Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
VehicleWear.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cmath>
4
5
namespace
VehicleWear
6
{
7
// Initial gameplay tuning: linear wear up to these service-life references.
8
// The existing ground odometer accumulates kilometers; aircraft usage is hours.
9
constexpr
float
GroundUsageAtFullWearKm
= 200000.0f;
10
constexpr
float
FlightUsageAtFullWearHours
= 10000.0f;
11
constexpr
float
MaximumThrustLoss
= 0.20f;
12
constexpr
float
MaximumDragIncrease
= 0.20f;
13
constexpr
float
MaximumFuelFlowIncrease
= 0.20f;
14
constexpr
float
MaximumControlPlay
= 0.10f;
15
16
struct
Factors
17
{
18
float
thrust
;
19
float
drag
;
20
float
fuelFlow
;
21
float
controlPlay
;
22
};
23
24
inline
Factors
Calculate
(
float
usage,
bool
groundVehicle)
25
{
26
// Invalid/missing usage must not introduce NaNs or improve performance.
27
if
(!std::isfinite(usage) || usage < 0.0f)
28
usage = 0.0f;
29
const
float
serviceLife = groundVehicle ?
GroundUsageAtFullWearKm
:
FlightUsageAtFullWearHours
;
30
const
float
wear = usage >= serviceLife ? 1.0f : usage / serviceLife;
31
return
{ 1.0f -
MaximumThrustLoss
* wear, 1.0f +
MaximumDragIncrease
* wear,
32
1.0f +
MaximumFuelFlowIncrease
* wear, groundVehicle ? 0.0f :
MaximumControlPlay
* wear };
33
}
34
35
// Mechanical play is applied to the final flight command, independently of
36
// device dead zones. Rescale the remaining travel so full authority is retained.
37
inline
float
ApplyControlPlay
(
float
input,
float
play)
38
{
39
if
(play <= 0.0f)
40
return
input;
41
const
float
magnitude = std::fabs(input);
42
if
(magnitude <= play)
43
return
0.0f;
44
const
float
output = magnitude >= 1.0f ? 1.0f : (magnitude - play) / (1.0f - play);
45
return
std::copysign(output, input);
46
}
47
48
// Restore a command from a saved surface position without applying play twice.
49
inline
float
RestoreControlInput
(
float
output,
float
play)
50
{
51
if
(play <= 0.0f || output == 0.0f)
52
return
output;
53
return
std::copysign(play + std::fabs(output) * (1.0f - play), output);
54
}
55
}
VehicleWear
Definition
VehicleWear.h:6
VehicleWear::ApplyControlPlay
float ApplyControlPlay(float input, float play)
Definition
VehicleWear.h:37
VehicleWear::MaximumThrustLoss
constexpr float MaximumThrustLoss
Definition
VehicleWear.h:11
VehicleWear::Calculate
Factors Calculate(float usage, bool groundVehicle)
Definition
VehicleWear.h:24
VehicleWear::MaximumControlPlay
constexpr float MaximumControlPlay
Definition
VehicleWear.h:14
VehicleWear::RestoreControlInput
float RestoreControlInput(float output, float play)
Definition
VehicleWear.h:49
VehicleWear::FlightUsageAtFullWearHours
constexpr float FlightUsageAtFullWearHours
Definition
VehicleWear.h:10
VehicleWear::MaximumFuelFlowIncrease
constexpr float MaximumFuelFlowIncrease
Definition
VehicleWear.h:13
VehicleWear::MaximumDragIncrease
constexpr float MaximumDragIncrease
Definition
VehicleWear.h:12
VehicleWear::GroundUsageAtFullWearKm
constexpr float GroundUsageAtFullWearKm
Definition
VehicleWear.h:9
VehicleWear::Factors
Definition
VehicleWear.h:17
VehicleWear::Factors::controlPlay
float controlPlay
Definition
VehicleWear.h:21
VehicleWear::Factors::thrust
float thrust
Definition
VehicleWear.h:18
VehicleWear::Factors::fuelFlow
float fuelFlow
Definition
VehicleWear.h:20
VehicleWear::Factors::drag
float drag
Definition
VehicleWear.h:19
Viewscreen
VehicleWear.h
Generated on
for Rise by
1.18.0