internal static Joint Create(JointDef def) { Joint result = null; switch (def.Type) { case JointType.RevoluteJoint: { result = new RevoluteJoint((RevoluteJointDef)def); break; } case JointType.PrismaticJoint: { result = new PrismaticJoint((PrismaticJointDef)def); break; } case JointType.DistanceJoint: { result = new DistanceJoint((DistanceJointDef)def); break; } case JointType.PulleyJoint: { result = new PulleyJoint((PulleyJointDef)def); break; } case JointType.MouseJoint: { result = new MouseJoint((MouseJointDef)def); break; } case JointType.GearJoint: { result = new GearJoint((GearJointDef)def); break; } case JointType.LineJoint: { result = new LineJoint((LineJointDef)def); break; } default: { Box2DXDebug.Assert(false); break; } } return(result); }
protected Joint(JointDef def) { this._type = def.Type; this._prev = null; this._next = null; this._body1 = def.Body1; this._body2 = def.Body2; this._collideConnected = def.CollideConnected; this._islandFlag = false; this._userData = def.UserData; }
protected Joint(JointDef def) { _type = def.Type; _prev = null; _next = null; _body1 = def.Body1; _body2 = def.Body2; _collideConnected = def.CollideConnected; _islandFlag = false; _userData = def.UserData; }
internal static Joint Create(JointDef def) { Joint joint = null; switch (def.Type) { case JointType.DistanceJoint: { joint = new DistanceJoint((DistanceJointDef)def); } break; case JointType.MouseJoint: { joint = new MouseJoint((MouseJointDef)def); } break; case JointType.PrismaticJoint: { joint = new PrismaticJoint((PrismaticJointDef)def); } break; case JointType.RevoluteJoint: { joint = new RevoluteJoint((RevoluteJointDef)def); } break; case JointType.PulleyJoint: { joint = new PulleyJoint((PulleyJointDef)def); } break; case JointType.GearJoint: { joint = new GearJoint((GearJointDef)def); } break; default: Box2DXDebug.Assert(false); break; } return(joint); }
protected Joint(JointDef def) { _type = def.Type; _prev = null; _next = null; _bodyA = def.Body1; _bodyB = def.Body2; _collideConnected = def.CollideConnected; _islandFlag = false; _userData = def.UserData; _edgeA.Joint = null; _edgeA.Other = null; _edgeA.Prev = null; _edgeA.Next = null; _edgeB.Joint = null; _edgeB.Other = null; _edgeB.Prev = null; _edgeB.Next = null; }
internal static Joint Create(JointDef def) { Joint result = null; switch (def.Type) { case JointType.RevoluteJoint: { result = new RevoluteJoint((RevoluteJointDef)def); break; } case JointType.PrismaticJoint: { result = new PrismaticJoint((PrismaticJointDef)def); break; } case JointType.DistanceJoint: { result = new DistanceJoint((DistanceJointDef)def); break; } case JointType.PulleyJoint: { result = new PulleyJoint((PulleyJointDef)def); break; } case JointType.MouseJoint: { result = new MouseJoint((MouseJointDef)def); break; } case JointType.GearJoint: { result = new GearJoint((GearJointDef)def); break; } case JointType.LineJoint: { result = new LineJoint((LineJointDef)def); break; } default: { Box2DXDebug.Assert(false); break; } } return result; }
/// <summary> /// Create a joint to constrain bodies together. No reference to the definition /// is retained. This may cause the connected bodies to cease colliding. /// @warning This function is locked during callbacks. /// </summary> /// <param name="def"></param> /// <returns></returns> public Joint CreateJoint(JointDef def) { Box2DXDebug.Assert(_lock == false); Joint j = Joint.Create(def); // Connect to the world list. j._prev = null; j._next = _jointList; if (_jointList != null) { _jointList._prev = j; } _jointList = j; ++_jointCount; // Connect to the bodies' doubly linked lists. j._node1.Joint = j; j._node1.Other = j._body2; j._node1.Prev = null; j._node1.Next = j._body1._jointList; if (j._body1._jointList != null) j._body1._jointList.Prev = j._node1; j._body1._jointList = j._node1; j._node2.Joint = j; j._node2.Other = j._body1; j._node2.Prev = null; j._node2.Next = j._body2._jointList; if (j._body2._jointList != null) j._body2._jointList.Prev = j._node2; j._body2._jointList = j._node2; // If the joint prevents collisions, then reset collision filtering. if (def.CollideConnected == false) { // Reset the proxies on the body with the minimum number of shapes. Body b = def.Body1._shapeCount < def.Body2._shapeCount ? def.Body1 : def.Body2; for (Shape s = b._shapeList; s != null; s = s._next) { s.RefilterProxy(_broadPhase, b.GetXForm()); } } return j; }
public Joint CreateJoint(JointDef def) { Box2DXDebug.Assert(!this._lock); Joint joint = Joint.Create(def); joint._prev = null; joint._next = this._jointList; if (this._jointList != null) { this._jointList._prev = joint; } this._jointList = joint; this._jointCount++; joint._node1.Joint = joint; joint._node1.Other = joint._body2; joint._node1.Prev = null; joint._node1.Next = joint._body1._jointList; if (joint._body1._jointList != null) { joint._body1._jointList.Prev = joint._node1; } joint._body1._jointList = joint._node1; joint._node2.Joint = joint; joint._node2.Other = joint._body1; joint._node2.Prev = null; joint._node2.Next = joint._body2._jointList; if (joint._body2._jointList != null) { joint._body2._jointList.Prev = joint._node2; } joint._body2._jointList = joint._node2; if (!def.CollideConnected) { Body body = (def.Body1._shapeCount < def.Body2._shapeCount) ? def.Body1 : def.Body2; for (Shape shape = body._shapeList; shape != null; shape = shape._next) { shape.RefilterProxy(this._broadPhase, body.GetXForm()); } } return joint; }
/// <summary> /// Create a joint to constrain bodies together. No reference to the definition /// is retained. This may cause the connected bodies to cease colliding. /// @warning This function is locked during callbacks. /// </summary> /// <param name="def"></param> /// <returns></returns> public Joint CreateJoint(JointDef def) { Box2DXDebug.Assert(IsLocked() == false); if (IsLocked()) { return(null); } Joint j = Joint.Create(def); // Connect to the world list. j._prev = null; j._next = _jointList; if (_jointList != null) { _jointList._prev = j; } _jointList = j; ++_jointCount; // Connect to the bodies' doubly linked lists. j._edgeA.Joint = j; j._edgeA.Other = j._bodyB; j._edgeA.Prev = null; j._edgeA.Next = j._bodyA._jointList; if (j._bodyA._jointList != null) { j._bodyA._jointList.Prev = j._edgeA; } j._bodyA._jointList = j._edgeA; j._edgeB.Joint = j; j._edgeB.Other = j._bodyA; j._edgeB.Prev = null; j._edgeB.Next = j._bodyB._jointList; if (j._bodyB._jointList != null) { j._bodyB._jointList.Prev = j._edgeB; } j._bodyB._jointList = j._edgeB; Body bodyA = def.Body1; Body bodyB = def.Body2; bool staticA = bodyA.IsStatic(); bool staticB = bodyB.IsStatic(); // If the joint prevents collisions, then flag any contacts for filtering. if (def.CollideConnected == false && (staticA == false || staticB == false)) { // Ensure we iterate over contacts on a dynamic body (usually have less contacts // than a static body). Ideally we will have a contact count on both bodies. if (staticB) { Math.Swap(ref bodyA, ref bodyB); } ContactEdge edge = bodyB.GetContactList(); while (edge != null) { if (edge.Other == bodyA) { // Flag the contact for filtering at the next time step (where either // body is awake). edge.Contact.FlagForFiltering(); } edge = edge.Next; } } // Note: creating a joint doesn't wake the bodies. return(j); }
/// <summary> /// Create a joint to constrain bodies together. No reference to the definition /// is retained. This may cause the connected bodies to cease colliding. /// @warning This function is locked during callbacks. /// </summary> /// <param name="def"></param> /// <returns></returns> public Joint CreateJoint(JointDef def) { Box2DXDebug.Assert(IsLocked() == false); if (IsLocked()) { return null; } Joint j = Joint.Create(def); // Connect to the world list. j._prev = null; j._next = _jointList; if (_jointList != null) { _jointList._prev = j; } _jointList = j; ++_jointCount; // Connect to the bodies' doubly linked lists. j._edgeA.Joint = j; j._edgeA.Other = j._bodyB; j._edgeA.Prev = null; j._edgeA.Next = j._bodyA._jointList; if (j._bodyA._jointList != null) j._bodyA._jointList.Prev = j._edgeA; j._bodyA._jointList = j._edgeA; j._edgeB.Joint = j; j._edgeB.Other = j._bodyA; j._edgeB.Prev = null; j._edgeB.Next = j._bodyB._jointList; if (j._bodyB._jointList != null) j._bodyB._jointList.Prev = j._edgeB; j._bodyB._jointList = j._edgeB; Body bodyA = def.Body1; Body bodyB = def.Body2; bool staticA = bodyA.IsStatic(); bool staticB = bodyB.IsStatic(); // If the joint prevents collisions, then flag any contacts for filtering. if (def.CollideConnected == false && (staticA == false || staticB == false)) { // Ensure we iterate over contacts on a dynamic body (usually have less contacts // than a static body). Ideally we will have a contact count on both bodies. if (staticB) { Math.Swap(ref bodyA, ref bodyB); } ContactEdge edge = bodyB.GetContactList(); while (edge != null) { if (edge.Other == bodyA) { // Flag the contact for filtering at the next time step (where either // body is awake). edge.Contact.FlagForFiltering(); } edge = edge.Next; } } // Note: creating a joint doesn't wake the bodies. return j; }