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 
30 
31 namespace playrho {
32 
41 class StepConf
42 {
43 public:
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 
84  {
85  invTime = value;
86  time = (value != 0_Hz)? Time{Real{1} / value}: 0_s;
87  return *this;
88  }
89 
95 
101 
107 
112 
120  Real regResolutionRate = Real{2} / 10; // aka 0.2.
121 
130 
133 
141  Real toiResolutionRate = Real{75} / 100; // aka .75
142 
151 
154 
160 
168 
174 
189 
213 
219 
223 
227 
231 
234 
242 
249 
254 
264 
270 
280 
284 
288 
292 
300 
304  bool doWarmStart = true;
305 
313  bool doToi = true;
314 
316  bool doBlocksolve = true;
317 
318 private:
321  Time time = DefaultStepTime;
322 
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