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));
     }
 }
Example #2
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();
        }
Example #3
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);
        }
Example #4
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);
     }
 }
Example #5
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);
        }
 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);
         }
     }
 }
Example #7
0
 public override void RemoveConstraint(TypedConstraint constraint)
 {
     m_constraints.Remove(constraint);
     constraint.GetRigidBodyA().RemoveConstraintRef(constraint);
     constraint.GetRigidBodyB().RemoveConstraintRef(constraint);
 }