Repository navigation
fix: dissolve coplanar boolean edges when faces share tags - #46
zalzdarkent wants to merge 4 commits into
Conversation
Problem: Blender's EXACT boolean solver leaves redundant coplanar split/triangulation edges on flat faces (e.g. overlapping faces in join/cut). Even after _flatten_names() untags flat named edges and marks them smooth, the extra edges and split faces remain in the mesh. Solution: - Add _dissolve_coplanar(bm) in src/sand3d/edit.py, called after _flatten_names(bm) in _boolean(). - Only dissolve interior edges whose two adjacent faces are strictly coplanar (dot > 1.0 - 1e-6, avoiding curved smooth-loft facets), share identical FACE_TAG layers, and have no EDGE_TAG on the separating edge. - Add test_coplanar_edges_dissolved_on_join in tests/test_edits.py to verify overlapping flush boxes merge coplanar top/bottom splits cleanly.
|
Hi! I've synced this branch with the latest Ready for CI workflow approval and review whenever you have a moment—thanks! |
|
Hey, thanks for this PR, I delayed the review since we had a lot of changes with the 1.7.0 & organic support. Before we dig in, I'd like to understand what got you there. What were you building when those leftover seams got in your way? Was it how the mesh looked, a later step like a fillet or a shell that misbehaved, an export, or something else? If you still have the small program where you hit it, could you share it? Knowing the actual pain point will help us find the right fix. |
|
Thanks for taking a look! The main pain point was mesh / wireframe cleanliness on generated models. When having an AI agent build 3D objects composed of multiple overlapping box/planar parts using Even a minimal case like joining two boxes of equal height: import sand3d as s3d
a = s3d.box("a", 10, 10, 10)
s3d.join(a, s3d.at(s3d.box("b", 5, 5, 10), x=4, y=4))leaves the flat top and bottom split into extra faces (14 polygons instead of 12), and in larger agent-generated models with several boolean steps, the wireframe quickly gets cluttered with redundant interior edges on flat faces. That's why I added (Also just pushed an update to |
|
Thanks for the details and the bracket comparison, I'm a bit sceptical though, The pass doesn't only clean the seams the boolean just made: it touches every coplanar edge on the part, including ones that were there on purpose.
In sand3d, while a model is being built, faces and edges carry meaning: names that later verbs look up, colour and Cleaning up topology feels like something that belongs at the very end, on the exported file, where nothing reads those names anymore. If we tackle topology optimisation, I think export is the place for it as a first step, ideally once we support textures and UVs, so that detail removed from the geometry can be baked into normal maps. So I'd rather not merge this one for now, but thanks a lot for digging into it. |
|
As a followup : #58 |





Problem
Blender's
EXACTboolean solver frequently leaves redundant coplanar split edges on flat faces (for example, when overlapping faces are fused injoin()orcut()). While_flatten_names()already untags flat named edges and marks them smooth, those interior edges and split faces remain in the mesh.Solution
_dissolve_coplanar(bm)insrc/sand3d/edit.py, called right after_flatten_names(bm)in_boolean().use_verts=True, use_face_split=Falseso 2-valent collinear vertices are also cleaned up and tessellation does not produce duplicate triangles) only when:dot > 1.0 - 1e-6, avoiding curved smooth-loft facets where adjacent normals can differ by< 0.5°),FACE_TAGlayers (preserving face provenance), andEDGE_TAG(not a real/named edge).test_coplanar_edges_dissolved_on_joinintests/test_edits.pyverifying that two overlapping boxes of equal height merge their coplanar top/bottom splits cleanly into 12 faces (instead of 14).Golden Digests (
tests/golden/bpy-5.2.json)Updated to match Linux CI (
bpy 5.2). Dissolving redundant coplanar edges and 2-valent collinear vertices after booleans reduces face/edge/vertex counts on boolean-built geometry, moving the following 10 digests:case:holes_and_pockets,case:distributors,case:export_traceprogram:weight_stack.weight_stack,program:cutlery.spoon,program:cutlery.fork,program:washing_machine.washer,program:washing_machine.washer_open,program:lamp.lamp,program:rack.rack