![]() |
Jolt Physics
A multi core friendly Game Physics Engine
|
Runtime controller class. More...
#include <MotorcycleController.h>
Public Member Functions | |
JPH_OVERRIDE_NEW_DELETE | MotorcycleController (const MotorcycleControllerSettings &inSettings, VehicleConstraint &inConstraint) |
Constructor. | |
float | GetWheelBase () const |
Get the distance between the front and back wheels. | |
void | EnableLeanController (bool inEnable) |
Enable or disable the lean spring. This allows you to temporarily disable the lean spring to allow the motorcycle to fall over. | |
bool | IsLeanControllerEnabled () const |
Check if the lean spring is enabled. | |
void | EnableLeanSteeringLimit (bool inEnable) |
Enable or disable the lean steering limit. When enabled (default) the steering angle is limited based on the vehicle speed to prevent steering that would cause an inertial force that causes the motorcycle to topple over. | |
bool | IsLeanSteeringLimitEnabled () const |
void | SetLeanSpringConstant (float inConstant) |
Spring constant for the lean spring. | |
float | GetLeanSpringConstant () const |
void | SetLeanSpringDamping (float inDamping) |
Spring damping constant for the lean spring. | |
float | GetLeanSpringDamping () const |
void | SetLeanSpringIntegrationCoefficient (float inCoefficient) |
The lean spring applies an additional force equal to this coefficient * Integral(delta angle, 0, t), this effectively makes the lean spring a PID controller. | |
float | GetLeanSpringIntegrationCoefficient () const |
void | SetLeanSpringIntegrationCoefficientDecay (float inDecay) |
How much to decay the angle integral when the wheels are not touching the floor: new_value = e^(-decay * t) * initial_value. | |
float | GetLeanSpringIntegrationCoefficientDecay () const |
void | SetLeanSmoothingFactor (float inFactor) |
float | GetLeanSmoothingFactor () const |
![]() | |
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 VehicleEngine & | GetEngine () const |
Get current engine state. | |
VehicleEngine & | GetEngine () |
Get current engine state (writable interface, allows you to make changes to the configuration which will take effect the next time step) | |
const VehicleTransmission & | GetTransmission () const |
Get current transmission state. | |
VehicleTransmission & | GetTransmission () |
Get current transmission state (writable interface, allows you to make changes to the configuration which will take effect the next time step) | |
const Differentials & | GetDifferentials () const |
Get the differentials this vehicle has. | |
Differentials & | GetDifferentials () |
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 TireMaxImpulseCallback & | GetTireMaxImpulseCallback () const |
void | SetTireMaxImpulseCallback (const TireMaxImpulseCallback &inTireMaxImpulseCallback) |
void | SetRPMMeter (Vec3Arg inPosition, float inSize) |
Debug drawing of RPM meter. | |
![]() | |
JPH_OVERRIDE_NEW_DELETE | VehicleController (VehicleConstraint &inConstraint) |
Constructor / destructor. | |
virtual | ~VehicleController ()=default |
VehicleConstraint & | GetConstraint () |
Access the vehicle constraint that this controller is part of. | |
const VehicleConstraint & | GetConstraint () const |
![]() | |
NonCopyable ()=default | |
NonCopyable (const NonCopyable &)=delete | |
void | operator= (const NonCopyable &)=delete |
Protected Member Functions | |
virtual void | PreCollide (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 |
![]() | |
virtual Wheel * | ConstructWheel (const WheelSettings &inWheel) const override |
virtual bool | AllowSleep () const override |
virtual void | PostCollide (float inDeltaTime, PhysicsSystem &inPhysicsSystem) override |
![]() |
Protected Attributes | |
bool | mEnableLeanController = true |
bool | mEnableLeanSteeringLimit = true |
float | mMaxLeanAngle |
float | mLeanSpringConstant |
float | mLeanSpringDamping |
float | mLeanSpringIntegrationCoefficient |
float | mLeanSpringIntegrationCoefficientDecay |
float | mLeanSmoothingFactor |
Vec3 | mTargetLean = Vec3::sZero() |
float | mLeanSpringIntegratedDeltaAngle = 0.0f |
float | mAppliedImpulse = 0.0f |
![]() | |
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. | |
![]() | |
VehicleConstraint & | mConstraint |
The vehicle constraint we belong to. | |
Additional Inherited Members | |
![]() | |
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). | |
Runtime controller class.
MotorcycleController::MotorcycleController | ( | const MotorcycleControllerSettings & | inSettings, |
VehicleConstraint & | inConstraint ) |
Constructor.
|
overrideprotectedvirtual |
Reimplemented from WheeledVehicleController.
|
inline |
Enable or disable the lean spring. This allows you to temporarily disable the lean spring to allow the motorcycle to fall over.
|
inline |
Enable or disable the lean steering limit. When enabled (default) the steering angle is limited based on the vehicle speed to prevent steering that would cause an inertial force that causes the motorcycle to topple over.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
float MotorcycleController::GetWheelBase | ( | ) | const |
Get the distance between the front and back wheels.
|
inline |
Check if the lean spring is enabled.
|
inline |
|
overrideprotectedvirtual |
Reimplemented from WheeledVehicleController.
|
overrideprotectedvirtual |
Reimplemented from WheeledVehicleController.
|
overrideprotectedvirtual |
Reimplemented from WheeledVehicleController.
|
inline |
How much to smooth the lean angle (0 = no smoothing, 1 = lean angle never changes) Note that this is frame rate dependent because the formula is: smoothing_factor * previous + (1 - smoothing_factor) * current
|
inline |
Spring constant for the lean spring.
|
inline |
Spring damping constant for the lean spring.
|
inline |
The lean spring applies an additional force equal to this coefficient * Integral(delta angle, 0, t), this effectively makes the lean spring a PID controller.
|
inline |
How much to decay the angle integral when the wheels are not touching the floor: new_value = e^(-decay * t) * initial_value.
|
overrideprotectedvirtual |
Reimplemented from WheeledVehicleController.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |