box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
constants.h File Reference
#include "user_constants.h"
Include dependency graph for constants.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  b2Version
 

Macros

#define b2_lengthUnitsPerMeter   1.0f
 
#define b2_pi   3.14159265359f
 https://en.wikipedia.org/wiki/Pi
 
#define b2_aabbMargin   (0.1f * b2_lengthUnitsPerMeter)
 
#define b2_linearSlop   (0.005f * b2_lengthUnitsPerMeter)
 
#define b2_angularSlop   (2.0f / 180.0f * b2_pi)
 
#define b2_maxPolygonVertices   8
 
#define b2_maxWorlds   32
 Maximum number of simultaneous worlds that can be allocated.
 
#define b2_maxTranslation   (4.0f * b2_lengthUnitsPerMeter)
 
#define b2_maxRotation   (0.5f * b2_pi)
 
#define b2_speculativeDistance   (4.0f * b2_linearSlop)
 
#define b2_timeToSleep   0.5f
 The time that a body must be still before it will go to sleep. In seconds.
 
#define b2_linearSleepTolerance   (0.01f * b2_lengthUnitsPerMeter)
 A body cannot sleep if its linear velocity is above this tolerance. Meters per second.
 
#define b2_angularSleepTolerance   (2.0f / 180.0f * b2_pi)
 A body cannot sleep if its angular velocity is above this tolerance. Radians per second.
 
#define b2_huge   (100000.0f * b2_lengthUnitsPerMeter)
 
#define b2_maxWorkers   64
 Maximum parallel workers. Used to size some static arrays.
 
#define b2_graphColorCount   12
 Solver graph coloring.
 

Detailed Description

Constants used by box2d. box2d uses meters-kilograms-seconds (MKS) units. Angles are always in radians unless degrees are indicated. Some values can be overridden by using a compiler definition. Other values cannot be modified without causing stability and/or performance problems. Although most of these are not user configurable, it can be interesting for a user to see these to understand the tuning values Box2D uses.


Data Structure Documentation

◆ b2Version

struct b2Version
Data Fields
int major < significant changes

incremental changes

int minor bug fixes
int revision

Macro Definition Documentation

◆ b2_aabbMargin

#define b2_aabbMargin   (0.1f * b2_lengthUnitsPerMeter)

This is used to fatten AABBs in the dynamic tree. This allows proxies to move by a small amount without triggering a tree adjustment. This is in meters.

Warning
modifying this can have a significant impact on performance

◆ b2_angularSlop

#define b2_angularSlop   (2.0f / 180.0f * b2_pi)

A small angle used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant.

Warning
modifying this can have a significant impact on stability

◆ b2_huge

#define b2_huge   (100000.0f * b2_lengthUnitsPerMeter)

Used to detect bad values. Positions greater than about 16km will have precision problems, so 100km as a limit should be fine in all cases.

◆ b2_lengthUnitsPerMeter

#define b2_lengthUnitsPerMeter   1.0f

box2d bases all length units on meters, but you may need different units for your game. You can override this value to use different units.

◆ b2_linearSlop

#define b2_linearSlop   (0.005f * b2_lengthUnitsPerMeter)

A small length used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant. In meters.

Warning
modifying this can have a significant impact on stability

◆ b2_maxPolygonVertices

#define b2_maxPolygonVertices   8

The maximum number of vertices on a convex polygon. Changing this affects performance even if you don't use more vertices.

◆ b2_maxRotation

#define b2_maxRotation   (0.5f * b2_pi)

The maximum angular velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.

Warning
modifying this can have a significant impact on stability

◆ b2_maxTranslation

#define b2_maxTranslation   (4.0f * b2_lengthUnitsPerMeter)

The maximum linear translation of a body per step. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this. Meters.

Warning
modifying this can have a significant impact on stability

◆ b2_speculativeDistance

#define b2_speculativeDistance   (4.0f * b2_linearSlop)
Warning
modifying this can have a significant impact on performance and stability