Skip to content

feat(core,lang): auto-smooth defaults, concave/hollow loft & 3D sheet, and O(V) scene instancing - #137

Merged
wrong-nebula merged 1 commit into
mainfrom
feat/auto-smooth-cloth-loft-scene-instancing
Dec 4, 2026
Merged

wrong-nebula merged 1 commit into
mainfrom
feat/auto-smooth-cloth-loft-scene-instancing

Conversation

@wrong-nebula

Copy link
Copy Markdown
Owner

Summary

Addresses the three shared frontier-model friction points surfaced by multi-model Forma bakeoffs (flat shading by default, concave/cloth loft() limits, and 10 MB / 500-piece ungrouped GLBs):

1. Auto-Smooth Default, Propagation, Spec Visibility & Smooth Studio Rendering

  • Default PolyMesh::new() to smooth_angle_deg = Some(35.0) and weighted_normals = true (DEFAULT_SMOOTH_ANGLE_DEG): keeps 45°/60°/90° hard edges razor-sharp while automatically shading domes, spheres, cylinders, bevels, lofts, and sheets smoothly (and welding GLB vertices cleanly). Opt out anytime with | flat().
  • Propagate smooth_angle_deg and weighted_normals cleanly through booleans (boolean.rs), Catmull-Clark subsurf, and QEM decimate (ops.rs).
  • Surface smooth(angle=35) and flat() directly in core SPEC_PIPE.
  • Add zero-allocation Gouraud shading (raster_tri_gouraud) driven by compute_corner_normals() and smooth-aware feature edge creases in render.rs so zero-GPU studio PNG previews match GLB shading.

2. Concave loft() Alignment + Watertight Thin-Shell Cloth Primitives

  • Replace independent per-ring centroid-angle rotation in resample_closed_2d with translation-invariant centered minimum-squared-distance cyclic alignment (align_ring_to_prev, with align=false opt-out), eliminating twisting/self-intersection on C-shaped, pleated, and concave profiles.
  • Add loft(..., t=...) (thickness / wall) in make_loft_ext for instant watertight open-ended hollow shells (genus 1, zero booleans).
  • Add sheet(rows, t=0.02, closed=false) (make_sheet) taking a 2D grid of 3D (x,y,z) points (usable directly with nested Forma-Pipe list comprehensions) thickened symmetrically along smooth vertex normals into a watertight manifold patch (closed=false, genus 0) or seamless 3D draped mantle/poncho (closed=true, genus 1).

3. Lean 3-Layer Scene Hierarchy, Automatic $O(V)$ GLB Deduplication & 64-Byte int4 Packaging Policy

  • Layer 1 (instancing.rs, zero extra LLM tokens): Deterministic $O(V)$ connectivity-hash + 4-point canonical basis (L = B * A^-1, verified per-vertex to < 1e-4 * diag, exact Y-up similarity transform) automatically deduplicates deep-transformed copies into 1 shared glTF mesh + per-node TRS.
  • Layer 2 (scene.rs, pipeline.rs, forma_pipe.gbnf): Add | group("pavilion/drum"), group("pavilion/drum", ["a", "b"]), and inst(proto, at=[...], rot=[...], scale=..., group="...", name="...") sharing a single Arc<PolyMesh> prototype (validated once under --strict, rendered in --scene PNG/SVG previews, transactional across checkpoint/rollback/undo/del, and collapsed to a single summary line in Scene::observe()).
  • Layer 3 (instancing.rs, export.rs): Add a 64-byte quantized 12 -> 8 -> 4 signed int4 packaging policy (choose_scene_pack_strategy, ~0.3 µs CPU/WASM, bit-exact) routing deduplicated clusters across Standalone, DataInstance (default core glTF 2.0), GpuInstance (EXT_mesh_gpu_instancing), and GpuInstanceSpatialCells (2×2×2 spatial cells for frustum culling via GlbSceneOptions::realtime()).

Benchmarks & Tests

  • 48 deep-transformed cylinders (zero script changes): 121,548 B → 9,632 B (48 meshes → 1 shared mesh, 12.6× smaller), exact read_glb_bytes round-trip.
  • 504-instance Pavilion + 2 hero parts:
    • Core glTF 2.0 (1 nested pavilion root, 4 meshes): 105.5 KB, observe() stays <= 14 lines.
    • GlbSceneOptions::realtime() (int4 policy → EXT_mesh_gpu_instancing): 35.6 KB.
  • Added regression & integration coverage in forma-core/src/instancing.rs, forma-core/tests/regression_fixes.rs, and forma-lang/tests/lang_expressiveness.rs; verified workspace --release tests and scripts/check_local_paths.py.

@wrong-nebula
wrong-nebula merged commit da3fbb7 into main Dec 4, 2026
3 checks passed
@wrong-nebula
wrong-nebula deleted the feat/auto-smooth-cloth-loft-scene-instancing branch December 4, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant