types used by the Box2D API
More...
#include "box2d/color.h"
#include "box2d/constants.h"
#include "box2d/id.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
#define | B2_LITERAL(T) (T) |
| Used for C literals like (b2Vec2){1.0f, 2.0f} where C++ requires b2Vec2{1.0f, 2.0f}.
|
|
#define | B2_ZERO_INIT |
| Used for C zero initialization, such as b2Vec2 v = {0} where C++ requires b2Vec2 v = {}.
|
|
#define | B2_ARRAY_COUNT(A) (int)(sizeof(A) / sizeof(A[0])) |
| Returns the number of elements of an array.
|
|
#define | B2_MAYBE_UNUSED(x) ((void)(x)) |
| Used to prevent the compiler from warning about unused variables.
|
|
|
typedef void | b2TaskCallback(int32_t startIndex, int32_t endIndex, uint32_t threadIndex, void *taskContext) |
|
typedef void * | b2EnqueueTaskCallback(b2TaskCallback *task, int32_t itemCount, int32_t minRange, void *taskContext, void *userContext) |
|
typedef void | b2FinishTaskCallback(void *userTask, void *userContext) |
| Finishes a user task object that wraps a Box2D task.
|
|
|
enum | b2BodyType { b2_staticBody = 0
, b2_kinematicBody = 1
, b2_dynamicBody = 2
, b2_bodyTypeCount
} |
|
enum | b2ShapeType {
b2_capsuleShape
, b2_circleShape
, b2_polygonShape
, b2_segmentShape
,
b2_smoothSegmentShape
, b2_shapeTypeCount
} |
| Shape type.
|
|
types used by the Box2D API
Mostly definition structs
- See also
- http://www.box2d.org
◆ b2Vec2
A 2D vector This can be used to represent a point or free vector.
Data Fields |
float |
x |
coordinates |
float |
y |
|
◆ b2Rot
Data Fields |
float |
c |
|
float |
s |
Sine and cosine. |
◆ b2Transform
◆ b2Mat22
◆ b2AABB
Axis-aligned bounding box.
◆ b2RayCastInput
Low level ray-cast input data.
Data Fields |
float |
maxFraction |
|
b2Vec2 |
origin |
|
b2Vec2 |
translation |
|
◆ b2ShapeCastInput
Low level hape cast input in generic form.
◆ b2RayCastOutput
Low level ray-cast or shape-cast output data.
Data Fields |
float |
fraction |
|
bool |
hit |
|
int32_t |
iterations |
|
b2Vec2 |
normal |
|
b2Vec2 |
point |
|
◆ b2WorldDef
World definition used to create a simulation world. Must be initialized using b2DefaultWorldDef.
Data Fields |
int32_t |
bodyCapacity |
Capacity for bodies. This may not be exceeded. |
int32_t |
contactCapacity |
Capacity for contacts. This may not be exceeded. |
float |
contactDampingRatio |
Contact bounciness. Non-dimensional. |
float |
contactHertz |
Contact stiffness. Cycles per second. |
float |
contactPushoutVelocity |
This parameter controls how fast overlap is resolved and has units of meters per second. |
bool |
enableSleep |
Can bodies go to sleep to improve performance. |
b2EnqueueTaskCallback * |
enqueueTask |
|
b2FinishTaskCallback * |
finishTask |
|
b2Vec2 |
gravity |
Gravity vector. Box2D has no up-vector defined. |
int32_t |
jointCapacity |
Capacity for joints. |
float |
restitutionThreshold |
Restitution velocity threshold, usually in m/s. Collisions above this speed have restitution applied (will bounce).
|
int32_t |
shapeCapacity |
initial capacity for shapes |
int32_t |
stackAllocatorCapacity |
Stack allocator capacity. This controls how much space box2d reserves for per-frame calculations. Larger worlds require more space. b2Statistics can be used to determine a good capacity for your application.
|
void * |
userTaskContext |
|
uint32_t |
workerCount |
task system hookup |
◆ b2BodyDef
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction.
Data Fields |
float |
angle |
The world angle of the body in radians. |
float |
angularDamping |
Angular damping is use to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
|
float |
angularVelocity |
The angular velocity of the body. |
bool |
enableSleep |
Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.
|
bool |
fixedRotation |
Should this body be prevented from rotating? Useful for characters. |
float |
gravityScale |
Scale the gravity applied to this body. |
bool |
isAwake |
Is this body initially awake or sleeping? |
bool |
isEnabled |
Does this body start out enabled? |
float |
linearDamping |
Linear damping is use to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
|
b2Vec2 |
linearVelocity |
The linear velocity of the body's origin in world co-ordinates. |
b2Vec2 |
position |
The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes.
|
b2BodyType |
type |
The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one.
|
void * |
userData |
Use this to store application specific body data. |
◆ b2Filter
This holds contact filtering data.
Data Fields |
uint32_t |
categoryBits |
The collision category bits. Normally you would just set one bit. |
int32_t |
groupIndex |
Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). Zero means no collision group. Non-zero group filtering always wins against the mask bits.
|
uint32_t |
maskBits |
The collision mask bits. This states the categories that this shape would accept for collision.
|
◆ b2QueryFilter
This holds contact filtering data.
Data Fields |
uint32_t |
categoryBits |
The collision category bits. Normally you would just set one bit. |
uint32_t |
maskBits |
The collision mask bits. This states the categories that this shape would accept for collision.
|
◆ b2ShapeDef
Data Fields |
float |
density |
The density, usually in kg/m^2. |
bool |
enableContactEvents |
Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. |
bool |
enablePreSolveEvents |
Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive and must be carefully handled due to multi-threading. Ignored for sensors.
|
bool |
enableSensorEvents |
Enable sensor events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. |
b2Filter |
filter |
Contact filtering data. |
float |
friction |
The friction coefficient, usually in the range [0,1]. |
bool |
isSensor |
A sensor shape collects contact information but never generates a collision response. |
float |
restitution |
The restitution (bounce) usually in the range [0,1]. |
void * |
userData |
Use this to store application specific shape data. |
◆ b2ChainDef
Used to create a chain of edges. This is designed to eliminate ghost collisions with some limitations.
- DO NOT use chain shapes unless you understand the limitations. This is an advanced feature!
- chains are one-sided
- chains have no mass and should be used on static bodies
- the front side of the chain points the right of the point sequence
- chains are either a loop or open
- a chain must have at least 4 points
- the distance between any two points must be greater than b2_linearSlop
- a chain shape should not self intersect (this is not validated)
- an open chain shape has NO COLLISION on the first and final edge
- you may overlap two open chains on their first three and/or last three points to get smooth collision
- a chain shape creates multiple hidden shapes on the body
Data Fields |
int32_t |
count |
The point count, must be 4 or more. |
b2Filter |
filter |
Contact filtering data. |
float |
friction |
The friction coefficient, usually in the range [0,1]. |
bool |
loop |
Indicates a closed chain formed by connecting the first and last points. |
const b2Vec2 * |
points |
An array of at least 4 points. These are cloned and may be temporary. |
float |
restitution |
The restitution (elasticity) usually in the range [0,1]. |
void * |
userData |
Use this to store application specific shape data. |
◆ B2_ZERO_INIT
Value:
Used for C zero initialization, such as b2Vec2 v = {0} where C++ requires b2Vec2 v = {}.
◆ b2EnqueueTaskCallback
typedef void * b2EnqueueTaskCallback(b2TaskCallback *task, int32_t itemCount, int32_t minRange, void *taskContext, void *userContext) |
These functions can be provided to Box2D to invoke a task system. These are designed to work well with enkiTS. Returns a pointer to the user's task object. May be nullptr.
◆ b2TaskCallback
typedef void b2TaskCallback(int32_t startIndex, int32_t endIndex, uint32_t threadIndex, void *taskContext) |
Task interface This is prototype for a Box2D task. Your task system is expected to invoke the Box2D task with these arguments. The task spans a range of the parallel-for: [startIndex, endIndex) The thread index must correctly identify each thread in the user thread pool, expected in [0, workerCount) The task context is the context pointer sent from Box2D when it is enqueued.
◆ b2BodyType
The body type. static: zero mass, zero velocity, may be manually moved kinematic: zero mass, non-zero velocity set by user, moved by solver dynamic: positive mass, non-zero velocity determined by forces, moved by solver