34#include "foundation/PxAssert.h"
35#include "foundation/PxTransform.h"
36#include "extensions/PxConstraintExt.h"
38#include "vehicle2/PxVehicleLimits.h"
39#include "vehicle2/tire/PxVehicleTireStates.h"
41#include "PxConstraint.h"
42#include "PxConstraintDesc.h"
63 eNB_DOFS_PER_PXCONSTRAINT = 12,
64 eNB_DOFS_PER_WHEEL = 3,
65 eNB_WHEELS_PER_PXCONSTRAINT = eNB_DOFS_PER_PXCONSTRAINT / eNB_DOFS_PER_WHEEL,
66 eNB_CONSTRAINTS_PER_VEHICLE = (PxVehicleLimits::eMAX_NB_WHEELS + (eNB_WHEELS_PER_PXCONSTRAINT - 1)) / (eNB_WHEELS_PER_PXCONSTRAINT)
96 PxReal
tireDamping[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
137 PxU32 maxConstraints,
139 const void* constantBlock,
145 PX_UNUSED(maxConstraints);
146 PX_UNUSED(body0WorldOffset);
147 PX_UNUSED(bodyBToWorld);
148 PX_ASSERT(bodyAToWorld.
isValid()); PX_ASSERT(bodyBToWorld.
isValid());
150 const PxVehiclePhysXConstraintState* data =
static_cast<const PxVehiclePhysXConstraintState*
>(constantBlock);
155 cA2w = bodyAToWorld.p;
156 cB2w = bodyBToWorld.p;
161 for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
163 if (data[i].suspActiveStatus)
189 p.linear0 = data[i].suspLinear;
190 p.angular0 = data[i].suspAngular;
191 p.geometricError = data[i].suspGeometricError;
195 p.maxImpulse = FLT_MAX;
196 p.velocityTarget = 0;
204 if (data[i].restitution > 0.0f)
207 p.mods.bounce.restitution = data[i].restitution;
208 p.mods.bounce.velocityThreshold = -FLT_MAX;
215 for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
217 if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLONGITUDINAL])
219 Px1DConstraint& p = constraints[numActive];
220 p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLONGITUDINAL];
221 p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLONGITUDINAL];
222 p.geometricError = 0.0f;
223 p.linear1 = PxVec3(0);
224 p.angular1 = PxVec3(0);
225 p.minImpulse = -FLT_MAX;
226 p.maxImpulse = FLT_MAX;
227 p.velocityTarget = 0.0f;
228 p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLONGITUDINAL];
237 for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
239 if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLATERAL])
241 Px1DConstraint& p = constraints[numActive];
242 p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLATERAL];
243 p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLATERAL];
244 p.geometricError = 0.0f;
245 p.linear1 = PxVec3(0);
246 p.angular1 = PxVec3(0);
247 p.minImpulse = -FLT_MAX;
248 p.maxImpulse = FLT_MAX;
249 p.velocityTarget = 0.0f;
250 p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLATERAL];
262(PxConstraintVisualizer &viz,
263 const void* constantBlock,
264 const PxTransform& body0Transform,
265 const PxTransform& body1Transform,
269 PX_UNUSED(constantBlock);
270 PX_UNUSED(body0Transform);
271 PX_UNUSED(body1Transform);
273 PX_ASSERT(body0Transform.isValid());
274 PX_ASSERT(body1Transform.isValid());
297 PX_UNUSED(pvdConnection);
299 PX_UNUSED(updateType);
305 virtual void*
getExternalReference(PxU32& typeID) { typeID = PxConstraintExtIDs::eVEHICLE_JOINT;
return this; }
339 for (PxU32 i = 0; i < PxVehicleLimits::eMAX_NB_WHEELS; i++)
343 for(PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE; i++)
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
This class connects a custom constraint to the SDK.
Definition PxConstraintDesc.h:354
A plugin class for implementing constraints.
Definition PxConstraint.h:100
A padded version of PxVec3, to safely load its data using SIMD.
Definition PxVec3.h:392
3 Element vector class.
Definition PxVec3.h:50
Definition PxPvdDataStream.h:241
Definition PxVehiclePhysXConstraintStates.h:278
virtual PxConstraintSolverPrep getPrep() const
Obtain the shader function pointer used to prep rows for this constraint.
Definition PxVehiclePhysXConstraintStates.h:289
virtual void updateOmniPvdProperties() const
this function is called by the SDK to update OmniPVD's view of it
Definition PxVehiclePhysXConstraintStates.h:302
virtual void onOriginShift(const PxVec3 &shift)
Origin shift callback.
Definition PxVehiclePhysXConstraintStates.h:304
virtual void onConstraintRelease()
Constraint release callback.
Definition PxVehiclePhysXConstraintStates.h:292
virtual void * prepareData()
Pre-simulation data preparation when the constraint is marked dirty, this function is called at the s...
Definition PxVehiclePhysXConstraintStates.h:287
virtual const void * getConstantBlock() const
Obtain the pointer to the constraint's constant data.
Definition PxVehiclePhysXConstraintStates.h:288
virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream &pvdConnection, const PxConstraint *c, PxPvdUpdateType::Enum updateType) const
this function is called by the SDK to update PVD's view of it
Definition PxVehiclePhysXConstraintStates.h:295
virtual void onComShift(PxU32 actor)
Center-of-mass shift callback.
Definition PxVehiclePhysXConstraintStates.h:303
virtual void * getExternalReference(PxU32 &typeID)
Fetches external data for a constraint.
Definition PxVehiclePhysXConstraintStates.h:305
virtual PxBase * getSerializable()
Obtain a reference to a PxBase interface if the constraint has one.
Definition PxVehiclePhysXConstraintStates.h:306
#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
PxU32(* PxConstraintSolverPrep)(Px1DConstraint *constraints, PxVec3p &bodyAWorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale &invMassScale, const void *constantBlock, const PxTransform &bodyAToWorld, const PxTransform &bodyBToWorld, bool useExtendedLimits, PxVec3p &cAtW, PxVec3p &cBtW)
Solver constraint generation shader.
Definition PxConstraintDesc.h:223
PX_FORCE_INLINE void * PxMemZero(void *dest, PxU32 count)
Sets the bytes of the provided buffer to zero.
Definition PxMemory.h:53
@ eANGULAR_CONSTRAINT
whether this is an angular or linear constraint
Definition PxConstraintDesc.h:71
@ eRESTITUTION
whether the restitution model should be applied to generate the target velocity. Mutually exclusive w...
Definition PxConstraintDesc.h:67
@ eACCELERATION_SPRING
whether the constraint is a force or acceleration spring. Only valid if eSPRING is set.
Definition PxConstraintDesc.h:66
@ eSPRING
whether the constraint is a spring. Mutually exclusive with eRESTITUTION. If set, eKEEPBIAS is ignore...
Definition PxConstraintDesc.h:65
A one-dimensional constraint.
Definition PxConstraintDesc.h:134
Struct for specifying mass scaling for a pair of rigids.
Definition PxConstraintDesc.h:184
@ eINEQUALITY
inequality constraints with (0, PX_MAX_FLT) force limits
Definition PxConstraintDesc.h:94
Enum
Definition PxConstraintDesc.h:337
A description of the number of PxConstraintConnector instances per vehicle required to maintain suspe...
Definition PxVehiclePhysXConstraintStates.h:60
PxVehiclePhysXConstraintState is a data structure used to write constraint data to the internal state...
Definition PxVehiclePhysXConstraintStates.h:76
PxVec3 suspAngular
angular component of velocity jacobian in the world frame.
Definition PxVehiclePhysXConstraintStates.h:110
bool tireActiveStatus[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]
a boolean describing whether to trigger a low speed constraint along the tire longitudinal and latera...
Definition PxVehiclePhysXConstraintStates.h:80
PxVec3 suspLinear
linear component of velocity jacobian in the world frame.
Definition PxVehiclePhysXConstraintStates.h:106
bool suspActiveStatus
a boolean describing whether to trigger a suspension limit constraint.
Definition PxVehiclePhysXConstraintStates.h:102
PxReal tireDamping[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]
damping coefficient applied to the tire's longitudinal and lateral velocities.
Definition PxVehiclePhysXConstraintStates.h:96
PxVec3 tireAngulars[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]
angular component of velocity jacobian in world space for the tire's longitudinal and lateral directi...
Definition PxVehiclePhysXConstraintStates.h:88
PxReal restitution
restitution value of the restitution model used to generate a target velocity that will resolve the g...
Definition PxVehiclePhysXConstraintStates.h:125
PxReal suspGeometricError
the excess suspension compression to be resolved by the constraint that cannot be resolved due to the...
Definition PxVehiclePhysXConstraintStates.h:118
PxVec3 tireLinears[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]
linear component of velocity jacobian in world space for the tire's longitudinal and lateral directio...
Definition PxVehiclePhysXConstraintStates.h:84
A mapping between constraint state data and the associated PxConstraint instances.
Definition PxVehiclePhysXConstraintStates.h:317
PxVehicleConstraintConnector * constraintConnectors[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE]
A constraint connector is necessary to connect each PxConstraint to a portion of the constraintStates...
Definition PxVehiclePhysXConstraintStates.h:335
PxVehiclePhysXConstraintState constraintStates[PxVehicleLimits::eMAX_NB_WHEELS]
PxVehiclePhysXConstraintComponent writes to the constraintStates array and a callback invoked by PxSc...
Definition PxVehiclePhysXConstraintStates.h:323
PxConstraint * constraints[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE]
PxVehiclePhysXConstraintComponent writes to the constraintStates array and a callback invoked by PxSc...
Definition PxVehiclePhysXConstraintStates.h:330