コード例 #1
0
        public void ComputeCollision()
        {
            RayBoxAlgorithm algo = new RayBoxAlgorithm(new CollisionDetection());

              CollisionObject ray = new CollisionObject(new GeometricObject
                  {
                    Shape = new RayShape(new Vector3F(0, 0, 0), new Vector3F(-1, 0, 0), 10),
                    Pose = new Pose(new Vector3F(0, 0, 0)),
                  });

              CollisionObject box = new CollisionObject(new GeometricObject
                  {
                    Shape = new BoxShape(2, 4, 8),
                  });

              ContactSet set;

              set = algo.GetClosestPoints(ray, box);
              Assert.AreEqual(true, algo.HaveContact(ray, box));
              Assert.AreEqual(true, algo.HaveContact(box, ray));
              Assert.AreEqual(0, set[0].PenetrationDepth);
              Assert.AreEqual(0, algo.GetContacts(box, ray)[0].PenetrationDepth);
              Assert.AreEqual(new Vector3F(), algo.GetContacts(box, ray)[0].Position);

              // Hit + x face.
              ((GeometricObject)box.GeometricObject).Pose = new Pose(new Vector3F(-1, 2, -4));
              ((GeometricObject)ray.GeometricObject).Pose = new Pose(new Vector3F(1, 0.5f, -2));
              set = algo.GetClosestPoints(ray, box);
              Assert.AreEqual(true, algo.HaveContact(ray, box));
              Assert.AreEqual(true, algo.HaveContact(box, ray));
              Assert.AreEqual(1, set[0].PenetrationDepth);
              Assert.AreEqual(1, algo.GetContacts(box, ray)[0].PenetrationDepth);
              Assert.AreEqual(-Vector3F.UnitX, algo.GetContacts(ray, box)[0].Normal);
              Assert.AreEqual(new Vector3F(0, 0.5f, -2), algo.GetContacts(box, ray)[0].Position);

              ((GeometricObject)ray.GeometricObject).Pose = new Pose(new Vector3F(3, 2, -2));
              ((RayShape) ray.GeometricObject.Shape).Direction = new Vector3F(-1, 1, 0).Normalized;
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(false, algo.HaveContact(ray, box));
              Assert.AreEqual(false, algo.HaveContact(box, ray));
              Assert.AreEqual(0, set.Count);
              Assert.IsTrue(Numeric.AreEqual(-(float) Math.Sqrt(0.5*0.5 + 0.5*0.5), algo.GetClosestPoints(ray, box)[0].PenetrationDepth));

              // Face is separating plane.
              ((GeometricObject)ray.GeometricObject).Pose = new Pose(new Vector3F(3, 2, -2));
              ((RayShape) ray.GeometricObject.Shape).Direction = new Vector3F(0, 1, 0);
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(false, algo.HaveContact(ray, box));
              Assert.AreEqual(false, algo.HaveContact(box, ray));
              Assert.AreEqual(0, set.Count);

              // Hit -x face.
              ((GeometricObject)ray.GeometricObject).Pose = new Pose(new Vector3F(-5, -1, 0));
              ((RayShape) ray.GeometricObject.Shape).Direction = new Vector3F(1, 1, 0).Normalized;
              set = set.Swapped;
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(true, algo.HaveContact(ray, box));
              Assert.AreEqual(true, algo.HaveContact(box, ray));
              Assert.IsTrue(Numeric.AreEqual((float)Math.Sqrt(3*3 + 3*3), set[0].PenetrationDepth));
              Assert.AreEqual(-Vector3F.UnitX, set[0].Normal);
        }
コード例 #2
0
        public void ComputeCollision()
        {
            RayBoxAlgorithm algo = new RayBoxAlgorithm(new CollisionDetection());

            CollisionObject ray = new CollisionObject(new GeometricObject
            {
                Shape = new RayShape(new Vector3(0, 0, 0), new Vector3(-1, 0, 0), 10),
                Pose  = new Pose(new Vector3(0, 0, 0)),
            });

            CollisionObject box = new CollisionObject(new GeometricObject
            {
                Shape = new BoxShape(2, 4, 8),
            });

            ContactSet set;

            set = algo.GetClosestPoints(ray, box);
            Assert.AreEqual(true, algo.HaveContact(ray, box));
            Assert.AreEqual(true, algo.HaveContact(box, ray));
            Assert.AreEqual(0, set[0].PenetrationDepth);
            Assert.AreEqual(0, algo.GetContacts(box, ray)[0].PenetrationDepth);
            Assert.AreEqual(new Vector3(), algo.GetContacts(box, ray)[0].Position);

            // Hit + x face.
            ((GeometricObject)box.GeometricObject).Pose = new Pose(new Vector3(-1, 2, -4));
            ((GeometricObject)ray.GeometricObject).Pose = new Pose(new Vector3(1, 0.5f, -2));
            set = algo.GetClosestPoints(ray, box);
            Assert.AreEqual(true, algo.HaveContact(ray, box));
            Assert.AreEqual(true, algo.HaveContact(box, ray));
            Assert.AreEqual(1, set[0].PenetrationDepth);
            Assert.AreEqual(1, algo.GetContacts(box, ray)[0].PenetrationDepth);
            Assert.AreEqual(-Vector3.UnitX, algo.GetContacts(ray, box)[0].Normal);
            Assert.AreEqual(new Vector3(0, 0.5f, -2), algo.GetContacts(box, ray)[0].Position);

            ((GeometricObject)ray.GeometricObject).Pose     = new Pose(new Vector3(3, 2, -2));
            ((RayShape)ray.GeometricObject.Shape).Direction = new Vector3(-1, 1, 0).Normalized;
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(false, algo.HaveContact(ray, box));
            Assert.AreEqual(false, algo.HaveContact(box, ray));
            Assert.AreEqual(0, set.Count);
            Assert.IsTrue(Numeric.AreEqual(-(float)Math.Sqrt(0.5 * 0.5 + 0.5 * 0.5), algo.GetClosestPoints(ray, box)[0].PenetrationDepth));

            // Face is separating plane.
            ((GeometricObject)ray.GeometricObject).Pose     = new Pose(new Vector3(3, 2, -2));
            ((RayShape)ray.GeometricObject.Shape).Direction = new Vector3(0, 1, 0);
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(false, algo.HaveContact(ray, box));
            Assert.AreEqual(false, algo.HaveContact(box, ray));
            Assert.AreEqual(0, set.Count);

            // Hit -x face.
            ((GeometricObject)ray.GeometricObject).Pose     = new Pose(new Vector3(-5, -1, 0));
            ((RayShape)ray.GeometricObject.Shape).Direction = new Vector3(1, 1, 0).Normalized;
            set = set.Swapped;
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(true, algo.HaveContact(ray, box));
            Assert.AreEqual(true, algo.HaveContact(box, ray));
            Assert.IsTrue(Numeric.AreEqual((float)Math.Sqrt(3 * 3 + 3 * 3), set[0].PenetrationDepth));
            Assert.AreEqual(-Vector3.UnitX, set[0].Normal);
        }
コード例 #3
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;
        }