/** Adds a joint to the physics world.*/ public virtual void AddJoint(CCPhysicsJoint joint) { if (joint.GetWorld() != null && joint.GetWorld() != this) { joint.RemoveFormWorld(); } AddJointOrDelay(joint); _joints.Add(joint); joint._world = this; }
/** Remove a joint from physics world.*/ public virtual void RemoveJoint(CCPhysicsJoint joint, bool destroy = true) { if (joint.GetWorld() != this) { if (destroy) { cp.AssertWarn("physics warnning: the joint is not in this world, it won't be destoried utill the body it conntect is destoried"); } return; } RemoveJointOrDelay(joint); _joints.Remove(joint); joint._world = null; // clean the connection to this joint if (destroy) { if (joint.GetBodyA() != null) { joint.GetBodyA().RemoveJoint(joint); } if (joint.GetBodyB() != null) { joint.GetBodyB().RemoveJoint(joint); } // test the distraction is delaied or not if (_delayRemoveJoints.Exists(j => j == joint)) { joint._destoryMark = true; } } }