Repository navigation
Conversation
geometry::face-to-triangle-aux is O(n^2) ear-clipping, called on every face by cascaded-coords's :make-pqpmodel and by gl::make-glvertices-from-faces on every render-mesh rebuild. For faces with many holes/vertices this dominates model build time. Add geometry::face-to-triangle-fast (irtgeo.l), a drop-in replacement that triangulates via libGLU's sweep-line tessellator when it's linked in (eusgl/irteusgl), falling back to the original ear-clipping path on a non-GL build or if GLU errors on a particular face -- *glu-tess-available* is computed once via fboundp so the fallback is safe even when the gl:: package doesn't exist at all. Wire it into pqp.l's :make-pqpmodel and irtgl.l's make-glvertices-from-faces. Extend irteus/test/test-triangulation.l with: - fast-vs-aux consistency checks (triangle count, total area, line-intersection behavior) reusing the existing multi-hole cases - a benchmark against a face with more holes, demonstrating real speedup (86 triangles, ~2.06s -> ~0.0023s, ~915x on this box) rather than just adding the low-level GLU collector primitives in isolation (see euslisp/EusLisp#542) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds a from-scratch, dependency-free 2D Delaunay triangulation (Bowyer-Watson incremental algorithm) to irtgeo.l, purely to compare mesh quality against face-to-triangle-aux (ear clipping) and face-to-triangle-fast (GLU sweep-line, this branch's earlier commit). Not wired into pqp.l or irtgl.l -- GLU remains the right choice there since this implementation is O(n^2) with no spatial acceleration structure, uncompetitive on speed. Delaunay triangulation maximizes the minimum angle over all triangulations of a point set (the empty-circumcircle property), so it's expected to avoid long thin slivers that both ear-clipping and GLU's sweep-line can produce. The new test-triangulation-quality-comparison test demonstrates this concretely: on the same 6-hole face already used by triangulation-benchmark-many-holes, max/min triangle area ratio is ~4166 (ear-clipping) / ~3998 (GLU) vs ~159 (Delaunay), while total covered area matches across all three. The implementation is an unconstrained Bowyer-Watson followed by a centroid-based inside-boundary/outside-holes filter, not a rigorous constrained Delaunay triangulation -- and its plain double-precision in-circumcircle test is unreliable on symmetric/co-circular input (an evenly-spaced ring of holes reproducibly triggered >10% spurious area). Mitigated by inserting points in a deterministic (reproducible) shuffled order and retrying with a different shuffle, checked against the true polygon area computed directly via the shoelace formula, each time; falls back to warning loudly if every attempt still disagrees beyond tolerance rather than silently returning a wrong mesh. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- catkin: GitHub Actions now forces Node 24 for actions targeting Node 20, but ubuntu:18.04's glibc (2.27) can't run it (needs >= 2.28). Set ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION so actions/checkout keeps using the glibc-2.17 Node 20 build the job already stages into /__e/node20. - linux-arm (bullseye): Debian bullseye's LTS support has ended, so deb.debian.org no longer serves bullseye(-security) packages. Switch to the snapshot.debian.org mirrors the image ships (commented out) and skip the Valid-Until check for this frozen suite's Release file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
CI was failing on two jobs unrelated to the code change here, both root-caused and fixed in 1812a10:
Verified locally with |
Three interactive irteus demos exploring a lightweight, EusLisp-native rigid-body physics visualization: prim-drop.l (multi-shape drop onto a floor), prim-box.l (same shapes bouncing inside an enclosed box), and hand-grasp.l (a hand catching each shape via IK-driven finger closing). Each body carries a real density-derived mass and per-shape diagonal moment-of-inertia tensor. Body-to-body tunnelling is prevented with a conservative-advancement CCD scheme (pair-toi-bound/min-pair-toi/ ccd-advance-frame in prim-drop.l) rather than fixed substepping, with a guaranteed full-frame catch-up step so a busy multi-body frame never silently drops simulated time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
geometry::face-to-triangle-aux(irtgeo.l) is an O(n^2) ear-clippingtriangulator. It's called on every face by two hot paths:
cascaded-coords's:make-pqpmodel(pqp.l) — run once per linkduring robot/body init, uncached.
gl::make-glvertices-from-faces(irtgl.l) — run whenever a rendermesh is (re)built from a faceset.
For faces with many holes/vertices (e.g. plates with many mounting
holes cut out) this dominates model build time; on a real multi-link
robot model with several such faces, build times of minutes were
observed to be spent almost entirely in ear-clipping.
Fix
Adds
geometry::face-to-triangle-fast(irtgeo.l): a drop-inreplacement for
face-to-triangle-auxthat triangulates via libGLU'ssweep-line tessellator when it's linked in (
eusgl/irteusgl),falling back to the original ear-clipping implementation when it isn't
(a non-GL
eus/irteusbuild, wherepqp.lis still loaded) or whenGLU reports an error for a particular face.
*glu-tess-available*is computed once via(and (fboundp 'gl::eus_tess_reset) (fboundp 'gl::gluNewTess)), so thefallback is safe even in a build where the
gl::package/symbolsdon't exist at all — this is a plain symbol-existence check, not a
try/catch, so it can't itself error on a non-GL build.
Wired into:
pqp.l's:make-pqpmodel:face-to-triangle-aux->face-to-triangle-fastirtgl.l'smake-glvertices-from-faces: same swapThis depends on the low-level
eus_tess_*GLU tessellation-callbackcollector primitives added to EusLisp core in
euslisp/EusLisp#542 — but only for the speedup; without them (older
EusLisp core, or a non-GL build), this PR is a no-op functionally and
falls back to the exact original algorithm.
Testing
Extended the existing
irteus/test/test-triangulation.l(rather thanadding a new file, so it keeps running via
.travis.sh'sfor test_l in irteus/test/*.lCI loop automatically) with:test-triangulation-fast-consistency-{0,1}: reuse the existing5-hole multi-hole test fixtures, but assert
face-to-triangle-fastmatches
face-to-triangle-auxin triangle count, total area, andline-intersection behavior against the same probe lines.
test-triangulation-benchmark-many-holes: builds a plate with 6holes, times both paths, and asserts they still agree (triangle
count + area) while printing the actual speedup. On the CI/dev
machine used here:
All 6 tests in the file pass (
irteusgl test/test-triangulation.l).Separately verified the non-GL fallback path by forcing
geo::*glu-tess-available*tonilinside a workingirteusglprocess (exercising the identical branch a real non-GL build would
take) and confirming both
:make-pqpmodelandgl::make-glvertices-from-facesstill complete correctly via theear-clipping path.
This was validated against a real-world workload before opening this
PR: applying the equivalent of this fix downstream (as an
application-level method override, not touching irteus core) cut
total generation time across ~30 previously-slowest robot models in a
larger robot-model-generation batch from ~8985s to ~818s (~11x
aggregate), with individual robots seeing 6x-28x speedups depending on
face/hole complexity.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Update: added face-to-triangle-delaunay for a mesh-quality comparison
Also added
geometry::face-to-triangle-delaunay(irtgeo.l): afrom-scratch, dependency-free 2D Delaunay triangulation
(Bowyer-Watson), added purely to compare mesh quality against the
two triangulators above -- not wired into
pqp.l/irtgl.l; GLUremains the right choice for those (this implementation is O(n^2),
no spatial acceleration structure, uncompetitive on speed).
Delaunay triangulation maximizes the minimum angle over all
triangulations of a point set (the empty-circumcircle property), so
it's expected to avoid the long thin slivers that both ear-clipping
and GLU's sweep-line can produce. The new
test-triangulation-quality-comparisontest demonstrates this on thesame 6-hole face used by
triangulation-benchmark-many-holes:(total covered area matches across all three; only how each cuts the
same region into triangles differs.)
Caveat, documented in the code: this is an unconstrained Bowyer-Watson
Delaunay triangulation, and its plain double-precision
in-circumcircle test is unreliable on symmetric/co-circular input (an
evenly-spaced ring of holes reproducibly triggered >10% spurious
area in testing). Mitigated by inserting points in a deterministic
(reproducible) shuffled order and retrying with a different shuffle,
checked against the true polygon area (shoelace formula) each time;
falls back to a loud warning if every attempt still disagrees beyond
tolerance, rather than silently returning a wrong mesh.