Box3D
Safe HaskellNone
LanguageGHC2021

Box3D.Collision

Synopsis

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.

saveRecordingToFile Source #

Arguments

:: Ptr Recording

recording: the recording to save

-> CString

path: file path to write

-> IO Bool 

Save the recording buffer to a file. Returns true on success.

Binds b3SaveRecordingToFile.

loadRecordingFromFile Source #

Arguments

:: CString

path: file path to read

-> IO (Ptr Recording) 

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.

validateReplay Source #

Arguments

:: Ptr ()

data: pointer to recording bytes

-> Int

size: byte count of the recording

-> Int

workerCount: reserved for future multithreaded replay; pass 1 for now

-> 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.

cloneHull :: Ptr HullData -> IO (Ptr HullData) Source #

Deep clone a hull.

Binds b3CloneHull.

cloneAndTransformHull Source #

Arguments

:: Ptr HullData
original
-> Transform 
-> Vec3
scale
-> IO (Ptr HullData) 

Clone and transform a hull. Supports non-uniform and mirroring scale.

Binds b3CloneAndTransformHull.

makeCubeHull Source #

Arguments

:: Float
halfWidth
-> Ptr BoxHull

Result buffer.

-> IO () 

Make a cube as a hull. Do not call b3DestroyHull on this.

Binds b3MakeCubeHull.

makeBoxHull Source #

Arguments

:: Float
hx
-> Float
hy
-> Float
hz
-> Ptr BoxHull

Result buffer.

-> IO () 

Make a box as a hull. Do not call b3DestroyHull on this.

Binds b3MakeBoxHull.

makeOffsetBoxHull Source #

Arguments

:: Float
hx
-> Float
hy
-> Float
hz
-> Vec3
offset
-> Ptr BoxHull

Result buffer.

-> IO () 

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

transform: local transform of box

-> Ptr BoxHull

Result buffer.

-> IO () 

Make a transformed box as a hull. Do not call b3DestroyHull on this.

Binds b3MakeTransformedBoxHull.

makeScaledBoxHull Source #

Arguments

:: Vec3

halfWidths: positive half widths

-> Transform

transform: local transform of box

-> Vec3

postScale: scale applied after the transform, may be negative

-> 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.

scaleBox Source #

Arguments

:: Ptr Vec3

halfWidths: \[in\/out\] the box half widths

-> Ptr Transform

transform: \[in\/out\] the box transform with rotation and translation

-> Vec3

postScale: the post scale being applied to the box after the transform

-> Float

minHalfWidth: the minimum half width after scale is applied

-> 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.

getHeight :: Ptr MeshData -> IO Int Source #

Get the height of the mesh BVH.

Binds b3GetHeight.

dumpHeightData Source #

Arguments

:: Ptr HeightFieldDef
data
-> CString
fileName
-> IO () 

Save input height data to a file

Binds b3DumpHeightData.

loadHeightField Source #

Arguments

:: CString
fileName
-> IO (Ptr HeightFieldData) 

Create a height field by loading a previously saved height data

Binds b3LoadHeightField.

getCompoundChild Source #

Arguments

:: Ptr CompoundData 
-> Int
childIndex
-> Ptr ChildShape

Result buffer.

-> IO () 

Get a child shape of a compound.

Binds b3GetCompoundChild.

queryCompound Source #

Arguments

:: Ptr CompoundData 
-> AABB 
-> FunPtr CompoundQueryFcn 
-> Ptr ()
context
-> IO () 

Query a compound shape for children that overlap an AABB.

Binds b3QueryCompound.

getCompoundCapsule Source #

Arguments

:: Ptr CompoundData 
-> Int
index
-> Ptr CompoundCapsule

Result buffer.

-> IO () 

Access a child capsule by index.

Binds b3GetCompoundCapsule.

getCompoundHull Source #

Arguments

:: Ptr CompoundData 
-> Int
index
-> Ptr CompoundHull

Result buffer.

-> IO () 

Access a child hull by index.

Binds b3GetCompoundHull.

getCompoundMesh Source #

Arguments

:: Ptr CompoundData 
-> Int
index
-> Ptr CompoundMesh

Result buffer.

-> IO () 

Access a child mesh by index.

Binds b3GetCompoundMesh.

getCompoundSphere Source #

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 #

Arguments

:: Ptr Word8
bytes
-> Int
byteCount
-> IO (Ptr CompoundData) 

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.

computeSphereMass Source #

Arguments

:: Sphere
shape
-> Float
density
-> IO MassData 

Compute mass properties of a sphere

Binds b3ComputeSphereMass.

computeCapsuleMass Source #

Arguments

:: Capsule
shape
-> Float
density
-> IO MassData 

Compute mass properties of a capsule

Binds b3ComputeCapsuleMass.

computeHullMass Source #

Arguments

:: Ptr HullData
shape
-> Float
density
-> IO MassData 

Compute mass properties of a hull

Binds b3ComputeHullMass.

computeHullMassInto Source #

Arguments

:: Ptr HullData
shape
-> Float
density
-> Ptr MassData

Result buffer.

-> IO () 

Like computeHullMass, but the result is written into a caller-supplied buffer.

computeSphereAABB Source #

Arguments

:: Sphere
shape
-> Transform 
-> IO AABB 

Compute the bounding box of a transformed sphere

Binds b3ComputeSphereAABB.

computeCapsuleAABB Source #

Arguments

:: Capsule
shape
-> Transform 
-> IO AABB 

Compute the bounding box of a transformed capsule

Binds b3ComputeCapsuleAABB.

computeHullAABB Source #

Arguments

:: Ptr HullData
shape
-> Transform 
-> IO AABB 

Compute the bounding box of a transformed hull

Binds b3ComputeHullAABB.

computeMeshAABB Source #

Arguments

:: Ptr MeshData
shape
-> Transform 
-> Vec3
scale
-> IO AABB 

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.

computeCompoundAABB Source #

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.

overlapCapsule Source #

Arguments

:: Capsule
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus capsule

Binds b3OverlapCapsule.

overlapCompound Source #

Arguments

:: Ptr CompoundData
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus compound

Binds b3OverlapCompound.

overlapHeightField Source #

Arguments

:: Ptr HeightFieldData
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus height field

Binds b3OverlapHeightField.

overlapHull Source #

Arguments

:: Ptr HullData
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus hull

Binds b3OverlapHull.

overlapMesh Source #

Arguments

:: Ptr Mesh
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus mesh

Binds b3OverlapMesh.

overlapSphere Source #

Arguments

:: Sphere
shape
-> Transform
shapeTransform
-> Ptr ShapeProxy 
-> IO Bool 

Overlap shape versus sphere

Binds b3OverlapSphere.

rayCastSphere Source #

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.

rayCastHollowSphere Source #

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.

rayCastCapsule Source #

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.

rayCastCompound Source #

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.

rayCastHull Source #

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.

rayCastMesh Source #

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.

rayCastHeightField Source #

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.

shapeCastSphere Source #

Arguments

:: Sphere
shape
-> Ptr ShapeCastInput 
-> IO CastOutput 

Shape cast versus a sphere. Initial overlap is treated as a miss.

Binds b3ShapeCastSphere.

shapeCastCapsule Source #

Arguments

:: Capsule
shape
-> Ptr ShapeCastInput 
-> IO CastOutput 

Shape cast versus a capsule. Initial overlap is treated as a miss.

Binds b3ShapeCastCapsule.

shapeCastCompound Source #

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.

shapeCastHull Source #

Arguments

:: Ptr HullData
shape
-> Ptr ShapeCastInput 
-> IO CastOutput 

Shape cast versus a hull. Initial overlap is treated as a miss.

Binds b3ShapeCastHull.

shapeCastHullInto Source #

Arguments

:: Ptr HullData
shape
-> Ptr ShapeCastInput 
-> Ptr CastOutput

Result buffer.

-> IO () 

Like shapeCastHull, but the result is written into a caller-supplied buffer.

shapeCastMesh Source #

Arguments

:: Ptr Mesh
shape
-> Ptr ShapeCastInput 
-> IO CastOutput 

Shape cast versus a mesh. Initial overlap is treated as a miss.

Binds b3ShapeCastMesh.

shapeCastMeshInto Source #

Arguments

:: Ptr Mesh
shape
-> Ptr ShapeCastInput 
-> Ptr CastOutput

Result buffer.

-> IO () 

Like shapeCastMesh, but the result is written into a caller-supplied buffer.

shapeCastHeightField Source #

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.

queryMesh Source #

Arguments

:: Ptr Mesh

mesh: the mesh to query, includes scale

-> AABB

bounds: the bounding box in local space

-> FunPtr MeshQueryFcn

fcn: a user function to collect triangles

-> Ptr ()

context: the context sent to the user function.

-> IO () 

Query a mesh for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.

Binds b3QueryMesh.

queryHeightField Source #

Arguments

:: Ptr HeightFieldData

heightField: the height field to query

-> AABB

bounds: the bounding box in local space

-> FunPtr MeshQueryFcn

fcn: a user function to collect triangles

-> Ptr ()

context: the context sent to the user function.

-> IO () 

Query a height field for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.

Binds b3QueryHeightField.

shapeDistance Source #

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.

shapeCastInto Source #

Arguments

:: Ptr ShapeCastPairInput 
-> Ptr CastOutput

Result buffer.

-> IO () 

Like shapeCast, but the result is written into a caller-supplied buffer.

getSweepTransform Source #

Arguments

:: Sweep 
-> Float
time
-> IO Transform 

Evaluate the transform sweep at a specific time.

Binds b3GetSweepTransform.

timeOfImpact Source #

Arguments

:: Ptr TOIInput 
-> Ptr TOIOutput

Result buffer.

-> IO () 

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.

collideSpheres Source #

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.

collideHullAndSphere Source #

Arguments

:: Ptr LocalManifold 
-> Int
capacity
-> Ptr HullData
hullA
-> Sphere
sphereB
-> Transform
transformBtoA
-> Ptr SimplexCache 
-> IO () 

Collide a hull and a sphere.

Binds b3CollideHullAndSphere.

collideCapsules Source #

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.

collideHulls Source #

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 #

Arguments

:: Ptr LocalManifold 
-> Int
capacity
-> Sphere
sphereA
-> Ptr Vec3
triangleB
-> IO () 

Collide a sphere and a triangle.

Binds b3CollideSphereAndTriangle.

solvePlanes Source #

Arguments

:: Vec3

targetDelta: the desired translation from the position used to generate the collision planes

-> Ptr CollisionPlane

planes: the collision planes

-> Int

count: the number of collision planes

-> Ptr PlaneSolverResult

Result buffer.

-> IO () 

Solves the position of a mover that satisfies the given collision planes.

Binds b3SolvePlanes.

clipVector Source #

Arguments

:: Vec3
vector
-> Ptr CollisionPlane
planes
-> Int
count
-> IO Vec3 

Clips the velocity against the given collision planes. Planes with zero push or clipVelocity set to false are skipped.

Binds b3ClipVector.