Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Differentials.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
6 For more information, see http://www.rigsofrods.org/
7
8 Rigs of Rods is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 3, as
10 published by the Free Software Foundation.
11
12 Rigs of Rods is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23#include <vector>
24
25namespace RoR {
26
29
32
34{
35 float speed[2];
36 float delta_rotation; // sign is first relative to the second
37 float out_torque[2];
38 float in_torque;
39 float dt;
40};
41
43{
44public:
45 TransferCase(int a1, int a2, bool has_2wd, bool has_2wd_lo, std::vector<float> grs):
46 tr_ax_1(a1), tr_ax_2(a2), tr_2wd(has_2wd), tr_2wd_lo(has_2wd_lo), tr_4wd_mode(false), tr_gear_ratios(grs) {};
47
48 int tr_ax_1;
49 int tr_ax_2;
50 bool tr_2wd;
51 bool tr_2wd_lo;
53 std::vector<float> tr_gear_ratios;
54};
55
64
66{
67public:
69
73
74 void AddDifferentialType(DiffType diff) { m_available_diffs.push_back(diff); }
76 void CalcAxleTorque(DifferentialData& diff_data);
77 std::string GetDifferentialTypeName();
79 int GetNumDiffTypes() { return static_cast<int>(m_available_diffs.size()); }
80
81 static void CalcSeparateDiff(DifferentialData& diff_data);
82 static void CalcOpenDiff(DifferentialData& diff_data );
83 static void CalcViscousDiff(DifferentialData& diff_data );
84 static void CalcLockedDiff(DifferentialData& diff_data );
85
86private:
87 std::vector<DiffType> m_available_diffs;
88};
89
92
93} // namespace RoR
94
DiffType GetActiveDiffType() const
int di_idx_1
array location of wheel / axle 1
static void CalcLockedDiff(DifferentialData &diff_data)
ensures both wheels rotate at the the same speed
int di_idx_2
array location of wheel / axle 2
std::vector< DiffType > m_available_diffs
static void CalcSeparateDiff(DifferentialData &diff_data)
a differential that always splits the torque evenly, this is the original method
void CalcAxleTorque(DifferentialData &diff_data)
float di_delta_rotation
difference of rotational position between two wheels/axles... a kludge at best
void AddDifferentialType(DiffType diff)
std::string GetDifferentialTypeName()
static void CalcOpenDiff(DifferentialData &diff_data)
more power goes to the faster spining wheel
static void CalcViscousDiff(DifferentialData &diff_data)
more power goes to the slower spining wheel
bool tr_2wd
Does it support 2WD mode?
bool tr_4wd_mode
Enables 4WD mode.
std::vector< float > tr_gear_ratios
Gear reduction ratios.
TransferCase(int a1, int a2, bool has_2wd, bool has_2wd_lo, std::vector< float > grs)
int tr_ax_2
This axle is only driven in 4WD mode.
int tr_ax_1
This axle is always driven.
bool tr_2wd_lo
Does it support 2WD Lo mode?
@ INVALID_DIFF
@ VISCOUS_DIFF
@ SPLIT_DIFF
@ OPEN_DIFF
@ LOCKED_DIFF