PxVehicleComponents.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 #ifndef PX_VEHICLE_CORE_COMPONENTS_H
14 #define PX_VEHICLE_CORE_COMPONENTS_H
15 
19 #include "foundation/PxMemory.h"
20 #include "foundation/PxVec3.h"
22 #include "PxVehicleSDK.h"
23 #include "common/PxTypeInfo.h"
24 #include "foundation/PxIO.h"
25 
26 #ifndef PX_DOXYGEN
27 namespace physx
28 {
29 #endif
30 
32 {
33 public:
34 
36 
38  : mMOI(PxVec3(0,0,0)),
39  mMass(1500),
40  mCMOffset(PxVec3(0,0,0))
41  {
42  }
43 
50 
57 
64 
65 private:
66 
68 
69  bool isValid() const;
70 };
72 
74 {
75 public:
76 
77  friend class PxVehicleDriveSimData;
78 
79  enum
80  {
81  eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8
82  };
83 
85  : mMOI(1.0f),
86  mPeakTorque(500.0f),
87  mMaxOmega(600.0f),
88  mDampingRateFullThrottle(0.15f),
89  mDampingRateZeroThrottleClutchEngaged(2.0f),
90  mDampingRateZeroThrottleClutchDisengaged(0.35f)
91  {
92  mTorqueCurve.addPair(0.0f, 0.8f);
93  mTorqueCurve.addPair(0.33f, 1.0f);
94  mTorqueCurve.addPair(1.0f, 0.8f);
95 
96  mRecipMOI=1.0f/mMOI;
97  mRecipMaxOmega=1.0f/mMaxOmega;
98  }
99 
106 
113 
124 
133 
150 
151 
168 
185 
189  PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
190 
194  PX_FORCE_INLINE PxReal getRecipMaxOmega() const {return mRecipMaxOmega;}
195 
196 private:
197 
206 
215 
216  bool isValid() const;
217 
218 
219 //serialization
220 public:
221  PxVehicleEngineData(const PxEMPTY&) : mTorqueCurve(PxEmpty) {}
222 //~serialization
223 };
224 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleEngineData)& 0x0f));
225 
227 {
228 public:
229 
230  friend class PxVehicleDriveSimData;
231 
232  enum Enum
233  {
234  eREVERSE=0,
266  eGEARSRATIO_COUNT
267  };
268 
270  : mFinalRatio(4.0f),
271  mNbRatios(7),
272  mSwitchTime(0.5f)
273  {
274  mRatios[PxVehicleGearsData::eREVERSE]=-4.0f;
275  mRatios[PxVehicleGearsData::eNEUTRAL]=0.0f;
276  mRatios[PxVehicleGearsData::eFIRST]=4.0f;
277  mRatios[PxVehicleGearsData::eSECOND]=2.0f;
278  mRatios[PxVehicleGearsData::eTHIRD]=1.5f;
279  mRatios[PxVehicleGearsData::eFOURTH]=1.1f;
280  mRatios[PxVehicleGearsData::eFIFTH]=1.0f;
281 
283  mRatios[i]=0.f;
284  }
285 
292 
299 
306 
315 
316 private:
317 
319 
320  bool isValid() const;
321 
322 //serialization
323 public:
325  PxReal getGearRatio(PxVehicleGearsData::Enum a) const {return mRatios[a];}
326  void setGearRatio(PxVehicleGearsData::Enum a, PxReal ratio) { mRatios[a] = ratio;}
327 //~serialization
328 };
329 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGearsData)& 0x0f));
330 
332 {
333 public:
334 
335  friend class PxVehicleDriveSimData;
336 
338  {
340  {
341  mUpRatios[i]=0.65f;
342  mDownRatios[i]=0.50f;
343  }
344  //Not sure how important this is but we want to kick out of neutral very quickly.
345  mUpRatios[PxVehicleGearsData::eNEUTRAL]=0.15f;
346  //Set the latency time in an unused element of one of the arrays.
347  mDownRatios[PxVehicleGearsData::eREVERSE]=2.0f;
348  }
349 
359 
369 
381  void setLatency(const PxReal latency)
382  {
383  mDownRatios[PxVehicleGearsData::eREVERSE]=latency;
384  }
385 
393  PxReal getLatency() const
394  {
395  return mDownRatios[PxVehicleGearsData::eREVERSE];
396  }
397 
398 private:
399  bool isValid() const;
400 
401 //serialization
402 public:
404 
405  PxReal getUpRatios(PxVehicleGearsData::Enum a) const {return mUpRatios[a];}
406  void setUpRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mUpRatios[a] = ratio;}
407 
408  PxReal getDownRatios(PxVehicleGearsData::Enum a) const {return mDownRatios[a];}
409  void setDownRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mDownRatios[a] = ratio;}
410 //~serialization
411 };
412 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAutoBoxData)& 0x0f));
413 
415 {
416 public:
417 
419 
420  enum Enum
421  {
422  eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels
423  eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive
424  eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive
425  eDIFF_TYPE_OPEN_4WD, //open differential for car with 4 driven wheels
426  eDIFF_TYPE_OPEN_FRONTWD, //open differential for car with front-wheel drive
427  eDIFF_TYPE_OPEN_REARWD, //open differential for car with rear-wheel drive
428  eMAX_NB_DIFF_TYPES
429  };
430 
432  : mFrontRearSplit(0.45f),
433  mFrontLeftRightSplit(0.5f),
434  mRearLeftRightSplit(0.5f),
435  mCentreBias(1.3f),
436  mFrontBias(1.3f),
437  mRearBias(1.3f),
438  mType(PxVehicleDifferential4WData::eDIFF_TYPE_LS_4WD)
439  {
440  }
441 
450 
459 
468 
478 
488 
498 
505 
506 private:
507 
508  PxReal mPad[1];
509 
510  bool isValid() const;
511 
512 //serialization
513 public:
515 //~serialization
516 };
518 
520 {
521 public:
522 
524  friend class PxVehicleUpdate;
525 
527  {
528  PxMemSet(mBitmapBuffer, 0, sizeof(PxU32) * (((PX_MAX_NB_WHEELS + 31) & ~31) >> 5));
529  mNbDrivenWheels=0;
530  mInvNbDrivenWheels=0.0f;
531  }
532 
540  void setDrivenWheel(const PxU32 wheelId, const bool drivenState);
541 
545  bool getIsDrivenWheel(const PxU32 wheelId) const;
546 
547 private:
548 
549  PxU32 mBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5];
553 
554  bool isValid() const;
555 
556 //serialization
557 public:
559  PxU32 getDrivenWheelStatus() const;
560  void setDrivenWheelStatus(PxU32 status);
561 //~serialization
562 };
564 
565 
567 {
568 public:
569 
571 
573  : mAccuracy(1.0f),
574  mFrontWidth(0.0f), //Must be filled out
575  mRearWidth(0.0f), //Must be filled out
576  mAxleSeparation(0.0f) //Must be filled out
577  {
578  }
579 
596 
605 
614 
623 
624 private:
625 
626  bool isValid() const;
627 
628 //serialization
629 public:
631 //~serialization
632 };
634 
640 {
641  enum Enum
642  {
643  eESTIMATE = 0,
644  eBEST_POSSIBLE
645  };
646 };
647 
649 {
650 public:
651 
652  friend class PxVehicleDriveSimData;
653 
655  : mStrength(10.0f),
656  mAccuracyMode(PxVehicleClutchAccuracyMode::eBEST_POSSIBLE),
657  mEstimateIterations(5)
658  {
659  }
660 
680 
696 
709 
710 private:
711 
712  PxU8 mPad[4];
713 
714  bool isValid() const;
715 
716 //serialization
717 public:
719 //~serialization
720 };
721 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleClutchData)& 0x0f));
722 
723 
747 {
748 public:
749 
751 
753  : mMinNormalisedLoad(0),
754  mMinFilteredNormalisedLoad(0.2308f),
755  mMaxNormalisedLoad(3.0f),
756  mMaxFilteredNormalisedLoad(3.0f)
757  {
758  mDenominator=1.0f/(mMaxNormalisedLoad - mMinNormalisedLoad);
759  }
760 
765 
770 
775 
780 
781  PX_FORCE_INLINE PxReal getDenominator() const {return mDenominator;}
782 
783 private:
784 
788  //1.0f/(mMaxNormalisedLoad-mMinNormalisedLoad) for quick calculations
790 
791  PxU32 mPad[3];
792 
793  bool isValid() const;
794 
795 //serialization
796 public:
798 //~serialization
799 };
801 
803 {
804 public:
805 
806  friend class PxVehicleWheels4SimData;
807 
809  : mRadius(0.0f), //Must be filled out
810  mWidth(0.0f),
811  mMass(20.0f),
812  mMOI(0.0f), //Must be filled out
813  mDampingRate(0.25f),
814  mMaxBrakeTorque(1500.0f),
815  mMaxHandBrakeTorque(0.0f),
816  mMaxSteer(0.0f),
817  mToeAngle(0.0f),
818  mRecipRadius(0.0f), //Must be filled out
819  mRecipMOI(0.0f) //Must be filled out
820  {
821  }
822 
831 
840 
849 
858 
867 
876 
885 
894 
902  PxReal mToeAngle;//in radians
903 
909  PX_FORCE_INLINE PxReal getRecipRadius() const {return mRecipRadius;}
910 
916  PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
917 
918 private:
919 
928 
937 
938  PxReal mPad[1];
939 
940  bool isValid() const;
941 };
942 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelData)& 0x0f));
943 
945 {
946 public:
947 
948  friend class PxVehicleWheels4SimData;
949 
951  : mSpringStrength(0.0f),
952  mSpringDamperRate(0.0f),
953  mMaxCompression(0.3f),
954  mMaxDroop(0.1f),
955  mSprungMass(0.0f),
956  mCamberAtRest(0.0f),
957  mCamberAtMaxCompression(0.0f),
958  mCamberAtMaxDroop(0.0f),
959  mRecipMaxCompression(1.0f),
960  mRecipMaxDroop(1.0f)
961  {
962  }
963 
972 
981 
990 
999 
1032 
1042 
1054 
1066 
1074  PX_FORCE_INLINE PxReal getRecipMaxCompression() const {return mRecipMaxCompression;}
1075 
1083  PX_FORCE_INLINE PxReal getRecipMaxDroop() const {return mRecipMaxDroop;}
1084 
1090  void setMassAndPreserveNaturalFrequency(const PxReal newSprungMass)
1091  {
1092  const PxF32 oldStrength = mSpringStrength;
1093  const PxF32 oldSprungMass = mSprungMass;
1094  const PxF32 newStrength = oldStrength * (newSprungMass / oldSprungMass);
1095  mSpringStrength = newStrength;
1096  mSprungMass = newSprungMass;
1097  }
1098 
1099 private:
1100 
1107 
1114 
1115  //padding
1116  PxReal mPad[2];
1117 
1118  bool isValid() const;
1119 };
1121 
1123 {
1124 public:
1125  friend class PxVehicleWheels4SimData;
1126 
1128  : mLatStiffX(2.0f),
1129  mLatStiffY(0.3125f*(180.0f / PxPi)),
1130  mLongitudinalStiffnessPerUnitGravity(1000.0f),
1131  mCamberStiffnessPerUnitGravity(0.1f*(180.0f / PxPi)),
1132  mType(0)
1133  {
1134  mFrictionVsSlipGraph[0][0]=0.0f;
1135  mFrictionVsSlipGraph[0][1]=1.0f;
1136  mFrictionVsSlipGraph[1][0]=0.1f;
1137  mFrictionVsSlipGraph[1][1]=1.0f;
1138  mFrictionVsSlipGraph[2][0]=1.0f;
1139  mFrictionVsSlipGraph[2][1]=1.0f;
1140 
1141  mRecipLongitudinalStiffnessPerUnitGravity=1.0f/mLongitudinalStiffnessPerUnitGravity;
1142 
1143  mFrictionVsSlipGraphRecipx1Minusx0=1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]);
1144  mFrictionVsSlipGraphRecipx2Minusx1=1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]);
1145  }
1146 
1155 
1172 
1185 
1198 
1232  PxReal mFrictionVsSlipGraph[3][2];
1233 
1242 
1248  PX_FORCE_INLINE PxReal getRecipLongitudinalStiffnessPerUnitGravity() const {return mRecipLongitudinalStiffnessPerUnitGravity;}
1249 
1255  PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx1Minusx0() const {return mFrictionVsSlipGraphRecipx1Minusx0;}
1256 
1262  PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx2Minusx1() const {return mFrictionVsSlipGraphRecipx2Minusx1;}
1263 
1264 private:
1265 
1274 
1283 
1292 
1293  PxReal mPad[2];
1294 
1295  bool isValid() const;
1296 };
1297 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireData)& 0x0f));
1298 #ifndef PX_DOXYGEN
1299 } // namespace physx
1300 #endif
1301 
1303 #endif //PX_VEHICLE_CORE_COMPONENTS_H


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com