private void RebuildCell(ref D2dEdgeColliderCell cell, int cellX, int cellY)
        {
            var xMin = CellSize * cellX;
            var yMin = CellSize * cellY;
            var xMax = Mathf.Min(CellSize + xMin, destructible.AlphaWidth);
            var yMax = Mathf.Min(CellSize + yMin, destructible.AlphaHeight);

            if (xMin > 0)
            {
                xMin += 1;
            }
            if (yMin > 0)
            {
                yMin += 1;
            }
            if (xMax < destructible.AlphaWidth)
            {
                xMax -= 1;
            }
            if (yMax < destructible.AlphaHeight)
            {
                yMax -= 1;
            }

            D2dColliderBuilder.AlphaData   = destructible.AlphaData;
            D2dColliderBuilder.AlphaWidth  = destructible.AlphaWidth;
            D2dColliderBuilder.AlphaHeight = destructible.AlphaHeight;
            D2dColliderBuilder.MinX        = xMin;
            D2dColliderBuilder.MinY        = yMin;
            D2dColliderBuilder.MaxX        = xMax;
            D2dColliderBuilder.MaxY        = yMax;

            D2dColliderBuilder.CalculateEdgeCells();

            if (cell == null)
            {
                cell = D2dEdgeColliderCell.Get();
            }

            cell.Clear(tempColliders);

            D2dColliderBuilder.BuildEdge(cell, tempColliders, child, Weld, Detail);

            cell.UpdateColliderSettings(IsTrigger, Material);
        }
        public static void BuildEdge(D2dEdgeColliderCell cell, List <EdgeCollider2D> unusedColliders, GameObject child, float detail)
        {
            cell.Clear(unusedColliders);

            // Find the start points of paths
            for (var i = 0; i < pointCount; i++)
            {
                var point = points[i];

                if (point.Used == false)
                {
                    Trace(point);
                    WeldLines();
                    OptimizeEdges(detail);

                    cell.AddPath(unusedColliders, child, ExtractPoints(0));
                }
            }
        }
Пример #3
0
 private void Mark(D2dEdgeColliderCell cell)
 {
     cell.Clear(unusedColliders);
 }