Enum SdfPrimitive
#[repr(C)]pub enum SdfPrimitive {
Sphere {
radius: f32,
},
RoundedBox {
half_extents: [f32; 3],
bevel_radius: f32,
},
Capsule {
radius: f32,
half_height: f32,
},
Torus {
major_radius: f32,
minor_radius: f32,
},
SmoothUnionPair {
center_a: [f32; 3],
radius_a: f32,
center_b: [f32; 3],
radius_b: f32,
blend_radius: f32,
},
}Expand description
Analytical SDF primitive shapes evaluated in $O(1)$ local coordinates.
Variants§
Sphere
Exact sphere of given radius centered at local origin.
RoundedBox
Exact rounded box with half-extents [hx, hy, hz] and corner fillet bevel_radius.
Capsule
Exact vertical capsule along local Y-axis ([-half_height, +half_height]) with radius.
Torus
Exact torus in the local XZ plane with major_radius and minor_radius.
SmoothUnionPair
$C^1$ polynomial smooth-minimum union of two spheres along local X/Y/Z.
Implementations§
§impl SdfPrimitive
impl SdfPrimitive
pub fn evaluate_local(&self, p: [f32; 3]) -> f32
pub fn evaluate_local(&self, p: [f32; 3]) -> f32
Evaluates the exact signed distance $d = \text{sdf}(\mathbf{p})$ in local space.
Negative inside the volume, zero on the boundary, positive outside.
pub fn gradient_normal_local(&self, p: [f32; 3]) -> [f32; 3]
pub fn gradient_normal_local(&self, p: [f32; 3]) -> [f32; 3]
Evaluates the unit outward gradient normal $\mathbf{n} = \frac{\nabla\text{sdf}(\mathbf{p})}{|\nabla\text{sdf}(\mathbf{p})|}$
in local space using the symmetric 4-sample tetrahedron finite-difference stencil
(identical to HOLOGRAPHIC_WGSL).
pub fn evaluate_world(
&self,
motor_world: &Motor,
p_world: [f32; 3],
) -> (f32, [f32; 3])
pub fn evaluate_world( &self, motor_world: &Motor, p_world: [f32; 3], ) -> (f32, [f32; 3])
Evaluates signed distance and world-space outward normal for a world query point p_world
given the SDF collider’s world PGA [Motor].
pub fn local_half_extents(&self) -> [f32; 3]
pub fn local_half_extents(&self) -> [f32; 3]
Returns conservative local-space half-extents [hx, hy, hz] enclosing the SDF zero-isosurface.
Trait Implementations§
§impl Clone for SdfPrimitive
impl Clone for SdfPrimitive
§fn clone(&self) -> SdfPrimitive
fn clone(&self) -> SdfPrimitive
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more