Example #1
0
        ///<summary>
        /// Updates the manifold.
        ///</summary>
        ///<param name="dt">Timestep duration.</param>
        public override void Update(float dt)
        {
            ContactData contactData;
            bool        colliding = false;

            if (SphereTester.AreSpheresColliding(sphereA.Shape, sphereB.Shape, ref sphereA.worldTransform.Position,
                                                 ref sphereB.worldTransform.Position, out contactData))
            {
                if (!previouslyColliding && contactData.PenetrationDepth >= 0
                    ) //Don't use the contact if it's an initial contact and the depth is negative.  Why not? Bounciness and InitialCollisionDetected.
                {
                    Add(ref contactData);
                    colliding = true;
                }
                else if (previouslyColliding)
                {
                    contactData.Validate();
                    contact.Normal           = contactData.Normal;
                    contact.PenetrationDepth = contactData.PenetrationDepth;
                    contact.Position         = contactData.Position;
                    colliding = true;
                }
            }
            else
            {
                if (previouslyColliding)
                {
                    Remove(0);
                }
            }

            previouslyColliding = colliding;
        }
Example #2
0
 public List <int> CollectSphere(BoundingSphere sphere)
 {
     ReturnTriangles.Clear();
     if (Bounds.Overlaps(ref sphere, 0))
     {
         SphereTester rt = new SphereTester();
         rt.sphere = sphere;
         TraverseNode(0, ref Bounds, rt);
     }
     return(ReturnTriangles);
 }
Example #3
0
 public List<int> CollectSphere(BoundingSphere sphere)
 {
   ReturnTriangles.Clear();
   if (Bounds.Overlaps(ref sphere, 0))
   {
     SphereTester rt = new SphereTester();
     rt.sphere = sphere;
     TraverseNode(0, ref Bounds, rt);
   }
   return ReturnTriangles;
 }