6.6 KiB
Void Chamfer V2 Plan (Geometric Offset, Not Boolean Cutters)
Goal
Replace the current chamfer implementation based on cutter solids + boolean difference with a deterministic geometric chamfer pipeline that operates directly on mesh topology and face offsets.
Why Change
- Current path is boolean-driven (
solid/chamfer.js) and depends on synthetic cutter prisms. - Boolean chamfer is fragile near:
- short edges
- dense/curved topology
- multi-edge corner interactions
- near-coplanar/low-angle neighborhoods
- Provenance and boundary tracking are harder when chamfer is represented as a subtract operation, rather than explicit edge-face reconstruction.
- Debugging and deterministic replay are harder with cutter generation and manifold fallback behavior.
Current-State Findings
-
Chamfer currently:
- resolves selected edges
- builds cutter meshes from adjacent triangle normals
- performs boolean difference
- writes resulting body as manifold output
-
Signals in current code indicate boolean-centric lifecycle:
manifold_chamfer_passthroughmanifold_chamfer_ready- cutter debug/failure logs
-
Edge references are already fairly good:
- chamfer refs use canonical boundary/segment identities
- this is strong input for a topology-based rebuild
Target Architecture
Chamfer becomes a topology/geometry transform, not a subtractive solid operation.
-
Input:
- selected sharp edges (from stable boundary segment refs)
- chamfer distance (and later optional asymmetric distances)
-
Core operation:
- for each selected edge, offset its two incident face planes by chamfer distance
- intersect offset planes with local wedge to compute chamfer strip geometry
- trim neighboring faces and insert chamfer face(s)
-
Corner resolution:
- solve multi-edge vertex neighborhoods explicitly
- produce watertight corner patches without global booleans
-
Output:
- rebuilt manifold mesh + updated provenance/boundary mappings
- explicit chamfer faces with stable IDs (not anonymous boolean remnants)
Data Model / Provenance Updates
-
Extend chamfer result metadata:
source_edge_segment_ids[]generated_face_ids[]status: geometric_chamfer_ready
-
GeometryStore integration:
- chamfer faces emit boundaries/segments directly
- chamfer faces carry source edge lineage
-
Preserve compatibility:
- existing docs still readable
- optional fallback to legacy boolean chamfer behind feature flag
Algorithm Plan
Stage A: Topology Extraction
-
Build edge->incident-face adjacency from input mesh.
-
Identify valid chamfer candidates:
- manifold edges with exactly two incident faces
- non-smooth crease threshold gating
-
Group selected edges into connected chamfer regions.
Stage B: Per-Edge Offset Construction
-
For each selected edge:
- compute incident face normals
- construct two offset face planes
- compute chamfer line as plane-plane intersection in local neighborhood
-
Create edge strip endpoints using neighboring trim constraints.
Stage C: Face Trimming + Insertion
- Trim original incident faces against chamfer boundary lines.
- Insert chamfer quad/tri strip faces.
- Maintain winding and local normal consistency.
Stage D: Vertex Corner Solver
-
At each selected vertex:
- collect incoming chamfer strips
- solve intersection polygon in tangent frame
- triangulate corner patch deterministically
-
Handle edge cases:
- 2-edge corner
- n-edge star corner
- near-parallel incident faces
Stage E: Rebuild + Mapping
- Rebuild indexed mesh with new vertices/faces.
- Recompute boundary segments and canonical edge refs.
- Emit provenance mappings:
- old edge ref -> new chamfer face/segments
- unchanged faces preserve IDs where possible
Execution Phases
Phase 1: Infrastructure + Feature Flag
- Add
chamfer_modetoggle:legacy_boolean(default initially)geometric_offset(new path)
- Build shared adjacency/topology helpers.
Exit criteria:
- New path can run no-op safely and fall back cleanly.
Phase 2: Single-Edge Geometric Chamfer
- Implement robust one-edge chamfer on simple prism/cube cases.
- Add deterministic unit fixtures.
Exit criteria:
- Single selected edge produces expected geometry with no booleans.
Phase 3: Multi-Edge Same-Face + Parallel Chains
- Handle multiple selected edges on same body.
- Ensure trim interactions are stable and watertight.
Exit criteria:
- Common user workflows work without mesh cracks.
Phase 4: Corner Solver
- Implement n-edge corner patches.
- Add tolerance policy and degeneracy handling.
Exit criteria:
- Complex corners no longer require boolean fallback.
Phase 5: Provenance + GeometryStore Wiring
- Emit chamfer-derived boundaries/patch IDs with lineage.
- Update hover/select mapping for chamfer outputs.
Exit criteria:
- Chamfer boundaries are first-class and traceable.
Phase 6: Default Cutover
- Make geometric mode default.
- Keep legacy boolean fallback for one release window.
- Remove legacy path after stability window.
Testing Plan
Unit
- Edge adjacency correctness.
- Plane offset/intersection math.
- Corner patch triangulation determinism.
- Degenerate geometry tolerance behavior.
Integration
- Cube single-edge chamfer.
- Multiple connected edges.
- Concave/convex mixed selections.
- Timeline edits upstream/downstream with stable refs.
- Interaction with boolean-added bodies.
Regression
- No face holes/non-manifold edges after chamfer.
- No ID churn for unaffected faces.
- Boundary segment refs remain selectable post-chamfer.
Risks and Mitigations
-
Risk: corner solver complexity.
- Mitigation: staged rollout with strict fixtures before cutover.
-
Risk: precision instability on small geometry.
- Mitigation: unified epsilon policy + local frame math.
-
Risk: behavior divergence from existing chamfer expectations.
- Mitigation: side-by-side mode comparison tooling and temp dual-run validator.
Implementation Touchpoints
-
src/void/solid/chamfer.js- split into legacy boolean and new geometric engine.
-
src/void/solid/rebuild.js- route chamfer feature to mode-specific executor.
-
src/void/api/solids.js- preserve/refit canonical edge mappings after geometric chamfer.
- expose chamfer lineage for debug overlays.
-
src/void/api/geometry_store.js- ensure chamfer outputs emit boundary/segment/provenance records consistently.
Immediate Next Step
Implement Phase 1 + Phase 2 in parallel:
- Add mode flag and new engine scaffolding.
- Land deterministic single-edge geometric chamfer on planar solids.