31 float mInertia = 0.9f;
32 float mAngularDamping = 0.2f;
36 float mMaxBrakeTorque = 1500.0f;
37 float mMaxHandBrakeTorque = 4000.0f;
55 mAngularVelocity += inTorque * inDeltaTime / GetSettings()->mInertia;
61 float mLongitudinalSlip = 0.0f;
62 float mLateralSlip = 0.0f;
63 float mCombinedLongitudinalFriction = 0.0f;
64 float mCombinedLateralFriction = 0.0f;
65 float mBrakeImpulse = 0.0f;
85 float mDifferentialLimitedSlipRatio = 1.4f;
105 void SetDriverInput(
float inForward,
float inRight,
float inBrake,
float inHandBrake) { mForwardInput = inForward; mRightInput = inRight; mBrakeInput = inBrake; mHandBrakeInput = inHandBrake; }
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
155 void SetRPMMeter(
Vec3Arg inPosition,
float inSize) { mRPMMeterPosition = inPosition; mRPMMeterSize = inSize; }
161 virtual bool AllowSleep()
const override;
162 virtual void PreCollide(
float inDeltaTime,
PhysicsSystem &inPhysicsSystem)
override;
163 virtual void PostCollide(
float inDeltaTime,
PhysicsSystem &inPhysicsSystem)
override;
164 virtual bool SolveLongitudinalAndLateralConstraints(
float inDeltaTime)
override;
165 virtual void SaveState(
StateRecorder &inStream)
const override;
167#ifdef JPH_DEBUG_RENDERER
172 float mForwardInput = 0.0f;
173 float mRightInput = 0.0f;
174 float mBrakeInput = 0.0f;
175 float mHandBrakeInput = 0.0f;
182 float mPreviousDeltaTime = 0.0f;
186 [](
uint,
float &outLongitudinalImpulse,
float &outLateralImpulse,
float inSuspensionImpulse,
float inLongitudinalFriction,
float inLateralFriction, float, float, float)
188 outLongitudinalImpulse = inLongitudinalFriction * inSuspensionImpulse;
189 outLateralImpulse = inLateralFriction * inSuspensionImpulse;
192#ifdef JPH_DEBUG_RENDERER
194 Vec3 mRPMMeterPosition { 0, 1, 0 };
195 float mRPMMeterSize = 0.5f;
#define JPH_EXPORT
Definition Core.h:271
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
#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
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
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 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
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
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
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
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
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
void ApplyTorque(float inTorque, float inDeltaTime)
Apply a torque (N m) to the wheel for a particular delta time.
Definition WheeledVehicleController.h:53
Runtime controller class.
Definition WheeledVehicleController.h:90
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
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:179
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:180
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:178
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
virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const override
Definition WheeledVehicleController.h:160
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
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:181
Differentials & GetDifferentials()
Get the differentials this vehicle has (writable interface, allows you to make changes to the configu...
Definition WheeledVehicleController.h:139
VehicleEngine & GetEngine()
Get current engine state (writable interface, allows you to make changes to the configuration which w...
Definition WheeledVehicleController.h:127
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