Esempio n. 1
0
        private CollisionPointStructure ExecuteEPAEngine(
            GJKOutput gjkOutput,
            VertexProperties[] vertexObjA,
            VertexProperties[] vertexObjB,
            int ID_A,
            int ID_B)
        {
            EPAOutput epaOutput = compenetrationEngine.Execute(
                vertexObjA,
                vertexObjB,
                gjkOutput.SupportTriangles,
                gjkOutput.Centroid);

            if (epaOutput.CollisionPoint.CollisionNormal.Length() < normalTolerance)
            {
                return(null);
            }

            List <CollisionPoint> collisionPointsList = null;

            collisionPointsList = manifoldEPAPointsGenerator.GetManifoldPoints(
                Array.ConvertAll(vertexObjA, x => x.Vertex),
                Array.ConvertAll(vertexObjB, x => x.Vertex),
                epaOutput.CollisionPoint);

            var collisionPointBaseStr = new CollisionPointBaseStructure(
                epaOutput.CollisionPoint,
                collisionPointsList?.ToArray());

            return(new CollisionPointStructure(
                       ID_A,
                       ID_B,
                       collisionPointBaseStr));
        }
Esempio n. 2
0
 public CollisionPointStructure(
     int objectA,
     int objectB,
     CollisionPointBaseStructure collisionPointBase)
     : this(objectA, objectB, new CollisionPointBaseStructure[] { collisionPointBase })
 {
 }
Esempio n. 3
0
        private CollisionPointStructure NarrowPhaseCollisionDetection(
            GJKOutput gjkOutput,
            VertexProperties[] vertexObjA,
            VertexProperties[] vertexObjB,
            int ID_A,
            int ID_B,
            double collisionDistance)
        {
            if (gjkOutput.Intersection)
            {
                return(ExecuteEPAEngine(
                           gjkOutput,
                           vertexObjA,
                           vertexObjB,
                           ID_A,
                           ID_B));
            }
            else if (gjkOutput.CollisionDistance <= collisionDistance &&
                     gjkOutput.CollisionDistance >= 0.0)
            {
                if (gjkOutput.CollisionNormal.Length() < normalTolerance)
                {
                    return(null);
                }

                List <CollisionPoint> collisionPointsList = null;

                collisionPointsList = manifoldGJKPointsGenerator.GetManifoldPoints(
                    Array.ConvertAll(vertexObjA, x => x.Vertex),
                    Array.ConvertAll(vertexObjB, x => x.Vertex),
                    gjkOutput.CollisionPoint);

                gjkOutput.CollisionPoint.SetDistance(gjkOutput.CollisionDistance);

                var collisionPointBaseStr = new CollisionPointBaseStructure(
                    gjkOutput.CollisionPoint,
                    collisionPointsList?.ToArray());

                return(new CollisionPointStructure(
                           ID_A,
                           ID_B,
                           collisionPointBaseStr));
            }

            return(null);
        }
Esempio n. 4
0
 public void SetBaseCollisionPoint(CollisionPointBaseStructure[] collisionPointBase)
 {
     CollisionPointBase = new CollisionPointBaseStructure[collisionPointBase.Length];
     Array.Copy(collisionPointBase, CollisionPointBase, collisionPointBase.Length);
 }