Пример #1
0
        static void FetchEncroachedSegments(NativeArray <float2> pgPoints, int pgPointCount, NativeArray <int2> pgEdges, int pgEdgeCount, ref NativeArray <UEncroachingSegment> encroach, ref int encroachCount, UCircle c)
        {
            for (int i = 0; i < pgEdgeCount; ++i)
            {
                var edge  = pgEdges[i];
                var edgeA = pgPoints[edge.x];
                var edgeB = pgPoints[edge.y];

                // Check if center is along the Edge.
                if (!math.any(c.center - edgeA) || !math.any(c.center - edgeB))
                {
                    continue;
                }

                // Get Radius
                var edgeD = edgeA - edgeB;
                var edgeM = (edgeA + edgeB) * 0.5f;
                var edgeR = math.length(edgeD) * 0.5f;
                if (math.length(edgeM - c.center) > edgeR)
                {
                    continue;
                }

                UEncroachingSegment es = new UEncroachingSegment();
                es.a     = edgeA;
                es.b     = edgeB;
                es.index = i;
                encroach[encroachCount++] = es;
            }
        }
Пример #2
0
 internal static bool IsInsideCircle(UCircle c, float2 v)
 {
     return(math.distance(v, c.center) < c.radius);
 }