| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box3D.World
Synopsis
- create :: WorldDef -> IO WorldId
- destroy :: WorldId -> IO ()
- isValid :: WorldId -> IO Bool
- step :: WorldId -> Float -> Int -> IO ()
- draw :: WorldId -> Ptr DebugDraw -> Word64 -> IO ()
- getBounds :: WorldId -> IO AABB
- getBoundsInto :: WorldId -> Ptr AABB -> IO ()
- getBodyEvents :: WorldId -> IO BodyEvents
- getBodyEventsInto :: WorldId -> Ptr BodyEvents -> IO ()
- getSensorEvents :: WorldId -> IO SensorEvents
- getSensorEventsInto :: WorldId -> Ptr SensorEvents -> IO ()
- getContactEvents :: WorldId -> IO ContactEvents
- getContactEventsInto :: WorldId -> Ptr ContactEvents -> IO ()
- getJointEvents :: WorldId -> IO JointEvents
- getJointEventsInto :: WorldId -> Ptr JointEvents -> IO ()
- overlapAABB :: WorldId -> AABB -> QueryFilter -> FunPtr OverlapResultFcn -> Ptr () -> IO TreeStats
- overlapShape :: WorldId -> Pos -> Ptr ShapeProxy -> QueryFilter -> FunPtr OverlapResultFcn -> Ptr () -> IO TreeStats
- castRay :: WorldId -> Pos -> Vec3 -> QueryFilter -> FunPtr CastResultFcn -> Ptr () -> IO TreeStats
- castRayClosest :: WorldId -> Pos -> Vec3 -> QueryFilter -> IO RayResult
- castShape :: WorldId -> Pos -> Ptr ShapeProxy -> Vec3 -> QueryFilter -> FunPtr CastResultFcn -> Ptr () -> IO TreeStats
- castMover :: WorldId -> Pos -> Capsule -> Vec3 -> QueryFilter -> FunPtr MoverFilterFcn -> Ptr () -> IO Float
- collideMover :: WorldId -> Pos -> Capsule -> QueryFilter -> FunPtr PlaneResultFcn -> Ptr () -> IO ()
- enableSleeping :: WorldId -> Bool -> IO ()
- isSleepingEnabled :: WorldId -> IO Bool
- enableContinuous :: WorldId -> Bool -> IO ()
- isContinuousEnabled :: WorldId -> IO Bool
- setRestitutionThreshold :: WorldId -> Float -> IO ()
- getRestitutionThreshold :: WorldId -> IO Float
- setHitEventThreshold :: WorldId -> Float -> IO ()
- getHitEventThreshold :: WorldId -> IO Float
- setCustomFilterCallback :: WorldId -> FunPtr CustomFilterFcn -> Ptr () -> IO ()
- setPreSolveCallback :: WorldId -> FunPtr PreSolveFcn -> Ptr () -> IO ()
- setGravity :: WorldId -> Vec3 -> IO ()
- getGravity :: WorldId -> IO Vec3
- getGravityInto :: WorldId -> Ptr Vec3 -> IO ()
- explode :: WorldId -> ExplosionDef -> IO ()
- setContactTuning :: WorldId -> Float -> Float -> Float -> IO ()
- setContactRecycleDistance :: WorldId -> Float -> IO ()
- getContactRecycleDistance :: WorldId -> IO Float
- setMaximumLinearSpeed :: WorldId -> Float -> IO ()
- getMaximumLinearSpeed :: WorldId -> IO Float
- enableWarmStarting :: WorldId -> Bool -> IO ()
- isWarmStartingEnabled :: WorldId -> IO Bool
- getAwakeBodyCount :: WorldId -> IO Int
- getProfile :: WorldId -> Ptr Profile -> IO ()
- getCounters :: WorldId -> Ptr Counters -> IO ()
- getMaxCapacity :: WorldId -> IO Capacity
- getMaxCapacityInto :: WorldId -> Ptr Capacity -> IO ()
- setUserData :: WorldId -> Ptr () -> IO ()
- getUserData :: WorldId -> IO (Ptr ())
- setFrictionCallback :: WorldId -> FunPtr FrictionCallback -> IO ()
- setRestitutionCallback :: WorldId -> FunPtr RestitutionCallback -> IO ()
- setWorkerCount :: WorldId -> Int -> IO ()
- getWorkerCount :: WorldId -> IO Int
- dumpMemoryStats :: WorldId -> IO ()
- dumpShapeBounds :: WorldId -> BodyType -> IO ()
- rebuildStaticTree :: WorldId -> IO ()
- enableSpeculative :: WorldId -> Bool -> IO ()
- dumpAwake :: WorldId -> IO ()
- dump :: WorldId -> IO ()
- startRecording :: WorldId -> Ptr Recording -> IO ()
- stopRecording :: WorldId -> IO ()
Documentation
create :: WorldDef -> IO WorldId Source #
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.
Returns: the world id.
Binds b3CreateWorld.
isValid :: WorldId -> IO Bool Source #
World id validation. Provides validation for up to 64K allocations.
Binds b3World_IsValid.
Arguments
| :: WorldId |
|
| -> Float |
|
| -> Int |
|
| -> IO () |
Simulate a world for one time step. This performs collision detection, integration, and constraint solution.
Binds b3World_Step.
Call this to draw shapes and other debug draw data
Binds b3World_Draw.
getBounds :: WorldId -> IO AABB Source #
Get the world's bounds. This is the bounding box that covers the current simulation. May have a small amount of padding.
Binds b3World_GetBounds.
Like getBounds, but the result is written into a caller-supplied buffer.
getBodyEvents :: WorldId -> IO BodyEvents Source #
Get the body events for the current time step. The event data is transient. Do not store a reference to this data.
Binds b3World_GetBodyEvents.
Arguments
| :: WorldId | |
| -> Ptr BodyEvents | Result buffer. |
| -> IO () |
Like getBodyEvents, but the result is written into a caller-supplied buffer.
getSensorEvents :: WorldId -> IO SensorEvents Source #
Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.
Binds b3World_GetSensorEvents.
Arguments
| :: WorldId | |
| -> Ptr SensorEvents | Result buffer. |
| -> IO () |
Like getSensorEvents, but the result is written into a caller-supplied buffer.
getContactEvents :: WorldId -> IO ContactEvents Source #
Get contact events for this current time step. The event data is transient. Do not store a reference to this data.
Binds b3World_GetContactEvents.
Arguments
| :: WorldId | |
| -> Ptr ContactEvents | Result buffer. |
| -> IO () |
Like getContactEvents, but the result is written into a caller-supplied buffer.
getJointEvents :: WorldId -> IO JointEvents Source #
Get the joint events for the current time step. The event data is transient. Do not store a reference to this data.
Binds b3World_GetJointEvents.
Arguments
| :: WorldId | |
| -> Ptr JointEvents | Result buffer. |
| -> IO () |
Like getJointEvents, but the result is written into a caller-supplied buffer.
Arguments
| :: WorldId | |
| -> AABB | |
| -> QueryFilter | |
| -> FunPtr OverlapResultFcn | |
| -> Ptr () | context |
| -> IO TreeStats |
Overlap test for all shapes that *potentially* overlap the provided AABB
Binds b3World_OverlapAABB.
Arguments
| :: WorldId | |
| -> Pos | origin |
| -> Ptr ShapeProxy | |
| -> QueryFilter | |
| -> FunPtr OverlapResultFcn | |
| -> Ptr () | context |
| -> IO TreeStats |
Overlap test for all shapes that overlap the provided shape proxy. The proxy points are relative to the world origin, which lets the query stay precise far from the world origin.
Binds b3World_OverlapShape.
Arguments
| :: WorldId |
|
| -> Pos |
|
| -> Vec3 |
|
| -> QueryFilter |
|
| -> FunPtr CastResultFcn |
|
| -> Ptr () |
|
| -> IO TreeStats |
Cast a ray into the world to collect shapes in the path of the ray. 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
Returns: traversal performance counters
Binds b3World_CastRay.
Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap. This is less general than b3World_CastRay() and does not allow for custom filtering.
Binds b3World_CastRayClosest.
Arguments
| :: WorldId | |
| -> Pos | origin |
| -> Ptr ShapeProxy | |
| -> Vec3 | translation |
| -> QueryFilter | |
| -> FunPtr CastResultFcn | |
| -> Ptr () | context |
| -> IO TreeStats |
Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point. The proxy points are relative to the origin and the hit points come back as world positions, so the cast stays precise far from the world origin. See also b3World_CastRay.
Binds b3World_CastShape.
Arguments
| :: WorldId |
|
| -> Pos |
|
| -> Capsule |
|
| -> Vec3 |
|
| -> QueryFilter |
|
| -> FunPtr MoverFilterFcn |
|
| -> Ptr () |
|
| -> IO Float |
Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping. This is not a good source of information about what the mover is touching. Instead use the planes returned by b3World_CollideMover.
Returns: the translation fraction
Binds b3World_CastMover.
Arguments
| :: WorldId | |
| -> Pos | origin |
| -> Capsule | mover |
| -> QueryFilter | |
| -> FunPtr PlaneResultFcn | |
| -> Ptr () | context |
| -> IO () |
Collide a capsule mover with the world, gathering collision planes that can be fed to b3SolvePlanes. Useful for kinematic character movement. The mover and the returned planes are relative to the origin.
Binds b3World_CollideMover.
Enable/disable sleep. If your application does not need sleeping, you can gain some performance by disabling sleep completely at the world level. See also b3WorldDef.
Binds b3World_EnableSleeping.
isSleepingEnabled :: WorldId -> IO Bool Source #
Is body sleeping enabled?
Binds b3World_IsSleepingEnabled.
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. See also b3WorldDef.
Binds b3World_EnableContinuous.
isContinuousEnabled :: WorldId -> IO Bool Source #
Is continuous collision enabled?
Binds b3World_IsContinuousEnabled.
setRestitutionThreshold Source #
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. See also b3WorldDef.
Binds b3World_SetRestitutionThreshold.
getRestitutionThreshold :: WorldId -> IO Float Source #
Get the restitution speed threshold. Usually in meters per second.
Binds b3World_GetRestitutionThreshold.
Adjust the hit event threshold. This controls the collision speed needed to generate a b3ContactHitEvent. Usually in meters per second. See also b3WorldDef::hitEventThreshold.
Binds b3World_SetHitEventThreshold.
getHitEventThreshold :: WorldId -> IO Float Source #
Get the hit event speed threshold. Usually in meters per second.
Binds b3World_GetHitEventThreshold.
setCustomFilterCallback Source #
Arguments
| :: WorldId | |
| -> FunPtr CustomFilterFcn | |
| -> Ptr () | context |
| -> IO () |
Register the custom filter callback. This is optional.
Binds b3World_SetCustomFilterCallback.
Arguments
| :: WorldId | |
| -> FunPtr PreSolveFcn | |
| -> Ptr () | context |
| -> IO () |
Register the pre-solve callback. This is optional.
Binds b3World_SetPreSolveCallback.
Set the gravity vector for the entire world. Box3D has no concept of an up direction and this is left as a decision for the application. Usually in m/s^2. See also b3WorldDef.
Binds b3World_SetGravity.
Like getGravity, but the result is written into a caller-supplied buffer.
Arguments
| :: WorldId |
|
| -> ExplosionDef |
|
| -> IO () |
Apply a radial explosion
Binds b3World_Explode.
Arguments
| :: WorldId |
|
| -> Float |
|
| -> Float |
|
| -> Float |
|
| -> IO () |
Adjust contact tuning parameters Note: Advanced feature
Binds b3World_SetContactTuning.
setContactRecycleDistance Source #
Set the contact point recycling distance. Setting this to zero disables contact point recycling. Usually in meters.
Binds b3World_SetContactRecycleDistance.
getContactRecycleDistance :: WorldId -> IO Float Source #
Get the contact point recycling distance. Usually in meters.
Binds b3World_GetContactRecycleDistance.
setMaximumLinearSpeed Source #
Set the maximum linear speed. Usually in m/s.
Binds b3World_SetMaximumLinearSpeed.
getMaximumLinearSpeed :: WorldId -> IO Float Source #
Get the maximum linear speed. Usually in m/s.
Binds b3World_GetMaximumLinearSpeed.
Enable/disable constraint warm starting. Advanced feature for testing. Disabling warm starting greatly reduces stability and provides no performance gain.
Binds b3World_EnableWarmStarting.
isWarmStartingEnabled :: WorldId -> IO Bool Source #
Is constraint warm starting enabled?
Binds b3World_IsWarmStartingEnabled.
getAwakeBodyCount :: WorldId -> IO Int Source #
Get the number of awake bodies
Binds b3World_GetAwakeBodyCount.
Get the current world performance profile
Binds b3World_GetProfile.
Get world counters and sizes
Binds b3World_GetCounters.
getMaxCapacity :: WorldId -> IO Capacity Source #
Get max capacity. This can be used with b3WorldDef to avoid run-time allocations and copies
Binds b3World_GetMaxCapacity.
Like getMaxCapacity, but the result is written into a caller-supplied buffer.
Set the user data pointer.
Binds b3World_SetUserData.
setFrictionCallback :: WorldId -> FunPtr FrictionCallback -> IO () Source #
Set the friction callback. Passing NULL resets to default.
Binds b3World_SetFrictionCallback.
setRestitutionCallback :: WorldId -> FunPtr RestitutionCallback -> IO () Source #
Set the restitution callback. Passing NULL resets to default.
Binds b3World_SetRestitutionCallback.
Set the worker count. Must be in the range \[1, B3_MAX_WORKERS\]
Binds b3World_SetWorkerCount.
dumpMemoryStats :: WorldId -> IO () Source #
Dump memory stats to log.
Binds b3World_DumpMemoryStats.
dumpShapeBounds :: WorldId -> BodyType -> IO () Source #
Dump shape bounds to box3d_bounds.txt
Binds b3World_DumpShapeBounds.
rebuildStaticTree :: WorldId -> IO () Source #
This is for internal testing
Binds b3World_RebuildStaticTree.
This is for internal testing
Binds b3World_EnableSpeculative.
dumpAwake :: WorldId -> IO () Source #
Dump world to a text file. Saves only awake bodies and associated static bodies. Meshes are saved to binary b3m files.
Binds b3World_DumpAwake.
dump :: WorldId -> IO () Source #
Dump world to a text file. Meshes are saved to binary b3m files.
Binds b3World_Dump.
Arguments
| :: WorldId |
|
| -> Ptr Recording |
|
| -> IO () |
Begin recording world mutations into the provided buffer. The buffer is reset on each call so a single b3Recording can be reused for multiple sessions.
Binds b3World_StartRecording.
End the current recording session. Writes the trailing geometry registry and backpatches the header. The buffer remains valid until the recording is destroyed.
Binds b3World_StopRecording.