Used for computing contact manifolds.
示例#1
0
        private static void FindIncidentEdge(ref FixedArray2<ClipVertex> c, EPProxy proxy1, int edge1, EPProxy proxy2)
        {
            int count2 = proxy2.Count;

            Debug.Assert(0 <= edge1 && edge1 < proxy1.Count);

            // Get the normal of the reference edge in proxy2's frame.
            Vector2 normal1 = proxy1.Normals[edge1];

            // Find the incident edge on proxy2.
            int index = 0;
            float minDot = float.MaxValue;
            for (int i = 0; i < count2; ++i)
            {
                float dot = Vector2.Dot(normal1, proxy2.Normals[i]);
                if (dot < minDot)
                {
                    minDot = dot;
                    index = i;
                }
            }

            // Build the clip vertices for the incident edge.
            int i1 = index;
            int i2 = i1 + 1 < count2 ? i1 + 1 : 0;

            ClipVertex cTemp = new ClipVertex();
            cTemp.V = proxy2.Vertices[i1];
            cTemp.ID.Features.IndexA = (byte) edge1;
            cTemp.ID.Features.IndexB = (byte) i1;
            cTemp.ID.Features.TypeA = (byte) ContactFeatureType.Face;
            cTemp.ID.Features.TypeB = (byte) ContactFeatureType.Vertex;
            c[0] = cTemp;

            cTemp.V = proxy2.Vertices[i2];
            cTemp.ID.Features.IndexA = (byte) edge1;
            cTemp.ID.Features.IndexB = (byte) i2;
            cTemp.ID.Features.TypeA = (byte) ContactFeatureType.Face;
            cTemp.ID.Features.TypeB = (byte) ContactFeatureType.Vertex;
            c[1] = cTemp;
        }