Skip to content

Commit

Permalink
Release references to solids once merged.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Pringle committed Aug 30, 2021
1 parent 8977cc6 commit f2b6c07
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Csg/Solid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ public static Solid FromPolygons(List<Polygon> polygons)

public Solid Union(params Solid[] others)
{
var csgs = new List<Solid>();
csgs.Add(this);
csgs.AddRange(others);
var i = 1;
for (; i < csgs.Count; i += 2)
if (others.Length == 0) {
return this;
}

var csgs = new Queue<Solid>(others);
csgs.Enqueue (this);
while (csgs.Count > 1)
{
var n = csgs[i - 1].UnionSub(csgs[i], false, false);
csgs.Add(n);
var a = csgs.Dequeue();
var b = csgs.Dequeue();

var n = a.UnionSub(b, false, false);
csgs.Enqueue(n);
}
return csgs[i - 1].Retesselated().Canonicalized();

return csgs.Dequeue().Retesselated().Canonicalized();
}

Solid UnionSub(Solid csg, bool retesselate, bool canonicalize)
Expand Down

0 comments on commit f2b6c07

Please sign in to comment.