Skip to content

Commit 42beb99

Browse files
committed
Add optional pooling of objects.
1 parent 48afef4 commit 42beb99

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

LibTessDotNet/Sources/Tess.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,16 @@ public partial class Tess
100100
public float SUnitY = 0.0f;
101101
public float SentinelCoord = 4e30f;
102102

103+
/// <summary>
104+
/// If true, will remove empty (zero area) polygons.
105+
/// </summary>
103106
public bool NoEmptyPolygons = false;
104107

108+
/// <summary>
109+
/// If true, will use pooling to reduce GC (compare performance with/without, can vary wildly).
110+
/// </summary>
111+
public bool UsePooling = false;
112+
105113
public ContourVertex[] Vertices { get { return _vertices; } }
106114
public int VertexCount { get { return _vertexCount; } }
107115

@@ -722,8 +730,10 @@ public void Tessellate(WindingRule windingRule, ElementType elementType, int pol
722730
OutputPolymesh(elementType, polySize);
723731
}
724732

725-
// Pooling disabled, performance is worse with pooling
726-
//_mesh.Free();
733+
if (UsePooling)
734+
{
735+
_mesh.Free();
736+
}
727737
_mesh = null;
728738
}
729739
}

0 commit comments

Comments
 (0)