Skip to main content

Module world

Module world 

Source

Structs§

Profile
Profiling data. Times are in milliseconds. (b2Profile)
TaskContext
Per thread task storage. (b2TaskContext)
World
The world struct manages all physics entities, dynamic simulation, and asynchronous queries. (b2World)

Functions§

compute_world_bounds
Compute the bounds of all shapes in the world. Returns the bounds and whether the world had any proxies at all. (b2ComputeWorldBounds)
default_friction_callback
Default friction mixing: sqrt(frictionA * frictionB). (static b2DefaultFrictionCallback)
default_restitution_callback
Default restitution mixing: max(restitutionA, restitutionB). (static b2DefaultRestitutionCallback)
world_cast_mover
Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping. Returns the fraction of the translation that can be performed without a hit. (b2World_CastMover + static MoverCastCallback)
world_cast_ray
Cast a ray into the world to collect shapes in the path of the ray. The callback receives (shape_id, point, normal, fraction) and controls the continuation like C’s b2CastResultFcn: return -1 to ignore the hit, 0 to terminate, a fraction to clip the ray, or 1 to continue without clipping. (b2World_CastRay + static RayCastCallback)
world_cast_ray_closest
Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap. (b2World_CastRayClosest + static b2RayCastClosestFcn)
world_cast_shape
Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point. The callback contract matches world_cast_ray. (b2World_CastShape + static ShapeCastCallback)
world_collide_mover
Collide a capsule mover with the world, gathering collision planes that can be fed to solve_planes. Useful for character controllers. The callback returns false to terminate the query. (b2World_CollideMover + static TreeCollideCallback)
world_draw
(b2World_Draw)
world_enable_continuous
Enable/disable continuous collision between dynamic and static bodies. 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. (b2World_EnableContinuous)
world_enable_sleeping
Enable/disable sleep. If your application does not need sleeping, you can gain some performance by disabling sleep completely at the world level. (b2World_EnableSleeping)
world_enable_speculative
This is for internal testing. (b2World_EnableSpeculative)
world_enable_warm_starting
Enable/disable constraint warm starting. Advanced feature for testing. Disabling warm starting greatly reduces stability and provides no performance gain. (b2World_EnableWarmStarting)
world_explode
Apply a radial explosion. Explosions are modeled as a force, not as a collision event. (b2World_Explode + static ExplosionCallback)
world_get_awake_body_count
Get the number of awake bodies. (b2World_GetAwakeBodyCount)
world_get_body_events
Get the body events for the current time step. The event data is transient. Do not store a reference to this data. (b2World_GetBodyEvents)
world_get_bounds
Get the bounds of all shapes in the world. Returns a zero AABB for an empty world. (b2World_GetBounds)
world_get_contact_events
Get contact events for this current time step. The event data is transient. Do not store a reference to this data. (b2World_GetContactEvents)
world_get_contact_recycle_distance
Get the contact recycle distance. (b2World_GetContactRecycleDistance)
world_get_counters
Get world counters and sizes. (b2World_GetCounters)
world_get_gravity
Get the gravity vector. (b2World_GetGravity)
world_get_hit_event_threshold
Get the the hit event speed threshold. Usually in meters per second. (b2World_GetHitEventThreshold)
world_get_joint_events
Get the joint events for the current time step. The event data is transient. Do not store a reference to this data. (b2World_GetJointEvents)
world_get_max_capacity
Get the maximum capacity the world has reached. (b2World_GetMaxCapacity)
world_get_maximum_linear_speed
Get the maximum linear speed. Usually in m/s. (b2World_GetMaximumLinearSpeed)
world_get_profile
Get the current world performance profile. (b2World_GetProfile)
world_get_restitution_threshold
Get the the restitution speed threshold. Usually in meters per second. (b2World_GetRestitutionThreshold)
world_get_sensor_events
Get sensor events for the current time step. The event data is transient. Do not store a reference to this data. (b2World_GetSensorEvents)
world_get_user_data
Get the user data pointer. (b2World_GetUserData)
world_is_continuous_enabled
Is continuous collision enabled? (b2World_IsContinuousEnabled)
world_is_sleeping_enabled
Is body sleeping enabled? (b2World_IsSleepingEnabled)
world_is_valid
World id validity. (b2World_IsValid)
world_is_warm_starting_enabled
Is constraint warm starting enabled? (b2World_IsWarmStartingEnabled)
world_overlap_aabb
Overlap test for all shapes that potentially overlap the provided AABB. The callback receives each overlapping shape id and returns false to terminate the query. (b2World_OverlapAABB + static TreeQueryCallback)
world_overlap_shape
Overlap test for all shapes that overlap the provided shape proxy. The callback returns false to terminate the query. (b2World_OverlapShape + static TreeOverlapCallback)
world_rebuild_static_tree
This is for internal testing. (b2World_RebuildStaticTree)
world_set_contact_recycle_distance
Set the contact recycle distance. Contacts this close to a recently destroyed contact reuse the old impulses for warm starting. (b2World_SetContactRecycleDistance)
world_set_contact_tuning
Adjust contact tuning parameters: hertz, damping ratio, and push speed. Advanced feature for testing. (b2World_SetContactTuning)
world_set_custom_filter_callback
Register the custom filter callback. This is optional. (b2World_SetCustomFilterCallback)
world_set_friction_callback
Register the friction callback. This is optional. Passing None restores the default mixing rule. (b2World_SetFrictionCallback)
world_set_gravity
Set the gravity vector for the entire world. Box2D has no concept of an up direction and this is left as a decision for the application. (b2World_SetGravity)
world_set_hit_event_threshold
Adjust the hit event threshold. This controls the collision speed needed to generate a b2ContactHitEvent. Usually in meters per second. (b2World_SetHitEventThreshold)
world_set_maximum_linear_speed
Set the maximum linear speed. Usually in m/s. (b2World_SetMaximumLinearSpeed)
world_set_pre_solve_callback
Register the pre-solve callback. This is optional. (b2World_SetPreSolveCallback)
world_set_restitution_callback
Register the restitution callback. This is optional. Passing None restores the default mixing rule. (b2World_SetRestitutionCallback)
world_set_restitution_threshold
Adjust the restitution threshold. It is recommended not to make this value very small because it will prevent bodies from sleeping. Usually in meters per second. (b2World_SetRestitutionThreshold)
world_set_user_data
Set the user data pointer. (b2World_SetUserData)
world_step
Simulate a world for one time step. (b2World_Step — takes &mut World; the C resolves the world from an id)

Type Aliases§

CustomFilterFcn
Prototype for a contact filter callback. Called when a contact pair is considered for collision, if one of the two shapes has custom filtering enabled. Return false to disable the collision. (b2CustomFilterFcn)
PreSolveFcn
Prototype for a pre-solve callback. Called after a contact is updated, only for awake dynamic bodies with pre-solve events enabled. Return false to disable the contact this step. (b2PreSolveFcn)