RavEngine
Loading...
Searching...
No Matches
PxVehicleSuspWheelTire4.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_VEHICLE_SUSP_WHEEL_TIRE4_H
30#define PX_VEHICLE_SUSP_WHEEL_TIRE4_H
35#include "foundation/PxSimpleTypes.h"
36#include "foundation/PxVec3.h"
37#include "foundation/PxVec4.h"
38#include "foundation/PxTransform.h"
39#include "foundation/PxIO.h"
40#include "geometry/PxGeometryHelpers.h"
41#include "vehicle/PxVehicleComponents.h"
42#include "PxVehicleSuspLimitConstraintShader.h"
43#include "extensions/PxSceneQueryExt.h"
44
45#if !PX_DOXYGEN
46namespace physx
47{
48#endif
49
50class PxMaterial;
51class PxShape;
52
54{
55//= ATTENTION! =====================================================================================
56// Changing the data layout of this class breaks the binary serialization format. See comments for
57// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
58// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
59// accordingly.
60//==================================================================================================
61public:
62
63 friend class PxVehicleUpdate;
64
66
67 bool isValid(const PxU32 id) const;
68
69 static void getBinaryMetaData(PxOutputStream& stream);
70
71public:
72
73 PX_FORCE_INLINE const PxVehicleSuspensionData& getSuspensionData(const PxU32 id) const {return mSuspensions[id];}
74 PX_FORCE_INLINE const PxVehicleWheelData& getWheelData(const PxU32 id) const {return mWheels[id];}
75 PX_FORCE_INLINE const PxVehicleTireData& getTireData(const PxU32 id) const {return mTires[id];}
76 PX_FORCE_INLINE const PxVec3& getSuspTravelDirection(const PxU32 id) const {return mSuspDownwardTravelDirections[id];}
77 PX_FORCE_INLINE const PxVec3& getSuspForceAppPointOffset(const PxU32 id) const {return mSuspForceAppPointOffsets[id];}
78 PX_FORCE_INLINE const PxVec3& getTireForceAppPointOffset(const PxU32 id) const {return mTireForceAppPointOffsets[id];}
79 PX_FORCE_INLINE const PxVec3& getWheelCentreOffset(const PxU32 id) const {return mWheelCentreOffsets[id];}
80 PX_FORCE_INLINE PxI32 getWheelShapeMapping(const PxU32 id) const {return (PX_MAX_U8 != mWheelShapeMap[id]) ? mWheelShapeMap[id] : -1;}
81 PX_FORCE_INLINE const PxFilterData& getSceneQueryFilterData(const PxU32 id) const {return mSqFilterData[id];}
82 PX_FORCE_INLINE const PxReal* getTireRestLoadsArray() const {return mTireRestLoads;}
83 PX_FORCE_INLINE const PxReal* getRecipTireRestLoadsArray() const {return mRecipTireRestLoads;}
84
85 void setSuspensionData (const PxU32 id, const PxVehicleSuspensionData& susp);
86 void setWheelData (const PxU32 id, const PxVehicleWheelData& susp);
87 void setTireData (const PxU32 id, const PxVehicleTireData& tire);
88 void setSuspTravelDirection (const PxU32 id, const PxVec3& dir);
89 void setSuspForceAppPointOffset (const PxU32 id, const PxVec3& offset);
90 void setTireForceAppPointOffset (const PxU32 id, const PxVec3& offset);
91 void setWheelCentreOffset (const PxU32 id, const PxVec3& offset);
92 void setWheelShapeMapping (const PxU32 id, const PxI32 shapeId);
93 void setSceneQueryFilterData (const PxU32 id, const PxFilterData& sqFilterData);
94
95private:
96
101 PxVehicleSuspensionData mSuspensions[4];
102
107 PxVehicleWheelData mWheels[4];
108
113 PxVehicleTireData mTires[4];
114
118 PxVec3 mSuspDownwardTravelDirections[4];
119
123 PxVec3 mSuspForceAppPointOffsets[4]; //Offset from cm
124
128 PxVec3 mTireForceAppPointOffsets[4]; //Offset from cm
129
133 PxVec3 mWheelCentreOffsets[4]; //Offset from cm
134
138 PxReal mTireRestLoads[4];
139
143 PxReal mRecipTireRestLoads[4];
144
149 PxFilterData mSqFilterData[4];
150
160 PxU8 mWheelShapeMap[4];
161
162 PxU32 mPad[3];
163};
165
167{
168//= ATTENTION! =====================================================================================
169// Changing the data layout of this class breaks the binary serialization format. See comments for
170// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
171// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
172// accordingly.
173//==================================================================================================
174public:
175
176 friend class PxVehicleUpdate;
177
179 : mRaycastResults(NULL),
180 mSweepResults(NULL)
181 {
182 setToRestState();
183 }
185 {
186 }
187
188 bool isValid() const {return true;}
189
190 static void getBinaryMetaData(PxOutputStream& stream);
191
192 void setToRestState()
193 {
194 for(PxU32 i=0;i<4;i++)
195 {
196 mWheelSpeeds[i] = 0.0f;
197 mCorrectedWheelSpeeds[i] = 0.0f;
198 mWheelRotationAngles[i] = 0.0f;
200 mTireLowSideSpeedTimers[i] = 0.0f;
201 mJounces[i] = PX_MAX_F32;
202 mSteerAngles[i] = 0.0f;
203 mVehicleConstraints->mData.mStickyTireForwardData.mActiveFlags[i] = false;
204 mVehicleConstraints->mData.mStickyTireSideData.mActiveFlags[i] = false;
205 mVehicleConstraints->mData.mSuspLimitData.mActiveFlags[i] = false;
206 }
208
209 mRaycastResults = NULL;
210 mSweepResults = NULL;
212 }
213
214 void setInternalDynamicsToZero()
215 {
216 for(PxU32 i=0;i<4;i++)
217 {
218 mWheelSpeeds[i] = 0.0f;
219 mCorrectedWheelSpeeds[i] = 0.0f;
220 mJounces[i] = PX_MAX_F32; //Ensure that the jounce speed is zero when the car wakes up again.
221 mSteerAngles[i] = 0.0f;
222 }
223 }
224
225 void setTireContacts(const PxU32* cachedHitCounts, const PxPlane* cachedHitPlanes, const PxF32* cachedFrictionMultipliers, const PxTireContactIntersectionMethod::Enum* cachedQueryTypes)
226 {
228 mRaycastResults = NULL;
229 mSweepResults = NULL;
230
233
234 for (PxU32 i = 0; i < 4; i++)
235 {
236 cachedRaycastHitResults->mCounts[i] = PxU16(cachedHitCounts[i]);
237 cachedRaycastHitResults->mPlanes[i] = cachedHitPlanes[i];
238 cachedRaycastHitResults->mDistances[i] = 1.0f;
239 cachedRaycastHitResults->mFrictionMultipliers[i] = cachedFrictionMultipliers[i];
240 cachedRaycastHitResults->mQueryTypes[i] = ((cachedQueryTypes[i] == PxTireContactIntersectionMethod::eRAY) ? 0 : 1);
241 }
242 }
243
248 PxReal mWheelSpeeds[4];
249
254
260
266
272
277 PxReal mJounces[4];
278
283 PxReal mSteerAngles[4];
284
311
313 {
319
325
330 PxReal mLengths[4];
331
332 PxU32 mPad[16];
333 };
334
336 {
342
348
352 PxF32 mDistances[4];
353
358 PxU16 mCounts[4];
359
363 PxU16 mQueryTypes[4];
364
365 PxU32 mPad1[16];
366 };
367
372
376 void setVehicleConstraintShader(PxVehicleConstraintShader* shader) {mVehicleConstraints=shader;}
377 PxVehicleConstraintShader& getVehicletConstraintShader() const {return *mVehicleConstraints;}
378
379private:
380
381 //Susp limits and sticky tire friction for all wheels.
382 PxVehicleConstraintShader* mVehicleConstraints;
383
384public:
385
391
397
404
405
406#if PX_P64_FAMILY
407 PxU32 mPad[12];
408#endif
409};
414
415#if !PX_DOXYGEN
416} // namespace physx
417#endif
418
420#endif
Geometry holder class.
Definition PxGeometryHelpers.h:66
Output stream class for I/O.
Definition PxIO.h:114
Representation of a plane.
Definition PxPlane.h:49
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Definition PxVehicleSuspLimitConstraintShader.h:47
Definition PxVehicleComponents.h:957
Definition PxVehicleComponents.h:1176
Definition PxVehicleUpdate.cpp:4519
Definition PxVehicleComponents.h:815
Definition PxVehicleSuspWheelTire4.h:167
PxReal mWheelRotationAngles[4]
Reported rotation angle about rolling axis.
Definition PxVehicleSuspWheelTire4.h:259
PxReal mSteerAngles[4]
Previous steer angle.
Definition PxVehicleSuspWheelTire4.h:283
PxReal mWheelSpeeds[4]
Rotation speeds of wheels.
Definition PxVehicleSuspWheelTire4.h:248
const PxSweepBuffer * mSweepResults
Set by PxVehicleSuspensionSweeps.
Definition PxVehicleSuspWheelTire4.h:396
const PxRaycastBuffer * mRaycastResults
Set by PxVehicleSuspensionRaycasts.
Definition PxVehicleSuspWheelTire4.h:390
void setVehicleConstraintShader(PxVehicleConstraintShader *shader)
Used only internally.
Definition PxVehicleSuspWheelTire4.h:376
PxU8 mQueryOrCachedHitResults[sizeof(SuspLineSweep)]
We either have a fresh raycast that was just performed or a cached raycast result that will be used i...
Definition PxVehicleSuspWheelTire4.h:371
PxReal mTireLowForwardSpeedTimers[4]
Timers used to trigger sticky friction to hold the car perfectly at rest.
Definition PxVehicleSuspWheelTire4.h:265
PxReal mCorrectedWheelSpeeds[4]
Rotation speeds of wheels used to update the wheel rotation angles.
Definition PxVehicleSuspWheelTire4.h:253
PxReal mJounces[4]
Previous suspension jounce.
Definition PxVehicleSuspWheelTire4.h:277
PxReal mTireLowSideSpeedTimers[4]
Timers used to trigger sticky friction to hold the car perfectly at rest.
Definition PxVehicleSuspWheelTire4.h:271
bool mHasCachedRaycastHitPlane
Set true if a raycast hit plane has been recorded and cached. This requires a raycast to be performed...
Definition PxVehicleSuspWheelTire4.h:403
Definition PxVehicleSuspWheelTire4.h:54
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemZero(void *dest, PxU32 count)
Sets the bytes of the provided buffer to zero.
Definition PxMemory.h:53
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
PxU16 mCounts[4]
Cached raycast hit counts. These are the hit counts found from the last scene queries.
Definition PxVehicleSuspWheelTire4.h:358
PxF32 mDistances[4]
Cached raycast hit distance. These are the hit distances found from the last scene queries.
Definition PxVehicleSuspWheelTire4.h:352
PxU16 mQueryTypes[4]
Store 0 if cached results are from raycasts, store 1 if cached results are from sweeps.
Definition PxVehicleSuspWheelTire4.h:363
PxPlane mPlanes[4]
Cached raycast hit planes. These are the planes found from the last scene queries.
Definition PxVehicleSuspWheelTire4.h:341
PxF32 mFrictionMultipliers[4]
Cached friction.
Definition PxVehicleSuspWheelTire4.h:347
Definition PxVehicleSuspWheelTire4.h:313
PxVec3 mDirs[4]
Directions of suspension line raycasts used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:324
PxReal mLengths[4]
Lengths of suspension line raycasts used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:330
PxVec3 mStarts[4]
Start point of suspension line raycasts used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:318
Definition PxVehicleSuspWheelTire4.h:286
PxTransform mStartPose[4]
Start poses of suspension line sweep used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:297
PxVec3 mDirs[4]
Directions of suspension line sweeps used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:303
PxReal mLengths[4]
Lengths of suspension line sweeps used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:309
PxGeometryHolder mGometries[4]
Geometry suspension line sweep used in most recent scene query.
Definition PxVehicleSuspWheelTire4.h:291