RavEngine
Loading...
Searching...
No Matches
PxVehicleSDK.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_SDK_H
30#define PX_VEHICLE_SDK_H
31
32#include "foundation/Px.h"
33#include "foundation/PxVec3.h"
34#include "common/PxTypeInfo.h"
35
36#if !PX_DOXYGEN
37namespace physx
38{
39#endif
40
41class PxPhysics;
42class PxSerializationRegistry;
43
57PX_DEPRECATED PX_C_EXPORT bool PX_CALL_CONV PxInitVehicleSDK(PxPhysics& physics, PxSerializationRegistry* serializationRegistry = NULL);
58
59
72PX_DEPRECATED PX_C_EXPORT void PX_CALL_CONV PxCloseVehicleSDK(PxSerializationRegistry* serializationRegistry = NULL);
73
74
78#define PX_MAX_NB_WHEELS (20)
79
80
86#define PX_DEBUG_VEHICLE_ON (1)
87
88
93{
94 enum Enum
95 {
96 eDRIVE4W=0,
97 eDRIVENW,
98 eDRIVETANK,
99 eNODRIVE,
100 eUSER1,
101 eUSER2,
102 eUSER3,
103 eMAX_NB_VEHICLE_TYPES
104 };
105};
106
107
114{
115 enum Enum
116 {
117 eVehicleNoDrive = PxConcreteType::eFIRST_VEHICLE_EXTENSION,
118 eVehicleDrive4W,
119 eVehicleDriveNW,
120 eVehicleDriveTank
121 };
122};
123
124
135PX_DEPRECATED void PxVehicleSetBasisVectors(const PxVec3& up, const PxVec3& forward);
136
137
142{
143 enum Enum
144 {
145 eVELOCITY_CHANGE,
146 eACCELERATION
147 };
148};
149
150
163PX_DEPRECATED void PxVehicleSetUpdateMode(PxVehicleUpdateMode::Enum vehicleUpdateMode);
164
217PX_DEPRECATED void PxVehicleSetSweepHitRejectionAngles(const PxF32 pointRejectAngle, const PxF32 normalRejectAngle);
218
219
233PX_DEPRECATED void PxVehicleSetMaxHitActorAcceleration(const PxF32 maxHitActorAcceleration);
234
235
244{
245public:
246
256
266
279
289 PxVehicleUpdateMode::Enum updateMode;
290
302
314
326
327
328public:
333
337 PX_INLINE void setToDefault();
338
344 PX_INLINE bool isValid() const;
345
349 PX_INLINE void computeSideAxis();
350};
351
353 upAxis(0.0f, 1.0f, 0.0f),
354 forwardAxis(0.0f, 0.0f, 1.0f),
355 sideAxis(1.0f, 0.0f, 0.0f),
356 updateMode(PxVehicleUpdateMode::eVELOCITY_CHANGE),
357 pointRejectAngleThresholdCosine(0.707f), // cosine of 45 degrees
358 normalRejectAngleThresholdCosine(0.707f), // cosine of 45 degrees
359 maxHitActorAcceleration(PX_MAX_REAL)
360{
361}
362
367
369{
370 if (!upAxis.isNormalized())
371 return false;
372
374 return false;
375
376 if (!sideAxis.isNormalized())
377 return false;
378
379 if (((upAxis.cross(forwardAxis)) - sideAxis).magnitude() > 0.02f) // somewhat above 1 degree assuming both have unit length
380 return false;
381
383 return false;
384
386 return false;
387
388 if (maxHitActorAcceleration < 0.0f)
389 return false;
390
391 return true;
392}
393
398
399
414
415
416#if !PX_DOXYGEN
417} // namespace physx
418#endif
419
420#endif
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 cross(const PxVec3 &v) const
cross product
Definition PxVec3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isNormalized() const
is normalized - used by API parameter validation
Definition PxVec3.h:164
Common parameters and settings used for the vehicle simulation.
Definition PxVehicleSDK.h:244
PxF32 pointRejectAngleThresholdCosine
Cosine of threshold angle for rejecting sweep hits.
Definition PxVehicleSDK.h:301
PxF32 normalRejectAngleThresholdCosine
Cosine of threshold angle for rejecting sweep hits.
Definition PxVehicleSDK.h:313
PxF32 maxHitActorAcceleration
Maximum acceleration experienced by PxRigidDynamic instances that are found to be in contact with a w...
Definition PxVehicleSDK.h:325
PxVec3 sideAxis
The axis denoting the side direction for vehicles.
Definition PxVehicleSDK.h:278
PxVec3 forwardAxis
The axis denoting the forward direction for vehicles.
Definition PxVehicleSDK.h:265
PxVec3 upAxis
The axis denoting the up direction for vehicles.
Definition PxVehicleSDK.h:255
PX_INLINE void computeSideAxis()
Compute the side-axis from the up- and forward-axis.
Definition PxVehicleSDK.h:394
PX_INLINE bool isValid() const
Check if the settings descriptor is valid.
Definition PxVehicleSDK.h:368
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxVehicleSDK.h:363
PxVehicleUpdateMode::Enum updateMode
Apply vehicle simulation results as acceleration or velocity modification.
Definition PxVehicleSDK.h:289
PX_INLINE PxVehicleContext()
Constructor sets to default.
Definition PxVehicleSDK.h:352
#define PX_CALL_CONV
Definition PxPreprocessor.h:299
#define PX_INLINE
Definition PxPreprocessor.h:320
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_DEPRECATED PX_C_EXPORT bool PX_CALL_CONV PxInitVehicleSDK(PxPhysics &physics, PxSerializationRegistry *serializationRegistry=NULL)
Initialize the PhysXVehicle library.
Definition PxVehicleSDK.cpp:52
PX_DEPRECATED void PxVehicleSetBasisVectors(const PxVec3 &up, const PxVec3 &forward)
Set the basis vectors of the vehicle simulation.
Definition PxVehicleUpdate.cpp:78
PX_DEPRECATED const PxVehicleContext & PxVehicleGetDefaultContext()
Get the default vehicle context.
Definition PxVehicleUpdate.cpp:120
PX_DEPRECATED void PxVehicleSetUpdateMode(PxVehicleUpdateMode::Enum vehicleUpdateMode)
Set the effect of PxVehicleUpdates to be either to modify each vehicle's rigid body actor.
Definition PxVehicleUpdate.cpp:89
PX_DEPRECATED void PxVehicleSetMaxHitActorAcceleration(const PxF32 maxHitActorAcceleration)
Determine the maximum acceleration experienced by PxRigidDynamic instances that are found to be in co...
Definition PxVehicleUpdate.cpp:110
PX_DEPRECATED void PxVehicleSetSweepHitRejectionAngles(const PxF32 pointRejectAngle, const PxF32 normalRejectAngle)
Set threshold angles that are used to determine if a wheel hit is to be resolved by vehicle suspensio...
Definition PxVehicleUpdate.cpp:98
PX_DEPRECATED PX_C_EXPORT void PX_CALL_CONV PxCloseVehicleSDK(PxSerializationRegistry *serializationRegistry=NULL)
Shut down the PhysXVehicle library.
Definition PxVehicleSDK.cpp:81
An enumeration of concrete vehicle classes inheriting from PxBase.
Definition PxVehicleSDK.h:114
Definition PxVehicleSDK.h:93
Definition PxVehicleSDK.h:142