RavEngine
Loading...
Searching...
No Matches
PxVehicleNoDrive.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_NO_DRIVE_H
30#define PX_VEHICLE_NO_DRIVE_H
31
32#include "vehicle/PxVehicleWheels.h"
33#include "vehicle/PxVehicleComponents.h"
34
35
36#if !PX_DOXYGEN
37namespace physx
38{
39#endif
40
41struct PxFilterData;
42class PxGeometry;
43class PxPhysics;
44class PxVehicleDrivableSurfaceToTireFrictionPairs;
45class PxShape;
46class PxMaterial;
47class PxRigidDynamic;
48
53{
54//= ATTENTION! =====================================================================================
55// Changing the data layout of this class breaks the binary serialization format. See comments for
56// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
57// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
58// accordingly.
59//==================================================================================================
60public:
61
62 friend class PxVehicleUpdate;
63
73 static PxVehicleNoDrive* allocate(const PxU32 nbWheels);
74
79 void free();
80
89 void setup
90 (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
91
101 static PxVehicleNoDrive* create
102 (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
103
111 void setToRestState();
112
123 void setBrakeTorque(const PxU32 id, const PxReal brakeTorque);
124
135 void setDriveTorque(const PxU32 id, const PxReal driveTorque);
136
147 void setSteerAngle(const PxU32 id, const PxReal steerAngle);
148
154 PxReal getBrakeTorque(const PxU32 id) const;
155
161 PxReal getDriveTorque(const PxU32 id) const;
162
168 PxReal getSteerAngle(const PxU32 id) const;
169
170private:
171
172 PxReal* mSteerAngles;
173 PxReal* mDriveTorques;
174 PxReal* mBrakeTorques;
175
176#if PX_P64_FAMILY
177 PxU32 mPad[2];
178#else
179 PxU32 mPad[1];
180#endif
181
185 bool isValid() const;
186
187
188//serialization
189public:
190 PxVehicleNoDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags) {}
191 virtual void exportExtraData(PxSerializationContext&);
192 void importExtraData(PxDeserializationContext&);
193 static PxVehicleNoDrive* createObject(PxU8*& address, PxDeserializationContext& context);
194 static void getBinaryMetaData(PxOutputStream& stream);
195 virtual const char* getConcreteTypeName() const { return "PxVehicleNoDrive"; }
196 virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleNoDrive", name) || PxBase::isKindOf(name); }
197 PxU32 getNbSteerAngle() const { return mWheelsSimData.getNbWheels(); }
198 PxU32 getNbDriveTorque() const { return mWheelsSimData.getNbWheels(); }
199 PxU32 getNbBrakeTorque() const { return mWheelsSimData.getNbWheels(); }
200protected:
201 PxVehicleNoDrive();
202 ~PxVehicleNoDrive() {}
203//~serialization
204};
205PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleNoDrive) & 15));
206
207#if !PX_DOXYGEN
208} // namespace physx
209#endif
210
211#endif
Definition base.h:1940
Binary deserialization context class.
Definition PxSerialFramework.h:174
Output stream class for I/O.
Definition PxIO.h:114
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition PxPhysics.h:91
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
Definition PxRigidDynamic.h:82
Binary serialization context class.
Definition PxSerialFramework.h:99
Data structure with instanced dynamics data and configuration data of a vehicle with no drive model.
Definition PxVehicleNoDrive.h:53
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxVehicleNoDrive.h:196
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition PxVehicleNoDrive.h:195
Definition PxVehicleUpdate.cpp:4519
Data structure describing configuration data of a vehicle with up to 20 wheels.
Definition PxVehicleWheels.h:129
Data structure with instanced dynamics data and configuration data of a vehicle with just wheels.
Definition PxVehicleWheels.h:827
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
#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