HughPH.Box2D
Organised dotnet bindings for Box2D 3.1.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
Box2D.World Class Referencesealed

A Box2D World, the container for all bodies, shapes, and constraints. More...

Public Member Functions

bool Equals (World other)
 Checks if this World and another World refer to the same World.
 
override bool Equals (object? obj)
 Checks if this World and another World refer to the same World.
 
override int GetHashCode ()
 Returns the hash code for this World.
 
unsafe World (WorldDef def)
 Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You may create up to 128 worlds. Each world is completely independent and may be simulated in parallel.
 
unsafe void Destroy ()
 Destroy this world.
 
unsafe void Step (float timeStep=0.016666668f, int subStepCount=4)
 Simulate a world for one time step. This performs collision detection, integration, and constraint solution.
 
void Draw (DebugDraw draw)
 Call this to draw shapes and other debug draw data.
 
unsafe void SetCustomFilterCallback< TContext > (CustomFilterCallback< TContext > callback, TContext context)
 Register the custom filter callback. This is optional.
 
unsafe void SetCustomFilterCallback< TContext > (CustomFilterRefCallback< TContext > callback, ref TContext context)
 Register the custom filter callback. This is optional.
 
void SetCustomFilterCallback (CustomFilterNintCallback callback, nint context)
 Register the custom filter callback. This is optional.
 
void SetCustomFilterCallback (CustomFilterCallback nintCallback)
 Register the custom filter callback. This is optional.
 
unsafe void SetPreSolveCallback< TContext > (PreSolveCallback< TContext > callback, TContext context)
 Register the pre-solve callback. This is optional.
 
unsafe void SetPreSolveCallback< TContext > (PreSolveRefCallback< TContext > callback, ref TContext context)
 Register the pre-solve callback. This is optional.
 
void SetPreSolveCallback (PreSolveCallback callback)
 Register the pre-solve callback. This is optional.
 
void SetPreSolveCallback (PreSolveNintCallback callback, nint context)
 Register the pre-solve callback. This is optional.
 
unsafe void Explode (in ExplosionDef explosionDef)
 Apply a radial explosion.
 
unsafe void SetContactTuning (float hertz, float dampingRatio, float pushSpeed)
 Adjust contact tuning parameters.
 
unsafe void SetFrictionCallback (FrictionCallback callback)
 Sets the friction callback.
 
unsafe void SetRestitutionCallback (RestitutionCallback callback)
 Sets the restitution callback.
 
unsafe void DumpMemoryStats ()
 Dumps memory stats to box2d_memory.txt.
 
unsafe Body CreateBody (BodyDef def)
 Creates a rigid body given a definition.
 
unsafe DistanceJoint CreateJoint (DistanceJointDef def)
 Creates a distance joint.
 
unsafe MotorJoint CreateJoint (MotorJointDef def)
 Creates a motor joint.
 
unsafe MouseJoint CreateJoint (MouseJointDef def)
 Creates a mouse joint.
 
unsafe Joint CreateJoint (FilterJointDef def)
 Creates a filter joint. See FilterJointDef for details.
 
unsafe PrismaticJoint CreateJoint (PrismaticJointDef def)
 Creates a prismatic (slider) joint.
 
unsafe RevoluteJoint CreateJoint (RevoluteJointDef def)
 Creates a revolute joint.
 
unsafe WeldJoint CreateJoint (WeldJointDef def)
 Creates a weld joint.
 
unsafe WheelJoint CreateJoint (WheelJointDef def)
 Creates a wheel joint.
 
override string ToString ()
 Returns a string representation of this world.
 
unsafe RayResult CastRayClosest (Vec2 origin, Vec2 translation, QueryFilter filter)
 Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap.
 
unsafe TreeStats CastRay< TContext > (Vec2 origin, Vec2 translation, QueryFilter filter, CastResultCallback< TContext > callback, TContext context)
 Cast a ray into the world to collect shapes in the path of the ray.
 
unsafe TreeStats CastRay< TContext > (Vec2 origin, Vec2 translation, QueryFilter filter, CastResultRefCallback< TContext > callback, ref TContext context)
 Cast a ray into the world to collect shapes in the path of the ray.
 
TreeStats CastRay (Vec2 origin, Vec2 translation, QueryFilter filter, CastResultCallback callback)
 Cast a ray into the world to collect shapes in the path of the ray.
 
unsafe TreeStats CastRay (Vec2 origin, Vec2 translation, QueryFilter filter, CastResultNintCallback callback, nint context)
 Cast a ray into the world to collect shapes in the path of the ray.
 
unsafe TreeStats CastShape< TContext > (in ShapeProxy proxy, Vec2 translation, QueryFilter filter, CastResultCallback< TContext > callback, TContext context)
 Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
 
unsafe TreeStats CastShape< TContext > (in ShapeProxy proxy, Vec2 translation, QueryFilter filter, CastResultRefCallback< TContext > callback, ref TContext context)
 Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
 
TreeStats CastShape (in ShapeProxy proxy, Vec2 translation, QueryFilter filter, CastResultCallback callback)
 Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
 
TreeStats CastShape (in ShapeProxy proxy, Vec2 translation, QueryFilter filter, CastResultNintCallback callback, nint context)
 Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.
 
unsafe float CastMover (in Capsule mover, Vec2 translation, QueryFilter filter)
 Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping.
 
unsafe void CollideMover< TContext > (in Capsule mover, QueryFilter filter, PlaneResultCallback< TContext > callback, TContext context)
 Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
 
unsafe void CollideMover< TContext > (in Capsule mover, QueryFilter filter, PlaneResultRefCallback< TContext > callback, ref TContext context)
 Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
 
void CollideMover (in Capsule mover, QueryFilter filter, PlaneResultCallback callback)
 Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
 
void CollideMover (in Capsule mover, QueryFilter filter, PlaneResultNintCallback callback, nint context)
 Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
 
unsafe TreeStats OverlapAABB< TContext > (AABB aabb, QueryFilter filter, OverlapResultCallback< TContext > callback, TContext context)
 Overlap test for all shapes that potentially overlap the provided AABB.
 
unsafe TreeStats OverlapAABB< TContext > (AABB aabb, QueryFilter filter, OverlapResultRefCallback< TContext > callback, ref TContext context)
 Overlap test for all shapes that potentially overlap the provided AABB.
 
TreeStats OverlapAABB (AABB aabb, QueryFilter filter, ref OverlapResultCallback callback)
 Overlap test for all shapes that potentially overlap the provided AABB.
 
TreeStats OverlapAABB (AABB aabb, QueryFilter filter, OverlapResultNintCallback callback, nint context)
 Overlap test for all shapes that potentially overlap the provided AABB.
 
unsafe TreeStats OverlapShape< TContext > (in ShapeProxy proxy, QueryFilter filter, OverlapResultCallback< TContext > callback, TContext context)
 Overlap test for all shapes that overlap the provided shape proxy.
 
unsafe TreeStats OverlapShape< TContext > (in ShapeProxy proxy, QueryFilter filter, OverlapResultRefCallback< TContext > callback, ref TContext context)
 Overlap test for all shapes that overlap the provided shape proxy.
 
TreeStats OverlapShape< TContext > (in ShapeProxy proxy, QueryFilter filter, OverlapResultNintCallback callback, nint context)
 Overlap test for all shapes that overlap the provided shape proxy.
 
TreeStats OverlapShape (in ShapeProxy proxy, QueryFilter filter, OverlapResultCallback callback)
 Overlap test for all shapes that overlap the provided shape proxy.
 
delegate void BodyMoveEventHandler (in BodyMoveEvent @event)
 Event handler for body move events.
 
delegate void SensorBeginTouchEventHandler (in SensorBeginTouchEvent @event)
 Event handler for sensor begin touch events.
 
delegate void SensorEndTouchEventHandler (in SensorEndTouchEvent @event)
 Event handler for sensor end touch events.
 
delegate void ContactBeginTouchEventHandler (in ContactBeginTouchEvent @event)
 Event handler for contact begin touch events.
 
delegate void ContactEndTouchEventHandler (in ContactEndTouchEvent @event)
 Event handler for contact end touch events.
 
delegate void ContactHitEventHandler (in ContactHitEvent @event)
 Event handler for contact hit events.
 

Static Public Member Functions

static World CreateWorld (WorldDef def)
 Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You may create up to 128 worlds. Each world is completely independent and may be simulated in parallel.
 

Public Attributes

object WorldLock = new()
 A lock object for the world. This is used to synchronize access to the world from multiple threads.
 
BodyMoveEventHandlerBodyMove
 The body move event handler. This is called when a body moves.
 
SensorBeginTouchEventHandlerSensorBeginTouch
 The sensor begin touch event handler. This is called when a sensor begins touching another shape.
 
SensorEndTouchEventHandlerSensorEndTouch
 The sensor end touch event handler. This is called when a sensor ends touching another shape.
 
ContactBeginTouchEventHandlerContactBeginTouch
 The contact begin touch event handler. This is called when a contact begins touching another shape.
 
ContactEndTouchEventHandlerContactEndTouch
 The contact end touch event handler. This is called when a contact ends touching another shape.
 
ContactHitEventHandlerContactHit
 The contact hit event handler. This is called when a contact hits another shape.
 

Properties

static IComparer< WorldDefaultComparer = WorldComparer.Instance [get]
 Default comparer for World instances. This is used for hashing and equality checks.
 
static IEqualityComparer< WorldDefaultEqualityComparer = WorldComparer.Instance [get]
 Default equality comparer for World instances. This is used for hashing and equality checks.
 
unsafe bool Valid [get]
 World id validation. Provides validation for up to 64K allocations.
 
unsafe BodyEvents BodyEvents [get]
 Get the body events for the current time step. The event data is transient. Do not store a reference to this data.
 
unsafe SensorEvents SensorEvents [get]
 Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.
 
unsafe ContactEvents ContactEvents [get]
 Get the contact events for the current time step. The event data is transient. Do not store a reference to this data.
 
unsafe bool SleepingEnabled [get, set]
 Gets or sets the sleeping enabled status of the world. If your application does not need sleeping, you can gain some performance by disabling sleep completely at the world level.
 
unsafe bool ContinuousEnabled [get, set]
 Gets or sets the continuous collision enabled state of the world.
 
unsafe float RestitutionThreshold [get, set]
 The restitution speed threshold.
 
unsafe float HitEventThreshold [get, set]
 The hit event threshold in meters per second.
 
unsafe Vec2 Gravity [get, set]
 The gravity vector.
 
unsafe float MaximumLinearSpeed [get, set]
 The maximum linear speed.
 
unsafe bool WarmStartingEnabled [get, set]
 Enable/disable constraint warm starting. Advanced feature for testing. Disabling warm starting greatly reduces stability and provides no performance gain.
 
unsafe int AwakeBodyCount [get]
 Get the number of awake bodies.
 
unsafe Profile Profile [get]
 Get the current world performance profile.
 
unsafe Counters Counters [get]
 Get world counters and sizes.
 
unsafe? object UserData [get, set]
 The user data object for this world.
 
IEnumerable< BodyBodies [get]
 Gets the bodies in this world.
 

Detailed Description

A Box2D World, the container for all bodies, shapes, and constraints.

Constructor & Destructor Documentation

◆ World()

unsafe Box2D.World.World ( WorldDef  def)
inline

Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You may create up to 128 worlds. Each world is completely independent and may be simulated in parallel.

Parameters
defThe world definition

Member Function Documentation

◆ CastMover()

unsafe float Box2D.World.CastMover ( in Capsule  mover,
Vec2  translation,
QueryFilter  filter 
)

Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping.

Parameters
moverThe capsule mover
translationThe translation of the capsule from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
Returns
The fraction of the translation that was completed before a collision occurred

◆ CastRay() [1/2]

TreeStats Box2D.World.CastRay ( Vec2  origin,
Vec2  translation,
QueryFilter  filter,
CastResultCallback  callback 
)
inline

Cast a ray into the world to collect shapes in the path of the ray.

Parameters
originThe start point of the ray
translationThe translation of the ray from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
Returns
Traversal performance counters

Your callback function controls whether you get the closest point, any point, or n-points.
Note: The callback function may receive shapes in any order

◆ CastRay() [2/2]

unsafe TreeStats Box2D.World.CastRay ( Vec2  origin,
Vec2  translation,
QueryFilter  filter,
CastResultNintCallback  callback,
nint  context 
)
inline

Cast a ray into the world to collect shapes in the path of the ray.

Parameters
originThe start point of the ray
translationThe translation of the ray from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function

///

Parameters
contextA user context that is passed along to the callback function
Returns
Traversal performance counters

Your callback function controls whether you get the closest point, any point, or n-points.
Note: The callback function may receive shapes in any order

◆ CastRay< TContext >() [1/2]

unsafe TreeStats Box2D.World.CastRay< TContext > ( Vec2  origin,
Vec2  translation,
QueryFilter  filter,
CastResultCallback< TContext >  callback,
TContext  context 
)
inline

Cast a ray into the world to collect shapes in the path of the ray.

Parameters
originThe start point of the ray
translationThe translation of the ray from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Returns
Traversal performance counters

Your callback function controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point. The callback function may receive shapes in any order

Type Constraints
TContext :class 

◆ CastRay< TContext >() [2/2]

unsafe TreeStats Box2D.World.CastRay< TContext > ( Vec2  origin,
Vec2  translation,
QueryFilter  filter,
CastResultRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Cast a ray into the world to collect shapes in the path of the ray.

Parameters
originThe start point of the ray
translationThe translation of the ray from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Returns
Traversal performance counters

Your callback function controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point. The callback function may receive shapes in any order

Type Constraints
TContext :unmanaged 

◆ CastRayClosest()

unsafe RayResult Box2D.World.CastRayClosest ( Vec2  origin,
Vec2  translation,
QueryFilter  filter 
)

Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap.

Parameters
originThe start point of the ray
translationThe translation of the ray from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
Returns
The ray result

This is less general than b2World_CastRay() and does not allow for custom filtering

◆ CastShape() [1/2]

TreeStats Box2D.World.CastShape ( in ShapeProxy  proxy,
Vec2  translation,
QueryFilter  filter,
CastResultCallback  callback 
)
inline

Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.

Parameters
proxyThe shape proxy
translationThe translation of the shape from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function

◆ CastShape() [2/2]

TreeStats Box2D.World.CastShape ( in ShapeProxy  proxy,
Vec2  translation,
QueryFilter  filter,
CastResultNintCallback  callback,
nint  context 
)
inline

Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.

Parameters
proxyThe shape proxy
translationThe translation of the shape from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function

◆ CastShape< TContext >() [1/2]

unsafe TreeStats Box2D.World.CastShape< TContext > ( in ShapeProxy  proxy,
Vec2  translation,
QueryFilter  filter,
CastResultCallback< TContext >  callback,
TContext  context 
)
inline

Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.

Parameters
proxyThe shape proxy
translationThe translation of the shape from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Type Constraints
TContext :class 

◆ CastShape< TContext >() [2/2]

unsafe TreeStats Box2D.World.CastShape< TContext > ( in ShapeProxy  proxy,
Vec2  translation,
QueryFilter  filter,
CastResultRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point.

Parameters
proxyThe shape proxy
translationThe translation of the shape from the start point to the end point
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Type Constraints
TContext :unmanaged 

◆ CollideMover() [1/2]

void Box2D.World.CollideMover ( in Capsule  mover,
QueryFilter  filter,
PlaneResultCallback  callback 
)
inline

Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.

Parameters
moverThe capsule mover
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function

◆ CollideMover() [2/2]

void Box2D.World.CollideMover ( in Capsule  mover,
QueryFilter  filter,
PlaneResultNintCallback  callback,
nint  context 
)

Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.

Parameters
moverThe capsule mover
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function

◆ CollideMover< TContext >() [1/2]

unsafe void Box2D.World.CollideMover< TContext > ( in Capsule  mover,
QueryFilter  filter,
PlaneResultCallback< TContext >  callback,
TContext  context 
)
inline

Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.

Parameters
moverThe capsule mover
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Type Constraints
TContext :class 

◆ CollideMover< TContext >() [2/2]

unsafe void Box2D.World.CollideMover< TContext > ( in Capsule  mover,
QueryFilter  filter,
PlaneResultRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.

Parameters
moverThe capsule mover
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextA user context that is passed along to the callback function
Type Constraints
TContext :unmanaged 

◆ CreateBody()

unsafe Body Box2D.World.CreateBody ( BodyDef  def)
inline

Creates a rigid body given a definition.

Parameters
defThe body definition
Returns
The body

◆ CreateJoint() [1/8]

unsafe DistanceJoint Box2D.World.CreateJoint ( DistanceJointDef  def)

Creates a distance joint.

Parameters
defThe distance joint definition
Returns
The distance joint

◆ CreateJoint() [2/8]

unsafe Joint Box2D.World.CreateJoint ( FilterJointDef  def)

Creates a filter joint. See FilterJointDef for details.

Parameters
defThe filter joint definition
Returns
The filter joint

The filter joint is used to disable collision between two bodies. As a side effect of being a joint, it also keeps the two bodies in the same simulation island.

◆ CreateJoint() [3/8]

unsafe MotorJoint Box2D.World.CreateJoint ( MotorJointDef  def)

Creates a motor joint.

Parameters
defThe motor joint definition
Returns
The motor joint

◆ CreateJoint() [4/8]

unsafe MouseJoint Box2D.World.CreateJoint ( MouseJointDef  def)

Creates a mouse joint.

Parameters
defThe mouse joint definition
Returns
The mouse joint

◆ CreateJoint() [5/8]

unsafe PrismaticJoint Box2D.World.CreateJoint ( PrismaticJointDef  def)

Creates a prismatic (slider) joint.

Parameters
defThe prismatic joint definition
Returns
The prismatic joint

◆ CreateJoint() [6/8]

unsafe RevoluteJoint Box2D.World.CreateJoint ( RevoluteJointDef  def)

Creates a revolute joint.

Parameters
defThe RevoluteJointDef
Returns
The revolute joint

◆ CreateJoint() [7/8]

unsafe WeldJoint Box2D.World.CreateJoint ( WeldJointDef  def)

Creates a weld joint.

Parameters
defThe WeldJointDef
Returns
The weld joint

◆ CreateJoint() [8/8]

unsafe WheelJoint Box2D.World.CreateJoint ( WheelJointDef  def)

Creates a wheel joint.

Parameters
defThe wheel joint definition
Returns
The wheel joint

◆ CreateWorld()

static World Box2D.World.CreateWorld ( WorldDef  def)
inlinestatic

Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You may create up to 128 worlds. Each world is completely independent and may be simulated in parallel.

Parameters
defThe world definition
Returns
The world

◆ Draw()

void Box2D.World.Draw ( DebugDraw  draw)
inline

Call this to draw shapes and other debug draw data.

Parameters
drawThe debug draw implementation

◆ DumpMemoryStats()

unsafe void Box2D.World.DumpMemoryStats ( )

Dumps memory stats to box2d_memory.txt.

Memory stats are dumped to box2d_memory.txt

◆ Explode()

unsafe void Box2D.World.Explode ( in ExplosionDef  explosionDef)

Apply a radial explosion.

Parameters
explosionDefThe explosion definition

Explosions are modeled as a force, not as a collision event

◆ OverlapAABB() [1/2]

TreeStats Box2D.World.OverlapAABB ( AABB  aabb,
QueryFilter  filter,
OverlapResultNintCallback  callback,
nint  context 
)
inline

Overlap test for all shapes that potentially overlap the provided AABB.

Parameters
aabbThe AABB
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context

◆ OverlapAABB() [2/2]

TreeStats Box2D.World.OverlapAABB ( AABB  aabb,
QueryFilter  filter,
ref OverlapResultCallback  callback 
)
inline

Overlap test for all shapes that potentially overlap the provided AABB.

Parameters
aabbThe AABB
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function

◆ OverlapAABB< TContext >() [1/2]

unsafe TreeStats Box2D.World.OverlapAABB< TContext > ( AABB  aabb,
QueryFilter  filter,
OverlapResultCallback< TContext >  callback,
TContext  context 
)
inline

Overlap test for all shapes that potentially overlap the provided AABB.

Parameters
aabbThe AABB
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context
Type Constraints
TContext :class 

◆ OverlapAABB< TContext >() [2/2]

unsafe TreeStats Box2D.World.OverlapAABB< TContext > ( AABB  aabb,
QueryFilter  filter,
OverlapResultRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Overlap test for all shapes that potentially overlap the provided AABB.

Parameters
aabbThe AABB
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context
Type Constraints
TContext :unmanaged 

◆ OverlapShape()

TreeStats Box2D.World.OverlapShape ( in ShapeProxy  proxy,
QueryFilter  filter,
OverlapResultCallback  callback 
)
inline

Overlap test for all shapes that overlap the provided shape proxy.

Parameters
proxyThe shape proxy
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function

◆ OverlapShape< TContext >() [1/3]

unsafe TreeStats Box2D.World.OverlapShape< TContext > ( in ShapeProxy  proxy,
QueryFilter  filter,
OverlapResultCallback< TContext >  callback,
TContext  context 
)
inline

Overlap test for all shapes that overlap the provided shape proxy.

Parameters
proxyThe shape proxy
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context
Type Constraints
TContext :class 

◆ OverlapShape< TContext >() [2/3]

TreeStats Box2D.World.OverlapShape< TContext > ( in ShapeProxy  proxy,
QueryFilter  filter,
OverlapResultNintCallback  callback,
nint  context 
)
inline

Overlap test for all shapes that overlap the provided shape proxy.

Parameters
proxyThe shape proxy
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context

◆ OverlapShape< TContext >() [3/3]

unsafe TreeStats Box2D.World.OverlapShape< TContext > ( in ShapeProxy  proxy,
QueryFilter  filter,
OverlapResultRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Overlap test for all shapes that overlap the provided shape proxy.

Parameters
proxyThe shape proxy
filterContains bit flags to filter unwanted shapes from the results
callbackA user implemented callback function
contextThe context
Type Constraints
TContext :unmanaged 

◆ SetContactTuning()

unsafe void Box2D.World.SetContactTuning ( float  hertz,
float  dampingRatio,
float  pushSpeed 
)

Adjust contact tuning parameters.

Parameters
hertzThe contact stiffness (cycles per second)
dampingRatioThe contact bounciness with 1 being critical damping (non-dimensional)
pushSpeedThe maximum contact constraint push out speed (meters per second)

Note: Advanced feature

◆ SetCustomFilterCallback() [1/2]

void Box2D.World.SetCustomFilterCallback ( CustomFilterCallback  nintCallback)
inline

Register the custom filter callback. This is optional.

Parameters
nintCallbackThe custom filter callback function

◆ SetCustomFilterCallback() [2/2]

void Box2D.World.SetCustomFilterCallback ( CustomFilterNintCallback  callback,
nint  context 
)
inline

Register the custom filter callback. This is optional.

Parameters
callbackThe custom filter callback function
contextThe context to be passed to the callback

◆ SetCustomFilterCallback< TContext >() [1/2]

unsafe void Box2D.World.SetCustomFilterCallback< TContext > ( CustomFilterCallback< TContext >  callback,
TContext  context 
)
inline

Register the custom filter callback. This is optional.

Parameters
callbackThe custom filter callback function
contextThe context to be passed to the callback
Type Constraints
TContext :class 

◆ SetCustomFilterCallback< TContext >() [2/2]

unsafe void Box2D.World.SetCustomFilterCallback< TContext > ( CustomFilterRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Register the custom filter callback. This is optional.

Parameters
callbackThe custom filter callback function
contextThe context to be passed to the callback
Type Constraints
TContext :unmanaged 

◆ SetFrictionCallback()

unsafe void Box2D.World.SetFrictionCallback ( FrictionCallback  callback)

Sets the friction callback.

Parameters
callbackThe friction callback

Passing NULL resets to default

◆ SetPreSolveCallback() [1/2]

void Box2D.World.SetPreSolveCallback ( PreSolveCallback  callback)
inline

Register the pre-solve callback. This is optional.

Parameters
callbackThe pre-solve callback function

◆ SetPreSolveCallback() [2/2]

void Box2D.World.SetPreSolveCallback ( PreSolveNintCallback  callback,
nint  context 
)
inline

Register the pre-solve callback. This is optional.

Parameters
callbackThe pre-solve callback function
contextThe context

◆ SetPreSolveCallback< TContext >() [1/2]

unsafe void Box2D.World.SetPreSolveCallback< TContext > ( PreSolveCallback< TContext >  callback,
TContext  context 
)
inline

Register the pre-solve callback. This is optional.

Parameters
callbackThe pre-solve callback function
contextThe context
Type Constraints
TContext :class 

◆ SetPreSolveCallback< TContext >() [2/2]

unsafe void Box2D.World.SetPreSolveCallback< TContext > ( PreSolveRefCallback< TContext >  callback,
ref TContext  context 
)
inline

Register the pre-solve callback. This is optional.

Parameters
callbackThe pre-solve callback function
contextThe context
Type Constraints
TContext :unmanaged 

◆ SetRestitutionCallback()

unsafe void Box2D.World.SetRestitutionCallback ( RestitutionCallback  callback)

Sets the restitution callback.

Parameters
callbackThe restitution callback

Passing NULL resets to default

◆ Step()

unsafe void Box2D.World.Step ( float  timeStep = 0::016666668f,
int  subStepCount = 4 
)
inline

Simulate a world for one time step. This performs collision detection, integration, and constraint solution.

Parameters
timeStepThe amount of time to simulate, this should be a fixed number. Usually 1/60.
subStepCountThe number of sub-steps, increasing the sub-step count can increase accuracy. Usually 4.

Member Data Documentation

◆ BodyMove

BodyMoveEventHandler? Box2D.World.BodyMove

The body move event handler. This is called when a body moves.

If this is set, the World will raise events for all valid BodyMoveEvents.
Note: This is not called for all bodies, only for those that are valid. The number of events may be different to those found in the world's BodyEvents.

◆ ContactBeginTouch

ContactBeginTouchEventHandler? Box2D.World.ContactBeginTouch

The contact begin touch event handler. This is called when a contact begins touching another shape.

If this is set, the World will raise events for all ContactBeginTouchEvents.
Note: This is not called for all contact shapes, only for those that are valid. The number of events may be different to those found in the world's ContactEvents.

◆ ContactEndTouch

ContactEndTouchEventHandler? Box2D.World.ContactEndTouch

The contact end touch event handler. This is called when a contact ends touching another shape.

If this is set, the World will raise events for all ContactEndTouchEvents.
Note: This is not called for all contact shapes, only for those that are valid. The number of events may be different to those found in the world's ContactEvents.

◆ ContactHit

ContactHitEventHandler? Box2D.World.ContactHit

The contact hit event handler. This is called when a contact hits another shape.

If this is set, the World will raise events for all ContactHitEvents.
Note: This is not called for all contact shapes, only for those that are valid. The number of events may be different to those found in the world's ContactEvents.

◆ SensorBeginTouch

SensorBeginTouchEventHandler? Box2D.World.SensorBeginTouch

The sensor begin touch event handler. This is called when a sensor begins touching another shape.

If this is set, the World will raise events for all SensorBeginTouchEvents.
Note: This is not called for all sensor shapes, only for those that are valid. The number of events may be different to those found in the world's SensorEvents.

◆ SensorEndTouch

SensorEndTouchEventHandler? Box2D.World.SensorEndTouch

The sensor end touch event handler. This is called when a sensor ends touching another shape.

If this is set, the World will raise events for all SensorEndTouchEvents.
Note: This is not called for all sensor shapes, only for those that are valid. The number of events may be different to those found in the world's SensorEvents.

◆ WorldLock

object Box2D.World.WorldLock = new()

A lock object for the world. This is used to synchronize access to the world from multiple threads.

If you wish to mutate the world, you should use your own Lock object, or use a lock statement with this lock object, e.g.
Thread 1:

world.Step();

Thread 2:

lock (world.WorldLock)
{
// update world, e.g. add bodies, remove bodies, etc.
}

Note: It is your responsibility to ensure that the object is unlocked within the time required for another Step.
Event handlers run within a world lock. Do not lock the world lock in a world event handler. This will cause a deadlock.

Property Documentation

◆ AwakeBodyCount

unsafe int Box2D.World.AwakeBodyCount
get

Get the number of awake bodies.

Returns
The number of awake bodies

◆ BodyEvents

unsafe BodyEvents Box2D.World.BodyEvents
get

Get the body events for the current time step. The event data is transient. Do not store a reference to this data.

Returns
The body events

◆ ContactEvents

unsafe ContactEvents Box2D.World.ContactEvents
get

Get the contact events for the current time step. The event data is transient. Do not store a reference to this data.

Returns
The contact events

◆ ContinuousEnabled

unsafe bool Box2D.World.ContinuousEnabled
getset

Gets or sets the continuous collision enabled state of the world.

Generally you should keep continuous collision enabled to prevent fast moving objects from going through static objects. The performance gain from disabling continuous collision is minor

◆ Counters

unsafe Counters Box2D.World.Counters
get

Get world counters and sizes.

Returns
The world counters and sizes

◆ Profile

unsafe Profile Box2D.World.Profile
get

Get the current world performance profile.

Returns
The world performance profile

◆ SensorEvents

unsafe SensorEvents Box2D.World.SensorEvents
get

Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.

Returns
The sensor events

◆ Valid

unsafe bool Box2D.World.Valid
get

World id validation. Provides validation for up to 64K allocations.

Returns
True if the world id is valid

The documentation for this class was generated from the following files: