146 float GetWheelSpeedAtClutch()
const;
149 using TireMaxImpulseCallback = function<void(
uint inWheelIndex,
float &outLongitudinalImpulse,
float &outLateralImpulse,
float inSuspensionImpulse,
float inLongitudinalFriction,
float inLateralFriction,
float inLongitudinalSlip,
float inLateralSlip,
float inDeltaTime)>;
153#ifdef JPH_DEBUG_RENDERER
167 virtual bool AllowSleep()
const override;
168 virtual void PreCollide(
float inDeltaTime,
PhysicsSystem &inPhysicsSystem)
override;
169 virtual void PostCollide(
float inDeltaTime,
PhysicsSystem &inPhysicsSystem)
override;
170 virtual bool SolveLongitudinalAndLateralConstraints(
float inDeltaTime)
override;
171 virtual void SaveState(
StateRecorder &inStream)
const override;
173#ifdef JPH_DEBUG_RENDERER
192 [](
uint,
float &outLongitudinalImpulse,
float &outLateralImpulse,
float inSuspensionImpulse,
float inLongitudinalFriction,
float inLateralFriction, float, float, float)
194 outLongitudinalImpulse = inLongitudinalFriction * inSuspensionImpulse;
195 outLateralImpulse = inLateralFriction * inSuspensionImpulse;
198#ifdef JPH_DEBUG_RENDERER
#define JPH_EXPORT
Definition Core.h:275
unsigned int uint
Definition Core.h:500
#define JPH_NAMESPACE_END
Definition Core.h:425
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
JPH_INLINE constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition Math.h:16
const Vec3 Vec3Arg
Definition MathTypes.h:19
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:50
const DstType * StaticCast(const SrcType *inObject)
Cast inObject to DstType, asserts on failure.
Definition RTTI.h:388
bool IsKindOf(const Type *inObject, const RTTI *inRTTI)
Check if inObject is or is derived from DstType.
Definition RTTI.h:369
#define JPH_RTTI(class_name)
Definition RTTI.h:319
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:109
Definition DebugRenderer.h:47
Definition LinearCurve.h:17
Definition PhysicsSystem.h:30
Definition Reference.h:107
Definition StateRecorder.h:110
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition VehicleConstraint.h:66
Runtime data for interface that controls acceleration / deceleration of the vehicle.
Definition VehicleController.h:41
friend class VehicleConstraint
Definition VehicleController.h:58
JPH_OVERRIDE_NEW_DELETE VehicleController(VehicleConstraint &inConstraint)
Constructor / destructor.
Definition VehicleController.h:46
Basic settings object for interface that controls acceleration / deceleration of the vehicle.
Definition VehicleController.h:25
Runtime data for engine.
Definition VehicleEngine.h:44
Generic properties for a vehicle engine.
Definition VehicleEngine.h:21
Runtime data for transmission.
Definition VehicleTransmission.h:46
Configuration for the transmission of a vehicle (gear box).
Definition VehicleTransmission.h:23
Base class for runtime data for a wheel, each VehicleController can implement a derived class of this...
Definition Wheel.h:46
RefConst< WheelSettings > mSettings
Configuration settings for this wheel.
Definition Wheel.h:123
JPH_OVERRIDE_NEW_DELETE Wheel(const WheelSettings &inSettings)
Constructor / destructor.
Definition Wheel.cpp:66
float mAngularVelocity
Rotation speed of wheel, positive when the wheels cause the vehicle to move forwards (rad/s).
Definition Wheel.h:137
Base class for wheel settings, each VehicleController can implement a derived class of this.
Definition Wheel.h:19
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents in binary form to inStream.
Definition Wheel.cpp:32
virtual void RestoreBinaryState(StreamIn &inStream)
Restores the contents in binary form to inStream.
Definition Wheel.cpp:49
WheelSettings object specifically for WheeledVehicleController.
Definition WheeledVehicleController.h:20
float mInertia
Moment of inertia (kg m^2), for a cylinder this would be 0.5 * M * R^2 which is 0....
Definition WheeledVehicleController.h:31
LinearCurve mLateralFriction
On the Y-axis: friction in the sideways direction of the tire. Friction is normally between 0 (no fri...
Definition WheeledVehicleController.h:35
float mMaxBrakeTorque
How much torque (Nm) the brakes can apply to this wheel.
Definition WheeledVehicleController.h:36
float mMaxHandBrakeTorque
How much torque (Nm) the hand brake can apply to this wheel (usually only applied to the rear wheels)...
Definition WheeledVehicleController.h:37
float mAngularDamping
Angular damping factor of the wheel: dw/dt = -c * w. Value should be zero or positive and is usually ...
Definition WheeledVehicleController.h:32
LinearCurve mLongitudinalFriction
On the Y-axis: friction in the forward direction of the tire. Friction is normally between 0 (no fric...
Definition WheeledVehicleController.h:34
WheelSettingsWV()
Constructor.
Definition WheeledVehicleController.cpp:45
float mMaxSteerAngle
How much this wheel can steer (radians).
Definition WheeledVehicleController.h:33
Wheel object specifically for WheeledVehicleController.
Definition WheeledVehicleController.h:42
const WheelSettingsWV * GetSettings() const
Override GetSettings and cast to the correct class.
Definition WheeledVehicleController.h:50
JPH_OVERRIDE_NEW_DELETE WheelWV(const WheelSettingsWV &inWheel)
Constructor.
Definition WheeledVehicleController.cpp:84
float mCombinedLongitudinalFriction
Combined friction coefficient in longitudinal direction (combines terrain and tires).
Definition WheeledVehicleController.h:63
void ApplyTorque(float inTorque, float inDeltaTime)
Apply a torque (N m) to the wheel for a particular delta time.
Definition WheeledVehicleController.h:53
float mLateralSlip
Angular difference (in radians) between ground and wheel relative to ground velocity.
Definition WheeledVehicleController.h:62
float mLongitudinalSlip
Velocity difference between ground and wheel relative to ground velocity.
Definition WheeledVehicleController.h:61
float mCombinedLateralFriction
Combined friction coefficient in lateral direction (combines terrain and tires).
Definition WheeledVehicleController.h:64
float mBrakeImpulse
Amount of impulse that the brakes can apply to the floor (excluding friction).
Definition WheeledVehicleController.h:65
function< void(uint inWheelIndex, float &outLongitudinalImpulse, float &outLateralImpulse, float inSuspensionImpulse, float inLongitudinalFriction, float inLateralFriction, float inLongitudinalSlip, float inLateralSlip, float inDeltaTime)> TireMaxImpulseCallback
Calculate max tire impulses by combining friction, slip, and suspension impulse. Note that the actual...
Definition WheeledVehicleController.h:149
float mHandBrakeInput
Value between 0 and 1 indicating how strong the hand brake is pulled.
Definition WheeledVehicleController.h:181
float mForwardInput
Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving dir...
Definition WheeledVehicleController.h:178
void SetDifferentialLimitedSlipRatio(float inV)
Definition WheeledVehicleController.h:143
void SetForwardInput(float inForward)
Value between -1 and 1 for auto transmission and value between 0 and 1 indicating desired driving dir...
Definition WheeledVehicleController.h:108
VehicleTransmission mTransmission
Transmission state of the vehicle.
Definition WheeledVehicleController.h:185
void SetBrakeInput(float inBrake)
Value between 0 and 1 indicating how strong the brake pedal is pressed.
Definition WheeledVehicleController.h:116
const VehicleTransmission & GetTransmission() const
Get current transmission state.
Definition WheeledVehicleController.h:130
void SetDriverInput(float inForward, float inRight, float inBrake, float inHandBrake)
Definition WheeledVehicleController.h:105
Differentials mDifferentials
Differential states of the vehicle.
Definition WheeledVehicleController.h:186
float GetRightInput() const
Definition WheeledVehicleController.h:113
const VehicleEngine & GetEngine() const
Get current engine state.
Definition WheeledVehicleController.h:124
VehicleEngine mEngine
Engine state of the vehicle.
Definition WheeledVehicleController.h:184
float mRightInput
Value between -1 and 1 indicating desired steering angle.
Definition WheeledVehicleController.h:179
float GetDifferentialLimitedSlipRatio() const
Ratio max / min average wheel speed of each differential (measured at the clutch).
Definition WheeledVehicleController.h:142
void SetRPMMeter(Vec3Arg inPosition, float inSize)
Debug drawing of RPM meter.
Definition WheeledVehicleController.h:155
const Differentials & GetDifferentials() const
Get the differentials this vehicle has.
Definition WheeledVehicleController.h:136
float GetForwardInput() const
Definition WheeledVehicleController.h:109
float GetHandBrakeInput() const
Definition WheeledVehicleController.h:121
void SetHandBrakeInput(float inHandBrake)
Value between 0 and 1 indicating how strong the hand brake is pulled.
Definition WheeledVehicleController.h:120
float mRPMMeterSize
Size of the RPM meter when drawing the constraint.
Definition WheeledVehicleController.h:201
virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const override
Definition WheeledVehicleController.h:166
float mBrakeInput
Value between 0 and 1 indicating how strong the brake pedal is pressed.
Definition WheeledVehicleController.h:180
void SetTireMaxImpulseCallback(const TireMaxImpulseCallback &inTireMaxImpulseCallback)
Definition WheeledVehicleController.h:151
VehicleTransmission & GetTransmission()
Get current transmission state (writable interface, allows you to make changes to the configuration w...
Definition WheeledVehicleController.h:133
TireMaxImpulseCallback mTireMaxImpulseCallback
Definition WheeledVehicleController.h:191
const TireMaxImpulseCallback & GetTireMaxImpulseCallback() const
Definition WheeledVehicleController.h:150
float GetBrakeInput() const
Definition WheeledVehicleController.h:117
float mDifferentialLimitedSlipRatio
Ratio max / min average wheel speed of each differential (measured at the clutch).
Definition WheeledVehicleController.h:187
Differentials & GetDifferentials()
Get the differentials this vehicle has (writable interface, allows you to make changes to the configu...
Definition WheeledVehicleController.h:139
Array< VehicleDifferentialSettings > Differentials
Typedefs.
Definition WheeledVehicleController.h:98
VehicleEngine & GetEngine()
Get current engine state (writable interface, allows you to make changes to the configuration which w...
Definition WheeledVehicleController.h:127
JPH_OVERRIDE_NEW_DELETE WheeledVehicleController(const WheeledVehicleControllerSettings &inSettings, VehicleConstraint &inConstraint)
Constructor.
Definition WheeledVehicleController.cpp:178
float mPreviousDeltaTime
Delta time of the last step.
Definition WheeledVehicleController.h:188
Vec3 mRPMMeterPosition
Position (in local space of the body) of the RPM meter when drawing the constraint.
Definition WheeledVehicleController.h:200
void SetRightInput(float inRight)
Value between -1 and 1 indicating desired steering angle (1 = right).
Definition WheeledVehicleController.h:112
Definition WheeledVehicleController.h:73
Array< VehicleDifferentialSettings > mDifferentials
List of differentials and their properties.
Definition WheeledVehicleController.h:84
VehicleTransmissionSettings mTransmission
The properties of the transmission (aka gear box).
Definition WheeledVehicleController.h:83
VehicleEngineSettings mEngine
The properties of the engine.
Definition WheeledVehicleController.h:82
virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const override
Create an instance of the vehicle controller class.
Definition WheeledVehicleController.cpp:144
float mDifferentialLimitedSlipRatio
Ratio max / min average wheel speed of each differential (measured at the clutch)....
Definition WheeledVehicleController.h:85