15#ifdef JPH_DEBUG_RENDERER
29 void SaveBinaryState(
StreamOut &inStream)
const;
32 void RestoreBinaryState(
StreamIn &inStream);
34 float mMaxTorque = 500.0f;
35 float mMinRPM = 1000.0f;
36 float mMaxRPM = 6000.0f;
38 float mInertia = 0.5f;
39 float mAngularDamping = 0.2f;
47 static constexpr float cAngularVelocityToRPM = 60.0f / (2.0f * JPH_PI);
50 inline void ClampRPM() { mCurrentRPM =
Clamp(mCurrentRPM, mMinRPM, mMaxRPM); }
63 float GetTorque(
float inAcceleration)
const {
return inAcceleration * mMaxTorque * mNormalizedTorque.GetValue(mCurrentRPM / mMaxRPM); }
68 void ApplyTorque(
float inTorque,
float inDeltaTime);
72 void ApplyDamping(
float inDeltaTime);
74#ifdef JPH_DEBUG_RENDERER
76 float ConvertRPMToAngle(
float inRPM)
const {
return (-0.75f + 1.5f * inRPM / mMaxRPM) * JPH_PI; }
83 bool AllowSleep()
const {
return mCurrentRPM <= 1.01f * mMinRPM; }
90 float mCurrentRPM = mMinRPM;
#define JPH_EXPORT
Definition: Core.h:227
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
constexpr T Clamp(T inV, T inMin, T inMax)
Clamp a value between two values.
Definition: Math.h:45
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition: SerializableObject.h:71
Definition: DebugRenderer.h:47
Definition: LinearCurve.h:17
Definition: StateRecorder.h:48
Simple binary input stream.
Definition: StreamIn.h:13
Simple binary output stream.
Definition: StreamOut.h:13
Runtime data for engine.
Definition: VehicleEngine.h:44
void ClampRPM()
Clamp the RPM between min and max RPM.
Definition: VehicleEngine.h:50
float GetTorque(float inAcceleration) const
Definition: VehicleEngine.h:63
float ConvertRPMToAngle(float inRPM) const
Definition: VehicleEngine.h:76
bool AllowSleep() const
If the engine is idle we allow the vehicle to sleep.
Definition: VehicleEngine.h:83
void SetCurrentRPM(float inRPM)
Update rotation speed of engine in rounds per minute.
Definition: VehicleEngine.h:56
float GetCurrentRPM() const
Current rotation speed of engine in rounds per minute.
Definition: VehicleEngine.h:53
float GetAngularVelocity() const
Get current angular velocity of the engine in radians / second.
Definition: VehicleEngine.h:59
Generic properties for a vehicle engine.
Definition: VehicleEngine.h:21
LinearCurve mNormalizedTorque
Y-axis: Curve that describes a ratio of the max torque the engine can produce (0 = 0,...
Definition: VehicleEngine.h:37