karl-/pb_CSG

Code to be fixed.

Opened this issue · 1 comments

Hi, I may have found an issue which should be fixed.

When I used CGS.Substruct() for a couple of times, I found Node.polygons.Count had rapidly increased. This was actually caused by

List list = this.polygons;

in CGS/Classes/Node.cs line 171. Since when list changes, this.polygons also changes, the code above should be like

List list = new List(this.polygons);

Sorry if this is just my misunderstanding.

Have run this:

// Initial subtraction
Model initialResult = CSG.Subtract(lhs, rhs);
int polygonCount = 0;
// Perform Subtract operation multiple times
for (int i = 0; i < 10; i++)
{
    initialResult = CSG.Subtract(lhs, rhs);

    // Check Node polygons count
    Node node = new Node(initialResult.ToPolygons());
    polygonCount = node.AllPolygons().Count; // or just .polygons
    Debug.Log($"Iteration {i}: Polygon count = {polygonCount}");
}

piece of code, count does not change. Is it really a problem or am i missing the point?