Box2D
Safe HaskellNone
LanguageGHC2021

Box2D.Collision

Synopsis

Documentation

saveRecordingToFile Source #

Arguments

:: Ptr Recording 
-> CString
path
-> IO Bool 

Save a recording buffer to a file. Convenience wrapper over your own file I/O.

Returns: false if the file could not be written

Binds b2SaveRecordingToFile.

loadRecordingFromFile Source #

Arguments

:: CString
path
-> IO (Ptr Recording) 

Load a recording from a file into a new recording buffer. Convenience wrapper over your own file I/O. Destroy the result with b2DestroyRecording.

Returns: NULL if the file is missing or unreadable

Binds b2LoadRecordingFromFile.

validateReplay Source #

Arguments

:: Ptr ()

data: Recorded bytes, e.g. from b2Recording_GetData or a loaded file

-> Int

size: Number of recorded bytes

-> Int

workerCount: Worker count to use for replay. 0 uses the serial single-worker fallback.

-> IO Bool 

Replay a recording by re-running the engine and asserting recorded ids and state match.

Returns: true if replay completed without divergence, false on any mismatch

Binds b2ValidateReplay.

isValidRay :: RayCastInput -> IO Bool Source #

Validate ray cast input data (NaN, etc)

Binds b2IsValidRay.

makePolygon Source #

Arguments

:: Hull 
-> Float
radius
-> IO Polygon 

Make a convex polygon from a convex hull. This will assert if the hull is not valid. Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull

Binds b2MakePolygon.

makeOffsetPolygon Source #

Arguments

:: Hull 
-> Vec2
position
-> Rot
rotation
-> IO Polygon 

Make an offset convex polygon from a convex hull. This will assert if the hull is not valid. Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull

Binds b2MakeOffsetPolygon.

makeOffsetRoundedPolygon Source #

Arguments

:: Hull 
-> Vec2
position
-> Rot
rotation
-> Float
radius
-> IO Polygon 

Make an offset convex polygon from a convex hull. This will assert if the hull is not valid. Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull

Binds b2MakeOffsetRoundedPolygon.

makeSquare Source #

Arguments

:: Float

halfWidth: the half-width

-> IO Polygon 

Make a square polygon, bypassing the need for a convex hull.

Binds b2MakeSquare.

makeSquareInto Source #

Arguments

:: Float

halfWidth: the half-width

-> Ptr Polygon

Result buffer.

-> IO () 

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

makeBox Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> IO Polygon 

Make a box (rectangle) polygon, bypassing the need for a convex hull.

Binds b2MakeBox.

makeBoxInto Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> Ptr Polygon

Result buffer.

-> IO () 

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

makeRoundedBox Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> Float

radius: the radius of the rounded extension

-> IO Polygon 

Make a rounded box, bypassing the need for a convex hull.

Binds b2MakeRoundedBox.

makeRoundedBoxInto Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> Float

radius: the radius of the rounded extension

-> Ptr Polygon

Result buffer.

-> IO () 

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

makeOffsetBox Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> Vec2

center: the local center of the box

-> Rot

rotation: the local rotation of the box

-> IO Polygon 

Make an offset box, bypassing the need for a convex hull.

Binds b2MakeOffsetBox.

makeOffsetRoundedBox Source #

Arguments

:: Float

halfWidth: the half-width (x-axis)

-> Float

halfHeight: the half-height (y-axis)

-> Vec2

center: the local center of the box

-> Rot

rotation: the local rotation of the box

-> Float

radius: the radius of the rounded extension

-> IO Polygon 

Make an offset rounded box, bypassing the need for a convex hull.

Binds b2MakeOffsetRoundedBox.

transformPolygon :: Transform -> Polygon -> IO Polygon Source #

Transform a polygon. This is useful for transferring a shape from one body to another.

Binds b2TransformPolygon.

computeCircleMass Source #

Arguments

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

Compute mass properties of a circle

Binds b2ComputeCircleMass.

computeCapsuleMass Source #

Arguments

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

Compute mass properties of a capsule

Binds b2ComputeCapsuleMass.

computePolygonMass Source #

Arguments

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

Compute mass properties of a polygon

Binds b2ComputePolygonMass.

computeCircleAABB Source #

Arguments

:: Circle
shape
-> WorldTransform 
-> IO AABB 

Compute the bounding box of a transformed circle

Binds b2ComputeCircleAABB.

computeCapsuleAABB Source #

Arguments

:: Capsule
shape
-> WorldTransform 
-> IO AABB 

Compute the bounding box of a transformed capsule

Binds b2ComputeCapsuleAABB.

computePolygonAABB Source #

Arguments

:: Polygon
shape
-> WorldTransform 
-> IO AABB 

Compute the bounding box of a transformed polygon

Binds b2ComputePolygonAABB.

computeSegmentAABB Source #

Arguments

:: Segment
shape
-> WorldTransform 
-> IO AABB 

Compute the bounding box of a transformed line segment

Binds b2ComputeSegmentAABB.

pointInCircle Source #

Arguments

:: Circle
shape
-> Vec2
point
-> IO Bool 

Test a point for overlap with a circle in local space

Binds b2PointInCircle.

pointInCapsule Source #

Arguments

:: Capsule
shape
-> Vec2
point
-> IO Bool 

Test a point for overlap with a capsule in local space

Binds b2PointInCapsule.

pointInPolygon Source #

Arguments

:: Polygon
shape
-> Vec2
point
-> IO Bool 

Test a point for overlap with a convex polygon in local space

Binds b2PointInPolygon.

rayCastCircle Source #

Arguments

:: Circle
shape
-> RayCastInput 
-> IO CastOutput 

Ray cast versus circle shape in local space.

Binds b2RayCastCircle.

rayCastCapsule Source #

Arguments

:: Capsule
shape
-> RayCastInput 
-> IO CastOutput 

Ray cast versus capsule shape in local space.

Binds b2RayCastCapsule.

rayCastSegment Source #

Arguments

:: Segment
shape
-> RayCastInput 
-> Bool
oneSided
-> IO CastOutput 

Ray cast versus segment shape in local space. Optionally treat the segment as one-sided with hits from the left side being treated as a miss.

Binds b2RayCastSegment.

rayCastPolygon Source #

Arguments

:: Polygon
shape
-> RayCastInput 
-> IO CastOutput 

Ray cast versus polygon shape in local space.

Binds b2RayCastPolygon.

shapeCastCircle Source #

Arguments

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

Shape cast versus a circle.

Binds b2ShapeCastCircle.

shapeCastCapsule Source #

Arguments

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

Shape cast versus a capsule.

Binds b2ShapeCastCapsule.

shapeCastSegment Source #

Arguments

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

Shape cast versus a line segment.

Binds b2ShapeCastSegment.

shapeCastPolygon Source #

Arguments

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

Shape cast versus a convex polygon.

Binds b2ShapeCastPolygon.

computeHull Source #

Arguments

:: Ptr Vec2
points
-> Int
count
-> IO Hull 

Compute the convex hull of a set of points. Returns an empty hull if it fails. Some failure cases: - all points very close together - all points on a line - less than 3 points - more than B2_MAX_POLYGON_VERTICES points This welds close points and removes collinear points. Warning: Do not modify a hull once it has been computed

Binds b2ComputeHull.

computeHullInto Source #

Arguments

:: Ptr Vec2
points
-> Int
count
-> Ptr Hull

Result buffer.

-> IO () 

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

validateHull :: Hull -> IO Bool Source #

This determines if a hull is valid. Checks for: - convexity - collinear points This is expensive and should not be called at runtime.

Binds b2ValidateHull.

segmentDistance Source #

Arguments

:: Vec2
p1
-> Vec2
q1
-> Vec2
p2
-> Vec2
q2
-> Ptr SegmentDistanceResult

Result buffer.

-> IO () 

Compute the distance between two line segments, clamping at the end points if needed.

Binds b2SegmentDistance.

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. b2SimplexCache cache is input/output. On the first call set b2SimplexCache.count to zero. The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.

Binds b2ShapeDistance.

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

shapeCastInto Source #

Arguments

:: Ptr ShapeCastPairInput 
-> Ptr CastOutput

Result buffer.

-> IO () 

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

makeProxy Source #

Arguments

:: Ptr Vec2
points
-> Int
count
-> Float
radius
-> Ptr ShapeProxy

Result buffer.

-> IO () 

Make a proxy for use in overlap, shape cast, and related functions. This is a deep copy of the points.

Binds b2MakeProxy.

makeOffsetProxy Source #

Arguments

:: Ptr Vec2
points
-> Int
count
-> Float
radius
-> Vec2
position
-> Rot
rotation
-> Ptr ShapeProxy

Result buffer.

-> IO () 

Make a proxy with a transform. This is a deep copy of the points.

Binds b2MakeOffsetProxy.

getSweepTransform Source #

Arguments

:: Sweep 
-> Float
time
-> IO Transform 

Evaluate the transform sweep at a specific time.

Binds b2GetSweepTransform.

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

collideCircles Source #

Arguments

:: Circle
circleA
-> Circle
circleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between two circles

Binds b2CollideCircles.

collideCapsuleAndCircle Source #

Arguments

:: Capsule
capsuleA
-> Circle
circleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a capsule and circle

Binds b2CollideCapsuleAndCircle.

collideSegmentAndCircle Source #

Arguments

:: Segment
segmentA
-> Circle
circleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between an segment and a circle

Binds b2CollideSegmentAndCircle.

collidePolygonAndCircle Source #

Arguments

:: Polygon
polygonA
-> Circle
circleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a polygon and a circle

Binds b2CollidePolygonAndCircle.

collideCapsules Source #

Arguments

:: Capsule
capsuleA
-> Capsule
capsuleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a capsule and circle

Binds b2CollideCapsules.

collideSegmentAndCapsule Source #

Arguments

:: Segment
segmentA
-> Capsule
capsuleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between an segment and a capsule

Binds b2CollideSegmentAndCapsule.

collidePolygonAndCapsule Source #

Arguments

:: Polygon
polygonA
-> Capsule
capsuleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a polygon and capsule

Binds b2CollidePolygonAndCapsule.

collidePolygons Source #

Arguments

:: Polygon
polygonA
-> Polygon
polygonB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between two polygons

Binds b2CollidePolygons.

collideSegmentAndPolygon Source #

Arguments

:: Segment
segmentA
-> Polygon
polygonB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between an segment and a polygon

Binds b2CollideSegmentAndPolygon.

collideChainSegmentAndCircle Source #

Arguments

:: Ptr ChainSegment
segmentA
-> Circle
circleB
-> Transform
xf
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a chain segment and a circle

Binds b2CollideChainSegmentAndCircle.

collideChainSegmentAndCapsule Source #

Arguments

:: Ptr ChainSegment
segmentA
-> Capsule
capsuleB
-> Transform
xf
-> Ptr SimplexCache 
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a chain segment and a capsule

Binds b2CollideChainSegmentAndCapsule.

collideChainSegmentAndPolygon Source #

Arguments

:: Ptr ChainSegment
segmentA
-> Polygon
polygonB
-> Transform
xf
-> Ptr SimplexCache 
-> Ptr LocalManifold

Result buffer.

-> IO () 

Compute the contact manifold between a chain segment and a rounded polygon

Binds b2CollideChainSegmentAndPolygon.

solvePlanes Source #

Arguments

:: Vec2

targetDelta: the desired movement 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 b2SolvePlanes.

clipVector Source #

Arguments

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

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

Binds b2ClipVector.