34#include "foundation/PxTransform.h"
35#include "foundation/PxMat33.h"
36#include "foundation/PxSimpleTypes.h"
37#include "PxRigidBody.h"
38#include "PxVehicleParams.h"
39#include "roadGeometry/PxVehicleRoadGeometryState.h"
40#include "rigidBody/PxVehicleRigidBodyStates.h"
41#include "physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h"
42#include "physxActor/PxVehiclePhysXActorStates.h"
51(
const PxVehicleFrame& srcFrame,
const PxVehicleFrame& trgFrame,
const PxVec3& v)
54 if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis))
56 const PxMat33 a = srcFrame.getFrame();
57 const PxMat33 r = trgFrame.getFrame();
58 result = (r * a.getTranspose() * v);
64(
const PxVehicleFrame& srcFrame,
const PxVehicleFrame& trgFrame,
65 const PxVehicleScale& srcScale,
const PxVehicleScale& trgScale,
68 PxVec3 result = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, v);
69 if((srcScale.scale != trgScale.scale))
70 result *= (trgScale.scale / srcScale.scale);
75(
const PxVehicleFrame& srcFrame,
const PxVehicleFrame& trgFrame,
76 const PxVehicleScale& srcScale,
const PxVehicleScale& trgScale,
79 PxTransform result(PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, v.p), v.q);
80 if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis))
84 v.q.toRadiansAndUnitAxis(angle, axis);
85 result.q = PxQuat(angle, PxVehicleTransformFrameToFrame(srcFrame, trgFrame, axis));
90PX_FORCE_INLINE PxVec3 PxVehicleComputeTranslation(
const PxVehicleFrame& frame,
const PxReal lng,
const PxReal lat,
const PxReal vrt)
92 const PxVec3 v = frame.getFrame()*PxVec3(lng, lat, vrt);
96PX_FORCE_INLINE PxQuat PxVehicleComputeRotation(
const PxVehicleFrame& frame,
const PxReal roll,
const PxReal pitch,
const PxReal yaw)
98 const PxMat33 m = frame.getFrame();
99 const PxVec3& lngAxis = m.column0;
100 const PxVec3& latAxis = m.column1;
101 const PxVec3& vrtAxis = m.column2;
102 const PxQuat quatPitch(pitch, latAxis);
103 const PxQuat quatRoll(roll, lngAxis);
104 const PxQuat quatYaw(yaw, vrtAxis);
105 const PxQuat result = quatYaw * quatRoll * quatPitch;
111 return physx::intrinsics::fsel(f, physx::intrinsics::fsel(-f, 0.0f, 1.0f), -1.0f);
136(
const PxVehicleAxleDescription& axleDesc,
const PxVec3& shift,
137 PxVehicleRigidBodyState& rigidBodyState, PxVehicleRoadGeometryState* roadGeometryStates,
138 PxVehiclePhysXActor* physxActor = NULL, PxVehiclePhysXRoadGeometryQueryState* physxQueryStates = NULL)
141 rigidBodyState.pose.p -= shift;
144 if (physxActor && !physxActor->rigidBody->getScene())
146 const PxTransform oldPose = physxActor->rigidBody->getGlobalPose();
147 const PxTransform newPose(oldPose.p - shift, oldPose.q);
148 physxActor->rigidBody->setGlobalPose(newPose);
151 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
153 const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
156 if (physxQueryStates && physxQueryStates[wheelId].actor)
157 physxQueryStates[wheelId].hitPosition -= shift;
160 if (roadGeometryStates[wheelId].hitState)
162 const PxPlane plane = roadGeometryStates[wheelId].plane;
163 PxU32 largestNormalComponentAxis = 0;
164 PxReal largestNormalComponent = 0.0f;
165 const PxF32 normalComponents[3] = { plane.n.x, plane.n.y, plane.n.z };
166 for (PxU32 k = 0; k < 3; k++)
168 if (
PxAbs(normalComponents[k]) > largestNormalComponent)
170 largestNormalComponent =
PxAbs(normalComponents[k]);
171 largestNormalComponentAxis = k;
174 PxVec3 pointInPlane(PxZero);
175 switch (largestNormalComponentAxis)
178 pointInPlane.x = -plane.d / plane.n.x;
181 pointInPlane.y = -plane.d / plane.n.y;
184 pointInPlane.z = -plane.d / plane.n.z;
189 roadGeometryStates[wheelId].plane.d = -plane.n.dot(pointInPlane - shift);
GLM_FUNC_DECL T angle(qua< T, Q > const &x)
Definition quaternion_trigonometric.inl:6
#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_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_DEPRECATED void PxVehicleShiftOrigin(const PxVec3 &shift, const PxU32 nbVehicles, PxVehicleWheels **vehicles)
Shift the origin of vehicles by the specified vector.
Definition PxVehicleUpdate.cpp:7105