karl- / pb_CSG

A C# port of CSG.js by Evan W (http://evanw.github.io/csg.js/).
MIT License
634 stars 99 forks source link

Code to be fixed. #37

Open max-free opened 1 year ago

max-free commented 1 year ago

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.

Golgovskiy commented 4 months ago

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?