Skip to content

Commit de1878e

Browse files
committed
[runtime] Improve clipper2-based implementation: use object pooling, use Float instead of Int64 on js target
1 parent a4c19f2 commit de1878e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

plugins/clay/tools/src/backend/tools/tasks/ClaySetup.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ class ClaySetup extends tools.Task {
181181
targetFlags += '\n' + '-D clay_shader_from_source';
182182
targetFlags += '\n' + '-D ceramic_auto_block_default_scroll';
183183
targetFlags += '\n' + '-D clay_webgl_unpack_premultiply_alpha';
184-
targetFlags += '\n' + '-D clipper_int64_as_float64';
184+
185+
if (!context.defines.exists('clipper_int64')) {
186+
targetFlags += '\n' + '-D clipper_int64_as_float64';
187+
}
185188
}
186189
else {
187190
if (target.name == 'cppia') {

runtime/src/ceramic/Line.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import clipper.Clipper;
44
import clipper.ClipperCore;
55
import clipper.ClipperOffset.EndType;
66
import clipper.ClipperOffset.JoinType;
7+
import clipper.ClipperPool;
78
import clipper.ClipperTriangulation.TriangulateResult;
89

910
using ceramic.Extensions;
@@ -279,6 +280,9 @@ class Line extends Mesh {
279280
// Clear and reuse the path array
280281
_path.resize(0);
281282

283+
// Start tracking clipper objects for pooling
284+
ClipperPool.trackObjects();
285+
282286
// Convert ceramic points to Clipper2 Path64
283287
var i = 0;
284288
while (i < points.length - 1) {
@@ -321,7 +325,11 @@ class Line extends Mesh {
321325
var inflated = Clipper.inflatePaths(_paths, delta, joinType, endType, miterLimit, arcTolerance);
322326

323327
// Convert inflated paths to vertices and triangulate
328+
// (extracts float data from clipper objects before recycling)
324329
buildMeshFromInflatedPaths(inflated, loop);
330+
331+
// Recycle all tracked clipper objects back to pools
332+
ClipperPool.recycleObjects();
325333
}
326334

327335
if (autoComputeSize)

0 commit comments

Comments
 (0)