Beispiel #1
0
 private void RemoveAxisLockConstraint()
 {
     if (LockAxisConstraint != null)
     {
         m_physicsScene.Constraints.RemoveAndDestroyConstraint(LockAxisConstraint);
         LockAxisConstraint = null;
         m_physicsScene.DetailLog("{0},BSActorLockAxis.RemoveAxisLockConstraint,destroyingConstraint", m_controllingPrim.LocalID);
     }
 }
Beispiel #2
0
        public bool AddConstraint(BSConstraint cons)
        {
            lock (m_constraints)
            {
                // There is only one constraint between any bodies. Remove any old just to make sure.
                RemoveAndDestroyConstraint(cons.Body1, cons.Body2);

                m_constraints.Add(cons);
            }

            return(true);
        }
Beispiel #3
0
        // The constraint MUST exist in the collection
        // Could be called if the constraint was previously removed.
        // Return 'true' if the constraint was actually removed and disposed.
        public bool RemoveAndDestroyConstraint(BSConstraint constrain)
        {
            bool removed = false;

            lock (m_constraints)
            {
                // remove the constraint from our collection
                removed = m_constraints.Remove(constrain);
            }
            // Dispose() is safe to call multiple times
            constrain.Dispose();
            return(removed);
        }
Beispiel #4
0
        // Get the constraint between two bodies. There can be only one.
        // Return 'true' if a constraint was found.
        public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint)
        {
            bool         found           = false;
            BSConstraint foundConstraint = null;

            uint lookingID1 = body1.ID;
            uint lookingID2 = body2.ID;

            lock (m_constraints)
            {
                foreach (BSConstraint constrain in m_constraints)
                {
                    if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) ||
                        (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1))
                    {
                        foundConstraint = constrain;
                        found           = true;
                        break;
                    }
                }
            }
            returnConstraint = foundConstraint;
            return(found);
        }
Beispiel #5
0
 public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName)
     : base(physicsScene, pObj, actorName)
 {
     m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID);
     LockAxisConstraint = null;
 }