#[non_exhaustive]pub struct Body {
pub flying: bool,
pub noclip: bool,
pub yaw: FreeCoordinate,
pub pitch: FreeCoordinate,
/* private fields */
}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.flying: boolIs this body not subject to gravity?
noclip: boolIs this body not subject to collision?
yaw: FreeCoordinateYaw 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: FreeCoordinatePitch 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 position(&self) -> FreePoint
pub fn position(&self) -> FreePoint
Returns the body’s current position.
If you are interested in the space it occupies, use Self::collision_box_abs() instead.
Sourcepub fn set_position(&mut self, position: FreePoint)
pub fn set_position(&mut self, position: FreePoint)
Sets the position of the body, disregarding collision.
Note: This may have effects that normal time stepping does not. In particular,
body.set_position(body.position()) is not guaranteed to do nothing.
If position contains any component which is infinite or NaN, this function does nothing.
This behavior may change in the future.
Sourcepub fn add_velocity(&mut self, Δv: Vector3D<f64, Velocity>)
pub fn add_velocity(&mut self, Δv: Vector3D<f64, Velocity>)
Adds the given value to the body’s velocity.
If Δv contains any component which is infinite or NaN, this function does nothing.
This behavior may change in the future.
Sourcepub fn set_velocity(&mut self, v: Vector3D<f64, Velocity>)
pub fn set_velocity(&mut self, v: Vector3D<f64, Velocity>)
Replaces the body’s velocity with the given value.
If Δv contains any component which is infinite or NaN, this function does nothing.
This behavior may change in the future.
Sourcepub fn collision_box_rel(&self) -> Aab
pub fn collision_box_rel(&self) -> Aab
Returns the body’s configured collision box in coordinates relative to Self::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 collision_box_abs(&self) -> Aab
pub fn collision_box_abs(&self) -> Aab
Returns the body’s current collision box in world coordinates.
This is not necessarily equal in size to Self::collision_box_rel().
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_direction(&self) -> FreeVector
pub fn look_direction(&self) -> FreeVector
Returns the direction the body is facing (when it is part of a character).
Sourcepub fn set_look_direction(&mut self, direction: FreeVector)
pub fn set_look_direction(&mut self, direction: FreeVector)
Changes self.yaw and self.pitch to look in the given
direction vector.
If direction has zero length, the resulting direction is unspecified but valid.
Trait Implementations§
Source§impl Component for Body
Required Components: [PhysicsOutputs], [rg :: Destination].
impl Component for Body
Required Components: [PhysicsOutputs], [rg :: Destination].
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
requiree: ComponentId,
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
Component::on_add, etc.)ComponentHooks.Source§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl<'de> Deserialize<'de> for Body
Available on crate feature save only.
impl<'de> Deserialize<'de> for Body
save only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Fmt<StatusText> for Body
Omits collision box on the grounds that it is presumably constant
impl Fmt<StatusText> for Body
Omits collision box on the grounds that it is presumably constant
Source§impl Transactional for Body
impl Transactional for Body
Source§type Transaction = BodyTransaction
type Transaction = BodyTransaction
Self.Source§fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
self,
equivalent to the following steps: Read moreimpl StructuralPartialEq for Body
Auto Trait Implementations§
impl Freeze for Body
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
Source§fn register_required_components(
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )
Bundle.Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
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§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
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 moreSource§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