Aar0n 我可以说一下,例如,我用 关节连一个 链条, 用了五个rigibody 和 4个joint,然后我场景退出的时候,在销毁的时候,box2d.JS会报错,循环rigibody,销毁,然后到第五个rigibody,有句判断,是否有joint,,,,,没有就跑出错误,
box2d.b2World.prototype.DestroyJoint=function(a){
box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());
if(!this.IsLocked()){
var b=a.m_collideConnected;
a.m_prev&&(a.m_prev.m_next=a.m_next);
a.m_next&&(a.m_next.m_prev=a.m_prev);
a===this.m_jointList&&(this.m_jointList=a.m_next);
var c=a.m_bodyA,d=a.m_bodyB;c.SetAwake(!0);d.SetAwake(!0);
a.m_edgeA.prev&&(a.m_edgeA.prev.next=a.m_edgeA.next);
a.m_edgeA.next&&(a.m_edgeA.next.prev=a.m_edgeA.prev);
a.m_edgeA===c.m_jointList&&(c.m_jointList=a.m_edgeA.next);
a.m_edgeA.prev=null;
a.m_edgeA.next = null;
a.m_edgeB.prev && (a.m_edgeB.prev.next = a.m_edgeB.next);
a.m_edgeB.next && (a.m_edgeB.next.prev = a.m_edgeB.prev);
a.m_edgeB === d.m_jointList && (d.m_jointList = a.m_edgeB.next);
a.m_edgeB.prev = null;
a.m_edgeB.next = null;
box2d.DEBUG = false;
box2d.b2JointFactory.Destroy(a, null);
box2d.ENABLE_ASSERTS && box2d.b2Assert(0 < this.m_jointCount);
--this.m_jointCount;
if (!b)
for (a = d.GetContactList(); a;)
a.other === c && a.contact.FlagForFiltering(), a = a.next
}
};
box2d.b2Assert=function(a,b,c){
if (box2d.DEBUG && !a) {console.log(box2d.DEBUG); console.log(a); throw Error() } else { };
};