From 42beb998d1d3cf231640eedab79f687cee09db4b Mon Sep 17 00:00:00 2001 From: Remi Gillig Date: Sun, 14 Feb 2016 10:14:56 +0000 Subject: [PATCH] Add optional pooling of objects. --- LibTessDotNet/Sources/Tess.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/LibTessDotNet/Sources/Tess.cs b/LibTessDotNet/Sources/Tess.cs index 0b613ca..382ef62 100644 --- a/LibTessDotNet/Sources/Tess.cs +++ b/LibTessDotNet/Sources/Tess.cs @@ -100,8 +100,16 @@ public partial class Tess public float SUnitY = 0.0f; public float SentinelCoord = 4e30f; + /// + /// If true, will remove empty (zero area) polygons. + /// public bool NoEmptyPolygons = false; + /// + /// If true, will use pooling to reduce GC (compare performance with/without, can vary wildly). + /// + public bool UsePooling = false; + public ContourVertex[] Vertices { get { return _vertices; } } public int VertexCount { get { return _vertexCount; } } @@ -722,8 +730,10 @@ public void Tessellate(WindingRule windingRule, ElementType elementType, int pol OutputPolymesh(elementType, polySize); } - // Pooling disabled, performance is worse with pooling - //_mesh.Free(); + if (UsePooling) + { + _mesh.Free(); + } _mesh = null; } }