Ejemplo n.º 1
0
        public virtual void CalculateSimulationIslands()
        {
            BulletGlobals.StartProfile("calculateSimulationIslands");

            GetSimulationIslandManager().UpdateActivationState(GetCollisionWorld(), GetCollisionWorld().GetDispatcher());
            {
                int length = m_constraints.Count;
                for (int i = 0; i < length; ++i)
                {
                    TypedConstraint constraint = m_constraints[i];
                    RigidBody       colObj0    = constraint.GetRigidBodyA();
                    RigidBody       colObj1    = constraint.GetRigidBodyB();

                    if (((colObj0 != null) && (!colObj0.IsStaticOrKinematicObject())) &&
                        ((colObj1 != null) && (!colObj1.IsStaticOrKinematicObject())))
                    {
                        if (colObj0.IsActive() || colObj1.IsActive())
                        {
                            GetSimulationIslandManager().GetUnionFind().Unite((colObj0).GetIslandTag(),
                                                                              (colObj1).GetIslandTag());
                        }
                    }
                }
            }

            //Store the island id in each body
            GetSimulationIslandManager().StoreIslandActivationState(GetCollisionWorld());
            BulletGlobals.StopProfile();
        }
Ejemplo n.º 2
0
        public override void DebugDrawWorld()
        {
            BulletGlobals.StartProfile("debugDrawWorld");

            base.DebugDrawWorld();

            if (GetDebugDrawer() != null)
            {
                DebugDrawModes mode = GetDebugDrawer().GetDebugMode();
                if ((mode & (DebugDrawModes.DBG_DrawConstraints | DebugDrawModes.DBG_DrawConstraintLimits)) != 0)
                {
                    for (int i = GetNumConstraints() - 1; i >= 0; i--)
                    {
                        TypedConstraint constraint = GetConstraint(i);
                        DrawHelper.DebugDrawConstraint(constraint, GetDebugDrawer());
                    }
                }
                if (mode != 0)
                {
                    int actionsCount = m_actions.Count;
                    for (int i = 0; i < actionsCount; ++i)
                    {
                        m_actions[i].DebugDraw(m_debugDrawer);
                    }
                }
            }

            BulletGlobals.StopProfile();
        }
Ejemplo n.º 3
0
        public void AddConstraintRef(TypedConstraint c)
        {
            if (!m_constraintRefs.Contains(c))
            {
                m_constraintRefs.Add(c);
            }

            m_checkCollideWith = true;
        }
Ejemplo n.º 4
0
        public static int GetConstraintIslandId(TypedConstraint lhs)
        {
            int             islandId;
            CollisionObject rcolObj0 = lhs.GetRigidBodyA();
            CollisionObject rcolObj1 = lhs.GetRigidBodyB();

            islandId = rcolObj0.GetIslandTag() >= 0 ? rcolObj0.GetIslandTag() : rcolObj1.GetIslandTag();
            return(islandId);
        }
Ejemplo n.º 5
0
 public static void PrintInfo1(StreamWriter writer, TypedConstraint constraint, ConstraintInfo1 info)
 {
     if (writer != null)
     {
         writer.WriteLine("getInfo1 [{0}] [{1}] [{2}] [{3}]", constraint.m_userConstraintId, constraint.GetObjectType(), (string)constraint.GetRigidBodyA().GetUserPointer(), (string)constraint.GetRigidBodyB().GetUserPointer());
         MathUtil.PrintMatrix(writer, "rBA cmot", constraint.GetRigidBodyA().GetCenterOfMassTransform());
         MathUtil.PrintMatrix(writer, "rBB cmot", constraint.GetRigidBodyB().GetCenterOfMassTransform());
         MathUtil.PrintMatrix(writer, "rBA inv tensor", constraint.GetRigidBodyA().GetInvInertiaTensorWorld());
         MathUtil.PrintMatrix(writer, "rBB inv tensor", constraint.GetRigidBodyB().GetInvInertiaTensorWorld());
         writer.WriteLine(String.Format("NumRows [{0}] Nub[{1}]", info.m_numConstraintRows, info.nub));
     }
 }
Ejemplo n.º 6
0
 public override void AddConstraint(TypedConstraint constraint, bool disableCollisionsBetweenLinkedBodies)
 {
     //if (constraint is ConeTwistConstraint)
     //if (constraint is HingeConstraint)
     //{
     //    return;
     //}
     m_constraints.Add(constraint);
     if (disableCollisionsBetweenLinkedBodies)
     {
         constraint.GetRigidBodyA().AddConstraintRef(constraint);
         constraint.GetRigidBodyB().AddConstraintRef(constraint);
     }
 }
Ejemplo n.º 7
0
 public static void PrintInfo2(StreamWriter writer, TypedConstraint constraint, ConstraintInfo2 info2)
 {
     if (writer != null)
     {
         writer.WriteLine(String.Format("getInfo2 [{0}] [{1}] [{2}] [{3}]", constraint.m_userConstraintId, constraint.GetObjectType(), (string)constraint.GetRigidBodyA().GetUserPointer(), (string)constraint.GetRigidBodyB().GetUserPointer()));
         writer.WriteLine(String.Format("numRows [{0}] fps[{1:0.00000000}] erp[{2:0.00000000}] findex[{3}] numIter[{4}]", info2.m_numRows, info2.fps, info2.erp, info2.findex, info2.m_numIterations));
         for (int i = 0; i < info2.m_numRows; ++i)
         {
             writer.WriteLine(String.Format("TypedConstraint[{0}]", i));
             writer.WriteLine("ContactNormal");
             MathUtil.PrintVector3(writer, info2.m_solverConstraints[i].m_contactNormal);
             writer.WriteLine("rel1pos1CrossNormal");
             MathUtil.PrintVector3(writer, info2.m_solverConstraints[i].m_relpos1CrossNormal);
             writer.WriteLine("rel1pos2CrossNormal");
             MathUtil.PrintVector3(writer, info2.m_solverConstraints[i].m_relpos2CrossNormal);
         }
     }
 }
Ejemplo n.º 8
0
        public override bool CheckCollideWithOverride(CollisionObject co)
        {
            RigidBody otherRb = RigidBody.Upcast(co);

            if (otherRb == null)
            {
                return(true);
            }

            for (int i = 0; i < m_constraintRefs.Count; ++i)
            {
                TypedConstraint c = m_constraintRefs[i];
                if (c.IsEnabled())
                {
                    if (c.GetRigidBodyA() == otherRb || c.GetRigidBodyB() == otherRb)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
 public void RemoveConstraintRef(TypedConstraint c)
 {
     m_constraintRefs.Remove(c);
     m_checkCollideWith = m_constraintRefs.Count > 0;
 }
Ejemplo n.º 10
0
 public virtual void     RemoveConstraint(TypedConstraint constraint)
 {
     //(void)constraint;
 }
Ejemplo n.º 11
0
 public virtual void     AddConstraint(TypedConstraint constraint, bool disableCollisionsBetweenLinkedBodies)
 {
     //(void)constraint;
     //(void)disableCollisionsBetweenLinkedBodies;
 }
Ejemplo n.º 12
0
 public virtual void AddConstraint(TypedConstraint constraint)
 {
     AddConstraint(constraint, false);
 }
Ejemplo n.º 13
0
 public override void RemoveConstraint(TypedConstraint constraint)
 {
     m_constraints.Remove(constraint);
     constraint.GetRigidBodyA().RemoveConstraintRef(constraint);
     constraint.GetRigidBodyB().RemoveConstraintRef(constraint);
 }