Struct veloren_voxygen::scene::math::Aabr
source · pub struct Aabr<T> {
pub min: Vec2<T>,
pub max: Vec2<T>,
}
Expand description
Axis-aligned Bounding Rectangle (2D), 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: Vec2<T>
Minimum coordinates of bounds.
max: Vec2<T>
Maximum coordinates of bounds.
Implementations§
source§impl<T> Aabr<T>
impl<T> Aabr<T>
sourcepub fn is_valid(&self) -> boolwhere
T: PartialOrd,
pub fn is_valid(&self) -> boolwhere
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
.
sourcepub fn make_valid(&mut self)where
T: PartialOrd,
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.
sourcepub fn made_valid(self) -> Aabr<T>where
T: PartialOrd,
pub fn made_valid(self) -> Aabr<T>where
T: PartialOrd,
Returns this bounding shape made valid by swapping elements of self.min
with self.max
as needed.
sourcepub fn new_empty(p: Vec2<T>) -> Aabr<T>where
T: Copy,
pub fn new_empty(p: Vec2<T>) -> Aabr<T>where
T: Copy,
Creates a new bounding shape from a single point.
sourcepub fn into_rect(self) -> Rect<T, T>
pub fn into_rect(self) -> Rect<T, T>
Converts this bounding shape to the matching rectangle representation.
sourcepub fn union(self, other: Aabr<T>) -> Aabr<T>where
T: PartialOrd,
pub fn union(self, other: Aabr<T>) -> Aabr<T>where
T: PartialOrd,
Gets the smallest bounding shape that contains both this one and another.
sourcepub fn intersection(self, other: Aabr<T>) -> Aabr<T>where
T: PartialOrd,
pub fn intersection(self, other: Aabr<T>) -> Aabr<T>where
T: PartialOrd,
Gets the largest bounding shape contained by both this one and another.
sourcepub fn expand_to_contain(&mut self, other: Aabr<T>)where
T: Copy + PartialOrd,
pub fn expand_to_contain(&mut self, other: Aabr<T>)where
T: Copy + PartialOrd,
Sets this bounding shape to the union of itself with another.
sourcepub fn intersect(&mut self, other: Aabr<T>)where
T: Copy + PartialOrd,
pub fn intersect(&mut self, other: Aabr<T>)where
T: Copy + PartialOrd,
Sets this bounding shape to the intersection of itself with another.
sourcepub fn expanded_to_contain_point(self, p: Vec2<T>) -> Aabr<T>where
T: Copy + PartialOrd,
pub fn expanded_to_contain_point(self, p: Vec2<T>) -> Aabr<T>where
T: Copy + PartialOrd,
Gets a copy of this shape so that it contains the given point.
sourcepub fn expand_to_contain_point(&mut self, p: Vec2<T>)where
T: Copy + PartialOrd,
pub fn expand_to_contain_point(&mut self, p: Vec2<T>)where
T: Copy + PartialOrd,
Expands this shape so that it contains the given point.
sourcepub fn contains_point(self, p: Vec2<T>) -> boolwhere
T: PartialOrd,
pub fn contains_point(self, p: Vec2<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape contain the given point ?
sourcepub fn contains_aabr(self, other: Aabr<T>) -> boolwhere
T: PartialOrd,
pub fn contains_aabr(self, other: Aabr<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape fully contain another ?
sourcepub fn collides_with_aabr(self, other: Aabr<T>) -> boolwhere
T: PartialOrd,
pub fn collides_with_aabr(self, other: Aabr<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape collide with another ?
sourcepub fn collision_vector_with_aabr(self, other: Aabr<T>) -> Vec2<T>
pub fn collision_vector_with_aabr(self, other: Aabr<T>) -> Vec2<T>
Gets a vector that tells how much self
penetrates other
.
sourcepub fn projected_point(self, p: Vec2<T>) -> Vec2<T>where
T: Clamp,
pub fn projected_point(self, p: Vec2<T>) -> Vec2<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).
sourcepub fn distance_to_point(self, p: Vec2<T>) -> T
pub fn distance_to_point(self, p: Vec2<T>) -> T
Get the smallest distance between the bounding shape and a point.
sourcepub fn split_at_x(self, sp: T) -> [Aabr<T>; 2]where
T: Copy + PartialOrd,
pub fn split_at_x(self, sp: T) -> [Aabr<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.
sourcepub fn split_at_y(self, sp: T) -> [Aabr<T>; 2]where
T: Copy + PartialOrd,
pub fn split_at_y(self, sp: T) -> [Aabr<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.
sourcepub fn map<D, F>(self, f: F) -> Aabr<D>where
F: FnMut(T) -> D,
pub fn map<D, F>(self, f: F) -> Aabr<D>where
F: FnMut(T) -> D,
Returns this bounding shape, converted element-wise using the given closure.
sourcepub fn as_<D>(self) -> Aabr<D>where
T: AsPrimitive<D>,
D: 'static + Copy,
pub fn as_<D>(self) -> Aabr<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<'de, T> Deserialize<'de> for Aabr<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Aabr<T>where
T: Deserialize<'de>,
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Aabr<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Aabr<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<T> PartialEq for Aabr<T>where
T: PartialEq,
impl<T> PartialEq for Aabr<T>where
T: PartialEq,
source§impl<T> Serialize for Aabr<T>where
T: Serialize,
impl<T> Serialize for Aabr<T>where
T: Serialize,
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<T> Copy for Aabr<T>where
T: Copy,
impl<T> Eq for Aabr<T>where
T: Eq,
impl<T> StructuralPartialEq for Aabr<T>
Auto Trait Implementations§
impl<T> Freeze for Aabr<T>where
T: Freeze,
impl<T> RefUnwindSafe for Aabr<T>where
T: RefUnwindSafe,
impl<T> Send for Aabr<T>where
T: Send,
impl<T> Sync for Aabr<T>where
T: Sync,
impl<T> Unpin for Aabr<T>where
T: Unpin,
impl<T> UnwindSafe for Aabr<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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<T> Chain<T> for T
impl<T> Chain<T> for T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
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>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.