33#include "foundation/PxFoundation.h"
34#include "foundation/PxAssert.h"
35#include "foundation/PxMemory.h"
36#include "foundation/PxVec3.h"
37#include "foundation/PxMat33.h"
39#include "PxVehicleLimits.h"
64 void addAxle(
const PxU32 nbWheelsOnAxle,
const PxU32*
const wheelIdsOnAxle)
66 PX_ASSERT((
nbWheels + nbWheelsOnAxle) < PxVehicleLimits::eMAX_NB_WHEELS);
67 PX_ASSERT(
nbAxles < PxVehicleLimits::eMAX_NB_AXLES);
70 for (PxU32 i = 0; i < nbWheelsOnAxle; i++)
140 PX_CHECK_AND_RETURN_VAL(
nbAxles > 0,
"PxVehicleAxleDescription.nbAxles must be greater than zero",
false);
141 PX_CHECK_AND_RETURN_VAL(
nbWheels > 0,
"PxVehicleAxleDescription.nbWheels must be greater than zero",
false);
153 PX_COMPILE_TIME_ASSERT(PxVehicleLimits::eMAX_NB_AXLES == PxVehicleLimits::eMAX_NB_WHEELS);
188 const PxVec3 basisDirs[6] = {
PxVec3(1,0,0),
PxVec3(-1,0,0),
PxVec3(0,1,0),
PxVec3(0,-1,0),
PxVec3(0,0,1),
PxVec3(0,0,-1) };
195 const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
201 const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
207 const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
213 PX_CHECK_AND_RETURN_VAL(
lngAxis < PxVehicleAxes::eMAX_NB_AXES,
"PxVehicleFrame.lngAxis is invalid",
false);
214 PX_CHECK_AND_RETURN_VAL(
latAxis < PxVehicleAxes::eMAX_NB_AXES,
"PxVehicleFrame.latAxis is invalid",
false);
215 PX_CHECK_AND_RETURN_VAL(
vrtAxis < PxVehicleAxes::eMAX_NB_AXES,
"PxVehicleFrame.vrtAxis is invalid",
false);
216 const PxMat33 frame = getFrame();
217 const PxQuat
quat(frame);
218 PX_CHECK_AND_RETURN_VAL(
quat.isFinite() &&
quat.isUnit() &&
quat.isSane(),
"PxVehicleFrame is not a legal frame",
false);
234 PX_CHECK_AND_RETURN_VAL(
scale > 0.0f,
"PxVehicleScale.scale must be greater than zero",
false);
497 const PxReal scaleRatio = trgScale.
scale / srcScale.
scale;
498 p.minLatSlipDenominator *= scaleRatio;
499 p.minPassiveLongSlipDenominator *= scaleRatio;
500 p.minActiveLongSlipDenominator *= scaleRatio;
506 PX_CHECK_AND_RETURN_VAL(
minLatSlipDenominator > 0.0f,
"PxVehicleTireSlipParams.minLatSlipDenominator must be greater than zero",
false);
507 PX_CHECK_AND_RETURN_VAL(
minPassiveLongSlipDenominator > 0.0f,
"PxVehicleTireSlipParams.minPassiveLongSlipDenominator must be greater than zero",
false);
508 PX_CHECK_AND_RETURN_VAL(
minActiveLongSlipDenominator > 0.0f,
"PxVehicleTireSlipParams.minActiveLongSlipDenominator must be greater than zero",
false);
522 eMAX_NB_PLANAR_DIRECTIONS
571 const PxReal scaleRatio = trgScale.
scale / srcScale.
scale;
572 p.thresholdSpeed *= scaleRatio;
578 PX_CHECK_AND_RETURN_VAL(
thresholdSpeed >= 0.0f,
"PxVehicleTireAxisStickyParams.thresholdSpeed must be greater than or equal to zero",
false);
579 PX_CHECK_AND_RETURN_VAL(
thresholdTime >= 0.0f,
"PxVehicleTireAxisStickyParams.thresholdTime must be greater than or equal to zero",
false);
580 PX_CHECK_AND_RETURN_VAL(
damping >= 0.0f,
"PxVehicleTireAxisStickyParams.damping must be greater than or equal to zero",
false);
611 p.stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL] =
612 stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
613 p.stickyParams[PxVehicleTireDirectionModes::eLATERAL] =
614 stickyParams[PxVehicleTireDirectionModes::eLATERAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
620 if (!
stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].isValid())
622 if (!
stickyParams[PxVehicleTireDirectionModes::eLATERAL].isValid())
712 frame.setToDefault();
713 scale.setToDefault();
715 gravity = frame.getVrtAxis() * (-9.81f * scale.scale);
717 tireSlipParams.setToDefault();
718 tireStickyParams.setToDefault();
726 const PxVehicleFrame& srcFrame,
const PxVehicleFrame& trgFrame,
const PxVehicleScale& srcScale,
const PxVehicleScale& trgScale)
const
728 PxVehicleSimulationContext c = *
this;
729 const PxReal scaleRatio = trgScale.scale / srcScale.scale;
730 c.gravity = trgFrame.getFrame()*srcFrame.getFrame().getTranspose()*c.gravity;
731 c.gravity *= scaleRatio;
732 c.tireSlipParams = tireSlipParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
733 c.tireStickyParams = tireStickyParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
734 c.thresholdForwardSpeedForWheelAngleIntegration *= scaleRatio;
754 PxVehiclePhysXActorUpdateMode::Enum physxActorUpdateMode;
783 PxVehicleSimulationContext::setToDefault();
785 physxUnitCylinderSweepMesh = NULL;
788 physxActorUpdateMode = PxVehiclePhysXActorUpdateMode::eAPPLY_VELOCITY;
798 static_cast<PxVehicleSimulationContext&
>(r) = PxVehicleSimulationContext::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
806template <
class T,
unsigned int NB_ELEMENTS>
818 PxMemCopy(xVals, src.xVals,
sizeof(PxReal)* src.nbDataPairs);
819 PxMemCopy(yVals, src.yVals,
sizeof(T)*src.nbDataPairs);
820 nbDataPairs = src.nbDataPairs;
829 PxMemCopy(xVals, src.xVals,
sizeof(PxReal)*src.nbDataPairs);
830 PxMemCopy(yVals, src.yVals,
sizeof(T)*src.nbDataPairs);
831 nbDataPairs = src.nbDataPairs;
840 PX_CHECK_AND_RETURN_VAL(nbDataPairs < NB_ELEMENTS,
"PxVehicleFixedSizeLookupTable::addPair() exceeded fixed size capacity",
false);
841 xVals[nbDataPairs] = x;
842 yVals[nbDataPairs] = y;
854 if (0 == nbDataPairs)
859 if (1 == nbDataPairs || x < xVals[0])
864 PxReal x0 = xVals[0];
867 for (PxU32 i = 1; i < nbDataPairs; i++)
869 const PxReal x1 = xVals[i];
870 const T y1 = yVals[i];
872 if ((x >= x0) && (x < x1))
874 return (y0 + (y1 - y0) * (x - x0) / (x1 - x0));
881 PX_ASSERT(x >= xVals[nbDataPairs - 1]);
882 return yVals[nbDataPairs - 1];
887 PxMemSet(xVals, 0, NB_ELEMENTS *
sizeof(PxReal));
888 PxMemSet(yVals, 0, NB_ELEMENTS *
sizeof(T));
892 PxReal xVals[NB_ELEMENTS];
893 T yVals[NB_ELEMENTS];
898 for (PxU32 i = 1; i < nbDataPairs; i++)
900 PX_CHECK_AND_RETURN_VAL(xVals[i] > xVals[i - 1],
"PxVehicleFixedSizeLookupTable:: xVals[i+1] must be greater than xVals[i]",
false);
Used to write debug information to an OmniPvdWriteStream.
Definition OmniPvdWriter.h:47
A convex mesh.
Definition PxConvexMesh.h:83
3x3 matrix class
Definition PxMat33.h:91
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
3 Element vector class.
Definition PxVec3.h:50
Express a function as a sequence of points {(x, y)} that form a piecewise polynomial.
Definition PxVehicleParams.h:808
PX_FORCE_INLINE T interpolate(const PxReal x) const
Identify the segment of the piecewise polynomial that includes x and compute the corresponding y valu...
Definition PxVehicleParams.h:852
PX_FORCE_INLINE bool addPair(const PxReal x, const T y)
Add one more point to create one more polynomial segment of a piecewise polynomial.
Definition PxVehicleParams.h:838
qua< float, defaultp > quat
Quaternion of single-precision floating-point numbers.
Definition quaternion_float.hpp:35
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemSet(void *dest, PxI32 c, PxU32 count)
Sets the bytes of the provided buffer to the specified value.
Definition PxMemory.h:67
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83
PX_FORCE_INLINE void * PxMemZero(void *dest, PxU32 count)
Sets the bytes of the provided buffer to zero.
Definition PxMemory.h:53
Helper struct to pass array type data to vehice components and functions.
Definition PxVehicleParams.h:249
T *const * arrayOfPointers
The data stored as an array of pointers.
Definition PxVehicleParams.h:362
PX_FORCE_INLINE T & getData(PxU32 index)
Get the data entry at a given index.
Definition PxVehicleParams.h:298
PX_FORCE_INLINE bool isEmpty() const
Check if declared as empty.
Definition PxVehicleParams.h:343
T * arrayOfStructs
The data stored as an array of structs.
Definition PxVehicleParams.h:361
PX_FORCE_INLINE void setEmpty()
Set as empty.
Definition PxVehicleParams.h:333
PX_FORCE_INLINE void setData(T *data)
Set the data as an array of structs.
Definition PxVehicleParams.h:261
PX_FORCE_INLINE const PxVehicleArrayData< const T > & getConst() const
Get a reference to the array but read only.
Definition PxVehicleParams.h:353
PX_FORCE_INLINE const T & getData(PxU32 index) const
Get the data entry at a given index.
Definition PxVehicleParams.h:317
PX_FORCE_INLINE void setData(T *const *data)
Set the data as an array of pointers.
Definition PxVehicleParams.h:272
DataFormat
Definition PxVehicleParams.h:251
@ eARRAY_OF_STRUCTS
The data is provided as an array of structs and stored in arrayOfStructs.
Definition PxVehicleParams.h:252
@ eARRAY_OF_POINTERS
The data is provided as an array of pointers and stored in arrayOfPointers.
Definition PxVehicleParams.h:253
Definition PxVehicleParams.h:160
Enum
Definition PxVehicleParams.h:162
@ eNegX
The -x axis.
Definition PxVehicleParams.h:164
@ ePosY
The +y axis.
Definition PxVehicleParams.h:165
@ eNegY
The -y axis.
Definition PxVehicleParams.h:166
@ eNegZ
The -z axis.
Definition PxVehicleParams.h:168
@ ePosZ
The +z axis.
Definition PxVehicleParams.h:167
@ ePosX
The +x axis.
Definition PxVehicleParams.h:163
Definition PxVehicleParams.h:53
PX_FORCE_INLINE PxU32 getNbWheels() const
Return the number of wheels on the vehicle.
Definition PxVehicleParams.h:115
PxU32 wheelIdsInAxleOrder[PxVehicleLimits::eMAX_NB_WHEELS]
The list of all wheel ids on the vehicle.
Definition PxVehicleParams.h:149
PX_FORCE_INLINE PxU32 getNbAxles() const
Return the number of axles on the vehicle.
Definition PxVehicleParams.h:83
PxU32 axleToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]
The list of wheel ids for the ith axle begins at wheelIdsInAxleOrder[axleToWheelIds[i]].
Definition PxVehicleParams.h:147
PX_FORCE_INLINE PxU32 getAxle(const PxU32 wheelId) const
Return the axle of a specified wheel.
Definition PxVehicleParams.h:125
PX_FORCE_INLINE PxU32 getNbWheelsOnAxle(const PxU32 i) const
Return the number of wheels on the ith axle.
Definition PxVehicleParams.h:94
void addAxle(const PxU32 nbWheelsOnAxle, const PxU32 *const wheelIdsOnAxle)
Add an axle to the vehicle by specifying the number of wheels on the axle and an array of wheel ids s...
Definition PxVehicleParams.h:64
PxU32 nbAxles
The number of axles on the vehicle.
Definition PxVehicleParams.h:145
PxU32 nbWheelsPerAxle[PxVehicleLimits::eMAX_NB_AXLES]
The number of wheels on each axle.
Definition PxVehicleParams.h:146
PX_FORCE_INLINE PxU32 getWheelOnAxle(const PxU32 j, const PxU32 i) const
Return the wheel id of the jth wheel on the ith axle.
Definition PxVehicleParams.h:106
PxU32 nbWheels
The number of wheels on the vehicle.
Definition PxVehicleParams.h:150
Definition PxVehicleParams.h:174
PxVehicleAxes::Enum vrtAxis
The axis defining the vertical (up) direction of the vehicle.
Definition PxVehicleParams.h:177
PxVehicleAxes::Enum lngAxis
The axis defining the longitudinal (forward) direction of the vehicle.
Definition PxVehicleParams.h:175
PxVehicleAxes::Enum latAxis
The axis defining the lateral (side) direction of the vehicle.
Definition PxVehicleParams.h:176
Determine whether the PhysX actor associated with a vehicle is to be updated with a velocity change o...
Definition PxVehicleParams.h:425
Definition PxVehicleParams.h:742
PxReal physxActorWakeCounterThreshold
Threshold below which to check whether the physx actor wake counter should get reset.
Definition PxVehicleParams.h:778
PxReal physxActorWakeCounterResetValue
Wake counter value to set on the physx actor if a reset is required.
Definition PxVehicleParams.h:768
Definition VhPvdAttributeHandles.h:46
Structure to support Omni PVD, the PhysX Visual Debugger.
Definition PxVehicleParams.h:641
const struct PxVehiclePvdAttributeHandles * attributeHandles
The attribute handles used to reflect vehicle parameter and state data in omnipvd.
Definition PxVehicleParams.h:658
OmniPvdWriter * writer
An instance of OmniPvdWriter used to write vehicle prameter and state data to omnipvd.
Definition PxVehicleParams.h:668
Definition PxVehicleParams.h:224
PxReal scale
The length scale used for the vehicle. For example, if 1.0 is considered meters, then 100....
Definition PxVehicleParams.h:225
Definition PxVehicleParams.h:629
Enum
Definition PxVehicleParams.h:631
@ ePHYSX
The simulation context inherits from PxVehiclePhysXSimulationContext.
Definition PxVehicleParams.h:633
@ eDEFAULT
The simulation context inherits from PxVehicleSimulationContext.
Definition PxVehicleParams.h:632
Definition PxVehicleParams.h:672
PxVehiclePvdContext pvdContext
Structure to support Omni PVD, the PhysX Visual Debugger.
Definition PxVehicleParams.h:701
PxReal thresholdForwardSpeedForWheelAngleIntegration
Forward wheel speed below which the wheel rotation speed gets blended with the rolling speed.
Definition PxVehicleParams.h:696
Definition PxVehicleParams.h:369
PX_FORCE_INLINE void setEmpty()
Set as empty.
Definition PxVehicleParams.h:397
PX_FORCE_INLINE void setDataAndCount(T *data, const PxU32 count)
Set the data as an array of structs and set the number of data entries.
Definition PxVehicleParams.h:376
PX_FORCE_INLINE bool isEmpty() const
Check if declared as empty.
Definition PxVehicleParams.h:408
PX_FORCE_INLINE void setDataAndCount(T *const *data, const PxU32 count)
Set the data as an array of pointers and set the number of data entries.
Definition PxVehicleParams.h:388
The low speed regime often presents numerical difficulties for the tire model due to the potential fo...
Definition PxVehicleParams.h:535
PxReal thresholdSpeed
A tire enters the "sticky tire" regime when it has been below a speed specified by thresholdSpeed for...
Definition PxVehicleParams.h:543
PxReal thresholdTime
A tire enters the "sticky tire" regime when it has been below a speed specified by thresholdSpeed for...
Definition PxVehicleParams.h:552
PxReal damping
The rate at which the velocity constraint approaches zero is controlled by the damping parameter.
Definition PxVehicleParams.h:562
Tires have two important directions for the purposes of tire force computation: longitudinal and late...
Definition PxVehicleParams.h:517
Tire slip values are computed using ratios with potential for divide-by-zero errors....
Definition PxVehicleParams.h:438
PxReal minPassiveLongSlipDenominator
The longitudinal slip represents the difference between the longitudinal speed of the rigid body in t...
Definition PxVehicleParams.h:466
PxReal minLatSlipDenominator
The lateral slip angle is typically computed as a function of the ratio of lateral and longitudinal s...
Definition PxVehicleParams.h:449
PxReal minActiveLongSlipDenominator
The longitudinal slip represents the difference between the longitudinal speed of the rigid body in t...
Definition PxVehicleParams.h:482
For each tire, the forces of the tire model may be replaced by velocity constraints when the tire ent...
Definition PxVehicleParams.h:590
PxVehicleTireAxisStickyParams stickyParams[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]
Definition PxVehicleParams.h:595