Box3D
0.1.0
A 3D physics engine for games
Loading...
Searching...
No Matches
constants.h
1
// SPDX-FileCopyrightText: 2025 Erin Catto
2
// SPDX-License-Identifier: MIT
3
4
#pragma once
5
6
#include "base.h"
7
12
B3_API
void
b3SetLengthUnitsPerMeter(
float
lengthUnits );
13
15
B3_API
float
b3GetLengthUnitsPerMeter(
void
);
16
18
B3_API
void
b3SetStallThreshold(
float
seconds );
19
21
B3_API
float
b3GetStallThreshold(
void
);
22
23
// Used to detect bad values. In float mode positions greater than about 16km have precision
24
// problems, so 100km is a safe limit. Large world mode keeps coordinates accurate much farther
25
// from the origin, so the sanity limit widens to keep valid far-field positions from tripping it.
26
#if defined( BOX3D_DOUBLE_PRECISION )
27
#define B3_HUGE ( 1.0e9f * b3GetLengthUnitsPerMeter() )
28
#else
29
#define B3_HUGE ( 1.0e5f * b3GetLengthUnitsPerMeter() )
30
#endif
31
33
#define B3_MAX_WORKERS 32
34
39
#define B3_MAX_TASKS 256
40
41
// Maximum number of colors in the constraint graph. Constraints that cannot
42
// find a color are added to the overflow set which are solved single-threaded.
43
// The compound barrel benchmark has minor overflow with 24 colors
44
#define B3_GRAPH_COLOR_COUNT 24
45
46
// Number of contact point buckets for counting the number of contact points per
47
// shape contact pair. This is just for reporting and doesn't affect simulation.
48
#define B3_CONTACT_MANIFOLD_COUNT_BUCKETS 8
49
50
// A small length used as a collision and constraint tolerance. Usually it is
51
// chosen to be numerically significant, but visually insignificant. In meters.
52
// @warning modifying this can have a significant impact on stability
53
#define B3_LINEAR_SLOP ( 0.005f * b3GetLengthUnitsPerMeter() )
54
55
#define B3_MIN_CAPSULE_LENGTH ( B3_LINEAR_SLOP )
56
60
#define B3_OVERLAP_SLOP ( 0.1f * B3_LINEAR_SLOP )
61
63
#ifndef B3_MAX_WORLDS
64
#define B3_MAX_WORLDS 128
65
#endif
66
70
#define B3_MAX_ROTATION ( 0.25f * B3_PI )
71
73
#define B3_SPECULATIVE_DISTANCE ( 4.0f * B3_LINEAR_SLOP )
74
79
#define B3_MESH_REST_OFFSET ( 1.0f * B3_LINEAR_SLOP )
80
82
#define B3_CONTACT_RECYCLE_DISTANCE ( 10.0f * B3_LINEAR_SLOP )
83
86
#define B3_CONTACT_RECYCLE_ANGULAR_DISTANCE ( 0.99240388f )
87
91
#define B3_MAX_AABB_MARGIN ( 0.05f * b3GetLengthUnitsPerMeter() )
92
95
#define B3_AABB_MARGIN_FRACTION 0.125f
96
98
#define B3_TIME_TO_SLEEP 0.5f
99
102
#ifndef B3_BODY_NAME_LENGTH
103
#define B3_BODY_NAME_LENGTH 18
104
#endif
105
109
#ifndef B3_SHAPE_NAME_LENGTH
110
#define B3_SHAPE_NAME_LENGTH 18
111
#endif
112
114
#define B3_MAX_MANIFOLD_POINTS 4
115
117
#define B3_MAX_SHAPE_CAST_POINTS 64
118
120
#define B3_SHAPE_POWER 22
121
#define B3_CHILD_POWER ( 64 - 2 * B3_SHAPE_POWER )
122
#define B3_MAX_SHAPES ( 1 << B3_SHAPE_POWER )
123
#define B3_MAX_CHILD_SHAPES ( 1 << B3_CHILD_POWER )
include
box3d
constants.h
Generated by
1.17.0