a3a7ff4a6b
Rule A (area-sorted triangle removal) left holes and open boundaries on closed meshes (visible artifacts when zoomed far out). The decimator is now a proper quadric edge collapse: - Collapse: welded u32 topology, per-vertex quadrics (accumulated incident face planes), edge cost = quadric error at the optimal point (clamped to the segment) + edge length, BinaryHeap with a custom Ord (f32 is not Ord; inverted compare, NaN-safe). - Standard GH semantics WITHOUT the new face: both incident pair faces degenerate and are removed; neighbouring faces remap and sweep over the region. Preserves the Euler characteristic and closedness (no holes, no books, no duplicate faces); interior collapse = -2 faces, boundary = -1. Guards: non-manifold edge (>2 faces) or a fold (duplicate sorted triple) rejects the collapse. - welded(): fuzzy welding (1e-6 relative tolerance, grid + 27- neighbour broad phase, exact verify) - trig-generated seams differ by ~1e-16, exact-bit welding missed them. - Root causes fixed along the way: dead face slots are never reused (stale edge/vface entries), vfaces updated on remap, degenerate faces dropped, best-effort target (granularity -2/-1 can land 1-2 off; soft cap, deterministic). - Docs: DRAFT D10, ROADMAP 4.3, ARCHI_CPU_GPU, gpu-driven, lib README, mesh/scene/demo comments - 'greedy decimation / Rule A' replaced by 'quadric edge collapse'. - lod.rs test: deprecated glam perspective alias -> explicit glam::camera::rh::proj::opengl::perspective. cargo test --workspace: 100 passed (94 lib + 3 wgsl + 3 integration), 0 failed; demo runs clean with LOD on.
Examples
Each .rs file in this directory is a standalone example auto-discovered by Cargo
(cargo build -p wsg-lib --examples). To run an example:
cargo run -p wsg-lib --example <name>
| Example | Command | Description |
|---|---|---|
demo |
cargo run -p wsg-lib --example demo |
Showcase: one of each primitive, procedural textures, directional + point + spot lights, a shadow-casting light, and a live orbital camera (drag / wheel zoom / R reset / 1-3 presets). |
simple |
cargo run -p wsg-lib --example simple |
Flat unlit quad (minimal declarative workflow, AppBuilder + auto scene). |
cube |
cargo run -p wsg-lib --example cube |
Textured cube (procedural checker) lit by a directional + point + spot light. |
manual |
cargo run -p wsg-lib --example manual |
Low-level workflow: Context, Renderer, PipelineCache, Mesh used directly (no App facade). |
spot_test |
cargo run -p wsg-lib --example spot_test |
Spot-light isolation: only one spot is on (near-zero ambient), cube rotates on two axes so the oriented beam is clearly visible. |
shadow_test |
cargo run -p wsg-lib --example shadow_test |
Shadow mapping: one directional light is the shadow caster (set_shadow_caster(Some(0))); a cube casts a PCF-softened shadow onto a thin ground slab. |
Conventions
- Examples are self-contained: no assets loaded from disk (procedural textures, hardcoded geometry).
- They use the declarative workflow (
AppBuilder+Scene) exceptmanual, which bypasses theAppfacade. - When adding a new example: create a
.rsfile in this directory, document it here, and reference it in the root README if appropriate.