RigsofRods
Soft-body Physics Simulation
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
i
k
l
m
n
p
r
s
t
u
v
w
Typedefs
a
c
d
e
f
g
l
m
n
o
p
r
s
t
v
w
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
a
b
c
d
g
h
l
m
n
o
p
r
s
t
v
Enumerator
a
b
c
d
f
g
h
l
m
n
o
r
s
t
v
Related Functions
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
k
o
Macros
_
a
b
c
d
e
f
h
i
l
m
n
o
p
r
s
t
x
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
source
main
gameplay
TyrePressure.cpp
Go to the documentation of this file.
1
/*
2
This source file is part of Rigs of Rods
3
Copyright 2005-2012 Pierre-Michel Ricordel
4
Copyright 2007-2012 Thomas Fischer
5
Copyright 2015-2020 Petr Ohlidal
6
7
For more information, see http://www.rigsofrods.org/
8
9
Rigs of Rods is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License version 3, as
11
published by the Free Software Foundation.
12
13
Rigs of Rods is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "
TyrePressure.h
"
23
24
#include "
Actor.h
"
25
#include "
InputEngine.h
"
26
#include "
SoundScriptManager.h
"
27
28
#include <Ogre.h>
29
30
using namespace
RoR
;
31
32
void
TyrePressure::UpdateInputEvents
(
float
dt)
33
{
34
if
(
App::GetInputEngine
()->getEventBoolValue(
EV_COMMON_PRESSURE_LESS
))
35
{
36
float
change =
m_ref_tyre_pressure
* (1.0f - pow(2.0f, dt / 2.0f));
37
change = Ogre::Math::Clamp(change, -dt * 10.0f, -dt * 1.0f);
38
if
(
m_pressure_pressed
= this->
ModifyTyrePressure
(change))
39
{
40
SOUND_START
(
m_actor
,
SS_TRIG_AIR
);
41
}
42
}
43
else
if
(
App::GetInputEngine
()->getEventBoolValue(
EV_COMMON_PRESSURE_MORE
))
44
{
45
float
change =
m_ref_tyre_pressure
* (pow(2.0f, dt / 2.0f) - 1.0f);
46
change = Ogre::Math::Clamp(change, +dt * 1.0f, +dt * 10.0f);
47
if
(
m_pressure_pressed
= this->
ModifyTyrePressure
(change))
48
{
49
SOUND_START
(
m_actor
,
SS_TRIG_AIR
);
50
}
51
}
52
else
if
(
m_pressure_pressed
)
53
{
54
SOUND_STOP
(
m_actor
,
SS_TRIG_AIR
);
55
m_pressure_pressed
=
false
;
56
m_pressure_pressed_timer
= 1.5f;
57
}
58
else
if
(
m_pressure_pressed_timer
> 0.0f)
59
{
60
m_pressure_pressed_timer
-= dt;
61
}
62
}
63
64
bool
TyrePressure::ModifyTyrePressure
(
float
v)
65
{
66
float
newpressure = Ogre::Math::Clamp(
m_ref_tyre_pressure
+ v, 0.0f, 100.0f);
67
if
(newpressure ==
m_ref_tyre_pressure
)
68
return
false
;
69
70
for
(
int
beam_id:
m_pressure_beams
)
71
{
72
m_actor
->
ar_beams
[beam_id].
k
= 10000 + newpressure * 10000;
73
}
74
m_ref_tyre_pressure
= newpressure;
75
return
true
;
76
}
RoR::TyrePressure::m_pressure_pressed
bool m_pressure_pressed
Definition:
TyrePressure.h:56
RoR::TyrePressure::m_ref_tyre_pressure
float m_ref_tyre_pressure
Definition:
TyrePressure.h:58
RoR::TyrePressure::ModifyTyrePressure
bool ModifyTyrePressure(float v)
Definition:
TyrePressure.cpp:64
TyrePressure.h
Wheel 'pressure adjustment' logic (only for 'wheels2')
RoR::TyrePressure::m_pressure_pressed_timer
float m_pressure_pressed_timer
Definition:
TyrePressure.h:57
RoR::EV_COMMON_PRESSURE_MORE
@ EV_COMMON_PRESSURE_MORE
increase tire pressure (note: only very few trucks support this)
Definition:
InputEngine.h:245
Actor.h
RoR::EV_COMMON_PRESSURE_LESS
@ EV_COMMON_PRESSURE_LESS
decrease tire pressure (note: only very few trucks support this)
Definition:
InputEngine.h:244
RoR::Actor::ar_beams
beam_t * ar_beams
Definition:
Actor.h:320
RoR::TyrePressure::m_pressure_beams
std::vector< int > m_pressure_beams
Definition:
TyrePressure.h:55
RoR::TyrePressure::m_actor
ActorPtr m_actor
Definition:
TyrePressure.h:54
RoR::SS_TRIG_AIR
@ SS_TRIG_AIR
Definition:
SoundScriptManager.h:68
SOUND_START
#define SOUND_START(_ACTOR_, _TRIG_)
Definition:
SoundScriptManager.h:35
SoundScriptManager.h
SOUND_STOP
#define SOUND_STOP(_ACTOR_, _TRIG_)
Definition:
SoundScriptManager.h:36
RoR::beam_t::k
float k
tensile spring
Definition:
SimData.h:311
RoR::App::GetInputEngine
InputEngine * GetInputEngine()
Definition:
Application.cpp:287
InputEngine.h
Handles controller inputs from player. Defines input events and binding mechanism,...
RoR
Definition:
AppContext.h:36
RoR::TyrePressure::UpdateInputEvents
void UpdateInputEvents(float dt)
Definition:
TyrePressure.cpp:32
Generated by
1.8.17