Skip to content

feat: production-grade 4D primitive catalog, lighting, CI, docs#16

Merged
sigilmakes merged 8 commits into
mainfrom
feature/engine-expansion
Jun 10, 2026
Merged

feat: production-grade 4D primitive catalog, lighting, CI, docs#16
sigilmakes merged 8 commits into
mainfrom
feature/engine-expansion

Conversation

@sigilmakes

Copy link
Copy Markdown
Owner

Summary

This branch takes Rust4D from a small tesseract/hyperplane renderer to a much more professional 4D engine foundation:

  • full 4D primitive catalog (regular polytopes + curved product shapes)
  • scene integration and physics collider hints
  • headless visual showcase for all primitives
  • two-sided Blinn-Phong lighting, point lights, fog
  • semantic input action mapping
  • safer Lua hecs entity handle round-trips
  • GitHub Actions CI
  • full shape catalog docs + changelog + project skills

Highlights

4D primitive catalog

Adds Mesh4D and built-in primitives:

  • tesseract
  • hypersphere
  • pentachoron / 5-cell
  • hexadecachoron / 16-cell
  • icositetrachoron / 24-cell
  • hexacosichoron / 600-cell
  • spherinder
  • cubinder
  • duocylinder

Every primitive is pinned by index validation, watertightness (Mesh4D::is_watertight), and boundary-volume tests. The 600-cell is generated from binary icosahedral group vertices; cells are the 4-cliques of the edge graph.

Bonus geometry fix

The old tesseract emitted 84 tetrahedra from a Kuhn 4-cube decomposition, but 36 were internal membranes. The renderer only needs the 48 boundary tetrahedra. This removes ~43% wasted slice work for the default object and prevents spurious interior walls.

Visual verification

Adds examples/shape_showcase.rs, rendering every primitive at 3 slice offsets × 3 orientations through the real offscreen GPU slice/render pipelines:

  • 81 captures
  • 0 zero-triangle captures
  • contact sheet visually inspected

Rendering polish

RenderUniforms and render.wgsl now support:

  • two-sided normal handling (required because slice triangle winding is not stable)
  • Blinn-Phong diffuse/specular
  • up to 4 point lights
  • W-depth color blending
  • distance fog
  • back-face culling disabled intentionally

Workflow polish

  • GitHub Actions: rustfmt, clippy -D warnings, rustdoc -D warnings, workspace tests
  • workspace is rustfmt clean
  • new project skills: 4D geometry, headless visual verification, production readiness
  • docs/shapes.md catalog and CHANGELOG.md

Verification

Final gate run locally:

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
  • cargo test --workspace — 984 passed
  • cargo run --example shape_showcase -- .scratchpad/captures-gallery-lit — 81 captures, 0 zero-triangle frames

Known follow-ups

  • wgpu 24 → 25+ to remove naga Vulkan validation warning
  • floor checkerboard should become per-face/fragment pattern (currently smeared vertex gradient)
  • Lua ECS still needs a live hecs::World bridge. This PR adds safe hecs handle bit round-trips, but world.spawn/query/get/set remain stubs until VM/world ownership is designed.

…Mesh4D

- Mesh4D: general tetrahedral mesh (merge, weld via spatial hash, transform
  baking, validation, Gram-determinant cell volumes, face-pairing /
  watertightness check)
- primitives::polytopes: pentachoron (5-cell), hexadecachoron (16-cell),
  icositetrachoron (24-cell, 96 tets via octahedral cell splitting),
  hexacosichoron (600-cell: 120 binary-icosahedral-group vertices, 600
  cells found as 4-cliques of the edge graph)
- primitives::curved: hypersphere (refined 16-cell boundary, O(h²)
  convergence to 2π²r³), spherinder, cubinder, duocylinder — all built on
  Dompierre lowest-index prism splitting with shared vertex pools for
  crack-free seams
- fix(tesseract): emit only the 48 boundary tetrahedra instead of all 84
  Kuhn tets — the 36 internal membranes wasted ~43% of slice work and
  rendered as spurious walls from inside; boundary is now watertight
- every primitive pinned by structure, watertightness, and closed-form
  boundary-volume tests (+37 tests)
- ShapeTemplate variants: Hypersphere, Pentachoron, Hexadecachoron,
  Icositetrachoron, Hexacosichoron, Spherinder, Cubinder, Duocylinder
  (resolution fields default via serde so scene files stay terse)
- bounding_radius() closed-form per variant; ColliderHint maps round
  shapes to sphere colliders, others to conservative AABBs
- scene instantiation uses collider hints instead of hardcoded
  tesseract-only half-extents
- RON round-trip + defaults + collider hint tests (+4 tests)
- scenes/gallery.ron: floor plus all nine primitive exhibits (tesseract,
  hypersphere, 5-cell, 16-cell, 24-cell, 600-cell, spherinder, cubinder,
  duocylinder), with a dynamic hypersphere to exercise collider hints
- examples/shape_showcase: offscreen GPU renderer for every primitive across
  three slice offsets and three orientations; writes PPM frames and logs
  triangle counts, using the real slice + render pipelines
- tests/gallery_scene: parses and instantiates the gallery through
  SceneManager, verifies all primitive variants are present, and builds
  renderable geometry

Verification:
- cargo run --example shape_showcase -- .scratchpad/captures-gallery
  produced 81 captures, zero zero-triangle frames
- contact-sheet.png visually checked from central slices
- cargo clippy --workspace --all-targets -- -D warnings
- RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
- cargo test --workspace (976 passed)
- RenderUniforms v2: camera position, specular parameters, fog, and up to
  four point lights (336-byte layout pinned against WGSL)
- render.wgsl: two-sided normal handling for arbitrary slice triangle
  winding, directional + point light Blinn-Phong, W-color blending, and
  exponential distance fog
- render pipeline disables back-face culling, matching the slice shader's
  non-stable winding
- all examples and render system inherit new uniform defaults

Verification:
- cargo run --example shape_showcase -- .scratchpad/captures-gallery-lit
  produced 81 captures, zero zero-triangle frames; contact sheet visually
  checked
- cargo clippy --workspace --all-targets -- -D warnings
- RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
- cargo test --workspace (977 passed)
Run cargo fmt --all so CI can enforce formatting consistently across the
workspace. Mechanical formatting only.
- GitHub Actions CI: fmt, clippy -D warnings, rustdoc -D warnings, workspace tests
- 4d-geometry skill: Mesh4D/watertightness/prism-splitting workflow
- headless-visual-verification skill: shape_showcase + invariant capture workflow
- production-readiness skill: final PR/release checklist
… round-trips

- rust4d_input::ActionMap + CameraAction: default WASD/QE/Space/Shift
  bindings are now data instead of hardcoded controller matches
- CameraController consumes semantic actions, supports custom maps via
  with_action_map/action_map_mut, and keeps legacy process_keyboard behavior
- Lua ECS binding exposes entity_from_bits(bits) and entity:equals(other),
  with LuaEntity helpers wrapping real hecs::Entity bit patterns even in
  disconnected stub mode

Verification:
- cargo test -p rust4d_input -p rust4d_scripting
- cargo clippy --workspace --all-targets -- -D warnings
- RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
- cargo test --workspace (984 passed)
- docs/shapes.md: full built-in shape catalog with construction math,
  cell counts, RON snippets, slice behavior, and verification workflow
- README/docs index/examples README link the catalog and shape_showcase
- user/developer guides point to the full catalog and update tesseract
  boundary-cell details
- CHANGELOG records PR #15 and the engine-expansion branch

Verification:
- cargo fmt --all -- --check
- cargo clippy --workspace --all-targets -- -D warnings
- RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
- cargo test --workspace (984 passed)
@sigilmakes sigilmakes merged commit 0fae2c9 into main Jun 10, 2026
2 checks passed
@sigilmakes sigilmakes deleted the feature/engine-expansion branch June 10, 2026 10:06
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