29#ifndef PX_VEHICLE_SUSP_LIMIT_CONSTRAINT_SHADER_H
30#define PX_VEHICLE_SUSP_LIMIT_CONSTRAINT_SHADER_H
35#include "foundation/PxTransform.h"
36#include "extensions/PxConstraintExt.h"
37#include "PxConstraintDesc.h"
38#include "PxConstraint.h"
39#include "vehicle/PxVehicleWheels.h"
59 : mConstraint(constraint),
78 virtual void onComShift(PxU32 actor) { PX_UNUSED(actor); }
89 PxPvdUpdateType::Enum updateType)
const { PX_UNUSED(c); PX_UNUSED(updateType); PX_UNUSED(&pvdConnection);
return true;}
95 mVehicle->onConstraintRelease();
98 virtual void*
getExternalReference(PxU32& typeID) { typeID = PxConstraintExtIDs::eVEHICLE_SUSP_LIMIT_DEPRECATED;
return this; }
102 static PxU32 vehicleSuspLimitConstraintSolverPrep(
105 PxU32 maxConstraints,
107 const void* constantBlock,
114 PX_UNUSED(maxConstraints);
115 PX_UNUSED(body0WorldOffset);
116 PX_UNUSED(bodyBToWorld);
117 PX_ASSERT(bodyAToWorld.
isValid()); PX_ASSERT(bodyBToWorld.
isValid());
119 const VehicleConstraintData* data =
static_cast<const VehicleConstraintData*
>(constantBlock);
121 const PxQuat bodyRotation = bodyAToWorld.q * data->mCMassRotation.getConjugate();
125 cA2w = bodyAToWorld.p;
126 cB2w = bodyBToWorld.p;
129 for(PxU32 i=0;i<4;i++)
131 if(data->mSuspLimitData.mActiveFlags[i])
134 p.linear0 = bodyRotation.
rotate(data->mSuspLimitData.mDirs[i]);
135 p.angular0 = bodyRotation.
rotate(data->mSuspLimitData.mCMOffsets[i].cross(data->mSuspLimitData.mDirs[i]));
136 p.geometricError=data->mSuspLimitData.mErrors[i];
139 p.minImpulse=-FLT_MAX;
148 for(PxU32 i=0;i<4;i++)
150 if(data->mStickyTireForwardData.mActiveFlags[i])
152 Px1DConstraint& p=constraints[numActive];
153 p.linear0=data->mStickyTireForwardData.mDirs[i];
154 p.angular0=data->mStickyTireForwardData.mCMOffsets[i].cross(data->mStickyTireForwardData.mDirs[i]);
155 p.geometricError=0.0f;
157 p.angular1=PxVec3(0);
158 p.minImpulse=-FLT_MAX;
159 p.maxImpulse=FLT_MAX;
160 p.velocityTarget=data->mStickyTireForwardData.mTargetSpeeds[i];
161 p.mods.spring.damping = 1000.0f;
169 for(PxU32 i=0;i<4;i++)
171 if(data->mStickyTireSideData.mActiveFlags[i])
173 Px1DConstraint& p=constraints[numActive];
174 p.linear0=data->mStickyTireSideData.mDirs[i];
175 p.angular0=data->mStickyTireSideData.mCMOffsets[i].cross(data->mStickyTireSideData.mDirs[i]);
176 p.geometricError=0.0f;
178 p.angular1=PxVec3(0);
179 p.minImpulse=-FLT_MAX;
180 p.maxImpulse=FLT_MAX;
181 p.velocityTarget=data->mStickyTireSideData.mTargetSpeeds[i];
182 p.mods.spring.damping = 1000.0f;
193 static void visualiseConstraint(PxConstraintVisualizer &viz,
194 const void* constantBlock,
195 const PxTransform& body0Transform,
196 const PxTransform& body1Transform,
197 PxU32 flags){ PX_UNUSED(&viz); PX_UNUSED(constantBlock); PX_UNUSED(body0Transform);
198 PX_UNUSED(body1Transform); PX_UNUSED(flags);
199 PX_ASSERT(body0Transform.isValid()); PX_ASSERT(body1Transform.isValid()); }
208 bool mActiveFlags[4];
214 PxReal mTargetSpeeds[4];
215 bool mActiveFlags[4];
231 mConstraint = pxConstraint;
239 PxConstraintConnector* getConnector()
265 (
const void* shaderData,
266 const PxF32 tireFriction,
267 const PxF32 longSlip,
const PxF32 latSlip,
const PxF32 camber,
268 const PxF32 wheelOmega,
const PxF32 wheelRadius,
const PxF32 recipWheelRadius,
269 const PxF32 restTireLoad,
const PxF32 normalisedTireLoad,
const PxF32 tireLoad,
270 const PxF32 gravity,
const PxF32 recipGravity,
271 PxF32& wheelTorque, PxF32& tireLongForceMag, PxF32& tireLatForceMag, PxF32& tireAlignMoment);
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
virtual void release()=0
Releases a PxConstraint instance.
Output stream class for I/O.
Definition PxIO.h:114
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotate(const PxVec3 &v) const
Definition PxQuat.h:287
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 PxVehicleSuspLimitConstraintShader.h:47
virtual void * getExternalReference(PxU32 &typeID)
Fetches external data for a constraint.
Definition PxVehicleSuspLimitConstraintShader.h:98
virtual bool updatePvdProperties(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 PxVehicleSuspLimitConstraintShader.h:87
virtual PxBase * getSerializable()
Obtain a reference to a PxBase interface if the constraint has one.
Definition PxVehicleSuspLimitConstraintShader.h:99
virtual PxConstraintSolverPrep getPrep() const
Obtain the shader function pointer used to prep rows for this constraint.
Definition PxVehicleSuspLimitConstraintShader.h:244
virtual const void * getConstantBlock() const
Obtain the pointer to the constraint's constant data.
Definition PxVehicleSuspLimitConstraintShader.h:245
virtual void updateOmniPvdProperties() const
this function is called by the SDK to update OmniPVD's view of it
Definition PxVehicleSuspLimitConstraintShader.h:91
virtual void onOriginShift(const PxVec3 &shift)
Origin shift callback.
Definition PxVehicleSuspLimitConstraintShader.h:80
virtual void onConstraintRelease()
Constraint release callback.
Definition PxVehicleSuspLimitConstraintShader.h:93
virtual void onComShift(PxU32 actor)
Center-of-mass shift callback.
Definition PxVehicleSuspLimitConstraintShader.h:78
virtual void * prepareData()
Pre-simulation data preparation when the constraint is marked dirty, this function is called at the s...
Definition PxVehicleSuspLimitConstraintShader.h:82
Structure containing shader data for each tire of a vehicle and a shader function that computes indiv...
Definition PxVehicleSuspLimitConstraintShader.h:278
const void ** mShaderData
Array of shader data - one data entry per tire. Default values are pointers to PxVehicleTireData (sto...
Definition PxVehicleSuspLimitConstraintShader.h:291
PxVehicleComputeTireForce mShader
Shader function. Default value is PxVehicleComputeTireForceDefault and is set in PxVehicleDriveTank::...
Definition PxVehicleSuspLimitConstraintShader.h:298
Data structure with instanced dynamics data and configuration data of a vehicle with just wheels.
Definition PxVehicleWheels.h:827
Definition PxPvdDataStream.h:241
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
#define PX_INLINE
Definition PxPreprocessor.h:320
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
void PxVehicleComputeTireForceDefault(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)
Default implementation of PxVehicleComputeTireForce.
Definition PxVehicleUpdate.cpp:1984
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
@ eANGULAR_CONSTRAINT
whether this is an angular or linear constraint
Definition PxConstraintDesc.h:71
@ 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
Enum
Definition PxConstraintDesc.h:337
Definition PxVehicleSuspLimitConstraintShader.h:211
Definition PxVehicleSuspLimitConstraintShader.h:204
Definition PxVehicleSuspLimitConstraintShader.h:219