public void TestTouchingContact()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1.5f, 0, 0));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);

            Assert.AreEqual(objectA, cs.ObjectA);
            Assert.AreEqual(objectB, cs.ObjectB);
            Assert.AreEqual(1, cs.Count);
            Assert.AreEqual(new Vector3F(1, 0, 0), cs[0].Position);
            Assert.AreEqual(new Vector3F(1, 0, 0), cs[0].Normal);
            Assert.IsTrue(Numeric.AreEqual(0, cs[0].PenetrationDepth));
        }
        public void TestContainment2()
        {
            // Second sphere is within first sphere on same position.

            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);

            Assert.AreEqual(1, cs.Count);
            Assert.AreEqual(new Vector3F(1, 1.25f, 1), cs[0].Position);
            Assert.AreEqual(new Vector3F(0, 1, 0), cs[0].Normal);
            Assert.IsTrue(Numeric.AreEqual(1.5f, cs[0].PenetrationDepth));
        }
        public void TestInterpenetration2()
        {
            // Center of the second sphere is within the first sphere.

            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0.75f));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);

            Assert.AreEqual(1, cs.Count);
            Assert.AreEqual(new Vector3F(0, 0, 0.625f), cs[0].Position);
            Assert.AreEqual(new Vector3F(0, 0, 1), cs[0].Normal);
            Assert.IsTrue(Numeric.AreEqual(0.75f, cs[0].PenetrationDepth));
        }
示例#4
0
        public void TestArgumentException1()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              CollisionObject objectB = new CollisionObject();
              ContactSet cs = ContactSet.Create(objectA, objectB);

              algo.UpdateContacts(cs, 0);
        }
        public void TestArgumentException1()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();
            CollisionObject objectB = new CollisionObject();
            ContactSet      cs      = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);
        }
示例#6
0
        public void TestArgumentException3()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(1);

              ContactSet cs = ContactSet.Create(objectA, objectB);
              algo.UpdateContacts(cs, 0);
        }
        public void TestArgumentException3()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(1);

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);
        }
        public void TestZeroSphere1()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(0);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 2f, 0));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);

            Assert.AreEqual(0, cs.Count);
        }
示例#9
0
        public void HaveContact()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));

              Assert.AreEqual(true, algo.HaveContact(objectA, objectB));

              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 2.5f));
              Assert.AreEqual(true, algo.HaveContact(objectA, objectB));

              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 2.6f));
              Assert.AreEqual(false, algo.HaveContact(objectA, objectB));
        }
        public void HaveContact()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 1));

            Assert.AreEqual(true, algo.HaveContact(objectA, objectB));

            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 2.5f));
            Assert.AreEqual(true, algo.HaveContact(objectA, objectB));

            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1, 1, 2.6f));
            Assert.AreEqual(false, algo.HaveContact(objectA, objectB));
        }
示例#11
0
        public void TestContainment1()
        {
            // Second sphere is within first sphere.

              SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0.5f));

              ContactSet cs = ContactSet.Create(objectA, objectB);

              algo.UpdateContacts(cs, 0);

              Assert.AreEqual(1, cs.Count);
              Assert.AreEqual(new Vector3F(0, 0, 0.5f), cs[0].Position);
              Assert.AreEqual(new Vector3F(0, 0, 1), cs[0].Normal);
              Assert.IsTrue(Numeric.AreEqual(1, cs[0].PenetrationDepth));
        }
        public void TestNoContact()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1.6f, 0, 0));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            cs.Add(ContactHelper.CreateContact(cs, Vector3F.Zero, Vector3F.UnitX, 0, false));

            algo.UpdateContacts(cs, 0);
            Assert.AreEqual(objectA, cs.ObjectA);
            Assert.AreEqual(objectB, cs.ObjectB);
            Assert.AreEqual(0, cs.Count);
        }
        public void TestInfiniteSphere()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            CollisionObject objectA = new CollisionObject();

            ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(float.PositiveInfinity);
            CollisionObject objectB = new CollisionObject();

            ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(1f);

            ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
            ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 2f, 0));

            ContactSet cs = ContactSet.Create(objectA, objectB);

            algo.UpdateContacts(cs, 0);

            Assert.AreEqual(1, cs.Count);
            //Assert.AreEqual(new Vector3F(0, 1f, 0), cs.Contacts[0].Position);     // Undefined when a sphere is infinite.
            Assert.AreEqual(new Vector3F(0, 1, 0), cs[0].Normal);
            Assert.IsTrue(float.IsPositiveInfinity(cs[0].PenetrationDepth));
        }
        public void TestNullArgument()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

            algo.UpdateContacts(null, 0);
        }
示例#15
0
        public void TestNoContact()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(1);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0.5f);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(1.6f, 0, 0));

              ContactSet cs = ContactSet.Create(objectA, objectB);
              cs.Add(ContactHelper.CreateContact(cs, Vector3F.Zero, Vector3F.UnitX, 0, false));

              algo.UpdateContacts(cs, 0);
              Assert.AreEqual(objectA, cs.ObjectA);
              Assert.AreEqual(objectB, cs.ObjectB);
              Assert.AreEqual(0, cs.Count);
        }
示例#16
0
        public void TestZeroSphere()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(0);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 1));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 1));

              ContactSet cs = ContactSet.Create(objectA, objectB);

              algo.UpdateContacts(cs, 0);

              Assert.AreEqual(1, cs.Count);
              Assert.AreEqual(new Vector3F(0, 0, 1), cs[0].Position);
              //Assert.AreEqual(new Vector3F(0, 0, 1), cs.Contacts[0].Normal);
              Assert.IsTrue(Numeric.AreEqual(0, cs[0].PenetrationDepth));
        }
示例#17
0
 public void TestNullArgument()
 {
     SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());
       algo.UpdateContacts(null, 0);
 }
示例#18
0
        public void TestZeroSphere1()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(0);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(0);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 2f, 0));

              ContactSet cs = ContactSet.Create(objectA, objectB);

              algo.UpdateContacts(cs, 0);

              Assert.AreEqual(0, cs.Count);
        }
示例#19
0
        public CollisionAlgorithmMatrix(CollisionDetection collisionDetection)
        {
            // Initialize with dummy collision algorithms.
            var noAlgo       = new NoCollisionAlgorithm(collisionDetection);   // Definitely no collision wanted.
            var infiniteAlgo = new InfiniteShapeAlgorithm(collisionDetection); // Returns always a collision.

            // Build default configuration:
            var gjk                = new Gjk(collisionDetection);
            var gjkBoxAlgorithm    = new CombinedCollisionAlgorithm(collisionDetection, gjk, new BoxBoxAlgorithm(collisionDetection));
            var gjkMprAlgorithm    = new CombinedCollisionAlgorithm(collisionDetection, gjk, new MinkowskiPortalRefinement(collisionDetection));
            var gjkTriTriAlgorithm = new CombinedCollisionAlgorithm(collisionDetection, gjk, new TriangleTriangleAlgorithm(collisionDetection));

            BoxSphereAlgorithm        boxSphereAlgorithm        = new BoxSphereAlgorithm(collisionDetection);
            CompositeShapeAlgorithm   compositeAlgorithm        = new CompositeShapeAlgorithm(collisionDetection);
            HeightFieldAlgorithm      heightFieldAlgorithm      = new HeightFieldAlgorithm(collisionDetection);
            LineAlgorithm             lineAlgorithm             = new LineAlgorithm(collisionDetection);
            PlaneBoxAlgorithm         planeBoxAlgorithm         = new PlaneBoxAlgorithm(collisionDetection);
            PlaneConvexAlgorithm      planeConvexAlgorithm      = new PlaneConvexAlgorithm(collisionDetection);
            PlaneRayAlgorithm         planeRayAlgorithm         = new PlaneRayAlgorithm(collisionDetection);
            PlaneSphereAlgorithm      planeSphereAlgorithm      = new PlaneSphereAlgorithm(collisionDetection);
            RayBoxAlgorithm           rayBoxAlgorithm           = new RayBoxAlgorithm(collisionDetection);
            RayConvexAlgorithm        rayConvexAlgorithm        = new RayConvexAlgorithm(collisionDetection);
            RaySphereAlgorithm        raySphereAlgorithm        = new RaySphereAlgorithm(collisionDetection);
            RayTriangleAlgorithm      rayTriangleAlgorithm      = new RayTriangleAlgorithm(collisionDetection);
            SphereSphereAlgorithm     sphereSphereAlgorithm     = new SphereSphereAlgorithm(collisionDetection);
            TransformedShapeAlgorithm transformedShapeAlgorithm = new TransformedShapeAlgorithm(collisionDetection);
            TriangleMeshAlgorithm     triangleMeshAlgorithm     = new TriangleMeshAlgorithm(collisionDetection);
            RayCompositeAlgorithm     rayCompositeAlgorithm     = new RayCompositeAlgorithm(collisionDetection);
            RayTriangleMeshAlgorithm  rayTriangleMeshAlgorithm  = new RayTriangleMeshAlgorithm(collisionDetection);
            RayHeightFieldAlgorithm   rayHeightFieldAlgorithm   = new RayHeightFieldAlgorithm(collisionDetection);

            this[typeof(PointShape), typeof(PointShape)]        = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(LineShape)]         = lineAlgorithm;
            this[typeof(PointShape), typeof(RayShape)]          = rayConvexAlgorithm;
            this[typeof(PointShape), typeof(LineSegmentShape)]  = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(TriangleShape)]     = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(RectangleShape)]    = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(BoxShape)]          = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(PointShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(PointShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(PointShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(PointShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(PointShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(PointShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(PointShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(LineShape), typeof(LineShape)]         = lineAlgorithm;
            this[typeof(LineShape), typeof(RayShape)]          = lineAlgorithm;
            this[typeof(LineShape), typeof(LineSegmentShape)]  = lineAlgorithm;
            this[typeof(LineShape), typeof(TriangleShape)]     = lineAlgorithm;
            this[typeof(LineShape), typeof(RectangleShape)]    = lineAlgorithm;
            this[typeof(LineShape), typeof(BoxShape)]          = lineAlgorithm;
            this[typeof(LineShape), typeof(ConvexShape)]       = lineAlgorithm;
            this[typeof(LineShape), typeof(ScaledConvexShape)] = lineAlgorithm;
            this[typeof(LineShape), typeof(CircleShape)]       = lineAlgorithm;
            this[typeof(LineShape), typeof(SphereShape)]       = lineAlgorithm;
            this[typeof(LineShape), typeof(CapsuleShape)]      = lineAlgorithm;
            this[typeof(LineShape), typeof(ConeShape)]         = lineAlgorithm;
            this[typeof(LineShape), typeof(CylinderShape)]     = lineAlgorithm;
            this[typeof(LineShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(LineShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(LineShape), typeof(PlaneShape)]        = noAlgo;
            this[typeof(LineShape), typeof(HeightField)]       = noAlgo;
            this[typeof(LineShape), typeof(TriangleMeshShape)] = lineAlgorithm;
            this[typeof(LineShape), typeof(TransformedShape)]  = lineAlgorithm;
            this[typeof(LineShape), typeof(CompositeShape)]    = lineAlgorithm;

            this[typeof(RayShape), typeof(RayShape)]          = noAlgo;
            this[typeof(RayShape), typeof(LineSegmentShape)]  = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(TriangleShape)]     = rayTriangleAlgorithm;
            this[typeof(RayShape), typeof(RectangleShape)]    = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(BoxShape)]          = rayBoxAlgorithm;
            this[typeof(RayShape), typeof(ConvexShape)]       = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(ScaledConvexShape)] = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(CircleShape)]       = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(SphereShape)]       = raySphereAlgorithm;
            this[typeof(RayShape), typeof(CapsuleShape)]      = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(ConeShape)]         = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(CylinderShape)]     = rayConvexAlgorithm;
            this[typeof(RayShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(RayShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(RayShape), typeof(PlaneShape)]        = planeRayAlgorithm;
            this[typeof(RayShape), typeof(HeightField)]       = rayHeightFieldAlgorithm;
            this[typeof(RayShape), typeof(TriangleMeshShape)] = rayTriangleMeshAlgorithm;
            this[typeof(RayShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(RayShape), typeof(CompositeShape)]    = rayCompositeAlgorithm;

            this[typeof(LineSegmentShape), typeof(LineSegmentShape)]  = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(TriangleShape)]     = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(RectangleShape)]    = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(BoxShape)]          = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(LineSegmentShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(LineSegmentShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(LineSegmentShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(LineSegmentShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(LineSegmentShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(LineSegmentShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(LineSegmentShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(TriangleShape), typeof(TriangleShape)]     = gjkTriTriAlgorithm;
            this[typeof(TriangleShape), typeof(RectangleShape)]    = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(BoxShape)]          = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(TriangleShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(TriangleShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(TriangleShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(TriangleShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(TriangleShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(TriangleShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(TriangleShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(RectangleShape), typeof(RectangleShape)]    = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(BoxShape)]          = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(RectangleShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(RectangleShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(RectangleShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(RectangleShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(RectangleShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(RectangleShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(RectangleShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(BoxShape), typeof(BoxShape)]          = gjkBoxAlgorithm;
            this[typeof(BoxShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(SphereShape)]       = boxSphereAlgorithm;
            this[typeof(BoxShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(BoxShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(BoxShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(BoxShape), typeof(PlaneShape)]        = planeBoxAlgorithm;
            this[typeof(BoxShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(BoxShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(BoxShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(BoxShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(ConvexShape), typeof(ConvexShape)]       = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(ConvexShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(ConvexShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(ConvexShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(ConvexShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(ConvexShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(ConvexShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(ConvexShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(ScaledConvexShape), typeof(ScaledConvexShape)] = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(ScaledConvexShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(ScaledConvexShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(ScaledConvexShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(ScaledConvexShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(ScaledConvexShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(ScaledConvexShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(ScaledConvexShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(CircleShape), typeof(CircleShape)]       = gjkMprAlgorithm;
            this[typeof(CircleShape), typeof(SphereShape)]       = gjkMprAlgorithm;
            this[typeof(CircleShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(CircleShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(CircleShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(CircleShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(CircleShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(CircleShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(CircleShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(CircleShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(CircleShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(CircleShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(SphereShape), typeof(SphereShape)]       = sphereSphereAlgorithm;
            this[typeof(SphereShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(SphereShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(SphereShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(SphereShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(SphereShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(SphereShape), typeof(PlaneShape)]        = planeSphereAlgorithm;
            this[typeof(SphereShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(SphereShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(SphereShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(SphereShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(CapsuleShape), typeof(CapsuleShape)]      = gjkMprAlgorithm;
            this[typeof(CapsuleShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(CapsuleShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(CapsuleShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(CapsuleShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(CapsuleShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(CapsuleShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(CapsuleShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(CapsuleShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(CapsuleShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(ConeShape), typeof(ConeShape)]         = gjkMprAlgorithm;
            this[typeof(ConeShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(ConeShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(ConeShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(ConeShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(ConeShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(ConeShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(ConeShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(ConeShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(CylinderShape), typeof(CylinderShape)]     = gjkMprAlgorithm;
            this[typeof(CylinderShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(CylinderShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(CylinderShape), typeof(PlaneShape)]        = planeConvexAlgorithm;
            this[typeof(CylinderShape), typeof(HeightField)]       = heightFieldAlgorithm;
            this[typeof(CylinderShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(CylinderShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(CylinderShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(EmptyShape), typeof(EmptyShape)]        = noAlgo;
            this[typeof(EmptyShape), typeof(InfiniteShape)]     = noAlgo; // No collision between Empty and Infinite.
            this[typeof(EmptyShape), typeof(PlaneShape)]        = noAlgo;
            this[typeof(EmptyShape), typeof(HeightField)]       = noAlgo;
            this[typeof(EmptyShape), typeof(TriangleMeshShape)] = noAlgo;
            this[typeof(EmptyShape), typeof(TransformedShape)]  = noAlgo;
            this[typeof(EmptyShape), typeof(CompositeShape)]    = noAlgo;

            this[typeof(InfiniteShape), typeof(InfiniteShape)]     = infiniteAlgo;
            this[typeof(InfiniteShape), typeof(PlaneShape)]        = infiniteAlgo;
            this[typeof(InfiniteShape), typeof(HeightField)]       = infiniteAlgo;
            this[typeof(InfiniteShape), typeof(TriangleMeshShape)] = infiniteAlgo;
            this[typeof(InfiniteShape), typeof(TransformedShape)]  = infiniteAlgo;
            this[typeof(InfiniteShape), typeof(CompositeShape)]    = infiniteAlgo;

            this[typeof(PlaneShape), typeof(PlaneShape)]        = noAlgo;
            this[typeof(PlaneShape), typeof(HeightField)]       = noAlgo;
            this[typeof(PlaneShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(PlaneShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(PlaneShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(HeightField), typeof(HeightField)] = noAlgo;
            // We could also call triangleMeshAlgorithm. But since HeightField has usually larger parts it
            // is better to call the heightFieldAlgorithm. The heightFieldAlgorithm will cull all but a
            // few height field cells very quickly.
            this[typeof(HeightField), typeof(TriangleMeshShape)] = heightFieldAlgorithm;
            this[typeof(HeightField), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            // Same as for triangle meshes: Call height field algorithm first.
            this[typeof(HeightField), typeof(CompositeShape)] = heightFieldAlgorithm;

            this[typeof(TriangleMeshShape), typeof(TriangleMeshShape)] = triangleMeshAlgorithm;
            this[typeof(TriangleMeshShape), typeof(TransformedShape)]  = transformedShapeAlgorithm;
            this[typeof(TriangleMeshShape), typeof(CompositeShape)]    = compositeAlgorithm;

            this[typeof(TransformedShape), typeof(TransformedShape)] = transformedShapeAlgorithm;
            this[typeof(TransformedShape), typeof(CompositeShape)]   = transformedShapeAlgorithm;

            this[typeof(CompositeShape), typeof(CompositeShape)] = compositeAlgorithm;
        }
示例#20
0
        public void TestInfiniteSphere()
        {
            SphereSphereAlgorithm algo = new SphereSphereAlgorithm(new CollisionDetection());

              CollisionObject objectA = new CollisionObject();
              ((GeometricObject)objectA.GeometricObject).Shape = new SphereShape(float.PositiveInfinity);
              CollisionObject objectB = new CollisionObject();
              ((GeometricObject)objectB.GeometricObject).Shape = new SphereShape(1f);

              ((GeometricObject)objectA.GeometricObject).Pose = new Pose(new Vector3F(0, 0, 0));
              ((GeometricObject)objectB.GeometricObject).Pose = new Pose(new Vector3F(0, 2f, 0));

              ContactSet cs = ContactSet.Create(objectA, objectB);

              algo.UpdateContacts(cs, 0);

              Assert.AreEqual(1, cs.Count);
              //Assert.AreEqual(new Vector3F(0, 1f, 0), cs.Contacts[0].Position);     // Undefined when a sphere is infinite.
              Assert.AreEqual(new Vector3F(0, 1, 0), cs[0].Normal);
              Assert.IsTrue(float.IsPositiveInfinity(cs[0].PenetrationDepth));
        }