-
Notifications
You must be signed in to change notification settings - Fork 48
/
CommonB2Settings.go
101 lines (75 loc) · 3.45 KB
/
CommonB2Settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package box2d
import "math"
// @port(OK)
const B2DEBUG = false
// @port(OK)
func B2Assert(a bool) {
if !a {
panic("B2Assert")
}
}
const B2_maxFloat = math.MaxFloat64
const B2_epsilon = math.SmallestNonzeroFloat64
const B2_pi = math.Pi
/// @file
/// Global tuning constants based on meters-kilograms-seconds (MKS) units.
///
// Collision
/// The maximum number of contact points between two convex shapes. Do
/// not change this value.
const B2_maxManifoldPoints = 2
/// The maximum number of vertices on a convex polygon. You cannot increase
/// this too much because b2BlockAllocator has a maximum object size.
const B2_maxPolygonVertices = 8
/// 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.
const B2_aabbExtension = 0.1
/// This is used to fatten AABBs in the dynamic tree. This is used to predict
/// the future position based on the current displacement.
/// This is a dimensionless multiplier.
const B2_aabbMultiplier = 2.0
/// A small length used as a collision and constraint tolerance. Usually it is
/// chosen to be numerically significant, but visually insignificant.
const B2_linearSlop = 0.005
/// A small angle used as a collision and constraint tolerance. Usually it is
/// chosen to be numerically significant, but visually insignificant.
const B2_angularSlop = (2.0 / 180.0 * B2_pi)
/// The radius of the polygon/edge shape skin. This should not be modified. Making
/// this smaller means polygons will have an insufficient buffer for continuous collision.
/// Making it larger may create artifacts for vertex collision.
const B2_polygonRadius = (2.0 * B2_linearSlop)
/// Maximum number of sub-steps per contact in continuous physics simulation.
const B2_maxSubSteps = 8
// Dynamics
/// Maximum number of contacts to be handled to solve a TOI impact.
const B2_maxTOIContacts = 32
/// A velocity threshold for elastic collisions. Any collision with a relative linear
/// velocity below this threshold will be treated as inelastic.
const B2_velocityThreshold = 1.0
/// The maximum linear position correction used when solving constraints. This helps to
/// prevent overshoot.
const B2_maxLinearCorrection = 0.2
/// The maximum angular position correction used when solving constraints. This helps to
/// prevent overshoot.
const B2_maxAngularCorrection = (8.0 / 180.0 * B2_pi)
/// The maximum linear velocity of a body. This limit is very large and is used
/// to prevent numerical problems. You shouldn't need to adjust this.
const B2_maxTranslation = 2.0
const B2_maxTranslationSquared = (B2_maxTranslation * B2_maxTranslation)
/// 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.
const B2_maxRotation = (0.5 * B2_pi)
const B2_maxRotationSquared = (B2_maxRotation * B2_maxRotation)
/// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
/// that overlap is removed in one time step. However using values close to 1 often lead
/// to overshoot.
const B2_baumgarte = 0.2
const B2_toiBaugarte = 0.75
// Sleep
/// The time that a body must be still before it will go to sleep.
const B2_timeToSleep = 0.5
/// A body cannot sleep if its linear velocity is above this tolerance.
const B2_linearSleepTolerance = 0.01
/// A body cannot sleep if its angular velocity is above this tolerance.
const B2_angularSleepTolerance = (2.0 / 180.0 * B2_pi)