Struct pixel_game_lib::physics::rigidbody::RigidBodyBuilder
source · pub struct RigidBodyBuilder { /* private fields */ }
Expand description
Create a new rigidbody.
Implementations§
source§impl RigidBodyBuilder
impl RigidBodyBuilder
sourcepub fn new(position: Vec2<f64>) -> Self
pub fn new(position: Vec2<f64>) -> Self
Create a new dynamic rigidbody.
Dynamic means it’s influenced by all forces and its position is updated accordingly. Good examples for it are projectiles and shrapnel.
sourcepub fn new_kinematic(position: Vec2<f64>) -> Self
pub fn new_kinematic(position: Vec2<f64>) -> Self
Create a new kinematic rigidbody.
Kinematic means the bodies are not affected by external forces or collisions. They will affect collisions with dynamic bodies but not be affected by them. Good examples for it are player controllers.
sourcepub fn new_static(position: Vec2<f64>) -> Self
pub fn new_static(position: Vec2<f64>) -> Self
Create a new static rigidbody.
Static means it’s not influenced by any forces and has infinite mass. Good example for it is the ground.
sourcepub fn with_collider(self, collider: Shape) -> Self
pub fn with_collider(self, collider: Shape) -> Self
Set the collider from a shape.
sourcepub fn with_velocity(self, velocity: Vec2<f64>) -> Self
pub fn with_velocity(self, velocity: Vec2<f64>) -> Self
Set the world-space initial linear velocity.
sourcepub fn with_linear_damping(self, linear_damping: f64) -> Self
pub fn with_linear_damping(self, linear_damping: f64) -> Self
Set the linear damping.
This can be used to simulate things like air friction.
sourcepub fn with_orientation<R>(self, orientation: R) -> Self
pub fn with_orientation<R>(self, orientation: R) -> Self
Set the initial orientation/rotation.
sourcepub fn with_orientation_from_direction(self, direction: Vec2<f64>) -> Self
pub fn with_orientation_from_direction(self, direction: Vec2<f64>) -> Self
Set the initial orientation/rotation pointing towards the direction.
Assumes the direction is normalized.
sourcepub fn with_angular_velocity(self, angular_velocity: f64) -> Self
pub fn with_angular_velocity(self, angular_velocity: f64) -> Self
Set the world-space initial angular velocity.
This is how many radians per time unit the orientation changes (rotates).
sourcepub fn with_angular_damping(self, angular_damping: f64) -> Self
pub fn with_angular_damping(self, angular_damping: f64) -> Self
Set the angular damping.
sourcepub fn with_density(self, density: f64) -> Self
pub fn with_density(self, density: f64) -> Self
Set the density.
Density is mass per 1x1 surface of the collider object. From this value inertia and mass will be calculated based on the collider shape.
sourcepub fn with_friction(self, friction: f64) -> Self
pub fn with_friction(self, friction: f64) -> Self
Set the dynamic and static friction.
Static friction is how much friction is needed to overcome before an object starts moving. Dynamic friction is how much friction is applied when colliding to another object.
sourcepub fn with_restitution(self, restitution: f64) -> Self
pub fn with_restitution(self, restitution: f64) -> Self
Set the restitution.
This is how “bouncy” collisions are.
sourcepub fn spawn(self, physics: &mut Physics) -> RigidBodyHandle
pub fn spawn(self, physics: &mut Physics) -> RigidBodyHandle
Spawn into the world.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RigidBodyBuilder
impl !RefUnwindSafe for RigidBodyBuilder
impl Send for RigidBodyBuilder
impl Sync for RigidBodyBuilder
impl Unpin for RigidBodyBuilder
impl !UnwindSafe for RigidBodyBuilder
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> 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> 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>
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> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.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>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.