- Rust 85.4%
- C# 13.1%
- PowerShell 1.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| docs | ||
| examples | ||
| src | ||
| tests | ||
| tools | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
GameCult.Geometry.Csg
The project is known as CultGeometry CSG. Its Rust package is
gamecult-geometry-csg, exposed to Rust code as gamecult_geometry_csg.
Lean constructive geometry tooling for Rust/Bevy-math scene blockouts.
CultGeometry 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
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:
experiments/generated/
Core Shape
use bevy_math::{Quat, Vec3};
use gamecult_geometry_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.
Signed Distance
Assembler::distance(p) (and stream_distance over any brush slice) lowers the
same ordered brush stream to a scalar field instead of triangles: negative
inside, positive outside. Add folds with min, Subtract with max(d, -b),
Intersect with max. It is the seam for isosurface meshing and GPU field
refinement.
Boxes, oriented boxes and Z cylinders are exact distances. Domes (a half-ellipsoid) and floret arms (max of face planes) are bounds that are exact on the surface and never overestimate. The field honours every operation on every primitive, including the non-box cutters the polygon kernel currently warns about and skips.
Docs
Research and implementation notes live in docs/:
docs/realtime-csg-bevy-assembler.mddocs/realtime-csg-doctrine.mddocs/csg-performance-fixtures.md
License
MIT