码迷,mamicode.com
首页 > 其他好文 > 详细

2016/02/27 codes

时间:2016-02-27 23:22:58      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

b2Math.b2Abs = function(a){return a > 0.0 ? a : -a ;};
b2Math.b2AbsV = function(a){var b = new b2Vec2(b2Math.b2Abs(a.x),b2Math.b2Abs(a.y));return b};
b2Math.b2AbsM=function(A){var B=new b2Mat22(0,b2Math.b2AbsV(A.col1),b2Math.b2AbsV(A.col2));return B;};
b2Math.b2Min = function(a,b){return a > b ? a : b;};
b2Math.b2MinV = function(a,b){var c = new b2Vec2(b2Math.b2Min(a.x, b.x),b2Math.b2Min(a.y, b.y));return c;};
b2Math.b2Max = function(a,b){return a > b ? a : b;};
b2Math.b2MaxV = function(a,b){var c = new b2Vec2(b2Math.b2Max(a.x, b.x),b2Math.b2Max(a.y, b.y));return c;};
b2Math.b2Clamp = function(a,low,high){return b2Math.b2Max(low,b2Math.b2Min(a,high));};
b2Math.b2ClampV = function(a,low,high){return b2Math.b2MaxV(low,b2Math.b2MinV(a,high));};
b2Math.b2Swap = function(a,b){var tmp = a[0];a[0] = b[0];b[0] = tmp;};
b2Math.b2Random = function(){return Math.random() * 2 - 1;};
b2Math.b2NextPowerOfTwo = function(x){x|= (x >> 1) & 0x7FFFFFFF;x|= (x >> 2) & 0x3FFFFFFF;x|= (x >> 4) & 0x0FFFFFFF;x|= (x >> 8) &0x00FFFFFF;x|= (x >> 16) & 0x0000FFFF;};
b2Math.b2IsPowerOfTwo = function(x){var result = x > 0 && (x&(x - 1)) == 0;return result;};
b2Math.tempVec2 = new b2Vec2();
b2Math.tempVec3 = new b2Vec2();
b2Math.tempVec4 = new b2Vec2();
b2Math.tempVec5 = new b2Vec2();
b2Math.tempMat = new b2Matt22();
var b2AABB=Class.create();
b2AABB.prototype = {IsValid:function(){
var dX = this.maxVertex.x;
var dY = this.maxVertex.y;
dX = this.maxVertex.x;
dy = this.maxVertex.y;
dX -= this.minVertex.x;
dY -= this.minVertex.y;
var valid = dX > 0.0 && dY > 0.0;
valid = valid && this.minVertex.IsValid() && this.maxVertex.IsValid();
return valid;
},
minVertex :new b2Vec2(),maxVertex : new b2Vec2();
initialize:function(){this.minVertex = new b2Vec2();this.maxVertex = new b2Vec2();}
};
var b2Bound = Class.create();
b2Bound.prototype = {IsLower: function () {
return (this.value & 1) == 1
},
var tempProxyId = this.proxyId;
var tempStabbingCount = this.stabbingCount;
this.value = b.value;
this.proxyId = b.proxyId;
this.stabbingCount = b.stabbingCount;
b.value = tempValue;
b.proxyId = tempProxyId;
b.stabbingCount = tempStabbingCount;
},
proxyId:0,value:0,stabbingCount:0,initialize:function(){}
}
var b2BoundValues = Class.create();
b2BoundValues.prototype = {lowerValues:[0,0],upperValues:[0,0],
initialize:function(){this.lowerValues = [0,0];this.upperValues = [0,0];}}
var b2Pair =Class.create();
b2Pair.prototype = {
SetBuffered:function(){this.status|= b2Pair.e_pairBuffered;},
ClearBuffered:function(){this.status &=~b2Pair.e_pairBuffered;},
IsBuffered:function(){return (this.status & b2Pair.e_pairBuffered) == b2Pair.e_pairBuffered;},
SetRemoved:function(){this.status |= b2Pair.e_pairRemoved;},
ClearRemoved:function(){this.status &=~ b2Pair.e_pairRemoved;},
IsRemoved:function(){return (this.status & b2Pair.e_pairRemoved) == b2Pair.e_pairRemoved;},
SetFinal:function(){this.status |= b2Pair.e_pairFinal ;},
IsFinal:function(){return (this.status & b2Pair.e_pairFinal) == b2Pair.e_pairFinal;},
userData:0,proxyId1:0,proxyId2:0,next:0,status:0,
initialize:function(){}
};
b2Pair.b2_nullPair = b2Settins.USHRT_MAX;
b2Pair.b2_nullProxy = b2Settins.USHRT_MAX;
b2Pair.b2_tableCapacity = b2Settins.b2_maxPairs;
b2Pair.b2_tableMask = b2Pair.b2_tableCapacity - 1;
b2Pair.e_pairBuffered = 0x0001;
b2Pair.e_pairRemoved = 0x0002;
b2Pair.e_pairFinal = 0x0004;
var b2PairCallback = Class.create();
b2PairCallback.prototype = function(){
PairAdded:function(proxyUserData1,proxyUserData2){return null},
PairRemoved:function(pairUserData1,pairUserData2,pairUserData){},
initialize:function(){}
};
var b2BufferedPair = Class.create();
b2BufferedPair.protype = {proxyId1:0,proxyId2:0,initialize:function{}}

var b2PairManger = Class.create();
b2PairManger.prototype = {
initialize:function(){var i = 0;this.m_hashTable = new Array(b2Pair.b2_tableCapacity);
for( i = 0;i < b2Pair.b2_tableCapacity;++i){
this.m_hashTable[i] = b2Pair.b2_nullPair;
}
this.m_pairs = new Array(b2Settins.b2_maxPairs);
for( i = 0;i < b2Settins.b2_maxPairs;++i){this.m_pairs[i] = new b2Pair();}
this.m_pairBuffer = new Array(b2Settins.b2_maxPairs);
for(i = 0;i < b2Settins.b2_maxPairs;++i){this.m_pairBuffer[i] = new b2BufferedPair();}
for(i = 0;i < b2Settins.b2_maxPairs;++i){
this.m_pairs[i].proxyId1 = b2Pair.b2_nullPair;
this.m_pairs[i].proxyId2 = b2Pair.b2_nullPair;
this.m_pairs[i].Usetdata = null;
this.m_pairs[i].status = 0;
this.m_pairs[i].next = (i + 1);
this.m_pairs[b2Settins.b2_maxPairs - 1].next = b2Pair.b2_nullPair;
this.m_pairCount = 0;
},
initialize:function(broadPhase,callback){this.m_broadPhase = broadPhase;this.m_callback = callback},
AddBufferPair:function(proxyId1,proxyId2){
var Pair = this.AddPair(proxyId1,proxyId2);
if(pair.IsBuffered() == false){
pair.SetBuffered ();
this.m_pairBuffer[this.m_pairBufferCount].proxyId1 = pair.proxyId1;
this.m_pairBuffer[this.m_pairBufferCount].proxyId2=pair.proxyId2;++this.m_pairBufferCount;}
pair.ClearRemoved();
if(b2BroadPhase.s_validate){
this.validateBuffer();
}
},
RemovedBufferPair:function(proxyId2,proxyId2){
if(pair == null){return;}
if(pair.IsBuffered() == false ){
pair.SetBuffered();
this.m_pairBuffer[this.m_pairBufferCount].proxyId1 = pair.proxyId1;
this.m_pairBuffer[this.m_pairBufferCount].proxyId2 = pair.proxyId2;
++this.m_pairBufferCount;
}
pair.SetRemoved();
if(pair.IsBuffered () == false){
pair.SetBuffered();
this.m_pairBuffer[this.m_pairBufferCount].proxyId1 = pair.proxyId1;
this.m_pairBuffer[this.m_pairBufferCount].proxyId2 = pair.proxyId2;
}
}
}
}
}

2016/02/27 codes

标签:

原文地址:http://www.cnblogs.com/whatcanido/p/5223707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!