#[repr(C, align(8))]
pub struct b2World { /* private fields */ }
Expand description

The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.

Implementations§

source§

impl b2World

source

pub unsafe fn QueryAABB( self: &b2World, callback: *mut b2QueryCallback, aabb: &b2AABB )

Query the world for all fixtures that potentially overlap the provided AABB. @param callback a user implemented callback class. @param aabb the query box.

source

pub unsafe fn QueryShapeAABB( self: &b2World, callback: *mut b2QueryCallback, shape: &b2Shape, xf: &b2Transform )

Query the world for all fixtures that potentially overlap the provided shape’s AABB. Calls QueryAABB internally. @param callback a user implemented callback class. @param shape the query shape @param xf the transform of the AABB

source

pub unsafe fn RayCast( self: &b2World, callback: *mut b2RayCastCallback, point1: &b2Vec2, point2: &b2Vec2 )

Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point. @param callback a user implemented callback class. @param point1 the ray starting point @param point2 the ray ending point

source

pub fn GetJointList(self: Pin<&mut b2World>) -> *mut b2Joint

Get the world joint list. With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A nullptr joint indicates the end of the list. @return the head of the world joint list.

source

pub fn GetJointList1(self: &b2World) -> *const b2Joint

source

pub fn GetContactList(self: Pin<&mut b2World>) -> *mut b2Contact

Get the world contact list. With the returned contact, use b2Contact::GetNext to get the next contact in the world list. A nullptr contact indicates the end of the list. @return the head of the world contact list. @warning contacts are created and destroyed in the middle of a time step. Use b2ContactListener to avoid missing contacts.

source

pub fn GetContactList1(self: &b2World) -> *const b2Contact

source

pub fn GetProxyCount(self: &b2World) -> c_int

Get the number of broad-phase proxies.

source

pub fn GetContactCount(self: &b2World) -> c_int

Get the number of contacts (each may have 0 or more contact points).

source

pub fn GetTreeHeight(self: &b2World) -> c_int

Get the height of the dynamic tree.

source

pub fn GetTreeBalance(self: &b2World) -> c_int

Get the balance of the dynamic tree.

source

pub fn GetTreeQuality(self: &b2World) -> f32

Get the quality metric of the dynamic tree. The smaller the better. The minimum is 1.

source

pub fn ShiftOrigin(self: Pin<&mut b2World>, newOrigin: &b2Vec2)

Shift the world origin. Useful for large worlds. The body shift formula is: position -= newOrigin @param newOrigin the new origin with respect to the old origin

source

pub fn Dump(self: Pin<&mut b2World>)

Dump the world into the log file. @warning this should be called outside of a time step.

source

pub fn new<'a>(gravity: &'a b2Vec2) -> impl New<Output = Self> + 'a

Construct a world object. @param gravity the world gravity vector.

source§

impl b2World

source

pub unsafe fn SetDestructionListener( self: Pin<&mut Self>, listener: *mut b2DestructionListener )

Register a destruction listener. The listener is owned by you and must remain in scope.

source§

impl b2World

source

pub unsafe fn SetContactFilter( self: Pin<&mut Self>, filter: *mut b2ContactFilter )

Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter). The listener is owned by you and must remain in scope.

source§

impl b2World

source

pub unsafe fn SetContactListener( self: Pin<&mut Self>, listener: *mut b2ContactListener )

Register a contact event listener. The listener is owned by you and must remain in scope.

source§

impl b2World

source

pub unsafe fn SetDebugDraw(self: Pin<&mut Self>, debugDraw: *mut b2Draw)

Register a routine for debug drawing. The debug draw functions are called inside with b2World::DebugDraw method. The debug draw object is owned by you and must remain in scope.

source§

impl b2World

source

pub unsafe fn CreateBody( self: Pin<&mut Self>, def: *const b2BodyDef ) -> *mut b2Body

Create a rigid body given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.

source§

impl b2World

source

pub unsafe fn DestroyBody(self: Pin<&mut Self>, body: *mut b2Body)

Destroy a rigid body. This function is locked during callbacks. @warning This automatically deletes all associated shapes and joints. @warning This function is locked during callbacks.

source§

impl b2World

source

pub unsafe fn CreateJoint( self: Pin<&mut Self>, def: *const b2JointDef ) -> *mut b2Joint

Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. @warning This function is locked during callbacks.

source§

impl b2World

source

pub unsafe fn DestroyJoint(self: Pin<&mut Self>, joint: *mut b2Joint)

Destroy a joint. This may cause the connected bodies to begin colliding. @warning This function is locked during callbacks.

source§

impl b2World

source

pub unsafe fn CreateParticleSystem( self: Pin<&mut Self>, def: *const b2ParticleSystemDef ) -> *mut b2ParticleSystem

Create a particle system given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.

source§

impl b2World

source

pub unsafe fn DestroyParticleSystem( self: Pin<&mut Self>, p: *mut b2ParticleSystem )

Destroy a particle system. @warning This function is locked during callbacks.

source§

impl b2World

source

pub fn Step( self: Pin<&mut Self>, timeStep: f32, velocityIterations: c_int, positionIterations: c_int, particleIterations: c_int )

Take a time step. This performs collision detection, integration, and constraint solution. For the numerical stability of particles, minimize the following dimensionless gravity acceleration: gravity / particleRadius * (timeStep / particleIterations)^2 b2CalculateParticleIterations() or CalculateReasonableParticleIterations() help to determine the optimal particleIterations. @param timeStep the amount of time to simulate, this should not vary. @param velocityIterations for the velocity constraint solver. @param positionIterations for the position constraint solver. @param particleIterations for the particle simulation.

source§

impl b2World

source

pub fn Step1( self: Pin<&mut Self>, timeStep: f32, velocityIterations: c_int, positionIterations: c_int )

Take a time step. This performs collision detection, integration, and constraint solution. @param timeStep the amount of time to simulate, this should not vary. @param velocityIterations for the velocity constraint solver. @param positionIterations for the position constraint solver.

source§

impl b2World

source

pub fn CalculateReasonableParticleIterations(&self, timeStep: f32) -> c_int

Recommend a value to be used in Step for particleIterations. This calculation is necessarily a simplification and should only be used as a starting point. Please see “Particle Iterations” in the Programmer’s Guide for details. @param timeStep is the value to be passed into Step.

source§

impl b2World

source

pub fn ClearForces(self: Pin<&mut Self>)

Manually clear the force buffer on all bodies. By default, forces are cleared automatically after each call to Step. The default behavior is modified by calling SetAutoClearForces. The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain a fixed sized time step under a variable frame-rate. When you perform sub-stepping you will disable auto clearing of forces and instead call ClearForces after all sub-steps are complete in one pass of your game loop. @see SetAutoClearForces

source§

impl b2World

source

pub fn DebugDraw(self: Pin<&mut Self>)

Call this to draw shapes and other debug draw data. This is intentionally non-const.

source§

impl b2World

source

pub fn GetBodyList(self: Pin<&mut Self>) -> *mut b2Body

Get the world body list. With the returned body, use b2Body::GetNext to get the next body in the world list. A nullptr body indicates the end of the list. @return the head of the world body list.

source§

impl b2World

source§

impl b2World

source

pub fn GetParticleSystemList(self: Pin<&mut Self>) -> *mut b2ParticleSystem

Get the world particle-system list. With the returned body, use b2ParticleSystem::GetNext to get the next particle-system in the world list. A nullptr particle-system indicates the end of the list. @return the head of the world particle-system list.

source§

impl b2World

source§

impl b2World

source

pub fn SetAllowSleeping(self: Pin<&mut Self>, flag: bool)

Enable/disable sleep.

source§

impl b2World

source

pub fn GetAllowSleeping(&self) -> bool

source§

impl b2World

source

pub fn SetWarmStarting(self: Pin<&mut Self>, flag: bool)

Enable/disable warm starting. For testing.

source§

impl b2World

source

pub fn GetWarmStarting(&self) -> bool

source§

impl b2World

source

pub fn SetContinuousPhysics(self: Pin<&mut Self>, flag: bool)

Enable/disable continuous physics. For testing.

source§

impl b2World

source§

impl b2World

source

pub fn SetSubStepping(self: Pin<&mut Self>, flag: bool)

Enable/disable single stepped continuous physics. For testing.

source§

impl b2World

source

pub fn GetSubStepping(&self) -> bool

source§

impl b2World

source

pub fn GetBodyCount(&self) -> c_int

Get the number of bodies.

source§

impl b2World

source

pub fn GetJointCount(&self) -> c_int

Get the number of joints.

source§

impl b2World

source

pub fn SetGravity(self: Pin<&mut Self>, gravity: &b2Vec2)

Change the global gravity vector.

source§

impl b2World

source

pub fn GetGravity(&self) -> b2Vec2

Get the global gravity vector.

source§

impl b2World

source

pub fn IsLocked(&self) -> bool

Is the world locked (in the middle of a time step).

source§

impl b2World

source

pub fn SetAutoClearForces(self: Pin<&mut Self>, flag: bool)

Set flag to control automatic clearing of forces after each time step.

source§

impl b2World

source

pub fn GetAutoClearForces(&self) -> bool

Get the flag that controls automatic clearing of forces after each time step.

source§

impl b2World

source

pub fn GetContactManager(&self) -> &b2ContactManager

Get the contact manager for testing.

source§

impl b2World

source

pub fn GetProfile(&self) -> &b2Profile

Get the current profile.

source§

impl b2World

source

pub fn GetVersion(&self) -> *const b2Version

Get API version.

source§

impl b2World

source

pub fn GetVersionString(&self) -> *const c_char

Get API version string.

Trait Implementations§

source§

impl Drop for b2World

source§

fn drop(self: &mut b2World)

Destruct the world. All physics entities are destroyed and all heap memory is released.

source§

impl ExternType for b2World

§

type Id = (b, _2, W, o, r, l, d)

A type-level representation of the type’s C++ namespace and type name. Read more
§

type Kind = Opaque

source§

impl MakeCppStorage for b2World

source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut b2World

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut b2World)

Frees a C++ allocation which has not yet had a constructor called. Read more
source§

impl SharedPtrTarget for b2World

source§

impl UniquePtrTarget for b2World

source§

impl WeakPtrTarget for b2World

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.