Box2D
Safe HaskellNone
LanguageGHC2021

Box2D.Types

Description

Low-level bindings to the enums and configuration structs of box2d/types.h needed to create and configure worlds, bodies and shapes.

The *Def structs carry an internalValue magic that Box2D uses to detect an initialised definition, so always start from the matching default* constructor and tweak the fields you need before use. Every C bool maps to CBool (one byte), and opaque callback / userData pointers are kept as Ptr () until the callback layer lands.

Synopsis

Enums

newtype BodyType Source #

The body simulation type.

Constructors

BodyType CInt 

Instances

Instances details
Storable BodyType Source # 
Instance details

Defined in Box2D.Types

Show BodyType Source # 
Instance details

Defined in Box2D.Types

Eq BodyType Source # 
Instance details

Defined in Box2D.Types

newtype ShapeType Source #

Shape geometry type.

Constructors

ShapeType CInt 

Instances

Instances details
Storable ShapeType Source # 
Instance details

Defined in Box2D.Types

Show ShapeType Source # 
Instance details

Defined in Box2D.Types

Eq ShapeType Source # 
Instance details

Defined in Box2D.Types

newtype JointType Source #

Joint type.

Constructors

JointType CInt 

Instances

Instances details
Storable JointType Source # 
Instance details

Defined in Box2D.Types

Show JointType Source # 
Instance details

Defined in Box2D.Types

Eq JointType Source # 
Instance details

Defined in Box2D.Types

Small structs

data Capacity Source #

Optional world capacities used to avoid run-time allocations.

Instances

Instances details
Storable Capacity Source # 
Instance details

Defined in Box2D.Types

Show Capacity Source # 
Instance details

Defined in Box2D.Types

Eq Capacity Source # 
Instance details

Defined in Box2D.Types

data MotionLocks Source #

Per-axis translation and rotation locks for a body.

data Filter Source #

Collision filtering data.

Instances

Instances details
Storable Filter Source # 
Instance details

Defined in Box2D.Types

Show Filter Source # 
Instance details

Defined in Box2D.Types

Eq Filter Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Filter -> Filter -> Bool #

(/=) :: Filter -> Filter -> Bool #

data Circle Source #

A solid circle with a local center offset.

Constructors

Circle 

Instances

Instances details
Storable Circle Source # 
Instance details

Defined in Box2D.Types

Show Circle Source # 
Instance details

Defined in Box2D.Types

Eq Circle Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Circle -> Circle -> Bool #

(/=) :: Circle -> Circle -> Bool #

data Capsule Source #

A solid capsule: an extruded circle between two semicircle centers.

Instances

Instances details
Storable Capsule Source # 
Instance details

Defined in Box2D.Types

Show Capsule Source # 
Instance details

Defined in Box2D.Types

Eq Capsule Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Capsule -> Capsule -> Bool #

(/=) :: Capsule -> Capsule -> Bool #

data Segment Source #

A two-sided line segment.

Constructors

Segment 

Instances

Instances details
Storable Segment Source # 
Instance details

Defined in Box2D.Types

Show Segment Source # 
Instance details

Defined in Box2D.Types

Eq Segment Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Segment -> Segment -> Bool #

(/=) :: Segment -> Segment -> Bool #

data Polygon Source #

A solid convex polygon with an optional rounding radius, up to maxPolygonVertices vertices. The engine expects consistent vertices, normals and centroid, so build values with Box2D.Collision.makeBox, makePolygon (from a Hull) and friends rather than by hand.

The vector fields carry the struct's count: both must have the same length, and anything past maxPolygonVertices is dropped on poke.

Instances

Instances details
Storable Polygon Source # 
Instance details

Defined in Box2D.Types

Show Polygon Source # 
Instance details

Defined in Box2D.Types

Eq Polygon Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Polygon -> Polygon -> Bool #

(/=) :: Polygon -> Polygon -> Bool #

newtype Hull Source #

A convex hull of up to maxPolygonVertices points. Compute with Box2D.Collision.computeHull (which validates and welds the input) rather than by hand; anything past maxPolygonVertices is dropped on poke.

Constructors

Hull 

Instances

Instances details
Storable Hull Source # 
Instance details

Defined in Box2D.Types

Methods

sizeOf :: Hull -> Int #

alignment :: Hull -> Int #

peekElemOff :: Ptr Hull -> Int -> IO Hull #

pokeElemOff :: Ptr Hull -> Int -> Hull -> IO () #

peekByteOff :: Ptr b -> Int -> IO Hull #

pokeByteOff :: Ptr b -> Int -> Hull -> IO () #

peek :: Ptr Hull -> IO Hull #

poke :: Ptr Hull -> Hull -> IO () #

Show Hull Source # 
Instance details

Defined in Box2D.Types

Methods

showsPrec :: Int -> Hull -> ShowS #

show :: Hull -> String #

showList :: [Hull] -> ShowS #

Eq Hull Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Hull -> Hull -> Bool #

(/=) :: Hull -> Hull -> Bool #

maxPolygonVertices :: Int Source #

The maximum number of vertices on a convex polygon (B2_MAX_POLYGON_VERTICES). Polygon and Hull reserve this many slots regardless of their count.

Definitions

data WorldDef Source #

World creation definition. Initialise with defaultWorldDef.

Instances

Instances details
Storable WorldDef Source # 
Instance details

Defined in Box2D.Types

Show WorldDef Source # 
Instance details

Defined in Box2D.Types

Eq WorldDef Source # 
Instance details

Defined in Box2D.Types

data EnqueueTaskCallback Source #

Phantom tags for the task-system callbacks stored on WorldDef. These typedefs never appear in API signatures, so Box2D.Tags carries no tag for them; produce values with withThreadPoolTaskSystem.

data ShapeDef Source #

Shape creation definition. Initialise with defaultShapeDef.

Constructors

ShapeDef 

Fields

Instances

Instances details
Storable ShapeDef Source # 
Instance details

Defined in Box2D.Types

Show ShapeDef Source # 
Instance details

Defined in Box2D.Types

Eq ShapeDef Source # 
Instance details

Defined in Box2D.Types

data ChainDef Source #

Chain (static terrain) definition. Initialise with defaultChainDef, then point chainDefPoints at a pinned/withArray array that stays alive across Box2D.Chain.create.

Instances

Instances details
Storable ChainDef Source # 
Instance details

Defined in Box2D.Types

Show ChainDef Source # 
Instance details

Defined in Box2D.Types

Eq ChainDef Source # 
Instance details

Defined in Box2D.Types

defaultChainDef :: IO ChainDef Source #

A fully-initialised chain definition (carries the internal cookie).

defaultExplosionDef :: IO ExplosionDef Source #

A fully-initialised explosion definition.

Queries and casts

data QueryFilter Source #

Filter for world queries: which shape categories to accept.

defaultQueryFilter :: IO QueryFilter Source #

A fully-initialised query filter (accept everything).

data MassData Source #

The mass, centroid and rotational inertia of a shape or body.

Instances

Instances details
Storable MassData Source # 
Instance details

Defined in Box2D.Types

Show MassData Source # 
Instance details

Defined in Box2D.Types

Eq MassData Source # 
Instance details

Defined in Box2D.Types

data RayCastInput Source #

Low-level ray-cast input in the local frame of the target shape.

data CastOutput Source #

Low-level ray or shape-cast output, in the frame of the input. A zero fraction and normal signal initial overlap.

Instances

Instances details
Storable CastOutput Source # 
Instance details

Defined in Box2D.Types

Show CastOutput Source # 
Instance details

Defined in Box2D.Types

Eq CastOutput Source # 
Instance details

Defined in Box2D.Types

type WorldCastOutput = CastOutput Source #

World-space cast output. In single-precision builds (the default) this is the same struct as CastOutput.

data RayResult Source #

The closest hit of a world ray cast (castRayClosest).

Instances

Instances details
Storable RayResult Source # 
Instance details

Defined in Box2D.Types

Show RayResult Source # 
Instance details

Defined in Box2D.Types

Eq RayResult Source # 
Instance details

Defined in Box2D.Types

data TreeStats Source #

Broad-phase traversal counters for a query. Diagnostic.

Instances

Instances details
Storable TreeStats Source # 
Instance details

Defined in Box2D.Types

Show TreeStats Source # 
Instance details

Defined in Box2D.Types

Eq TreeStats Source # 
Instance details

Defined in Box2D.Types

data Sweep Source #

The motion of a body between two configurations, for TOI computation.

Constructors

Sweep 

Instances

Instances details
Storable Sweep Source # 
Instance details

Defined in Box2D.Types

Methods

sizeOf :: Sweep -> Int #

alignment :: Sweep -> Int #

peekElemOff :: Ptr Sweep -> Int -> IO Sweep #

pokeElemOff :: Ptr Sweep -> Int -> Sweep -> IO () #

peekByteOff :: Ptr b -> Int -> IO Sweep #

pokeByteOff :: Ptr b -> Int -> Sweep -> IO () #

peek :: Ptr Sweep -> IO Sweep #

poke :: Ptr Sweep -> Sweep -> IO () #

Show Sweep Source # 
Instance details

Defined in Box2D.Types

Methods

showsPrec :: Int -> Sweep -> ShowS #

show :: Sweep -> String #

showList :: [Sweep] -> ShowS #

Eq Sweep Source # 
Instance details

Defined in Box2D.Types

Methods

(==) :: Sweep -> Sweep -> Bool #

(/=) :: Sweep -> Sweep -> Bool #

data PlaneResult Source #

One collision plane from collideMover, relative to the query origin. Ignore planes whose planeResultHit is 0.

dynamicTreeByteCount :: Int Source #

The size of the (opaque) b2DynamicTree struct, for allocating one to initialise with create.

Events

data BodyEvents Source #

Body events buffer: a C-owned array of BodyMoveEvent valid until the next step. Marshalled to a list by Box2D.Events.

Instances

Instances details
Storable BodyEvents Source # 
Instance details

Defined in Box2D.Types

Show BodyEvents Source # 
Instance details

Defined in Box2D.Types

Eq BodyEvents Source # 
Instance details

Defined in Box2D.Types

data BodyMoveEvent Source #

A body move event: the new transform of a body that moved this step. Enabled per body via bodyDefIsAwake / motion; read after step and before the next step (see Box2D.Events).

data SensorEvents Source #

Sensor events buffer: C-owned begin/end arrays valid until the next step. Marshalled to lists by Box2D.Events.

data JointEvents Source #

Joint events buffer: a C-owned array of JointEvent valid until the next step. Marshalled to a list by Box2D.Events.

data JointEvent Source #

A joint exceeded its force/torque event threshold this step.

Instances

Instances details
Storable JointEvent Source # 
Instance details

Defined in Box2D.Types

Show JointEvent Source # 
Instance details

Defined in Box2D.Types

Eq JointEvent Source # 
Instance details

Defined in Box2D.Types

Default definitions

defaultWorldDef :: IO WorldDef Source #

A fully-initialised world definition.

defaultBodyDef :: IO BodyDef Source #

A fully-initialised body definition.

defaultShapeDef :: IO ShapeDef Source #

A fully-initialised shape definition.

defaultFilter :: IO Filter Source #

A fully-initialised collision filter.

defaultSurfaceMaterial :: IO SurfaceMaterial Source #

A fully-initialised surface material.

Joint definitions

data DistanceJointDef Source #

Distance joint definition. Initialise with defaultDistanceJointDef.

defaultDistanceJointDef :: IO DistanceJointDef Source #

A fully-initialised DistanceJointDef.

defaultMotorJointDef :: IO MotorJointDef Source #

A fully-initialised MotorJointDef.

data PrismaticJointDef Source #

Prismatic joint definition. Initialise with defaultPrismaticJointDef.

defaultPrismaticJointDef :: IO PrismaticJointDef Source #

A fully-initialised PrismaticJointDef.

data RevoluteJointDef Source #

Revolute joint definition. Initialise with defaultRevoluteJointDef.

defaultRevoluteJointDef :: IO RevoluteJointDef Source #

A fully-initialised RevoluteJointDef.

defaultWeldJointDef :: IO WeldJointDef Source #

A fully-initialised WeldJointDef.

defaultWheelJointDef :: IO WheelJointDef Source #

A fully-initialised WheelJointDef.

defaultFilterJointDef :: IO FilterJointDef Source #

A fully-initialised FilterJointDef.