Struct all_is_cubes::physics::Body
source · #[non_exhaustive]pub struct Body {
pub position: FreePoint,
pub velocity: Vector3D<FreeCoordinate, Velocity>,
pub collision_box: Aab,
pub flying: bool,
pub noclip: bool,
pub yaw: FreeCoordinate,
pub pitch: FreeCoordinate,
}
Expand description
An object with a position, velocity, and collision volume. What it collides with is determined externally.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.position: FreePoint
Position.
velocity: Vector3D<FreeCoordinate, Velocity>
Velocity, in position units per second.
collision_box: Aab
Collision volume, defined with position
as the origin.
flying: bool
Is this body not subject to gravity?
noclip: bool
Is this body not subject to collision?
yaw: FreeCoordinate
Yaw of the camera look direction, in degrees clockwise from looking towards -Z.
The preferred range is 0 inclusive to 360 exclusive.
This does not affect the behavior of the Body
itself; it has nothing to do with
the direction of the velocity.
pitch: FreeCoordinate
Pitch of the camera look direction, in degrees downward from looking horixontally.
The preferred range is -90 to 90, inclusive.
This does not affect the behavior of the Body
itself; it has nothing to do with
the direction of the velocity.
Implementations§
source§impl Body
impl Body
sourcepub fn new_minimal(
position: impl Into<FreePoint>,
collision_box: impl Into<Aab>
) -> Self
pub fn new_minimal( position: impl Into<FreePoint>, collision_box: impl Into<Aab> ) -> Self
Constructs a Body
requiring only information that can’t be reasonably defaulted.
sourcepub fn collision_box_abs(&self) -> Aab
pub fn collision_box_abs(&self) -> Aab
Returns the body’s collision box in world coordinates
(collision_box
translated by position
).
use all_is_cubes::math::Aab;
use all_is_cubes::physics::Body;
let body = Body::new_minimal(
(0.0, 20.0, 0.0),
Aab::new(-1.0, 1.0, -2.0, 2.0, -3.0, 3.0)
);
assert_eq!(body.collision_box_abs(), Aab::new(-1.0, 1.0, 18.0, 22.0, -3.0, 3.0));
sourcepub fn look_at(&mut self, point: FreePoint)
pub fn look_at(&mut self, point: FreePoint)
Changes self.yaw
and self.pitch
to look directly
towards the given point within the same coordinate system as
self.position
.
Trait Implementations§
source§impl Fmt<StatusText> for Body
impl Fmt<StatusText> for Body
Omits collision box on the grounds that it is presumably constant
source§impl PartialEq for Body
impl PartialEq for Body
source§impl Transaction<Body> for BodyTransaction
impl Transaction<Body> for BodyTransaction
§type CommitCheck = ()
type CommitCheck = ()
Transaction::check
to Transaction::commit
.
This may be used to pass precalculated values to speed up the commit phase,
or even lock guards or similar, but also makes it slightly harder to accidentally
call commit
without check
.§type Output = Infallible
type Output = Infallible
Transaction::commit()
or Transaction::execute()
.
Each commit may produce any number of these messages. Read moresource§fn check(&self, _body: &Body) -> Result<Self::CommitCheck, PreconditionFailed>
fn check(&self, _body: &Body) -> Result<Self::CommitCheck, PreconditionFailed>
source§fn commit(
&self,
body: &mut Body,
_: Self::CommitCheck,
_outputs: &mut dyn FnMut(Self::Output)
) -> Result<(), CommitError>
fn commit( &self, body: &mut Body, _: Self::CommitCheck, _outputs: &mut dyn FnMut(Self::Output) ) -> Result<(), CommitError>
check
value should have
been created by a prior call to Transaction::commit
. Read moresource§impl Transactional for Body
impl Transactional for Body
§type Transaction = BodyTransaction
type Transaction = BodyTransaction
Self
.impl StructuralPartialEq for Body
Auto Trait Implementations§
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe for Body
Blanket Implementations§
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
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§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
.source§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
.source§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.source§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.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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)
source§impl<F, T> Refmt<F> for T
impl<F, T> Refmt<F> for T
source§fn refmt<'a>(&'a self, fopt: &'a F) -> Wrapper<'a, F, T>
fn refmt<'a>(&'a self, fopt: &'a F) -> Wrapper<'a, F, T>
fmt::Debug
or fmt::Display
, it uses
the given Fmt
custom format type instead. Read more