Exemple #1
0
        public b2Joint CreateJoint(b2JointDef def)
        {
            global::System.IntPtr cPtr = Box2dPINVOKE.b2World_CreateJoint(swigCPtr, b2JointDef.getCPtr(def));
            b2Joint ret = (cPtr == global::System.IntPtr.Zero) ? null : new b2Joint(cPtr, false);

            return(ret);
        }
Exemple #2
0
    protected b2Joint(b2JointDef def)
    {
        Debug.Assert(def.bodyA != def.bodyB);

        m_type             = def.type;
        m_prev             = null;
        m_next             = null;
        m_bodyA            = def.bodyA;
        m_bodyB            = def.bodyB;
        m_index            = 0;
        m_collideConnected = def.collideConnected;
        m_islandFlag       = false;
        m_userData         = def.userData;

        m_edgeA.joint = null;
        m_edgeA.other = null;
        m_edgeA.prev  = null;
        m_edgeA.next  = null;

        m_edgeB.joint = null;
        m_edgeB.other = null;
        m_edgeB.prev  = null;
        m_edgeB.next  = null;
    }
Exemple #3
0
        public b2Joint CreateJoint(b2JointDef def)
        {
            if (IsLocked())
            {
                return(null);
            }

            b2Joint j = b2Joint.Create(def);

            // Connect to the world list.
            j.Prev = null;
            j.Next = m_jointList;
            if (m_jointList)
            {
                m_jointList.Prev = j;
            }
            m_jointList = j;
            ++m_jointCount;

            // Connect to the bodies' doubly linked lists.
            j.m_edgeA.joint = j;
            j.m_edgeA.other = j.m_bodyB;
            j.m_edgeA.prev  = null;
            j.m_edgeA.next  = j.m_bodyA.JointList;
            if (j.m_bodyA.JointList)
            {
                j.m_bodyA.JointList.prev = &j.m_edgeA;
            }
            j.m_bodyA.JointList = &j.m_edgeA;

            j.m_edgeB.joint = j;
            j.m_edgeB.other = j.m_bodyA;
            j.m_edgeB.prev  = null;
            j.m_edgeB.next  = j.m_bodyB.JointList;
            if (j.m_bodyB.JointList)
            {
                j.m_bodyB.JointList.prev = &j.m_edgeB;
            }
            j.m_bodyB.JointList = &j.m_edgeB;

            b2Body bodyA = def.bodyA;
            b2Body bodyB = def.bodyB;

            // If the joint prevents collisions, then flag any contacts for filtering.
            if (def.collideConnected == false)
            {
                b2ContactEdge edge = bodyB.ContactList;
                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);
        }
Exemple #4
0
    internal static b2Joint Create(b2JointDef def)
    {
        b2Joint joint = null;

        switch (def.type)
        {
        case b2JointType.e_distanceJoint:
        {
            joint = new b2DistanceJoint((b2DistanceJointDef)def);
        }
        break;

        case b2JointType.e_mouseJoint:
        {
            joint = new b2MouseJoint((b2MouseJointDef)def);
        }
        break;

        case b2JointType.e_prismaticJoint:
        {
            joint = new b2PrismaticJoint((b2PrismaticJointDef)def);
        }
        break;

        case b2JointType.e_revoluteJoint:
        {
            joint = new b2RevoluteJoint((b2RevoluteJointDef)def);
        }
        break;

        case b2JointType.e_pulleyJoint:
        {
            joint = new b2PulleyJoint((b2PulleyJointDef)def);
        }
        break;

        case b2JointType.e_gearJoint:
        {
            joint = new b2GearJoint((b2GearJointDef)def);
        }
        break;

        case b2JointType.e_wheelJoint:
        {
            joint = new b2WheelJoint((b2WheelJointDef)def);
        }
        break;

        case b2JointType.e_weldJoint:
        {
            joint = new b2WeldJoint((b2WeldJointDef)def);
        }
        break;

        case b2JointType.e_frictionJoint:
        {
            joint = new b2FrictionJoint((b2FrictionJointDef)def);
        }
        break;

        case b2JointType.e_ropeJoint:
        {
            joint = new b2RopeJoint((b2RopeJointDef)def);
        }
        break;

        case b2JointType.e_motorJoint:
        {
            joint = new b2MotorJoint((b2MotorJointDef)def);
        }
        break;

        default:
            Debug.Assert(false);
            break;
        }

        return(joint);
    }
Exemple #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2JointDef obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #6
0
        public b2Joint CreateJoint(b2JointDef def)
        {
            if (IsLocked())
            {
                return null;
            }

            b2Joint j = b2Joint.Create(def);

            // Connect to the world list.
            j.Prev = null;
            j.Next = m_jointList;
            if (m_jointList)
            {
                m_jointList.Prev = j;
            }
            m_jointList = j;
            ++m_jointCount;

            // Connect to the bodies' doubly linked lists.
            j.m_edgeA.joint = j;
            j.m_edgeA.other = j.m_bodyB;
            j.m_edgeA.prev = null;
            j.m_edgeA.next = j.m_bodyA.JointList;
            if (j.m_bodyA.JointList) j.m_bodyA.JointList.prev = &j.m_edgeA;
            j.m_bodyA.JointList = &j.m_edgeA;

            j.m_edgeB.joint = j;
            j.m_edgeB.other = j.m_bodyA;
            j.m_edgeB.prev = null;
            j.m_edgeB.next = j.m_bodyB.JointList;
            if (j.m_bodyB.JointList) j.m_bodyB.JointList.prev = &j.m_edgeB;
            j.m_bodyB.JointList = &j.m_edgeB;

            b2Body bodyA = def.bodyA;
            b2Body bodyB = def.bodyB;

            // If the joint prevents collisions, then flag any contacts for filtering.
            if (def.collideConnected == false)
            {
                b2ContactEdge edge = bodyB.ContactList;
                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;
        }