RavEngine
Loading...
Searching...
No Matches
PxVehicleDrivetrainStates.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#pragma once
30
35#include "vehicle2/commands/PxVehicleCommandStates.h"
36
37#if !PX_DOXYGEN
38namespace physx
39{
40namespace vehicle2
41{
42#endif
43
44
46{
47 PxReal normalisedCommandResponse;
48 PxReal commandResponse;
49
50 PX_FORCE_INLINE void setToDefault()
51 {
53 }
54};
55
57{
58 PxReal commandResponse;
59
60 PX_FORCE_INLINE void setToDefault()
61 {
63 }
64};
65
67{
74
75 PX_FORCE_INLINE void setToDefault()
76 {
77 PxMemZero(this, sizeof(PxVehicleEngineState));
78 }
79};
80
81#define PX_VEHICLE_NO_GEAR_SWITCH_PENDING -1.0f
82#define PX_VEHICLE_GEAR_SWITCH_INITIATED -2.0f
83
85{
90
95
110
111 PX_FORCE_INLINE void setToDefault()
112 {
113 currentGear = 0;
114 targetGear = 0;
115 gearSwitchTime = PX_VEHICLE_NO_GEAR_SWITCH_PENDING;
116 }
117};
118
119#define PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT PX_MAX_F32
120
122{
129
134
135 PX_FORCE_INLINE void setToDefault()
136 {
137 timeSinceLastShift = PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT;
139 }
140};
141
143{
147 PxU32 connectedWheels[PxVehicleLimits::eMAX_NB_WHEELS];
148
153
160 PxReal torqueRatiosAllWheels[PxVehicleLimits::eMAX_NB_WHEELS];
161
167 PxReal aveWheelSpeedContributionAllWheels[PxVehicleLimits::eMAX_NB_WHEELS];
168
169 PX_FORCE_INLINE void setToDefault()
170 {
172 }
173};
174
179{
180 PX_FORCE_INLINE void setToDefault()
181 {
183 }
184
194 void addConstraintGroup(const PxU32 nbWheelsInGroupToAdd, const PxU32* const wheelIdsInGroupToAdd, const PxF32* constraintMultipliers)
195 {
196 PX_ASSERT((nbWheelsInGroups + nbWheelsInGroupToAdd) < PxVehicleLimits::eMAX_NB_WHEELS);
197 PX_ASSERT(nbGroups < PxVehicleLimits::eMAX_NB_WHEELS);
198 nbWheelsPerGroup[nbGroups] = nbWheelsInGroupToAdd;
200 for (PxU32 i = 0; i < nbWheelsInGroupToAdd; i++)
201 {
202 wheelIdsInGroupOrder[nbWheelsInGroups + i] = wheelIdsInGroupToAdd[i];
203 wheelMultipliersInGroupOrder[nbWheelsInGroups + i] = constraintMultipliers[i];
204 }
205 nbWheelsInGroups += nbWheelsInGroupToAdd;
206 nbGroups++;
207 }
208
215 {
216 return nbGroups;
217 }
218
226 {
227 return nbWheelsPerGroup[i];
228 }
229
237 PX_FORCE_INLINE PxU32 getWheelInConstraintGroup(const PxU32 j, const PxU32 i) const
238 {
240 }
241
248 PX_FORCE_INLINE PxReal getMultiplierInConstraintGroup(const PxU32 j, const PxU32 i) const
249 {
251 }
252
253 PxU32 nbGroups;
254 PxU32 nbWheelsPerGroup[PxVehicleLimits::eMAX_NB_AXLES];
255 PxU32 groupToWheelIds[PxVehicleLimits::eMAX_NB_AXLES];
256
257 PxU32 wheelIdsInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS];
258 PxF32 wheelMultipliersInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS];
260};
261
266{
273
274 PX_FORCE_INLINE void setToDefault()
275 {
276 PxMemZero(this, sizeof(PxVehicleClutchSlipState));
277 }
278};
279
280
281
282
283#if !PX_DOXYGEN
284} // namespace vehicle2
285} // namespace physx
286#endif
287
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
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
Definition PxVehicleDrivetrainStates.h:122
PxReal timeSinceLastShift
Time that has lapsed since the last autobox gear shift.
Definition PxVehicleDrivetrainStates.h:128
bool activeAutoboxGearShift
Describes whether a gear shift triggered by the autobox is still in flight.
Definition PxVehicleDrivetrainStates.h:133
Definition PxVehicleDrivetrainStates.h:46
The clutch is modelled as two spinning plates with one connected to the wheels through the gearing an...
Definition PxVehicleDrivetrainStates.h:266
PxReal clutchSlip
The slip at the clutch.
Definition PxVehicleDrivetrainStates.h:272
Definition PxVehicleDrivetrainStates.h:143
PxReal aveWheelSpeedContributionAllWheels[PxVehicleLimits::eMAX_NB_WHEELS]
The contribution of each wheel to the average wheel rotation speed measured at the clutch.
Definition PxVehicleDrivetrainStates.h:167
PxU32 nbConnectedWheels
The number of wheels that are connected to the differential.
Definition PxVehicleDrivetrainStates.h:152
PxReal torqueRatiosAllWheels[PxVehicleLimits::eMAX_NB_WHEELS]
The fraction of available torque that is delivered to each wheel through the differential.
Definition PxVehicleDrivetrainStates.h:160
PxU32 connectedWheels[PxVehicleLimits::eMAX_NB_WHEELS]
A list of wheel indices that are connected to the differential.
Definition PxVehicleDrivetrainStates.h:147
Definition PxVehicleDrivetrainStates.h:67
PxReal rotationSpeed
The rotation speed of the engine (radians per second).
Definition PxVehicleDrivetrainStates.h:73
Definition PxVehicleDrivetrainStates.h:85
PxU32 currentGear
Current gear.
Definition PxVehicleDrivetrainStates.h:89
PxU32 targetGear
Target gear (different from current gear if a gear change is underway)
Definition PxVehicleDrivetrainStates.h:94
PxReal gearSwitchTime
Reported time that has passed since gear change started.
Definition PxVehicleDrivetrainStates.h:109
Specify groups of wheels that are to be constrained to have pre-determined angular velocity relations...
Definition PxVehicleDrivetrainStates.h:179
PxU32 groupToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]
The list of wheel ids for the ith group begins at wheelIdsInGroupOrder[groupToWheelIds[i]].
Definition PxVehicleDrivetrainStates.h:255
PX_FORCE_INLINE PxReal getMultiplierInConstraintGroup(const PxU32 j, const PxU32 i) const
Return the constraint multiplier of the jth wheel in the ith constraint group.
Definition PxVehicleDrivetrainStates.h:248
PX_FORCE_INLINE PxU32 getNbConstraintGroups() const
Return the number of wheel constraint groups in the vehicle.
Definition PxVehicleDrivetrainStates.h:214
PX_FORCE_INLINE PxU32 getWheelInConstraintGroup(const PxU32 j, const PxU32 i) const
Return the wheel id of the jth wheel in the ith constraint group.
Definition PxVehicleDrivetrainStates.h:237
PxU32 nbWheelsPerGroup[PxVehicleLimits::eMAX_NB_AXLES]
The number of wheels in each group.
Definition PxVehicleDrivetrainStates.h:254
PxU32 nbWheelsInGroups
The number of wheels in a constraint group.
Definition PxVehicleDrivetrainStates.h:259
PxU32 wheelIdsInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS]
The list of all wheel ids in constraint groups.
Definition PxVehicleDrivetrainStates.h:257
PxU32 nbGroups
The number of constraint groups in the vehicle.
Definition PxVehicleDrivetrainStates.h:253
PxF32 wheelMultipliersInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS]
The constraint multipliers for each constraint group.
Definition PxVehicleDrivetrainStates.h:258
PX_FORCE_INLINE PxU32 getNbWheelsInConstraintGroup(const PxU32 i) const
Return the number of wheels in the ith constraint group.
Definition PxVehicleDrivetrainStates.h:225
void addConstraintGroup(const PxU32 nbWheelsInGroupToAdd, const PxU32 *const wheelIdsInGroupToAdd, const PxF32 *constraintMultipliers)
Add a wheel constraint group by specifying the number of wheels in the group, an array of wheel ids s...
Definition PxVehicleDrivetrainStates.h:194