externals
box2d
include
box2d
b2_friction_joint.h
Go to the documentation of this file.
1
// MIT License
2
3
// Copyright (c) 2019 Erin Catto
4
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef B2_FRICTION_JOINT_H
24
#define B2_FRICTION_JOINT_H
25
26
#include "
b2_api.h
"
27
#include "
b2_joint.h
"
28
30
struct
B2_API
b2FrictionJointDef
:
public
b2JointDef
31
{
32
b2FrictionJointDef
()
33
{
34
type
=
e_frictionJoint
;
35
localAnchorA.SetZero();
36
localAnchorB.SetZero();
37
maxForce = 0.0f;
38
maxTorque = 0.0f;
39
}
40
43
void
Initialize
(
b2Body
* bodyA,
b2Body
* bodyB,
const
b2Vec2
& anchor);
44
46
b2Vec2
localAnchorA
;
47
49
b2Vec2
localAnchorB
;
50
52
float
maxForce
;
53
55
float
maxTorque
;
56
};
57
60
class
B2_API
b2FrictionJoint
:
public
b2Joint
61
{
62
public
:
63
b2Vec2
GetAnchorA
()
const override
;
64
b2Vec2
GetAnchorB
()
const override
;
65
66
b2Vec2
GetReactionForce
(
float
inv_dt)
const override
;
67
float
GetReactionTorque
(
float
inv_dt)
const override
;
68
70
const
b2Vec2
&
GetLocalAnchorA
()
const
{
return
m_localAnchorA; }
71
73
const
b2Vec2
&
GetLocalAnchorB
()
const
{
return
m_localAnchorB; }
74
76
void
SetMaxForce(
float
force);
77
79
float
GetMaxForce()
const
;
80
82
void
SetMaxTorque(
float
torque);
83
85
float
GetMaxTorque()
const
;
86
88
void
Dump
()
override
;
89
90
protected
:
91
92
friend
class
b2Joint
;
93
94
b2FrictionJoint
(
const
b2FrictionJointDef
* def);
95
96
void
InitVelocityConstraints
(
const
b2SolverData
& data)
override
;
97
void
SolveVelocityConstraints
(
const
b2SolverData
& data)
override
;
98
bool
SolvePositionConstraints
(
const
b2SolverData
& data)
override
;
99
100
b2Vec2
m_localAnchorA
;
101
b2Vec2
m_localAnchorB
;
102
103
// Solver shared
104
b2Vec2
m_linearImpulse
;
105
float
m_angularImpulse
;
106
float
m_maxForce
;
107
float
m_maxTorque
;
108
109
// Solver temp
110
int32
m_indexA
;
111
int32
m_indexB
;
112
b2Vec2
m_rA
;
113
b2Vec2
m_rB
;
114
b2Vec2
m_localCenterA
;
115
b2Vec2
m_localCenterB
;
116
float
m_invMassA
;
117
float
m_invMassB
;
118
float
m_invIA
;
119
float
m_invIB
;
120
b2Mat22
m_linearMass
;
121
float
m_angularMass
;
122
};
123
124
#endif
b2FrictionJointDef::maxForce
float maxForce
The maximum friction force in N.
Definition:
b2_friction_joint.h:52
b2Joint::SolveVelocityConstraints
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2FrictionJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition:
b2_friction_joint.h:46
b2FrictionJointDef::b2FrictionJointDef
b2FrictionJointDef()
Definition:
b2_friction_joint.h:32
b2Joint::GetReactionForce
virtual b2Vec2 GetReactionForce(float inv_dt) const =0
Get the reaction force on bodyB at the joint anchor in Newtons.
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2_joint.h:72
B2_API
#define B2_API
Definition:
b2_api.h:49
b2FrictionJoint::m_rB
b2Vec2 m_rB
Definition:
b2_friction_joint.h:113
b2FrictionJoint::m_invMassB
float m_invMassB
Definition:
b2_friction_joint.h:117
e_frictionJoint
Definition:
b2_joint.h:46
b2FrictionJointDef::maxTorque
float maxTorque
The maximum friction torque in N-m.
Definition:
b2_friction_joint.h:55
b2FrictionJoint::m_maxTorque
float m_maxTorque
Definition:
b2_friction_joint.h:107
b2FrictionJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition:
b2_friction_joint.h:49
b2FrictionJoint
Definition:
b2_friction_joint.h:60
b2FrictionJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2_friction_joint.h:101
b2FrictionJoint::m_indexA
int32 m_indexA
Definition:
b2_friction_joint.h:110
b2FrictionJoint::m_maxForce
float m_maxForce
Definition:
b2_friction_joint.h:106
b2SolverData
Solver Data.
Definition:
b2_time_step.h:67
b2Vec2
A 2D column vector.
Definition:
b2_math.h:41
b2FrictionJoint::m_localCenterB
b2Vec2 m_localCenterB
Definition:
b2_friction_joint.h:115
int32
signed int int32
Definition:
b2_types.h:28
b2FrictionJointDef
Friction joint definition.
Definition:
b2_friction_joint.h:30
b2Joint::GetReactionTorque
virtual float GetReactionTorque(float inv_dt) const =0
Get the reaction torque on bodyB in N*m.
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2_body.h:128
b2Joint::GetAnchorA
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
b2Joint::InitVelocityConstraints
virtual void InitVelocityConstraints(const b2SolverData &data)=0
b2FrictionJoint::m_angularMass
float m_angularMass
Definition:
b2_friction_joint.h:121
b2FrictionJoint::m_rA
b2Vec2 m_rA
Definition:
b2_friction_joint.h:112
b2FrictionJoint::m_angularImpulse
float m_angularImpulse
Definition:
b2_friction_joint.h:105
b2Joint::SolvePositionConstraints
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2FrictionJoint::m_indexB
int32 m_indexB
Definition:
b2_friction_joint.h:111
b2FrictionJoint::GetLocalAnchorB
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition:
b2_friction_joint.h:73
b2FrictionJoint::m_invIB
float m_invIB
Definition:
b2_friction_joint.h:119
b2FrictionJoint::GetLocalAnchorA
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition:
b2_friction_joint.h:70
ImGui::Initialize
IMGUI_API void Initialize(ImGuiContext *context)
Definition:
imgui.cpp:3473
b2_api.h
b2Joint::Dump
virtual void Dump()
Dump this joint to the log file.
Definition:
b2_joint.h:151
b2FrictionJoint::m_linearMass
b2Mat22 m_linearMass
Definition:
b2_friction_joint.h:120
b2_joint.h
b2Joint
Definition:
b2_joint.h:110
b2Joint::GetAnchorB
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
b2FrictionJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2_friction_joint.h:100
b2FrictionJoint::m_invIA
float m_invIA
Definition:
b2_friction_joint.h:118
b2Mat22
A 2-by-2 matrix. Stored in column-major order.
Definition:
b2_math.h:171
b2FrictionJoint::m_localCenterA
b2Vec2 m_localCenterA
Definition:
b2_friction_joint.h:114
b2FrictionJoint::m_invMassA
float m_invMassA
Definition:
b2_friction_joint.h:116
type
GLenum type
Definition:
gl.h:1033
b2FrictionJoint::m_linearImpulse
b2Vec2 m_linearImpulse
Definition:
b2_friction_joint.h:104
mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19