33 float mMaxPitchRollAngle = JPH_PI;
143 void GetWheelLocalBasis(
const Wheel *inWheel,
Vec3 &outForward,
Vec3 &outUp,
Vec3 &outRight)
const;
160 virtual void SetupVelocityConstraint(
float inDeltaTime)
override;
161 virtual void WarmStartVelocityConstraint(
float inWarmStartImpulseRatio)
override;
162 virtual bool SolveVelocityConstraint(
float inDeltaTime)
override;
163 virtual bool SolvePositionConstraint(
float inDeltaTime,
float inBaumgarte)
override;
166#ifdef JPH_DEBUG_RENDERER
167 virtual void DrawConstraint(
DebugRenderer *inRenderer)
const override;
168 virtual void DrawConstraintLimits(
DebugRenderer *inRenderer)
const override;
170 virtual void SaveState(
StateRecorder &inStream)
const override;
176 virtual void OnStep(
float inDeltaTime,
PhysicsSystem &inPhysicsSystem)
override;
179 void CalculateSuspensionForcePoint(
const Wheel &inWheel,
Vec3 &outR1PlusU,
Vec3 &outR2)
const;
182 void CalculatePitchRollConstraintProperties(
RMat44Arg inBodyTransform);
192 bool mIsActive =
false;
195 float mCosMaxPitchRollAngle;
196 float mCosPitchRollAngle;
197 Vec3 mPitchRollRotationAxis { 0, 1, 0 };
202 CombineFunction mCombineFriction = [](
float inTireFriction,
const Body &inBody2,
const SubShapeID &) {
return sqrt(inTireFriction * inBody2.GetFriction()); };
205 StepCallback mPreStepCallback;
206 StepCallback mPostCollideCallback;
207 StepCallback mPostStepCallback;
EConstraintSubType
Enum to identify constraint sub type.
Definition Constraint.h:34
#define JPH_EXPORT
Definition Core.h:214
unsigned int uint
Definition Core.h:426
#define JPH_NAMESPACE_END
Definition Core.h:354
std::uint32_t uint32
Definition Core.h:429
#define JPH_NAMESPACE_BEGIN
Definition Core.h:348
std::vector< T, STLAllocator< T > > Array
Definition STLAllocator.h:81
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:100
JPH_INLINE float Cos(float inX)
Cosine of x (input in radians)
Definition Trigonometry.h:20
Array< Wheel * > Wheels
Definition Wheel.h:146
Definition AngleConstraintPart.h:37
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition BodyID.h:13
Class that contains all bodies.
Definition BodyManager.h:32
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rig...
Definition Constraint.h:103
virtual bool IsActive() const
Definition Constraint.h:163
Class used to store the configuration of a constraint. Allows run-time creation of constraints.
Definition Constraint.h:65
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents of the constraint settings in binary form to inStream.
Definition Constraint.cpp:26
virtual void RestoreBinaryState(StreamIn &inStream)
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition Constraint.cpp:36
Simple triangle renderer for debugging purposes.
Definition DebugRenderer.h:30
Keeps track of connected bodies and builds islands for multithreaded velocity/position update.
Definition IslandBuilder.h:19
Definition LargeIslandSplitter.h:24
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
A listener class that receives a callback before every physics simulation step.
Definition PhysicsStepListener.h:13
Definition PhysicsSystem.h:28
Definition Reference.h:151
Definition Reference.h:101
Definition StateRecorder.h:48
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition SubShapeID.h:23
Class that does collision detection between wheels and ground.
Definition VehicleCollisionTester.h:20
Definition VehicleConstraint.h:66
const StepCallback & GetPreStepCallback() const
Definition VehicleConstraint.h:95
const Wheel * GetWheel(uint inIdx) const
Definition VehicleConstraint.h:136
Body * GetVehicleBody() const
Access to the vehicle body.
Definition VehicleConstraint.h:120
virtual bool IsActive() const override
Definition VehicleConstraint.h:158
VehicleController * GetController()
Access to the vehicle controller interface (determines acceleration / decelleration)
Definition VehicleConstraint.h:126
void SetVehicleCollisionTester(const VehicleCollisionTester *inTester)
Set the interface that tests collision between wheel and ground.
Definition VehicleConstraint.h:79
void SetMaxPitchRollAngle(float inMaxPitchRollAngle)
Defines the maximum pitch/roll angle (rad), can be used to avoid the car from getting upside down....
Definition VehicleConstraint.h:76
const StepCallback & GetPostStepCallback() const
Definition VehicleConstraint.h:107
Vec3 GetLocalForward() const
Get the local space forward vector of the vehicle.
Definition VehicleConstraint.h:111
Wheels & GetWheels()
Get the state of a wheels (writable interface, allows you to make changes to the configuration which ...
Definition VehicleConstraint.h:132
Wheel * GetWheel(uint inIdx)
Get the state of a wheel.
Definition VehicleConstraint.h:135
Vec3 GetWorldUp() const
Vector indicating the world space up direction (used to limit vehicle pitch/roll),...
Definition VehicleConstraint.h:117
virtual EConstraintSubType GetSubType() const override
Get the type of a constraint.
Definition VehicleConstraint.h:73
float(*)(float inTireFriction, const Body &inBody2, const SubShapeID &inSubShapeID2) CombineFunction
Callback function to combine the friction of a tire with the friction of the body it is colliding wit...
Definition VehicleConstraint.h:82
Vec3 GetLocalUp() const
Get the local space up vector of the vehicle.
Definition VehicleConstraint.h:114
const StepCallback & GetPostCollideCallback() const
Definition VehicleConstraint.h:101
CombineFunction GetCombineFriction() const
Definition VehicleConstraint.h:87
const VehicleController * GetController() const
Access to the vehicle controller interface (determines acceleration / decelleration)
Definition VehicleConstraint.h:123
void SetPostCollideCallback(const StepCallback &inPostCollideCallback)
Definition VehicleConstraint.h:102
virtual void NotifyShapeChanged(const BodyID &inBodyID, Vec3Arg inDeltaCOM) override
Definition VehicleConstraint.h:159
void SetPreStepCallback(const StepCallback &inPreStepCallback)
Definition VehicleConstraint.h:96
void SetCombineFriction(CombineFunction inCombineFriction)
Definition VehicleConstraint.h:86
const Wheels & GetWheels() const
Get the state of the wheels.
Definition VehicleConstraint.h:129
void SetPostStepCallback(const StepCallback &inPostStepCallback)
Definition VehicleConstraint.h:108
function< void(VehicleConstraint &inVehicle, float inDeltaTime, PhysicsSystem &inPhysicsSystem)> StepCallback
Callback function to notify of current stage in PhysicsStepListener::OnStep.
Definition VehicleConstraint.h:90
Definition VehicleConstraint.h:24
Ref< VehicleControllerSettings > mController
Defines how the vehicle can accelerate / decellerate.
Definition VehicleConstraint.h:36
Array< Ref< WheelSettings > > mWheels
List of wheels and their properties.
Definition VehicleConstraint.h:34
Array< VehicleAntiRollBar > mAntiRollBars
List of anti rollbars and their properties.
Definition VehicleConstraint.h:35
Runtime data for interface that controls acceleration / decelleration of the vehicle.
Definition VehicleController.h:41
Base class for runtime data for a wheel, each VehicleController can implement a derived class of this...
Definition Wheel.h:46