Exemplo n.º 1
0
        private CollisionPointStructure SoftBodyNarrowPhase(
            ShapeDecompositionOutput A,
            ShapeDecompositionOutput B,
            int ID_A,
            int ID_B)
        {
            List <CollisionPointStructure> collisionPointStructure = ConvexCollisionStep(A, B, ID_A, ID_B, parameters.CollisionDistance);

            if (collisionPointStructure.Count > 1)
            {
                List <CollisionPointBaseStructure> baseStructure = new List <CollisionPointBaseStructure>();

                foreach (CollisionPointStructure cps in collisionPointStructure)
                {
                    if (cps != null)
                    {
                        baseStructure.AddRange(cps.CollisionPointBase);
                    }
                }

                collisionPointStructure[0].SetBaseCollisionPoint(baseStructure.ToArray());
            }

            if (collisionPointStructure.Count > 0)
            {
                return(collisionPointStructure[0]);
            }

            return(null);
        }
Exemplo n.º 2
0
        private List <CollisionPointStructure> ConvexCollisionStep(
            ShapeDecompositionOutput A,
            ShapeDecompositionOutput B,
            int ID_A,
            int ID_B,
            double collisionDistance)
        {
            VertexProperties[] vertexObjA = Array.ConvertAll(A.Vertex3Idx.ToArray(), x => new VertexProperties(x.Vector3, x.ID));
            VertexProperties[] vertexObjB = Array.ConvertAll(B.Vertex3Idx.ToArray(), x => new VertexProperties(x.Vector3, x.ID));

            List <CollisionPointStructure> collisionPointStructure = new List <CollisionPointStructure>();

            var cps = convexBodyNarrowPhase.Execute(vertexObjA, vertexObjB, ID_A, ID_B, collisionDistance);

            if (cps != null)
            {
                collisionPointStructure.Add(cps);
            }

            return(collisionPointStructure);
        }