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 moreimpl Copy for SdfPrimitive
§impl Debug for SdfPrimitive
impl Debug for SdfPrimitive
§impl Default for SdfPrimitive
impl Default for SdfPrimitive
§fn default() -> SdfPrimitive
fn default() -> SdfPrimitive
§impl PartialEq for SdfPrimitive
impl PartialEq for SdfPrimitive
impl StructuralPartialEq for SdfPrimitive
Auto Trait Implementations§
impl Freeze for SdfPrimitive
impl RefUnwindSafe for SdfPrimitive
impl Send for SdfPrimitive
impl Sync for SdfPrimitive
impl Unpin for SdfPrimitive
impl UnsafeUnpin for SdfPrimitive
impl UnwindSafe for SdfPrimitive
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more