Example #1
0
        protected Joint(JointDef def)
        {
            //Debug.Assert(def.bodyA != def.bodyB);

            _type             = def.type;
            _bodyA            = def.bodyA;
            _bodyB            = def.bodyB;
            _collideConnected = def.collideConnected;
            _userData         = def.userData;

            _edgeA = new JointEdge();
            _edgeB = new JointEdge();
        }
Example #2
0
		protected Joint(JointDef def){
			Utilities.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 = new List<JointEdge>();
			m_edgeB = new List<JointEdge>();
		}
Example #3
0
        protected Joint(JointDef def)
        {
            Utilities.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 = new List <JointEdge>();
            m_edgeB = new List <JointEdge>();
        }
Example #4
0
        /// 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.
        public Joint CreateJoint(JointDef def)
        {
            Utilities.Assert(IsLocked() == false);
            if (IsLocked())
            {
                return(null);
            }

            Joint j = Joint.Create(def);

            // Connect to the world list.
            m_jointList.Add(j);

            // Connect to the bodies' doubly linked lists.
            j.m_edgeA.Clear();
            j.m_edgeA.Add(new JointEdge(j, j.m_bodyB));

            j.m_edgeA.AddRange(j.m_bodyA.m_jointList);
            j.m_bodyA.m_jointList = j.m_edgeA;

            j.m_edgeB.Clear();
            j.m_edgeB.Add(new JointEdge(j, j.m_bodyA));
            j.m_edgeB.AddRange(j.m_bodyB.m_jointList);
            j.m_bodyB.m_jointList = j.m_edgeB;

            Body bodyA = def.bodyA;
            Body bodyB = def.bodyB;

            // If the joint prevents collisions, then flag any contacts for filtering.
            if (def.collideConnected == false)
            {
                foreach (ContactEdge edge in bodyB.GetContactList())
                {
                    if (edge.other == bodyA)
                    {
                        // Flag the contact for filtering at the next time step (where either
                        // body is awake).
                        edge.contact.FlagForFiltering();
                    }
                }
            }

            // Note: creating a joint doesn't wake the bodies.

            return(j);
        }
Example #5
0
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.Distance:
            {
                joint = new DistanceJoint((DistanceJointDef)def);
            }
            break;

            case JointType.Mouse:
            {
                joint = new MouseJoint((MouseJointDef)def);
            }
            break;

            case JointType.Prismatic:
            {
                joint = new PrismaticJoint((PrismaticJointDef)def);
            }
            break;

            case JointType.Revolute:
            {
                joint = new RevoluteJoint((RevoluteJointDef)def);
            }
            break;

            case JointType.Pulley:
            {
                joint = new PulleyJoint((PulleyJointDef)def);
            }
            break;

            case JointType.Gear:
            {
                joint = new GearJoint((GearJointDef)def);
            }
            break;

            case JointType.Line:
            {
                joint = new LineJoint((LineJointDef)def);
            }
            break;

            case JointType.Weld:
            {
                joint = new WeldJoint((WeldJointDef)def);
            }
            break;

            case JointType.Friction:
            {
                joint = new FrictionJoint((FrictionJointDef)def);
            }
            break;

            case JointType.MaxDistance:
            {
                joint = new MaxDistanceJoint((MaxDistanceJointDef)def);
            }
            break;

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

            return(joint);
        }
Example #6
0
		internal static Joint Create(JointDef def){
			Joint joint = null;

			switch (def.type)
			{
			case JointType.e_distanceJoint:
			    {
					joint = new DistanceJoint((DistanceJointDef)def);
			    }
			    break;

			case JointType.e_mouseJoint:
			    {
			        joint = new MouseJoint((MouseJointDef)def);
			    }
			    break;

			case JointType.e_prismaticJoint:
			    {
			        joint = new PrismaticJoint((PrismaticJointDef)def);
			    }
			    break;

			case JointType.e_revoluteJoint:
			    {
					joint = new RevoluteJoint((RevoluteJointDef)def);
			    }
			    break;

			case JointType.e_pulleyJoint:
			    {
					joint = new PulleyJoint((PulleyJointDef)def);
			    }
			    break;

			case JointType.e_gearJoint:
			    {
					joint = new GearJoint((GearJointDef)def);
			    }
			    break;

			case JointType.e_wheelJoint:
			    {
					joint = new WheelJoint((WheelJointDef)def);
			    }
			    break;

			case JointType.e_weldJoint:
			    {
					joint = new WeldJoint((WeldJointDef)def);
			    }
			    break;
        
			case JointType.e_frictionJoint:
			    {
			        joint = new FrictionJoint((FrictionJointDef)def);
			    }
			    break;

			case JointType.e_ropeJoint:
			    {
					throw new NotImplementedException();
					//joint = new RopeJoint((RopeJointDef)def);
			    }
			    break;

			case JointType.e_motorJoint:
			    {
			        joint = new MotorJoint((MotorJointDef)def);
			    }
			    break;

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

			return joint;
		}
Example #7
0
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.e_distanceJoint:
            {
                joint = new DistanceJoint((DistanceJointDef)def);
            }
            break;

            case JointType.e_mouseJoint:
            {
                joint = new MouseJoint((MouseJointDef)def);
            }
            break;

            case JointType.e_prismaticJoint:
            {
                joint = new PrismaticJoint((PrismaticJointDef)def);
            }
            break;

            case JointType.e_revoluteJoint:
            {
                joint = new RevoluteJoint((RevoluteJointDef)def);
            }
            break;

            case JointType.e_pulleyJoint:
            {
                joint = new PulleyJoint((PulleyJointDef)def);
            }
            break;

            case JointType.e_gearJoint:
            {
                joint = new GearJoint((GearJointDef)def);
            }
            break;

            case JointType.e_wheelJoint:
            {
                joint = new WheelJoint((WheelJointDef)def);
            }
            break;

            case JointType.e_weldJoint:
            {
                joint = new WeldJoint((WeldJointDef)def);
            }
            break;

            case JointType.e_frictionJoint:
            {
                joint = new FrictionJoint((FrictionJointDef)def);
            }
            break;

            case JointType.e_ropeJoint:
            {
                throw new NotImplementedException();
                //joint = new RopeJoint((RopeJointDef)def);
            }
            break;

            case JointType.e_motorJoint:
            {
                joint = new MotorJoint((MotorJointDef)def);
            }
            break;

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

            return(joint);
        }
Example #8
0
		/// 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.
		public Joint CreateJoint(JointDef def){
			Utilities.Assert(IsLocked() == false);
			if (IsLocked())
			{
			    return null;
			}

			Joint j = Joint.Create(def);

			// Connect to the world list.
			m_jointList.Add(j);

			// Connect to the bodies' doubly linked lists.
			j.m_edgeA.Clear();
			j.m_edgeA.Add(new JointEdge(j, j.m_bodyB));

			j.m_edgeA.AddRange(j.m_bodyA.m_jointList);
			j.m_bodyA.m_jointList = j.m_edgeA;

			j.m_edgeB.Clear();
			j.m_edgeB.Add(new JointEdge(j, j.m_bodyA));
			j.m_edgeB.AddRange(j.m_bodyB.m_jointList);
			j.m_bodyB.m_jointList = j.m_edgeB;

			Body bodyA = def.bodyA;
			Body bodyB = def.bodyB;

			// If the joint prevents collisions, then flag any contacts for filtering.
			if (def.collideConnected == false)
			{
				foreach (ContactEdge edge in bodyB.GetContactList())
			    {
			        if (edge.other == bodyA)
			        {
			            // Flag the contact for filtering at the next time step (where either
			            // body is awake).
			            edge.contact.FlagForFiltering();
			        }
			    }
			}

			// Note: creating a joint doesn't wake the bodies.

			return j;
		}
Example #9
0
        /// Create a joint to rain 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.
        public Joint CreateJoint(JointDef def)
        {
            //Debug.Assert(!IsLocked);
            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.bodyA;
            Body bodyB = def.bodyB;

            bool staticA = bodyA.GetType() == BodyType.Static;
            bool staticB = bodyB.GetType() == BodyType.Static;

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