Box2D 3.1.0
A 2D physics engine for games
|
World event types. More...
Data Structures | |
struct | b2SensorBeginTouchEvent |
A begin touch event is generated when a shape starts to overlap a sensor shape. More... | |
struct | b2SensorEndTouchEvent |
An end touch event is generated when a shape stops overlapping a sensor shape. More... | |
struct | b2SensorEvents |
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays after the time step is complete. More... | |
struct | b2ContactBeginTouchEvent |
A begin touch event is generated when two shapes begin touching. More... | |
struct | b2ContactEndTouchEvent |
An end touch event is generated when two shapes stop touching. More... | |
struct | b2ContactHitEvent |
A hit touch event is generated when two shapes collide with a speed faster than the hit speed threshold. More... | |
struct | b2ContactEvents |
Contact events are buffered in the Box2D world and are available as event arrays after the time step is complete. More... | |
struct | b2BodyMoveEvent |
Body move events triggered when a body moves. More... | |
struct | b2BodyEvents |
Body events are buffered in the Box2D world and are available as event arrays after the time step is complete. More... | |
struct | b2ContactData |
The contact data for two shapes. More... | |
World event types.
Events are used to collect events that occur during the world time step. These events are then available to query after the time step is complete. This is preferable to callbacks because Box2D uses multithreaded simulation.
Also when events occur in the simulation step it may be problematic to modify the world, which is often what applications want to do when events occur.
With event arrays, you can scan the events in a loop and modify the world. However, you need to be careful that some event data may become invalid. There are several samples that show how to do this safely.
struct b2SensorBeginTouchEvent |
struct b2SensorEndTouchEvent |
struct b2SensorEvents |
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays after the time step is complete.
Note: these may become invalid if bodies and/or shapes are destroyed
Data Fields | ||
---|---|---|
int32_t | beginCount | The number of begin touch events. |
b2SensorBeginTouchEvent * | beginEvents | Array of sensor begin touch events. |
int32_t | endCount | The number of end touch events. |
b2SensorEndTouchEvent * | endEvents | Array of sensor end touch events. |
struct b2ContactBeginTouchEvent |
struct b2ContactEndTouchEvent |
struct b2ContactHitEvent |
A hit touch event is generated when two shapes collide with a speed faster than the hit speed threshold.
Data Fields | ||
---|---|---|
float | approachSpeed | The speed the shapes are approaching. Always positive. Typically in meters per second. |
b2Vec2 | normal | Normal vector pointing from shape A to shape B. |
b2Vec2 | point | Point where the shapes hit. |
b2ShapeId | shapeIdA | Id of the first shape. |
b2ShapeId | shapeIdB | Id of the second shape. |
struct b2ContactEvents |
Contact events are buffered in the Box2D world and are available as event arrays after the time step is complete.
Note: these may become invalid if bodies and/or shapes are destroyed
Data Fields | ||
---|---|---|
int32_t | beginCount | Number of begin touch events. |
b2ContactBeginTouchEvent * | beginEvents | Array of begin touch events. |
int32_t | endCount | Number of end touch events. |
b2ContactEndTouchEvent * | endEvents | Array of end touch events. |
int32_t | hitCount | Number of hit events. |
b2ContactHitEvent * | hitEvents | Array of hit events. |
struct b2BodyMoveEvent |
Body move events triggered when a body moves.
Triggered when a body moves due to simulation. Not reported for bodies moved by the user. This also has a flag to indicate that the body went to sleep so the application can also sleep that actor/entity/object associated with the body. On the other hand if the flag does not indicate the body went to sleep then the application can treat the actor/entity/object associated with the body as awake. This is an efficient way for an application to update game object transforms rather than calling functions such as b2Body_GetTransform() because this data is delivered as a contiguous array and it is only populated with bodies that have moved.
Data Fields | ||
---|---|---|
b2BodyId | bodyId | |
bool | fellAsleep | |
b2Transform | transform | |
void * | userData |
struct b2BodyEvents |
Body events are buffered in the Box2D world and are available as event arrays after the time step is complete.
Note: this data becomes invalid if bodies are destroyed
Data Fields | ||
---|---|---|
int32_t | moveCount | Number of move events. |
b2BodyMoveEvent * | moveEvents | Array of move events. |
struct b2ContactData |
The contact data for two shapes.
By convention the manifold normal points from shape A to shape B.
Data Fields | ||
---|---|---|
b2Manifold | manifold | |
b2ShapeId | shapeIdA | |
b2ShapeId | shapeIdB |