29#ifndef PX_VEHICLE_WHEELS_H
30#define PX_VEHICLE_WHEELS_H
32#include "foundation/PxSimpleTypes.h"
33#include "vehicle/PxVehicleShaders.h"
34#include "vehicle/PxVehicleComponents.h"
35#include "common/PxBase.h"
36#include "PxRigidDynamic.h"
43class PxVehicleWheels4SimData;
44class PxVehicleWheels4DynData;
45class PxVehicleTireForceCalculator;
70 eLIMIT_SUSPENSION_EXPANSION_VELOCITY = (1 << 0),
83 eDISABLE_INTERNAL_CYLINDER_PLANE_INTERSECTION_TEST = (1 << 1),
102 eDISABLE_SUSPENSION_FORCE_PROJECTION = (1 << 2),
112 eDISABLE_SPRUNG_MASS_SUM_CHECK = (1 << 3)
163 void setChassisMass(
const PxF32 chassisMass);
209 const PxVec3& getSuspTravelDirection(
const PxU32
id)
const;
215 const PxVec3& getSuspForceAppPointOffset(
const PxU32
id)
const;
221 const PxVec3& getTireForceAppPointOffset(
const PxU32
id)
const;
226 const PxVec3& getWheelCentreOffset(
const PxU32
id)
const;
237 PxI32 getWheelShapeMapping(
const PxU32 wheelId)
const;
242 const PxFilterData& getSceneQueryFilterData(
const PxU32 suspId)
const;
250 return mNbActiveAntiRollBars;
268 return mNormalisedLoadFilter;
297 void setSuspTravelDirection(
const PxU32
id,
const PxVec3& dir);
305 void setSuspForceAppPointOffset(
const PxU32
id,
const PxVec3& offset);
313 void setTireForceAppPointOffset(
const PxU32
id,
const PxVec3& offset);
321 void setWheelCentreOffset(
const PxU32
id,
const PxVec3& offset);
343 void setWheelShapeMapping(
const PxU32 wheelId,
const PxI32 shapeId);
352 void setSceneQueryFilterData(
const PxU32 suspId,
const PxFilterData& sqFilterData);
414 void disableWheel(
const PxU32 wheel);
422 void enableWheel(
const PxU32 wheel);
428 bool getIsWheelDisabled(
const PxU32 wheel)
const;
460 void setSubStepCount(
const PxReal thresholdLongitudinalSpeed,
const PxU32 lowForwardSpeedSubStepCount,
const PxU32 highForwardSpeedSubStepCount);
478 void setMinLongSlipDenominator(
const PxReal minLongSlipDenominator);
521 PxU32 mNbActiveWheels;
531 PxU32 mNbAntiRollBars4;
536 PxU32 mNbActiveAntiRollBars;
542 PxU32 mActiveWheelsBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5];
549 PxF32 mThresholdLongitudinalSpeed;
555 PxU32 mLowForwardSpeedSubStepCount;
561 PxU32 mHighForwardSpeedSubStepCount;
566 PxF32 mMinLongSlipDenominator;
582 bool isValid()
const;
587 static PxU32 computeByteSize(
const PxU32 numWheels);
594 static void getBinaryMetaData(PxOutputStream& stream);
595 PxU32 getNbWheels4()
const {
return mNbWheels4; }
596 PxU32 getNbSuspensionData()
const {
return mNbActiveWheels; }
597 PxU32 getNbWheelData()
const {
return mNbActiveWheels; }
598 PxU32 getNbSuspTravelDirection()
const {
return mNbActiveWheels; }
599 PxU32 getNbTireData()
const {
return mNbActiveWheels; }
600 PxU32 getNbSuspForceAppPointOffset()
const {
return mNbActiveWheels; }
601 PxU32 getNbTireForceAppPointOffset()
const {
return mNbActiveWheels; }
602 PxU32 getNbWheelCentreOffset()
const {
return mNbActiveWheels; }
603 PxU32 getNbWheelShapeMapping()
const {
return mNbActiveWheels; }
604 PxU32 getNbSceneQueryFilterData()
const {
return mNbActiveWheels; }
605 PxF32 getMinLongSlipDenominator()
const {
return mMinLongSlipDenominator;}
606 void setThresholdLongSpeed(
const PxF32 f) {mThresholdLongitudinalSpeed = f;}
607 PxF32 getThresholdLongSpeed()
const {
return mThresholdLongitudinalSpeed;}
608 void setLowForwardSpeedSubStepCount(
const PxU32 f) {mLowForwardSpeedSubStepCount = f;}
609 PxU32 getLowForwardSpeedSubStepCount()
const {
return mLowForwardSpeedSubStepCount;}
610 void setHighForwardSpeedSubStepCount(
const PxU32 f) {mHighForwardSpeedSubStepCount = f;}
611 PxU32 getHighForwardSpeedSubStepCount()
const {
return mHighForwardSpeedSubStepCount;}
612 void setWheelEnabledState(
const PxU32 wheel,
const bool state) {
if(state) {enableWheel(wheel);}
else {disableWheel(wheel);}}
613 bool getWheelEnabledState(
const PxU32 wheel)
const {
return !getIsWheelDisabled(wheel);}
614 PxU32 getNbWheelEnabledState()
const {
return mNbActiveWheels;}
615 PxU32 getNbAntiRollBars4()
const {
return mNbAntiRollBars4; }
616 PxU32 getNbAntiRollBarData()
const {
return mNbActiveAntiRollBars;}
617 void setAntiRollBarData(
const PxU32
id,
const PxVehicleAntiRollBarData& antiRoll);
618 PxVehicleWheelsSimData(){}
619 ~PxVehicleWheelsSimData(){}
662 void setToRestState();
675 void setTireForceShaderData(
const PxU32 tireId,
const void* tireForceShaderData);
680 const void* getTireForceShaderData(
const PxU32 tireId)
const;
687 void setWheelRotationSpeed(
const PxU32 wheelIdx,
const PxReal speed);
692 PxReal getWheelRotationSpeed(
const PxU32 wheelIdx)
const;
699 void setWheelRotationAngle(
const PxU32 wheelIdx,
const PxReal angle);
704 PxReal getWheelRotationAngle(
const PxU32 wheelIdx)
const;
712 void setUserData(
const PxU32 tireIdx,
void* userData);
717 void* getUserData(
const PxU32 tireIdx)
const;
743 void setTireContacts(
const PxU32* nbHits,
const PxPlane* contactPlanes,
const PxReal* contactFrictions,
const PxTireContactIntersectionMethod::Enum* intersectionMethods,
const PxU32 nbWheels);
755 bool isValid()
const;
776 PxU32 mNbActiveWheels;
783 static PxU32 computeByteSize(
const PxU32 numWheels);
790 PxU32 getNbWheelRotationSpeed()
const {
return mNbActiveWheels; }
791 PxU32 getNbWheelRotationAngle()
const {
return mNbActiveWheels; }
818 PxU32 getConstraints(
PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0)
const;
888 void setToRestState();
893 bool isValid()
const;
898 static PxU32 computeByteSize(
const PxU32 nbWheels);
899 static PxU8* patchupPointers(
const PxU32 nbWheels,
PxVehicleWheels* vehWheels, PxU8* ptr);
900 virtual void init(
const PxU32 numWheels);
911 void onConstraintRelease();
919 const PxU32 nbDrivenWheels,
const PxU32 nbNonDrivenWheels);
932 PxU32 mNbNonDrivenWheels;
934 PxU8 mOnConstraintReleaseCounter;
953 virtual bool isKindOf(
const char* name)
const {
return !::strcmp(
"PxVehicleWheels", name) || PxBase::isKindOf(name); }
954 virtual void preExportDataReset() {}
955 virtual void exportExtraData(PxSerializationContext&);
956 void importExtraData(PxDeserializationContext&);
957 void resolveReferences(PxDeserializationContext&);
958 static void getBinaryMetaData(PxOutputStream& stream);
959 PX_FORCE_INLINE PxU32 getNbNonDrivenWheels()
const {
return mNbNonDrivenWheels; }
960 PxVehicleWheels(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
961 PxVehicleWheels(PxBaseFlags baseFlags) : PxBase(baseFlags), mWheelsSimData(PxEmpty) {}
962 virtual ~PxVehicleWheels() {}
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
A plugin class for implementing constraints.
Definition PxConstraint.h:100
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
Output stream class for I/O.
Definition PxIO.h:114
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition PxPhysics.h:91
Representation of a plane.
Definition PxPlane.h:49
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
Definition PxRigidDynamic.h:82
3 Element vector class.
Definition PxVec3.h:50
Definition PxVehicleComponents.h:1136
Definition PxVehicleSuspLimitConstraintShader.h:47
Data structure with instanced dynamics data and configuration data of a vehicle with up to 4 driven w...
Definition PxVehicleDrive4W.h:173
Data structure with instanced dynamics data and configuration data of a tank.
Definition PxVehicleDriveTank.h:147
Data structure with instanced dynamics data and configuration data of a vehicle with no drive model.
Definition PxVehicleNoDrive.h:53
Definition PxVehicleComponents.h:957
Definition PxVehicleComponents.h:1176
Structure containing shader data for each tire of a vehicle and a shader function that computes indiv...
Definition PxVehicleSuspLimitConstraintShader.h:278
Tire load variation can be strongly dependent on the time-step so it is a good idea to filter it to g...
Definition PxVehicleComponents.h:759
Definition PxVehicleUpdate.cpp:4519
Definition PxVehicleComponents.h:815
Definition PxVehicleSuspWheelTire4.h:167
Definition PxVehicleSuspWheelTire4.h:54
Data structure with instanced dynamics data for wheels.
Definition PxVehicleWheels.h:641
PxU32 getNbConstraints() const
Retrieve the number of PxConstraint objects associated with the vehicle.
Definition PxVehicleWheels.h:804
Data structure describing configuration data of a vehicle with up to 20 wheels.
Definition PxVehicleWheels.h:129
PxU32 getNbWheels() const
Return the number of wheels.
Definition PxVehicleWheels.h:189
PxU32 getNbAntiRollBars() const
Return the number of unique anti-roll bars that have been added with addAntiRollBarData.
Definition PxVehicleWheels.h:248
PX_FORCE_INLINE const PxVehicleTireLoadFilterData & getTireLoadFilterData() const
Return the data that describes the filtering of the tire load to produce smoother handling at large t...
Definition PxVehicleWheels.h:266
Data structure with instanced dynamics data and configuration data of a vehicle with just wheels.
Definition PxVehicleWheels.h:827
PX_FORCE_INLINE const PxRigidDynamic * getRigidDynamicActor() const
Get const ptr to PxRigidDynamic instance that is the vehicle's physx representation.
Definition PxVehicleWheels.h:853
PX_FORCE_INLINE PxRigidDynamic * getRigidDynamicActor()
Get non-const ptr to PxRigidDynamic instance that is the vehicle's physx representation.
Definition PxVehicleWheels.h:848
virtual void release()
Releases the PxBase instance, please check documentation of release in derived class.
Definition PxVehicleWheels.h:963
PxVehicleWheelsDynData mWheelsDynData
Data describing the dynamic state of all wheels/suspension/tires.
Definition PxVehicleWheels.h:881
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxVehicleWheels.h:953
PX_FORCE_INLINE PxU32 getVehicleType() const
Return the type of vehicle.
Definition PxVehicleWheels.h:843
PxU8 mType
Vehicle type (eVehicleDriveTypes)
Definition PxVehicleWheels.h:941
PxVehicleWheelsSimData mWheelsSimData
Data describing the setup of all the wheels/suspensions/tires.
Definition PxVehicleWheels.h:876
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition PxVehicleWheels.h:952
PxRigidDynamic * mActor
The rigid body actor that represents the vehicle in the PhysX SDK.
Definition PxVehicleWheels.h:924
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_DEPRECATED typedef void(* PxVehicleComputeTireForce)(const void *shaderData, const PxF32 tireFriction, const PxF32 longSlip, const PxF32 latSlip, const PxF32 camber, const PxF32 wheelOmega, const PxF32 wheelRadius, const PxF32 recipWheelRadius, const PxF32 restTireLoad, const PxF32 normalisedTireLoad, const PxF32 tireLoad, const PxF32 gravity, const PxF32 recipGravity, PxF32 &wheelTorque, PxF32 &tireLongForceMag, PxF32 &tireLatForceMag, PxF32 &tireAlignMoment)
Prototype of shader function that is used to compute wheel torque and tire forces.
Definition PxVehicleShaders.h:61
PX_DEPRECATED const PxVehicleContext & PxVehicleGetDefaultContext()
Get the default vehicle context.
Definition PxVehicleUpdate.cpp:120
PxEMPTY
Definition Px.h:87
PxFlags< PxVehicleWheelsSimFlag::Enum, PxU32 > PxVehicleWheelsSimFlags
Collection of set bits defined in #PxVehicleWheelsSimFlag.
Definition PxVehicleWheels.h:121
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Flags to configure the vehicle wheel simulation.
Definition PxVehicleWheels.h:56
Enum
Definition PxVehicleWheels.h:58