ContactSolver.hpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright (c) 2006-2009 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  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  * 1. The origin of this software must not be misrepresented; you must not
12  * claim that you wrote the original software. If you use this software
13  * in a product, an acknowledgment in the product documentation would be
14  * appreciated but is not required.
15  * 2. Altered source versions must be plainly marked as such, and must not be
16  * misrepresented as being the original software.
17  * 3. This notice may not be removed or altered from any source distribution.
18  */
19 
20 #ifndef PLAYRHO_DYNAMICS_CONTACTS_CONTACTSOLVER_HPP
21 #define PLAYRHO_DYNAMICS_CONTACTS_CONTACTSOLVER_HPP
22 
23 #include <PlayRho/Common/Math.hpp>
24 
25 namespace playrho {
26 
27 class StepConf;
28 
29 namespace d2 {
30 
31 class VelocityConstraint;
32 class PositionConstraint;
33 class BodyConstraint;
34 
37 {
41 };
42 
45 {
46  return PositionSolution{
47  lhs.pos_a + rhs.pos_a,
48  lhs.pos_b + rhs.pos_b,
50  };
51 }
52 
55 {
56  return PositionSolution{
57  lhs.pos_a - rhs.pos_a,
58  lhs.pos_b - rhs.pos_b,
60  };
61 }
62 
63 } // namespace d2
64 
70 {
73 
75  ConstraintSolverConf& UseLinearSlop(Length value) noexcept;
76 
78  ConstraintSolverConf& UseAngularSlop(Angle value) noexcept;
79 
82 
85 
95 
100 
104 
110 
116 };
117 
119 {
120  resolutionRate = value;
121  return *this;
122 }
123 
125 {
126  linearSlop = value;
127  return *this;
128 }
129 
131 {
132  angularSlop = value;
133  return *this;
134 }
135 
137 {
138  maxLinearCorrection = value;
139  return *this;
140 }
141 
143 {
144  maxAngularCorrection = value;
145  return *this;
146 }
147 
150 {
152 }
153 
156 {
157  // For solving TOI events, use a faster/higher resolution rate than normally used.
159 }
160 
162 ConstraintSolverConf GetRegConstraintSolverConf(const StepConf& conf) noexcept;
163 
165 ConstraintSolverConf GetToiConstraintSolverConf(const StepConf& conf) noexcept;
166 
167 namespace GaussSeidel {
168 
184 Momentum SolveVelocityConstraint(d2::VelocityConstraint& vc);
185 
193 d2::PositionSolution SolvePositionConstraint(const d2::PositionConstraint& pc,
194  const bool moveA, const bool moveB,
195  ConstraintSolverConf conf);
196 
197 } // namespace GaussSidel
198 
199 } // namespace playrho
200 
201 #endif // PLAYRHO_DYNAMICS_CONTACTS_CONTACTSOLVER_HPP
202