Union

Struct Union 

Source
pub struct Union<Lhs, Rhs, Scalar: Float, State: SdfState<Scalar, DIM>, const DIM: usize>
where Lhs: Sdf<Scalar, DIM, State = State>, Rhs: Sdf<Scalar, DIM, State = State>,
{ /* private fields */ }
Expand description

Hard union of two SDFs.

See crate::combinators::SdfCombinationOperations for more information on how to use this.

Implementations§

Source§

impl<Lhs, Rhs, Scalar: Float, State: SdfState<Scalar, DIM>, const DIM: usize> Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State>, Rhs: Sdf<Scalar, DIM, State = State>,

Source

pub const fn new(lhs: Lhs, rhs: Rhs) -> Self

Trait Implementations§

Source§

impl<Lhs, Rhs, Scalar: Clone + Float, State: Clone + SdfState<Scalar, DIM>, const DIM: usize> Clone for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Clone, Rhs: Sdf<Scalar, DIM, State = State> + Clone,

Source§

fn clone(&self) -> Union<Lhs, Rhs, Scalar, State, DIM>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Lhs, Rhs, Scalar: Debug + Float, State: Debug + SdfState<Scalar, DIM>, const DIM: usize> Debug for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Debug, Rhs: Sdf<Scalar, DIM, State = State> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Lhs, Rhs, Scalar: Default + Float, State: Default + SdfState<Scalar, DIM>, const DIM: usize> Default for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Default, Rhs: Sdf<Scalar, DIM, State = State> + Default,

Source§

fn default() -> Union<Lhs, Rhs, Scalar, State, DIM>

Returns the “default value” for a type. Read more
Source§

impl<Lhs, Rhs, Scalar: Hash + Float, State: Hash + SdfState<Scalar, DIM>, const DIM: usize> Hash for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Hash, Rhs: Sdf<Scalar, DIM, State = State> + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Lhs, Rhs, Scalar: PartialEq + Float, State: PartialEq + SdfState<Scalar, DIM>, const DIM: usize> PartialEq for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + PartialEq, Rhs: Sdf<Scalar, DIM, State = State> + PartialEq,

Source§

fn eq(&self, other: &Union<Lhs, Rhs, Scalar, State, DIM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Lhs, Rhs, Scalar: Float, State: SdfState<Scalar, DIM>, const DIM: usize> Sdf<Scalar, DIM> for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State>, Rhs: Sdf<Scalar, DIM, State = State>,

Source§

type State = State

The state that is bound to this SDF. See SdfState for more information.
Source§

fn distance(&self, position: [Scalar; DIM]) -> Scalar

Evaluates the SDF at some point
Source§

fn state(&self, position: [Scalar; DIM]) -> Self::State

Evaluates the state of the SDF at some point. See SdfState for more information.
Source§

fn distance_and_state(&self, position: [Scalar; DIM]) -> (Scalar, Self::State)

Evaluates both the distance and the state of the SDF, hopefully a little bit faster than if you called both Sdf::distance and Sdf::state separately.
Source§

fn gradient(&self, position: [Scalar; DIM], epsilon: Scalar) -> [Scalar; DIM]

Calculates the gradient of the SDF at some point in space. Some SDF have analytical expressions of the gradient, some don’t. If a SDF doesn’t have an implementation, it will instead approximate it using epsilon. Read more
Source§

fn state_sample( &self, position: [Scalar; DIM], ) -> <Self::State as SdfState<Scalar, DIM>>::Sample

Evaluates, then samples the state of the SDF at some point. See SdfState for more information.
Source§

fn distance_and_state_sample( &self, position: [Scalar; DIM], ) -> (Scalar, <Self::State as SdfState<Scalar, DIM>>::Sample)

Evaluates both the distance and the sample of the state of the SDF, hopefully a little bit faster than if you called both Sdf::distance and Sdf::state_sample separately.
Source§

fn normal(&self, position: [Scalar; DIM], epsilon: Scalar) -> [Scalar; DIM]

Calculates the gradient, then normalizes it. The gradient typically is already normalized if the SDF is well formed and if we aren’t on some edge case, but we never know. Smooth combinations and the empty SDF are good counter examples.
Source§

fn normal_or_zero( &self, position: [Scalar; DIM], epsilon: Scalar, ) -> [Scalar; DIM]

Calculates the gradient, then normalizes it. If the norm is 0, then [0; DIM] is returned. The gradient typically is already normalized, but sometimes this isn’t the case, for example with the empty SDF.
Source§

fn gradient_approx( &self, position: [Scalar; DIM], epsilon: Scalar, ) -> [Scalar; DIM]

Calculates the gradient of the SDF at some point in space. It will approximate it using epsilon.
Source§

fn normal_approx( &self, position: [Scalar; DIM], epsilon: Scalar, ) -> [Scalar; DIM]

Calculates the normal of the SDF at some point in space. It will approximate the gradient using epsilon.
Source§

fn normal_or_zero_approx( &self, position: [Scalar; DIM], epsilon: Scalar, ) -> [Scalar; DIM]

Calculates the normal of the SDF at some point in space, and if the norm is 0, it will simply return [0; DIM]. It will approximate the gradient using epsilon.
Source§

impl<Lhs, Rhs, Scalar: Copy + Float, State: Copy + SdfState<Scalar, DIM>, const DIM: usize> Copy for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Copy, Rhs: Sdf<Scalar, DIM, State = State> + Copy,

Source§

impl<Lhs, Rhs, Scalar: Eq + Float, State: Eq + SdfState<Scalar, DIM>, const DIM: usize> Eq for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State> + Eq, Rhs: Sdf<Scalar, DIM, State = State> + Eq,

Source§

impl<Lhs, Rhs, Scalar: Float, State: SdfState<Scalar, DIM>, const DIM: usize> StructuralPartialEq for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sdf<Scalar, DIM, State = State>, Rhs: Sdf<Scalar, DIM, State = State>,

Auto Trait Implementations§

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> Freeze for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Freeze, Rhs: Freeze,

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> RefUnwindSafe for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: RefUnwindSafe, Rhs: RefUnwindSafe, Scalar: RefUnwindSafe, State: RefUnwindSafe,

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> Send for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Send, Rhs: Send, Scalar: Send, State: Send,

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> Sync for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Sync, Rhs: Sync, Scalar: Sync, State: Sync,

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> Unpin for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: Unpin, Rhs: Unpin, Scalar: Unpin, State: Unpin,

§

impl<Lhs, Rhs, Scalar, State, const DIM: usize> UnwindSafe for Union<Lhs, Rhs, Scalar, State, DIM>
where Lhs: UnwindSafe, Rhs: UnwindSafe, Scalar: UnwindSafe, State: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, Scalar, const DIM: usize> SdfBindTrait<Scalar, DIM> for T
where Scalar: Float, T: Sdf<Scalar, DIM>,

Source§

fn bind<State: SdfState<Scalar, DIM>>( self, state: State, ) -> Bound<Self, Scalar, State, DIM>

Source§

impl<T, Scalar, State, const DIM: usize> SdfCombinationOperations<Scalar, State, DIM> for T
where Scalar: Float + 'static, State: SdfState<Scalar, DIM>, T: Sdf<Scalar, DIM, State = State>,

Source§

fn add<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn mul<Rhs>(self, rhs: Rhs) -> Intersection<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn sub<Rhs>(self, rhs: Rhs) -> Difference<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn add_smooth_sigmoid<Rhs>( self, rhs: Rhs, factor: Scalar, ) -> SUnionSigmoid<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn add_smooth_exp<Rhs>( self, rhs: Rhs, factor: Scalar, ) -> SUnionExponential<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn mul_smooth_exp<Rhs>( self, rhs: Rhs, factor: Scalar, ) -> SIntersectionExponential<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

fn sub_smooth_exp<Rhs>( self, rhs: Rhs, factor: Scalar, ) -> SDifferenceExponential<Self, Rhs, Scalar, State, DIM>
where Rhs: Sdf<Scalar, DIM, State = State>,

Source§

impl<State, S> SdfRotationOperations<State> for S
where State: SdfState<f32, 3>, S: Sdf<f32, 3, State = State>,

Source§

fn rotate(self, rotation: Quat) -> Rotated<State, Self>

Source§

impl<Scalar, State, const DIM: usize, S> SdfTransformOperations<Scalar, State, DIM> for S
where Scalar: Float + 'static, State: SdfState<Scalar, DIM>, S: Sdf<Scalar, DIM, State = State>,

Source§

fn translate( self, translation: impl Into<[Scalar; DIM]>, ) -> Translated<Scalar, State, Self, DIM>

Source§

fn scale(self, scale: Scalar) -> Scaled<Scalar, State, Self, DIM>

Source§

fn invert(self) -> Inverted<Scalar, State, Self, DIM>

Source§

fn iso(self, iso: Scalar) -> IsoSurface<Scalar, State, Self, DIM>

Source§

fn thicken(self, thickness: Scalar) -> Thicken<Scalar, State, Self, DIM>

Source§

fn approx(self, radius: Scalar) -> Approximated<Scalar, State, Self, DIM>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.