Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
VehicleEngine Class Reference

Runtime data for engine. More...

#include <VehicleEngine.h>

Inheritance diagram for VehicleEngine:
VehicleEngineSettings

Public Member Functions

void ClampRPM ()
 Clamp the RPM between min and max RPM. More...
 
float GetCurrentRPM () const
 Current rotation speed of engine in rounds per minute. More...
 
void SetCurrentRPM (float inRPM)
 Update rotation speed of engine in rounds per minute. More...
 
float GetAngularVelocity () const
 Get current angular velocity of the engine in radians / second. More...
 
float GetTorque (float inAcceleration) const
 
void ApplyTorque (float inTorque, float inDeltaTime)
 
void ApplyDamping (float inDeltaTime)
 
float ConvertRPMToAngle (float inRPM) const
 
void DrawRPM (DebugRenderer *inRenderer, RVec3Arg inPosition, Vec3Arg inForward, Vec3Arg inUp, float inSize, float inShiftDownRPM, float inShiftUpRPM) const
 Debug draw a RPM meter. More...
 
bool AllowSleep () const
 If the engine is idle we allow the vehicle to sleep. More...
 
void SaveState (StateRecorder &inStream) const
 Saving state for replay. More...
 
void RestoreState (StateRecorder &inStream)
 
- Public Member Functions inherited from VehicleEngineSettings
 VehicleEngineSettings ()
 Constructor. More...
 
void SaveBinaryState (StreamOut &inStream) const
 Saves the contents in binary form to inStream. More...
 
void RestoreBinaryState (StreamIn &inStream)
 Restores the contents in binary form to inStream. More...
 

Static Public Attributes

static constexpr float cAngularVelocityToRPM = 60.0f / (2.0f * JPH_PI)
 Multiply an angular velocity (rad/s) with this value to get rounds per minute (RPM) More...
 

Additional Inherited Members

- Public Attributes inherited from VehicleEngineSettings
float mMaxTorque = 500.0f
 Max amount of torque (Nm) that the engine can deliver. More...
 
float mMinRPM = 1000.0f
 Min amount of revolutions per minute (rpm) the engine can produce without stalling. More...
 
float mMaxRPM = 6000.0f
 Max amount of revolutions per minute (rpm) the engine can generate. More...
 
LinearCurve mNormalizedTorque
 Y-axis: Curve that describes a ratio of the max torque the engine can produce (0 = 0, 1 = mMaxTorque). X-axis: the fraction of the RPM of the engine (0 = mMinRPM, 1 = mMaxRPM) More...
 
float mInertia = 0.5f
 Moment of inertia (kg m^2) of the engine. More...
 
float mAngularDamping = 0.2f
 Angular damping factor of the wheel: dw/dt = -c * w. More...
 

Detailed Description

Runtime data for engine.

Member Function Documentation

◆ AllowSleep()

bool VehicleEngine::AllowSleep ( ) const
inline

If the engine is idle we allow the vehicle to sleep.

◆ ApplyDamping()

void VehicleEngine::ApplyDamping ( float  inDeltaTime)

Update the engine RPM for damping

Parameters
inDeltaTimeDelta time in seconds

◆ ApplyTorque()

void VehicleEngine::ApplyTorque ( float  inTorque,
float  inDeltaTime 
)

Apply a torque to the engine rotation speed

Parameters
inTorqueTorque in N m
inDeltaTimeDelta time in seconds

◆ ClampRPM()

void VehicleEngine::ClampRPM ( )
inline

Clamp the RPM between min and max RPM.

◆ ConvertRPMToAngle()

float VehicleEngine::ConvertRPMToAngle ( float  inRPM) const
inline

◆ DrawRPM()

void VehicleEngine::DrawRPM ( DebugRenderer inRenderer,
RVec3Arg  inPosition,
Vec3Arg  inForward,
Vec3Arg  inUp,
float  inSize,
float  inShiftDownRPM,
float  inShiftUpRPM 
) const

Debug draw a RPM meter.

◆ GetAngularVelocity()

float VehicleEngine::GetAngularVelocity ( ) const
inline

Get current angular velocity of the engine in radians / second.

◆ GetCurrentRPM()

float VehicleEngine::GetCurrentRPM ( ) const
inline

Current rotation speed of engine in rounds per minute.

◆ GetTorque()

float VehicleEngine::GetTorque ( float  inAcceleration) const
inline

Get the amount of torque (N m) that the engine can supply

Parameters
inAccelerationHow much the gas pedal is pressed [0, 1]

◆ RestoreState()

void VehicleEngine::RestoreState ( StateRecorder inStream)

◆ SaveState()

void VehicleEngine::SaveState ( StateRecorder inStream) const

Saving state for replay.

◆ SetCurrentRPM()

void VehicleEngine::SetCurrentRPM ( float  inRPM)
inline

Update rotation speed of engine in rounds per minute.

Member Data Documentation

◆ cAngularVelocityToRPM

constexpr float VehicleEngine::cAngularVelocityToRPM = 60.0f / (2.0f * JPH_PI)
staticconstexpr

Multiply an angular velocity (rad/s) with this value to get rounds per minute (RPM)


The documentation for this class was generated from the following files: