pub struct RotationConstraints {
pub allow_x: bool,
pub allow_y: bool,
pub allow_z: bool,
}
Expand description
Component that restrict what rotations can be caused by forces.
It must be inserted on the same entity of a RigidBody
Note that angular velocity may still be applied programmatically. This only restrict how rotation can change when force/torques are applied.
§Example
fn spawn(mut commands: Commands) {
commands.spawn_bundle(todo!("Spawn your sprite/mesh, incl. at least a GlobalTransform"))
.insert(CollisionShape::Sphere { radius: 1.0 })
.insert(RotationConstraints::lock()); // Prevent rotation caused by forces
}
Fields§
§allow_x: bool
Set to true to prevent rotations around the x axis
allow_y: bool
Set to true to prevent rotations around the y axis
allow_z: bool
Set to true to prevent rotations around the Z axis
Implementations§
Source§impl RotationConstraints
impl RotationConstraints
Sourcepub fn lock() -> RotationConstraints
pub fn lock() -> RotationConstraints
Lock rotations around all axes
Sourcepub fn allow() -> RotationConstraints
pub fn allow() -> RotationConstraints
Allow rotations around all axes
Sourcepub fn restrict_to_x_only() -> RotationConstraints
pub fn restrict_to_x_only() -> RotationConstraints
Allow rotation around the x axis only (and prevent rotating around the other axes)
Sourcepub fn restrict_to_y_only() -> RotationConstraints
pub fn restrict_to_y_only() -> RotationConstraints
Allow rotation around the y axis only (and prevent rotating around the other axes)
Sourcepub fn restrict_to_z_only() -> RotationConstraints
pub fn restrict_to_z_only() -> RotationConstraints
Allow rotation around the z axis only (and prevent rotating around the other axes)
Trait Implementations§
Source§impl Clone for RotationConstraints
impl Clone for RotationConstraints
Source§fn clone(&self) -> RotationConstraints
fn clone(&self) -> RotationConstraints
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Component for RotationConstraints
impl Component for RotationConstraints
type Storage = TableStorage
Source§impl Debug for RotationConstraints
impl Debug for RotationConstraints
Source§impl Default for RotationConstraints
impl Default for RotationConstraints
Source§fn default() -> RotationConstraints
fn default() -> RotationConstraints
Returns the “default value” for a type. Read more
Source§impl Reflect for RotationConstraints
impl Reflect for RotationConstraints
Source§fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
Source§fn into_any(self: Box<RotationConstraints>) -> Box<dyn Any>
fn into_any(self: Box<RotationConstraints>) -> Box<dyn Any>
Returns the value as a
Box<dyn Any>
.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the value as a
&mut dyn Any
.Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Casts this type to a reflected value
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Casts this type to a mutable reflected value
Source§fn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Clones the value as a
Reflect
trait object. Read moreSource§fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
Performs a type-checked assignment of a reflected value to this value. Read more
Source§fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
Applies a reflected value to this value. Read more
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Returns an enumeration of “kinds” of type. Read more
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Returns a mutable enumeration of “kinds” of type. Read more
Source§fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
Returns a “partial equality” comparison result. Read more
Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Returns a hash of the value (which includes the type). Read more
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Debug formatter for the value. Read more
Source§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
Returns a serializable version of the value. Read more
Source§impl Struct for RotationConstraints
impl Struct for RotationConstraints
Source§fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
Returns a reference to the value of the field named
name
as a &dyn Reflect
.Source§fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
Returns a mutable reference to the value of the field named
name
as a
&mut dyn Reflect
.Source§fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
Returns a reference to the value of the field with index
index
as a
&dyn Reflect
.Source§fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
Returns a mutable reference to the value of the field with index
index
as a &mut dyn Reflect
.Source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
Returns the name of the field with index
index
.Source§fn iter_fields(&self) -> FieldIter<'_>
fn iter_fields(&self) -> FieldIter<'_>
Returns an iterator over the values of the struct’s fields.
Source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
Clones the struct into a
DynamicStruct
.Source§impl Typed for RotationConstraints
impl Typed for RotationConstraints
impl Copy for RotationConstraints
Auto Trait Implementations§
impl Freeze for RotationConstraints
impl RefUnwindSafe for RotationConstraints
impl Send for RotationConstraints
impl Sync for RotationConstraints
impl Unpin for RotationConstraints
impl UnwindSafe for RotationConstraints
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset>,
) -> U
fn as_bind_group_shader_type( &self, _images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset>, ) -> U
Return the
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given WorldSource§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
Source§impl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere
T: Reflect,
Source§fn path<'r, 'p>(
&'r self,
path: &'p str,
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn path<'r, 'p>( &'r self, path: &'p str, ) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a reference to the value specified by
path
. Read moreSource§fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str,
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn path_mut<'r, 'p>( &'r mut self, path: &'p str, ) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a mutable reference to the value specified by
path
. Read moreSource§fn get_path<'r, 'p, T>(
&'r self,
path: &'p str,
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
fn get_path<'r, 'p, T>(
&'r self,
path: &'p str,
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed reference to the value specified by
path
.Source§fn get_path_mut<'r, 'p, T>(
&'r mut self,
path: &'p str,
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
fn get_path_mut<'r, 'p, T>(
&'r mut self,
path: &'p str,
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed mutable reference to the value specified by
path
.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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> ⓘ
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 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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.