| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box3D.Collision
Synopsis
- getWorldCount :: IO Int
- getMaxWorldCount :: IO Int
- saveRecordingToFile :: Ptr Recording -> CString -> IO Bool
- loadRecordingFromFile :: CString -> IO (Ptr Recording)
- validateReplay :: Ptr () -> Int -> Int -> IO Bool
- cloneHull :: Ptr HullData -> IO (Ptr HullData)
- cloneAndTransformHull :: Ptr HullData -> Transform -> Vec3 -> IO (Ptr HullData)
- makeCubeHull :: Float -> Ptr BoxHull -> IO ()
- makeBoxHull :: Float -> Float -> Float -> Ptr BoxHull -> IO ()
- makeOffsetBoxHull :: Float -> Float -> Float -> Vec3 -> Ptr BoxHull -> IO ()
- makeTransformedBoxHull :: Float -> Float -> Float -> Transform -> Ptr BoxHull -> IO ()
- makeScaledBoxHull :: Vec3 -> Transform -> Vec3 -> Ptr BoxHull -> IO ()
- scaleBox :: Ptr Vec3 -> Ptr Transform -> Vec3 -> Float -> IO ()
- getHeight :: Ptr MeshData -> IO Int
- dumpHeightData :: Ptr HeightFieldDef -> CString -> IO ()
- loadHeightField :: CString -> IO (Ptr HeightFieldData)
- getCompoundChild :: Ptr CompoundData -> Int -> Ptr ChildShape -> IO ()
- queryCompound :: Ptr CompoundData -> AABB -> FunPtr CompoundQueryFcn -> Ptr () -> IO ()
- getCompoundCapsule :: Ptr CompoundData -> Int -> Ptr CompoundCapsule -> IO ()
- getCompoundHull :: Ptr CompoundData -> Int -> Ptr CompoundHull -> IO ()
- getCompoundMesh :: Ptr CompoundData -> Int -> Ptr CompoundMesh -> IO ()
- getCompoundSphere :: Ptr CompoundData -> Int -> Ptr CompoundSphere -> IO ()
- getCompoundMaterials :: Ptr CompoundData -> IO (Ptr SurfaceMaterial)
- convertCompoundToBytes :: Ptr CompoundData -> IO (Ptr Word8)
- convertBytesToCompound :: Ptr Word8 -> Int -> IO (Ptr CompoundData)
- computeSphereMass :: Sphere -> Float -> IO MassData
- computeCapsuleMass :: Capsule -> Float -> IO MassData
- computeHullMass :: Ptr HullData -> Float -> IO MassData
- computeHullMassInto :: Ptr HullData -> Float -> Ptr MassData -> IO ()
- computeSphereAABB :: Sphere -> Transform -> IO AABB
- computeCapsuleAABB :: Capsule -> Transform -> IO AABB
- computeHullAABB :: Ptr HullData -> Transform -> IO AABB
- computeMeshAABB :: Ptr MeshData -> Transform -> Vec3 -> IO AABB
- computeHeightFieldAABB :: Ptr HeightFieldData -> Transform -> IO AABB
- computeCompoundAABB :: Ptr CompoundData -> Transform -> IO AABB
- isValidRay :: RayCastInput -> IO Bool
- overlapCapsule :: Capsule -> Transform -> Ptr ShapeProxy -> IO Bool
- overlapCompound :: Ptr CompoundData -> Transform -> Ptr ShapeProxy -> IO Bool
- overlapHeightField :: Ptr HeightFieldData -> Transform -> Ptr ShapeProxy -> IO Bool
- overlapHull :: Ptr HullData -> Transform -> Ptr ShapeProxy -> IO Bool
- overlapMesh :: Ptr Mesh -> Transform -> Ptr ShapeProxy -> IO Bool
- overlapSphere :: Sphere -> Transform -> Ptr ShapeProxy -> IO Bool
- rayCastSphere :: Sphere -> RayCastInput -> IO CastOutput
- rayCastHollowSphere :: Sphere -> RayCastInput -> IO CastOutput
- rayCastCapsule :: Capsule -> RayCastInput -> IO CastOutput
- rayCastCompound :: Ptr CompoundData -> RayCastInput -> IO CastOutput
- rayCastHull :: Ptr HullData -> RayCastInput -> IO CastOutput
- rayCastMesh :: Ptr Mesh -> RayCastInput -> IO CastOutput
- rayCastHeightField :: Ptr HeightFieldData -> RayCastInput -> IO CastOutput
- shapeCastSphere :: Sphere -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastCapsule :: Capsule -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastCompound :: Ptr CompoundData -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastCompoundInto :: Ptr CompoundData -> Ptr ShapeCastInput -> Ptr CastOutput -> IO ()
- shapeCastHull :: Ptr HullData -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastHullInto :: Ptr HullData -> Ptr ShapeCastInput -> Ptr CastOutput -> IO ()
- shapeCastMesh :: Ptr Mesh -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastMeshInto :: Ptr Mesh -> Ptr ShapeCastInput -> Ptr CastOutput -> IO ()
- shapeCastHeightField :: Ptr HeightFieldData -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastHeightFieldInto :: Ptr HeightFieldData -> Ptr ShapeCastInput -> Ptr CastOutput -> IO ()
- queryMesh :: Ptr Mesh -> AABB -> FunPtr MeshQueryFcn -> Ptr () -> IO ()
- queryHeightField :: Ptr HeightFieldData -> AABB -> FunPtr MeshQueryFcn -> Ptr () -> IO ()
- shapeDistance :: Ptr DistanceInput -> Ptr SimplexCache -> Ptr Simplex -> Int -> Ptr DistanceOutput -> IO ()
- shapeCast :: Ptr ShapeCastPairInput -> IO CastOutput
- shapeCastInto :: Ptr ShapeCastPairInput -> Ptr CastOutput -> IO ()
- getSweepTransform :: Sweep -> Float -> IO Transform
- timeOfImpact :: Ptr TOIInput -> Ptr TOIOutput -> IO ()
- collideSpheres :: Ptr LocalManifold -> Int -> Sphere -> Sphere -> Transform -> IO ()
- collideCapsuleAndSphere :: Ptr LocalManifold -> Int -> Capsule -> Sphere -> Transform -> IO ()
- collideHullAndSphere :: Ptr LocalManifold -> Int -> Ptr HullData -> Sphere -> Transform -> Ptr SimplexCache -> IO ()
- collideCapsules :: Ptr LocalManifold -> Int -> Capsule -> Capsule -> Transform -> IO ()
- collideHullAndCapsule :: Ptr LocalManifold -> Int -> Ptr HullData -> Capsule -> Transform -> Ptr SimplexCache -> IO ()
- collideHulls :: Ptr LocalManifold -> Int -> Ptr HullData -> Ptr HullData -> Transform -> Ptr SATCache -> IO ()
- collideCapsuleAndTriangle :: Ptr LocalManifold -> Int -> Capsule -> Ptr Vec3 -> Ptr SimplexCache -> IO ()
- collideHullAndTriangle :: Ptr LocalManifold -> Int -> Ptr HullData -> Vec3 -> Vec3 -> Vec3 -> Int -> Ptr SATCache -> IO ()
- collideSphereAndTriangle :: Ptr LocalManifold -> Int -> Sphere -> Ptr Vec3 -> IO ()
- solvePlanes :: Vec3 -> Ptr CollisionPlane -> Int -> Ptr PlaneSolverResult -> IO ()
- clipVector :: Vec3 -> Ptr CollisionPlane -> Int -> IO Vec3
Documentation
getWorldCount :: IO Int Source #
Get the current number of worlds
Binds b3GetWorldCount.
getMaxWorldCount :: IO Int Source #
Get the maximum number of simultaneous worlds that have been created
Binds b3GetMaxWorldCount.
Arguments
| :: Ptr Recording |
|
| -> CString |
|
| -> IO Bool |
Save the recording buffer to a file. Returns true on success.
Binds b3SaveRecordingToFile.
loadRecordingFromFile Source #
Load a recording from a file. Returns NULL on failure (file not found, wrong magic). The caller owns the returned recording and must destroy it with b3DestroyRecording.
Binds b3LoadRecordingFromFile.
Arguments
| :: Ptr () |
|
| -> Int |
|
| -> Int |
|
| -> IO Bool |
Replay a recording from memory and verify it reproduces the same world-state hashes. Stands up a fresh world, restores the seed snapshot, replays every op, and checks each embedded StateHash record. Returns true if replay completed without id mismatches or hash divergences.
Binds b3ValidateReplay.
cloneAndTransformHull Source #
Clone and transform a hull. Supports non-uniform and mirroring scale.
Binds b3CloneAndTransformHull.
Make a cube as a hull. Do not call b3DestroyHull on this.
Binds b3MakeCubeHull.
Make a box as a hull. Do not call b3DestroyHull on this.
Binds b3MakeBoxHull.
Make an offset box as a hull. Do not call b3DestroyHull on this.
Binds b3MakeOffsetBoxHull.
makeTransformedBoxHull Source #
Arguments
| :: Float | hx |
| -> Float | hy |
| -> Float | hz |
| -> Transform |
|
| -> Ptr BoxHull | Result buffer. |
| -> IO () |
Make a transformed box as a hull. Do not call b3DestroyHull on this.
Binds b3MakeTransformedBoxHull.
Arguments
| :: Vec3 |
|
| -> Transform |
|
| -> Vec3 |
|
| -> Ptr BoxHull | Result buffer. |
| -> IO () |
This makes a transformed box hull with post scaling. This is useful for boxes that are scaled in a level editor. Such scaling can have reflection and shear. In the case of shear the result may be approximate. If you need to support shear consider using b3CreateHull. Do not call b3DestroyHull on this.
Binds b3MakeScaledBoxHull.
Arguments
| :: Ptr Vec3 |
|
| -> Ptr Transform |
|
| -> Vec3 |
|
| -> Float |
|
| -> IO () |
This takes a box with a transform and post scale and converts it into a box with the post scale resolved with new half-widths and transform. This accepts non-uniform and negative scale. This is approximate if there is shear.
Binds b3ScaleBox.
Arguments
| :: Ptr HeightFieldDef | data |
| -> CString | fileName |
| -> IO () |
Save input height data to a file
Binds b3DumpHeightData.
Arguments
| :: CString | fileName |
| -> IO (Ptr HeightFieldData) |
Create a height field by loading a previously saved height data
Binds b3LoadHeightField.
Arguments
| :: Ptr CompoundData | |
| -> Int | childIndex |
| -> Ptr ChildShape | Result buffer. |
| -> IO () |
Get a child shape of a compound.
Binds b3GetCompoundChild.
Arguments
| :: Ptr CompoundData | |
| -> AABB | |
| -> FunPtr CompoundQueryFcn | |
| -> Ptr () | context |
| -> IO () |
Query a compound shape for children that overlap an AABB.
Binds b3QueryCompound.
Arguments
| :: Ptr CompoundData | |
| -> Int | index |
| -> Ptr CompoundCapsule | Result buffer. |
| -> IO () |
Access a child capsule by index.
Binds b3GetCompoundCapsule.
Arguments
| :: Ptr CompoundData | |
| -> Int | index |
| -> Ptr CompoundHull | Result buffer. |
| -> IO () |
Access a child hull by index.
Binds b3GetCompoundHull.
Arguments
| :: Ptr CompoundData | |
| -> Int | index |
| -> Ptr CompoundMesh | Result buffer. |
| -> IO () |
Access a child mesh by index.
Binds b3GetCompoundMesh.
Arguments
| :: Ptr CompoundData | |
| -> Int | index |
| -> Ptr CompoundSphere | Result buffer. |
| -> IO () |
Access a child sphere by index.
Binds b3GetCompoundSphere.
getCompoundMaterials :: Ptr CompoundData -> IO (Ptr SurfaceMaterial) Source #
Access the compound material array.
Binds b3GetCompoundMaterials.
convertCompoundToBytes :: Ptr CompoundData -> IO (Ptr Word8) Source #
If bytes is null then this returns the number of required bytes. This clones all the data into the bytes buffer. This is expected to run offline or asynchronously. This mutates the compound to nullify pointers, leaving the compound in an unusable state.
Binds b3ConvertCompoundToBytes.
convertBytesToCompound Source #
Convert bytes to compound. This does not clone. The bytes must remain in scope while the compound is used. This is done to improve run-time performance and allow for instancing. The bytes are mutated to fixup pointers.
Binds b3ConvertBytesToCompound.
Compute mass properties of a sphere
Binds b3ComputeSphereMass.
Compute mass properties of a capsule
Binds b3ComputeCapsuleMass.
Compute mass properties of a hull
Binds b3ComputeHullMass.
Like computeHullMass, but the result is written into a caller-supplied buffer.
Compute the bounding box of a transformed sphere
Binds b3ComputeSphereAABB.
Compute the bounding box of a transformed capsule
Binds b3ComputeCapsuleAABB.
Compute the bounding box of a transformed hull
Binds b3ComputeHullAABB.
Compute the bounding box of a transformed mesh. Scale may be non-uniform and have negative components.
Binds b3ComputeMeshAABB.
computeHeightFieldAABB Source #
Arguments
| :: Ptr HeightFieldData | shape |
| -> Transform | |
| -> IO AABB |
Compute the bounding box of a transformed height-field
Binds b3ComputeHeightFieldAABB.
Arguments
| :: Ptr CompoundData | shape |
| -> Transform | |
| -> IO AABB |
Compute the bounding box of a compound
Binds b3ComputeCompoundAABB.
isValidRay :: RayCastInput -> IO Bool Source #
Use this to ensure your ray cast input is valid and avoid internal assertions.
Binds b3IsValidRay.
Overlap shape versus capsule
Binds b3OverlapCapsule.
Arguments
| :: Ptr CompoundData | shape |
| -> Transform | shapeTransform |
| -> Ptr ShapeProxy | |
| -> IO Bool |
Overlap shape versus compound
Binds b3OverlapCompound.
Arguments
| :: Ptr HeightFieldData | shape |
| -> Transform | shapeTransform |
| -> Ptr ShapeProxy | |
| -> IO Bool |
Overlap shape versus height field
Binds b3OverlapHeightField.
Overlap shape versus hull
Binds b3OverlapHull.
Overlap shape versus mesh
Binds b3OverlapMesh.
Overlap shape versus sphere
Binds b3OverlapSphere.
Arguments
| :: Sphere | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus sphere in local space. A zero length ray is a point query. Initial overlap reports a hit at the ray origin with zero fraction and zero normal.
Binds b3RayCastSphere.
Arguments
| :: Sphere | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus a hollow sphere shell in local space. Unlike the solid sphere a ray starting inside is not an overlap: it passes through and hits the far wall.
Binds b3RayCastHollowSphere.
Arguments
| :: Capsule | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus capsule in local space. A zero length ray is a point query. Initial overlap reports a hit at the ray origin with zero fraction and zero normal.
Binds b3RayCastCapsule.
Arguments
| :: Ptr CompoundData | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus compound in local space. A zero length ray is a point query. Initial overlap with a child reports a hit at the ray origin with zero fraction and zero normal.
Binds b3RayCastCompound.
Arguments
| :: Ptr HullData | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus hull shape in local space. A zero length ray is a point query. Initial overlap reports a hit at the ray origin with zero fraction and zero normal.
Binds b3RayCastHull.
Arguments
| :: Ptr Mesh | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus mesh in local space. A thin surface with no interior, so there is no overlap case.
Binds b3RayCastMesh.
Arguments
| :: Ptr HeightFieldData | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus height field in local space. A thin surface with no interior, so there is no overlap case.
Binds b3RayCastHeightField.
Arguments
| :: Sphere | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a sphere. Initial overlap is treated as a miss.
Binds b3ShapeCastSphere.
Arguments
| :: Capsule | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a capsule. Initial overlap is treated as a miss.
Binds b3ShapeCastCapsule.
Arguments
| :: Ptr CompoundData | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus compound. Initial overlap is treated as a miss.
Binds b3ShapeCastCompound.
shapeCastCompoundInto Source #
Arguments
| :: Ptr CompoundData | shape |
| -> Ptr ShapeCastInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCastCompound, but the result is written into a caller-supplied buffer.
Arguments
| :: Ptr HullData | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a hull. Initial overlap is treated as a miss.
Binds b3ShapeCastHull.
Arguments
| :: Ptr HullData | shape |
| -> Ptr ShapeCastInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCastHull, but the result is written into a caller-supplied buffer.
Arguments
| :: Ptr Mesh | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a mesh. Initial overlap is treated as a miss.
Binds b3ShapeCastMesh.
Arguments
| :: Ptr Mesh | shape |
| -> Ptr ShapeCastInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCastMesh, but the result is written into a caller-supplied buffer.
Arguments
| :: Ptr HeightFieldData | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a height field. Initial overlap is treated as a miss.
Binds b3ShapeCastHeightField.
shapeCastHeightFieldInto Source #
Arguments
| :: Ptr HeightFieldData | shape |
| -> Ptr ShapeCastInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCastHeightField, but the result is written into a caller-supplied buffer.
Arguments
| :: Ptr Mesh |
|
| -> AABB |
|
| -> FunPtr MeshQueryFcn |
|
| -> Ptr () |
|
| -> IO () |
Query a mesh for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.
Binds b3QueryMesh.
Arguments
| :: Ptr HeightFieldData |
|
| -> AABB |
|
| -> FunPtr MeshQueryFcn |
|
| -> Ptr () |
|
| -> IO () |
Query a height field for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.
Binds b3QueryHeightField.
Arguments
| :: Ptr DistanceInput | |
| -> Ptr SimplexCache | |
| -> Ptr Simplex | simplexes |
| -> Int | simplexCapacity |
| -> Ptr DistanceOutput | Result buffer. |
| -> IO () |
Compute the closest points between two shapes represented as point clouds. b3SimplexCache cache is input/output. On the first call set b3SimplexCache.count to zero. The query runs in frame A, so the witness points and normal are returned in frame A. The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.
Binds b3ShapeDistance.
shapeCast :: Ptr ShapeCastPairInput -> IO CastOutput Source #
Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction. The query runs in frame A, so the hit point and normal are returned in frame A. Initially touching shapes are a miss.
Binds b3ShapeCast.
Arguments
| :: Ptr ShapeCastPairInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCast, but the result is written into a caller-supplied buffer.
Evaluate the transform sweep at a specific time.
Binds b3GetSweepTransform.
Compute the upper bound on time before two shapes penetrate. Time is represented as a fraction between \[0,tMax\]. This uses a swept separating axis and may miss some intermediate, non-tunneling collisions. If you change the time interval, you should call this function again.
Binds b3TimeOfImpact.
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Sphere | sphereA |
| -> Sphere | sphereB |
| -> Transform | transformBtoA |
| -> IO () |
Collide two spheres.
Binds b3CollideSpheres.
collideCapsuleAndSphere Source #
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Capsule | capsuleA |
| -> Sphere | sphereB |
| -> Transform | transformBtoA |
| -> IO () |
Collide a capsule and a sphere.
Binds b3CollideCapsuleAndSphere.
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Ptr HullData | hullA |
| -> Sphere | sphereB |
| -> Transform | transformBtoA |
| -> Ptr SimplexCache | |
| -> IO () |
Collide a hull and a sphere.
Binds b3CollideHullAndSphere.
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Capsule | capsuleA |
| -> Capsule | capsuleB |
| -> Transform | transformBtoA |
| -> IO () |
Collide two capsules.
Binds b3CollideCapsules.
collideHullAndCapsule Source #
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Ptr HullData | hullA |
| -> Capsule | capsuleB |
| -> Transform | transformBtoA |
| -> Ptr SimplexCache | |
| -> IO () |
Collide a hull and a capsule.
Binds b3CollideHullAndCapsule.
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Ptr HullData | hullA |
| -> Ptr HullData | hullB |
| -> Transform | transformBtoA |
| -> Ptr SATCache | |
| -> IO () |
Collide two hulls.
Binds b3CollideHulls.
collideCapsuleAndTriangle Source #
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Capsule | capsuleA |
| -> Ptr Vec3 | triangleB |
| -> Ptr SimplexCache | |
| -> IO () |
Collide a capsule and a triangle.
Binds b3CollideCapsuleAndTriangle.
collideHullAndTriangle Source #
Arguments
| :: Ptr LocalManifold | |
| -> Int | capacity |
| -> Ptr HullData | hullA |
| -> Vec3 | v1 |
| -> Vec3 | v2 |
| -> Vec3 | v3 |
| -> Int | triangleFlags |
| -> Ptr SATCache | |
| -> IO () |
Collide a hull and a triangle.
Binds b3CollideHullAndTriangle.
collideSphereAndTriangle Source #
Collide a sphere and a triangle.
Binds b3CollideSphereAndTriangle.
Arguments
| :: Vec3 |
|
| -> Ptr CollisionPlane |
|
| -> Int |
|
| -> Ptr PlaneSolverResult | Result buffer. |
| -> IO () |
Solves the position of a mover that satisfies the given collision planes.
Binds b3SolvePlanes.
Clips the velocity against the given collision planes. Planes with zero push or clipVelocity set to false are skipped.
Binds b3ClipVector.