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

Runtime controller class. More...

#include <WheeledVehicleController.h>

Inheritance diagram for WheeledVehicleController:
VehicleController RefTarget< VehicleController > NonCopyable MotorcycleController

Public Types

using Differentials = Array< VehicleDifferentialSettings >
 Typedefs.
 
using TireMaxImpulseCallback = function< void(uint inWheelIndex, float &outLongitudinalImpulse, float &outLateralImpulse, float inSuspensionImpulse, float inLongitudinalFriction, float inLateralFriction, float inLongitudinalSlip, float inLateralSlip, float inDeltaTime)>
 Calculate max tire impulses by combining friction, slip, and suspension impulse. Note that the actual applied impulse may be lower (e.g. when the vehicle is stationary on a horizontal surface the actual impulse applied will be 0).
 

Public Member Functions

JPH_OVERRIDE_NEW_DELETE WheeledVehicleController (const WheeledVehicleControllerSettings &inSettings, VehicleConstraint &inConstraint)
 Constructor.
 
void SetDriverInput (float inForward, float inRight, float inBrake, float inHandBrake)
 
void SetForwardInput (float inForward)
 Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving direction and amount the gas pedal is pressed.
 
float GetForwardInput () const
 
void SetRightInput (float inRight)
 Value between -1 and 1 indicating desired steering angle (1 = right)
 
float GetRightInput () const
 
void SetBrakeInput (float inBrake)
 Value between 0 and 1 indicating how strong the brake pedal is pressed.
 
float GetBrakeInput () const
 
void SetHandBrakeInput (float inHandBrake)
 Value between 0 and 1 indicating how strong the hand brake is pulled.
 
float GetHandBrakeInput () const
 
const VehicleEngineGetEngine () const
 Get current engine state.
 
VehicleEngineGetEngine ()
 Get current engine state (writable interface, allows you to make changes to the configuration which will take effect the next time step)
 
const VehicleTransmissionGetTransmission () const
 Get current transmission state.
 
VehicleTransmissionGetTransmission ()
 Get current transmission state (writable interface, allows you to make changes to the configuration which will take effect the next time step)
 
const DifferentialsGetDifferentials () const
 Get the differentials this vehicle has.
 
DifferentialsGetDifferentials ()
 Get the differentials this vehicle has (writable interface, allows you to make changes to the configuration which will take effect the next time step)
 
float GetDifferentialLimitedSlipRatio () const
 Ratio max / min average wheel speed of each differential (measured at the clutch).
 
void SetDifferentialLimitedSlipRatio (float inV)
 
float GetWheelSpeedAtClutch () const
 Get the average wheel speed of all driven wheels (measured at the clutch)
 
const TireMaxImpulseCallbackGetTireMaxImpulseCallback () const
 
void SetTireMaxImpulseCallback (const TireMaxImpulseCallback &inTireMaxImpulseCallback)
 
void SetRPMMeter (Vec3Arg inPosition, float inSize)
 Debug drawing of RPM meter.
 
- Public Member Functions inherited from VehicleController
JPH_OVERRIDE_NEW_DELETE VehicleController (VehicleConstraint &inConstraint)
 Constructor / destructor.
 
virtual ~VehicleController ()=default
 
- Public Member Functions inherited from RefTarget< VehicleController >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Protected Member Functions

virtual WheelConstructWheel (const WheelSettings &inWheel) const override
 
virtual bool AllowSleep () const override
 
virtual void PreCollide (float inDeltaTime, PhysicsSystem &inPhysicsSystem) override
 
virtual void PostCollide (float inDeltaTime, PhysicsSystem &inPhysicsSystem) override
 
virtual bool SolveLongitudinalAndLateralConstraints (float inDeltaTime) override
 
virtual void SaveState (StateRecorder &inStream) const override
 
virtual void RestoreState (StateRecorder &inStream) override
 
virtual void Draw (DebugRenderer *inRenderer) const override
 

Protected Attributes

float mForwardInput = 0.0f
 Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving direction and amount the gas pedal is pressed.
 
float mRightInput = 0.0f
 Value between -1 and 1 indicating desired steering angle.
 
float mBrakeInput = 0.0f
 Value between 0 and 1 indicating how strong the brake pedal is pressed.
 
float mHandBrakeInput = 0.0f
 Value between 0 and 1 indicating how strong the hand brake is pulled.
 
VehicleEngine mEngine
 Engine state of the vehicle.
 
VehicleTransmission mTransmission
 Transmission state of the vehicle.
 
Differentials mDifferentials
 Differential states of the vehicle.
 
float mDifferentialLimitedSlipRatio
 Ratio max / min average wheel speed of each differential (measured at the clutch).
 
float mPreviousDeltaTime = 0.0f
 Delta time of the last step.
 
TireMaxImpulseCallback mTireMaxImpulseCallback
 
Vec3 mRPMMeterPosition { 0, 1, 0 }
 Position (in local space of the body) of the RPM meter when drawing the constraint.
 
float mRPMMeterSize = 0.5f
 Size of the RPM meter when drawing the constraint.
 
- Protected Attributes inherited from VehicleController
VehicleConstraintmConstraint
 The vehicle constraint we belong to.
 
- Protected Attributes inherited from RefTarget< VehicleController >
atomic< uint32mRefCount
 Current reference count.
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< VehicleController >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Static Protected Attributes inherited from RefTarget< VehicleController >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Runtime controller class.

Member Typedef Documentation

◆ Differentials

◆ TireMaxImpulseCallback

using WheeledVehicleController::TireMaxImpulseCallback = function<void(uint inWheelIndex, float &outLongitudinalImpulse, float &outLateralImpulse, float inSuspensionImpulse, float inLongitudinalFriction, float inLateralFriction, float inLongitudinalSlip, float inLateralSlip, float inDeltaTime)>

Calculate max tire impulses by combining friction, slip, and suspension impulse. Note that the actual applied impulse may be lower (e.g. when the vehicle is stationary on a horizontal surface the actual impulse applied will be 0).

Constructor & Destructor Documentation

◆ WheeledVehicleController()

WheeledVehicleController::WheeledVehicleController ( const WheeledVehicleControllerSettings inSettings,
VehicleConstraint inConstraint 
)

Constructor.

Member Function Documentation

◆ AllowSleep()

bool WheeledVehicleController::AllowSleep ( ) const
overrideprotectedvirtual

Implements VehicleController.

◆ ConstructWheel()

virtual Wheel * WheeledVehicleController::ConstructWheel ( const WheelSettings inWheel) const
inlineoverrideprotectedvirtual

Implements VehicleController.

◆ Draw()

void WheeledVehicleController::Draw ( DebugRenderer inRenderer) const
overrideprotectedvirtual

Implements VehicleController.

Reimplemented in MotorcycleController.

◆ GetBrakeInput()

float WheeledVehicleController::GetBrakeInput ( ) const
inline

◆ GetDifferentialLimitedSlipRatio()

float WheeledVehicleController::GetDifferentialLimitedSlipRatio ( ) const
inline

Ratio max / min average wheel speed of each differential (measured at the clutch).

◆ GetDifferentials() [1/2]

Differentials & WheeledVehicleController::GetDifferentials ( )
inline

Get the differentials this vehicle has (writable interface, allows you to make changes to the configuration which will take effect the next time step)

◆ GetDifferentials() [2/2]

const Differentials & WheeledVehicleController::GetDifferentials ( ) const
inline

Get the differentials this vehicle has.

◆ GetEngine() [1/2]

VehicleEngine & WheeledVehicleController::GetEngine ( )
inline

Get current engine state (writable interface, allows you to make changes to the configuration which will take effect the next time step)

◆ GetEngine() [2/2]

const VehicleEngine & WheeledVehicleController::GetEngine ( ) const
inline

Get current engine state.

◆ GetForwardInput()

float WheeledVehicleController::GetForwardInput ( ) const
inline

◆ GetHandBrakeInput()

float WheeledVehicleController::GetHandBrakeInput ( ) const
inline

◆ GetRightInput()

float WheeledVehicleController::GetRightInput ( ) const
inline

◆ GetTireMaxImpulseCallback()

const TireMaxImpulseCallback & WheeledVehicleController::GetTireMaxImpulseCallback ( ) const
inline

◆ GetTransmission() [1/2]

VehicleTransmission & WheeledVehicleController::GetTransmission ( )
inline

Get current transmission state (writable interface, allows you to make changes to the configuration which will take effect the next time step)

◆ GetTransmission() [2/2]

const VehicleTransmission & WheeledVehicleController::GetTransmission ( ) const
inline

Get current transmission state.

◆ GetWheelSpeedAtClutch()

float WheeledVehicleController::GetWheelSpeedAtClutch ( ) const

Get the average wheel speed of all driven wheels (measured at the clutch)

◆ PostCollide()

void WheeledVehicleController::PostCollide ( float  inDeltaTime,
PhysicsSystem inPhysicsSystem 
)
overrideprotectedvirtual

Implements VehicleController.

◆ PreCollide()

void WheeledVehicleController::PreCollide ( float  inDeltaTime,
PhysicsSystem inPhysicsSystem 
)
overrideprotectedvirtual

Implements VehicleController.

Reimplemented in MotorcycleController.

◆ RestoreState()

void WheeledVehicleController::RestoreState ( StateRecorder inStream)
overrideprotectedvirtual

Implements VehicleController.

Reimplemented in MotorcycleController.

◆ SaveState()

void WheeledVehicleController::SaveState ( StateRecorder inStream) const
overrideprotectedvirtual

Implements VehicleController.

Reimplemented in MotorcycleController.

◆ SetBrakeInput()

void WheeledVehicleController::SetBrakeInput ( float  inBrake)
inline

Value between 0 and 1 indicating how strong the brake pedal is pressed.

◆ SetDifferentialLimitedSlipRatio()

void WheeledVehicleController::SetDifferentialLimitedSlipRatio ( float  inV)
inline

◆ SetDriverInput()

void WheeledVehicleController::SetDriverInput ( float  inForward,
float  inRight,
float  inBrake,
float  inHandBrake 
)
inline

Set input from driver

Parameters
inForwardValue between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving direction and amount the gas pedal is pressed
inRightValue between -1 and 1 indicating desired steering angle (1 = right)
inBrakeValue between 0 and 1 indicating how strong the brake pedal is pressed
inHandBrakeValue between 0 and 1 indicating how strong the hand brake is pulled

◆ SetForwardInput()

void WheeledVehicleController::SetForwardInput ( float  inForward)
inline

Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving direction and amount the gas pedal is pressed.

◆ SetHandBrakeInput()

void WheeledVehicleController::SetHandBrakeInput ( float  inHandBrake)
inline

Value between 0 and 1 indicating how strong the hand brake is pulled.

◆ SetRightInput()

void WheeledVehicleController::SetRightInput ( float  inRight)
inline

Value between -1 and 1 indicating desired steering angle (1 = right)

◆ SetRPMMeter()

void WheeledVehicleController::SetRPMMeter ( Vec3Arg  inPosition,
float  inSize 
)
inline

Debug drawing of RPM meter.

◆ SetTireMaxImpulseCallback()

void WheeledVehicleController::SetTireMaxImpulseCallback ( const TireMaxImpulseCallback inTireMaxImpulseCallback)
inline

◆ SolveLongitudinalAndLateralConstraints()

bool WheeledVehicleController::SolveLongitudinalAndLateralConstraints ( float  inDeltaTime)
overrideprotectedvirtual

Implements VehicleController.

Reimplemented in MotorcycleController.

Member Data Documentation

◆ mBrakeInput

float WheeledVehicleController::mBrakeInput = 0.0f
protected

Value between 0 and 1 indicating how strong the brake pedal is pressed.

◆ mDifferentialLimitedSlipRatio

float WheeledVehicleController::mDifferentialLimitedSlipRatio
protected

Ratio max / min average wheel speed of each differential (measured at the clutch).

◆ mDifferentials

Differentials WheeledVehicleController::mDifferentials
protected

Differential states of the vehicle.

◆ mEngine

VehicleEngine WheeledVehicleController::mEngine
protected

Engine state of the vehicle.

◆ mForwardInput

float WheeledVehicleController::mForwardInput = 0.0f
protected

Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving direction and amount the gas pedal is pressed.

◆ mHandBrakeInput

float WheeledVehicleController::mHandBrakeInput = 0.0f
protected

Value between 0 and 1 indicating how strong the hand brake is pulled.

◆ mPreviousDeltaTime

float WheeledVehicleController::mPreviousDeltaTime = 0.0f
protected

Delta time of the last step.

◆ mRightInput

float WheeledVehicleController::mRightInput = 0.0f
protected

Value between -1 and 1 indicating desired steering angle.

◆ mRPMMeterPosition

Vec3 WheeledVehicleController::mRPMMeterPosition { 0, 1, 0 }
protected

Position (in local space of the body) of the RPM meter when drawing the constraint.

◆ mRPMMeterSize

float WheeledVehicleController::mRPMMeterSize = 0.5f
protected

Size of the RPM meter when drawing the constraint.

◆ mTireMaxImpulseCallback

TireMaxImpulseCallback WheeledVehicleController::mTireMaxImpulseCallback
protected
Initial value:
=
[](uint, float &outLongitudinalImpulse, float &outLateralImpulse, float inSuspensionImpulse, float inLongitudinalFriction, float inLateralFriction, float, float, float)
{
outLongitudinalImpulse = inLongitudinalFriction * inSuspensionImpulse;
outLateralImpulse = inLateralFriction * inSuspensionImpulse;
}
unsigned int uint
Definition Core.h:448

◆ mTransmission

VehicleTransmission WheeledVehicleController::mTransmission
protected

Transmission state of the vehicle.


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