Exemplo n.º 1
0
        public void AddConstraint(HkConstraint constraint)
        {
            Debug.Assert(!m_constraints.Contains(constraint), "Constraint added twice");

            Debug.Assert(m_world.RigidBodies.Contains(constraint.RigidBodyA), "Object must be in the world");
            Debug.Assert(m_world.RigidBodies.Contains(constraint.RigidBodyB), "Object must be in the world");
            Debug.Assert(constraint.RigidBodyA.IsAddedToWorld);
            Debug.Assert(constraint.RigidBodyB.IsAddedToWorld);
            m_constraints.Add(constraint);

            m_world.AddConstraint(constraint);

            constraint.OnAddedToWorld();
        }
Exemplo n.º 2
0
        public void AddConstraint(HkConstraint constraint)
        {
            if (IsWelded)
            {
                WeldInfo.Parent.AddConstraint(constraint);
                return;
            }
            if (HavokWorld == null || RigidBody == null)
                return;
            if (constraint.UserData == 0)
                constraint.UserData = (uint)(WeldedRigidBody == null ? RigidBody.GetGcRoot() : WeldedRigidBody.GetGcRoot());

            Debug.Assert(!m_constraints.Contains(constraint), "Constraint added twice");

            Debug.Assert(HavokWorld.RigidBodies.Contains(constraint.RigidBodyA), "Object must be in the world");
            Debug.Assert(HavokWorld.RigidBodies.Contains(constraint.RigidBodyB), "Object must be in the world");
            Debug.Assert(constraint.RigidBodyA.IsAddedToWorld);
            Debug.Assert(constraint.RigidBodyB.IsAddedToWorld);
            m_constraints.Add(constraint);

            HavokWorld.AddConstraint(constraint);

            if (constraint.InWorld)
                constraint.OnAddedToWorld();
            else
                Debug.Fail("Constraint not added!");
        }