diff --git a/docs/research/realtime-csg-bevy-assembler.md b/docs/research/realtime-csg-bevy-assembler.md index 2742bca..adb3763 100644 --- a/docs/research/realtime-csg-bevy-assembler.md +++ b/docs/research/realtime-csg-bevy-assembler.md @@ -162,8 +162,25 @@ or sweep than by carving: The immediate next upgrade is not "more primitives." It is the category-router kernel: split crossing polygons, route classified source polygons through -boolean branches, preserve material/surface metadata, and then add a BVH or -spatial hash so cutter cost does not scale like a punishment. +boolean branches, and preserve material/surface metadata. + +The next accelerator should not be a reflexive BVH-shaped apology. The +EpiphanyAquarium memory points at a stronger pattern from GigaVoxels, froxels, +and Dreams: let the consumer define the query frontier. For CSG, the consumer is +not always "the whole scene." It can be the moved brush, the current branch, the +editor tile, the requested output mesh, or the visible/view-tested surface set. +So the near-term spatial plan is: + +- use branch and brush bounds as semantic gates before cutting; +- keep dirty/touched brush discovery separate from polygon classification; +- build affected brush-pair or surface-frontier batches from those gates; +- measure those batches before adding a generic BVH, loose grid, or spatial + hash; +- only promote an index if it beats the demand-shaped frontier on dirty rebuilds + and preserves exact output parity. + +Sideways version: do not ask every cutter whether it matters. Ask the branch, +dirty region, and requested output which pairs deserve to exist this frame. Performance fixtures live in `docs/research/csg-performance-fixtures.md` and `tools/run_csg_perf.ps1`. They time our release fixture now and reserve a JSONL diff --git a/docs/research/realtime-csg-doctrine.md b/docs/research/realtime-csg-doctrine.md index ee47b14..c01f0c8 100644 --- a/docs/research/realtime-csg-doctrine.md +++ b/docs/research/realtime-csg-doctrine.md @@ -142,6 +142,28 @@ Implication for `vg_csg`: every brush, polygon batch, and branch needs cheap bounds. Later BVH, hashed grid, or sweep-and-prune should be measured against the built-in tree culling instead of assumed superior by vibes in a lab coat. +The EpiphanyAquarium research memory adds a sharper rule: treat spatial queries +as a demand problem before treating them as an index problem. GigaVoxels uses +visible rays as the oracle for which bricks deserve high resolution. Wronski fog +uses the camera froxel volume as the field where sources are injected once and +sampled many times. Dreams' prototype refined frustum cells, shortened object +lists as cells split, then switched to per-pixel sorted lists that could truncate +at the first solid hit. + +For `vg_csg`, that translates to consumer-shaped query frontiers: + +- dirty brush movement asks for affected brush pairs, not a world rebuild; +- branch evaluation asks for left/right bounds gates before polygon tests; +- an editor viewport or tile asks for surfaces that can contribute to the + requested output, not every latent overlap in the level; +- repeated cutters ask for cached pair classifications or brush-frontier batches, + not a thousand independent list walks. + +This does not outlaw BVHs, grids, or sweep-and-prune. It demotes them. They are +candidate storage layouts for a demand frontier, not the central idea. The +central idea is that the request already contains spatial information; make the +kernel exploit that before building a generic little bureaucracy with boxes. + ### 7. Realtime Means Incremental, Not Global The public notes frame the algorithm as fast for updating affected brushes, not @@ -273,8 +295,10 @@ Algorithm migration steps: 6. Implement boolean branch routing using category list swizzles. 7. Add bounds early-outs before every expensive classification. 8. Add dirty-set and touching-brush discovery. -9. Convert categorized visible polygons to Bevy mesh buffers. -10. Benchmark global rebuild, affected-brush rebuild, and worst-case overlap +9. Add a demand-frontier prototype that produces affected brush-pair batches + from dirty brushes, branch bounds, and requested output scope. +10. Convert categorized visible polygons to Bevy mesh buffers. +11. Benchmark global rebuild, affected-brush rebuild, and worst-case overlap scenes before making performance claims. ## Acceptance Tests To Add @@ -303,8 +327,10 @@ Algorithm migration steps: cut material? - Should Bevy output preserve large n-gons for later optimization, or triangulate at the boundary immediately? -- What is the best initial spatial rejection structure after branch bounds: - loose grid, BVH, sweep-and-prune, or no extra structure until profiling says - the tree culling is insufficient? +- What is the smallest demand frontier after branch bounds: dirty affected + brush pairs, viewport/tile-frontier batches, pair-classification caches, or no + extra structure until profiling says tree culling is insufficient? +- If a frontier needs storage, which layout wins under dirty rebuild timings: + loose grid, BVH, sweep-and-prune, pair cache, or sorted frontier batches? - How much topology should live in reusable library code versus Bevy ECS components? diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 65b89a8..d18d88e 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -81,8 +81,17 @@ Repo-local Geometry Script clone notes live in missing. The current next action is to replace the ordered `vg_csg` dense rotated -subtraction path with the category-router kernel while keeping cached-vs-dirty -output parity tests green and comparing against the C++ timing oracle. +subtraction path with the category-router kernel, then prototype a +demand-shaped affected-pair frontier before adding any generic BVH/grid spatial +index. Keep cached-vs-dirty output parity tests green and compare against the +C++ timing oracle. + +Spatial-query correction from EpiphanyAquarium memory: GigaVoxels, froxels, and +Dreams all point away from static "better tree" thinking. Let the consumer +shape the query frontier first: dirty brush, branch bounds, requested output +tile/view, or visible surface set. BVHs, grids, sweep-and-prune, and pair caches +are candidate layouts only after that frontier exists and timing evidence says +they help. ## Important Invariants diff --git a/state/evidence.jsonl b/state/evidence.jsonl index a02a5ea..4ed5980 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -61,3 +61,4 @@ {"ts": "2026-05-07T02:27:49+00:00", "type": "implementation", "status": "ok", "note": "RealtimeCSG native bridge now reaches mesh extraction and timing: matching the public Foundation path (brushes first, tree second, InsertChildNodeRange, no redundant default brush setters) converts the direct DLL bridge from zero mesh descriptions to health cube mesh descriptions and full perf fixture records."} {"ts": "2026-05-07T02:49:43+00:00", "type": "implementation", "status": "ok", "note": "CSG speed pass kept parity tests green while adding an axis-aligned box fast path, compiled brush geometry cache, owned convex splitting, clipping allocation reserves, and stable-generation output caching. Stable-tree fixture now beats or matches the direct C++ bridge on sampled scenarios, but dirty dense rotated subtraction still needs category-router work."} {"ts": "2026-05-07T03:31:28+00:00", "type": "implementation", "status": "ok", "note": "Added explicit stable and dirty vg_csg perf modes, public rebuild() bypassing stable output cache, cached-vs-dirty output parity test, and convex containment shortcuts. Latest fixture shows dirty box-heavy and distant-rejection paths are respectable; dirty dense rotated subtraction remains the next category-router target."} +{"ts": "2026-05-07T06:57:45+00:00", "type": "research", "status": "accepted", "note": "EpiphanyAquarium persisted memory changes the vg_csg acceleration prior: before adding a generic BVH/grid/sweep index, prototype demand-shaped spatial frontiers driven by dirty brushes, branch bounds, requested output scope, and visible/tile surfaces. GigaVoxels/froxel/Dreams doctrine treats rays or consumers as the query oracle; indexes are storage layouts for that frontier, not the central idea."} diff --git a/state/map.yaml b/state/map.yaml index 9ac25ab..199e38a 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -111,7 +111,7 @@ data_flow: current_status: summary: VibeGeometry has verified Geometry Script translations for local samples, official Blender demos, and IRCSS French Houses footholds, plus from-scratch Aetheria Bloom and Lucent tether habitat builds. Durable lessons now driving the pipeline: Python orchestrates intent and batching; Geometry Script emits inspectable node groups; source-bound scenes need explicit coordinate contracts before ornament; spin-gravity habitats need ground planes orthogonal to their tether/rotation axis; utility petals, radiators, and solar arrays belong outside pressure glass and may need Citadel-scale presence; large habitat parts need visible load paths across coordinate frames; organic city maps need street fields, irregular parcels, parks, and land-use gradients rather than grids; dense detail must be batched; institutional spaces should model power as surfaces, rails, overlays, thresholds, shader behavior, and camera evidence; and visual acceptance needs domain-facing inspection renders plus verifier checks, not only overview renders. The first reusable `vibegeometry/` helper library now carries coordinate frames, fields, batching, Blender scene primitives, and verifier helpers used by the Bloom and Lucent builds. The Rust crate `vg_csg` now has a RealtimeCSG-shaped API skeleton plus a convex-brush stepping-stone kernel: CSG operation ordinals, branch vocabulary, tree/branch/brush handles, child and operation mutation, exact parity fixtures, ordered assembler compilation, AABB/oriented-box subtraction/intersection via convex plane splitting, crossing polygon category buckets, primitive/solid/tree bounds, additive cylinder/dome/floret primitives, JSONL performance fixtures with stable and dirty modes, mesh-array output, stable-generation output caching, tests, clippy, and examples. The `vg_grammar` crate is the Dream Machine authoring layer: semantic solid/void claims with tags compile into flat `vg_csg` brushes or generated CSG tree intent; it supports local frames, oriented claims, deterministic seeded variation, rule composition, and generated gallery chains. Public RealtimeCSG demo/source research points the target away from fragment carving and toward faster polygon classification through boolean trees. A standalone RealtimeCSG C++ P/Invoke bridge now mirrors the managed wrapper surface, verifies a native health cube, extracts generated mesh descriptions, and appends direct native timing records. Current perf pass: `vg_csg` has a fast axis-aligned path, cached compiled brush geometry, owned convex splitting, convex containment shortcuts, stable-tree output caching, and stable/dirty perf records; dirty box-heavy and distant-rejection paths are respectable, but dirty dense rotated subtraction still needs the category-router kernel. Known graph-tooling blockers remain repeat-zone feedback, repeat Top outputs, foreach zones, and gizmo nodes. - next_action: Replace the ordered `vg_csg` dense rotated subtraction path with the category-router kernel while keeping cached-vs-dirty output parity tests green and comparing against the C++ timing oracle. + next_action: Replace the ordered `vg_csg` dense rotated subtraction path with the category-router kernel, then prototype a demand-shaped affected-pair frontier before adding any generic BVH/grid spatial index; keep cached-vs-dirty output parity tests green and compare against the C++ timing oracle. remotes: vibegeometry: https://github.com/GameCult/VibeGeometry geometry_script_fork: https://github.com/GameCult/geometry-script