pub enum SdfNode {
Show 23 variants
Sphere {
radius: f32,
},
Box {
half_extents: Vec3,
},
RoundedBox {
half_extents: Vec3,
radius: f32,
},
Torus {
major_radius: f32,
minor_radius: f32,
},
Cylinder {
radius: f32,
half_height: f32,
},
Capsule {
start: Vec3,
end: Vec3,
radius: f32,
},
Cone {
radius: f32,
height: f32,
},
Plane {
normal: Vec3,
offset: f32,
},
Union(Box<SdfNode>, Box<SdfNode>),
Subtract(Box<SdfNode>, Box<SdfNode>),
Intersect(Box<SdfNode>, Box<SdfNode>),
SmoothUnion {
left: Box<SdfNode>,
right: Box<SdfNode>,
k: f32,
},
SmoothSubtract {
left: Box<SdfNode>,
right: Box<SdfNode>,
k: f32,
},
SmoothIntersect {
left: Box<SdfNode>,
right: Box<SdfNode>,
k: f32,
},
Translate {
child: Box<SdfNode>,
offset: Vec3,
},
Rotate {
child: Box<SdfNode>,
rotation: Quat,
},
Scale {
child: Box<SdfNode>,
factor: f32,
},
Mirror {
child: Box<SdfNode>,
axes: [bool; 3],
},
RepeatFinite {
child: Box<SdfNode>,
spacing: Vec3,
limit: [u32; 3],
},
Twist {
child: Box<SdfNode>,
rate: f32,
},
Bend {
child: Box<SdfNode>,
rate: f32,
},
Onion {
child: Box<SdfNode>,
thickness: f32,
},
Displace {
child: Box<SdfNode>,
amplitude: f32,
frequency: f32,
},
}Expand description
Composable Signed Distance Field (SDF) and Constructive Solid Geometry (CSG) expression tree.
Variants§
Sphere
Sphere centered at the origin with radius radius.
Box
Axis-aligned box centered at the origin with half_extents.
RoundedBox
Beveled axis-aligned box with outer half_extents and corner rounding radius.
Torus
Torus in the XZ plane around the Y axis.
Cylinder
Capped vertical cylinder centered at the origin along Y.
Capsule
Capsule segment spanning from start to end with spherical cap radius.
Fields
Cone
Bounded upright cone centered at the origin along Y with base radius radius and height height.
Plane
Infinite half-space bounded by plane dot(p, normal) = offset.
Union(Box<SdfNode>, Box<SdfNode>)
Exact CSG union (min(left, right)).
Subtract(Box<SdfNode>, Box<SdfNode>)
Exact CSG subtraction carving right out of left (max(left, -right)).
Intersect(Box<SdfNode>, Box<SdfNode>)
Exact CSG intersection (max(left, right)).
SmoothUnion
Polynomial smooth CSG union blending two fields across radius k.
Fields
SmoothSubtract
Polynomial smooth CSG subtraction carving right out of left with fillet radius k.
Fields
SmoothIntersect
Polynomial smooth CSG intersection blending the overlap boundary across radius k.
Fields
Translate
Translates child by offset.
Rotate
Rotates child by unit quaternion rotation.
Scale
Uniformly scales child by positive factor with exact distance compensation.
Mirror
Mirrors child across any combination of the X, Y, and Z coordinate planes.
Fields
RepeatFinite
Repeats child on a finite 3D lattice with cell spacing and half-count limit.
Fields
Twist
Twists child smoothly around the Y axis at rate radians per unit height.
Bend
Bends child smoothly in the XY plane at rate radians per unit X.
Onion
Hollows child into a thin shell of wall half-thickness thickness (|d| - thickness).
Displace
Perturbs child with deterministic analytic trigonometric displacement.
Implementations§
Source§impl SdfNode
Composable constructors, zero-allocation signed-distance evaluation, and analytic gradients for SdfNode.
impl SdfNode
Composable constructors, zero-allocation signed-distance evaluation, and analytic gradients for SdfNode.