Struct veloren_voxygen_anim::vek::Aabb

source ·
pub struct Aabb<T> {
    pub min: Vec3<T>,
    pub max: Vec3<T>,
}
Expand description

Axis-aligned Bounding Box (3D), represented by min and max points.

N.B: You are responsible for ensuring that all respective elements of min are indeed less than or equal to those of max. The is_valid(), make_valid() and made_valid() methods are designed to help you with this.

Fields§

§min: Vec3<T>

Minimum coordinates of bounds.

§max: Vec3<T>

Maximum coordinates of bounds.

Implementations§

source§

impl<T> Aabb<T>

source

pub fn is_valid(&self) -> bool
where T: PartialOrd,

Is this bounding shape valid ? True only if all elements of self.min are less than or equal to those of self.max.

source

pub fn make_valid(&mut self)
where T: PartialOrd,

Makes this bounding shape valid by swapping elements of self.min with self.max as needed.

source

pub fn made_valid(self) -> Aabb<T>
where T: PartialOrd,

Returns this bounding shape made valid by swapping elements of self.min with self.max as needed.

source

pub fn new_empty(p: Vec3<T>) -> Aabb<T>
where T: Copy,

Creates a new bounding shape from a single point.

source

pub fn into_rect3(self) -> Rect3<T, T>
where T: Copy + Sub<Output = T>,

Converts this bounding shape to the matching rectangle representation.

source

pub fn center(self) -> Vec3<T>
where T: Copy + One + Add<Output = T> + Div<Output = T>,

Gets this bounding shape’s center.

source

pub fn size(self) -> Extent3<T>
where T: Copy + Sub<Output = T>,

Gets this bounding shape’s total size.

source

pub fn half_size(self) -> Extent3<T>
where T: Copy + Sub<Output = T> + One + Div<Output = T> + Add<Output = T>,

Gets this bounding shape’s half size.

source

pub fn union(self, other: Aabb<T>) -> Aabb<T>
where T: PartialOrd,

Gets the smallest bounding shape that contains both this one and another.

source

pub fn intersection(self, other: Aabb<T>) -> Aabb<T>
where T: PartialOrd,

Gets the largest bounding shape contained by both this one and another.

source

pub fn expand_to_contain(&mut self, other: Aabb<T>)
where T: Copy + PartialOrd,

Sets this bounding shape to the union of itself with another.

source

pub fn intersect(&mut self, other: Aabb<T>)
where T: Copy + PartialOrd,

Sets this bounding shape to the intersection of itself with another.

source

pub fn expanded_to_contain_point(self, p: Vec3<T>) -> Aabb<T>
where T: Copy + PartialOrd,

Gets a copy of this shape so that it contains the given point.

source

pub fn expand_to_contain_point(&mut self, p: Vec3<T>)
where T: Copy + PartialOrd,

Expands this shape so that it contains the given point.

source

pub fn contains_point(self, p: Vec3<T>) -> bool
where T: PartialOrd,

Does this bounding shape contain the given point ?

source

pub fn contains_aabb(self, other: Aabb<T>) -> bool
where T: PartialOrd,

Does this bounding shape fully contain another ?

source

pub fn collides_with_aabb(self, other: Aabb<T>) -> bool
where T: PartialOrd,

Does this bounding shape collide with another ?

source

pub fn collision_vector_with_aabb(self, other: Aabb<T>) -> Vec3<T>
where T: Copy + PartialOrd + Sub<Output = T> + One + Add<Output = T> + Div<Output = T>,

Gets a vector that tells how much self penetrates other.

source

pub fn projected_point(self, p: Vec3<T>) -> Vec3<T>
where T: Clamp,

Project the given point into the bounding shape (equivalent to ‘snapping’ the point to the closest point in the bounding shape).

source

pub fn distance_to_point(self, p: Vec3<T>) -> T
where T: Clamp + Real<Output = T> + Add + RelativeEq,

Get the smallest distance between the bounding shape and a point.

source

pub fn split_at_x(self, sp: T) -> [Aabb<T>; 2]
where T: Copy + PartialOrd,

Splits this shape in two, by a straight plane along the x axis. The returned tuple is (low, high).

§Panics

sp is assumed to be a position along the x axis that is within this shape’s bounds.

source

pub fn split_at_y(self, sp: T) -> [Aabb<T>; 2]
where T: Copy + PartialOrd,

Splits this shape in two, by a straight plane along the y axis. The returned tuple is (low, high).

§Panics

sp is assumed to be a position along the y axis that is within this shape’s bounds.

source

pub fn split_at_z(self, sp: T) -> [Aabb<T>; 2]
where T: Copy + PartialOrd,

Splits this shape in two, by a straight plane along the z axis. The returned tuple is (low, high).

§Panics

sp is assumed to be a position along the z axis that is within this shape’s bounds.

source

pub fn map<D, F>(self, f: F) -> Aabb<D>
where F: FnMut(T) -> D,

Returns this bounding shape, converted element-wise using the given closure.

source

pub fn as_<D>(self) -> Aabb<D>
where T: AsPrimitive<D>, D: 'static + Copy,

Converts this rectangle to a rectangle of another type, using the as conversion.

Trait Implementations§

source§

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

source§

fn clone(&self) -> Aabb<T>

Returns a copy 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<T> Debug for Aabb<T>
where T: Debug,

source§

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

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

impl<T> Default for Aabb<T>
where T: Default,

source§

fn default() -> Aabb<T>

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

impl<'de, T> Deserialize<'de> for Aabb<T>
where T: Deserialize<'de>,

source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Aabb<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<Aabb<T>> for Aabr<T>

source§

fn from(aabb: Aabb<T>) -> Aabr<T>

Converts to this type from the input type.
source§

impl<T> From<Aabb<T>> for Rect3<T, T>
where T: Copy + Sub<Output = T>,

source§

fn from(aab: Aabb<T>) -> Rect3<T, T>

Converts to this type from the input type.
source§

impl<T> From<Rect3<T, T>> for Aabb<T>
where T: Copy + Add<Output = T>,

source§

fn from(rect: Rect3<T, T>) -> Aabb<T>

Converts to this type from the input type.
source§

impl<T> Hash for Aabb<T>
where T: Hash,

source§

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

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<T> PartialEq for Aabb<T>
where T: PartialEq,

source§

fn eq(&self, other: &Aabb<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Aabb<T>
where T: Serialize,

source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Copy for Aabb<T>
where T: Copy,

source§

impl<T> Eq for Aabb<T>
where T: Eq,

source§

impl<T> StructuralPartialEq for Aabb<T>

Auto Trait Implementations§

§

impl<T> Freeze for Aabb<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Aabb<T>
where T: RefUnwindSafe,

§

impl<T> Send for Aabb<T>
where T: Send,

§

impl<T> Sync for Aabb<T>
where T: Sync,

§

impl<T> Unpin for Aabb<T>
where T: Unpin,

§

impl<T> UnwindSafe for Aabb<T>
where T: 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
§

impl<T> CallHasher for T
where T: Hash,

§

fn get_hash<H>(&self, hasher: H) -> u64
where H: Hasher,

source§

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

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<C, M> ConvertSaveload<M> for C

§

type Data = C

(De)Serializable data representation for data type
§

type Error = Infallible

Error may occur during serialization or deserialization of component
§

fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
where F: FnMut(Entity) -> Option<M>,

Convert this data type into serializable form (Data) using entity to marker mapping function
§

fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
where F: FnMut(M) -> Option<Entity>,

Convert this data from a deserializable form (Data) using entity to marker mapping function
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> GetSetFdFlags for T

§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<Context> SubContext<Context> for Context

§

fn sub_context(self) -> Context

source§

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

§

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
§

impl<T> TryDefault for T
where T: Default,

§

fn try_default() -> Result<T, String>

Tries to create the default.
§

fn unwrap_default() -> Self

Calls try_default and panics on an error case.
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Event for T
where T: Send + Sync + 'static,

§

impl<T> Resource for T
where T: Any + Send + Sync,

§

impl<T> Storable for T
where T: Send + Sync + 'static,