private void Update() { changes = BlocChanges.None; if (contourShapes != null) { foreach (ContourShape shape in contourShapes) { if (shape != null) { shape.changes = ContourShape.ShapeChanged.None; } } } }
public void RemoveContourAt(int contourIndex) { // Remove all points from the contour List <int> pointIndices = GetContour(contourIndex, true); foreach (int pti in pointIndices) { RemovePointFromContour(pti, contourIndex); } // Decrement higher contour indices in all point occurences, including buffer point for (int pti = -1, ptCount = PointCount; pti < ptCount; pti++) { Point point = pti == -1 ? bufferPoint : points[pti]; int occurenceCount = point.OccurenceCount; if (occurenceCount == 0) { continue; } List <PointOccurence> occurences = point.occurences; bool changeOccurences = false; for (int occi = 0; occi < occurenceCount; occi++) { PointOccurence occ = occurences[occi]; if (occ.contourIndex > contourIndex) { changeOccurences = true; occ.contourIndex--; occurences[occi] = occ; } } if (changeOccurences) { point.occurences = occurences; if (pti == -1) { bufferPoint = point; } else { points[pti] = point; } } } // Remove contour contourShapes.RemoveAt(contourIndex); changes |= BlocChanges.ContourRemoved; }
public void AddContour() { // Create empty contour (contour with one undefined point) int oldContourCount = GetContourCount(); bufferPoint.occurences.Add(new PointOccurence() { contourIndex = oldContourCount, indexInContour = 0 }); if (contourShapes == null) { contourShapes = new List <ContourShape>(); } ContourShape newContour = new ContourShape(new List <Vector2>()); contourShapes.Add(newContour); changes |= BlocChanges.ContourAdded; }
public void RemoveContoursAt(List <int> contourIndices) { // Remove multiple contours if (contourIndices == null) { return; } for (int i = 0, iend = contourIndices.Count; i < iend; i++) { RemoveContourAt(contourIndices[i]); for (int j = 0; j < iend; j++) { if (contourIndices[j] > contourIndices[i]) { contourIndices[j]--; } } } changes |= BlocChanges.ContourRemoved; }