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 (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 (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 >& Gt 4) & 0x0fffffff;x|= (x >> 8) &0x00ffffff;x|= (x >> +) & 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