2016/03/01 Codes

Source: Internet
Author: User

if (Deltaupper > 0) {
index = Upperindex;
while (Index < boundCount-1 && Bounds[index + 1].value <= uppervalue) {
bound = Bounds[index];
Nextbound = Bounds[index + 1];
Nextproxyid = Nextbound.proxyid;
Nextproxy = This.m_proxypool[nextproxyid];
nextbound.stabbingcount++;
if (nextbound.islower () = = True) {
if (this. Testoverlap (Newvalues,nextproxy))
{This.m_pairManager.AddBufferedPair (Proxyid,nextproxyid);}
Nextproxy.lowerbounds[axis]--;
Bound.stabbingcount + +;
}
Else{nextproxy.upperbounds[axis]--;bound.stabbingcount--;}
proxy.upperbounds[axis]++;
Bound. Swap (Nextbound);
Index + +;
}
if (Deltalower > 0) {
index = Lowerindex;
while (Index < boundCount-1 && Bounds[index + 1].value <= lowervalue) {
bounds = Bounds[index];
Nextbound = Bounds[index + 1];
Nextproxyid = Nextbound.proxyid;
Nextproxy = This.m_proxypool[proxyid];
Nextbound.stabbingcount--;
}
if (Nextbound.isupper ()) {
if (this. Testoverlap (Oldvalues,nextproxy)) {
This.m_pairManager.RemoveBufferedPair (Proxyid,nextproxyid);
}
nextproxy.upperbounds[axis]--;
Bound.stabbingcount--;
}
else{
nextproxy.lowerbounds[axis]--;
bound.stabbingcount++;
}
proxy.lowerbounds[axis]++;
Bound. Swap (nextbound); index++;
}
}
if (Deltaupper < 0) {
index = Upperindex;
while (Index > 0 && uppervalue < bounds[index-1].value) {
bound = Bounds[index];
Prevbound = Bounds[index-1];
Prevproxyid = Prevbound.proxyid;
Prevproxy = This.m_proxypool[index-1];
Prevbound.stabbingcount--;
if (prevbound.islower () = = True) {
if (This.overlapcount (Oldvalues,prevproxy)) {
This.m_pairManager.RemoveBufferedPair (Proxyid,prevproxyid);
}
prevproxy.lowerbounds[axis]--;
Bound.stabbingcount--;
}
else{
prevproxy.upperbounds[axis]++;bound.stabbingcount++;
}
Proxy.upperbounds[axis]--;bound. Swap (prevbound); index-;
}
}
}
Commit:function () {this.m_pairManager.Commit ();},
Queryaabb:function (Aabb,userdata,maxcount) {
var lowervalues = new Array ();
var uppervalues = new Array ();
This.computebounds (LOWERVALUES,UPPERVALUES,AABB);
var Lowerindex = 0;var Upperindex = 0;
var lowerindexout = [Lowerindex];
var upperindexout = [Upperindex];
This. Query (lowerindexout,upperindexout,lowervalues[0],uppervalues[0],this.m_bounds[0],2 * this.m_proxyCount,0);
This. Query (lowerindexout,upperindexout,lowervalues[1],uppervalues[1],this.m_bounds[1],2 * this.m_proxyCount,1);
var count = 0;
for (var i = 0;i < This.m_queryresultcount && Count < Maxcount;++i,++count) {
var proxy = this.m_proxypool[this.m_queryresults[i]];
Userdata[i] = Proxy.userdata;
}
This.m_queryresultcount = 0;this. Incrementtimestamp (); return count;
},
Validate:function () {var pair;var proxy1;var proxy2;var overlap;
for (var axis = 0;axis < 2;++axis) {var bounds = This.m_bounds[axis];
var boundcount = 2 * This.m_proxycount;var stabbingcount = 0;
for (var i = 0;i < Boundcount; ++i) {
var bound = bounds[i];
if (bound. Islower () = = True) {Stabbingcount + +;}
Else{stabbingcount--;}}},
Computebounds:function (Lowervalues,uppervalues,aabb) {
var Minvertexx = aabb.minvertex.x;
var minvertexy = aabb.minvertex.y;
Minvertexx = B2math.b2min (minvertexx,this.m_worldaabb.maxvertex.x);
Minvertexy = B2math.b2min (minvertexy,this.m_worldaabb.maxvertex.y);
Maxvertexx = B2math.b2min (minvertexx,this.m_worldaabb.minvertex.x);
Maxvertexy = B2math.b2min (minvertexy,this.m_worldaabb.minvertex.y);
var Maxvertexx = aabb.maxvertex.x;
var maxvertexy = aabb.maxvertex.y;
Maxvertexx = B2math.b2min (maxvertexx,this.m_worldaabb.maxvertex.x);
Maxvertexy = B2math.b2min (maxvertexx,this.m_worldaabb.maxvertex.y);
Maxvertexx = B2math.b2min (maxvertexx,this.m_worldaabb.minvertex.x);
Maxvertexy = B2math.b2min (maxvertexy,this.m_worldaabb.minvertex.y);
Lowervalues[0] = (this.m_quantizationfactor.x * (minvertexx-this.m_worldaabb.minvertex.x)) & (B2Settings.USHRT_ MAX-1);
Uppervalues[0] = (this.m_quantizationfactor.x * (maxvertexy-this.m_worldaabb.minvertex.x)) & 0x0000ffff) |
LOWERVALUES[1] = (THIS.M_QUANTIZATIONFACTOR.Y * (MINVERTEXX-THIS.M_WORLDAABB.MINVERTEX.Y)) & (B2Settins.USHRT_ MAX);
UPPERVALUES[1] = (THIS.M_QUANTIZATIONFACTOR.Y * (minvertexx-this.m_worldaabb.minvertex.y)) & 0x0000ffff) |
},
Testoverlapvalidate:function (P1,P2) {
for (var axis = 0;axis < 2;++axis) {
var bounds =this.m_bounds[axis];
if (Bounds[p1.lowrbounds[axis]].value > Bounds[p1.upperbounds[axis]].value)
return false;
if (Bounds[p1.upperbounds[axis]].value < Bounds[p1.lowerbounds[axis]].value)
return false;
}
return true;
},
Testoverlap:function (b,p) {
for (var axis = 0;axis < 2;axis + +) {
var bounds = This.m_bounds[axis];
if (B.lowervalues[axis] > Bounds[p.upperbounds[axis]].value)
return false;
if (B.uppervalues[axis] > Bounds[p.lowerbounds[axis]].value)
return false;
}
return true;
},
Query:function (Lowerqueryout,upperqueryout,lowervalue,uppervalue,bounds,boundscount,axis) {
var lowerqueryout = B2broadphase.binarysearch (Bounds,boundscount,lowervalue);
var upperqueryout = B2broadphase.binarysearch (Bounds,boundscount,lowervalue);
for (var j = Lowerquery;j < upperquery;j++) {
if (bounds. Islower ()) {this. Incrementoverlapcount (Bounds[j].proxyid);}
}
if (Lowerquery > 0) {
var i = lowerQuery-1;
var s = bounds.stabbingcount;
while (s) {
if (Bounds[i]. Islower ()) {
var proxy = This.m_proxypool[bounds[i].proxyid];
if (Lowerquery <= Proxy.upperbounds[axis]) {
This. Incrementoverlapcount (Bounds[i].proxyid);
--s;}}
-----;}}
Lowerqueryout[0] = lowerquery;
Upperqueryout[0] = upperquery;
},
Incrementoverlapcount:function (Proxyid) {
var proxy = This.m_proxypool[proxyid];
if (Proxy.timestamp < This.m_timestamp) {Proxy.timestamp = This.timestamp;proxy.overlapcount = 1;}
Else
{Proxy.overlapcount = 2;this.m_queryresults[this.m_queryresultcount] = Proxyid;
++this.m_queryresultcount;}
}
}
}
}
}

2016/03/01 Codes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.