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

Base class for runtime data for a wheel, each VehicleController can implement a derived class of this. More...

#include <Wheel.h>

Inheritance diagram for Wheel:
NonCopyable WheelTV WheelWV

Public Member Functions

JPH_OVERRIDE_NEW_DELETE Wheel (const WheelSettings &inSettings)
 Constructor / destructor. More...
 
virtual ~Wheel ()=default
 
const WheelSettingsGetSettings () const
 Get settings for the wheel. More...
 
float GetAngularVelocity () const
 Get the angular velocity (rad/s) for this wheel, note that positive means the wheel is rotating such that the car moves forward. More...
 
void SetAngularVelocity (float inVel)
 Update the angular velocity (rad/s) More...
 
float GetRotationAngle () const
 Get the current rotation angle of the wheel in radians [0, 2 pi]. More...
 
void SetRotationAngle (float inAngle)
 Set the current rotation angle of the wheel in radians [0, 2 pi]. More...
 
float GetSteerAngle () const
 Get the current steer angle of the wheel in radians [-pi, pi], positive is to the left. More...
 
void SetSteerAngle (float inAngle)
 Set the current steer angle of the wheel in radians [-pi, pi]. More...
 
bool HasContact () const
 Returns true if the wheel is touching an object. More...
 
BodyID GetContactBodyID () const
 Returns the body ID of the body that this wheel is touching. More...
 
SubShapeID GetContactSubShapeID () const
 Returns the sub shape ID where we're contacting the body. More...
 
RVec3 GetContactPosition () const
 Returns the current contact position in world space (note by the time you call this the vehicle has moved) More...
 
Vec3 GetContactPointVelocity () const
 Velocity of the contact point (m / s, not relative to the wheel but in world space) More...
 
Vec3 GetContactNormal () const
 Returns the current contact normal in world space (note by the time you call this the vehicle has moved) More...
 
Vec3 GetContactLongitudinal () const
 Returns longitudinal direction (direction along the wheel relative to floor) in world space (note by the time you call this the vehicle has moved) More...
 
Vec3 GetContactLateral () const
 Returns lateral direction (sideways direction) in world space (note by the time you call this the vehicle has moved) More...
 
float GetSuspensionLength () const
 Get the length of the suspension for a wheel (m) relative to the suspension attachment point (hard point) More...
 
bool HasHitHardPoint () const
 Check if the suspension hit its upper limit. More...
 
float GetSuspensionLambda () const
 Get the total impulse (N s) that was applied by the suspension. More...
 
float GetLongitudinalLambda () const
 Get total impulse (N s) applied along the forward direction of the wheel. More...
 
float GetLateralLambda () const
 Get total impulse (N s) applied along the sideways direction of the wheel. More...
 
bool SolveLongitudinalConstraintPart (const VehicleConstraint &inConstraint, float inMinImpulse, float inMaxImpulse)
 Internal function that should only be called by the controller. Used to apply impulses in the forward direction of the vehicle. More...
 
bool SolveLateralConstraintPart (const VehicleConstraint &inConstraint, float inMinImpulse, float inMaxImpulse)
 Internal function that should only be called by the controller. Used to apply impulses in the sideways direction of the vehicle. More...
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Protected Attributes

RefConst< WheelSettingsmSettings
 Configuration settings for this wheel. More...
 
BodyID mContactBodyID
 ID of body for ground. More...
 
SubShapeID mContactSubShapeID
 Sub shape ID for ground. More...
 
BodymContactBody = nullptr
 Body for ground. More...
 
float mSuspensionLength
 Current length of the suspension. More...
 
RVec3 mContactPosition
 Position of the contact point between wheel and ground. More...
 
Vec3 mContactPointVelocity
 Velocity of the contact point (m / s, not relative to the wheel but in world space) More...
 
Vec3 mContactNormal
 Normal of the contact point between wheel and ground. More...
 
Vec3 mContactLongitudinal
 Vector perpendicular to normal in the forward direction. More...
 
Vec3 mContactLateral
 Vector perpendicular to normal and longitudinal direction in the right direction. More...
 
Real mAxlePlaneConstant
 Constant for the contact plane of the axle, defined as ContactNormal . (WorldSpaceSuspensionPoint + SuspensionLength * WorldSpaceSuspensionDirection) More...
 
float mAntiRollBarImpulse = 0.0f
 Amount of impulse applied to the suspension from the anti-rollbars. More...
 
float mSteerAngle = 0.0f
 Rotation around the suspension direction, positive is to the left. More...
 
float mAngularVelocity = 0.0f
 Rotation speed of wheel, positive when the wheels cause the vehicle to move forwards (rad/s) More...
 
float mAngle = 0.0f
 Current rotation of the wheel (rad, [0, 2 pi]) More...
 
AxisConstraintPart mSuspensionPart
 Controls movement up/down along the contact normal. More...
 
AxisConstraintPart mSuspensionMaxUpPart
 Adds a hard limit when reaching the minimal suspension length. More...
 
AxisConstraintPart mLongitudinalPart
 Controls movement forward/backward. More...
 
AxisConstraintPart mLateralPart
 Controls movement sideways (slip) More...
 

Friends

class VehicleConstraint
 

Detailed Description

Base class for runtime data for a wheel, each VehicleController can implement a derived class of this.

Constructor & Destructor Documentation

◆ Wheel()

Wheel::Wheel ( const WheelSettings inSettings)
explicit

Constructor / destructor.

◆ ~Wheel()

virtual Wheel::~Wheel ( )
virtualdefault

Member Function Documentation

◆ GetAngularVelocity()

float Wheel::GetAngularVelocity ( ) const
inline

Get the angular velocity (rad/s) for this wheel, note that positive means the wheel is rotating such that the car moves forward.

◆ GetContactBodyID()

BodyID Wheel::GetContactBodyID ( ) const
inline

Returns the body ID of the body that this wheel is touching.

◆ GetContactLateral()

Vec3 Wheel::GetContactLateral ( ) const
inline

Returns lateral direction (sideways direction) in world space (note by the time you call this the vehicle has moved)

◆ GetContactLongitudinal()

Vec3 Wheel::GetContactLongitudinal ( ) const
inline

Returns longitudinal direction (direction along the wheel relative to floor) in world space (note by the time you call this the vehicle has moved)

◆ GetContactNormal()

Vec3 Wheel::GetContactNormal ( ) const
inline

Returns the current contact normal in world space (note by the time you call this the vehicle has moved)

◆ GetContactPointVelocity()

Vec3 Wheel::GetContactPointVelocity ( ) const
inline

Velocity of the contact point (m / s, not relative to the wheel but in world space)

◆ GetContactPosition()

RVec3 Wheel::GetContactPosition ( ) const
inline

Returns the current contact position in world space (note by the time you call this the vehicle has moved)

◆ GetContactSubShapeID()

SubShapeID Wheel::GetContactSubShapeID ( ) const
inline

Returns the sub shape ID where we're contacting the body.

◆ GetLateralLambda()

float Wheel::GetLateralLambda ( ) const
inline

Get total impulse (N s) applied along the sideways direction of the wheel.

◆ GetLongitudinalLambda()

float Wheel::GetLongitudinalLambda ( ) const
inline

Get total impulse (N s) applied along the forward direction of the wheel.

◆ GetRotationAngle()

float Wheel::GetRotationAngle ( ) const
inline

Get the current rotation angle of the wheel in radians [0, 2 pi].

◆ GetSettings()

const WheelSettings * Wheel::GetSettings ( ) const
inline

Get settings for the wheel.

◆ GetSteerAngle()

float Wheel::GetSteerAngle ( ) const
inline

Get the current steer angle of the wheel in radians [-pi, pi], positive is to the left.

◆ GetSuspensionLambda()

float Wheel::GetSuspensionLambda ( ) const
inline

Get the total impulse (N s) that was applied by the suspension.

◆ GetSuspensionLength()

float Wheel::GetSuspensionLength ( ) const
inline

Get the length of the suspension for a wheel (m) relative to the suspension attachment point (hard point)

◆ HasContact()

bool Wheel::HasContact ( ) const
inline

Returns true if the wheel is touching an object.

◆ HasHitHardPoint()

bool Wheel::HasHitHardPoint ( ) const
inline

Check if the suspension hit its upper limit.

◆ SetAngularVelocity()

void Wheel::SetAngularVelocity ( float  inVel)
inline

Update the angular velocity (rad/s)

◆ SetRotationAngle()

void Wheel::SetRotationAngle ( float  inAngle)
inline

Set the current rotation angle of the wheel in radians [0, 2 pi].

◆ SetSteerAngle()

void Wheel::SetSteerAngle ( float  inAngle)
inline

Set the current steer angle of the wheel in radians [-pi, pi].

◆ SolveLateralConstraintPart()

bool Wheel::SolveLateralConstraintPart ( const VehicleConstraint inConstraint,
float  inMinImpulse,
float  inMaxImpulse 
)

Internal function that should only be called by the controller. Used to apply impulses in the sideways direction of the vehicle.

◆ SolveLongitudinalConstraintPart()

bool Wheel::SolveLongitudinalConstraintPart ( const VehicleConstraint inConstraint,
float  inMinImpulse,
float  inMaxImpulse 
)

Internal function that should only be called by the controller. Used to apply impulses in the forward direction of the vehicle.

Friends And Related Function Documentation

◆ VehicleConstraint

friend class VehicleConstraint
friend

Member Data Documentation

◆ mAngle

float Wheel::mAngle = 0.0f
protected

Current rotation of the wheel (rad, [0, 2 pi])

◆ mAngularVelocity

float Wheel::mAngularVelocity = 0.0f
protected

Rotation speed of wheel, positive when the wheels cause the vehicle to move forwards (rad/s)

◆ mAntiRollBarImpulse

float Wheel::mAntiRollBarImpulse = 0.0f
protected

Amount of impulse applied to the suspension from the anti-rollbars.

◆ mAxlePlaneConstant

Real Wheel::mAxlePlaneConstant
protected

Constant for the contact plane of the axle, defined as ContactNormal . (WorldSpaceSuspensionPoint + SuspensionLength * WorldSpaceSuspensionDirection)

◆ mContactBody

Body* Wheel::mContactBody = nullptr
protected

Body for ground.

◆ mContactBodyID

BodyID Wheel::mContactBodyID
protected

ID of body for ground.

◆ mContactLateral

Vec3 Wheel::mContactLateral
protected

Vector perpendicular to normal and longitudinal direction in the right direction.

◆ mContactLongitudinal

Vec3 Wheel::mContactLongitudinal
protected

Vector perpendicular to normal in the forward direction.

◆ mContactNormal

Vec3 Wheel::mContactNormal
protected

Normal of the contact point between wheel and ground.

◆ mContactPointVelocity

Vec3 Wheel::mContactPointVelocity
protected

Velocity of the contact point (m / s, not relative to the wheel but in world space)

◆ mContactPosition

RVec3 Wheel::mContactPosition
protected

Position of the contact point between wheel and ground.

◆ mContactSubShapeID

SubShapeID Wheel::mContactSubShapeID
protected

Sub shape ID for ground.

◆ mLateralPart

AxisConstraintPart Wheel::mLateralPart
protected

Controls movement sideways (slip)

◆ mLongitudinalPart

AxisConstraintPart Wheel::mLongitudinalPart
protected

Controls movement forward/backward.

◆ mSettings

RefConst<WheelSettings> Wheel::mSettings
protected

Configuration settings for this wheel.

◆ mSteerAngle

float Wheel::mSteerAngle = 0.0f
protected

Rotation around the suspension direction, positive is to the left.

◆ mSuspensionLength

float Wheel::mSuspensionLength
protected

Current length of the suspension.

◆ mSuspensionMaxUpPart

AxisConstraintPart Wheel::mSuspensionMaxUpPart
protected

Adds a hard limit when reaching the minimal suspension length.

◆ mSuspensionPart

AxisConstraintPart Wheel::mSuspensionPart
protected

Controls movement up/down along the contact normal.


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