| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box2D.Collision
Synopsis
- saveRecordingToFile :: Ptr Recording -> CString -> IO Bool
- loadRecordingFromFile :: CString -> IO (Ptr Recording)
- validateReplay :: Ptr () -> Int -> Int -> IO Bool
- isValidRay :: RayCastInput -> IO Bool
- makePolygon :: Hull -> Float -> IO Polygon
- makeOffsetPolygon :: Hull -> Vec2 -> Rot -> IO Polygon
- makeOffsetRoundedPolygon :: Hull -> Vec2 -> Rot -> Float -> IO Polygon
- makeSquare :: Float -> IO Polygon
- makeSquareInto :: Float -> Ptr Polygon -> IO ()
- makeBox :: Float -> Float -> IO Polygon
- makeBoxInto :: Float -> Float -> Ptr Polygon -> IO ()
- makeRoundedBox :: Float -> Float -> Float -> IO Polygon
- makeRoundedBoxInto :: Float -> Float -> Float -> Ptr Polygon -> IO ()
- makeOffsetBox :: Float -> Float -> Vec2 -> Rot -> IO Polygon
- makeOffsetRoundedBox :: Float -> Float -> Vec2 -> Rot -> Float -> IO Polygon
- transformPolygon :: Transform -> Polygon -> IO Polygon
- computeCircleMass :: Circle -> Float -> IO MassData
- computeCapsuleMass :: Capsule -> Float -> IO MassData
- computePolygonMass :: Polygon -> Float -> IO MassData
- computeCircleAABB :: Circle -> WorldTransform -> IO AABB
- computeCapsuleAABB :: Capsule -> WorldTransform -> IO AABB
- computePolygonAABB :: Polygon -> WorldTransform -> IO AABB
- computeSegmentAABB :: Segment -> WorldTransform -> IO AABB
- pointInCircle :: Circle -> Vec2 -> IO Bool
- pointInCapsule :: Capsule -> Vec2 -> IO Bool
- pointInPolygon :: Polygon -> Vec2 -> IO Bool
- rayCastCircle :: Circle -> RayCastInput -> IO CastOutput
- rayCastCapsule :: Capsule -> RayCastInput -> IO CastOutput
- rayCastSegment :: Segment -> RayCastInput -> Bool -> IO CastOutput
- rayCastPolygon :: Polygon -> RayCastInput -> IO CastOutput
- shapeCastCircle :: Circle -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastCapsule :: Capsule -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastSegment :: Segment -> Ptr ShapeCastInput -> IO CastOutput
- shapeCastPolygon :: Polygon -> Ptr ShapeCastInput -> IO CastOutput
- computeHull :: Ptr Vec2 -> Int -> IO Hull
- computeHullInto :: Ptr Vec2 -> Int -> Ptr Hull -> IO ()
- validateHull :: Hull -> IO Bool
- segmentDistance :: Vec2 -> Vec2 -> Vec2 -> Vec2 -> Ptr SegmentDistanceResult -> IO ()
- shapeDistance :: Ptr DistanceInput -> Ptr SimplexCache -> Ptr Simplex -> Int -> Ptr DistanceOutput -> IO ()
- shapeCast :: Ptr ShapeCastPairInput -> IO CastOutput
- shapeCastInto :: Ptr ShapeCastPairInput -> Ptr CastOutput -> IO ()
- makeProxy :: Ptr Vec2 -> Int -> Float -> Ptr ShapeProxy -> IO ()
- makeOffsetProxy :: Ptr Vec2 -> Int -> Float -> Vec2 -> Rot -> Ptr ShapeProxy -> IO ()
- getSweepTransform :: Sweep -> Float -> IO Transform
- timeOfImpact :: Ptr TOIInput -> Ptr TOIOutput -> IO ()
- collideCircles :: Circle -> Circle -> Transform -> Ptr LocalManifold -> IO ()
- collideCapsuleAndCircle :: Capsule -> Circle -> Transform -> Ptr LocalManifold -> IO ()
- collideSegmentAndCircle :: Segment -> Circle -> Transform -> Ptr LocalManifold -> IO ()
- collidePolygonAndCircle :: Polygon -> Circle -> Transform -> Ptr LocalManifold -> IO ()
- collideCapsules :: Capsule -> Capsule -> Transform -> Ptr LocalManifold -> IO ()
- collideSegmentAndCapsule :: Segment -> Capsule -> Transform -> Ptr LocalManifold -> IO ()
- collidePolygonAndCapsule :: Polygon -> Capsule -> Transform -> Ptr LocalManifold -> IO ()
- collidePolygons :: Polygon -> Polygon -> Transform -> Ptr LocalManifold -> IO ()
- collideSegmentAndPolygon :: Segment -> Polygon -> Transform -> Ptr LocalManifold -> IO ()
- collideChainSegmentAndCircle :: Ptr ChainSegment -> Circle -> Transform -> Ptr LocalManifold -> IO ()
- collideChainSegmentAndCapsule :: Ptr ChainSegment -> Capsule -> Transform -> Ptr SimplexCache -> Ptr LocalManifold -> IO ()
- collideChainSegmentAndPolygon :: Ptr ChainSegment -> Polygon -> Transform -> Ptr SimplexCache -> Ptr LocalManifold -> IO ()
- solvePlanes :: Vec2 -> Ptr CollisionPlane -> Int -> Ptr PlaneSolverResult -> IO ()
- clipVector :: Vec2 -> Ptr CollisionPlane -> Int -> IO Vec2
Documentation
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 #
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.
Arguments
| :: Ptr () |
|
| -> Int |
|
| -> Int |
|
| -> 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.
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.
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 #
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.
Make a square polygon, bypassing the need for a convex hull.
Binds b2MakeSquare.
Like makeSquare, but the result is written into a caller-supplied buffer.
Arguments
| :: Float |
|
| -> Float |
|
| -> IO Polygon |
Make a box (rectangle) polygon, bypassing the need for a convex hull.
Binds b2MakeBox.
Arguments
| :: Float |
|
| -> Float |
|
| -> Ptr Polygon | Result buffer. |
| -> IO () |
Like makeBox, but the result is written into a caller-supplied buffer.
Arguments
| :: Float |
|
| -> Float |
|
| -> Float |
|
| -> IO Polygon |
Make a rounded box, bypassing the need for a convex hull.
Binds b2MakeRoundedBox.
Arguments
| :: Float |
|
| -> Float |
|
| -> Float |
|
| -> Ptr Polygon | Result buffer. |
| -> IO () |
Like makeRoundedBox, but the result is written into a caller-supplied buffer.
Arguments
| :: Float |
|
| -> Float |
|
| -> Vec2 |
|
| -> Rot |
|
| -> IO Polygon |
Make an offset box, bypassing the need for a convex hull.
Binds b2MakeOffsetBox.
Arguments
| :: Float |
|
| -> Float |
|
| -> Vec2 |
|
| -> Rot |
|
| -> Float |
|
| -> 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.
Compute mass properties of a circle
Binds b2ComputeCircleMass.
Compute mass properties of a capsule
Binds b2ComputeCapsuleMass.
Compute mass properties of a polygon
Binds b2ComputePolygonMass.
Arguments
| :: Circle | shape |
| -> WorldTransform | |
| -> IO AABB |
Compute the bounding box of a transformed circle
Binds b2ComputeCircleAABB.
Arguments
| :: Capsule | shape |
| -> WorldTransform | |
| -> IO AABB |
Compute the bounding box of a transformed capsule
Binds b2ComputeCapsuleAABB.
Arguments
| :: Polygon | shape |
| -> WorldTransform | |
| -> IO AABB |
Compute the bounding box of a transformed polygon
Binds b2ComputePolygonAABB.
Arguments
| :: Segment | shape |
| -> WorldTransform | |
| -> IO AABB |
Compute the bounding box of a transformed line segment
Binds b2ComputeSegmentAABB.
Test a point for overlap with a circle in local space
Binds b2PointInCircle.
Test a point for overlap with a capsule in local space
Binds b2PointInCapsule.
Test a point for overlap with a convex polygon in local space
Binds b2PointInPolygon.
Arguments
| :: Circle | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus circle shape in local space.
Binds b2RayCastCircle.
Arguments
| :: Capsule | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus capsule shape in local space.
Binds b2RayCastCapsule.
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.
Arguments
| :: Polygon | shape |
| -> RayCastInput | |
| -> IO CastOutput |
Ray cast versus polygon shape in local space.
Binds b2RayCastPolygon.
Arguments
| :: Circle | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a circle.
Binds b2ShapeCastCircle.
Arguments
| :: Capsule | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a capsule.
Binds b2ShapeCastCapsule.
Arguments
| :: Segment | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a line segment.
Binds b2ShapeCastSegment.
Arguments
| :: Polygon | shape |
| -> Ptr ShapeCastInput | |
| -> IO CastOutput |
Shape cast versus a convex polygon.
Binds b2ShapeCastPolygon.
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.
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.
Compute the distance between two line segments, clamping at the end points if needed.
Binds b2SegmentDistance.
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.
Arguments
| :: Ptr ShapeCastPairInput | |
| -> Ptr CastOutput | Result buffer. |
| -> IO () |
Like shapeCast, but the result is written into a caller-supplied buffer.
Make a proxy for use in overlap, shape cast, and related functions. This is a deep copy of the points.
Binds b2MakeProxy.
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.
Evaluate the transform sweep at a specific time.
Binds b2GetSweepTransform.
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.
Compute the contact manifold between two circles
Binds b2CollideCircles.
collideCapsuleAndCircle Source #
Compute the contact manifold between a capsule and circle
Binds b2CollideCapsuleAndCircle.
collideSegmentAndCircle Source #
Compute the contact manifold between an segment and a circle
Binds b2CollideSegmentAndCircle.
collidePolygonAndCircle Source #
Compute the contact manifold between a polygon and a circle
Binds b2CollidePolygonAndCircle.
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.
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.
Arguments
| :: Vec2 |
|
| -> Ptr CollisionPlane |
|
| -> Int |
|
| -> Ptr PlaneSolverResult | Result buffer. |
| -> IO () |
Solves the position of a mover that satisfies the given collision planes.
Binds b2SolvePlanes.
Clips the velocity against the given collision planes. Planes with zero push or clipVelocity set to false are skipped.
Binds b2ClipVector.