Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Dynamics
StepConf.hpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
*
9
* Permission is granted to anyone to use this software for any purpose,
10
* including commercial applications, and to alter it and redistribute it
11
* freely, subject to the following restrictions:
12
*
13
* 1. The origin of this software must not be misrepresented; you must not
14
* claim that you wrote the original software. If you use this software
15
* in a product, an acknowledgment in the product documentation would be
16
* appreciated but is not required.
17
* 2. Altered source versions must be plainly marked as such, and must not be
18
* misrepresented as being the original software.
19
* 3. This notice may not be removed or altered from any source distribution.
20
*/
21
22
#ifndef PLAYRHO_DYNAMICS_STEPCONF_HPP
23
#define PLAYRHO_DYNAMICS_STEPCONF_HPP
24
27
28
#include <
PlayRho/Common/Settings.hpp
>
29
#include <
PlayRho/Common/BoundedValue.hpp
>
30
31
namespace
playrho
{
32
41
class
StepConf
42
{
43
public
:
47
using
iteration_type
=
TimestepIters
;
48
50
static
PLAYRHO_CONSTEXPR
const
auto
InvalidIteration
=
static_cast<
iteration_type
>
(-1);
51
55
Time
GetTime
() const noexcept {
return
time; }
56
60
Frequency
GetInvTime
() const noexcept {
return
invTime; }
61
69
PLAYRHO_CONSTEXPR
inline
StepConf
&
SetTime
(
Time
value) noexcept
70
{
71
time = value;
72
invTime = (value != 0_s)?
Real
{1} / value: 0_Hz;
73
return
*
this
;
74
}
75
83
PLAYRHO_CONSTEXPR
inline
StepConf
&
SetInvTime
(
Frequency
value) noexcept
84
{
85
invTime = value;
86
time = (value != 0_Hz)?
Time
{
Real
{1} / value}: 0_s;
87
return
*
this
;
88
}
89
94
Real
dtRatio
= 1;
95
100
Time
minStillTimeToSleep
=
DefaultMinStillTimeToSleep
;
101
106
Positive<Length>
linearSlop
=
DefaultLinearSlop
;
107
111
Positive<Angle>
angularSlop
=
DefaultAngularSlop
;
112
120
Real
regResolutionRate
=
Real
{2} / 10;
// aka 0.2.
121
129
Length
regMinSeparation
= -
DefaultLinearSlop
*
Real
{3};
130
132
Momentum
regMinMomentum
=
DefaultRegMinMomentum
;
133
141
Real
toiResolutionRate
=
Real
{75} / 100;
// aka .75
142
150
Length
toiMinSeparation
= -
DefaultLinearSlop
*
Real
(1.5f);
151
153
Momentum
toiMinMomentum
=
DefaultToiMinMomentum
;
154
159
Length
targetDepth
=
DefaultLinearSlop
*
Real
{3};
160
167
NonNegative<Length>
tolerance
=
DefaultLinearSlop
/
Real
{4};
168
173
LinearVelocity
velocityThreshold
=
DefaultVelocityThreshold
;
174
188
Length
maxTranslation
=
DefaultMaxTranslation
;
189
212
Angle
maxRotation
=
DefaultMaxRotation
;
213
218
Length
maxLinearCorrection
=
DefaultMaxLinearCorrection
;
219
222
Angle
maxAngularCorrection
=
DefaultMaxAngularCorrection
;
223
226
LinearVelocity
linearSleepTolerance
=
DefaultLinearSleepTolerance
;
227
230
AngularVelocity
angularSleepTolerance
=
DefaultAngularSleepTolerance
;
231
233
Real
displaceMultiplier
=
DefaultDistanceMultiplier
;
234
241
Length
aabbExtension
=
DefaultAabbExtension
;
242
248
Real
maxCirclesRatio
=
DefaultCirclesRatio
;
249
253
iteration_type
regVelocityIterations
= 8;
254
263
iteration_type
regPositionIterations
= 3;
264
269
iteration_type
toiVelocityIterations
= 8;
270
279
iteration_type
toiPositionIterations
= 20;
280
283
iteration_type
maxToiRootIters
=
DefaultMaxToiRootIters
;
284
287
iteration_type
maxToiIters
=
DefaultMaxToiIters
;
288
291
iteration_type
maxDistanceIters
=
DefaultMaxDistanceIters
;
292
299
iteration_type
maxSubSteps
=
DefaultMaxSubSteps
;
300
304
bool
doWarmStart
=
true
;
305
313
bool
doToi
=
true
;
314
316
bool
doBlocksolve
=
true
;
317
318
private
:
321
Time
time =
DefaultStepTime
;
322
326
Frequency
invTime =
DefaultStepFrequency
;
327
};
328
331
inline
Length
GetMaxRegLinearCorrection
(
const
StepConf
& conf) noexcept
332
{
333
return
conf.maxLinearCorrection *
static_cast<
Real
>
(conf.regPositionIterations);
334
}
335
338
bool
IsMaxTranslationWithinTolerance
(
const
StepConf& conf) noexcept;
339
340
}
// namespace playrho
341
342
#endif // PLAYRHO_DYNAMICS_STEPCONF_HPP