Skip to main content

Module geom

Module geom 

Source
Expand description

Analytic ray/membership evaluation of a DynamicObject tree.

A tree is flattened into supported primitive leaves (GeomLeaf, each carrying its accumulated world transform) plus a boolean expression over them (CsgExpr). Rays are intersected per leaf in local space and the resulting t-intervals are combined through the booleans (classic ray-CSG with normal flipping under Difference), so a hit identifies the final solid’s surface: leaf, face tag, and outward normal — with no meshing.

§Conventions

  • Primitive anchors follow the backend contract pinned in rscad-csg-traits/src/dynamic.rs: cube corner-anchored spanning [0, size], cylinder/cone base on y = 0 extending along +Y, sphere centered at the origin.
  • Rotate accumulates as Rz·Ry·Rx (OpenSCAD order), matching every renderer (DynamicObject::extract_top_transforms, the SDF compiler, Manifold). Note SceneGraph::world_transform currently uses XYZ order — a pre-existing divergence; this module must match the pixels.
  • A zero-length Mirror axis yields empty geometry (Manifold behavior).
  • Bare 2D leaves in 3D context evaluate to empty (Manifold semantics).
  • Rays keep their (unnormalized) world parameterization in local space, so t values are directly comparable across leaves.

Structs§

CsgLeaves
Flattened analytic model of one tree: primitive leaves + boolean structure.
GeomLeaf
A primitive leaf with its accumulated world transform.
HitBoundary
One surface crossing along a ray.
HitSpan
A solid stretch of the ray: enter.t < exit.t.

Enums§

CsgExpr
Boolean structure over leaf indices into CsgLeaves::leaves.
LeafPrim
A supported primitive in its local frame.

Type Aliases§

AabbHint
Callback supplying a conservative local-space AABB for a subtree this module cannot evaluate analytically (sketch/extrude/revolve/offset based). Returning None drops the subtree from the model (it stops occluding).