Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Dynamics
Joints
FrictionJoint.hpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2007 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_JOINTS_FRICTIONJOINT_HPP
23
#define PLAYRHO_DYNAMICS_JOINTS_FRICTIONJOINT_HPP
24
25
#include <
PlayRho/Dynamics/Joints/Joint.hpp
>
26
#include <
PlayRho/Dynamics/Joints/FrictionJointConf.hpp
>
27
#include <
PlayRho/Common/BoundedValue.hpp
>
28
29
namespace
playrho
{
30
namespace
d2 {
31
39
class
FrictionJoint
:
public
Joint
40
{
41
public
:
42
47
FrictionJoint
(
const
FrictionJointConf
& def);
48
49
void
Accept
(
JointVisitor
& visitor)
const override
;
50
void
Accept
(
JointVisitor
& visitor)
override
;
51
52
Length2
GetAnchorA
()
const override
;
53
Length2
GetAnchorB
()
const override
;
54
55
Momentum2
GetLinearReaction
()
const override
;
56
AngularMomentum
GetAngularReaction
()
const override
;
57
59
Length2
GetLocalAnchorA
()
const
{
return
m_localAnchorA; }
60
62
Length2
GetLocalAnchorB
()
const
{
return
m_localAnchorB; }
63
65
void
SetMaxForce
(
NonNegative<Force>
force);
66
68
NonNegative<Force>
GetMaxForce
()
const
;
69
71
void
SetMaxTorque
(
NonNegative<Torque>
torque);
72
74
NonNegative<Torque>
GetMaxTorque
()
const
;
75
76
private
:
77
78
void
InitVelocityConstraints(
BodyConstraintsMap
& bodies,
const
StepConf
& step,
79
const
ConstraintSolverConf
& conf)
override
;
80
bool
SolveVelocityConstraints(
BodyConstraintsMap
& bodies,
const
StepConf
& step)
override
;
81
bool
SolvePositionConstraints(
BodyConstraintsMap
& bodies,
82
const
ConstraintSolverConf
& conf)
const override
;
83
84
Length2
m_localAnchorA;
85
Length2
m_localAnchorB;
86
NonNegative<Force>
m_maxForce =
NonNegative<Force>
{0_N};
87
NonNegative<Torque>
m_maxTorque =
NonNegative<Torque>
{0_Nm};
88
89
// Solver shared data - data saved & updated over multiple InitVelocityConstraints calls.
90
Momentum2
m_linearImpulse =
Momentum2
{};
91
AngularMomentum
m_angularImpulse =
AngularMomentum
{0};
92
93
// Solver temp
94
Length2
m_rA;
95
Length2
m_rB;
96
Mass22
m_linearMass;
97
RotInertia
m_angularMass;
98
};
99
100
inline
void
FrictionJoint::SetMaxForce
(
NonNegative<Force>
force)
101
{
102
m_maxForce = force;
103
}
104
105
inline
NonNegative<Force>
FrictionJoint::GetMaxForce
()
const
106
{
107
return
m_maxForce;
108
}
109
110
inline
void
FrictionJoint::SetMaxTorque
(
NonNegative<Torque>
torque)
111
{
112
m_maxTorque = torque;
113
}
114
115
inline
NonNegative<Torque>
FrictionJoint::GetMaxTorque
()
const
116
{
117
return
m_maxTorque;
118
}
119
120
}
// namespace d2
121
}
// namespace playrho
122
123
#endif // PLAYRHO_DYNAMICS_JOINTS_FRICTIONJOINT_HPP