Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
CmdKeyInertia.h
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 2020-2023 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#pragma once
23
24#include <OgrePrerequisites.h>
25#include <string>
26#include <unordered_map>
27
28namespace RoR {
29
32
35{
36public:
38 Ogre::SimpleSpline* GetSplineByName(Ogre::String model);
39
40private:
41 std::map<Ogre::String, Ogre::SimpleSpline> m_splines;
42};
43
46{
47public:
49
50 float CalcCmdKeyDelay(float cmd_input, float dt);
51 int SetCmdKeyDelay(RoR::CmdKeyInertiaConfig& cfg, float start_delay, float stop_delay, std::string start_function, std::string stop_function);
52 void ResetCmdKeyDelay();
53 float GetStartDelay() const { return m_start_delay; }
54 float GetStopDelay() const { return m_stop_delay; }
55 const std::string& GetStartFunction() const { return m_start_function; }
56 const std::string& GetStopFunction() const { return m_stop_function; }
57
58protected:
62 float m_time;
63 std::string m_start_function;
64 Ogre::SimpleSpline* m_start_spline;
65 std::string m_stop_function;
66 Ogre::SimpleSpline* m_stop_spline;
67
68 float CalculateCmdOutput(float time, Ogre::SimpleSpline* spline);
69};
70
73{
74public:
75 void SetSimpleDelay(RoR::CmdKeyInertiaConfig& cfg, float start_delay, float stop_delay, std::string start_function, std::string stop_function);
76
78 float CalcSimpleDelay(bool input, float dt);
79
80private:
81 bool m_last_input = false;
82 float m_start_delay = 0;
83 float m_stop_delay = 0;
84 float m_spline_time = 0;
85 Ogre::SimpleSpline* m_start_spline = nullptr;
86 Ogre::SimpleSpline* m_stop_spline = nullptr;
87};
88
90
91} // namespace RoR
Loads and manages 'inertia_models.cfg'.
std::map< Ogre::String, Ogre::SimpleSpline > m_splines
Ogre::SimpleSpline * GetSplineByName(Ogre::String model)
Designed to be run in physics loop (2khz)
std::string m_stop_function
std::string m_start_function
Ogre::SimpleSpline * m_stop_spline
const std::string & GetStopFunction() const
float CalcCmdKeyDelay(float cmd_input, float dt)
int SetCmdKeyDelay(RoR::CmdKeyInertiaConfig &cfg, float start_delay, float stop_delay, std::string start_function, std::string stop_function)
float CalculateCmdOutput(float time, Ogre::SimpleSpline *spline)
float GetStartDelay() const
const std::string & GetStartFunction() const
Ogre::SimpleSpline * m_start_spline
float GetStopDelay() const
Designed to be run on main/rendering loop (FPS)
Ogre::SimpleSpline * m_stop_spline
void SetSimpleDelay(RoR::CmdKeyInertiaConfig &cfg, float start_delay, float stop_delay, std::string start_function, std::string stop_function)
Ogre::SimpleSpline * m_start_spline
float CalcSimpleDelay(bool input, float dt)
Expected to be invoked in main/rendering loop, once per frame. The dt is in seconds.