Skip to main content

WorldDef

Struct WorldDef 

Source
pub struct WorldDef {
Show 16 fields pub gravity: Vec2, pub restitution_threshold: f32, pub hit_event_threshold: f32, pub contact_hertz: f32, pub contact_damping_ratio: f32, pub contact_speed: f32, pub maximum_linear_speed: f32, pub friction_callback: Option<FrictionCallback>, pub restitution_callback: Option<RestitutionCallback>, pub enable_sleep: bool, pub enable_continuous: bool, pub enable_contact_softening: bool, pub worker_count: i32, pub user_data: u64, pub capacity: Capacity, pub internal_value: i32,
}
Expand description

World definition used to create a simulation world. Must be initialized using default_world_def. (b2WorldDef)

PartialEq is intentionally not derived: it holds optional function-pointer callbacks, and function-pointer equality is not meaningful.

Fields§

§gravity: Vec2

Gravity vector. Box2D has no up-vector defined.

§restitution_threshold: f32

Restitution speed threshold, usually in m/s. Collisions above this speed have restitution applied (will bounce).

§hit_event_threshold: f32

Threshold speed for hit events. Usually meters per second.

§contact_hertz: f32

Contact stiffness. Cycles per second.

§contact_damping_ratio: f32

Contact bounciness. Non-dimensional.

§contact_speed: f32

Speed cap on overlap resolution, usually meters per second.

§maximum_linear_speed: f32

Maximum linear speed. Usually meters per second.

§friction_callback: Option<FrictionCallback>

Optional mixing callback for friction.

§restitution_callback: Option<RestitutionCallback>

Optional mixing callback for restitution.

§enable_sleep: bool

Can bodies go to sleep to improve performance.

§enable_continuous: bool

Enable continuous collision.

§enable_contact_softening: bool

Contact softening when mass ratios are large. Experimental.

§worker_count: i32

Number of workers for multithreading, clamped to [1, MAX_WORKERS].

§user_data: u64

User data.

§capacity: Capacity

Optional initial capacities.

§internal_value: i32

Used internally to detect a valid definition. DO NOT SET.

Trait Implementations§

Source§

impl Clone for WorldDef

Source§

fn clone(&self) -> WorldDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WorldDef

Source§

impl Debug for WorldDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WorldDef

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.