Make extracted vg-csg standalone

This commit is contained in:
Meta Vens 2026-05-07 22:52:50 +01:00
commit 1adeadc74d
10 changed files with 1195 additions and 9 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
target/
experiments/generated/
*.pdb

1081
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2024"
description = "Lean Bevy-math constructive geometry assembler for VibeGeometry blockouts"
license = "MIT"
repository = "https://github.com/GameCult/vg-csg"
readme = "README.md"
[dependencies]
bevy_math = "0.17"

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 GameCult
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

83
README.md Normal file
View file

@ -0,0 +1,83 @@
# vg-csg
Lean constructive geometry tooling for Rust/Bevy-math scene blockouts.
`vg-csg` is the extracted CSG kernel from VibeGeometry. It is not trying to be
a full CAD kernel. It is a small, inspectable machine for agent-authored level
and habitat geometry:
- ordered additive, subtractive, and intersecting brush streams
- axis-aligned and oriented box CSG through convex plane splitting
- RealtimeCSG-shaped public vocabulary for operations, branches, trees, and
dirty brush generations
- exact observable parity fixtures where the public RealtimeCSG/demo API surface
overlaps
- mesh-array output suitable for Bevy-side ingestion
- dirty-frontier and prefix-checkpoint experiments for realtime editing
- additive habitat primitives used by the current examples
The crate is young and sharp in the places young crates are sharp. It exists so
we can build concrete fixtures, profile real edits, and grow the API from
working procedural scenes instead of designing the perfect museum label first.
## Quick Start
```powershell
cargo test
cargo run --example csg_room
cargo run --example dream_machine_level
cargo run --example industrial_maintenance_loop
```
The showpiece examples write OBJ/MTL/SVG artifacts under:
```text
experiments/generated/
```
## Core Shape
```rust
use bevy_math::{Quat, Vec3};
use vg_csg::{LevelDsl, MaterialId};
let mut level = LevelDsl::new();
level.solid_box(
"wall",
Vec3::new(0.0, 0.0, 1.5),
Vec3::new(5.0, 0.3, 3.0),
MaterialId(1),
);
level.cut_oriented_box(
"angled doorway",
Vec3::new(0.0, 0.0, 1.2),
Vec3::new(1.4, 0.8, 2.2),
Quat::from_rotation_z(0.25),
);
let output = level.assemble();
println!("triangles={}", output.mesh.triangle_count());
```
## Doctrine
CSG is the adjudicator, not the authoring language. Good procedural scenes
should still be written in the coordinate system that belongs to the domain:
room bay, curved shell segment, manifold face, staging rail, brush tree, dirty
frontier. Compile those local claims into CSG brushes late.
That bias is visible in `examples/industrial_maintenance_loop.rs`, where a
curved habitat room is authored in tangent/radial/up space and then lowered into
world-space oriented boxes and mesh bands.
## Docs
Research and implementation notes live in `docs/`:
- `docs/realtime-csg-bevy-assembler.md`
- `docs/realtime-csg-doctrine.md`
- `docs/csg-performance-fixtures.md`
## License
MIT

View file

@ -181,7 +181,7 @@ for the real engine.
## Incremental Dirty Smoke Run
Captured on 2026-05-07 with
`cargo run -p vg_csg --release --example csg_perf_fixture`. Dirty modes mutate
`cargo run --release --example csg_perf_fixture`. Dirty modes mutate
the tail brush each iteration. `incremental_dirty` uses prefix checkpoints and
falls back to full replay only when no valid checkpoint exists.

View file

@ -41,7 +41,7 @@ to Bevy render assets.
## Current Port Shape
`crates/vg_csg` is the first lean Rust organ.
`vg-csg` is the first lean Rust organ.
It uses `bevy_math` for `Vec3`, `Vec2`, and Bevy-compatible spatial types while
keeping output as simple arrays:
@ -94,7 +94,7 @@ should preserve brush polygons, classify them through the tree, and emit only
the visible categories.
The expanded doctrine lives in
`docs/research/realtime-csg-doctrine.md`; keep this file focused on the current
`docs/realtime-csg-doctrine.md`; keep this file focused on the current
crate shape.
Procedural non-CSG primitives are additive:
@ -182,7 +182,7 @@ So the near-term spatial plan is:
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
Performance fixtures live in `docs/csg-performance-fixtures.md` and
`tools/run_csg_perf.ps1`. They time our release fixture now and reserve a JSONL
slot for a public-demo/reference harness when one is available.

View file

@ -347,8 +347,6 @@ fn seeded_wave(value: f32) -> f32 {
fn output_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("experiments")
.join("generated")
.join("dream_machine_level")

View file

@ -728,8 +728,6 @@ fn polar_point(radius: f32, angle: f32, z: f32) -> Vec3 {
fn output_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("experiments")
.join("generated")
.join("industrial_maintenance_loop")

View file

@ -13,7 +13,7 @@ New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
Push-Location $root
try {
cargo build --release -p vg_csg --example csg_perf_fixture | Out-Host
cargo build --release --example csg_perf_fixture | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "vg_csg perf fixture build failed with exit code $LASTEXITCODE"
}