(any());
+ }
+
+ union {
+ PxU8 geometry[sizeof(PxGeometry)];
+ PxU8 box[sizeof(PxBoxGeometry)];
+ PxU8 sphere[sizeof(PxSphereGeometry)];
+ PxU8 capsule[sizeof(PxCapsuleGeometry)];
+ PxU8 plane[sizeof(PxPlaneGeometry)];
+ PxU8 convex[sizeof(PxConvexMeshGeometry)];
+ PxU8 mesh[sizeof(PxTriangleMeshGeometry)];
+ PxU8 heightfield[sizeof(PxHeightFieldGeometry)];
+ } bytes;
+}
+PX_ALIGN_SUFFIX(4);
+
+
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxGeometryQuery.h b/sources/PhysX/PhysX/include/geometry/PxGeometryQuery.h
new file mode 100644
index 00000000..a4cab1a7
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxGeometryQuery.h
@@ -0,0 +1,225 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_PX_GEOMETRY_QUERY
+#define PX_PHYSICS_GEOMUTILS_PX_GEOMETRY_QUERY
+
+/**
+\brief Maximum sweep distance for scene sweeps. The distance parameter for sweep functions will be clamped to this value.
+The reason for this is GJK support cannot be evaluated near infinity. A viable alternative can be a sweep followed by an infinite raycast.
+
+@see PxScene
+*/
+#define PX_MAX_SWEEP_DISTANCE 1e8f
+
+/** \addtogroup geomutils
+ @{
+*/
+
+#include "common/PxPhysXCommonConfig.h"
+#include "PxQueryReport.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxGeometry;
+struct PxSweepHit;
+struct PxRaycastHit;
+
+class PxTriangle;
+
+/**
+\brief Collection of geometry object queries (sweeps, raycasts, overlaps, ...).
+*/
+class PxGeometryQuery
+{
+public:
+
+ /**
+ \brief Sweep a specified geometry object in space and test for collision with a given object.
+
+ The following combinations are supported.
+
+ \li PxSphereGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
+ \li PxCapsuleGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
+ \li PxBoxGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
+ \li PxConvexMeshGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
+
+ \param[in] unitDir Normalized direction along which object geom0 should be swept
+ \param[in] maxDist Maximum sweep distance, has to be in the [0, inf) range
+ \param[in] geom0 The geometry object to sweep. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry, #PxBoxGeometry and #PxConvexMeshGeometry
+ \param[in] pose0 Pose of the geometry object to sweep
+ \param[in] geom1 The geometry object to test the sweep against
+ \param[in] pose1 Pose of the geometry object to sweep against
+ \param[out] sweepHit The sweep hit information. Only valid if this method returns true.
+ \param[in] hitFlags Specify which properties per hit should be computed and written to result hit array. Combination of #PxHitFlag flags
+ \param[in] inflation Surface of the swept shape is additively extruded in the normal direction, rounding corners and edges.
+
+ \return True if the swept geometry object geom0 hits the object geom1
+
+ @see PxSweepHit PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static bool sweep(const PxVec3& unitDir,
+ const PxReal maxDist,
+ const PxGeometry& geom0,
+ const PxTransform& pose0,
+ const PxGeometry& geom1,
+ const PxTransform& pose1,
+ PxSweepHit& sweepHit,
+ PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
+ const PxReal inflation = 0.f);
+
+
+ /**
+ \brief Overlap test for two geometry objects.
+
+ All combinations are supported except:
+ \li PxPlaneGeometry vs. {PxPlaneGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
+ \li PxTriangleMeshGeometry vs. {PxTriangleMeshGeometry, PxHeightFieldGeometry}
+ \li PxHeightFieldGeometry vs. {PxHeightFieldGeometry}
+
+ \param[in] geom0 The first geometry object
+ \param[in] pose0 Pose of the first geometry object
+ \param[in] geom1 The second geometry object
+ \param[in] pose1 Pose of the second geometry object
+ \return True if the two geometry objects overlap
+
+ @see PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static bool overlap(const PxGeometry& geom0, const PxTransform& pose0,
+ const PxGeometry& geom1, const PxTransform& pose1);
+
+
+ /**
+ \brief Raycast test against a geometry object.
+
+ \param[in] origin The origin of the ray to test the geometry object against
+ \param[in] unitDir Normalized direction of the ray to test the geometry object against
+ \param[in] geom The geometry object to test the ray against
+ \param[in] pose Pose of the geometry object
+ \param[in] maxDist Maximum ray length, has to be in the [0, inf) range
+ \param[in] hitFlags Specification of the kind of information to retrieve on hit. Combination of #PxHitFlag flags
+ \param[in] maxHits max number of returned hits = size of 'rayHits' buffer
+ \param[out] rayHits Raycast hits information
+ \return Number of hits between the ray and the geometry object
+
+ @see PxRaycastHit PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static PxU32 raycast(const PxVec3& origin,
+ const PxVec3& unitDir,
+ const PxGeometry& geom,
+ const PxTransform& pose,
+ PxReal maxDist,
+ PxHitFlags hitFlags,
+ PxU32 maxHits,
+ PxRaycastHit* PX_RESTRICT rayHits);
+
+ /**
+ \brief Compute minimum translational distance (MTD) between two geometry objects.
+
+ All combinations of geom objects are supported except:
+ - plane/plane
+ - plane/mesh
+ - plane/heightfield
+ - mesh/mesh
+ - mesh/heightfield
+ - heightfield/heightfield
+
+ The function returns a unit vector ('direction') and a penetration depth ('depth').
+
+ The depenetration vector D = direction * depth should be applied to the first object, to
+ get out of the second object.
+
+ Returned depth should always be positive or null.
+
+ If objects do not overlap, the function can not compute the MTD and returns false.
+
+ \param[out] direction Computed MTD unit direction
+ \param[out] depth Penetration depth. Always positive or null.
+ \param[in] geom0 The first geometry object
+ \param[in] pose0 Pose of the first geometry object
+ \param[in] geom1 The second geometry object
+ \param[in] pose1 Pose of the second geometry object
+ \return True if the MTD has successfully been computed, i.e. if objects do overlap.
+
+ @see PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static bool computePenetration(PxVec3& direction, PxF32& depth,
+ const PxGeometry& geom0, const PxTransform& pose0,
+ const PxGeometry& geom1, const PxTransform& pose1);
+
+ /**
+ \brief Computes distance between a point and a geometry object.
+
+ Currently supported geometry objects: box, sphere, capsule, convex.
+
+ \param[in] point The point P
+ \param[in] geom The geometry object
+ \param[in] pose Pose of the geometry object
+ \param[out] closestPoint Optionally returned closest point to P on the geom object. Only valid when returned distance is strictly positive.
+ \return Square distance between the point and the geom object, or 0.0 if the point is inside the object, or -1.0 if the geometry type is not supported.
+
+ @see PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static PxReal pointDistance(const PxVec3& point, const PxGeometry& geom, const PxTransform& pose, PxVec3* closestPoint=NULL);
+
+
+ /**
+ \brief get the bounds for a geometry object
+
+ \param[in] geom The geometry object
+ \param[in] pose Pose of the geometry object
+ \param[in] inflation Scale factor for computed world bounds. Box extents are multiplied by this value.
+ \return The bounds of the object
+
+ @see PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static PxBounds3 getWorldBounds(const PxGeometry& geom, const PxTransform& pose, float inflation=1.01f);
+
+ /**
+ \brief Checks if provided geometry is valid.
+
+ \param[in] geom The geometry object.
+ \return True if geometry is valid.
+
+ @see PxGeometry PxSphereGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexGeometry
+ */
+ PX_PHYSX_COMMON_API static bool isValid(const PxGeometry& geom);
+};
+
+
+#if !PX_DOXYGEN
+}
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxHeightField.h b/sources/PhysX/PhysX/include/geometry/PxHeightField.h
new file mode 100644
index 00000000..34665956
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxHeightField.h
@@ -0,0 +1,262 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_NX_HEIGHTFIELD
+#define PX_PHYSICS_GEOMUTILS_NX_HEIGHTFIELD
+/** \addtogroup geomutils
+ @{
+*/
+
+#include "geometry/PxHeightFieldFlag.h"
+#include "geometry/PxHeightFieldSample.h"
+#include "common/PxBase.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxHeightFieldDesc;
+
+/**
+\brief A height field class.
+
+Height fields work in a similar way as triangle meshes specified to act as
+height fields, with some important differences:
+
+Triangle meshes can be made of nonuniform geometry, while height fields are
+regular, rectangular grids. This means that with PxHeightField, you sacrifice
+flexibility in return for improved performance and decreased memory consumption.
+
+In local space rows extend in X direction, columns in Z direction and height in Y direction.
+
+Like Convexes and TriangleMeshes, HeightFields are referenced by shape instances
+(see #PxHeightFieldGeometry, #PxShape).
+
+To avoid duplicating data when you have several instances of a particular
+height field differently, you do not use this class to represent a
+height field object directly. Instead, you create an instance of this height field
+via the PxHeightFieldGeometry and PxShape classes.
+
+Creation
+
+To create an instance of this class call PxPhysics::createHeightField() or
+PxCooking::createHeightField(const PxHeightFieldDesc&, PxPhysicsInsertionCallback&).
+To delete it call release(). This is only possible
+once you have released all of its PxHeightFiedShape instances.
+
+Visualizations:
+\li #PxVisualizationParameter::eCOLLISION_AABBS
+\li #PxVisualizationParameter::eCOLLISION_SHAPES
+\li #PxVisualizationParameter::eCOLLISION_AXES
+\li #PxVisualizationParameter::eCOLLISION_FNORMALS
+\li #PxVisualizationParameter::eCOLLISION_EDGES
+
+@see PxHeightFieldDesc PxHeightFieldGeometry PxShape PxPhysics.createHeightField() PxCooking.createHeightField()
+*/
+
+class PxHeightField : public PxBase
+{
+ public:
+ /**
+ \brief Decrements the reference count of a height field and releases it if the new reference count is zero.
+
+ @see PxPhysics.createHeightField() PxHeightFieldDesc PxHeightFieldGeometry PxShape
+ */
+ PX_PHYSX_COMMON_API virtual void release() = 0;
+
+ /**
+ \brief Writes out the sample data array.
+
+ The user provides destBufferSize bytes storage at destBuffer.
+ The data is formatted and arranged as PxHeightFieldDesc.samples.
+
+ \param[out] destBuffer The destination buffer for the sample data.
+ \param[in] destBufferSize The size of the destination buffer.
+ \return The number of bytes written.
+
+ @see PxHeightFieldDesc.samples
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 saveCells(void* destBuffer, PxU32 destBufferSize) const = 0;
+
+ /**
+ \brief Replaces a rectangular subfield in the sample data array.
+
+ The user provides the description of a rectangular subfield in subfieldDesc.
+ The data is formatted and arranged as PxHeightFieldDesc.samples.
+
+ \param[in] startCol First cell in the destination heightfield to be modified. Can be negative.
+ \param[in] startRow First row in the destination heightfield to be modified. Can be negative.
+ \param[in] subfieldDesc Description of the source subfield to read the samples from.
+ \param[in] shrinkBounds If left as false, the bounds will never shrink but only grow. If set to true the bounds will be recomputed from all HF samples at O(nbColums*nbRows) perf cost.
+ \return True on success, false on failure. Failure can occur due to format mismatch.
+
+ \note Modified samples are constrained to the same height quantization range as the original heightfield.
+ Source samples that are out of range of target heightfield will be clipped with no error.
+ PhysX does not keep a mapping from the heightfield to heightfield shapes that reference it.
+ Call PxShape::setGeometry on each shape which references the height field, to ensure that internal data structures are updated to reflect the new geometry.
+ Please note that PxShape::setGeometry does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.
+
+ @see PxHeightFieldDesc.samples PxShape.setGeometry
+ */
+ PX_PHYSX_COMMON_API virtual bool modifySamples(PxI32 startCol, PxI32 startRow, const PxHeightFieldDesc& subfieldDesc, bool shrinkBounds = false) = 0;
+
+ /**
+ \brief Retrieves the number of sample rows in the samples array.
+
+ \return The number of sample rows in the samples array.
+
+ @see PxHeightFieldDesc.nbRows
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 getNbRows() const = 0;
+
+ /**
+ \brief Retrieves the number of sample columns in the samples array.
+
+ \return The number of sample columns in the samples array.
+
+ @see PxHeightFieldDesc.nbColumns
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 getNbColumns() const = 0;
+
+ /**
+ \brief Retrieves the format of the sample data.
+
+ \return The format of the sample data.
+
+ @see PxHeightFieldDesc.format PxHeightFieldFormat
+ */
+ PX_PHYSX_COMMON_API virtual PxHeightFieldFormat::Enum getFormat() const = 0;
+
+ /**
+ \brief Retrieves the offset in bytes between consecutive samples in the array.
+
+ \return The offset in bytes between consecutive samples in the array.
+
+ @see PxHeightFieldDesc.sampleStride
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 getSampleStride() const = 0;
+
+ /**
+ \brief Retrieves the convex edge threshold.
+
+ \return The convex edge threshold.
+
+ @see PxHeightFieldDesc.convexEdgeThreshold
+ */
+ PX_PHYSX_COMMON_API virtual PxReal getConvexEdgeThreshold() const = 0;
+
+ /**
+ \brief Retrieves the flags bits, combined from values of the enum ::PxHeightFieldFlag.
+
+ \return The flags bits, combined from values of the enum ::PxHeightFieldFlag.
+
+ @see PxHeightFieldDesc.flags PxHeightFieldFlag
+ */
+ PX_PHYSX_COMMON_API virtual PxHeightFieldFlags getFlags() const = 0;
+
+ /**
+ \brief Retrieves the height at the given coordinates in grid space.
+
+ \return The height at the given coordinates or 0 if the coordinates are out of range.
+ */
+ PX_PHYSX_COMMON_API virtual PxReal getHeight(PxReal x, PxReal z) const = 0;
+
+ /**
+ \brief Returns the reference count for shared heightfields.
+
+ At creation, the reference count of the heightfield is 1. Every shape referencing this heightfield increments the
+ count by 1. When the reference count reaches 0, and only then, the heightfield gets destroyed automatically.
+
+ \return the current reference count.
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 getReferenceCount() const = 0;
+
+ /**
+ \brief Acquires a counted reference to a heightfield.
+
+ This method increases the reference count of the heightfield by 1. Decrement the reference count by calling release()
+ */
+ PX_PHYSX_COMMON_API virtual void acquireReference() = 0;
+
+ /**
+ \brief Returns material table index of given triangle
+
+ \note This function takes a post cooking triangle index.
+
+ \param[in] triangleIndex (internal) index of desired triangle
+ \return Material table index, or 0xffff if no per-triangle materials are used
+ */
+ PX_PHYSX_COMMON_API virtual PxMaterialTableIndex getTriangleMaterialIndex(PxTriangleID triangleIndex) const = 0;
+
+ /**
+ \brief Returns a triangle face normal for a given triangle index
+
+ \note This function takes a post cooking triangle index.
+
+ \param[in] triangleIndex (internal) index of desired triangle
+ \return Triangle normal for a given triangle index
+ */
+ PX_PHYSX_COMMON_API virtual PxVec3 getTriangleNormal(PxTriangleID triangleIndex) const = 0;
+
+ /**
+ \brief Returns heightfield sample of given row and column
+
+ \param[in] row Given heightfield row
+ \param[in] column Given heightfield column
+ \return Heightfield sample
+ */
+ PX_PHYSX_COMMON_API virtual const PxHeightFieldSample& getSample(PxU32 row, PxU32 column) const = 0;
+
+ /**
+ \brief Returns the number of times the heightfield data has been modified
+
+ This method returns the number of times modifySamples has been called on this heightfield, so that code that has
+ retained state that depends on the heightfield can efficiently determine whether it has been modified.
+
+ \return the number of times the heightfield sample data has been modified.
+ */
+ PX_PHYSX_COMMON_API virtual PxU32 getTimestamp() const = 0;
+
+ PX_PHYSX_COMMON_API virtual const char* getConcreteTypeName() const { return "PxHeightField"; }
+
+protected:
+ PX_INLINE PxHeightField(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
+ PX_INLINE PxHeightField(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
+ PX_PHYSX_COMMON_API virtual ~PxHeightField() {}
+ PX_PHYSX_COMMON_API virtual bool isKindOf(const char* name) const { return !::strcmp("PxHeightField", name) || PxBase::isKindOf(name); }
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxHeightFieldDesc.h b/sources/PhysX/PhysX/include/geometry/PxHeightFieldDesc.h
new file mode 100644
index 00000000..669e9155
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxHeightFieldDesc.h
@@ -0,0 +1,187 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_COLLISION_NXHEIGHTFIELDDESC
+#define PX_COLLISION_NXHEIGHTFIELDDESC
+/** \addtogroup geomutils
+@{
+*/
+
+#include "common/PxPhysXCommonConfig.h"
+#include "geometry/PxHeightFieldFlag.h"
+#include "common/PxCoreUtilityTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Descriptor class for #PxHeightField.
+
+\note The heightfield data is *copied* when a PxHeightField object is created from this descriptor. After the call the
+user may discard the height data.
+
+@see PxHeightField PxHeightFieldGeometry PxShape PxPhysics.createHeightField() PxCooking.createHeightField()
+*/
+class PxHeightFieldDesc
+{
+public:
+
+ /**
+ \brief Number of sample rows in the height field samples array.
+
+ \note Local space X-axis corresponds to rows.
+
+ Range: >1
+ Default: 0
+ */
+ PxU32 nbRows;
+
+ /**
+ \brief Number of sample columns in the height field samples array.
+
+ \note Local space Z-axis corresponds to columns.
+
+ Range: >1
+ Default: 0
+ */
+ PxU32 nbColumns;
+
+ /**
+ \brief Format of the sample data.
+
+ Currently the only supported format is PxHeightFieldFormat::eS16_TM:
+
+ Default: PxHeightFieldFormat::eS16_TM
+
+ @see PxHeightFormat PxHeightFieldDesc.samples
+ */
+ PxHeightFieldFormat::Enum format;
+
+ /**
+ \brief The samples array.
+
+ It is copied to the SDK's storage at creation time.
+
+ There are nbRows * nbColumn samples in the array,
+ which define nbRows * nbColumn vertices and cells,
+ of which (nbRows - 1) * (nbColumns - 1) cells are actually used.
+
+ The array index of sample(row, column) = row * nbColumns + column.
+ The byte offset of sample(row, column) = sampleStride * (row * nbColumns + column).
+ The sample data follows at the offset and spans the number of bytes defined by the format.
+ Then there are zero or more unused bytes depending on sampleStride before the next sample.
+
+ Default: NULL
+
+ @see PxHeightFormat
+ */
+ PxStridedData samples;
+
+ /**
+ This threshold is used by the collision detection to determine if a height field edge is convex
+ and can generate contact points.
+ Usually the convexity of an edge is determined from the angle (or cosine of the angle) between
+ the normals of the faces sharing that edge.
+ The height field allows a more efficient approach by comparing height values of neighboring vertices.
+ This parameter offsets the comparison. Smaller changes than 0.5 will not alter the set of convex edges.
+ The rule of thumb is that larger values will result in fewer edge contacts.
+
+ This parameter is ignored in contact generation with sphere and capsule primitives.
+
+ Range: [0, PX_MAX_F32)
+ Default: 0
+ */
+ PxReal convexEdgeThreshold;
+
+ /**
+ \brief Flags bits, combined from values of the enum ::PxHeightFieldFlag.
+
+ Default: 0
+
+ @see PxHeightFieldFlag PxHeightFieldFlags
+ */
+ PxHeightFieldFlags flags;
+
+ /**
+ \brief Constructor sets to default.
+ */
+ PX_INLINE PxHeightFieldDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ \brief Returns true if the descriptor is valid.
+ \return True if the current settings are valid.
+ */
+ PX_INLINE bool isValid() const;
+};
+
+PX_INLINE PxHeightFieldDesc::PxHeightFieldDesc() //constructor sets to default
+{
+ nbColumns = 0;
+ nbRows = 0;
+ format = PxHeightFieldFormat::eS16_TM;
+ convexEdgeThreshold = 0.0f;
+ flags = PxHeightFieldFlags();
+}
+
+PX_INLINE void PxHeightFieldDesc::setToDefault()
+{
+ *this = PxHeightFieldDesc();
+}
+
+PX_INLINE bool PxHeightFieldDesc::isValid() const
+{
+ if (nbColumns < 2)
+ return false;
+ if (nbRows < 2)
+ return false;
+ if(format != PxHeightFieldFormat::eS16_TM)
+ return false;
+ if (samples.stride < 4)
+ return false;
+ if (convexEdgeThreshold < 0)
+ return false;
+ if ((flags & PxHeightFieldFlag::eNO_BOUNDARY_EDGES) != flags)
+ return false;
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxHeightFieldFlag.h b/sources/PhysX/PhysX/include/geometry/PxHeightFieldFlag.h
new file mode 100644
index 00000000..85b27a33
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxHeightFieldFlag.h
@@ -0,0 +1,162 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_COLLISION_NXHEIGHTFIELDFLAG
+#define PX_COLLISION_NXHEIGHTFIELDFLAG
+/** \addtogroup geomutils
+@{
+*/
+
+#include "foundation/PxFlags.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Describes the format of height field samples.
+@see PxHeightFieldDesc.format PxHeightFieldDesc.samples
+*/
+struct PxHeightFieldFormat
+{
+ enum Enum
+ {
+ /**
+ \brief Height field height data is 16 bit signed integers, followed by triangle materials.
+
+ Each sample is 32 bits wide arranged as follows:
+
+ \image html heightFieldFormat_S16_TM.png
+
+ 1) First there is a 16 bit height value.
+ 2) Next, two one byte material indices, with the high bit of each byte reserved for special use.
+ (so the material index is only 7 bits).
+ The high bit of material0 is the tess-flag.
+ The high bit of material1 is reserved for future use.
+
+ There are zero or more unused bytes before the next sample depending on PxHeightFieldDesc.sampleStride,
+ where the application may eventually keep its own data.
+
+ This is the only format supported at the moment.
+
+ @see PxHeightFieldDesc.format PxHeightFieldDesc.samples
+ */
+ eS16_TM = (1 << 0)
+ };
+};
+
+/**
+\brief Determines the tessellation of height field cells.
+@see PxHeightFieldDesc.format PxHeightFieldDesc.samples
+*/
+struct PxHeightFieldTessFlag
+{
+ enum Enum
+ {
+ /**
+ \brief This flag determines which way each quad cell is subdivided.
+
+ The flag lowered indicates subdivision like this: (the 0th vertex is referenced by only one triangle)
+
+ \image html heightfieldTriMat2.PNG
+
+
+ +--+--+--+---> column
+ | /| /| /|
+ |/ |/ |/ |
+ +--+--+--+
+ | /| /| /|
+ |/ |/ |/ |
+ +--+--+--+
+ |
+ |
+ V row
+
+
+ The flag raised indicates subdivision like this: (the 0th vertex is shared by two triangles)
+
+ \image html heightfieldTriMat1.PNG
+
+
+ +--+--+--+---> column
+ |\ |\ |\ |
+ | \| \| \|
+ +--+--+--+
+ |\ |\ |\ |
+ | \| \| \|
+ +--+--+--+
+ |
+ |
+ V row
+
+
+ @see PxHeightFieldDesc.format PxHeightFieldDesc.samples
+ */
+ e0TH_VERTEX_SHARED = (1 << 0)
+ };
+};
+
+
+/**
+\brief Enum with flag values to be used in PxHeightFieldDesc.flags.
+*/
+struct PxHeightFieldFlag
+{
+ enum Enum
+ {
+ /**
+ \brief Disable collisions with height field with boundary edges.
+
+ Raise this flag if several terrain patches are going to be placed adjacent to each other,
+ to avoid a bump when sliding across.
+
+ This flag is ignored in contact generation with sphere and capsule shapes.
+
+ @see PxHeightFieldDesc.flags
+ */
+ eNO_BOUNDARY_EDGES = (1 << 0)
+ };
+};
+
+/**
+\brief collection of set bits defined in PxHeightFieldFlag.
+
+@see PxHeightFieldFlag
+*/
+typedef PxFlags PxHeightFieldFlags;
+PX_FLAGS_OPERATORS(PxHeightFieldFlag::Enum,PxU16)
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxHeightFieldGeometry.h b/sources/PhysX/PhysX/include/geometry/PxHeightFieldGeometry.h
new file mode 100644
index 00000000..d32c1b89
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxHeightFieldGeometry.h
@@ -0,0 +1,143 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NX_HEIGHTFIELD_GEOMETRY
+#define PX_PHYSICS_NX_HEIGHTFIELD_GEOMETRY
+/** \addtogroup geomutils
+@{
+*/
+#include "geometry/PxTriangleMeshGeometry.h"
+#include "common/PxCoreUtilityTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+#define PX_MIN_HEIGHTFIELD_XZ_SCALE 1e-8f
+#define PX_MIN_HEIGHTFIELD_Y_SCALE (0.0001f / PxReal(0xFFFF))
+
+class PxHeightField;
+
+/**
+\brief Height field geometry class.
+
+This class allows to create a scaled height field geometry instance.
+
+There is a minimum allowed value for Y and XZ scaling - PX_MIN_HEIGHTFIELD_XZ_SCALE, heightfield creation will fail if XZ value is below this value.
+*/
+class PxHeightFieldGeometry : public PxGeometry
+{
+public:
+ PX_INLINE PxHeightFieldGeometry() :
+ PxGeometry (PxGeometryType::eHEIGHTFIELD),
+ heightField (NULL),
+ heightScale (1.0f),
+ rowScale (1.0f),
+ columnScale (1.0f),
+ heightFieldFlags(0)
+ {}
+
+ PX_INLINE PxHeightFieldGeometry(PxHeightField* hf,
+ PxMeshGeometryFlags flags,
+ PxReal heightScale_,
+ PxReal rowScale_,
+ PxReal columnScale_) :
+ PxGeometry (PxGeometryType::eHEIGHTFIELD),
+ heightField (hf) ,
+ heightScale (heightScale_),
+ rowScale (rowScale_),
+ columnScale (columnScale_),
+ heightFieldFlags (flags)
+ {
+ }
+
+ /**
+ \brief Returns true if the geometry is valid.
+
+ \return True if the current settings are valid
+
+ \note A valid height field has a positive scale value in each direction (heightScale > 0, rowScale > 0, columnScale > 0).
+ It is illegal to call PxRigidActor::createShape and PxPhysics::createShape with a height field that has zero extents in any direction.
+
+ @see PxRigidActor::createShape, PxPhysics::createShape
+ */
+ PX_INLINE bool isValid() const;
+
+public:
+ /**
+ \brief The height field data.
+ */
+ PxHeightField* heightField;
+
+ /**
+ \brief The scaling factor for the height field in vertical direction (y direction in local space).
+ */
+ PxReal heightScale;
+
+ /**
+ \brief The scaling factor for the height field in the row direction (x direction in local space).
+ */
+ PxReal rowScale;
+
+ /**
+ \brief The scaling factor for the height field in the column direction (z direction in local space).
+ */
+ PxReal columnScale;
+
+ /**
+ \brief Flags to specify some collision properties for the height field.
+ */
+ PxMeshGeometryFlags heightFieldFlags;
+
+ PxPadding<3> paddingFromFlags; //!< padding for mesh flags.
+};
+
+
+PX_INLINE bool PxHeightFieldGeometry::isValid() const
+{
+ if (mType != PxGeometryType::eHEIGHTFIELD)
+ return false;
+ if (!PxIsFinite(heightScale) || !PxIsFinite(rowScale) || !PxIsFinite(columnScale))
+ return false;
+ if (rowScale < PX_MIN_HEIGHTFIELD_XZ_SCALE || columnScale < PX_MIN_HEIGHTFIELD_XZ_SCALE || heightScale < PX_MIN_HEIGHTFIELD_Y_SCALE)
+ return false;
+ if (!heightField)
+ return false;
+
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxHeightFieldSample.h b/sources/PhysX/PhysX/include/geometry/PxHeightFieldSample.h
new file mode 100644
index 00000000..a0489974
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxHeightFieldSample.h
@@ -0,0 +1,124 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NXHEIGHTFIELDSAMPLE
+#define PX_PHYSICS_NXHEIGHTFIELDSAMPLE
+/** \addtogroup geomutils
+@{ */
+
+#include "common/PxPhysXCommonConfig.h"
+#include "foundation/PxBitAndData.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Special material index values for height field samples.
+
+@see PxHeightFieldSample.materialIndex0 PxHeightFieldSample.materialIndex1
+*/
+struct PxHeightFieldMaterial
+{
+ enum Enum
+ {
+ eHOLE = 127 //!< A material indicating that the triangle should be treated as a hole in the mesh.
+ };
+};
+
+/**
+\brief Heightfield sample format.
+
+This format corresponds to the #PxHeightFieldFormat member PxHeightFieldFormat::eS16_TM.
+
+An array of heightfield samples are used when creating a PxHeightField to specify
+the elevation of the heightfield points. In addition the material and tessellation of the adjacent
+triangles are specified.
+
+@see PxHeightField PxHeightFieldDesc PxHeightFieldDesc.samples
+*/
+struct PxHeightFieldSample
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+
+ /**
+ \brief The height of the heightfield sample
+
+ This value is scaled by PxHeightFieldGeometry::heightScale.
+
+ @see PxHeightFieldGeometry
+ */
+ PxI16 height;
+
+ /**
+ \brief The triangle material index of the quad's lower triangle + tesselation flag
+
+ An index pointing into the material table of the shape which instantiates the heightfield.
+ This index determines the material of the lower of the quad's two triangles (i.e. the quad whose
+ upper-left corner is this sample, see the Guide for illustrations).
+
+ Special values of the 7 data bits are defined by PxHeightFieldMaterial
+
+ The tesselation flag specifies which way the quad is split whose upper left corner is this sample.
+ If the flag is set, the diagonal of the quad will run from this sample to the opposite vertex; if not,
+ it will run between the other two vertices (see the Guide for illustrations).
+
+ @see PxHeightFieldGeometry materialIndex1 PxShape.setmaterials() PxShape.getMaterials()
+ */
+ PxBitAndByte materialIndex0;
+
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 tessFlag() const { return PxU8(materialIndex0.isBitSet() ? 1 : 0); } // PT: explicit conversion to make sure we don't break the code
+ PX_CUDA_CALLABLE PX_FORCE_INLINE void setTessFlag() { materialIndex0.setBit(); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE void clearTessFlag() { materialIndex0.clearBit(); }
+
+ /**
+ \brief The triangle material index of the quad's upper triangle + reserved flag
+
+ An index pointing into the material table of the shape which instantiates the heightfield.
+ This index determines the material of the upper of the quad's two triangles (i.e. the quad whose
+ upper-left corner is this sample, see the Guide for illustrations).
+
+ @see PxHeightFieldGeometry materialIndex0 PxShape.setmaterials() PxShape.getMaterials()
+ */
+ PxBitAndByte materialIndex1;
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxMeshQuery.h b/sources/PhysX/PhysX/include/geometry/PxMeshQuery.h
new file mode 100644
index 00000000..7a9cfb6f
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxMeshQuery.h
@@ -0,0 +1,201 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_PX_MESH_QUERY
+#define PX_PHYSICS_GEOMUTILS_PX_MESH_QUERY
+
+/** \addtogroup geomutils
+ @{
+*/
+
+#include "common/PxPhysXCommonConfig.h"
+#include "PxQueryReport.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxGeometry;
+class PxConvexMeshGeometry;
+class PxTriangleMeshGeometry;
+class PxHeightFieldGeometry;
+
+class PxTriangle;
+
+class PxMeshQuery
+{
+public:
+
+ /**
+ \brief Retrieves triangle data from a triangle ID.
+
+ This function can be used together with #findOverlapTriangleMesh() to retrieve triangle properties.
+
+ \param[in] triGeom Geometry of the triangle mesh to extract the triangle from.
+ \param[in] transform Transform for the triangle mesh
+ \param[in] triangleIndex The index of the triangle to retrieve.
+ \param[out] triangle Triangle points in world space.
+ \param[out] vertexIndices Returned vertex indices for given triangle
+ \param[out] adjacencyIndices Returned 3 triangle adjacency internal face indices (0xFFFFFFFF if no adjacency). The mesh must be cooked with cooking param buildTriangleAdjacencies enabled.
+
+ \note This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.
+
+ @see PxTriangle PxTriangleFlags PxTriangleID findOverlapTriangleMesh()
+ */
+ PX_PHYSX_COMMON_API static void getTriangle(const PxTriangleMeshGeometry& triGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);
+
+
+ /**
+ \brief Retrieves triangle data from a triangle ID.
+
+ This function can be used together with #findOverlapHeightField() to retrieve triangle properties.
+
+ \param[in] hfGeom Geometry of the height field to extract the triangle from.
+ \param[in] transform Transform for the height field.
+ \param[in] triangleIndex The index of the triangle to retrieve.
+ \param[out] triangle Triangle points in world space.
+ \param[out] vertexIndices Returned vertex indices for given triangle
+ \param[out] adjacencyIndices Returned 3 triangle adjacency triangle indices (0xFFFFFFFF if no adjacency).
+
+ \note This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.
+ \note TriangleIndex is an index used in internal format, which does have an index out of the bounds in last row.
+ To traverse all tri indices in the HF, the following code can be applied:
+ for (PxU32 row = 0; row < (nbRows - 1); row++)
+ {
+ for (PxU32 col = 0; col < (nbCols - 1); col++)
+ {
+ for (PxU32 k = 0; k < 2; k++)
+ {
+ const PxU32 triIndex = 2 * (row*nbCols + col) + k;
+ ....
+ }
+ }
+ }
+ @see PxTriangle PxTriangleFlags PxTriangleID findOverlapHeightField()
+ */
+ PX_PHYSX_COMMON_API static void getTriangle(const PxHeightFieldGeometry& hfGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);
+
+
+ /**
+ \brief Find the mesh triangles which touch the specified geometry object.
+
+ Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
+
+ \param[in] geom The geometry object to test for mesh triangle overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry
+ \param[in] geomPose Pose of the geometry object
+ \param[in] meshGeom The triangle mesh geometry to check overlap against
+ \param[in] meshPose Pose of the triangle mesh
+ \param[out] results Indices of overlapping triangles
+ \param[in] maxResults Size of 'results' buffer
+ \param[in] startIndex Index of first result to be retrieved. Previous indices are skipped.
+ \param[out] overflow True if a buffer overflow occurred
+ \return Number of overlaps found, i.e. number of elements written to the results buffer
+
+ @see PxTriangleMeshGeometry getTriangle()
+ */
+ PX_PHYSX_COMMON_API static PxU32 findOverlapTriangleMesh( const PxGeometry& geom, const PxTransform& geomPose,
+ const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose,
+ PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow);
+
+ /**
+ \brief Find the height field triangles which touch the specified geometry object.
+
+ Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
+
+ \param[in] geom The geometry object to test for height field overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry. The sphere and capsule queries are currently conservative estimates.
+ \param[in] geomPose Pose of the geometry object
+ \param[in] hfGeom The height field geometry to check overlap against
+ \param[in] hfPose Pose of the height field
+ \param[out] results Indices of overlapping triangles
+ \param[in] maxResults Size of 'results' buffer
+ \param[in] startIndex Index of first result to be retrieved. Previous indices are skipped.
+ \param[out] overflow True if a buffer overflow occurred
+ \return Number of overlaps found, i.e. number of elements written to the results buffer
+
+ @see PxHeightFieldGeometry getTriangle()
+ */
+ PX_PHYSX_COMMON_API static PxU32 findOverlapHeightField(const PxGeometry& geom, const PxTransform& geomPose,
+ const PxHeightFieldGeometry& hfGeom, const PxTransform& hfPose,
+ PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow);
+
+
+ /**
+ \brief Sweep a specified geometry object in space and test for collision with a set of given triangles.
+
+ This function simply sweeps input geometry against each input triangle, in the order they are given.
+ This is an O(N) operation with N = number of input triangles. It does not use any particular acceleration structure.
+
+ \param[in] unitDir Normalized direction of the sweep.
+ \param[in] distance Sweep distance. Needs to be larger than 0. Clamped to PX_MAX_SWEEP_DISTANCE.
+ \param[in] geom The geometry object to sweep. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry
+ \param[in] pose Pose of the geometry object to sweep.
+ \param[in] triangleCount Number of specified triangles
+ \param[in] triangles Array of triangles to sweep against
+ \param[out] sweepHit The sweep hit information. See the notes below for limitations about returned results.
+ \param[in] hitFlags Specification of the kind of information to retrieve on hit. Combination of #PxHitFlag flags. See the notes below for limitations about supported flags.
+ \param[in] cachedIndex Cached triangle index for subsequent calls. Cached triangle is tested first. Optional parameter.
+ \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
+ \param[in] doubleSided Counterpart of PxMeshGeometryFlag::eDOUBLE_SIDED for input triangles.
+ \return True if the swept geometry object hits the specified triangles
+
+ \note Only the following geometry types are currently supported: PxSphereGeometry, PxCapsuleGeometry, PxBoxGeometry
+ \note If a shape from the scene is already overlapping with the query shape in its starting position, the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified.
+ \note This function returns a single closest hit across all the input triangles. Multiple hits are not supported.
+ \note Supported hitFlags are PxHitFlag::eDEFAULT, PxHitFlag::eASSUME_NO_INITIAL_OVERLAP, PxHitFlag::ePRECISE_SWEEP, PxHitFlag::eMESH_BOTH_SIDES, PxHitFlag::eMESH_ANY.
+ \note ePOSITION is only defined when there is no initial overlap (sweepHit.hadInitialOverlap() == false)
+ \note The returned normal for initially overlapping sweeps is set to -unitDir.
+ \note Otherwise the returned normal is the front normal of the triangle even if PxHitFlag::eMESH_BOTH_SIDES is set.
+ \note The returned PxSweepHit::faceIndex parameter will hold the index of the hit triangle in input array, i.e. the range is [0; triangleCount). For initially overlapping sweeps, this is the index of overlapping triangle.
+ \note The returned PxSweepHit::actor and PxSweepHit::shape pointers are not filled.
+ \note The inflation parameter is not compatible with PxHitFlag::ePRECISE_SWEEP.
+
+ @see PxTriangle PxSweepHit PxGeometry PxTransform
+ */
+ PX_PHYSX_COMMON_API static bool sweep(const PxVec3& unitDir,
+ const PxReal distance,
+ const PxGeometry& geom,
+ const PxTransform& pose,
+ PxU32 triangleCount,
+ const PxTriangle* triangles,
+ PxSweepHit& sweepHit,
+ PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
+ const PxU32* cachedIndex = NULL,
+ const PxReal inflation = 0.0f,
+ bool doubleSided = false);
+};
+
+
+#if !PX_DOXYGEN
+}
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxMeshScale.h b/sources/PhysX/PhysX/include/geometry/PxMeshScale.h
new file mode 100644
index 00000000..02bf3659
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxMeshScale.h
@@ -0,0 +1,175 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NX_MESHSCALE
+#define PX_PHYSICS_NX_MESHSCALE
+/** \addtogroup geomutils
+@{
+*/
+
+#include "common/PxPhysXCommonConfig.h"
+#include "foundation/PxMat33.h"
+#include "foundation/PxAssert.h"
+
+/** \brief Minimum allowed absolute magnitude for each of mesh scale's components (x,y,z).
+ \note Only positive scale values are allowed for convex meshes. */
+#define PX_MESH_SCALE_MIN 1e-6f
+
+/** \brief Maximum allowed absolute magnitude for each of mesh scale's components (x,y,z).
+ \note Only positive scale values are allowed for convex meshes. */
+#define PX_MESH_SCALE_MAX 1e6f
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief A class expressing a nonuniform scaling transformation.
+
+The scaling is along arbitrary axes that are specified by PxMeshScale::rotation.
+
+\note Negative scale values are supported for PxTriangleMeshGeometry
+ with absolute values for each component within [PX_MIN_ABS_MESH_SCALE, PX_MAX_ABS_MESH_SCALE] range.
+ Negative scale causes a reflection around the specified axis, in addition PhysX will flip the normals
+ for mesh triangles when scale.x*scale.y*scale.z < 0.
+\note Only positive scale values are supported for PxConvexMeshGeometry
+ with values for each component within [PX_MIN_ABS_MESH_SCALE, PX_MAX_ABS_MESH_SCALE] range).
+
+@see PxConvexMeshGeometry PxTriangleMeshGeometry
+*/
+class PxMeshScale
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+ /**
+ \brief Constructor initializes to identity scale.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(): scale(1.0f), rotation(PxIdentity)
+ {
+ }
+
+ /**
+ \brief Constructor from scalar.
+ */
+ explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(PxReal r): scale(r), rotation(PxIdentity)
+ {
+ }
+
+ /**
+ \brief Constructor to initialize to arbitrary scale and identity scale rotation.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s)
+ {
+ scale = s;
+ rotation = PxQuat(PxIdentity);
+ }
+
+ /**
+ \brief Constructor to initialize to arbitrary scaling.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s, const PxQuat& r)
+ {
+ PX_ASSERT(r.isUnit());
+ scale = s;
+ rotation = r;
+ }
+
+
+ /**
+ \brief Returns true if the scaling is an identity transformation.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE bool isIdentity() const
+ {
+ return (scale.x == 1.0f && scale.y == 1.0f && scale.z == 1.0f);
+ }
+
+ /**
+ \brief Returns the inverse of this scaling transformation.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale getInverse() const
+ {
+ return PxMeshScale(PxVec3(1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z), rotation);
+ }
+
+ /**
+ \brief Converts this transformation to a 3x3 matrix representation.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 toMat33() const
+ {
+ PxMat33 rot(rotation);
+ PxMat33 trans = rot.getTranspose();
+ trans.column0 *= scale[0];
+ trans.column1 *= scale[1];
+ trans.column2 *= scale[2];
+ return trans * rot;
+ }
+
+ /**
+ \brief Returns true if combination of negative scale components will cause the triangle normal to flip. The SDK will flip the normals internally.
+ */
+ PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNegativeDeterminant() const
+ {
+ return (scale.x * scale.y * scale.z < 0.0f);
+ }
+
+ PxVec3 transform(const PxVec3& v) const
+ {
+ return rotation.rotateInv(scale.multiply(rotation.rotate(v)));
+ }
+
+ bool isValidForTriangleMesh() const
+ {
+ PxVec3 absXYZ = scale.abs();
+ return (absXYZ.maxElement() <= PX_MESH_SCALE_MAX) && (absXYZ.minElement() >= PX_MESH_SCALE_MIN);
+ }
+
+ bool isValidForConvexMesh() const
+ {
+ return (scale.maxElement() <= PX_MESH_SCALE_MAX) && (scale.minElement() >= PX_MESH_SCALE_MIN);
+ }
+
+ PxVec3 scale; //!< A nonuniform scaling
+ PxQuat rotation; //!< The orientation of the scaling axes
+
+
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxPlaneGeometry.h b/sources/PhysX/PhysX/include/geometry/PxPlaneGeometry.h
new file mode 100644
index 00000000..cbc80e8d
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxPlaneGeometry.h
@@ -0,0 +1,108 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NX_PLANE_GEOMETRY
+#define PX_PHYSICS_NX_PLANE_GEOMETRY
+/** \addtogroup geomutils
+@{
+*/
+#include "foundation/PxPlane.h"
+#include "foundation/PxTransform.h"
+#include "geometry/PxGeometry.h"
+#include "foundation/PxFoundationConfig.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Class describing a plane geometry.
+
+The plane geometry specifies the half-space volume x<=0. As with other geometry types,
+when used in a PxShape the collision volume is obtained by transforming the halfspace
+by the shape local pose and the actor global pose.
+
+To generate a PxPlane from a PxTransform, transform PxPlane(1,0,0,0).
+
+To generate a PxTransform from a PxPlane, use PxTransformFromPlaneEquation.
+
+@see PxShape.setGeometry() PxShape.getPlaneGeometry() PxTransformFromPlaneEquation
+*/
+class PxPlaneGeometry : public PxGeometry
+{
+public:
+ PX_INLINE PxPlaneGeometry() : PxGeometry(PxGeometryType::ePLANE) {}
+
+ /**
+ \brief Returns true if the geometry is valid.
+
+ \return True if the current settings are valid
+ */
+ PX_INLINE bool isValid() const;
+};
+
+
+PX_INLINE bool PxPlaneGeometry::isValid() const
+{
+ if (mType != PxGeometryType::ePLANE)
+ return false;
+
+ return true;
+}
+
+
+/** \brief creates a transform from a plane equation, suitable for an actor transform for a PxPlaneGeometry
+
+\param[in] plane the desired plane equation
+\return a PxTransform which will transform the plane PxPlane(1,0,0,0) to the specified plane
+*/
+
+PX_FOUNDATION_API PxTransform PxTransformFromPlaneEquation(const PxPlane& plane);
+
+/** \brief creates a plane equation from a transform, such as the actor transform for a PxPlaneGeometry
+
+\param[in] transform the transform
+\return the plane
+*/
+
+
+PX_INLINE PxPlane PxPlaneEquationFromTransform(const PxTransform& transform)
+{
+ return transform.transform(PxPlane(1.f,0.f,0.f,0.f));
+}
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxSimpleTriangleMesh.h b/sources/PhysX/PhysX/include/geometry/PxSimpleTriangleMesh.h
new file mode 100644
index 00000000..643905dd
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxSimpleTriangleMesh.h
@@ -0,0 +1,166 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_NX_SIMPLETRIANGLEMESH
+#define PX_PHYSICS_GEOMUTILS_NX_SIMPLETRIANGLEMESH
+/** \addtogroup geomutils
+@{
+*/
+
+#include "foundation/PxVec3.h"
+#include "foundation/PxFlags.h"
+#include "common/PxCoreUtilityTypes.h"
+#include "common/PxPhysXCommonConfig.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Enum with flag values to be used in PxSimpleTriangleMesh::flags.
+*/
+struct PxMeshFlag
+{
+ enum Enum
+ {
+ /**
+ \brief Specifies if the SDK should flip normals.
+
+ The PhysX libraries assume that the face normal of a triangle with vertices [a,b,c] can be computed as:
+ edge1 = b-a
+ edge2 = c-a
+ face_normal = edge1 x edge2.
+
+ Note: This is the same as a counterclockwise winding in a right handed coordinate system or
+ alternatively a clockwise winding order in a left handed coordinate system.
+
+ If this does not match the winding order for your triangles, raise the below flag.
+ */
+ eFLIPNORMALS = (1<<0),
+ e16_BIT_INDICES = (1<<1) //!< Denotes the use of 16-bit vertex indices
+ };
+};
+
+/**
+\brief collection of set bits defined in PxMeshFlag.
+
+@see PxMeshFlag
+*/
+typedef PxFlags PxMeshFlags;
+PX_FLAGS_OPERATORS(PxMeshFlag::Enum,PxU16)
+
+
+/**
+\brief A structure describing a triangle mesh.
+*/
+class PxSimpleTriangleMesh
+{
+public:
+
+ /**
+ \brief Pointer to first vertex point.
+ */
+ PxBoundedData points;
+
+ /**
+ \brief Pointer to first triangle.
+
+ Caller may add triangleStrideBytes bytes to the pointer to access the next triangle.
+
+ These are triplets of 0 based indices:
+ vert0 vert1 vert2
+ vert0 vert1 vert2
+ vert0 vert1 vert2
+ ...
+
+ where vertex is either a 32 or 16 bit unsigned integer. There are numTriangles*3 indices.
+
+ This is declared as a void pointer because it is actually either an PxU16 or a PxU32 pointer.
+ */
+ PxBoundedData triangles;
+
+ /**
+ \brief Flags bits, combined from values of the enum ::PxMeshFlag
+ */
+ PxMeshFlags flags;
+
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE PxSimpleTriangleMesh();
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+ /**
+ \brief returns true if the current settings are valid
+ */
+ PX_INLINE bool isValid() const;
+};
+
+
+PX_INLINE PxSimpleTriangleMesh::PxSimpleTriangleMesh()
+{
+}
+
+PX_INLINE void PxSimpleTriangleMesh::setToDefault()
+{
+ *this = PxSimpleTriangleMesh();
+}
+
+PX_INLINE bool PxSimpleTriangleMesh::isValid() const
+{
+ // Check geometry
+ if(points.count > 0xffff && flags & PxMeshFlag::e16_BIT_INDICES)
+ return false;
+ if(!points.data)
+ return false;
+ if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
+ return false;
+
+ // Check topology
+ // The triangles pointer is not mandatory
+ if(triangles.data)
+ {
+ // Indexed mesh
+ PxU32 limit = (flags & PxMeshFlag::e16_BIT_INDICES) ? sizeof(PxU16)*3 : sizeof(PxU32)*3;
+ if(triangles.stride < limit)
+ return false;
+ }
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxSphereGeometry.h b/sources/PhysX/PhysX/include/geometry/PxSphereGeometry.h
new file mode 100644
index 00000000..b89191d4
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxSphereGeometry.h
@@ -0,0 +1,93 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NX_SPHERE_GEOMETRY
+#define PX_PHYSICS_NX_SPHERE_GEOMETRY
+/** \addtogroup geomutils
+@{
+*/
+#include "geometry/PxGeometry.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief A class representing the geometry of a sphere.
+
+Spheres are defined by their radius.
+\note The scaling of the sphere is expected to be baked into this value, there is no additional scaling parameter.
+*/
+class PxSphereGeometry : public PxGeometry
+{
+public:
+ PX_INLINE PxSphereGeometry() : PxGeometry(PxGeometryType::eSPHERE), radius(0) {}
+ PX_INLINE PxSphereGeometry(PxReal ir) : PxGeometry(PxGeometryType::eSPHERE), radius(ir) {}
+
+ /**
+ \brief Returns true if the geometry is valid.
+
+ \return True if the current settings are valid
+
+ \note A valid sphere has radius > 0.
+ It is illegal to call PxRigidActor::createShape and PxPhysics::createShape with a sphere that has zero radius.
+
+ @see PxRigidActor::createShape, PxPhysics::createShape
+ */
+ PX_INLINE bool isValid() const;
+
+public:
+
+ /**
+ \brief The radius of the sphere.
+ */
+ PxReal radius;
+};
+
+
+PX_INLINE bool PxSphereGeometry::isValid() const
+{
+ if (mType != PxGeometryType::eSPHERE)
+ return false;
+ if (!PxIsFinite(radius))
+ return false;
+ if (radius <= 0.0f)
+ return false;
+
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxTriangle.h b/sources/PhysX/PhysX/include/geometry/PxTriangle.h
new file mode 100644
index 00000000..8ccc6d64
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxTriangle.h
@@ -0,0 +1,149 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_PX_TRIANGLE
+#define PX_PHYSICS_GEOMUTILS_PX_TRIANGLE
+/** \addtogroup geomutils
+ @{
+*/
+
+#include "common/PxPhysXCommonConfig.h"
+#include "foundation/PxVec3.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Triangle class.
+*/
+class PxTriangle
+{
+ public:
+ /**
+ \brief Constructor
+ */
+ PX_FORCE_INLINE PxTriangle() {}
+
+ /**
+ \brief Constructor
+
+ \param[in] p0 Point 0
+ \param[in] p1 Point 1
+ \param[in] p2 Point 2
+ */
+ PX_FORCE_INLINE PxTriangle(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2)
+ {
+ verts[0] = p0;
+ verts[1] = p1;
+ verts[2] = p2;
+ }
+
+ /**
+ \brief Copy constructor
+
+ \param[in] triangle Tri to copy
+ */
+ PX_FORCE_INLINE PxTriangle(const PxTriangle& triangle)
+ {
+ verts[0] = triangle.verts[0];
+ verts[1] = triangle.verts[1];
+ verts[2] = triangle.verts[2];
+ }
+
+ /**
+ \brief Destructor
+ */
+ PX_FORCE_INLINE ~PxTriangle() {}
+
+ /**
+ \brief Assignment operator
+ */
+ PX_FORCE_INLINE void operator=(const PxTriangle& triangle)
+ {
+ verts[0] = triangle.verts[0];
+ verts[1] = triangle.verts[1];
+ verts[2] = triangle.verts[2];
+ }
+
+ /**
+ \brief Compute the normal of the Triangle.
+
+ \param[out] _normal Triangle normal.
+ */
+ PX_FORCE_INLINE void normal(PxVec3& _normal) const
+ {
+ _normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
+ _normal.normalize();
+ }
+
+ /**
+ \brief Compute the unnormalized normal of the triangle.
+
+ \param[out] _normal Triangle normal (not normalized).
+ */
+ PX_FORCE_INLINE void denormalizedNormal(PxVec3& _normal) const
+ {
+ _normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
+ }
+
+ /**
+ \brief Compute the area of the triangle.
+
+ \return Area of the triangle.
+ */
+ PX_FORCE_INLINE PxReal area() const
+ {
+ const PxVec3& p0 = verts[0];
+ const PxVec3& p1 = verts[1];
+ const PxVec3& p2 = verts[2];
+ return ((p0 - p1).cross(p0 - p2)).magnitude() * 0.5f;
+ }
+
+ /**
+ \return Computes a point on the triangle from u and v barycentric coordinates.
+ */
+ PxVec3 pointFromUV(PxReal u, PxReal v) const { return (1.0f-u-v)*verts[0] + u*verts[1] + v*verts[2]; }
+
+ /**
+ \brief Array of Vertices.
+ */
+ PxVec3 verts[3];
+
+};
+
+
+#if !PX_DOXYGEN
+}
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxTriangleMesh.h b/sources/PhysX/PhysX/include/geometry/PxTriangleMesh.h
new file mode 100644
index 00000000..6b0eb2ef
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxTriangleMesh.h
@@ -0,0 +1,317 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_GEOMUTILS_NX_TRIANGLEMESH
+#define PX_PHYSICS_GEOMUTILS_NX_TRIANGLEMESH
+/** \addtogroup geomutils
+@{ */
+
+#include "foundation/PxVec3.h"
+#include "foundation/PxBounds3.h"
+#include "common/PxPhysXCommonConfig.h"
+#include "common/PxBase.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Enables the dynamic rtree mesh feature. It is recommended to use this feature for scene queries only.
+@see PxTriangleMesh::getVerticesForModification
+@see PxTriangleMesh::refitBVH
+*/
+#define PX_ENABLE_DYNAMIC_MESH_RTREE 1
+
+/**
+\brief Mesh midphase structure. This enum is used to select the desired acceleration structure for midphase queries
+ (i.e. raycasts, overlaps, sweeps vs triangle meshes).
+
+ The PxMeshMidPhase::eBVH33 structure is the one used in recent PhysX versions (up to PhysX 3.3). It has great performance and is
+ supported on all platforms.
+
+ The PxMeshMidPhase::eBVH34 structure is a revisited implementation introduced in PhysX 3.4. It can be significantly faster both
+ in terms of cooking performance and runtime performance, but it is currently only available on platforms supporting the
+ SSE2 instuction set.
+*/
+struct PxMeshMidPhase
+{
+ enum Enum
+ {
+ eBVH33 = 0, //!< Default midphase mesh structure, as used up to PhysX 3.3
+ eBVH34 = 1, //!< New midphase mesh structure, introduced in PhysX 3.4
+
+ eLAST
+ };
+};
+
+/**
+\brief Flags for the mesh geometry properties.
+
+Used in ::PxTriangleMeshFlags.
+*/
+struct PxTriangleMeshFlag
+{
+ enum Enum
+ {
+ e16_BIT_INDICES = (1<<1), //!< The triangle mesh has 16bits vertex indices.
+ eADJACENCY_INFO = (1<<2) //!< The triangle mesh has adjacency information build.
+ };
+};
+
+/**
+\brief collection of set bits defined in PxTriangleMeshFlag.
+
+@see PxTriangleMeshFlag
+*/
+typedef PxFlags PxTriangleMeshFlags;
+PX_FLAGS_OPERATORS(PxTriangleMeshFlag::Enum,PxU8)
+
+/**
+
+\brief A triangle mesh, also called a 'polygon soup'.
+
+It is represented as an indexed triangle list. There are no restrictions on the
+triangle data.
+
+To avoid duplicating data when you have several instances of a particular
+mesh positioned differently, you do not use this class to represent a
+mesh object directly. Instead, you create an instance of this mesh via
+the PxTriangleMeshGeometry and PxShape classes.
+
+Creation
+
+To create an instance of this class call PxPhysics::createTriangleMesh(),
+and release() to delete it. This is only possible
+once you have released all of its PxShape instances.
+
+
+Visualizations:
+\li #PxVisualizationParameter::eCOLLISION_AABBS
+\li #PxVisualizationParameter::eCOLLISION_SHAPES
+\li #PxVisualizationParameter::eCOLLISION_AXES
+\li #PxVisualizationParameter::eCOLLISION_FNORMALS
+\li #PxVisualizationParameter::eCOLLISION_EDGES
+
+@see PxTriangleMeshDesc PxTriangleMeshGeometry PxShape PxPhysics.createTriangleMesh()
+*/
+
+class PxTriangleMesh : public PxBase
+{
+ public:
+ /**
+ \brief Returns the number of vertices.
+ \return number of vertices
+ @see getVertices()
+ */
+ virtual PxU32 getNbVertices() const = 0;
+
+ /**
+ \brief Returns the vertices.
+ \return array of vertices
+ @see getNbVertices()
+ */
+ virtual const PxVec3* getVertices() const = 0;
+
+#if PX_ENABLE_DYNAMIC_MESH_RTREE
+ /**
+ \brief Returns all mesh vertices for modification.
+
+ This function will return the vertices of the mesh so that their positions can be changed in place.
+ After modifying the vertices you must call refitBVH for the refitting to actually take place.
+ This function maintains the old mesh topology (triangle indices).
+
+ \return inplace vertex coordinates for each existing mesh vertex.
+
+ \note works only for PxMeshMidPhase::eBVH33
+ \note Size of array returned is equal to the number returned by getNbVertices().
+ \note This function operates on cooked vertex indices.
+ \note This means the index mapping and vertex count can be different from what was provided as an input to the cooking routine.
+ \note To achieve unchanged 1-to-1 index mapping with orignal mesh data (before cooking) please use the following cooking flags:
+ \note eWELD_VERTICES = 0, eDISABLE_CLEAN_MESH = 1.
+ \note It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled.
+ @see getNbVertices()
+ @see refitBVH()
+ */
+ virtual PxVec3* getVerticesForModification() = 0;
+
+ /**
+ \brief Refits BVH for mesh vertices.
+
+ This function will refit the mesh BVH to correctly enclose the new positions updated by getVerticesForModification.
+ Mesh BVH will not be reoptimized by this function so significantly different new positions will cause significantly reduced performance.
+
+ \return New bounds for the entire mesh.
+
+ \note works only for PxMeshMidPhase::eBVH33
+ \note PhysX does not keep a mapping from the mesh to mesh shapes that reference it.
+ \note Call PxShape::setGeometry on each shape which references the mesh, to ensure that internal data structures are updated to reflect the new geometry.
+ \note PxShape::setGeometry does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.
+ \note It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled.
+ \note Active edges information will be lost during refit, the rigid body mesh contact generation might not perform as expected.
+ @see getNbVertices()
+ @see getVerticesForModification()
+ */
+ virtual PxBounds3 refitBVH() = 0;
+#endif // PX_ENABLE_DYNAMIC_MESH_RTREE
+
+ /**
+ \brief Returns the number of triangles.
+ \return number of triangles
+ @see getTriangles() getTrianglesRemap()
+ */
+ virtual PxU32 getNbTriangles() const = 0;
+
+ /**
+ \brief Returns the triangle indices.
+
+ The indices can be 16 or 32bit depending on the number of triangles in the mesh.
+ Call getTriangleMeshFlags() to know if the indices are 16 or 32 bits.
+
+ The number of indices is the number of triangles * 3.
+
+ \return array of triangles
+ @see getNbTriangles() getTriangleMeshFlags() getTrianglesRemap()
+ */
+ virtual const void* getTriangles() const = 0;
+
+ /**
+ \brief Reads the PxTriangleMesh flags.
+
+ See the list of flags #PxTriangleMeshFlag
+
+ \return The values of the PxTriangleMesh flags.
+
+ @see PxTriangleMesh
+ */
+ virtual PxTriangleMeshFlags getTriangleMeshFlags() const = 0;
+
+ /**
+ \brief Returns the triangle remapping table.
+
+ The triangles are internally sorted according to various criteria. Hence the internal triangle order
+ does not always match the original (user-defined) order. The remapping table helps finding the old
+ indices knowing the new ones:
+
+ remapTable[ internalTriangleIndex ] = originalTriangleIndex
+
+ \return the remapping table (or NULL if 'PxCookingParams::suppressTriangleMeshRemapTable' has been used)
+ @see getNbTriangles() getTriangles() PxCookingParams::suppressTriangleMeshRemapTable
+ */
+ virtual const PxU32* getTrianglesRemap() const = 0;
+
+
+ /**
+ \brief Decrements the reference count of a triangle mesh and releases it if the new reference count is zero.
+
+ @see PxPhysics.createTriangleMesh()
+ */
+ virtual void release() = 0;
+
+ /**
+ \brief Returns material table index of given triangle
+
+ This function takes a post cooking triangle index.
+
+ \param[in] triangleIndex (internal) index of desired triangle
+ \return Material table index, or 0xffff if no per-triangle materials are used
+ */
+ virtual PxMaterialTableIndex getTriangleMaterialIndex(PxTriangleID triangleIndex) const = 0;
+
+ /**
+ \brief Returns the local-space (vertex space) AABB from the triangle mesh.
+
+ \return local-space bounds
+ */
+ virtual PxBounds3 getLocalBounds() const = 0;
+
+ /**
+ \brief Returns the reference count for shared meshes.
+
+ At creation, the reference count of the mesh is 1. Every shape referencing this mesh increments the
+ count by 1. When the reference count reaches 0, and only then, the mesh gets destroyed automatically.
+
+ \return the current reference count.
+ */
+ virtual PxU32 getReferenceCount() const = 0;
+
+ /**
+ \brief Acquires a counted reference to a triangle mesh.
+
+ This method increases the reference count of the triangle mesh by 1. Decrement the reference count by calling release()
+ */
+ virtual void acquireReference() = 0;
+
+protected:
+ PX_INLINE PxTriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
+ PX_INLINE PxTriangleMesh(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
+ virtual ~PxTriangleMesh() {}
+
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxTriangleMesh", name) || PxBase::isKindOf(name); }
+};
+
+/**
+
+\brief A triangle mesh containing the PxMeshMidPhase::eBVH33 structure.
+
+@see PxMeshMidPhase
+*/
+class PxBVH33TriangleMesh : public PxTriangleMesh
+{
+ public:
+protected:
+ PX_INLINE PxBVH33TriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxTriangleMesh(concreteType, baseFlags) {}
+ PX_INLINE PxBVH33TriangleMesh(PxBaseFlags baseFlags) : PxTriangleMesh(baseFlags) {}
+ virtual ~PxBVH33TriangleMesh() {}
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxBVH33TriangleMesh", name) || PxTriangleMesh::isKindOf(name); }
+};
+
+/**
+
+\brief A triangle mesh containing the PxMeshMidPhase::eBVH34 structure.
+
+@see PxMeshMidPhase
+*/
+class PxBVH34TriangleMesh : public PxTriangleMesh
+{
+ public:
+protected:
+ PX_INLINE PxBVH34TriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxTriangleMesh(concreteType, baseFlags) {}
+ PX_INLINE PxBVH34TriangleMesh(PxBaseFlags baseFlags) : PxTriangleMesh(baseFlags) {}
+ virtual ~PxBVH34TriangleMesh() {}
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxBVH34TriangleMesh", name) || PxTriangleMesh::isKindOf(name); }
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geometry/PxTriangleMeshGeometry.h b/sources/PhysX/PhysX/include/geometry/PxTriangleMeshGeometry.h
new file mode 100644
index 00000000..56f58f79
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geometry/PxTriangleMeshGeometry.h
@@ -0,0 +1,150 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_PHYSICS_NX_TRIANGLEMESH_GEOMETRY
+#define PX_PHYSICS_NX_TRIANGLEMESH_GEOMETRY
+/** \addtogroup geomutils
+@{
+*/
+#include "geometry/PxGeometry.h"
+#include "geometry/PxMeshScale.h"
+#include "common/PxCoreUtilityTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxTriangleMesh;
+
+
+/**
+\brief Flags controlling the simulated behavior of the triangle mesh geometry.
+
+Used in ::PxMeshGeometryFlags.
+*/
+struct PxMeshGeometryFlag
+{
+ enum Enum
+ {
+ eDOUBLE_SIDED = (1<<1) //!< Meshes with this flag set are treated as double-sided.
+ //!< This flag is currently only used for raycasts and sweeps (it is ignored for overlap queries).
+ //!< For detailed specifications of this flag for meshes and heightfields please refer to the Geometry Query section of the user guide.
+ };
+};
+
+/**
+\brief collection of set bits defined in PxMeshGeometryFlag.
+
+@see PxMeshGeometryFlag
+*/
+typedef PxFlags PxMeshGeometryFlags;
+PX_FLAGS_OPERATORS(PxMeshGeometryFlag::Enum,PxU8)
+
+/**
+\brief Triangle mesh geometry class.
+
+This class unifies a mesh object with a scaling transform, and
+lets the combined object be used anywhere a PxGeometry is needed.
+
+The scaling is a transform along arbitrary axes contained in the scale object.
+The vertices of the mesh in geometry (or shape) space is the
+PxMeshScale::toMat33() transform, multiplied by the vertex space vertices
+in the PxConvexMesh object.
+*/
+class PxTriangleMeshGeometry : public PxGeometry
+{
+public:
+ /**
+ \brief Default constructor.
+
+ Creates an empty object with a NULL mesh and identity scale.
+ */
+ PX_INLINE PxTriangleMeshGeometry() :
+ PxGeometry (PxGeometryType::eTRIANGLEMESH),
+ triangleMesh(NULL)
+ {}
+
+ /**
+ \brief Constructor.
+ \param[in] mesh Mesh pointer. May be NULL, though this will not make the object valid for shape construction.
+ \param[in] scaling Scale factor.
+ \param[in] flags Mesh flags.
+ \
+ */
+ PX_INLINE PxTriangleMeshGeometry( PxTriangleMesh* mesh,
+ const PxMeshScale& scaling = PxMeshScale(),
+ PxMeshGeometryFlags flags = PxMeshGeometryFlags()) :
+ PxGeometry (PxGeometryType::eTRIANGLEMESH),
+ scale (scaling),
+ meshFlags (flags),
+ triangleMesh(mesh)
+ {}
+
+ /**
+ \brief Returns true if the geometry is valid.
+
+ \return True if the current settings are valid for shape creation.
+
+ \note A valid triangle mesh has a positive scale value in each direction (scale.scale.x > 0, scale.scale.y > 0, scale.scale.z > 0).
+ It is illegal to call PxRigidActor::createShape and PxPhysics::createShape with a triangle mesh that has zero extents in any direction.
+
+ @see PxRigidActor::createShape, PxPhysics::createShape
+ */
+ PX_INLINE bool isValid() const;
+
+public:
+ PxMeshScale scale; //!< The scaling transformation.
+ PxMeshGeometryFlags meshFlags; //!< Mesh flags.
+ PxPadding<3> paddingFromFlags; //!< padding for mesh flags
+ PxTriangleMesh* triangleMesh; //!< A reference to the mesh object.
+};
+
+
+PX_INLINE bool PxTriangleMeshGeometry::isValid() const
+{
+ if(mType != PxGeometryType::eTRIANGLEMESH)
+ return false;
+ if(!scale.scale.isFinite() || !scale.rotation.isUnit())
+ return false;
+ if(!scale.isValidForTriangleMesh())
+ return false;
+ if(!triangleMesh)
+ return false;
+
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/geomutils/GuContactBuffer.h b/sources/PhysX/PhysX/include/geomutils/GuContactBuffer.h
new file mode 100644
index 00000000..78673579
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geomutils/GuContactBuffer.h
@@ -0,0 +1,131 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef GU_CONTACTBUFFER_H
+#define GU_CONTACTBUFFER_H
+
+#include "geomutils/GuContactPoint.h"
+#include "PxPhysXConfig.h"
+#include "PxContact.h"
+
+namespace physx
+{
+namespace Gu
+{
+
+ struct NarrowPhaseParams
+ {
+ PX_FORCE_INLINE NarrowPhaseParams(PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength) :
+ mContactDistance(contactDistance),
+ mMeshContactMargin(meshContactMargin),
+ mToleranceLength(toleranceLength) {}
+
+ PxReal mContactDistance;
+ PxReal mMeshContactMargin; // PT: Margin used to generate mesh contacts. Temp & unclear, should be removed once GJK is default path.
+ PxReal mToleranceLength; // PT: copy of PxTolerancesScale::length
+ };
+
+//sizeof(SavedContactData)/sizeof(PxU32) = 17, 1088/17 = 64 triangles in the local array
+#define LOCAL_CONTACTS_SIZE 1088
+
+class ContactBuffer
+{
+public:
+
+ static const PxU32 MAX_CONTACTS = 64;
+
+ Gu::ContactPoint contacts[MAX_CONTACTS];
+ PxU32 count;
+ PxU32 pad;
+
+ PX_FORCE_INLINE void reset()
+ {
+ count = 0;
+ }
+
+ PX_FORCE_INLINE bool contact(const PxVec3& worldPoint,
+ const PxVec3& worldNormalIn,
+ PxReal separation,
+ PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
+ )
+ {
+ PX_ASSERT(PxAbs(worldNormalIn.magnitude()-1)<1e-3f);
+
+ if(count>=MAX_CONTACTS)
+ return false;
+
+ Gu::ContactPoint& p = contacts[count++];
+ p.normal = worldNormalIn;
+ p.point = worldPoint;
+ p.separation = separation;
+ p.internalFaceIndex1= faceIndex1;
+ return true;
+ }
+
+ PX_FORCE_INLINE bool contact(const PxVec3& worldPoint,
+ const PxVec3& worldNormalIn,
+ PxReal separation,
+ PxU16 internalUsage,
+ PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
+ )
+ {
+ PX_ASSERT(PxAbs(worldNormalIn.magnitude() - 1)<1e-3f);
+
+ if (count >= MAX_CONTACTS)
+ return false;
+
+ Gu::ContactPoint& p = contacts[count++];
+ p.normal = worldNormalIn;
+ p.point = worldPoint;
+ p.separation = separation;
+ p.internalFaceIndex1 = faceIndex1;
+ p.forInternalUse = internalUsage;
+ return true;
+ }
+
+ PX_FORCE_INLINE bool contact(const Gu::ContactPoint & pt)
+ {
+ if(count>=MAX_CONTACTS)
+ return false;
+ contacts[count++] = pt;
+ return true;
+ }
+
+ PX_FORCE_INLINE Gu::ContactPoint* contact()
+ {
+ if(count>=MAX_CONTACTS)
+ return NULL;
+ return &contacts[count++];
+ }
+};
+
+}
+}
+
+#endif
diff --git a/sources/PhysX/PhysX/include/geomutils/GuContactPoint.h b/sources/PhysX/PhysX/include/geomutils/GuContactPoint.h
new file mode 100644
index 00000000..33f851d6
--- /dev/null
+++ b/sources/PhysX/PhysX/include/geomutils/GuContactPoint.h
@@ -0,0 +1,109 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef GU_CONTACT_POINT_H
+#define GU_CONTACT_POINT_H
+
+/** \addtogroup geomutils
+@{
+*/
+
+#include "foundation/PxVec3.h"
+
+namespace physx
+{
+namespace Gu
+{
+
+struct ContactPoint
+{
+ /**
+ \brief The normal of the contacting surfaces at the contact point.
+
+ For two shapes s0 and s1, the normal points in the direction that s0 needs to move in to resolve the contact with s1.
+ */
+ PX_ALIGN(16, PxVec3 normal);
+ /**
+ \brief The separation of the shapes at the contact point. A negative separation denotes a penetration.
+ */
+ PxReal separation;
+
+ /**
+ \brief The point of contact between the shapes, in world space.
+ */
+ PX_ALIGN(16, PxVec3 point);
+
+ /**
+ \brief The max impulse permitted at this point
+ */
+ PxReal maxImpulse;
+
+ PX_ALIGN(16, PxVec3 targetVel);
+
+ /**
+ \brief The static friction coefficient
+ */
+ PxReal staticFriction;
+
+ /**
+ \brief Material flags for this contact (eDISABLE_FRICTION, eDISABLE_STRONG_FRICTION). @see PxMaterialFlag
+ */
+ PxU8 materialFlags;
+
+ /**
+ \brief internal structure used for internal use only
+ */
+ PxU16 forInternalUse;
+
+ /**
+ \brief The surface index of shape 1 at the contact point. This is used to identify the surface material.
+
+ \note This field is only supported by triangle meshes and heightfields, else it will be set to PXC_CONTACT_NO_FACE_INDEX.
+ \note This value must be directly after internalFaceIndex0 in memory
+ */
+
+ PxU32 internalFaceIndex1;
+
+ /**
+ \brief The dynamic friction coefficient
+ */
+ PxReal dynamicFriction;
+ /**
+ \brief The restitution coefficient
+ */
+ PxReal restitution;
+
+};
+
+}
+
+}
+
+/** @} */
+#endif
diff --git a/sources/PhysX/PhysX/include/gpu/PxGpu.h b/sources/PhysX/PhysX/include/gpu/PxGpu.h
new file mode 100644
index 00000000..60210a6b
--- /dev/null
+++ b/sources/PhysX/PhysX/include/gpu/PxGpu.h
@@ -0,0 +1,96 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_GPU_H
+#define PX_GPU_H
+
+#include "PxPhysXConfig.h"
+
+
+#if PX_SUPPORT_GPU_PHYSX
+
+#include "cudamanager/PxCudaContextManager.h"
+#include "cudamanager/PxCudaMemoryManager.h"
+#include "foundation/Px.h"
+#include "foundation/PxPreprocessor.h"
+#include "common/PxPhysXCommonConfig.h"
+#include "PxFoundation.h"
+
+/**
+\brief PxGpuLoadHook
+
+This is a helper class for loading the PhysXGpu dll.
+If a PhysXGpu dll with a non-default file name needs to be loaded,
+PxGpuLoadHook can be sub-classed to provide the custom filenames.
+
+Once the names are set, the instance must be set for use by PhysX.dll using PxSetPhysXGpuLoadHook(),
+
+@see PxSetPhysXGpuLoadHook()
+*/
+class PxGpuLoadHook
+{
+public:
+ PxGpuLoadHook() {}
+ virtual ~PxGpuLoadHook() {}
+
+ virtual const char* getPhysXGpuDllName() const = 0;
+
+protected:
+private:
+};
+
+/**
+\brief Sets GPU load hook instance for PhysX dll.
+
+\param[in] hook GPU load hook.
+
+@see PxGpuLoadHook
+*/
+PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxSetPhysXGpuLoadHook(const PxGpuLoadHook* hook);
+
+/**
+ * \brief Ask the NVIDIA control panel which GPU has been selected for use by
+ * PhysX. Returns -1 if no PhysX capable GPU is found or GPU PhysX has
+ * been disabled.
+ */
+PX_C_EXPORT PX_PHYSX_CORE_API int PX_CALL_CONV PxGetSuggestedCudaDeviceOrdinal(physx::PxErrorCallback& errc);
+
+/**
+ * \brief Allocate a CUDA Context manager, complete with heaps.
+ * You only need one CUDA context manager per GPU device you intend to use for
+ * CUDA tasks.
+ \param[in] foundation PhysXFoundation instance.
+ \param[in] desc Cuda context manager desc.
+ \param[in] profilerCallback PhysX profiler callback instance.
+
+ @see PxGetProfilerCallback()
+ */
+PX_C_EXPORT PX_PHYSX_CORE_API physx::PxCudaContextManager* PX_CALL_CONV PxCreateCudaContextManager(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback = NULL);
+
+#endif // PX_SUPPORT_GPU_PHYSX
+
+#endif // PX_GPU_H
diff --git a/sources/PhysX/PhysX/include/pvd/PxPvd.h b/sources/PhysX/PhysX/include/pvd/PxPvd.h
new file mode 100644
index 00000000..08b4aaba
--- /dev/null
+++ b/sources/PhysX/PhysX/include/pvd/PxPvd.h
@@ -0,0 +1,178 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PXPVDSDK_PXPVD_H
+#define PXPVDSDK_PXPVD_H
+
+/** \addtogroup pvd
+@{
+*/
+#include "foundation/PxFlags.h"
+#include "foundation/PxProfiler.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxFoundation;
+class PxPvdTransport;
+
+/**
+\brief types of instrumentation that PVD can do.
+*/
+struct PxPvdInstrumentationFlag
+{
+ enum Enum
+ {
+ /**
+ \brief Send debugging information to PVD.
+
+ This information is the actual object data of the rigid statics, shapes,
+ articulations, etc. Sending this information has a noticeable impact on
+ performance and thus this flag should not be set if you want an accurate
+ performance profile.
+ */
+ eDEBUG = 1 << 0,
+
+ /**
+ \brief Send profile information to PVD.
+
+ This information populates PVD's profile view. It has (at this time) negligible
+ cost compared to Debug information and makes PVD *much* more useful so it is quite
+ highly recommended.
+
+ This flag works together with a PxCreatePhysics parameter.
+ Using it allows the SDK to send profile events to PVD.
+ */
+ ePROFILE = 1 << 1,
+
+ /**
+ \brief Send memory information to PVD.
+
+ The PVD sdk side hooks into the Foundation memory controller and listens to
+ allocation/deallocation events. This has a noticable hit on the first frame,
+ however, this data is somewhat compressed and the PhysX SDK doesn't allocate much
+ once it hits a steady state. This information also has a fairly negligible
+ impact and thus is also highly recommended.
+
+ This flag works together with a PxCreatePhysics parameter,
+ trackOutstandingAllocations. Using both of them together allows users to have
+ an accurate view of the overall memory usage of the simulation at the cost of
+ a hashtable lookup per allocation/deallocation. Again, PhysX makes a best effort
+ attempt not to allocate or deallocate during simulation so this hashtable lookup
+ tends to have no effect past the first frame.
+
+ Sending memory information without tracking outstanding allocations means that
+ PVD will accurate information about the state of the memory system before the
+ actual connection happened.
+ */
+ eMEMORY = 1 << 2,
+
+ eALL = (eDEBUG | ePROFILE | eMEMORY)
+ };
+};
+
+/**
+\brief Bitfield that contains a set of raised flags defined in PxPvdInstrumentationFlag.
+
+@see PxPvdInstrumentationFlag
+*/
+typedef PxFlags PxPvdInstrumentationFlags;
+PX_FLAGS_OPERATORS(PxPvdInstrumentationFlag::Enum, uint8_t)
+
+/**
+\brief PxPvd is the top-level class for the PVD framework, and the main customer interface for PVD
+configuration.It is a singleton class, instantiated and owned by the application.
+*/
+class PxPvd : public physx::PxProfilerCallback
+{
+ public:
+ /**
+ Connects the SDK to the PhysX Visual Debugger application.
+ \param transport transport for pvd captured data.
+ \param flags Flags to set.
+ return True if success
+ */
+ virtual bool connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags) = 0;
+
+ /**
+ Disconnects the SDK from the PhysX Visual Debugger application.
+ If we are still connected, this will kill the entire debugger connection.
+ */
+ virtual void disconnect() = 0;
+
+ /**
+ * Return if connection to PVD is created.
+ \param useCachedStatus
+ 1> When useCachedStaus is false, isConnected() checks the lowlevel network status.
+ This can be slow because it needs to lock the lowlevel network stream. If isConnected() is
+ called frequently, the expense of locking can be significant.
+ 2> When useCachedStatus is true, isConnected() checks the highlevel cached status with atomic access.
+ It is faster than locking, but the status may be different from the lowlevel network with latency of up to
+ one frame.
+ The reason for this is that the cached status is changed inside socket listener, which is not
+ called immediately when the lowlevel connection status changes.
+ */
+ virtual bool isConnected(bool useCachedStatus = true) = 0;
+
+ /**
+ returns the PVD data transport
+ returns NULL if no transport is present.
+ */
+ virtual PxPvdTransport* getTransport() = 0;
+
+ /**
+ Retrieves the PVD flags. See PxPvdInstrumentationFlags.
+ */
+ virtual PxPvdInstrumentationFlags getInstrumentationFlags() = 0;
+
+ /**
+ \brief Releases the pvd instance.
+ */
+ virtual void release() = 0;
+
+ protected:
+ virtual ~PxPvd()
+ {
+ }
+};
+
+/**
+ \brief Create a pvd instance.
+ \param foundation is the foundation instance that stores the allocator and error callbacks.
+*/
+PX_C_EXPORT PxPvd* PX_CALL_CONV PxCreatePvd(PxFoundation& foundation);
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif // PXPVDSDK_PXPVD_H
diff --git a/sources/PhysX/PhysX/include/pvd/PxPvdSceneClient.h b/sources/PhysX/PhysX/include/pvd/PxPvdSceneClient.h
new file mode 100644
index 00000000..2db2e073
--- /dev/null
+++ b/sources/PhysX/PhysX/include/pvd/PxPvdSceneClient.h
@@ -0,0 +1,142 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_PVD_SCENE_CLIENT_H
+#define PX_PVD_SCENE_CLIENT_H
+
+/** \addtogroup pvd
+@{
+*/
+
+#include "foundation/PxFlags.h"
+
+namespace physx
+{
+ namespace pvdsdk
+ {
+ class PvdClient;
+ struct PvdDebugPoint;
+ struct PvdDebugLine;
+ struct PvdDebugTriangle;
+ struct PvdDebugText;
+ }
+}
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief PVD scene Flags. They are disabled by default, and only works if PxPvdInstrumentationFlag::eDEBUG is set.
+*/
+struct PxPvdSceneFlag
+{
+ enum Enum
+ {
+ eTRANSMIT_CONTACTS = (1 << 0), //! Transmits contact stream to PVD.
+ eTRANSMIT_SCENEQUERIES = (1 << 1), //! Transmits scene query stream to PVD.
+ eTRANSMIT_CONSTRAINTS = (1 << 2) //! Transmits constraints visualize stream to PVD.
+ };
+};
+
+/**
+\brief Bitfield that contains a set of raised flags defined in PxPvdSceneFlag.
+
+@see PxPvdSceneFlag
+*/
+typedef PxFlags PxPvdSceneFlags;
+PX_FLAGS_OPERATORS(PxPvdSceneFlag::Enum, PxU8)
+
+/**
+\brief Special client for PxScene.
+It provides access to the PxPvdSceneFlag.
+It also provides simple user debug services that associated scene position such as immediate rendering and camera updates.
+*/
+class PxPvdSceneClient
+{
+ public:
+ /**
+ Sets the PVD flag. See PxPvdSceneFlag.
+ \param flag Flag to set.
+ \param value value the flag gets set to.
+ */
+ virtual void setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value) = 0;
+
+ /**
+ Sets the PVD flags. See PxPvdSceneFlags.
+ \param flags Flags to set.
+ */
+ virtual void setScenePvdFlags(PxPvdSceneFlags flags) = 0;
+
+ /**
+ Retrieves the PVD flags. See PxPvdSceneFlags.
+ */
+ virtual PxPvdSceneFlags getScenePvdFlags() const = 0;
+
+ /**
+ update camera on PVD application's render window
+ */
+ virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) = 0;
+
+ /**
+ draw points on PVD application's render window
+ */
+ virtual void drawPoints(const physx::pvdsdk::PvdDebugPoint* points, PxU32 count) = 0;
+
+ /**
+ draw lines on PVD application's render window
+ */
+ virtual void drawLines(const physx::pvdsdk::PvdDebugLine* lines, PxU32 count) = 0;
+
+ /**
+ draw triangles on PVD application's render window
+ */
+ virtual void drawTriangles(const physx::pvdsdk::PvdDebugTriangle* triangles, PxU32 count) = 0;
+
+ /**
+ draw text on PVD application's render window
+ */
+ virtual void drawText(const physx::pvdsdk::PvdDebugText& text) = 0;
+
+ /**
+ get the underlying client, for advanced users
+ */
+ virtual physx::pvdsdk::PvdClient* getClientInternal() = 0;
+
+protected:
+ virtual ~PxPvdSceneClient(){}
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif // PX_PVD_SCENE_CLIENT_H
diff --git a/sources/PhysX/PhysX/include/pvd/PxPvdTransport.h b/sources/PhysX/PhysX/include/pvd/PxPvdTransport.h
new file mode 100644
index 00000000..169ec23d
--- /dev/null
+++ b/sources/PhysX/PhysX/include/pvd/PxPvdTransport.h
@@ -0,0 +1,129 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PXPVDSDK_PXPVDTRANSPORT_H
+#define PXPVDSDK_PXPVDTRANSPORT_H
+
+/** \addtogroup pvd
+@{
+*/
+#include "foundation/PxErrors.h"
+#include "foundation/PxFlags.h"
+#include "pvd/PxPvd.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief PxPvdTransport is an interface representing the data transport mechanism.
+This class defines all services associated with the transport: configuration, connection, reading, writing etc.
+It is owned by the application, and can be realized as a file or a socket (using one-line PxDefault<...> methods in
+PhysXExtensions) or in a custom implementation. This is a class that is intended for use by PVD, not by the
+application, the application entry points are PxPvd and PvdClient.
+*/
+
+class PxPvdTransport
+{
+ public:
+ // connect, isConnected, disconnect, read, write, flush
+
+ /**
+ Connects to the Visual Debugger application.
+ return True if success
+ */
+ virtual bool connect() = 0;
+
+ /**
+ Disconnects from the Visual Debugger application.
+ If we are still connected, this will kill the entire debugger connection.
+ */
+ virtual void disconnect() = 0;
+
+ /**
+ * Return if connection to PVD is created.
+ */
+ virtual bool isConnected() = 0;
+
+ /**
+ * write bytes to the other endpoint of the connection. should lock before witre. If an error occurs
+ * this connection will assume to be dead.
+ */
+ virtual bool write(const uint8_t* inBytes, uint32_t inLength) = 0;
+
+ /*
+ lock this transport and return it
+ */
+ virtual PxPvdTransport& lock() = 0;
+
+ /*
+ unlock this transport
+ */
+ virtual void unlock() = 0;
+
+ /**
+ * send any data and block until we know it is at least on the wire.
+ */
+ virtual void flush() = 0;
+
+ /**
+ * Return size of written data.
+ */
+ virtual uint64_t getWrittenDataSize() = 0;
+
+ virtual void release() = 0;
+
+ protected:
+ virtual ~PxPvdTransport()
+ {
+ }
+};
+
+/**
+ \brief Create a default socket transport.
+ \param host host address of the pvd application.
+ \param port ip port used for pvd, should same as the port setting in pvd application.
+ \param timeoutInMilliseconds timeout when connect to pvd host.
+*/
+PX_C_EXPORT PxPvdTransport* PX_CALL_CONV
+PxDefaultPvdSocketTransportCreate(const char* host, int port, unsigned int timeoutInMilliseconds);
+
+/**
+ \brief Create a default file transport.
+ \param name full path filename used save captured pvd data, or NULL for a fake/test file transport.
+*/
+PX_C_EXPORT PxPvdTransport* PX_CALL_CONV PxDefaultPvdFileTransportCreate(const char* name);
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif // PXPVDSDK_PXPVDTRANSPORT_H
diff --git a/sources/PhysX/PhysX/include/solver/PxSolverDefs.h b/sources/PhysX/PhysX/include/solver/PxSolverDefs.h
new file mode 100644
index 00000000..f93b6835
--- /dev/null
+++ b/sources/PhysX/PhysX/include/solver/PxSolverDefs.h
@@ -0,0 +1,443 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_SOLVER_DEFS_H
+#define PX_SOLVER_DEFS_H
+
+#include "PxPhysXConfig.h"
+#include "foundation/PxVec3.h"
+#include "foundation/PxMat33.h"
+#include "foundation/PxTransform.h"
+#include "PxConstraintDesc.h"
+#include "geomutils/GuContactPoint.h"
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable : 4324) // structure was padded due to alignment
+#endif
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxTGSSolverBodyVel;
+
+namespace Dy
+{
+ class ArticulationV;
+ typedef size_t ArticulationLinkHandle;
+}
+
+namespace Sc
+{
+ class ShapeInteraction;
+}
+
+struct PxSolverBody
+{
+ PX_ALIGN(16, PxVec3) linearVelocity; //!< Delta linear velocity computed by the solver
+ PxU16 maxSolverNormalProgress; //!< Progress counter used by constraint batching and parallel island solver.
+ PxU16 maxSolverFrictionProgress; //!< Progress counter used by constraint batching and parallel island solver.
+
+ PxVec3 angularState; //!< Delta angular velocity state computed by the solver.
+
+ PxU32 solverProgress; //!< Progress counter used by constraint batching and parallel island solver
+
+ PxSolverBody() : linearVelocity(0.f), maxSolverNormalProgress(0), maxSolverFrictionProgress(0), angularState(0), solverProgress(0)
+ {
+ }
+};
+
+PX_COMPILE_TIME_ASSERT(sizeof(PxSolverBody) == 32);
+
+struct PxSolverBodyData
+{
+ PX_ALIGN(16, PxVec3 linearVelocity); //!< 12 Pre-solver linear velocity
+ PxReal invMass; //!< 16 inverse mass
+ PxVec3 angularVelocity; //!< 28 Pre-solver angular velocity
+ PxReal reportThreshold; //!< 32 contact force threshold
+ PxMat33 sqrtInvInertia; //!< 68 inverse inertia in world space
+ PxReal penBiasClamp; //!< 72 the penetration bias clamp
+ PxU32 nodeIndex; //!< 76 the node idx of this solverBodyData. Used by solver to reference between solver bodies and island bodies. Not required by immediate mode
+ PxReal maxContactImpulse; //!< 80 the max contact impulse
+ PxTransform body2World; //!< 108 the body's transform
+ PxU16 lockFlags; //!< 110 lock flags
+ PxU16 pad; //!< 112 pad
+
+ PX_FORCE_INLINE PxReal projectVelocity(const PxVec3& lin, const PxVec3& ang) const
+ {
+ return linearVelocity.dot(lin) + angularVelocity.dot(ang);
+ }
+};
+
+//----------------------------------
+/*
+* A header that defines the size of a specific batch of constraints (of same type and without dependencies)
+*/
+struct PxConstraintBatchHeader
+{
+ PxU32 startIndex; //!< Start index for this batch
+ PxU16 stride; //!< Number of constraints in this batch (range: 1-4)
+ PxU16 constraintType; //!< The type of constraint this batch references
+};
+
+struct PxSolverConstraintDesc
+{
+ static const PxU16 NO_LINK = 0xffff;
+
+ enum ConstraintType
+ {
+ eCONTACT_CONSTRAINT, //!< Defines this pair is a contact constraint
+ eJOINT_CONSTRAINT //!< Defines this pair is a joint constraint
+ };
+
+ union
+ {
+ PxSolverBody* bodyA; //!< bodyA pointer
+ PxTGSSolverBodyVel* tgsBodyA; //!< bodyA pointer
+ Dy::ArticulationV* articulationA; //!< Articulation pointer for body A
+
+ };
+
+ union
+ {
+ PxSolverBody* bodyB; //!< BodyB pointer
+ PxTGSSolverBodyVel* tgsBodyB; //!< BodyB pointer
+ Dy::ArticulationV* articulationB; //!< Articulation pointer for body B
+ };
+ PxU16 linkIndexA; //!< Link index defining which link in Articulation A this constraint affects. If not an articulation, must be NO_LINK
+ PxU16 linkIndexB; //!< Link index defining which link in Articulation B this constraint affects. If not an articulation, must be NO_LINK.
+ PxU32 bodyADataIndex; //!< Body A's index into the SolverBodyData array
+ PxU32 bodyBDataIndex; //!< Body B's index into the SolverBodyData array
+ PxU16 writeBackLengthOver4; //!< writeBackLength/4, max writeback length is 256K, allows PxSolverConstraintDesc to fit in 32 bytes
+ PxU16 constraintLengthOver16; //!< constraintLength/16, max constraint length is 1MB, allows PxSolverConstraintDesc to fit in 32 bytes
+ PxU8* constraint; //!< Pointer to the constraint rows to be solved
+ void* writeBack; //!< Pointer to the writeback structure results for this given constraint are to be written to
+};
+
+struct PxSolverConstraintPrepDescBase
+{
+ enum BodyState
+ {
+ eDYNAMIC_BODY = 1 << 0,
+ eSTATIC_BODY = 1 << 1,
+ eKINEMATIC_BODY = 1 << 2,
+ eARTICULATION = 1 << 3
+ };
+
+ PxConstraintInvMassScale invMassScales; //!< In: The local mass scaling for this pair.
+
+ PxSolverConstraintDesc* desc; //!< Output: The PxSolverConstraintDesc filled in by contact prep
+
+ const PxSolverBody* body0; //!< In: The first body. Stores velocity information. Unused unless contact involves articulations.
+ const PxSolverBody* body1; //!< In: The second body. Stores velocity information. Unused unless contact involves articulations.
+
+ const PxSolverBodyData* data0; //!< In: The first PxSolverBodyData. Stores mass and miscellaneous information for the first body.
+ const PxSolverBodyData* data1; //!< In: The second PxSolverBodyData. Stores mass and miscellaneous information for the second body
+
+ PxTransform bodyFrame0; //!< In: The world-space transform of the first body.
+ PxTransform bodyFrame1; //!< In: The world-space transform of the second body.
+
+ BodyState bodyState0; //!< In: Defines what kind of actor the first body is
+ BodyState bodyState1; //!< In: Defines what kind of actor the second body is
+};
+
+struct PxSolverConstraintPrepDesc : public PxSolverConstraintPrepDescBase
+{
+ PX_ALIGN(16, Px1DConstraint* rows); //!< The start of the constraint rows
+ PxU32 numRows; //!< The number of rows
+
+ PxReal linBreakForce, angBreakForce; //!< Break forces
+ PxReal minResponseThreshold; //!< The minimum response threshold
+ void* writeback; //!< Pointer to constraint writeback structure. Reports back joint breaking. If not required, set to NULL.
+ bool disablePreprocessing; //!< Disable joint pre-processing. Pre-processing can improve stability but under certain circumstances, e.g. when some invInertia rows are zero/almost zero, can cause instabilities.
+ bool improvedSlerp; //!< Use improved slerp model
+ bool driveLimitsAreForces; //!< Indicates whether drive limits are forces
+ bool extendedLimits; //!< Indicates whether we want to use extended limits
+
+ PxVec3 body0WorldOffset; //!< Body0 world offset
+};
+
+struct PxSolverContactDesc : public PxSolverConstraintPrepDescBase
+{
+ PX_ALIGN(16, Sc::ShapeInteraction* shapeInteraction); //!< Pointer to share interaction. Used for force threshold reports in solver. Set to NULL if using immediate mode.
+ Gu::ContactPoint* contacts; //!< The start of the contacts for this pair
+ PxU32 numContacts; //!< The total number of contacs this pair references.
+
+ bool hasMaxImpulse; //!< Defines whether this pairs has maxImpulses clamping enabled
+ bool disableStrongFriction; //!< Defines whether this pair disables strong friction (sticky friction correlation)
+ bool hasForceThresholds; //!< Defines whether this pair requires force thresholds
+
+ PxReal restDistance; //!< A distance at which the solver should aim to hold the bodies separated. Default is 0
+ PxReal maxCCDSeparation; //!< A distance used to configure speculative CCD behavior. Default is PX_MAX_F32. Set internally in PhysX for bodies with eENABLE_SPECULATIVE_CCD on. Do not set directly!
+
+ PxU8* frictionPtr; //!< InOut: Friction patch correlation data. Set each frame by solver. Can be retained for improved behaviour or discarded each frame.
+ PxU8 frictionCount; //!< The total number of friction patches in this pair
+
+ PxReal* contactForces; //!< Out: A buffer for the solver to write applied contact forces to.
+
+ PxU32 startFrictionPatchIndex; //!< Start index of friction patch in the correlation buffer. Set by friction correlation
+ PxU32 numFrictionPatches; //!< Total number of friction patches in this pair. Set by friction correlation
+
+ PxU32 startContactPatchIndex; //!< The start index of this pair's contact patches in the correlation buffer. For internal use only
+ PxU16 numContactPatches; //!< Total number of contact patches.
+ PxU16 axisConstraintCount; //!< Axis constraint count. Defines how many constraint rows this pair has produced. Useful for statistical purposes.
+
+ PxU8 pad[16 - sizeof(void*)];
+};
+
+class PxConstraintAllocator
+{
+public:
+ /**
+ \brief Allocates constraint data. It is the application's responsibility to release this memory after PxSolveConstraints has completed.
+ \param[in] byteSize Allocation size in bytes
+ \return the allocated memory. This address must be 16-byte aligned.
+ */
+ virtual PxU8* reserveConstraintData(const PxU32 byteSize) = 0;
+
+ /**
+ \brief Allocates friction data. Friction data can be retained by the application for a given pair and provided as an input to PxSolverContactDesc to improve simulation stability.
+ It is the application's responsibility to release this memory. If this memory is released, the application should ensure it does not pass pointers to this memory to PxSolverContactDesc.
+ \param[in] byteSize Allocation size in bytes
+ \return the allocated memory. This address must be 4-byte aligned.
+ */
+ virtual PxU8* reserveFrictionData(const PxU32 byteSize) = 0;
+
+ virtual ~PxConstraintAllocator() {}
+};
+
+struct PxArticulationAxis
+{
+ enum Enum
+ {
+ eTWIST = 0,
+ eSWING1 = 1,
+ eSWING2 = 2,
+ eX = 3,
+ eY = 4,
+ eZ = 5,
+ eCOUNT = 6
+ };
+};
+
+PX_FLAGS_OPERATORS(PxArticulationAxis::Enum, PxU8)
+
+struct PxArticulationMotion
+{
+ enum Enum
+ {
+ eLOCKED = 0,
+ eLIMITED = 1,
+ eFREE = 2
+ };
+};
+
+typedef PxFlags PxArticulationMotions;
+PX_FLAGS_OPERATORS(PxArticulationMotion::Enum, PxU8)
+
+struct PxArticulationJointType
+{
+ enum Enum
+ {
+ ePRISMATIC = 0,
+ eREVOLUTE = 1,
+ eSPHERICAL = 2,
+ eFIX = 3,
+ eUNDEFINED = 4
+ };
+};
+
+struct PxArticulationFlag
+{
+ enum Enum
+ {
+ eFIX_BASE = (1 << 0),
+ eDRIVE_LIMITS_ARE_FORCES = (1<<1)
+ };
+};
+
+typedef PxFlags PxArticulationFlags;
+PX_FLAGS_OPERATORS(PxArticulationFlag::Enum, PxU8)
+
+struct PxArticulationDriveType
+{
+ enum Enum
+ {
+ eFORCE = 0,
+ eACCELERATION = 1,
+ eTARGET = 2,
+ eVELOCITY = 3,
+ eNONE = 4
+ };
+};
+
+struct PxArticulationLimit
+{
+ PxReal low, high;
+};
+
+struct PxArticulationDrive
+{
+ PxReal stiffness, damping, maxForce;
+ PxArticulationDriveType::Enum driveType;
+};
+
+
+struct PxTGSSolverBodyVel
+{
+ PX_ALIGN(16, PxVec3) linearVelocity; //12
+ PxU16 nbStaticInteractions; //14 Used to accumulate the number of static interactions
+ PxU16 maxDynamicPartition; //16 Used to accumualte the max partition of dynamic interactions
+ PxVec3 angularVelocity; //28
+ PxU32 partitionMask; //32 Used in partitioning as a bit-field
+ PxVec3 deltaAngDt; //44
+ PxReal maxAngVel; //48
+ PxVec3 deltaLinDt; //60
+ PxU16 lockFlags; //62
+ bool isKinematic; //63
+ PxU8 pad; //64
+
+ PX_FORCE_INLINE PxReal projectVelocity(const PxVec3& lin, const PxVec3& ang) const
+ {
+ return linearVelocity.dot(lin) + angularVelocity.dot(ang);
+ }
+
+};
+
+//Needed only by prep, integration and 1D constraints
+struct PxTGSSolverBodyTxInertia
+{
+ PxTransform deltaBody2World;
+ PxMat33 sqrtInvInertia;
+};
+
+struct PxTGSSolverBodyData
+{
+ PX_ALIGN(16, PxVec3) originalLinearVelocity;
+ PxReal maxContactImpulse;
+ PxVec3 originalAngularVelocity;
+ PxReal penBiasClamp;
+
+ PxReal invMass;
+ PxU32 nodeIndex;
+ PxReal reportThreshold;
+ PxU32 pad;
+
+ PxReal projectVelocity(const PxVec3& linear, const PxVec3& angular) const
+ {
+ return originalLinearVelocity.dot(linear) + originalAngularVelocity.dot(angular);
+ }
+};
+
+struct PxTGSSolverConstraintPrepDescBase
+{
+ PxConstraintInvMassScale invMassScales; //!< In: The local mass scaling for this pair.
+
+ PxSolverConstraintDesc* desc; //!< Output: The PxSolverConstraintDesc filled in by contact prep
+
+ const PxTGSSolverBodyVel* body0; //!< In: The first body. Stores velocity information. Unused unless contact involves articulations.
+ const PxTGSSolverBodyVel *body1; //!< In: The second body. Stores velocity information. Unused unless contact involves articulations.
+
+ const PxTGSSolverBodyTxInertia* body0TxI;
+ const PxTGSSolverBodyTxInertia* body1TxI;
+
+ const PxTGSSolverBodyData* bodyData0;
+ const PxTGSSolverBodyData* bodyData1;
+
+ PxTransform bodyFrame0; //!< In: The world-space transform of the first body.
+ PxTransform bodyFrame1; //!< In: The world-space transform of the second body.
+
+ PxSolverContactDesc::BodyState bodyState0; //!< In: Defines what kind of actor the first body is
+ PxSolverContactDesc::BodyState bodyState1; //!< In: Defines what kind of actor the second body is
+
+};
+
+struct PxTGSSolverConstraintPrepDesc : public PxTGSSolverConstraintPrepDescBase
+{
+ Px1DConstraint* rows; //!< The start of the constraint rows
+ PxU32 numRows; //!< The number of rows
+
+ PxReal linBreakForce, angBreakForce; //!< Break forces
+ PxReal minResponseThreshold; //!< The minimum response threshold
+ void* writeback; //!< Pointer to constraint writeback structure. Reports back joint breaking. If not required, set to NULL.
+ bool disablePreprocessing; //!< Disable joint pre-processing. Pre-processing can improve stability but under certain circumstances, e.g. when some invInertia rows are zero/almost zero, can cause instabilities.
+ bool improvedSlerp; //!< Use improved slerp model
+ bool driveLimitsAreForces; //!< Indicates whether drive limits are forces
+ bool extendedLimits; //!< Indiciates whether extended limits are used
+
+ PxVec3 body0WorldOffset; //!< Body0 world offset
+ PxVec3 cA2w; //!< Location of anchor point A in world space
+ PxVec3 cB2w; //!< Location of anchor point B in world space
+};
+
+
+struct PxTGSSolverContactDesc : public PxTGSSolverConstraintPrepDescBase
+{
+
+ Sc::ShapeInteraction* shapeInteraction; //!< Pointer to share interaction. Used for force threshold reports in solver. Set to NULL if using immediate mode.
+ Gu::ContactPoint* contacts; //!< The start of the contacts for this pair
+ PxU32 numContacts; //!< The total number of contacs this pair references.
+
+ bool hasMaxImpulse; //!< Defines whether this pairs has maxImpulses clamping enabled
+ bool disableStrongFriction; //!< Defines whether this pair disables strong friction (sticky friction correlation)
+ bool hasForceThresholds; //!< Defines whether this pair requires force thresholds
+
+ PxReal restDistance; //!< A distance at which the solver should aim to hold the bodies separated. Default is 0
+ PxReal maxCCDSeparation; //!< A distance used to configure speculative CCD behavior. Default is PX_MAX_F32. Set internally in PhysX for bodies with eENABLE_SPECULATIVE_CCD on. Do not set directly!
+
+ PxU8* frictionPtr; //!< InOut: Friction patch correlation data. Set each frame by solver. Can be retained for improved behaviour or discarded each frame.
+ PxU8 frictionCount; //!< The total number of friction patches in this pair
+
+ PxReal* contactForces; //!< Out: A buffer for the solver to write applied contact forces to.
+
+ PxU32 startFrictionPatchIndex; //!< Start index of friction patch in the correlation buffer. Set by friction correlation
+ PxU32 numFrictionPatches; //!< Total number of friction patches in this pair. Set by friction correlation
+
+ PxU32 startContactPatchIndex; //!< The start index of this pair's contact patches in the correlation buffer. For internal use only
+ PxU16 numContactPatches; //!< Total number of contact patches.
+ PxU16 axisConstraintCount; //!< Axis constraint count. Defines how many constraint rows this pair has produced. Useful for statistical purposes.
+
+ PxReal maxImpulse;
+
+ PxReal torsionalPatchRadius;
+ PxReal minTorsionalPatchRadius;
+};
+
+#if !PX_DOXYGEN
+}
+#endif
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
+
diff --git a/sources/PhysX/PhysX/include/task/PxCpuDispatcher.h b/sources/PhysX/PhysX/include/task/PxCpuDispatcher.h
new file mode 100644
index 00000000..a9993d5c
--- /dev/null
+++ b/sources/PhysX/PhysX/include/task/PxCpuDispatcher.h
@@ -0,0 +1,79 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+
+#ifndef PXTASK_PXCPUDISPATCHER_H
+#define PXTASK_PXCPUDISPATCHER_H
+
+#include "task/PxTaskDefine.h"
+#include "foundation/PxSimpleTypes.h"
+
+namespace physx
+{
+
+class PxBaseTask;
+
+/**
+ \brief A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK.
+
+ A typical implementation would for example use a thread pool with the dispatcher
+ pushing tasks onto worker thread queues or a global queue.
+
+ @see PxBaseTask
+ @see PxTask
+ @see PxTaskManager
+*/
+class PxCpuDispatcher
+{
+public:
+ /**
+ \brief Called by the TaskManager when a task is to be queued for execution.
+
+ Upon receiving a task, the dispatcher should schedule the task
+ to run when resource is available. After the task has been run,
+ it should call the release() method and discard it's pointer.
+
+ \param[in] task The task to be run.
+
+ @see PxBaseTask
+ */
+ virtual void submitTask( PxBaseTask& task ) = 0;
+
+ /**
+ \brief Returns the number of available worker threads for this dispatcher.
+
+ The SDK will use this count to control how many tasks are submitted. By
+ matching the number of tasks with the number of execution units task
+ overhead can be reduced.
+ */
+ virtual uint32_t getWorkerCount() const = 0;
+
+ virtual ~PxCpuDispatcher() {}
+};
+
+} // end physx namespace
+
+#endif // PXTASK_PXCPUDISPATCHER_H
diff --git a/sources/PhysX/PhysX/include/task/PxTask.h b/sources/PhysX/PhysX/include/task/PxTask.h
new file mode 100644
index 00000000..d2040062
--- /dev/null
+++ b/sources/PhysX/PhysX/include/task/PxTask.h
@@ -0,0 +1,320 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+
+#ifndef PXTASK_PXTASK_H
+#define PXTASK_PXTASK_H
+
+#include "task/PxTaskDefine.h"
+#include "task/PxTaskManager.h"
+#include "task/PxCpuDispatcher.h"
+#include "foundation/PxAssert.h"
+
+namespace physx
+{
+
+/**
+ * \brief Base class of all task types
+ *
+ * PxBaseTask defines a runnable reference counted task with built-in profiling.
+ */
+class PxBaseTask
+{
+public:
+ PxBaseTask() : mContextID(0), mTm(NULL) {}
+ virtual ~PxBaseTask() {}
+
+ /**
+ * \brief The user-implemented run method where the task's work should be performed
+ *
+ * run() methods must be thread safe, stack friendly (no alloca, etc), and
+ * must never block.
+ */
+ virtual void run() = 0;
+
+ /**
+ * \brief Return a user-provided task name for profiling purposes.
+ *
+ * It does not have to be unique, but unique names are helpful.
+ *
+ * \return The name of this task
+ */
+ virtual const char* getName() const = 0;
+
+ //! \brief Implemented by derived implementation classes
+ virtual void addReference() = 0;
+ //! \brief Implemented by derived implementation classes
+ virtual void removeReference() = 0;
+ //! \brief Implemented by derived implementation classes
+ virtual int32_t getReference() const = 0;
+
+ /** \brief Implemented by derived implementation classes
+ *
+ * A task may assume in its release() method that the task system no longer holds
+ * references to it - so it may safely run its destructor, recycle itself, etc.
+ * provided no additional user references to the task exist
+ */
+ virtual void release() = 0;
+
+ /**
+ * \brief Return PxTaskManager to which this task was submitted
+ *
+ * Note, can return NULL if task was not submitted, or has been
+ * completed.
+ */
+ PX_FORCE_INLINE PxTaskManager* getTaskManager() const
+ {
+ return mTm;
+ }
+
+ PX_FORCE_INLINE void setContextId(PxU64 id) { mContextID = id; }
+ PX_FORCE_INLINE PxU64 getContextId() const { return mContextID; }
+
+protected:
+ PxU64 mContextID; //!< Context ID for profiler interface
+ PxTaskManager* mTm; //!< Owning PxTaskManager instance
+
+ friend class PxTaskMgr;
+};
+
+
+/**
+ * \brief A PxBaseTask implementation with deferred execution and full dependencies
+ *
+ * A PxTask must be submitted to a PxTaskManager to to be executed, Tasks may
+ * optionally be named when they are submitted.
+ */
+class PxTask : public PxBaseTask
+{
+public:
+ PxTask() : mTaskID(0) {}
+ virtual ~PxTask() {}
+
+ //! \brief Release method implementation
+ virtual void release()
+ {
+ PX_ASSERT(mTm);
+
+ // clear mTm before calling taskCompleted() for safety
+ PxTaskManager* save = mTm;
+ mTm = NULL;
+ save->taskCompleted( *this );
+ }
+
+ //! \brief Inform the PxTaskManager this task must finish before the given
+ // task is allowed to start.
+ PX_INLINE void finishBefore( PxTaskID taskID )
+ {
+ PX_ASSERT(mTm);
+ mTm->finishBefore( *this, taskID);
+ }
+
+ //! \brief Inform the PxTaskManager this task cannot start until the given
+ // task has completed.
+ PX_INLINE void startAfter( PxTaskID taskID )
+ {
+ PX_ASSERT(mTm);
+ mTm->startAfter( *this, taskID );
+ }
+
+ /**
+ * \brief Manually increment this task's reference count. The task will
+ * not be allowed to run until removeReference() is called.
+ */
+ PX_INLINE void addReference()
+ {
+ PX_ASSERT(mTm);
+ mTm->addReference( mTaskID );
+ }
+
+ /**
+ * \brief Manually decrement this task's reference count. If the reference
+ * count reaches zero, the task will be dispatched.
+ */
+ PX_INLINE void removeReference()
+ {
+ PX_ASSERT(mTm);
+ mTm->decrReference( mTaskID );
+ }
+
+ /**
+ * \brief Return the ref-count for this task
+ */
+ PX_INLINE int32_t getReference() const
+ {
+ return mTm->getReference( mTaskID );
+ }
+
+ /**
+ * \brief Return the unique ID for this task
+ */
+ PX_INLINE PxTaskID getTaskID() const
+ {
+ return mTaskID;
+ }
+
+ /**
+ * \brief Called by PxTaskManager at submission time for initialization
+ *
+ * Perform simulation step initialization here.
+ */
+ virtual void submitted()
+ {
+ }
+
+protected:
+ PxTaskID mTaskID; //!< ID assigned at submission
+
+ friend class PxTaskMgr;
+};
+
+
+/**
+ * \brief A PxBaseTask implementation with immediate execution and simple dependencies
+ *
+ * A PxLightCpuTask bypasses the PxTaskManager launch dependencies and will be
+ * submitted directly to your scene's CpuDispatcher. When the run() function
+ * completes, it will decrement the reference count of the specified
+ * continuation task.
+ *
+ * You must use a full-blown PxTask if you want your task to be resolved
+ * by another PxTask, or you need more than a single dependency to be
+ * resolved when your task completes, or your task will not run on the
+ * CpuDispatcher.
+ */
+class PxLightCpuTask : public PxBaseTask
+{
+public:
+ PxLightCpuTask()
+ : mCont( NULL )
+ , mRefCount( 0 )
+ {
+ }
+ virtual ~PxLightCpuTask()
+ {
+ mTm = NULL;
+ }
+
+ /**
+ * \brief Initialize this task and specify the task that will have its ref count decremented on completion.
+ *
+ * Submission is deferred until the task's mRefCount is decremented to zero.
+ * Note that we only use the PxTaskManager to query the appropriate dispatcher.
+ *
+ * \param[in] tm The PxTaskManager this task is managed by
+ * \param[in] c The task to be executed when this task has finished running
+ */
+ PX_INLINE void setContinuation(PxTaskManager& tm, PxBaseTask* c)
+ {
+ PX_ASSERT( mRefCount == 0 );
+ mRefCount = 1;
+ mCont = c;
+ mTm = &tm;
+ if( mCont )
+ {
+ mCont->addReference();
+ }
+ }
+
+ /**
+ * \brief Initialize this task and specify the task that will have its ref count decremented on completion.
+ *
+ * This overload of setContinuation() queries the PxTaskManager from the continuation
+ * task, which cannot be NULL.
+ * \param[in] c The task to be executed after this task has finished running
+ */
+ PX_INLINE void setContinuation( PxBaseTask* c )
+ {
+ PX_ASSERT( c );
+ PX_ASSERT( mRefCount == 0 );
+ mRefCount = 1;
+ mCont = c;
+ if( mCont )
+ {
+ mCont->addReference();
+ mTm = mCont->getTaskManager();
+ PX_ASSERT( mTm );
+ }
+ }
+
+ /**
+ * \brief Retrieves continuation task
+ */
+ PX_INLINE PxBaseTask* getContinuation() const
+ {
+ return mCont;
+ }
+
+ /**
+ * \brief Manually decrement this task's reference count. If the reference
+ * count reaches zero, the task will be dispatched.
+ */
+ PX_INLINE void removeReference()
+ {
+ mTm->decrReference(*this);
+ }
+
+ /** \brief Return the ref-count for this task */
+ PX_INLINE int32_t getReference() const
+ {
+ return mRefCount;
+ }
+
+ /**
+ * \brief Manually increment this task's reference count. The task will
+ * not be allowed to run until removeReference() is called.
+ */
+ PX_INLINE void addReference()
+ {
+ mTm->addReference(*this);
+ }
+
+ /**
+ * \brief called by CpuDispatcher after run method has completed
+ *
+ * Decrements the continuation task's reference count, if specified.
+ */
+ PX_INLINE void release()
+ {
+ if( mCont )
+ {
+ mCont->removeReference();
+ }
+ }
+
+protected:
+
+ PxBaseTask* mCont; //!< Continuation task, can be NULL
+ volatile int32_t mRefCount; //!< PxTask is dispatched when reaches 0
+
+ friend class PxTaskMgr;
+};
+
+
+}// end physx namespace
+
+
+#endif // PXTASK_PXTASK_H
diff --git a/sources/PhysX/PhysX/include/task/PxTaskDefine.h b/sources/PhysX/PhysX/include/task/PxTaskDefine.h
new file mode 100644
index 00000000..401d36eb
--- /dev/null
+++ b/sources/PhysX/PhysX/include/task/PxTaskDefine.h
@@ -0,0 +1,37 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+
+#ifndef PXTASK_PXTASKDEFINE_H
+#define PXTASK_PXTASKDEFINE_H
+
+#include "foundation/PxPreprocessor.h"
+
+#ifndef PX_SUPPORT_PXTASK_PROFILING
+#define PX_SUPPORT_PXTASK_PROFILING 1
+#endif
+
+#endif // PXTASK_PXTASKDEFINE_H
diff --git a/sources/PhysX/PhysX/include/task/PxTaskManager.h b/sources/PhysX/PhysX/include/task/PxTaskManager.h
new file mode 100644
index 00000000..003bbb6c
--- /dev/null
+++ b/sources/PhysX/PhysX/include/task/PxTaskManager.h
@@ -0,0 +1,204 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+
+#ifndef PXTASK_PXTASKMANAGER_H
+#define PXTASK_PXTASKMANAGER_H
+
+#include "task/PxTaskDefine.h"
+#include "foundation/PxSimpleTypes.h"
+#include "foundation/PxErrorCallback.h"
+
+namespace physx
+{
+PX_PUSH_PACK_DEFAULT
+
+class PxBaseTask;
+class PxTask;
+class PxLightCpuTask;
+typedef unsigned int PxTaskID;
+
+/**
+\brief Identifies the type of each heavyweight PxTask object
+
+\note This enum type is only used by PxTask and GpuTask objects, LightCpuTasks do not use this enum.
+
+@see PxTask
+@see PxLightCpuTask
+*/
+struct PxTaskType
+{
+ /**
+ * \brief Identifies the type of each heavyweight PxTask object
+ */
+ enum Enum
+ {
+ TT_CPU, //!< PxTask will be run on the CPU
+ TT_NOT_PRESENT, //!< Return code when attempting to find a task that does not exist
+ TT_COMPLETED //!< PxTask execution has been completed
+ };
+};
+
+class PxCpuDispatcher;
+
+/**
+ \brief The PxTaskManager interface
+
+ A PxTaskManager instance holds references to user-provided dispatcher objects, when tasks are
+ submitted the PxTaskManager routes them to the appropriate dispatcher and handles task profiling if enabled.
+ Users should not implement the PxTaskManager interface, the SDK creates its own concrete PxTaskManager object
+ per-scene which users can configure by passing dispatcher objects into the PxSceneDesc.
+
+ @see CpuDispatcher
+
+*/
+class PxTaskManager
+{
+public:
+
+ /**
+ \brief Set the user-provided dispatcher object for CPU tasks
+
+ \param[in] ref The dispatcher object.
+
+ @see CpuDispatcher
+ */
+ virtual void setCpuDispatcher(PxCpuDispatcher& ref) = 0;
+
+ /**
+ \brief Get the user-provided dispatcher object for CPU tasks
+
+ \return The CPU dispatcher object.
+
+ @see CpuDispatcher
+ */
+ virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
+
+ /**
+ \brief Reset any dependencies between Tasks
+
+ \note Will be called at the start of every frame before tasks are submitted.
+
+ @see PxTask
+ */
+ virtual void resetDependencies() = 0;
+
+ /**
+ \brief Called by the owning scene to start the task graph.
+
+ \note All tasks with with ref count of 1 will be dispatched.
+
+ @see PxTask
+ */
+ virtual void startSimulation() = 0;
+
+ /**
+ \brief Called by the owning scene at the end of a simulation step.
+ */
+ virtual void stopSimulation() = 0;
+
+ /**
+ \brief Called by the worker threads to inform the PxTaskManager that a task has completed processing
+
+ \param[in] task The task which has been completed
+ */
+ virtual void taskCompleted(PxTask& task) = 0;
+
+ /**
+ \brief Retrieve a task by name
+
+ \param[in] name The unique name of a task
+ \return The ID of the task with that name, or TT_NOT_PRESENT if not found
+ */
+ virtual PxTaskID getNamedTask(const char* name) = 0;
+
+ /**
+ \brief Submit a task with a unique name.
+
+ \param[in] task The task to be executed
+ \param[in] name The unique name of a task
+ \param[in] type The type of the task (default TT_CPU)
+ \return The ID of the task with that name, or TT_NOT_PRESENT if not found
+ */
+ virtual PxTaskID submitNamedTask(PxTask* task, const char* name, PxTaskType::Enum type = PxTaskType::TT_CPU) = 0;
+
+ /**
+ \brief Submit an unnamed task.
+
+ \param[in] task The task to be executed
+ \param[in] type The type of the task (default TT_CPU)
+
+ \return The ID of the task with that name, or TT_NOT_PRESENT if not found
+ */
+ virtual PxTaskID submitUnnamedTask(PxTask& task, PxTaskType::Enum type = PxTaskType::TT_CPU) = 0;
+
+ /**
+ \brief Retrieve a task given a task ID
+
+ \param[in] id The ID of the task to return, a valid ID must be passed or results are undefined
+
+ \return The task associated with the ID
+ */
+ virtual PxTask* getTaskFromID(PxTaskID id) = 0;
+
+ /**
+ \brief Release the PxTaskManager object, referenced dispatchers will not be released
+ */
+ virtual void release() = 0;
+
+ /**
+ \brief Construct a new PxTaskManager instance with the given [optional] dispatchers
+ */
+ static PxTaskManager* createTaskManager(PxErrorCallback& errorCallback, PxCpuDispatcher* = 0);
+
+protected:
+ virtual ~PxTaskManager() {}
+
+ /*! \cond PRIVATE */
+
+ virtual void finishBefore(PxTask& task, PxTaskID taskID) = 0;
+ virtual void startAfter(PxTask& task, PxTaskID taskID) = 0;
+
+ virtual void addReference(PxTaskID taskID) = 0;
+ virtual void decrReference(PxTaskID taskID) = 0;
+ virtual int32_t getReference(PxTaskID taskID) const = 0;
+
+ virtual void decrReference(PxLightCpuTask&) = 0;
+ virtual void addReference(PxLightCpuTask&) = 0;
+
+ /*! \endcond */
+
+ friend class PxBaseTask;
+ friend class PxTask;
+ friend class PxLightCpuTask;
+};
+
+PX_POP_PACK
+
+} // end physx namespace
+
+
+#endif // PXTASK_PXTASKMANAGER_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleComponents.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleComponents.h
new file mode 100644
index 00000000..dbf0a1c6
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleComponents.h
@@ -0,0 +1,1359 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_CORE_COMPONENTS_H
+#define PX_VEHICLE_CORE_COMPONENTS_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/PxMemory.h"
+#include "foundation/PxVec3.h"
+#include "common/PxCoreUtilityTypes.h"
+#include "vehicle/PxVehicleSDK.h"
+#include "common/PxTypeInfo.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxVehicleChassisData
+{
+public:
+
+ friend class PxVehicleDriveSimData4W;
+
+ PxVehicleChassisData()
+ : mMOI(PxVec3(0,0,0)),
+ mMass(1500),
+ mCMOffset(PxVec3(0,0,0))
+ {
+ }
+
+ /**
+ \brief Moment of inertia of vehicle rigid body actor.
+
+ \note Specified in kilograms metres-squared (kg m^2).
+ */
+ PxVec3 mMOI;
+
+ /**
+ \brief Mass of vehicle rigid body actor.
+
+ \note Specified in kilograms (kg).
+ */
+ PxReal mMass;
+
+ /**
+ \brief Center of mass offset of vehicle rigid body actor.
+
+ \note Specified in metres (m).
+ */
+ PxVec3 mCMOffset;
+
+private:
+
+ PxReal pad;
+
+ bool isValid() const;
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleChassisData)& 0x0f));
+
+class PxVehicleEngineData
+{
+public:
+
+ friend class PxVehicleDriveSimData;
+
+ enum
+ {
+ eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8
+ };
+
+ PxVehicleEngineData()
+ : mMOI(1.0f),
+ mPeakTorque(500.0f),
+ mMaxOmega(600.0f),
+ mDampingRateFullThrottle(0.15f),
+ mDampingRateZeroThrottleClutchEngaged(2.0f),
+ mDampingRateZeroThrottleClutchDisengaged(0.35f)
+ {
+ mTorqueCurve.addPair(0.0f, 0.8f);
+ mTorqueCurve.addPair(0.33f, 1.0f);
+ mTorqueCurve.addPair(1.0f, 0.8f);
+
+ mRecipMOI=1.0f/mMOI;
+ mRecipMaxOmega=1.0f/mMaxOmega;
+ }
+
+ /**
+ \brief Graph of normalized torque (torque/mPeakTorque) against normalized engine speed ( engineRotationSpeed / mMaxOmega ).
+
+ \note The normalized engine speed is the x-axis of the graph, while the normalized torque is the y-axis of the graph.
+ */
+ PxFixedSizeLookupTable mTorqueCurve;
+
+ /**
+ \brief Moment of inertia of the engine around the axis of rotation.
+
+ \note Specified in kilograms metres-squared (kg m^2)
+ */
+ PxReal mMOI;
+
+ /**
+ \brief Maximum torque available to apply to the engine when the accelerator pedal is at maximum.
+
+ \note The torque available is the value of the accelerator pedal (in range [0, 1]) multiplied by the normalized torque as computed from mTorqueCurve multiplied by mPeakTorque.
+
+ \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mPeakTorque;
+
+ /**
+ \brief Maximum rotation speed of the engine.
+
+ \note Specified in radians per second (s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxOmega;
+
+ /**
+ \brief Damping rate of engine when full throttle is applied.
+
+ \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
+
+ \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
+
+ \note Specified in kilograms metres-squared per second (kg m^2 s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mDampingRateFullThrottle;
+
+
+ /**
+ \brief Damping rate of engine when full throttle is applied.
+
+ \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
+
+ \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
+
+ \note Specified in kilograms metres-squared per second (kg m^2 s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mDampingRateZeroThrottleClutchEngaged;
+
+ /**
+ \brief Damping rate of engine when full throttle is applied.
+
+ \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
+
+ \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
+ between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle:
+ mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
+
+ \note Specified in kilograms metres-squared per second (kg m^2 s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mDampingRateZeroThrottleClutchDisengaged;
+
+ /**
+ \brief Return value of mRecipMOI(=1.0f/mMOI) that is automatically set by PxVehicleDriveSimData::setEngineData
+ */
+ PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
+
+ /**
+ \brief Return value of mRecipMaxOmega( = 1.0f / mMaxOmega ) that is automatically set by PxVehicleDriveSimData::setEngineData
+ */
+ PX_FORCE_INLINE PxReal getRecipMaxOmega() const {return mRecipMaxOmega;}
+
+private:
+
+ /**
+ \brief Reciprocal of the engine moment of inertia.
+
+ \note Not necessary to set this value because it is set by PxVehicleDriveSimData::setEngineData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRecipMOI;
+
+ /**
+ \brief Reciprocal of the maximum rotation speed of the engine.
+
+ \note Not necessary to set this value because it is set by PxVehicleDriveSimData::setEngineData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRecipMaxOmega;
+
+ bool isValid() const;
+
+
+//serialization
+public:
+ PxVehicleEngineData(const PxEMPTY) : mTorqueCurve(PxEmpty) {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleEngineData)& 0x0f));
+
+class PxVehicleGearsData
+{
+public:
+
+ friend class PxVehicleDriveSimData;
+
+ enum Enum
+ {
+ eREVERSE=0,
+ eNEUTRAL,
+ eFIRST,
+ eSECOND,
+ eTHIRD,
+ eFOURTH,
+ eFIFTH,
+ eSIXTH,
+ eSEVENTH,
+ eEIGHTH,
+ eNINTH,
+ eTENTH,
+ eELEVENTH,
+ eTWELFTH,
+ eTHIRTEENTH,
+ eFOURTEENTH,
+ eFIFTEENTH,
+ eSIXTEENTH,
+ eSEVENTEENTH,
+ eEIGHTEENTH,
+ eNINETEENTH,
+ eTWENTIETH,
+ eTWENTYFIRST,
+ eTWENTYSECOND,
+ eTWENTYTHIRD,
+ eTWENTYFOURTH,
+ eTWENTYFIFTH,
+ eTWENTYSIXTH,
+ eTWENTYSEVENTH,
+ eTWENTYEIGHTH,
+ eTWENTYNINTH,
+ eTHIRTIETH,
+ eGEARSRATIO_COUNT
+ };
+
+ PxVehicleGearsData()
+ : mFinalRatio(4.0f),
+ mNbRatios(7),
+ mSwitchTime(0.5f)
+ {
+ mRatios[PxVehicleGearsData::eREVERSE]=-4.0f;
+ mRatios[PxVehicleGearsData::eNEUTRAL]=0.0f;
+ mRatios[PxVehicleGearsData::eFIRST]=4.0f;
+ mRatios[PxVehicleGearsData::eSECOND]=2.0f;
+ mRatios[PxVehicleGearsData::eTHIRD]=1.5f;
+ mRatios[PxVehicleGearsData::eFOURTH]=1.1f;
+ mRatios[PxVehicleGearsData::eFIFTH]=1.0f;
+
+ for(PxU32 i = PxVehicleGearsData::eSIXTH; i < PxVehicleGearsData::eGEARSRATIO_COUNT; ++i)
+ mRatios[i]=0.f;
+ }
+
+ /**
+ \brief Gear ratios
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
+
+ /**
+ \brief Gear ratio applied is mRatios[currentGear]*finalRatio
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mFinalRatio;
+
+ /**
+ \brief Number of gears (including reverse and neutral).
+
+ Range: (0, MAX_NB_GEAR_RATIOS)
+ */
+ PxU32 mNbRatios;
+
+ /**
+ \brief Time it takes to switch gear.
+
+ \note Specified in seconds (s).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mSwitchTime;
+
+private:
+
+ PxReal mPad;
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleGearsData(const PxEMPTY) {}
+ PxReal getGearRatio(PxVehicleGearsData::Enum a) const {return mRatios[a];}
+ void setGearRatio(PxVehicleGearsData::Enum a, PxReal ratio) { mRatios[a] = ratio;}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGearsData)& 0x0f));
+
+class PxVehicleAutoBoxData
+{
+public:
+
+ friend class PxVehicleDriveSimData;
+
+ PxVehicleAutoBoxData()
+ {
+ for(PxU32 i=0;i mUpRatios[currentGear] the autobox will begin
+ a transition to currentGear+1 unless currentGear is the highest possible gear or neutral or reverse.
+
+ Range: [0, 1]
+ */
+ PxReal mUpRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
+
+ /**
+ \brief Value of engineRevs/maxEngineRevs that is low enough to decrement gear.
+
+ \note When ( engineRotationSpeed / PxVehicleEngineData::mMaxOmega ) < mDownRatios[currentGear] the autobox will begin
+ a transition to currentGear-1 unless currentGear is first gear or neutral or reverse.
+
+ Range: [0, 1]
+ */
+ PxReal mDownRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
+
+ /**
+ \brief Set the latency time of the autobox.
+
+ \note Latency time is the minimum time that must pass between each gear change that is initiated by the autobox.
+ The auto-box will only attempt to initiate another gear change up or down if the simulation time that has passed since the most recent
+ automated gear change is greater than the specified latency.
+
+ \note Specified in seconds (s).
+
+ @see getLatency
+ */
+ void setLatency(const PxReal latency)
+ {
+ mDownRatios[PxVehicleGearsData::eREVERSE]=latency;
+ }
+
+ /**
+ \brief Get the latency time of the autobox.
+
+ \note Specified in seconds (s).
+
+ @see setLatency
+ */
+ PxReal getLatency() const
+ {
+ return mDownRatios[PxVehicleGearsData::eREVERSE];
+ }
+
+private:
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleAutoBoxData(const PxEMPTY) {}
+
+ PxReal getUpRatios(PxVehicleGearsData::Enum a) const {return mUpRatios[a];}
+ void setUpRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mUpRatios[a] = ratio;}
+
+ PxReal getDownRatios(PxVehicleGearsData::Enum a) const {return mDownRatios[a];}
+ void setDownRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mDownRatios[a] = ratio;}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAutoBoxData)& 0x0f));
+
+class PxVehicleDifferential4WData
+{
+public:
+
+ friend class PxVehicleDriveSimData4W;
+
+ enum Enum
+ {
+ eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels
+ eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive
+ eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive
+ eDIFF_TYPE_OPEN_4WD, //open differential for car with 4 driven wheels
+ eDIFF_TYPE_OPEN_FRONTWD, //open differential for car with front-wheel drive
+ eDIFF_TYPE_OPEN_REARWD, //open differential for car with rear-wheel drive
+ eMAX_NB_DIFF_TYPES
+ };
+
+ PxVehicleDifferential4WData()
+ : mFrontRearSplit(0.45f),
+ mFrontLeftRightSplit(0.5f),
+ mRearLeftRightSplit(0.5f),
+ mCentreBias(1.3f),
+ mFrontBias(1.3f),
+ mRearBias(1.3f),
+ mType(PxVehicleDifferential4WData::eDIFF_TYPE_LS_4WD)
+ {
+ }
+
+ /**
+ \brief Ratio of torque split between front and rear (>0.5 means more to front, <0.5 means more to rear).
+
+ \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD
+
+ Range: [0, 1]
+ */
+ PxReal mFrontRearSplit;
+
+ /**
+ \brief Ratio of torque split between front-left and front-right (>0.5 means more to front-left, <0.5 means more to front-right).
+
+ \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD and eDIFF_TYPE_LS_FRONTWD
+
+ Range: [0, 1]
+ */
+ PxReal mFrontLeftRightSplit;
+
+ /**
+ \brief Ratio of torque split between rear-left and rear-right (>0.5 means more to rear-left, <0.5 means more to rear-right).
+
+ \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD and eDIFF_TYPE_LS_REARWD
+
+ Range: [0, 1]
+ */
+ PxReal mRearLeftRightSplit;
+
+ /**
+ \brief Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds
+ The differential will divert more torque to the slower wheels when the bias is exceeded.
+
+ \note Only applied to DIFF_TYPE_LS_4WD
+
+ Range: [1, PX_MAX_F32)
+ */
+ PxReal mCentreBias;
+
+ /**
+ \brief Maximum allowed ratio of front-left and front-right wheel rotation speeds.
+ The differential will divert more torque to the slower wheel when the bias is exceeded.
+
+ \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD
+
+ Range: [1, PX_MAX_F32)
+ */
+ PxReal mFrontBias;
+
+ /**
+ \brief Maximum allowed ratio of rear-left and rear-right wheel rotation speeds.
+ The differential will divert more torque to the slower wheel when the bias is exceeded.
+
+ \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_REARWD
+
+ Range: [1, PX_MAX_F32)
+ */
+ PxReal mRearBias;
+
+ /**
+ \brief Type of differential.
+
+ Range: [DIFF_TYPE_LS_4WD, DIFF_TYPE_OPEN_FRONTWD]
+ */
+ PxVehicleDifferential4WData::Enum mType;
+
+private:
+
+ PxReal mPad[1];
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDifferential4WData(const PxEMPTY) {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferential4WData)& 0x0f));
+
+class PxVehicleDifferentialNWData
+{
+public:
+
+ friend class PxVehicleDriveSimDataNW;
+ friend class PxVehicleUpdate;
+
+ PxVehicleDifferentialNWData()
+ {
+ PxMemSet(mBitmapBuffer, 0, sizeof(PxU32) * (((PX_MAX_NB_WHEELS + 31) & ~31) >> 5));
+ mNbDrivenWheels=0;
+ mInvNbDrivenWheels=0.0f;
+ }
+
+ /**
+ \brief Set a specific wheel to be driven or non-driven by the differential.
+
+ \note The available drive torque will be split equally between all driven wheels.
+ Zero torque will be applied to non-driven wheels.
+ The default state of each wheel is to be uncoupled to the differential.
+ */
+ void setDrivenWheel(const PxU32 wheelId, const bool drivenState);
+
+ /**
+ \brief Test if a specific wheel has been configured as a driven or non-driven wheel.
+ */
+ bool getIsDrivenWheel(const PxU32 wheelId) const;
+
+private:
+
+ PxU32 mBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5];
+ PxU32 mNbDrivenWheels;
+ PxReal mInvNbDrivenWheels;
+ PxU32 mPad;
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDifferentialNWData(const PxEMPTY) {}
+ PxU32 getDrivenWheelStatus() const;
+ void setDrivenWheelStatus(PxU32 status);
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferentialNWData)& 0x0f));
+
+
+class PxVehicleAckermannGeometryData
+{
+public:
+
+ friend class PxVehicleDriveSimData4W;
+
+ PxVehicleAckermannGeometryData()
+ : mAccuracy(1.0f),
+ mFrontWidth(0.0f), //Must be filled out
+ mRearWidth(0.0f), //Must be filled out
+ mAxleSeparation(0.0f) //Must be filled out
+ {
+ }
+
+ /**
+ \brief Accuracy of Ackermann steer calculation.
+
+ \note Accuracy with value 0.0 results in no Ackermann steer-correction, while
+ accuracy with value 1.0 results in perfect Ackermann steer-correction.
+
+ \note Perfect Ackermann steer correction modifies the steer angles applied to the front-left and
+ front-right wheels so that the perpendiculars to the wheels' longitudinal directions cross the
+ extended vector of the rear axle at the same point. It is also applied to any steer angle applied
+ to the rear wheels but instead using the extended vector of the front axle.
+
+ \note In general, more steer correction produces better cornering behavior.
+
+ Range: [0, 1]
+ */
+ PxReal mAccuracy;
+
+ /**
+ \brief Distance between center-point of the two front wheels.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mFrontWidth;
+
+ /**
+ \brief Distance between center-point of the two rear wheels.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRearWidth;
+
+ /**
+ \brief Distance between center of front axle and center of rear axle.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mAxleSeparation;
+
+private:
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleAckermannGeometryData(const PxEMPTY) {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAckermannGeometryData)& 0x0f));
+
+/**
+\brief Choose between a potentially more expensive but more accurate solution to the clutch model or a potentially cheaper but less accurate solution.
+@see PxVehicleClutchData
+*/
+struct PxVehicleClutchAccuracyMode
+{
+ enum Enum
+ {
+ eESTIMATE = 0,
+ eBEST_POSSIBLE
+ };
+};
+
+class PxVehicleClutchData
+{
+public:
+
+ friend class PxVehicleDriveSimData;
+
+ PxVehicleClutchData()
+ : mStrength(10.0f),
+ mAccuracyMode(PxVehicleClutchAccuracyMode::eBEST_POSSIBLE),
+ mEstimateIterations(5)
+ {
+ }
+
+ /**
+ \brief Strength of clutch.
+
+ \note The clutch is the mechanism that couples the engine to the wheels.
+ A stronger clutch more strongly couples the engine to the wheels, while a
+ clutch of strength zero completely decouples the engine from the wheels.
+ Stronger clutches more quickly bring the wheels and engine into equilibrium, while weaker
+ clutches take longer, resulting in periods of clutch slip and delays in power transmission
+ from the engine to the wheels.
+ The torque generated by the clutch is proportional to the clutch strength and
+ the velocity difference between the engine's rotational speed and the rotational speed of the
+ driven wheels after accounting for the gear ratio.
+ The torque at the clutch is applied negatively to the engine and positively to the driven wheels.
+
+ \note Specified in kilograms metres-squared per second (kg m^2 s^-1)
+
+ Range: [0,PX_MAX_F32)
+ */
+ PxReal mStrength;
+
+ /**
+ \brief The engine and wheel rotation speeds that are coupled through the clutch can be updated by choosing
+ one of two modes: eESTIMATE and eBEST_POSSIBLE.
+
+ \note If eESTIMATE is chosen the vehicle sdk will update the wheel and engine rotation speeds
+ with estimated values to the implemented clutch model.
+
+ \note If eBEST_POSSIBLE is chosen the vehicle sdk will compute the best possible
+ solution (within floating point tolerance) to the implemented clutch model.
+ This is the recommended mode.
+
+ \note The clutch model remains the same if either eESTIMATE or eBEST_POSSIBLE is chosen but the accuracy and
+ computational cost of the solution to the model can be tuned as required.
+ */
+ PxVehicleClutchAccuracyMode::Enum mAccuracyMode;
+
+ /**
+ \brief Tune the mathematical accuracy and computational cost of the computed estimate to the wheel and
+ engine rotation speeds if eESTIMATE is chosen.
+
+ \note As mEstimateIterations increases the computational cost of the clutch also increases and the solution
+ approaches the solution that would be computed if eBEST_POSSIBLE was chosen instead.
+
+ \note This has no effect if eBEST_POSSIBLE is chosen as the accuracy mode.
+
+ \note A value of zero is not allowed if eESTIMATE is chosen as the accuracy mode.
+ */
+ PxU32 mEstimateIterations;
+
+private:
+
+ PxU8 mPad[4];
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleClutchData(const PxEMPTY) {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleClutchData)& 0x0f));
+
+
+/**
+\brief Tire load variation can be strongly dependent on the time-step so it is a good idea to filter it
+to give less jerky handling behavior.
+
+\note The x-axis of the graph is normalized tire load, while the y-axis is the filtered normalized tire load.
+
+\note The normalized load is the force acting downwards on the tire divided by the force experienced by the tire when the car is at rest on the ground.
+
+\note The rest load is approximately the product of the value of gravitational acceleration and PxVehicleSuspensionData::mSprungMass.
+
+\note The minimum possible normalized load is zero.
+
+\note There are two points on the graph: (mMinNormalisedLoad, mMinNormalisedFilteredLoad) and (mMaxNormalisedLoad, mMaxFilteredNormalisedLoad).
+
+\note Normalized loads less than mMinNormalisedLoad have filtered normalized load = mMinNormalisedFilteredLoad.
+
+\note Normalized loads greater than mMaxNormalisedLoad have filtered normalized load = mMaxFilteredNormalisedLoad.
+
+\note Normalized loads in-between are linearly interpolated between mMinNormalisedFilteredLoad and mMaxFilteredNormalisedLoad.
+
+\note The tire load applied as input to the tire force computation is the filtered normalized load multiplied by the rest load.
+*/
+class PxVehicleTireLoadFilterData
+{
+public:
+
+ friend class PxVehicleWheelsSimData;
+
+ PxVehicleTireLoadFilterData()
+ : mMinNormalisedLoad(0),
+ mMinFilteredNormalisedLoad(0.2308f),
+ mMaxNormalisedLoad(3.0f),
+ mMaxFilteredNormalisedLoad(3.0f)
+ {
+ mDenominator=1.0f/(mMaxNormalisedLoad - mMinNormalisedLoad);
+ }
+
+ /**
+ \brief Graph point (mMinNormalisedLoad,mMinFilteredNormalisedLoad)
+ */
+ PxReal mMinNormalisedLoad;
+
+ /**
+ \brief Graph point (mMinNormalisedLoad,mMinFilteredNormalisedLoad)
+ */
+ PxReal mMinFilteredNormalisedLoad;
+
+ /**
+ \brief Graph point (mMaxNormalisedLoad,mMaxFilteredNormalisedLoad)
+ */
+ PxReal mMaxNormalisedLoad;
+
+ /**
+ \brief Graph point (mMaxNormalisedLoad,mMaxFilteredNormalisedLoad)
+ */
+ PxReal mMaxFilteredNormalisedLoad;
+
+ PX_FORCE_INLINE PxReal getDenominator() const {return mDenominator;}
+
+private:
+
+ /**
+ \brief Not necessary to set this value.
+ */
+ //1.0f/(mMaxNormalisedLoad-mMinNormalisedLoad) for quick calculations
+ PxReal mDenominator;
+
+ PxU32 mPad[3];
+
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleTireLoadFilterData(const PxEMPTY) {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireLoadFilterData)& 0x0f));
+
+class PxVehicleWheelData
+{
+public:
+
+ friend class PxVehicleWheels4SimData;
+
+ PxVehicleWheelData()
+ : mRadius(0.0f), //Must be filled out
+ mWidth(0.0f),
+ mMass(20.0f),
+ mMOI(0.0f), //Must be filled out
+ mDampingRate(0.25f),
+ mMaxBrakeTorque(1500.0f),
+ mMaxHandBrakeTorque(0.0f),
+ mMaxSteer(0.0f),
+ mToeAngle(0.0f),
+ mRecipRadius(0.0f), //Must be filled out
+ mRecipMOI(0.0f) //Must be filled out
+ {
+ }
+
+ /**
+ \brief Radius of unit that includes metal wheel plus rubber tire.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRadius;
+
+ /**
+ \brief Maximum width of unit that includes wheel plus tire.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mWidth;
+
+ /**
+ \brief Mass of unit that includes wheel plus tire.
+
+ \note Specified in kilograms (kg).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMass;
+
+ /**
+ \brief Moment of inertia of unit that includes wheel plus tire about the rolling axis.
+
+ \note Specified in kilograms metres-squared (kg m^2).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMOI;
+
+ /**
+ \brief Damping rate applied to wheel.
+
+ \note Specified in kilograms metres-squared per second (kg m^2 s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mDampingRate;
+
+ /**
+ \brief Max brake torque that can be applied to wheel.
+
+ \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2)
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxBrakeTorque;
+
+ /**
+ \brief Max handbrake torque that can be applied to wheel.
+
+ \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2)
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxHandBrakeTorque;
+
+ /**
+ \brief Max steer angle that can be achieved by the wheel.
+
+ \note Specified in radians.
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxSteer;
+
+ /**
+ \brief Wheel toe angle. This value is ignored by PxVehicleDriveTank and PxVehicleNoDrive.
+
+ \note Specified in radians.
+
+ Range: [0, Pi/2]
+ */
+ PxReal mToeAngle;//in radians
+
+ /**
+ \brief Return value equal to 1.0f/mRadius
+
+ @see PxVehicleWheelsSimData::setWheelData
+ */
+ PX_FORCE_INLINE PxReal getRecipRadius() const {return mRecipRadius;}
+
+ /**
+ \brief Return value equal to 1.0f/mRecipMOI
+
+ @see PxVehicleWheelsSimData::setWheelData
+ */
+ PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
+
+private:
+
+ /**
+ \brief Reciprocal of radius of unit that includes metal wheel plus rubber tire.
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setWheelData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRecipRadius;
+
+ /**
+ \brief Reciprocal of moment of inertia of unit that includes wheel plus tire about single allowed axis of rotation.
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setWheelData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mRecipMOI;
+
+ PxReal mPad[1];
+
+ bool isValid() const;
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelData)& 0x0f));
+
+class PxVehicleSuspensionData
+{
+public:
+
+ friend class PxVehicleWheels4SimData;
+
+ PxVehicleSuspensionData()
+ : mSpringStrength(0.0f),
+ mSpringDamperRate(0.0f),
+ mMaxCompression(0.3f),
+ mMaxDroop(0.1f),
+ mSprungMass(0.0f),
+ mCamberAtRest(0.0f),
+ mCamberAtMaxCompression(0.0f),
+ mCamberAtMaxDroop(0.0f),
+ mRecipMaxCompression(1.0f),
+ mRecipMaxDroop(1.0f)
+ {
+ }
+
+ /**
+ \brief Spring strength of suspension unit.
+
+ \note Specified in kilograms per second-squared (kg s^-2).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mSpringStrength;
+
+ /**
+ \brief Spring damper rate of suspension unit.
+
+ \note Specified in kilograms per second (kg s^-1).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mSpringDamperRate;
+
+ /**
+ \brief Maximum compression allowed by suspension spring.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxCompression;
+
+ /**
+ \brief Maximum elongation allowed by suspension spring.
+
+ \note Specified in metres (m).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mMaxDroop;
+
+ /**
+ \brief Mass of vehicle that is supported by suspension spring.
+
+ \note Specified in kilograms (kg).
+
+ \note Each suspension is guaranteed to generate an upwards force of |gravity|*mSprungMass along the suspension direction when the wheel is perfectly
+ at rest and sitting at the rest pose defined by the wheel centre offset.
+
+ \note The sum of the sprung masses of all suspensions of a vehicle should match the mass of the PxRigidDynamic associated with the vehicle.
+ When this condition is satisfied for a vehicle on a horizontal plane the wheels of the vehicle are guaranteed to sit at the rest pose
+ defined by the wheel centre offset. The mass matching condition is not enforced.
+
+ \note As the wheel compresses or elongates along the suspension direction the force generated by the spring is
+ F = |gravity|*mSprungMass + deltaX*mSpringStrength + deltaXDot*mSpringDamperRate
+ where deltaX is the deviation from the defined rest pose and deltaXDot is the velocity of the sprung mass along the suspension direction.
+ In practice, deltaXDot is computed by comparing the current and previous deviation from the rest pose and dividing the difference
+ by the simulation timestep.
+
+ \note If a single suspension spring is hanging in the air and generates zero force the remaining springs of the vehicle will necessarily
+ sit in a compressed configuration. In summary, the sum of the remaining suspension forces cannot balance the downwards gravitational force
+ acting on the vehicle without extra force arising from the deltaX*mSpringStrength force term.
+
+ \note Theoretically, a suspension spring should generate zero force at maximum elongation and increase linearly as the suspension approaches the rest pose.
+ PxVehicleSuspensionData will only enforce this physical law if the spring is configured so that |gravity|*mSprungMass == mMaxDroop*mSpringStrength.
+ To help decouple vehicle handling from visual wheel positioning this condition is not enforced.
+ In practice, the value of |gravity|*mSprungMass + deltaX*mSpringStrength is clamped at zero to ensure it never falls negative.
+
+ @see PxVehicleComputeSprungMasses, PxVehicleWheelsSimData::setWheelCentreOffset, PxVehicleSuspensionData::mSpringStrength, PxVehicleSuspensionData::mSpringDamperRate, PxVehicleSuspensionData::mMaxDroop
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mSprungMass;
+
+ /**
+ \brief Camber angle (in radians) of wheel when the suspension is at its rest position.
+
+ \note Specified in radians.
+
+ Range: [-pi/2, pi/2]
+
+ */
+ PxReal mCamberAtRest;
+
+ /**
+ \brief Camber angle (in radians) of wheel when the suspension is at maximum compression.
+
+ \note For compressed suspensions the camber angle is a linear interpolation of
+ mCamberAngleAtRest and mCamberAtMaxCompression
+
+ \note Specified in radians.
+
+ Range: [-pi/2, pi/2]
+ */
+ PxReal mCamberAtMaxCompression;
+
+ /**
+ \brief Camber angle (in radians) of wheel when the suspension is at maximum droop.
+
+ \note For extended suspensions the camber angle is linearly interpolation of
+ mCamberAngleAtRest and mCamberAtMaxDroop
+
+ \note Specified in radians.
+
+ Range: [-pi/2, pi/2]
+ */
+ PxReal mCamberAtMaxDroop;
+
+ /**
+ \brief Reciprocal of maximum compression.
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PX_FORCE_INLINE PxReal getRecipMaxCompression() const {return mRecipMaxCompression;}
+
+ /**
+ \brief Reciprocal of maximum droop.
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData
+
+ Range: [0, PX_MAX_F32)
+ */
+ PX_FORCE_INLINE PxReal getRecipMaxDroop() const {return mRecipMaxDroop;}
+
+ /**
+ \brief Set a new sprung mass for the suspension and modify the spring strength so that the natural frequency
+ of the spring is preserved.
+ \param[in] newSprungMass is the new mass that the suspension spring will support.
+ */
+ void setMassAndPreserveNaturalFrequency(const PxReal newSprungMass)
+ {
+ const PxF32 oldStrength = mSpringStrength;
+ const PxF32 oldSprungMass = mSprungMass;
+ const PxF32 newStrength = oldStrength * (newSprungMass / oldSprungMass);
+ mSpringStrength = newStrength;
+ mSprungMass = newSprungMass;
+ }
+
+private:
+
+ /**
+ \brief Cached value of 1.0f/mMaxCompression
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData
+ */
+ PxReal mRecipMaxCompression;
+
+ /**
+ \brief Cached value of 1.0f/mMaxDroop
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData
+ */
+ PxReal mRecipMaxDroop;
+
+ //padding
+ PxReal mPad[2];
+
+ bool isValid() const;
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleSuspensionData)& 0x0f));
+
+class PxVehicleAntiRollBarData
+{
+public:
+
+ friend class PxVehicleWheelsSimData;
+
+ PxVehicleAntiRollBarData()
+ : mWheel0(0xffffffff),
+ mWheel1(0xffffffff),
+ mStiffness(0.0f)
+ {
+ }
+
+ /*
+ \brief The anti-roll bar connects two wheels with indices mWheel0 and mWheel1
+ */
+ PxU32 mWheel0;
+
+ /*
+ \brief The anti-roll bar connects two wheels with indices mWheel0 and mWheel1
+ */
+ PxU32 mWheel1;
+
+ /*
+ \brief The stiffness of the anti-roll bar.
+
+ \note Specified in kilograms per second-squared (kg s^-2).
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxF32 mStiffness;
+
+private:
+
+ PxF32 mPad[1];
+
+ bool isValid() const;
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAntiRollBarData)& 0x0f));
+
+class PxVehicleTireData
+{
+public:
+ friend class PxVehicleWheels4SimData;
+
+ PxVehicleTireData()
+ : mLatStiffX(2.0f),
+ mLatStiffY(0.3125f*(180.0f / PxPi)),
+ mLongitudinalStiffnessPerUnitGravity(1000.0f),
+ mCamberStiffnessPerUnitGravity(0.1f*(180.0f / PxPi)),
+ mType(0)
+ {
+ mFrictionVsSlipGraph[0][0]=0.0f;
+ mFrictionVsSlipGraph[0][1]=1.0f;
+ mFrictionVsSlipGraph[1][0]=0.1f;
+ mFrictionVsSlipGraph[1][1]=1.0f;
+ mFrictionVsSlipGraph[2][0]=1.0f;
+ mFrictionVsSlipGraph[2][1]=1.0f;
+
+ mRecipLongitudinalStiffnessPerUnitGravity=1.0f/mLongitudinalStiffnessPerUnitGravity;
+
+ mFrictionVsSlipGraphRecipx1Minusx0=1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]);
+ mFrictionVsSlipGraphRecipx2Minusx1=1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]);
+ }
+
+ /**
+ \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and
+ flattens at large loads. mLatStiffX describes the minimum normalized load (load/restLoad) that gives a
+ flat lateral stiffness response to load.
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mLatStiffX;
+
+ /**
+ \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and
+ flattens at large loads. mLatStiffY describes the maximum possible value of lateralStiffness/restLoad that occurs
+ when (load/restLoad)>= mLatStiffX.
+
+ \note If load/restLoad is greater than mLatStiffX then the lateral stiffness is mLatStiffY*restLoad.
+
+ \note If load/restLoad is less than mLatStiffX then the lateral stiffness is mLastStiffY*(load/mLatStiffX)
+
+ \note Lateral force can be approximated as lateralStiffness * lateralSlip.
+
+ \note Specified in per radian.
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mLatStiffY;
+
+ /**
+ \brief Tire Longitudinal stiffness per unit gravitational acceleration.
+
+ \note Longitudinal stiffness of the tire is calculated as gravitationalAcceleration*mLongitudinalStiffnessPerUnitGravity.
+
+ \note Longitudinal force can be approximated as gravitationalAcceleration*mLongitudinalStiffnessPerUnitGravity*longitudinalSlip.
+
+ \note Specified in kilograms per radian.
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mLongitudinalStiffnessPerUnitGravity;
+
+ /**
+ \brief tire Tire camber stiffness per unity gravitational acceleration.
+
+ \note Camber stiffness of the tire is calculated as gravitationalAcceleration*mCamberStiffnessPerUnitGravity
+
+ \note Camber force can be approximated as gravitationalAcceleration*mCamberStiffnessPerUnitGravity*camberAngle.
+
+ \note Specified in kilograms per radian.
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mCamberStiffnessPerUnitGravity;
+
+ /**
+ \brief Graph of friction vs longitudinal slip with 3 points.
+
+ \note mFrictionVsSlipGraph[0][0] is always zero.
+
+ \note mFrictionVsSlipGraph[0][1] is the friction available at zero longitudinal slip.
+
+ \note mFrictionVsSlipGraph[1][0] is the value of longitudinal slip with maximum friction.
+
+ \note mFrictionVsSlipGraph[1][1] is the maximum friction.
+
+ \note mFrictionVsSlipGraph[2][0] is the end point of the graph.
+
+ \note mFrictionVsSlipGraph[2][1] is the value of friction for slips greater than mFrictionVsSlipGraph[2][0].
+
+ \note The friction value computed from the friction vs longitudinal slip graph is used to scale the friction
+ value for the combination of material and tire type (PxVehicleDrivableSurfaceToTireFrictionPairs).
+
+ \note mFrictionVsSlipGraph[2][0] > mFrictionVsSlipGraph[1][0] > mFrictionVsSlipGraph[0][0]
+
+ \note mFrictionVsSlipGraph[1][1] is typically greater than mFrictionVsSlipGraph[0][1]
+
+ \note mFrictionVsSlipGraph[2][1] is typically smaller than mFrictionVsSlipGraph[1][1]
+
+ \note longitudinal slips > mFrictionVsSlipGraph[2][0] use friction multiplier mFrictionVsSlipGraph[2][1]
+
+ \note The final friction value used by the tire model is the value returned by PxVehicleDrivableSurfaceToTireFrictionPairs
+ multiplied by the value computed from mFrictionVsSlipGraph.
+
+ @see PxVehicleDrivableSurfaceToTireFrictionPairs, PxVehicleComputeTireForce
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxReal mFrictionVsSlipGraph[3][2];
+
+ /**
+ \brief Tire type denoting slicks, wets, snow, winter, summer, all-terrain, mud etc.
+
+ @see PxVehicleDrivableSurfaceToTireFrictionPairs
+
+ Range: [0, PX_MAX_F32)
+ */
+ PxU32 mType;
+
+ /**
+ \brief Return Cached value of 1.0/mLongitudinalStiffnessPerUnitGravity
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PX_FORCE_INLINE PxReal getRecipLongitudinalStiffnessPerUnitGravity() const {return mRecipLongitudinalStiffnessPerUnitGravity;}
+
+ /**
+ \brief Return Cached value of 1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0])
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx1Minusx0() const {return mFrictionVsSlipGraphRecipx1Minusx0;}
+
+ /**
+ \brief Return Cached value of 1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0])
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx2Minusx1() const {return mFrictionVsSlipGraphRecipx2Minusx1;}
+
+private:
+
+ /**
+ \brief Cached value of 1.0/mLongitudinalStiffnessPerUnitGravity.
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PxReal mRecipLongitudinalStiffnessPerUnitGravity;
+
+ /**
+ \brief Cached value of 1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0])
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PxReal mFrictionVsSlipGraphRecipx1Minusx0;
+
+ /**
+ \brief Cached value of 1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0])
+
+ \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData
+
+ @see PxVehicleWheelsSimData::setTireData
+ */
+ PxReal mFrictionVsSlipGraphRecipx2Minusx1;
+
+ PxReal mPad[2];
+
+ bool isValid() const;
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireData)& 0x0f));
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_CORE_COMPONENTS_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive.h
new file mode 100644
index 00000000..c0ca3fc6
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive.h
@@ -0,0 +1,565 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_DRIVE_H
+#define PX_VEHICLE_DRIVE_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleWheels.h"
+#include "vehicle/PxVehicleComponents.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxFilterData;
+class PxGeometry;
+class PxPhysics;
+class PxVehicleDrivableSurfaceToTireFrictionPairs;
+class PxShape;
+class PxMaterial;
+class PxRigidDynamic;
+
+/**
+\brief Data structure describing non-wheel configuration data of a vehicle that has engine, gears, clutch, and auto-box.
+@see PxVehicleWheelsSimData for wheels configuration data.
+*/
+class PxVehicleDriveSimData
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleDriveTank;
+
+ /**
+ \brief Return the engine data
+ */
+ PX_FORCE_INLINE const PxVehicleEngineData& getEngineData() const
+ {
+ return mEngine;
+ }
+
+ /**
+ \brief Set the engine data
+ \param[in] engine - the data stored in engine is copied to the vehicle's engine.
+ */
+ void setEngineData(const PxVehicleEngineData& engine);
+
+ /**
+ \brief Return the gears data
+ */
+ PX_FORCE_INLINE const PxVehicleGearsData& getGearsData() const
+ {
+ return mGears;
+ }
+
+ /**
+ \brief Set the gears data
+ \param[in] gears - the data stored in gears is copied to the vehicle's gears.
+ */
+ void setGearsData(const PxVehicleGearsData& gears);
+
+ /**
+ \brief Return the clutch data
+ */
+ PX_FORCE_INLINE const PxVehicleClutchData& getClutchData() const
+ {
+ return mClutch;
+ }
+
+ /**
+ \brief Set the clutch data
+ \param[in] clutch - the data stored in clutch is copied to the vehicle's clutch.
+ */
+ void setClutchData(const PxVehicleClutchData& clutch);
+
+ /**
+ \brief Return the autobox data
+ */
+ PX_FORCE_INLINE const PxVehicleAutoBoxData& getAutoBoxData() const
+ {
+ return mAutoBox;
+ }
+
+ /**
+ \brief Set the autobox data
+ \param[in] autobox - the data stored in autobox is copied to the vehicle's autobox.
+ */
+ void setAutoBoxData(const PxVehicleAutoBoxData& autobox);
+
+protected:
+ /*
+ \brief Engine simulation data
+ @see setEngineData, getEngineData
+ */
+ PxVehicleEngineData mEngine;
+
+ /*
+ \brief Gear simulation data
+ @see setGearsData, getGearsData
+ */
+ PxVehicleGearsData mGears;
+
+ /*
+ \brief Clutch simulation data
+ @see setClutchData, getClutchData
+ */
+ PxVehicleClutchData mClutch;
+
+ /*
+ \brief Autobox simulation data
+ @see setAutoboxData, getAutoboxData
+ */
+ PxVehicleAutoBoxData mAutoBox;
+
+ /**
+ \brief Test that a PxVehicleDriveSimData instance has been configured with legal data.
+ Call only after setting all components with setEngineData,setGearsData,setClutchData,setAutoBoxData
+ @see PxVehicleDrive4W::setup, PxVehicleDriveTank::setup
+ */
+ bool isValid() const;
+
+
+//serialization
+public:
+ PxVehicleDriveSimData() {}
+ PxVehicleDriveSimData(const PxEMPTY) : mEngine(PxEmpty), mGears(PxEmpty), mClutch(PxEmpty), mAutoBox(PxEmpty) {}
+ static void getBinaryMetaData(PxOutputStream& stream);
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData) & 15));
+
+
+/**
+\brief Data structure with instanced dynamics data for vehicle with engine, clutch, gears, autobox
+@see PxVehicleWheelsDynData for wheels dynamics data.
+*/
+class PxVehicleDriveDynData
+{
+public:
+
+ enum
+ {
+ eMAX_NB_ANALOG_INPUTS=16
+ };
+
+ friend class PxVehicleDrive;
+
+ /**
+ \brief Set all dynamics data to zero to bring the vehicle to rest.
+ */
+ void setToRestState();
+
+ /**
+ \brief Set an analog control value to drive the vehicle.
+ \param[in] type describes the type of analog control being modified
+ \param[in] analogVal is the new value of the specific analog control.
+ @see PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl
+ */
+ void setAnalogInput(const PxU32 type, const PxReal analogVal);
+
+ /**
+ \brief Get the analog control value that has been applied to the vehicle.
+ \return The value of the specified analog control value.
+ @see PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl
+ */
+ PxReal getAnalogInput(const PxU32 type) const;
+
+ /**
+ \brief Inform the vehicle that the gear-up button has been pressed.
+
+ \param[in] digitalVal is the state of the gear-up button.
+
+ \note If digitalVal is true the vehicle will attempt to initiate a gear change at the next call to PxVehicleUpdates.
+
+ \note The value of mGearUpPressed is not reset by PxVehicleUpdates
+ */
+ void setGearUp(const bool digitalVal)
+ {
+ mGearUpPressed = digitalVal;
+ }
+
+ /**
+ \brief Set that the gear-down button has been pressed.
+
+ \param[in] digitalVal is the state of the gear-down button.
+
+ \note If digitalVal is true the vehicle will attempt to initiate a gear change at the next call to PxVehicleUpdates.
+
+ \note The value of mGearDownPressed is not reset by PxVehicleUpdates
+ */
+ void setGearDown(const bool digitalVal)
+ {
+ mGearDownPressed = digitalVal;
+ }
+
+ /**
+ \brief Check if the gear-up button has been pressed
+ \return The state of the gear-up button.
+ */
+ bool getGearUp() const
+ {
+ return mGearUpPressed;
+ }
+
+ /**
+ \brief Check if the gear-down button has been pressed
+ \return The state of the gear-down button.
+ */
+ bool getGearDown() const
+ {
+ return mGearDownPressed;
+ }
+
+ /**
+ \brief Set the flag that will be used to select auto-gears
+ If useAutoGears is true the auto-box will be active.
+ \param[in] useAutoGears is the active state of the auto-box.
+ */
+ PX_FORCE_INLINE void setUseAutoGears(const bool useAutoGears)
+ {
+ mUseAutoGears=useAutoGears;
+ }
+
+ /**
+ \brief Get the flag status that is used to select auto-gears
+ \return The active status of the auto-box.
+ */
+ PX_FORCE_INLINE bool getUseAutoGears() const
+ {
+ return mUseAutoGears;
+ }
+
+ /**
+ \brief Toggle the auto-gears flag
+ If useAutoGears is true the auto-box will be active.
+ */
+ PX_FORCE_INLINE void toggleAutoGears()
+ {
+ mUseAutoGears = !mUseAutoGears;
+ }
+
+ /**
+ \brief Set the current gear.
+
+ \param[in] currentGear is the vehicle's gear.
+
+ \note If the target gear is different from the current gear the vehicle will
+ attempt to start a gear change from the current gear that has just been set
+ towards the target gear at the next call to PxVehicleUpdates.
+
+ @see setTargetGear, PxVehicleGearsData
+ */
+ PX_FORCE_INLINE void setCurrentGear(PxU32 currentGear)
+ {
+ mCurrentGear = currentGear;
+ }
+
+ /**
+ \brief Get the current gear.
+
+ \return The vehicle's current gear.
+
+ @see getTargetGear, PxVehicleGearsData
+ */
+ PX_FORCE_INLINE PxU32 getCurrentGear() const
+ {
+ return mCurrentGear;
+ }
+
+ /**
+ \brief Set the target gear.
+
+ \param[in] targetGear is the vehicle's target gear.
+
+ \note If the target gear is different from the current gear the vehicle will
+ attempt to start a gear change towards the target gear at the next call to
+ PxVehicleUpdates.
+
+ @see PxVehicleGearsData
+ */
+ PX_FORCE_INLINE void setTargetGear(PxU32 targetGear)
+ {
+ mTargetGear = targetGear;
+ }
+
+ /**
+ \brief Get the target gear.
+
+ \return The vehicle's target gear.
+
+ @see setTargetGear, PxVehicleGearsData
+ */
+ PX_FORCE_INLINE PxU32 getTargetGear() const
+ {
+ return mTargetGear;
+ }
+
+ /**
+ \brief Start a gear change to a target gear.
+
+ \param[in] targetGear is the gear the vehicle will begin a transition towards.
+
+ \note The gear change will begin at the next call to PxVehicleUpadates.
+
+ @see PxVehicleGearsData
+ */
+ PX_FORCE_INLINE void startGearChange(const PxU32 targetGear)
+ {
+ mTargetGear=targetGear;
+ }
+
+ /**
+ \brief Force an immediate gear change to a target gear
+
+ \param[in] targetGear is the gear the vehicle will be given immediately.
+
+ @see PxVehicleGearsData
+ */
+ PX_FORCE_INLINE void forceGearChange(const PxU32 targetGear)
+ {
+ mTargetGear=targetGear;
+ mCurrentGear=targetGear;
+ }
+
+ /**
+ \brief Set the rotation speed of the engine (radians per second)
+
+ \param[in] speed is the rotational speed (radians per second) to apply to the engine.
+ */
+ PX_FORCE_INLINE void setEngineRotationSpeed(const PxF32 speed)
+ {
+ mEnginespeed = speed;
+ }
+
+ /**
+ \brief Return the rotation speed of the engine (radians per second)
+
+ \return The rotational speed (radians per second) of the engine.
+ */
+ PX_FORCE_INLINE PxReal getEngineRotationSpeed() const
+ {
+ return mEnginespeed;
+ }
+
+ /**
+ \brief Return the time that has passed since the current gear change was initiated.
+
+ \return The time that has passed since the current gear change was initiated.
+
+ \note If no gear change is in process the gear switch time will be zero.
+
+ @see PxVehicleGearsData.mSwitchTime
+ */
+ PX_FORCE_INLINE PxReal getGearSwitchTime() const
+ {
+ return mGearSwitchTime;
+ }
+
+ /**
+ \brief Return the time that has passed since the autobox last initiated a gear change.
+
+ \return The time that has passed since the autobox last initiated a gear change.
+
+ @see PxVehicleAutoBoxData::setLatency, PxVehicleAutoBoxData::getLatency
+ */
+ PX_FORCE_INLINE PxReal getAutoBoxSwitchTime() const
+ {
+ return mAutoBoxSwitchTime;
+ }
+
+ /**
+ \brief All dynamic data values are public for fast access.
+ */
+
+
+ /**
+ \brief Analog control values used by vehicle simulation.
+ @see setAnalogInput, getAnalogInput, PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl
+ */
+ PxReal mControlAnalogVals[eMAX_NB_ANALOG_INPUTS];
+
+ /**
+ \brief Auto-gear flag used by vehicle simulation. Set true to enable the autobox, false to disable the autobox.
+ @see setUseAutoGears, setUseAutoGears, toggleAutoGears, PxVehicleAutoBoxData
+ */
+ bool mUseAutoGears;
+
+ /**
+ \brief Gear-up digital control value used by vehicle simulation.
+
+ \note If true a gear change will be initiated towards currentGear+1 (or to first gear if in reverse).
+
+ @see setDigitalInput, getDigitalInput
+ */
+ bool mGearUpPressed;
+
+ /**
+ \brief Gear-down digital control value used by vehicle simulation.
+
+ \note If true a gear change will be initiated towards currentGear-1 (or to reverse if in first).
+
+ @see setDigitalInput, getDigitalInput
+ */
+ bool mGearDownPressed;
+
+ /**
+ \brief Current gear
+ @see startGearChange, forceGearChange, getCurrentGear, PxVehicleGearsData
+ */
+ PxU32 mCurrentGear;
+
+ /**
+ \brief Target gear (different from current gear if a gear change is underway)
+ @see startGearChange, forceGearChange, getTargetGear, PxVehicleGearsData
+ */
+ PxU32 mTargetGear;
+
+ /**
+ \brief Rotation speed of engine
+ @see setToRestState, getEngineRotationSpeed
+ */
+ PxReal mEnginespeed;
+
+ /**
+ \brief Reported time that has passed since gear change started.
+ @see setToRestState, startGearChange, PxVehicleGearsData::mSwitchTime
+ */
+ PxReal mGearSwitchTime;
+
+ /**
+ \brief Reported time that has passed since last autobox gearup/geardown decision.
+ @see setToRestState, PxVehicleAutoBoxData::setLatency
+ */
+ PxReal mAutoBoxSwitchTime;
+
+private:
+ PxU32 mPad[2];
+
+ /**
+ \brief Test that a PxVehicleDriveDynData instance has legal values.
+ @see setToRestState
+ */
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDriveDynData();
+ PxVehicleDriveDynData(const PxEMPTY) {}
+ PxU32 getNbAnalogInput() const { return eMAX_NB_ANALOG_INPUTS; }
+ PX_FORCE_INLINE void setGearChange(const PxU32 gearChange) { mTargetGear= gearChange; }
+ PX_FORCE_INLINE PxU32 getGearChange() const { return mTargetGear; }
+ PX_FORCE_INLINE void setGearSwitchTime(const PxReal switchTime) { mGearSwitchTime = switchTime; }
+ PX_FORCE_INLINE void setAutoBoxSwitchTime(const PxReal autoBoxSwitchTime) { mAutoBoxSwitchTime = autoBoxSwitchTime; }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveDynData) & 15));
+
+/**
+\brief A complete vehicle with instance dynamics data and configuration data for wheels and engine,clutch,gears,autobox.
+@see PxVehicleDrive4W, PxVehicleDriveTank
+*/
+class PxVehicleDrive : public PxVehicleWheels
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Dynamics data of vehicle instance.
+ @see setup
+ */
+ PxVehicleDriveDynData mDriveDynData;
+
+protected:
+
+ /**
+ \brief Test that all instanced dynamics data and configuration data have legal values.
+ */
+ bool isValid() const;
+
+ /**
+ \brief Set vehicle to rest.
+ */
+ void setToRestState();
+
+ /**
+ @see PxVehicleDrive4W::allocate, PxVehicleDriveTank::allocate
+ */
+ static PxU32 computeByteSize(const PxU32 numWheels);
+ static PxU8* patchupPointers(const PxU32 nbWheels, PxVehicleDrive* vehDrive, PxU8* ptr);
+ virtual void init(const PxU32 numWheels);
+
+ /**
+ \brief Deallocate a PxVehicle4WDrive instance.
+ @see PxVehicleDrive4W::free, PxVehicleDriveTank::free
+ */
+ void free();
+
+ /**
+ @see PxVehicleDrive4W::setup, PxVehicleDriveTank::setup
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData,
+ const PxU32 nbDrivenWheels, const PxU32 nbNonDrivenWheels);
+
+//serialization
+public:
+ static void getBinaryMetaData(PxOutputStream& stream);
+ PxVehicleDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags), mDriveDynData(PxEmpty) {}
+ virtual const char* getConcreteTypeName() const { return "PxVehicleDrive"; }
+protected:
+ PxVehicleDrive(PxType concreteType, PxBaseFlags baseFlags) : PxVehicleWheels(concreteType, baseFlags) {}
+ ~PxVehicleDrive() {}
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleDrive", name) || PxBase::isKindOf(name); }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_DRIVE_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive4W.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive4W.h
new file mode 100644
index 00000000..270f1662
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleDrive4W.h
@@ -0,0 +1,278 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_4WDRIVE_H
+#define PX_VEHICLE_4WDRIVE_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleDrive.h"
+#include "vehicle/PxVehicleWheels.h"
+#include "vehicle/PxVehicleComponents.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxFilterData;
+class PxGeometry;
+class PxPhysics;
+class PxVehicleDrivableSurfaceToTireFrictionPairs;
+class PxShape;
+class PxMaterial;
+class PxRigidDynamic;
+
+/**
+\brief Data structure describing the drive model components of a vehicle with up to 4 driven wheels and up to 16 un-driven wheels.
+The drive model incorporates engine, clutch, gears, autobox, differential, and Ackermann steer correction.
+@see PxVehicleDriveSimData
+*/
+class PxVehicleDriveSimData4W : public PxVehicleDriveSimData
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleDrive4W;
+
+ PxVehicleDriveSimData4W()
+ : PxVehicleDriveSimData()
+ {
+ }
+
+ /**
+ \brief Return the data describing the differential.
+ @see PxVehicleDifferential4WData
+ */
+ PX_FORCE_INLINE const PxVehicleDifferential4WData& getDiffData() const
+ {
+ return mDiff;
+ }
+
+ /**
+ \brief Return the data describing the Ackermann steer-correction.
+ @see PxVehicleAckermannGeometryData
+ */
+ PX_FORCE_INLINE const PxVehicleAckermannGeometryData& getAckermannGeometryData() const
+ {
+ return mAckermannGeometry;
+ }
+
+ /**
+ \brief Set the data describing the differential.
+ @see PxVehicleDifferential4WData
+ */
+ void setDiffData(const PxVehicleDifferential4WData& diff);
+
+ /**
+ \brief Set the data describing the Ackermann steer-correction.
+ @see PxVehicleAckermannGeometryData
+ */
+ void setAckermannGeometryData(const PxVehicleAckermannGeometryData& ackermannData);
+
+private:
+
+ /**
+ \brief Differential simulation data
+ @see setDiffData, getDiffData
+ */
+ PxVehicleDifferential4WData mDiff;
+
+ /**
+ \brief Data for ackermann steer angle computation.
+ @see setAckermannGeometryData, getAckermannGeometryData
+ */
+ PxVehicleAckermannGeometryData mAckermannGeometry;
+
+ /**
+ \brief Test if the 4W-drive simulation data has been setup with legal data.
+ \note Call only after setting all components.
+ @see setEnginedata, setClutchData, setGearsData, setAutoboxData, setDiffData, setAckermannGeometryData
+ */
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDriveSimData4W(const PxEMPTY) : PxVehicleDriveSimData(PxEmpty), mDiff(PxEmpty), mAckermannGeometry(PxEmpty) {}
+ static void getBinaryMetaData(PxOutputStream& stream);
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData4W) & 15));
+
+
+
+/**
+\brief The ordering of the driven and steered wheels of a PxVehicleDrive4W.
+
+@see PxVehicleWheelsSimData, PxVehicleWheelsDynData
+*/
+
+struct PxVehicleDrive4WWheelOrder
+{
+ enum Enum
+ {
+ eFRONT_LEFT=0,
+ eFRONT_RIGHT,
+ eREAR_LEFT,
+ eREAR_RIGHT
+ };
+};
+
+/**
+\brief The control inputs for a PxVehicleDrive4W.
+
+@see PxVehicleDriveDynData::setAnalogInput, PxVehicleDriveDynData::getAnalogInput
+*/
+
+struct PxVehicleDrive4WControl
+{
+ enum Enum
+ {
+ eANALOG_INPUT_ACCEL=0,
+ eANALOG_INPUT_BRAKE,
+ eANALOG_INPUT_HANDBRAKE,
+ eANALOG_INPUT_STEER_LEFT,
+ eANALOG_INPUT_STEER_RIGHT,
+ eMAX_NB_DRIVE4W_ANALOG_INPUTS
+ };
+};
+
+/**
+\brief Data structure with instanced dynamics data and configuration data of a vehicle with up to 4 driven wheels and up to 16 non-driven wheels.
+*/
+class PxVehicleDrive4W : public PxVehicleDrive
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Allocate a PxVehicleDrive4W instance for a 4WDrive vehicle with nbWheels (= 4 + number of un-driven wheels)
+
+ \param[in] nbWheels is the number of vehicle wheels (= 4 + number of un-driven wheels)
+
+ \return The instantiated vehicle.
+
+ @see free, setup
+ */
+ static PxVehicleDrive4W* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Deallocate a PxVehicleDrive4W instance.
+ @see allocate
+ */
+ void free();
+
+ /**
+ \brief Set up a vehicle using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \param[in] driveData describes the properties of the vehicle's drive model (gears/engine/clutch/differential/autobox). The vehicle instance takes a copy of this data.
+ \param[in] nbNonDrivenWheels is the number of wheels on the vehicle that cannot be connected to the differential (= numWheels - 4).
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ \note wheelsData must contain data for at least 4 wheels. Unwanted wheels can be disabled with PxVehicleWheelsSimData::disableWheel after calling setup.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData4W& driveData,
+ const PxU32 nbNonDrivenWheels);
+
+ /**
+ \brief Allocate and set up a vehicle using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \param[in] driveData describes the properties of the vehicle's drive model (gears/engine/clutch/differential/autobox). The vehicle instance takes a copy of this data.
+ \param[in] nbNonDrivenWheels is the number of wheels on the vehicle that cannot be connected to the differential (= numWheels - 4).
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ \note wheelsData must contain data for at least 4 wheels. Unwanted wheels can be disabled with PxVehicleWheelsSimData::disableWheel after calling setup.
+ \return The instantiated vehicle.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ */
+ static PxVehicleDrive4W* create
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData4W& driveData,
+ const PxU32 nbNonDrivenWheels);
+
+ /**
+ \brief Set a vehicle to its rest state. Aside from the rigid body transform, this will set the vehicle and rigid body
+ to the state they were in immediately after setup or create.
+ \note Calling setToRestState invalidates the cached raycast hit planes under each wheel meaning that suspension line
+ raycasts need to be performed at least once with PxVehicleSuspensionRaycasts before calling PxVehicleUpdates.
+ @see setup, create, PxVehicleSuspensionRaycasts, PxVehicleUpdates
+ */
+ void setToRestState();
+
+ /**
+ \brief Simulation data that describes the configuration of the vehicle's drive model.
+ @see setup, create
+ */
+ PxVehicleDriveSimData4W mDriveSimData;
+
+private:
+
+ /**
+ \brief Test if the instanced dynamics and configuration data has legal values.
+ */
+ bool isValid() const;
+
+//serialization
+protected:
+ PxVehicleDrive4W();
+ ~PxVehicleDrive4W(){}
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleDrive4W", name) || PxBase::isKindOf(name); }
+public:
+ static PxVehicleDrive4W* createObject(PxU8*& address, PxDeserializationContext& context);
+ static void getBinaryMetaData(PxOutputStream& stream);
+ PxVehicleDrive4W(PxBaseFlags baseFlags) : PxVehicleDrive(baseFlags), mDriveSimData(PxEmpty) {}
+ virtual const char* getConcreteTypeName() const { return "PxVehicleDrive4W"; }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive4W) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_4WDRIVE_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveNW.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveNW.h
new file mode 100644
index 00000000..f9334d2a
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveNW.h
@@ -0,0 +1,236 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_NWDRIVE_H
+#define PX_VEHICLE_NWDRIVE_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleDrive.h"
+#include "vehicle/PxVehicleWheels.h"
+#include "vehicle/PxVehicleComponents.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxFilterData;
+class PxGeometry;
+class PxPhysics;
+class PxVehicleDrivableSurfaceToTireFrictionPairs;
+class PxShape;
+class PxMaterial;
+class PxRigidDynamic;
+
+/**
+\brief Data structure describing configuration data of a vehicle with up to PX_MAX_NB_WHEELS driven equally through the differential. The vehicle has an
+engine, clutch, gears, autobox, differential.
+@see PxVehicleDriveSimData
+*/
+class PxVehicleDriveSimDataNW : public PxVehicleDriveSimData
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleDriveNW;
+
+ PxVehicleDriveSimDataNW()
+ : PxVehicleDriveSimData()
+ {
+ }
+
+ /**
+ \brief Return the data describing the differential of a vehicle with up to PX_MAX_NB_WHEELS driven wheels.
+ */
+ const PxVehicleDifferentialNWData& getDiffData() const
+ {
+ return mDiff;
+ }
+
+ /**
+ \brief Set the data describing the differential of a vehicle with up to PX_MAX_NB_WHEELS driven wheels.
+ The differential data describes the set of wheels that are driven by the differential.
+ */
+ void setDiffData(const PxVehicleDifferentialNWData& diff);
+
+private:
+
+ /**
+ \brief Differential simulation data
+ @see setDiffData, getDiffData
+ */
+ PxVehicleDifferentialNWData mDiff;
+
+ /**
+ \brief Test if the NW-drive simulation data has been setup with legal data.
+ Call only after setting all components.
+ @see setEngineData, setClutchData, setGearsData, setAutoboxData, setDiffData, setAckermannGeometryData
+ */
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDriveSimDataNW(const PxEMPTY) : PxVehicleDriveSimData(PxEmpty), mDiff(PxEmpty) {}
+ static void getBinaryMetaData(PxOutputStream& stream);
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimDataNW) & 15));
+
+
+/**
+\brief The control inputs for a PxVehicleDriveNW.
+
+@see PxVehicleDriveDynData::setAnalogInput, PxVehicleDriveDynData::getAnalogInput
+*/
+struct PxVehicleDriveNWControl
+{
+ enum Enum
+ {
+ eANALOG_INPUT_ACCEL=0,
+ eANALOG_INPUT_BRAKE,
+ eANALOG_INPUT_HANDBRAKE,
+ eANALOG_INPUT_STEER_LEFT,
+ eANALOG_INPUT_STEER_RIGHT,
+ eMAX_NB_DRIVENW_ANALOG_INPUTS
+ };
+};
+
+/**
+\brief Data structure with instanced dynamics data and configuration data of a vehicle with up to PX_MAX_NB_WHEELS driven wheels.
+*/
+class PxVehicleDriveNW : public PxVehicleDrive
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Allocate a PxVehicleDriveNW instance for a NWDrive vehicle with nbWheels
+
+ \param[in] nbWheels is the number of wheels on the vehicle.
+
+ \return The instantiated vehicle.
+
+ @see free, setup
+ */
+ static PxVehicleDriveNW* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Deallocate a PxVehicleDriveNW instance.
+ @see allocate
+ */
+ void free();
+
+ /**
+ \brief Set up a vehicle using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \param[in] driveData describes the properties of the vehicle's drive model (gears/engine/clutch/differential/autobox). The vehicle instance takes a copy of this data.
+ \param[in] nbWheels is the number of wheels on the vehicle.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimDataNW& driveData,
+ const PxU32 nbWheels);
+
+ /**
+ \brief Allocate and set up a vehicle using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \param[in] driveData describes the properties of the vehicle's drive model (gears/engine/clutch/differential/autobox). The vehicle instance takes a copy of this data.
+ \param[in] nbWheels is the number of wheels on the vehicle.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ \return The instantiated vehicle.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ */
+ static PxVehicleDriveNW* create
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimDataNW& driveData,
+ const PxU32 nbWheels);
+
+ /**
+ \brief Set a vehicle to its rest state. Aside from the rigid body transform, this will set the vehicle and rigid body
+ to the state they were in immediately after setup or create.
+ \note Calling setToRestState invalidates the cached raycast hit planes under each wheel meaning that suspension line
+ raycasts need to be performed at least once with PxVehicleSuspensionRaycasts before calling PxVehicleUpdates.
+ @see setup, create, PxVehicleSuspensionRaycasts, PxVehicleUpdates
+ */
+ void setToRestState();
+
+ /**
+ \brief Simulation data that describes the configuration of the vehicle's drive model.
+ @see setup, create
+ */
+ PxVehicleDriveSimDataNW mDriveSimData;
+
+private:
+
+ /**
+ \brief Test if the instanced dynamics and configuration data has legal values.
+ */
+ bool isValid() const;
+
+//serialization
+public:
+ PxVehicleDriveNW(PxBaseFlags baseFlags) : PxVehicleDrive(baseFlags), mDriveSimData(PxEmpty) {}
+ PxVehicleDriveNW();
+ ~PxVehicleDriveNW(){}
+ static PxVehicleDriveNW* createObject(PxU8*& address, PxDeserializationContext& context);
+ static void getBinaryMetaData(PxOutputStream& stream);
+ virtual const char* getConcreteTypeName() const { return "PxVehicleDriveNW"; }
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleDriveNW", name) || PxBase::isKindOf(name); }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveNW) & 15));
+
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_NWDRIVE_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveTank.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveTank.h
new file mode 100644
index 00000000..b9f16351
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleDriveTank.h
@@ -0,0 +1,280 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_DRIVE_TANK_H
+#define PX_VEHICLE_DRIVE_TANK_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleDrive.h"
+#include "vehicle/PxVehicleWheels.h"
+#include "vehicle/PxVehicleComponents.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxFilterData;
+class PxGeometry;
+class PxPhysics;
+class PxVehicleDrivableSurfaceToTireFrictionPairs;
+class PxShape;
+class PxMaterial;
+class PxRigidDynamic;
+
+/**
+\brief The ordering of the wheels of a PxVehicleDriveTank.
+
+@see PxVehicleWheelsSimData, PxVehicleWheelsDynData
+*/
+struct PxVehicleDriveTankWheelOrder
+{
+ enum Enum
+ {
+ eFRONT_LEFT=0,
+ eFRONT_RIGHT,
+ e1ST_FROM_FRONT_LEFT,
+ e1ST_FROM_FRONT_RIGHT,
+ e2ND_FROM_FRONT_LEFT,
+ e2ND_FROM_FRONT_RIGHT,
+ e3RD_FROM_FRONT_LEFT,
+ e3RD_FROM_FRONT_RIGHT,
+ e4TH_FROM_FRONT_LEFT,
+ e4TH_FROM_FRONT_RIGHT,
+ e5TH_FROM_FRONT_LEFT,
+ e5TH_FROM_FRONT_RIGHT,
+ e6TH_FROM_FRONT_LEFT,
+ e6TH_FROM_FRONT_RIGHT,
+ e7TH_FROM_FRONT_LEFT,
+ e7TH_FROM_FRONT_RIGHT,
+ e8TH_FROM_FRONT_LEFT,
+ e8TH_FROM_FRONT_RIGHT,
+ e9TH_FROM_FRONT_LEFT,
+ e9TH_FROM_FRONT_RIGHT
+ };
+};
+
+
+/**
+\brief The control inputs for a PxVehicleDriveTank.
+
+\note The values of eANALOG_INPUT_THRUST_LEFT and eANALOG_INPUT_THRUST_RIGHT determine how much
+of the total available drive torque is diverted to the left and right wheels. These entries in the
+enumerated list represent the state of the left and right control sticks of a tank. The total available
+drive torque available is controlled by eANALOG_INPUT_ACCEL, which represents the state of the acceleration
+pedal and controls how much torque will be applied to the engine.
+
+\note To accelerate forwards eANALOG_INPUT_ACCEL must be greater than zero so that torque is applied to drive the
+engine, while eANALOG_INPUT_THRUST_LEFT and eANALOG_INPUT_THRUST_RIGHT must also be greater than zero
+to divert the available drive torque to the left and wheels. If eANALOG_INPUT_THRUST_LEFT > eANALOG_INPUT_THRUST_RIGHT
+the tank will turn to the right. If eANALOG_INPUT_THRUST_RIGHT > eANALOG_INPUT_THRUST_LEFT
+the tank will turn to the left.
+
+@see PxVehicleDriveDynData::setAnalogInput, PxVehicleDriveDynData::getAnalogInput
+*/
+
+struct PxVehicleDriveTankControl
+{
+ enum Enum
+ {
+ eANALOG_INPUT_ACCEL=0,
+ eANALOG_INPUT_BRAKE_LEFT,
+ eANALOG_INPUT_BRAKE_RIGHT,
+ eANALOG_INPUT_THRUST_LEFT,
+ eANALOG_INPUT_THRUST_RIGHT,
+ eMAX_NB_DRIVETANK_ANALOG_INPUTS
+ };
+};
+
+/**
+\brief Two driving models are supported.
+
+\note If eSTANDARD is chosen the left and right wheels are always driven in the same direction. If the tank is in
+a forward gear the left and right wheels will all be driven forwards, while in reverse gear the left and right wheels
+will all be driven backwards. With eSTANDARD the legal range of left and right thrust is (0,1).
+
+\note If eSPECIAL is chosen it is possible to drive the left and right wheels in different directions.
+With eSPECIAL the legal range of left and right thrust is (-1,1). In forward(reverse) gear negative thrust values drive the wheels
+backwards(forwards), while positive thrust values drives the wheels forwards(backwards).
+
+\note A sharp left turn can be achieved in eSTANDARD mode by braking with the left wheels and thrusting forward with the
+right wheels. A smaller turning circle can theoretically be achieved in eSPECIAL mode by applying negative thrust to the left wheels and positive
+thrust to the right wheels.
+
+\note In both modes the legal ranges of acceleration and left/right brake are all (0,1).
+
+@see PxVehicleDriveTank::setDriveModel
+*/
+struct PxVehicleDriveTankControlModel
+{
+ enum Enum
+ {
+ eSTANDARD=0,
+ eSPECIAL
+ };
+};
+
+
+/**
+\brief Data structure with instanced dynamics data and configuration data of a tank.
+*/
+class PxVehicleDriveTank : public PxVehicleDrive
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleUpdate;
+
+
+ /**
+ \brief Allocate a PxVehicleTankDrive instance for a tank with nbWheels
+
+ \param[in] nbWheels is the number of wheels on the vehicle.
+
+ \note It is assumed that all wheels are driven wheels.
+
+ \return The instantiated vehicle.
+
+ @see free, setup
+ */
+ static PxVehicleDriveTank* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Deallocate a PxVehicleDriveTank instance.
+ @see allocate
+ */
+ void free();
+
+ /**
+ \brief Set up a tank using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the tank in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the tank. The tank instance takes a copy of this data.
+ \param[in] driveData describes the properties of the tank's drive model (gears/engine/clutch/autobox). The tank instance takes a copy of this data.
+ \param[in] nbDrivenWheels is the number of wheels on the tank.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ \note nbDrivenWheels must be an even number
+ \note The wheels must be arranged according to PxVehicleDriveTankWheelOrder; that is,
+ the even wheels are on the left side of the tank and the odd wheels are on the right side of the tank.
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData& driveData,
+ const PxU32 nbDrivenWheels);
+
+ /**
+ \brief Allocate and set up a tank using simulation data for the wheels and drive model.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the tank.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the tank in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the tank. The tank instance takes a copy of this data.
+ \param[in] driveData describes the properties of the tank's drive model (gears/engine/clutch/differential/autobox). The tank instance takes a copy of this data.
+ \param[in] nbDrivenWheels is the number of wheels on the tank.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping.
+ \return The instantiated vehicle.
+ @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping
+ */
+ static PxVehicleDriveTank* create
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData& driveData,
+ const PxU32 nbDrivenWheels);
+
+ /**
+ \brief Set the control model used by the tank.
+ \note eDRIVE_MODEL_STANDARD: turning achieved by braking on one side, accelerating on the other side.
+ \note eDRIVE_MODEL_SPECIAL: turning achieved by accelerating forwards on one side, accelerating backwards on the other side.
+ \note The default value is eDRIVE_MODEL_STANDARD
+ */
+ void setDriveModel(const PxVehicleDriveTankControlModel::Enum driveModel)
+ {
+ mDriveModel=driveModel;
+ }
+
+ /**
+ \brief Return the control model used by the tank.
+ */
+ PxVehicleDriveTankControlModel::Enum getDriveModel() const {return mDriveModel;}
+
+ /**
+ \brief Set a vehicle to its rest state. Aside from the rigid body transform, this will set the vehicle and rigid body
+ to the state they were in immediately after setup or create.
+ \note Calling setToRestState invalidates the cached raycast hit planes under each wheel meaning that suspension line
+ raycasts need to be performed at least once with PxVehicleSuspensionRaycasts before calling PxVehicleUpdates.
+ @see setup, create, PxVehicleSuspensionRaycasts, PxVehicleUpdates
+ */
+ void setToRestState();
+
+ /**
+ \brief Simulation data that models vehicle components
+ @see setup, create
+ */
+ PxVehicleDriveSimData mDriveSimData;
+
+private:
+ /**
+ \brief Test if the instanced dynamics and configuration data has legal values.
+ */
+ bool isValid() const;
+
+ /**
+ \brief Drive model
+ @see setDriveModel, getDriveModel, PxVehicleDriveTankControlModel
+ */
+ PxVehicleDriveTankControlModel::Enum mDriveModel;
+
+ PxU32 mPad[3];
+
+//serialization
+public:
+ PxVehicleDriveTank(PxBaseFlags baseFlags) : PxVehicleDrive(baseFlags) {}
+ static PxVehicleDriveTank* createObject(PxU8*& address, PxDeserializationContext& context);
+ static void getBinaryMetaData(PxOutputStream& stream);
+ virtual const char* getConcreteTypeName() const { return "PxVehicleDriveTank"; }
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleDriveTank", name) || PxBase::isKindOf(name); }
+protected:
+ PxVehicleDriveTank();
+ ~PxVehicleDriveTank(){}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveTank) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_DRIVE_TANK_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleNoDrive.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleNoDrive.h
new file mode 100644
index 00000000..69982da2
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleNoDrive.h
@@ -0,0 +1,216 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_NO_DRIVE_H
+#define PX_VEHICLE_NO_DRIVE_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleWheels.h"
+#include "vehicle/PxVehicleComponents.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxFilterData;
+class PxGeometry;
+class PxPhysics;
+class PxVehicleDrivableSurfaceToTireFrictionPairs;
+class PxShape;
+class PxMaterial;
+class PxRigidDynamic;
+
+/**
+\brief Data structure with instanced dynamics data and configuration data of a vehicle with no drive model.
+*/
+class PxVehicleNoDrive : public PxVehicleWheels
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Allocate a PxVehicleNoDrive instance for a vehicle without drive model and with nbWheels
+
+ \param[in] nbWheels is the number of wheels on the vehicle.
+
+ \return The instantiated vehicle.
+
+ @see free, setup
+ */
+ static PxVehicleNoDrive* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Deallocate a PxVehicleNoDrive instance.
+ @see allocate
+ */
+ void free();
+
+ /**
+ \brief Set up a vehicle using simulation data for the wheels.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheels::setWheelShapeMapping.
+ @see allocate, free, setToRestState, PxVehicleWheels::setWheelShapeMapping
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
+
+ /**
+ \brief Allocate and set up a vehicle using simulation data for the wheels.
+ \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle.
+ \param[in] vehActor is a PxRigidDynamic instance that is used to represent the vehicle in the PhysX SDK.
+ \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the vehicle. The vehicle instance takes a copy of this data.
+ \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheels::setWheelShapeMapping.
+ \return The instantiated vehicle.
+ @see allocate, free, setToRestState, PxVehicleWheels::setWheelShapeMapping
+ */
+ static PxVehicleNoDrive* create
+ (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
+
+ /**
+ \brief Set a vehicle to its rest state. Aside from the rigid body transform, this will set the vehicle and rigid body
+ to the state they were in immediately after setup or create.
+ \note Calling setToRestState invalidates the cached raycast hit planes under each wheel meaning that suspension line
+ raycasts need to be performed at least once with PxVehicleSuspensionRaycasts before calling PxVehicleUpdates.
+ @see setup, create, PxVehicleSuspensionRaycasts, PxVehicleUpdates
+ */
+ void setToRestState();
+
+ /**
+ \brief Set the brake torque to be applied to a specific wheel
+
+ \note The applied brakeTorque persists until the next call to setBrakeTorque
+
+ \note The brake torque is specified in Newton metres.
+
+ \param[in] id is the wheel being given the brake torque
+ \param[in] brakeTorque is the value of the brake torque
+ */
+ void setBrakeTorque(const PxU32 id, const PxReal brakeTorque);
+
+ /**
+ \brief Set the drive torque to be applied to a specific wheel
+
+ \note The applied driveTorque persists until the next call to setDriveTorque
+
+ \note The brake torque is specified in Newton metres.
+
+ \param[in] id is the wheel being given the brake torque
+ \param[in] driveTorque is the value of the brake torque
+ */
+ void setDriveTorque(const PxU32 id, const PxReal driveTorque);
+
+ /**
+ \brief Set the steer angle to be applied to a specific wheel
+
+ \note The applied steerAngle persists until the next call to setSteerAngle
+
+ \note The steer angle is specified in radians.
+
+ \param[in] id is the wheel being given the steer angle
+ \param[in] steerAngle is the value of the steer angle in radians.
+ */
+ void setSteerAngle(const PxU32 id, const PxReal steerAngle);
+
+ /**
+ \brief Get the brake torque that has been applied to a specific wheel
+ \param[in] id is the wheel being queried for its brake torque
+ \return The brake torque applied to the queried wheel.
+ */
+ PxReal getBrakeTorque(const PxU32 id) const;
+
+ /**
+ \brief Get the drive torque that has been applied to a specific wheel
+ \param[in] id is the wheel being queried for its drive torque
+ \return The drive torque applied to the queried wheel.
+ */
+ PxReal getDriveTorque(const PxU32 id) const;
+
+ /**
+ \brief Get the steer angle that has been applied to a specific wheel
+ \param[in] id is the wheel being queried for its steer angle
+ \return The steer angle (in radians) applied to the queried wheel.
+ */
+ PxReal getSteerAngle(const PxU32 id) const;
+
+private:
+
+ PxReal* mSteerAngles;
+ PxReal* mDriveTorques;
+ PxReal* mBrakeTorques;
+
+#if PX_P64_FAMILY
+ PxU32 mPad[2];
+#else
+ PxU32 mPad[1];
+#endif
+
+ /**
+ \brief Test if the instanced dynamics and configuration data has legal values.
+ */
+ bool isValid() const;
+
+
+//serialization
+public:
+ PxVehicleNoDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags) {}
+ virtual void exportExtraData(PxSerializationContext&);
+ void importExtraData(PxDeserializationContext&);
+ static PxVehicleNoDrive* createObject(PxU8*& address, PxDeserializationContext& context);
+ static void getBinaryMetaData(PxOutputStream& stream);
+ virtual const char* getConcreteTypeName() const { return "PxVehicleNoDrive"; }
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleNoDrive", name) || PxBase::isKindOf(name); }
+ PxU32 getNbSteerAngle() const { return mWheelsSimData.getNbWheels(); }
+ PxU32 getNbDriveTorque() const { return mWheelsSimData.getNbWheels(); }
+ PxU32 getNbBrakeTorque() const { return mWheelsSimData.getNbWheels(); }
+protected:
+ PxVehicleNoDrive();
+ ~PxVehicleNoDrive() {}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleNoDrive) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_NO_DRIVE_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleSDK.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleSDK.h
new file mode 100644
index 00000000..d47aa543
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleSDK.h
@@ -0,0 +1,237 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_SDK_H
+#define PX_VEHICLE_SDK_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/Px.h"
+#include "common/PxTypeInfo.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxPhysics;
+class PxSerializationRegistry;
+
+/**
+\brief Initialize the PhysXVehicle library.
+
+Call this before using any of the vehicle functions.
+
+\param physics The PxPhysics instance.
+\param serializationRegistry PxSerializationRegistry instance, if NULL vehicle serialization is not supported.
+
+\note This function must be called after PxFoundation and PxPhysics instances have been created.
+\note If a PxSerializationRegistry instance is specified then PhysXVehicle is also dependent on PhysXExtensions.
+
+@see PxCloseVehicleSDK
+*/
+PX_C_EXPORT bool PX_CALL_CONV PxInitVehicleSDK(PxPhysics& physics, PxSerializationRegistry* serializationRegistry = NULL);
+
+
+/**
+\brief Shut down the PhysXVehicle library.
+
+Call this function as part of the physx shutdown process.
+
+\param serializationRegistry PxSerializationRegistry instance, if non-NULL must be the same as passed into PxInitVehicleSDK.
+
+\note This function must be called prior to shutdown of PxFoundation and PxPhysics.
+\note If the PxSerializationRegistry instance is specified this function must additionally be called prior to shutdown of PhysXExtensions.
+
+@see PxInitVehicleSDK
+*/
+PX_C_EXPORT void PX_CALL_CONV PxCloseVehicleSDK(PxSerializationRegistry* serializationRegistry = NULL);
+
+
+/**
+\brief This number is the maximum number of wheels allowed for a vehicle.
+*/
+#define PX_MAX_NB_WHEELS (20)
+
+
+/**
+\brief Compiler setting to enable recording of telemetry data
+
+@see PxVehicleUpdateSingleVehicleAndStoreTelemetryData, PxVehicleTelemetryData
+*/
+#define PX_DEBUG_VEHICLE_ON (1)
+
+
+/**
+@see PxVehicleDrive4W, PxVehicleDriveTank, PxVehicleDriveNW, PxVehicleNoDrive, PxVehicleWheels::getVehicleType
+*/
+struct PxVehicleTypes
+{
+ enum Enum
+ {
+ eDRIVE4W=0,
+ eDRIVENW,
+ eDRIVETANK,
+ eNODRIVE,
+ eUSER1,
+ eUSER2,
+ eUSER3,
+ eMAX_NB_VEHICLE_TYPES
+ };
+};
+
+
+/**
+\brief An enumeration of concrete vehicle classes inheriting from PxBase.
+\note This enum can be used to identify a vehicle object stored in a PxCollection.
+@see PxBase, PxTypeInfo, PxBase::getConcreteType
+*/
+struct PxVehicleConcreteType
+{
+ enum Enum
+ {
+ eVehicleNoDrive = PxConcreteType::eFIRST_VEHICLE_EXTENSION,
+ eVehicleDrive4W,
+ eVehicleDriveNW,
+ eVehicleDriveTank
+ };
+};
+
+
+/**
+\brief Set the basis vectors of the vehicle simulation
+
+Default values PxVec3(0,1,0), PxVec3(0,0,1)
+
+Call this function before using PxVehicleUpdates unless the default values are correct.
+*/
+void PxVehicleSetBasisVectors(const PxVec3& up, const PxVec3& forward);
+
+
+/**
+@see PxVehicleSetUpdateMode
+*/
+struct PxVehicleUpdateMode
+{
+ enum Enum
+ {
+ eVELOCITY_CHANGE,
+ eACCELERATION
+ };
+};
+
+
+/**
+\brief Set the effect of PxVehicleUpdates to be either to modify each vehicle's rigid body actor
+
+with an acceleration to be applied in the next PhysX SDK update or as an immediate velocity modification.
+
+Default behavior is immediate velocity modification.
+
+Call this function before using PxVehicleUpdates for the first time if the default is not the desired behavior.
+
+@see PxVehicleUpdates
+*/
+void PxVehicleSetUpdateMode(PxVehicleUpdateMode::Enum vehicleUpdateMode);
+
+/**
+
+\brief Set threshold angles that are used to determine if a wheel hit is to be resolved by vehicle suspension or by rigid body collision.
+
+
+\note ^
+ N ___
+ |**
+ **
+ **
+ %%% %%% **
+ %%% %%% ** /
+ /
+ %%% %%% /
+ /
+ %%% %%% /
+ C /
+ %%% | ** %%% /
+ | ** /
+ %%% | **%%%/
+ | X**
+ %%% | %%% / **_| ^
+ | / D
+ %%% | %%% /
+ | /
+ | /
+ | /
+ |
+ ^ |
+ S \|/
+
+The diagram above depicts a wheel centered at "C" that has hit an inclined plane at point "X".
+The inclined plane has unit normal "N", while the suspension direction has unit vector "S".
+The unit vector from the wheel center to the hit point is "D".
+Hit points are analyzed by comparing the unit vectors D and N with the suspension direction S.
+This analysis is performed in the contact modification callback PxVehicleModifyWheelContacts (when enabled) and in
+PxVehicleUpdates (when non-blocking sweeps are enabled).
+If the angle between D and S is less than pointRejectAngle the hit is accepted by the suspension in PxVehicleUpdates and rejected
+by the contact modification callback PxVehicleModifyWheelContacts.
+If the angle between -N and S is less than normalRejectAngle the hit is accepted by the suspension in PxVehicleUpdates and rejected
+by the contact modification callback PxVehicleModifyWheelContacts.
+
+\param pointRejectAngle is the threshold angle used when comparing the angle between D and S.
+
+\param normalRejectAngle is the threshold angle used when comparing the angle between -N and S.
+
+\note PxVehicleUpdates ignores the rejection angles for raycasts and for sweeps that return blocking hits.
+
+\note Both angles have default values of Pi/4.
+
+@see PxVehicleSuspensionSweeps, PxVehicleModifyWheelContacts
+*/
+void PxVehicleSetSweepHitRejectionAngles(const PxF32 pointRejectAngle, const PxF32 normalRejectAngle);
+
+
+/**
+\brief Determine the maximum acceleration experienced by PxRigidDynamic instances that are found to be in contact
+with a wheel.
+
+\note Newton's Third Law states that every force has an equal and opposite force. As a consequence, forces applied to
+the suspension must be applied to dynamic objects that lie under the wheel. This can lead to instabilities, particularly
+when a heavy wheel is driving on a light object. The value of maxHitActorAcceleration clamps the applied force so that it never
+generates an acceleration greater than the specified value.
+
+\note Default value of maxHitActorAcceleration is PX_MAX_REAL
+*/
+void PxVehicleSetMaxHitActorAcceleration(const PxF32 maxHitActorAcceleration);
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_SDK_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleShaders.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleShaders.h
new file mode 100644
index 00000000..18d92440
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleShaders.h
@@ -0,0 +1,79 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_SHADERS_H
+#define PX_VEHICLE_SHADERS_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/PxSimpleTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Prototype of shader function that is used to compute wheel torque and tire forces.
+\param[in] shaderData is the shader data for the tire being processed. The shader data describes the tire data in the format required by the tire model that is implemented by the shader function.
+\param[in] tireFriction is the value of friction for the contact between the tire and the ground.
+\param[in] longSlip is the value of longitudinal slip experienced by the tire.
+\param[in] latSlip is the value of lateral slip experienced by the tire.
+\param[in] camber is the camber angle of the tire in radians.
+\param[in] wheelOmega is the rotational speed of the wheel.
+\param[in] wheelRadius is the distance from the tire surface to the center of the wheel.
+\param[in] recipWheelRadius is the reciprocal of wheelRadius.
+\param[in] restTireLoad is the load force experienced by the tire when the vehicle is at rest.
+\param[in] normalisedTireLoad is a pre-computed value equal to the load force on the tire divided by restTireLoad.
+\param[in] tireLoad is the load force currently experienced by the tire (= restTireLoad*normalisedTireLoad)
+\param[in] gravity is the magnitude of gravitational acceleration.
+\param[in] recipGravity is the reciprocal of the magnitude of gravitational acceleration.
+\param[out] wheelTorque is the torque that is to be applied to the wheel around the wheel's axle.
+\param[out] tireLongForceMag is the magnitude of the longitudinal tire force to be applied to the vehicle's rigid body.
+\param[out] tireLatForceMag is the magnitude of the lateral tire force to be applied to the vehicle's rigid body.
+\param[out] tireAlignMoment is the aligning moment of the tire that is to be applied to the vehicle's rigid body (not currently used).
+@see PxVehicleWheelsDynData::setTireForceShaderFunction, PxVehicleWheelsDynData::setTireForceShaderData
+*/
+typedef void (*PxVehicleComputeTireForce)
+(const void* shaderData,
+ const PxF32 tireFriction,
+ const PxF32 longSlip, const PxF32 latSlip, const PxF32 camber,
+ const PxF32 wheelOmega, const PxF32 wheelRadius, const PxF32 recipWheelRadius,
+ const PxF32 restTireLoad, const PxF32 normalisedTireLoad, const PxF32 tireLoad,
+ const PxF32 gravity, const PxF32 recipGravity,
+ PxF32& wheelTorque, PxF32& tireLongForceMag, PxF32& tireLatForceMag, PxF32& tireAlignMoment);
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_SHADERS_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleTireFriction.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleTireFriction.h
new file mode 100644
index 00000000..cdc8ca75
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleTireFriction.h
@@ -0,0 +1,223 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_TIREFRICTION_H
+#define PX_VEHICLE_TIREFRICTION_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/PxSimpleTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxMaterial;
+
+/**
+\brief Driving surface type. Each PxMaterial is associated with a corresponding PxVehicleDrivableSurfaceType.
+@see PxMaterial, PxVehicleDrivableSurfaceToTireFrictionPairs
+*/
+struct PxVehicleDrivableSurfaceType
+{
+ enum
+ {
+ eSURFACE_TYPE_UNKNOWN=0xffffffff
+ };
+ PxU32 mType;
+};
+
+/**
+\brief Friction for each combination of driving surface type and tire type.
+@see PxVehicleDrivableSurfaceType, PxVehicleTireData::mType
+*/
+class PxVehicleDrivableSurfaceToTireFrictionPairs
+{
+public:
+
+ friend class VehicleSurfaceTypeHashTable;
+
+ enum
+ {
+ eMAX_NB_SURFACE_TYPES=256
+ };
+
+ /**
+ \brief Allocate the memory for a PxVehicleDrivableSurfaceToTireFrictionPairs instance
+ that can hold data for combinations of tire type and surface type with up to maxNbTireTypes types of tire and maxNbSurfaceTypes types of surface.
+
+ \param[in] maxNbTireTypes is the maximum number of allowed tire types.
+ \param[in] maxNbSurfaceTypes is the maximum number of allowed surface types. Must be less than or equal to eMAX_NB_SURFACE_TYPES
+
+ \return a PxVehicleDrivableSurfaceToTireFrictionPairs instance that can be reused later with new type and friction data.
+
+ @see setup
+ */
+ static PxVehicleDrivableSurfaceToTireFrictionPairs* allocate
+ (const PxU32 maxNbTireTypes, const PxU32 maxNbSurfaceTypes);
+
+ /**
+ \brief Set up a PxVehicleDrivableSurfaceToTireFrictionPairs instance for combinations of nbTireTypes tire types and nbSurfaceTypes surface types.
+
+ \param[in] nbTireTypes is the number of different types of tire. This value must be less than or equal to maxNbTireTypes specified in allocate().
+ \param[in] nbSurfaceTypes is the number of different types of surface. This value must be less than or equal to maxNbSurfaceTypes specified in allocate().
+ \param[in] drivableSurfaceMaterials is an array of PxMaterial pointers of length nbSurfaceTypes.
+ \param[in] drivableSurfaceTypes is an array of PxVehicleDrivableSurfaceType instances of length nbSurfaceTypes.
+
+ \note If the pointer to the PxMaterial that touches the tire is found in drivableSurfaceMaterials[x] then the surface type is drivableSurfaceTypes[x].mType
+ and the friction is the value that is set with setTypePairFriction(drivableSurfaceTypes[x].mType, PxVehicleTireData::mType, frictionValue).
+
+ \note A friction value of 1.0 will be assigned as default to each combination of tire and surface type. To override this use setTypePairFriction.
+ @see release, setTypePairFriction, getTypePairFriction, PxVehicleTireData.mType
+ */
+ void setup
+ (const PxU32 nbTireTypes, const PxU32 nbSurfaceTypes,
+ const PxMaterial** drivableSurfaceMaterials, const PxVehicleDrivableSurfaceType* drivableSurfaceTypes);
+
+ /**
+ \brief Deallocate a PxVehicleDrivableSurfaceToTireFrictionPairs instance
+ */
+ void release();
+
+ /**
+ \brief Set the friction for a specified pair of tire type and drivable surface type.
+
+ \param[in] surfaceType describes the surface type
+ \param[in] tireType describes the tire type.
+ \param[in] value describes the friction coefficient for the combination of surface type and tire type.
+ */
+ void setTypePairFriction(const PxU32 surfaceType, const PxU32 tireType, const PxReal value);
+
+ /**
+ \brief Return the friction for a specified combination of surface type and tire type.
+ \return The friction for a specified combination of surface type and tire type.
+ \note The final friction value used by the tire model is the value returned by getTypePairFriction
+ multiplied by the value computed from PxVehicleTireData::mFrictionVsSlipGraph
+ @see PxVehicleTireData::mFrictionVsSlipGraph
+ */
+ PxReal getTypePairFriction(const PxU32 surfaceType, const PxU32 tireType) const;
+
+ /**
+ \brief Return the maximum number of surface types
+ \return The maximum number of surface types
+ @see allocate
+ */
+ PxU32 getMaxNbSurfaceTypes() const {return mMaxNbSurfaceTypes;}
+
+ /**
+ \brief Return the maximum number of tire types
+ \return The maximum number of tire types
+ @see allocate
+ */
+ PxU32 getMaxNbTireTypes() const {return mMaxNbTireTypes;}
+
+private:
+
+ /**
+ \brief Ptr to base address of a 2d PxReal array with dimensions [mNbSurfaceTypes][mNbTireTypes]
+
+ \note Each element of the array describes the maximum friction provided by a surface type-tire type combination.
+ eg the friction corresponding to a combination of surface type x and tire type y is mPairs[x][y]
+ */
+ PxReal* mPairs;
+
+ /**
+ \brief Ptr to 1d array of material ptrs that is of length mNbSurfaceTypes.
+
+ \note If the PxMaterial that touches the tire corresponds to mDrivableSurfaceMaterials[x] then the drivable surface
+ type is mDrivableSurfaceTypes[x].mType and the friction for that contact is mPairs[mDrivableSurfaceTypes[x].mType][y],
+ assuming a tire type y.
+
+ \note If the PxMaterial that touches the tire is not found in mDrivableSurfaceMaterials then the friction is
+ mPairs[0][y], assuming a tire type y.
+ */
+ const PxMaterial** mDrivableSurfaceMaterials;
+
+ /**
+ \brief Ptr to 1d array of PxVehicleDrivableSurfaceType that is of length mNbSurfaceTypes.
+
+ \note If the PxMaterial that touches the tire is found in mDrivableSurfaceMaterials[x] then the drivable surface
+ type is mDrivableSurfaceTypes[x].mType and the friction for that contact is mPairs[mDrivableSurfaceTypes[x].mType][y],
+ assuming a tire type y.
+
+ \note If the PxMaterial that touches the tire is not found in mDrivableSurfaceMaterials then the friction is
+ mPairs[0][y], assuming a tire type y.
+ */
+ PxVehicleDrivableSurfaceType* mDrivableSurfaceTypes;
+
+ /**
+ \brief Number of different driving surface types.
+
+ \note mDrivableSurfaceMaterials and mDrivableSurfaceTypes are both 1d arrays of length mMaxNbSurfaceTypes.
+
+ \note mNbSurfaceTypes must be less than or equal to mMaxNbSurfaceTypes.
+ */
+ PxU32 mNbSurfaceTypes;
+
+ /**
+ \brief Maximum number of different driving surface types.
+
+ \note mMaxNbSurfaceTypes must be less than or equal to eMAX_NB_SURFACE_TYPES.
+ */
+ PxU32 mMaxNbSurfaceTypes;
+
+ /**
+ \brief Number of different tire types.
+
+ \note Tire types stored in PxVehicleTireData.mType
+ */
+ PxU32 mNbTireTypes;
+
+ /**
+ \brief Maximum number of different tire types.
+
+ \note Tire types stored in PxVehicleTireData.mType
+ */
+ PxU32 mMaxNbTireTypes;
+
+
+#if !PX_P64_FAMILY
+ PxU32 mPad[1];
+#else
+ PxU32 mPad[2];
+#endif
+
+ PxVehicleDrivableSurfaceToTireFrictionPairs(){}
+ ~PxVehicleDrivableSurfaceToTireFrictionPairs(){}
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrivableSurfaceToTireFrictionPairs) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_TIREFRICTION_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleUpdate.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleUpdate.h
new file mode 100644
index 00000000..40306fdc
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleUpdate.h
@@ -0,0 +1,581 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_UPDATE_H
+#define PX_VEHICLE_UPDATE_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "vehicle/PxVehicleSDK.h"
+#include "vehicle/PxVehicleTireFriction.h"
+#include "foundation/PxSimpleTypes.h"
+#include "foundation/PxMemory.h"
+#include "foundation/PxTransform.h"
+#include "PxBatchQueryDesc.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+ class PxBatchQuery;
+ class PxContactModifyPair;
+ class PxVehicleWheels;
+ class PxVehicleDrivableSurfaceToTireFrictionPairs;
+ class PxVehicleTelemetryData;
+
+ /**
+ \brief Structure containing data describing the non-persistent state of each suspension/wheel/tire unit.
+ This structure is filled out in PxVehicleUpdates and PxVehicleUpdateSingleVehicleAndStoreTelemetryData
+ @see PxVehicleUpdates, PxVehicleUpdateSingleVehicleAndStoreTelemetryData
+ */
+ struct PxWheelQueryResult
+ {
+ PxWheelQueryResult()
+ {
+ PxMemZero(this, sizeof(PxWheelQueryResult));
+ isInAir=true;
+ tireSurfaceType = PxU32(PxVehicleDrivableSurfaceType::eSURFACE_TYPE_UNKNOWN);
+ localPose = PxTransform(PxIdentity);
+ }
+
+ /**
+ \brief Start point of suspension line raycast/sweep used in the raycast/sweep completed immediately before PxVehicleUpdates.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then (0,0,0) is stored.
+ @see PxVehicleSuspensionRaycasts, PxVehicleSuspensionRaycasts
+ */
+ PxVec3 suspLineStart;
+
+ /**
+ \brief Directions of suspension line raycast/sweep used in the raycast/sweep completed immediately before PxVehicleUpdates.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then (0,0,0) is stored.
+ @see PxVehicleSuspensionRaycasts, PxVehicleSuspensionRaycasts
+ */
+ PxVec3 suspLineDir;
+
+ /**
+ \brief Lengths of suspension line raycast/sweep used in raycast/sweep completed immediately before PxVehicleUpdates.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then 0 is stored.
+ @see PxVehicleSuspensionRaycasts, PxVehicleSuspensionRaycasts
+ */
+ PxReal suspLineLength;
+
+ /**
+ \brief If suspension travel limits forbid the wheel from touching the drivable surface then isInAir is true.
+ \note If the wheel can be placed on the contact plane of the most recent suspension line raycast/sweep then isInAir is false.
+ \note If #PxVehicleWheelsSimFlag::eLIMIT_SUSPENSION_EXPANSION_VELOCITY is set, then isInAir will also be true if the suspension
+ force is not large enough to expand to the target length in the given simulation time step.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then isInAir
+ is computed using the contact plane that was hit by the most recent suspension line raycast/sweep.
+ */
+ bool isInAir;
+
+ /**
+ \brief PxActor instance of the driving surface under the corresponding vehicle wheel.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireContactActor is NULL.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then NULL is stored.
+ */
+ PxActor* tireContactActor;
+
+ /**
+ \brief PxShape instance of the driving surface under the corresponding vehicle wheel.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireContactShape is NULL.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then NULL is stored.
+ */
+ PxShape* tireContactShape;
+
+ /**
+ \brief PxMaterial instance of the driving surface under the corresponding vehicle wheel.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireSurfaceMaterial is NULL.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then NULL is stored.
+ */
+ const PxMaterial* tireSurfaceMaterial;
+
+ /**
+ \brief Surface type integer that corresponds to the mapping between tireSurfaceMaterial and integer as
+ described in PxVehicleDrivableSurfaceToTireFrictionPairs.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireSurfaceType is
+ PxVehicleDrivableSurfaceType::eSURFACE_TYPE_UNKNOWN.
+ \note If no raycast/sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then
+ PxVehicleDrivableSurfaceType::eSURFACE_TYPE_UNKNOWN is stored.
+ @see PxVehicleDrivableSurfaceToTireFrictionPairs
+ */
+ PxU32 tireSurfaceType;
+
+ /**
+ \brief Point on the drivable surface hit by the most recent suspension raycast or sweep.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then the contact point is (0,0,0).
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then (0,0,0) is stored.
+ */
+ PxVec3 tireContactPoint;
+
+ /**
+ \brief Normal on the drivable surface at the hit point of the most recent suspension raycast or sweep.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then the contact normal is (0,0,0).
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then (0,0,0) is stored.
+ */
+ PxVec3 tireContactNormal;
+
+ /**
+ \brief Friction experienced by the tire for the combination of tire type and surface type after accounting
+ for the friction vs slip graph.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then the tire friction is 0.
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ stored tire friction is the value computed in PxVehicleUpdates that immediately followed the last raycast or sweep.
+ @see PxVehicleDrivableSurfaceToTireFrictionPairs, PxVehicleTireData
+ */
+ PxReal tireFriction;
+
+ /**
+ \brief Compression of the suspension spring.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then the jounce is -PxVehicleSuspensionData.mMaxDroop
+ The jounce can never exceed PxVehicleSuspensionData.mMaxCompression. Positive values result when the suspension is compressed from
+ the rest position, while negative values mean the suspension is elongated from the rest position.
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ suspension compression is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ */
+ PxReal suspJounce;
+
+ /**
+ \brief Magnitude of force applied by the suspension spring along the direction of suspension travel.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then the force is 0
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ suspension spring force is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ @see PxVehicleWheelsSimData::getSuspTravelDirection
+ */
+ PxReal suspSpringForce;
+
+ /**
+ \brief Forward direction of the wheel/tire accounting for steer/toe/camber angle projected on to the contact plane of the drivable surface.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireLongitudinalDir is (0,0,0)
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ tire longitudinal direction is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ */
+ PxVec3 tireLongitudinalDir;
+
+ /**
+ \brief Lateral direction of the wheel/tire accounting for steer/toe/camber angle projected on to the contact plan of the drivable surface.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then tireLateralDir is (0,0,0)
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ tire lateral direction is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ */
+ PxVec3 tireLateralDir;
+
+ /**
+ \brief Longitudinal slip of the tire.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then longitudinalSlip is 0.0
+ \note The longitudinal slip is approximately (w*r - vz) / PxAbs(vz) where w is the angular speed of the wheel, r is the radius of the wheel, and
+ vz component of rigid body velocity computed at the wheel base along the longitudinal direction of the tire.
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ tire longitudinal slip is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ */
+ PxReal longitudinalSlip;
+
+ /**
+ \brief Lateral slip of the tire.
+ \note If suspension travel limits forbid the wheel from touching the drivable surface then lateralSlip is 0.0
+ \note The lateral slip angle is approximately PxAtan(vx / PxAbs(vz)) where vx and vz are the components of rigid body velocity at the wheel base
+ along the wheel's lateral and longitudinal directions, respectively.
+ \note If no raycast or sweep for the corresponding suspension was performed immediately prior to PxVehicleUpdates then the
+ tire lateral slip is computed using the contact plane that was hit by the most recent suspension line raycast or sweep.
+ */
+ PxReal lateralSlip;
+
+ /**
+ \brief Steer angle of the wheel about the "up" vector accounting for input steer and toe and, if applicable, Ackermann steer correction.
+ @see PxVehicleWheelData::mToeAngle
+ */
+ PxReal steerAngle;
+
+ /**
+ \brief Local pose of the wheel.
+ */
+ PxTransform localPose;
+ };
+
+ struct PxVehicleWheelQueryResult
+ {
+ /**
+ \brief Pointer to an PxWheelQueryResult buffer of length nbWheelQueryResults
+ The wheelQueryResults buffer must persist until the end of PxVehicleUpdates
+ A NULL pointer is permitted.
+ The wheelQueryResults buffer is left unmodified in PxVehicleUpdates for vehicles with sleeping rigid bodies
+ whose control inputs indicate they should remain inert.
+ @see PxVehicleUpdates
+ */
+ PxWheelQueryResult* wheelQueryResults;
+
+ /**
+ \brief The length of the wheelQueryResults buffer. This value corresponds to the
+ number of wheels in the associated vehicle in PxVehicleUpdates.
+ */
+ PxU32 nbWheelQueryResults;
+ };
+
+ /**
+ \brief Structure containing data that is computed for a wheel during concurrent calls to PxVehicleUpdates
+ but which cannot be safely concurrently applied.
+
+ @see PxVehicleUpdates, PxVehiclePostUpdates, PxVehicleConcurrentUpdate
+ */
+ struct PxVehicleWheelConcurrentUpdateData
+ {
+ friend class PxVehicleUpdate;
+
+ PxVehicleWheelConcurrentUpdateData()
+ : localPose(PxTransform(PxIdentity)),
+ hitActor(NULL),
+ hitActorForce(PxVec3(0,0,0)),
+ hitActorForcePosition(PxVec3(0,0,0))
+ {
+ }
+
+ private:
+
+ PxTransform localPose;
+ PxRigidDynamic* hitActor;
+ PxVec3 hitActorForce;
+ PxVec3 hitActorForcePosition;
+ };
+
+ /**
+ \brief Structure containing data that is computed for a vehicle and its wheels during concurrent calls to PxVehicleUpdates
+ but which cannot be safely concurrently applied.
+
+ @see PxVehicleUpdates, PxVehiclePostUpdates, PxVehicleWheelConcurrentUpdateData
+ */
+
+ struct PxVehicleConcurrentUpdateData
+ {
+ friend class PxVehicleUpdate;
+
+ PxVehicleConcurrentUpdateData()
+ : concurrentWheelUpdates(NULL),
+ nbConcurrentWheelUpdates(0),
+ linearMomentumChange(PxVec3(0,0,0)),
+ angularMomentumChange(PxVec3(0,0,0)),
+ staySleeping(false),
+ wakeup(false)
+ {
+ }
+
+ /**
+ \brief Pointer to an PxVehicleWheelConcurrentUpdate buffer of length nbConcurrentWheelUpdates
+ The concurrentWheelUpdates buffer must persist until the end of PxVehiclePostUpdates
+ A NULL pointer is not permitted.
+ @see PxVehicleUpdates, PxVehiclePostUpdates
+ */
+ PxVehicleWheelConcurrentUpdateData* concurrentWheelUpdates;
+
+ /**
+ \brief The length of the concurrentWheelUpdates buffer. This value corresponds to the
+ number of wheels in the associated vehicle passed to PxVehicleUpdates.
+ */
+ PxU32 nbConcurrentWheelUpdates;
+
+ private:
+
+ PxVec3 linearMomentumChange;
+ PxVec3 angularMomentumChange;
+ bool staySleeping;
+ bool wakeup;
+ };
+
+ /**
+ \brief Perform raycasts for all suspension lines for all vehicles.
+
+ \param[in] batchQuery is a PxBatchQuery instance used to specify shader data and functions for the raycast scene queries.
+
+ \param[in] nbVehicles is the number of vehicles in the vehicles array.
+
+ \param[in] vehicles is an array of all vehicles that are to have a raycast issued from each wheel.
+
+ \param[in] nbSceneQueryResults must be greater than or equal to the total number of wheels of all the vehicles in the vehicles array; that is,
+ sceneQueryResults must have dimensions large enough for one raycast hit result per wheel for all the vehicles in the vehicles array.
+
+ \param[in] sceneQueryResults must persist without being overwritten until the end of the next PxVehicleUpdates call.
+
+ \param[in] vehiclesToRaycast is an array of bools of length nbVehicles that is used to decide if raycasts will be performed for the corresponding vehicle
+ in the vehicles array. If vehiclesToRaycast[i] is true then suspension line raycasts will be performed for vehicles[i]. If vehiclesToRaycast[i] is
+ false then suspension line raycasts will not be performed for vehicles[i].
+
+ \note If vehiclesToRaycast is NULL then raycasts are performed for all vehicles in the vehicles array.
+
+ \note If vehiclesToRaycast[i] is false then the vehicle stored in vehicles[i] will automatically use the raycast or sweep hit planes recorded by the most recent
+ suspension sweeps or raycasts for that vehicle. For vehicles far from the camera or not visible on the screen it can be
+ optimal to only perform suspension line raycasts every Nth update rather than every single update. The accuracy of the cached contact plane
+ naturally diminishes as N increase, meaning that wheels might start to hover or intersect the ground for large values of N or even with values close to 1 in
+ conjunction with large vehicle speeds and/or geometry that has low spatial coherence.
+
+ \note Calling setToRestState invalidates any cached hit planes. Prior to calling PxVehicleUpdates each vehicle needs to perform suspension line raycasts
+ or sweeps at least once after instantiation and at least once after calling setToRestState.
+
+ \note Each raycast casts along the suspension travel direction from the position of the top of the wheel at maximum suspension compression
+ to the position of the base of the wheel at maximum droop. Raycasts that start inside a PxShape are subsequently ignored by the
+ corresponding vehicle.
+
+ \note Only blocking hits are supported (PxQueryHitType::eBLOCK).
+
+ @see PxVehicleDrive4W::setToRestState, PxVehicleDriveNW::setToRestState, PxVehicleDriveTank::setToRestState, PxVehicleNoDrive::setToRestState
+ */
+ void PxVehicleSuspensionRaycasts
+ (PxBatchQuery* batchQuery,
+ const PxU32 nbVehicles, PxVehicleWheels** vehicles,
+ const PxU32 nbSceneQueryResults, PxRaycastQueryResult* sceneQueryResults,
+ const bool* vehiclesToRaycast = NULL);
+
+
+ /**
+ \brief Perform sweeps for all suspension lines for all vehicles.
+
+ \param[in] batchQuery is a PxBatchQuery instance used to specify shader data and functions for the sweep scene queries.
+
+ \param[in] nbVehicles is the number of vehicles in the vehicles array.
+
+ \param[in] vehicles is an array of all vehicles that are to have a sweep issued from each wheel.
+
+ \param[in] nbSceneQueryResults must be greater than or equal to the total number of wheels of all the vehicles in the vehicles array; that is,
+ sceneQueryResults must have dimensions large enough for one sweep hit result per wheel for all the vehicles in the vehicles array.
+
+ \param[in] sceneQueryResults must persist without being overwritten until the end of the next PxVehicleUpdates call.
+
+ \param[in] nbHitsPerQuery is the maximum numbers of hits that will be returned for each query.
+
+ \param[in] vehiclesToSweep is an array of bools of length nbVehicles that is used to decide if sweeps will be performed for the corresponding vehicle
+ in the vehicles array. If vehiclesToSweep[i] is true then suspension sweeps will be performed for vehicles[i]. If vehiclesToSweep[i] is
+ false then suspension sweeps will not be performed for vehicles[i].
+
+ \param[in] sweepWidthScale scales the geometry of the wheel used in the sweep. Values < 1 result in a thinner swept wheel, while values > 1 result in a fatter swept wheel.
+
+ \param[in] sweepRadiusScale scales the geometry of the wheel used in the sweep. Values < 1 result in a larger swept wheel, while values > 1 result in a smaller swept wheel.
+
+ \note If vehiclesToSweep is NULL then sweeps are performed for all vehicles in the vehicles array.
+
+ \note If vehiclesToSweep[i] is false then the vehicle stored in vehicles[i] will automatically use the most recent sweep or raycast hit planes
+ recorded by the most recent suspension sweeps or raycasts for that vehicle. For vehicles far from the camera or not visible on the screen it can be
+ optimal to only perform suspension queries every Nth update rather than every single update. The accuracy of the cached contact plane
+ naturally diminishes as N increase, meaning that wheels might start to hover or intersect the ground for large values of N or even with values close to 1 in
+ conjunction with large vehicle speeds and/or geometry that has low spatial coherence.
+
+ \note Calling setToRestState invalidates any cached hit planes. Prior to calling PxVehicleUpdates each vehicle needs to perform suspension raycasts
+ or sweeps at least once after instantiation and at least once after calling setToRestState.
+
+ \note Each sweep casts the wheel's shape along the suspension travel direction from the position of the top of the wheel at maximum suspension compression
+ to the position of the base of the wheel at maximum droop. Sweeps that start inside a PxShape are subsequently ignored by the
+ corresponding vehicle.
+
+ \note A scale can be applied to the shape so that a modified shape is swept through the scene. The parameters sweepWidthScale and sweepRadiusScale scale the
+ swept wheel shape in the width and radial directions. It is sometimes a good idea to sweep a thinner wheel to allow contact with other dynamic actors to be resolved
+ first before attempting to drive on them.
+
+ \note Blocking hits (PxQueryHitType::eBLOCK) and non-blocking hits (PxQueryHitType::TOUCH) are supported. If the pre-and post-filter functions of the PxBatchQuery
+ instance are set up to return blocking hits it is recommended to set nbHitsPerQuery = 1. If the filter functions returns touch hits then it is recommended to
+ set nbHitsPerQuery > 1. The exact value depends on the expected complexity of the geometry that lies under the wheel. For complex geometry, especially with dynamic
+ objects, it is recommended to use non-blocking hits. The vehicle update function will analyze all returned hits and choose the most appropriate using the thresholds
+ set in PxVehicleSetSweepHitRejectionAngles.
+
+ @see PxVehicleDrive4W::setToRestState, PxVehicleDriveNW::setToRestState, PxVehicleDriveTank::setToRestState, PxVehicleNoDrive::setToRestState
+
+ @see PxBatchQuery::sweep
+
+ @see PxVehicleSetSweepHitRejectionAngles
+ */
+ void PxVehicleSuspensionSweeps
+ (PxBatchQuery* batchQuery,
+ const PxU32 nbVehicles, PxVehicleWheels** vehicles,
+ const PxU32 nbSceneQueryResults, PxSweepQueryResult* sceneQueryResults, const PxU16 nbHitsPerQuery,
+ const bool* vehiclesToSweep = NULL,
+ const PxF32 sweepWidthScale = 1.0f, const PxF32 sweepRadiusScale = 1.0f);
+
+ /**
+ \brief A function called from PxContactModifyCallback::onContactModify. The function determines if rigid body contact points
+ recorded for the wheel's PxShape are likely to be duplicated and resolved by the wheel's suspension raycast. Contact points that will be
+ resolved by the suspension are ignored. Contact points that are accepted (rather than ignored) are modified to account for the effect of the
+ suspension geometry and the angular speed of the wheel.
+
+ \param[in] vehicle is a reference to the PxVehicleWheels instance that owns the wheel
+
+ \param[in] wheelId is the id of the wheel
+
+ \param[in] wheelTangentVelocityMultiplier determines the amount of wheel angular velocity that is used to modify the target relative velocity of the contact.
+ The target relative velocity is modified by adding a vector equal to the tangent velocity of the rotating wheel at the contact point and scaled by
+ wheelTangentVelocityMultiplier. The value of wheelTangentVelocityMultiplier is limited to the range (0,1). Higher values mimic higher values of friction
+ and tire load, while lower values mimic lower values of friction and tire load.
+
+ \param[in] maxImpulse determines the maximum impulse strength that the contacts can apply when a wheel is in contact with a PxRigidDynamic. This value is ignored for
+ contacts with PxRigidStatic instances.
+
+ \param[in,out] contactModifyPair describes the set of contacts involving the PxShape of the specified wheel and one other shape. The contacts in the contact set are
+ ignored or modified as required.
+
+ \note[in] Contact points are accepted or rejected using the threshold angles specified in the function PxVehicleSetSweepHitRejectionAngles.
+
+ \note If a contact point is not rejected it is modified to account for the wheel rotation speed.
+
+ \note Set maxImpulse to PX_MAX_F32 to allow any impulse value to be applied.
+
+ \note Reduce maxImpulse if the wheels are frequently colliding with light objects with mass much less than the vehicle's mass.
+ Reducing this value encourages numerical stability.
+
+ @see PxContactModifyCallback::onContactModify, PxVehicleSetSweepHitRejectionAngles
+ */
+ PxU32 PxVehicleModifyWheelContacts
+ (const PxVehicleWheels& vehicle, const PxU32 wheelId,
+ const PxF32 wheelTangentVelocityMultiplier, const PxReal maxImpulse,
+ PxContactModifyPair& contactModifyPair);
+
+
+ /**
+ \brief Update an array of vehicles by either applying an acceleration to the rigid body actor associated with
+ each vehicle or by an immediate update of the velocity of the actor.
+
+ \note The update mode (acceleration or velocity change) can be selected with PxVehicleSetUpdateMode.
+
+ \param[in] timestep is the timestep of the update
+
+ \param[in] gravity is the value of gravitational acceleration
+
+ \param[in] vehicleDrivableSurfaceToTireFrictionPairs describes the mapping between each PxMaterial ptr and an integer representing a
+ surface type. It also stores the friction value for each combination of surface and tire type.
+
+ \param[in] nbVehicles is the number of vehicles pointers in the vehicles array
+
+ \param[in,out] vehicles is an array of length nbVehicles containing all vehicles to be updated by the specified timestep
+
+ \param[out] vehicleWheelQueryResults is an array of length nbVehicles storing the wheel query results of each corresponding vehicle and wheel in the
+ vehicles array. A NULL pointer is permitted.
+
+ \param[out] vehicleConcurrentUpdates is an array of length nbVehicles. It is only necessary to specify vehicleConcurrentUpdates if PxVehicleUpdates is
+ called concurrently. The element vehicleWheelQueryResults[i] of the array stores data that is computed for vehicle[i] during PxVehicleUpdates but which
+ cannot be safely written when concurrently called. The data computed and stored in vehicleConcurrentUpdates must be passed to PxVehiclePostUpdates, where
+ it is applied to all relevant actors in sequence. A NULL pointer is permitted.
+
+ \note The vehicleWheelQueryResults buffer must persist until the end of PxVehicleUpdates.
+
+ \note The vehicleWheelQueryResults buffer is left unmodified for vehicles with sleeping rigid bodies whose control inputs indicate they should remain inert.
+
+ \note If PxVehicleUpdates is called concurrently then vehicleConcurrentUpdates must be specified. Do not specify vehicleConcurrentUpdates is PxVehicleUpdates
+ is not called concurrently.
+
+ \note The vehicleConcurrentUpdates buffer must persist until the end of PxVehiclePostUpdate.
+
+ \note If any vehicle has one or more disabled wheels (PxVehicleWheelsSimData::disableWheel) then the disabled wheels must not be associated
+ with a PxShape (PxVehicleWheelsSimData::setWheelShapeMapping); the differential of the vehicle must be configured so that no drive torque
+ is delivered to a disabled wheel; and the wheel must have zero rotation speed (PxVehicleWheelsDynData::setWheelRotationSpeed)
+
+ \note PxVehicleUpdates may be called concurrently provided all concurrent calls to PxVehicleUpdates involve only vehicles in the scene specified by PxVehicleUpdateSetScene.
+ PxVehicleUpdates must never run concurrently with PxVehicleUpdateSingleVehicleAndStoreTelemetryData.
+
+ @see PxVehicleSetUpdateMode, PxVehicleWheelsSimData::disableWheel, PxVehicleWheelsSimData::setWheelShapeMapping, PxVehicleWheelsDynData::setWheelRotationSpeed,
+ PxVehiclePostUpdates
+ */
+ void PxVehicleUpdates(
+ const PxReal timestep, const PxVec3& gravity,
+ const PxVehicleDrivableSurfaceToTireFrictionPairs& vehicleDrivableSurfaceToTireFrictionPairs,
+ const PxU32 nbVehicles, PxVehicleWheels** vehicles, PxVehicleWheelQueryResult* vehicleWheelQueryResults, PxVehicleConcurrentUpdateData* vehicleConcurrentUpdates = NULL);
+
+
+ /**
+ \brief Apply actor changes that were computed in concurrent calls to PxVehicleUpdates but which could not be safely applied due to the concurrency.
+
+ \param[in] vehicleConcurrentUpdates is an array of length nbVehicles where vehicleConcurrentUpdates[i] contains data describing actor changes that
+ were computed for vehicles[i] during concurrent calls to PxVehicleUpdates.
+
+ \param[in] nbVehicles is the number of vehicles pointers in the vehicles array
+
+ \param[in,out] vehicles is an array of length nbVehicles containing all vehicles that were partially updated in concurrent calls to PxVehicleUpdates.
+
+ @see PxVehicleUpdates
+ */
+ void PxVehiclePostUpdates(
+ const PxVehicleConcurrentUpdateData* vehicleConcurrentUpdates, const PxU32 nbVehicles, PxVehicleWheels** vehicles);
+
+
+ /**
+ \brief Shift the origin of vehicles by the specified vector.
+
+ Call this method to adjust the internal data structures of vehicles to reflect the shifted origin location
+ (the shift vector will get subtracted from all world space spatial data).
+
+ \note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from PhysXVehicle accordingly.
+
+ \note This call will not automatically shift the PhysX scene and its objects. You need to call PxScene::shiftOrigin() seperately to keep the systems in sync.
+
+ \param[in] shift is the translation vector to shift the origin by.
+
+ \param[in] nbVehicles is the number of vehicles in the vehicles array.
+
+ \param[in,out] vehicles is an array of all vehicles that should be updated to map to the new scene origin.
+ */
+ void PxVehicleShiftOrigin(const PxVec3& shift, const PxU32 nbVehicles, PxVehicleWheels** vehicles);
+
+#if PX_DEBUG_VEHICLE_ON
+ /**
+ \brief Update an single vehicle by either applying an acceleration to the rigid body actor associated with
+ each vehicle or by an immediate update of the velocity of the actor. Also record telemetry data from the
+ vehicle so that it may be visualized or queried.
+
+ \note The update mode (acceleration or velocity change) can be selected with PxVehicleSetUpdateMode.
+
+ \param[in] timestep is the timestep of the update
+
+ \param[in] gravity is the value of gravitational acceleration
+
+ \param[in] vehicleDrivableSurfaceToTireFrictionPairs describes the mapping between each PxMaterial ptr and an integer representing a
+ surface type. It also stores the friction value for each combination of surface and tire type.
+
+ \param[in,out] focusVehicle is the vehicle to be updated and have its telemetry data recorded
+
+ \param[out] vehicleWheelQueryResults is an array of length 1 storing the wheel query results of each wheel of the vehicle/
+ A NULL pointer is permitted.
+
+ \param[out] telemetryData is the data structure used to record telemetry data during the update for later query or visualization
+
+ \note The vehicleWheelQueryResults buffer must persist until the end of PxVehicleUpdates
+
+ \note The vehicleWheelQueryResults buffer is left unmodified for vehicles with sleeping rigid bodies whose control inputs indicate they should remain inert.
+
+ \note PxVehicleUpdateSingleVehicleAndStoreTelemetryData is not thread-safe. As a consequence, it must run sequentially and never concurrently with PxVehicleUpdates
+
+ @see PxVehicleSetUpdateMode, PxVehicleTelemetryData
+ */
+ void PxVehicleUpdateSingleVehicleAndStoreTelemetryData
+ (const PxReal timestep, const PxVec3& gravity,
+ const PxVehicleDrivableSurfaceToTireFrictionPairs& vehicleDrivableSurfaceToTireFrictionPairs,
+ PxVehicleWheels* focusVehicle, PxVehicleWheelQueryResult* vehicleWheelQueryResults,
+ PxVehicleTelemetryData& telemetryData);
+#endif
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_UPDATE_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleUtil.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleUtil.h
new file mode 100644
index 00000000..b2bfd2d2
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleUtil.h
@@ -0,0 +1,64 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_UTILHELPER_H
+#define PX_VEHICLE_UTILHELPER_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/Px.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+struct PxVehicleWheelQueryResult;
+
+/**
+\brief Test if all wheels of a vehicle are in the air by querying the wheel query data
+stored in the last call to PxVehicleUpdates. If all wheels are in the air then true is returned.
+
+\note False is returned if any wheel can reach to the ground.
+
+\note If vehWheelQueryResults.wheelQueryResults is NULL or vehWheelQueryResults.nbWheelQueryResults is 0 then true is returned.
+This function does not account for wheels that have been disabled since the last execution of PxVehicleUpdates so it is possible
+that wheels disabled more recently than the last call to PxVehicleUpdates report are treated as touching the ground.
+
+\return True if the vehicle is in the air, false if any wheel is touching the ground.
+*/
+bool PxVehicleIsInAir(const PxVehicleWheelQueryResult& vehWheelQueryResults);
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_UTILHELPER_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleUtilControl.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleUtilControl.h
new file mode 100644
index 00000000..62a86cff
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleUtilControl.h
@@ -0,0 +1,651 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_CONTROL_H
+#define PX_VEHICLE_CONTROL_H
+/** \addtogroup vehicle
+ @{
+*/
+#include "vehicle/PxVehicleSDK.h"
+#include "vehicle/PxVehicleDrive4W.h"
+#include "vehicle/PxVehicleDriveNW.h"
+#include "vehicle/PxVehicleDriveTank.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+#if PX_CHECKED
+ void testValidAnalogValue(const PxF32 actualValue, const PxF32 minVal, const PxF32 maxVal, const char* errorString);
+#endif
+
+/**
+\brief Used to produce smooth vehicle driving control values from key inputs.
+@see PxVehicle4WSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicle4WSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+struct PxVehicleKeySmoothingData
+{
+public:
+
+ /**
+ \brief Rise rate of each analog value if digital value is 1
+ */
+ PxReal mRiseRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+
+ /**
+ \brief Fall rate of each analog value if digital value is 0
+ */
+ PxReal mFallRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleKeySmoothingData)& 0x0f));
+
+/**
+\brief Used to produce smooth analog vehicle control values from analog inputs.
+@see PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+struct PxVehiclePadSmoothingData
+{
+public:
+
+ /**
+ \brief Rise rate of each analog value from previous value towards target if target>previous
+ */
+ PxReal mRiseRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+
+ /**
+ \brief Rise rate of each analog value from previous value towards target if target& steerVsForwardSpeedTable,
+ const PxVehicleDrive4WRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDrive4W& focusVehicle);
+
+/**
+\brief Used to smooth and set analog vehicle control values from analog inputs (gamepad).
+Also used to set boolean gearup, geardown values.
+\param[in] padSmoothing describes how quickly the control values applied to the vehicle blend from the current vehicle values towards the raw analog values from the gamepad.
+\param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+\param[in] rawInputData is the state of all gamepad analog inputs that will be used control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+\param[in] focusVehicle is the vehicle that will be given analog control values arising from the gamepad inputs.
+*/
+void PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs
+ (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDrive4WRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDrive4W& focusVehicle);
+
+
+/**
+\brief Used to produce smooth vehicle driving control values from analog and digital inputs.
+@see PxVehicleDriveNWSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDriveNWSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+class PxVehicleDriveNWRawInputData : public PxVehicleDrive4WRawInputData
+{
+public:
+
+ PxVehicleDriveNWRawInputData() : PxVehicleDrive4WRawInputData(){}
+ ~PxVehicleDriveNWRawInputData(){}
+};
+
+/**
+\brief Used to smooth and set analog vehicle control values (accel,brake,handbrake,steer) from digital inputs (keyboard).
+ Also used to set boolean gearup, geardown values.
+ \param[in] keySmoothing describes the rise and fall rates of the corresponding analog values when keys are pressed on and off.
+ \param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+ \param[in] rawInputData is the state of all digital inputs that control the vehicle.
+ \param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+ \param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+ \param[in] focusVehicle is the vehicle that will be given analog and gearup/geardown control values arising from the digital inputs.
+*/
+void PxVehicleDriveNWSmoothDigitalRawInputsAndSetAnalogInputs
+ (const PxVehicleKeySmoothingData& keySmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDriveNWRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDriveNW& focusVehicle);
+
+/**
+\brief Used to smooth and set analog vehicle control values from analog inputs (gamepad).
+Also used to set boolean gearup, geardown values.
+\param[in] padSmoothing describes how quickly the control values applied to the vehicle blend from the current vehicle values towards the raw analog values from the gamepad.
+\param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+\param[in] rawInputData is the state of all gamepad analog inputs that will be used control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+\param[in] focusVehicle is the vehicle that will be given analog control values arising from the gamepad inputs.
+*/
+void PxVehicleDriveNWSmoothAnalogRawInputsAndSetAnalogInputs
+ (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDriveNWRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDriveNW& focusVehicle);
+
+
+/**
+\brief Used to produce smooth analog tank control values from analog and digital inputs.
+@see PxVehicleDriveTankSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDriveTankSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+class PxVehicleDriveTankRawInputData
+{
+public:
+
+ PxVehicleDriveTankRawInputData(const PxVehicleDriveTankControlModel::Enum mode)
+ : mMode(mode)
+ {
+ for(PxU32 i=0;iRange: (0,1)
+ */
+ PxReal mPosX;
+
+ /**
+ \brief y-coord of graph centre.
+ Range: (0,1)
+ */
+ PxReal mPosY;
+
+ /**
+ \brief x-extents of graph (from mPosX-0.5f*mSizeX to mPosX+0.5f*mSizeX).
+ Range: (0,1)
+ */
+ PxReal mSizeX;
+
+ /**
+ \brief y-extents of graph (from mPosY-0.5f*mSizeY to mPosY+0.5f*mSizeY).
+ Range: (0,1)
+ */
+ PxReal mSizeY;
+
+ /**
+ \brief Background color of graph.
+ */
+ PxVec3 mBackgroundColor;
+
+ /**
+ \brief Alpha value of background color.
+ */
+ PxReal mAlpha;
+
+private:
+
+ bool isValid() const;
+};
+
+struct PxVehicleGraphChannelDesc
+{
+public:
+
+ friend class PxVehicleGraph;
+
+ PxVehicleGraphChannelDesc();
+
+ /**
+ \brief Data values less than mMinY will be clamped at mMinY.
+ */
+ PxReal mMinY;
+
+ /**
+ \brief Data values greater than mMaxY will be clamped at mMaxY.
+ */
+ PxReal mMaxY;
+
+ /**
+ \brief Data values greater than mMidY will be drawn with color mColorHigh.
+ Data values less than mMidY will be drawn with color mColorLow.
+ */
+ PxReal mMidY;
+
+ /**
+ \brief Color used to render data values lower than mMidY.
+ */
+ PxVec3 mColorLow;
+
+ /**
+ \brief Color used to render data values greater than mMidY.
+ */
+ PxVec3 mColorHigh;
+
+ /**
+ \brief String to describe data channel.
+ */
+ char* mTitle;
+
+private:
+
+ bool isValid() const;
+};
+
+struct PxVehicleWheelGraphChannel
+{
+ enum Enum
+ {
+ eJOUNCE=0,
+ eSUSPFORCE,
+ eTIRELOAD,
+ eNORMALIZED_TIRELOAD,
+ eWHEEL_OMEGA,
+ eTIRE_FRICTION,
+ eTIRE_LONG_SLIP,
+ eNORM_TIRE_LONG_FORCE,
+ eTIRE_LAT_SLIP,
+ eNORM_TIRE_LAT_FORCE,
+ eNORM_TIRE_ALIGNING_MOMENT,
+ eMAX_NB_WHEEL_CHANNELS
+ };
+};
+
+struct PxVehicleDriveGraphChannel
+{
+ enum Enum
+ {
+ eENGINE_REVS=0,
+ eENGINE_DRIVE_TORQUE,
+ eCLUTCH_SLIP,
+ eACCEL_CONTROL, //TANK_ACCEL
+ eBRAKE_CONTROL, //TANK_BRAKE_LEFT
+ eHANDBRAKE_CONTROL, //TANK_BRAKE_RIGHT
+ eSTEER_LEFT_CONTROL, //TANK_THRUST_LEFT
+ eSTEER_RIGHT_CONTROL, //TANK_THRUST_RIGHT
+ eGEAR_RATIO,
+ eMAX_NB_DRIVE_CHANNELS
+ };
+};
+
+struct PxVehicleGraphType
+{
+ enum Enum
+ {
+ eWHEEL=0,
+ eDRIVE
+ };
+};
+
+
+class PxVehicleGraph
+{
+public:
+
+ friend class PxVehicleTelemetryData;
+ friend class PxVehicleUpdate;
+
+ enum
+ {
+ eMAX_NB_SAMPLES=256
+ };
+
+ enum
+ {
+ eMAX_NB_TITLE_CHARS=256
+ };
+
+ enum
+ {
+ eMAX_NB_CHANNELS=12
+ };
+
+ /**
+ \brief Setup a graph from a descriptor.
+ */
+ void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
+
+ /**
+ \brief Clear all data recorded in a graph.
+ */
+ void clearRecordedChannelData();
+
+ /**
+ \brief Get the color of the graph background. Used for rendering a graph.
+ */
+ const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
+
+ /**
+ \brief Get the alpha transparency of the color of the graph background. Used for rendering a graph.
+ */
+ PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
+
+ /**
+ \brief Get the coordinates of the graph background. Used for rendering a graph
+
+ \param[out] xMin is the x-coord of the lower-left corner
+ \param[out] yMin is the y-coord of the lower-left corner
+ \param[out] xMax is the x-coord of the upper-right corner
+ \param[out] yMax is the y-coord of the upper-right corner
+ */
+ void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
+
+ /**
+ \brief Compute the coordinates of the graph data of a specific graph channel.
+
+ \param[out] xy is an array of graph sample coordinates stored in order x0,y0,x1,y1,x2,y2...xn,yn.
+ \param[out] colors stores the color of each point on the graph.
+ \param[out] title is the title of the graph.
+ */
+ void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
+
+ /**
+ \brief Return the latest value stored in the specified graph channel
+ */
+ PxF32 getLatestValue(const PxU32 channel) const ;
+
+private:
+
+ //Min and max of each sample.
+ PxReal mChannelMinY[eMAX_NB_CHANNELS];
+ PxReal mChannelMaxY[eMAX_NB_CHANNELS];
+ //Discriminate between high and low values with different colors.
+ PxReal mChannelMidY[eMAX_NB_CHANNELS];
+ //Different colors for values than midY and less than midY.
+ PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
+ PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
+ //Title of graph
+ char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
+ //Graph data.
+ PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
+
+ //Background color,alpha,coords
+ PxVec3 mBackgroundColor;
+ PxReal mBackgroundAlpha;
+ PxReal mBackgroundMinX;
+ PxReal mBackgroundMaxX;
+ PxReal mBackgroundMinY;
+ PxReal mBackgroundMaxY;
+
+ PxU32 mSampleTide;
+
+ PxU32 mNbChannels;
+
+ PxU32 mPad[2];
+
+
+ void setup
+ (const PxF32 graphSizeX, const PxF32 graphSizeY,
+ const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
+ const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
+ const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
+
+ void updateTimeSlice(const PxReal* const samples);
+
+ void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
+
+ void setupEngineGraph
+ (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
+ const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
+
+ void setupWheelGraph
+ (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
+ const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
+
+ PxVehicleGraph();
+ ~PxVehicleGraph();
+};
+PX_COMPILE_TIME_ASSERT(PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleWheelGraphChannel::eMAX_NB_WHEEL_CHANNELS) && PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleDriveGraphChannel::eMAX_NB_DRIVE_CHANNELS));
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
+
+class PxVehicleTelemetryData
+{
+public:
+
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Allocate a PxVehicleNWTelemetryData instance for a vehicle with nbWheels
+ @see PxVehicleNWTelemetryDataFree
+ */
+ static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Free a PxVehicleNWTelemetryData instance for a vehicle.
+ @see PxVehicleNWTelemetryDataAllocate
+ */
+ void free();
+
+ /**
+ \brief Set up all the graphs so that they are ready to record data.
+ */
+ void setup
+ (const PxReal graphSizeX, const PxReal graphSizeY,
+ const PxReal engineGraphPosX, const PxReal engineGraphPosY,
+ const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
+ const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
+
+ /**
+ \brief Clear the graphs of recorded data.
+ */
+ void clear();
+
+ /**
+ \brief Get the graph data for the engine
+ */
+ const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
+
+ /**
+ \brief Get the number of wheel graphs
+ */
+ PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
+
+ /**
+ \brief Get the graph data for the kth wheel
+ */
+ const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
+
+ /**
+ \brief Get the array of tire force application points so they can be rendered
+ */
+ const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
+
+ /**
+ \brief Get the array of susp force application points so they can be rendered
+ */
+ const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
+
+private:
+
+ /**
+ \brief Graph data for engine.
+ Used for storing single timeslices of debug data for engine graph.
+ @see PxVehicleGraph
+ */
+ PxVehicleGraph* mEngineGraph;
+
+ /**
+ \brief Graph data for each wheel.
+ Used for storing single timeslices of debug data for wheel graphs.
+ @see PxVehicleGraph
+ */
+ PxVehicleGraph* mWheelGraphs;
+
+ /**
+ \brief Application point of tire forces.
+ */
+ PxVec3* mTireforceAppPoints;
+
+ /**
+ \brief Application point of susp forces.
+ */
+ PxVec3* mSuspforceAppPoints;
+
+ /**
+ \brief Total number of active wheels
+ */
+ PxU32 mNbActiveWheels;
+
+ PxU32 mPad[3];
+
+private:
+
+ PxVehicleTelemetryData(){}
+ ~PxVehicleTelemetryData(){}
+};
+
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
+
+#endif //PX_DEBUG_VEHICLE_ON
+
+//#endif // PX_DEBUG_VEHICLE_ON
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_UTILSTELEMETRY_H
diff --git a/sources/PhysX/PhysX/include/vehicle/PxVehicleWheels.h b/sources/PhysX/PhysX/include/vehicle/PxVehicleWheels.h
new file mode 100644
index 00000000..322701c4
--- /dev/null
+++ b/sources/PhysX/PhysX/include/vehicle/PxVehicleWheels.h
@@ -0,0 +1,874 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+
+#ifndef PX_VEHICLE_WHEELS_H
+#define PX_VEHICLE_WHEELS_H
+/** \addtogroup vehicle
+ @{
+*/
+
+#include "foundation/PxSimpleTypes.h"
+#include "vehicle/PxVehicleShaders.h"
+#include "vehicle/PxVehicleComponents.h"
+#include "common/PxBase.h"
+#include "PxRigidDynamic.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxVehicleWheels4SimData;
+class PxVehicleWheels4DynData;
+class PxVehicleTireForceCalculator;
+class PxShape;
+class PxPhysics;
+class PxMaterial;
+
+/**
+\brief Flags to configure the vehicle wheel simulation.
+
+@see PxVehicleWheelsSimData::setFlags(), PxVehicleWheelsSimData::getFlags()
+*/
+struct PxVehicleWheelsSimFlag
+{
+ enum Enum
+ {
+ /**
+ \brief Limit the suspension expansion velocity.
+
+ For extreme damping ratios, large damping forces might result in the vehicle sticking to the ground where
+ one would rather expect to see the vehicle lift off. While it is highly recommended to use somewhat realistic
+ damping ratios, this flag can be used to limit the velocity of the suspension. In more detail, the simulation
+ will check whether the suspension can extend to the target length in the given simulation time step. If that
+ is the case, the suspension force will be computed as usual, else the force will be set to zero. Enabling
+ this feature gives a slightly more realisitic behavior at the potential cost of more easily losing control
+ when steering the vehicle.
+ */
+ eLIMIT_SUSPENSION_EXPANSION_VELOCITY = (1 << 0)
+ };
+};
+
+/**
+\brief Collection of set bits defined in #PxVehicleWheelsSimFlag.
+
+@see PxVehicleWheelsSimFlag
+*/
+typedef PxFlags PxVehicleWheelsSimFlags;
+PX_FLAGS_OPERATORS(PxVehicleWheelsSimFlag::Enum, PxU32)
+
+/**
+\brief Data structure describing configuration data of a vehicle with up to 20 wheels.
+*/
+
+class PxVehicleWheelsSimData
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleWheels;
+ friend class PxVehicleNoDrive;
+ friend class PxVehicleDrive4W;
+ friend class PxVehicleDriveTank;
+ friend class PxVehicleUpdate;
+
+ /**
+ \brief Allocate a PxVehicleWheelsSimData instance for with nbWheels.
+ @see free
+ */
+ static PxVehicleWheelsSimData* allocate(const PxU32 nbWheels);
+
+ /**
+ \brief Setup with mass information that can be applied to the default values of the suspensions, wheels, and tires
+ set in their respective constructors.
+
+ \param chassisMass is the mass of the chassis.
+
+ \note This function assumes that the suspensions equally share the load of the chassis mass. It also
+ assumes that the suspension will have a particular natural frequency and damping ratio that is typical
+ of a standard car. If either of these assumptions is broken then each suspension will need to
+ be individually configured with custom strength, damping rate, and sprung mass.
+
+ @see allocate
+ */
+ void setChassisMass(const PxF32 chassisMass);
+
+ /**
+ \brief Free a PxVehicleWheelsSimData instance
+ @see allocate
+ */
+ void free();
+
+ /**
+ \brief Copy wheel simulation data.
+ \note The number of wheels on both instances of PxVehicleWheelsSimData must match.
+ */
+ PxVehicleWheelsSimData& operator=(const PxVehicleWheelsSimData& src);
+
+ /**
+ \brief Copy the data of a single wheel unit (wheel, suspension, tire) from srcWheel of src to trgWheel.
+ \param[in] src is the data to be copied.
+ \param[in] srcWheel is the wheel whose data will be copied from src.
+ \param[in] trgWheel is the wheel that will be assigned the copied data.
+ */
+ void copy(const PxVehicleWheelsSimData& src, const PxU32 srcWheel, const PxU32 trgWheel);
+
+ /**
+ \brief Return the number of wheels
+ @see allocate
+ */
+ PxU32 getNbWheels() const {return mNbActiveWheels;}
+
+ /**
+ \brief Return the suspension data of the idth wheel
+ */
+ const PxVehicleSuspensionData& getSuspensionData(const PxU32 id) const;
+
+ /**
+ \brief Return the wheel data of the idth wheel
+ */
+ const PxVehicleWheelData& getWheelData(const PxU32 id) const;
+
+ /**
+ \brief Return the tire data of the idth wheel
+ */
+ const PxVehicleTireData& getTireData(const PxU32 id) const;
+
+ /**
+ \brief Return the direction of travel of the suspension of the idth wheel
+ */
+ const PxVec3& getSuspTravelDirection(const PxU32 id) const;
+
+ /**
+ \brief Return the application point of the suspension force of the suspension of the idth wheel as an offset from the rigid body center of mass.
+ \note Specified relative to the center of mass of the rigid body
+ */
+ const PxVec3& getSuspForceAppPointOffset(const PxU32 id) const;
+
+ /**
+ \brief Return the application point of the tire force of the tire of the idth wheel as an offset from the rigid body center of mass.
+ \note Specified relative to the centre of mass of the rigid body
+ */
+ const PxVec3& getTireForceAppPointOffset(const PxU32 id) const;
+
+ /**
+ \brief Return the offset from the rigid body centre of mass to the centre of the idth wheel.
+ */
+ const PxVec3& getWheelCentreOffset(const PxU32 id) const;
+
+ /**
+ \brief Return the wheel mapping for the ith wheel.
+
+ \note The return value is the element in the array of
+ shapes of the vehicle's PxRigidDynamic that corresponds to the ith wheel. A return value of -1 means
+ that the wheel is not mapped to a PxShape.
+
+ @see PxRigidActor.getShapes
+ */
+ PxI32 getWheelShapeMapping(const PxU32 wheelId) const;
+
+ /**
+ \brief Return the scene query filter data used by the specified suspension line
+ */
+ const PxFilterData& getSceneQueryFilterData(const PxU32 suspId) const;
+
+ /**
+ \brief Return the number of unique anti-roll bars that have been added with addAntiRollBarData
+ @see PxVehicleWheelsSimData::addAntiRollBarData
+ */
+ PxU32 getNbAntiRollBars() const
+ {
+ return mNbActiveAntiRollBars;
+ }
+
+ /**
+ \brief Return a specific anti-roll bar.
+ \param antiRollId is the unique id of the anti-roll bar
+ \note The return value of addAntiRollBarData is a unique id for that specific anti-roll bar
+ and can be used as input parameter for getAntiRollBarData in order to query the same anti-roll bar.
+ Alternatively, it is possible to iterate over all anti-roll bars by choosing antiRollId
+ in range (0, getNbAntiRollBars()).
+ */
+ const PxVehicleAntiRollBarData& getAntiRollBarData(const PxU32 antiRollId) const;
+
+ /**
+ \brief Return the data that describes the filtering of the tire load to produce smoother handling at large time-steps.
+ */
+ PX_FORCE_INLINE const PxVehicleTireLoadFilterData& getTireLoadFilterData() const
+ {
+ return mNormalisedLoadFilter;
+ }
+
+ /**
+ \brief Set the suspension data of the idth wheel
+ \param[in] id is the wheel index.
+ \param[in] susp is the suspension data to be applied.
+ */
+ void setSuspensionData(const PxU32 id, const PxVehicleSuspensionData& susp);
+
+ /**
+ \brief Set the wheel data of the idth wheel
+ \param[in] id is the wheel index.
+ \param[in] wheel is the wheel data to be applied.
+ */
+ void setWheelData(const PxU32 id, const PxVehicleWheelData& wheel);
+
+ /**
+ \brief Set the tire data of the idth wheel
+ \param[in] id is the wheel index.
+ \param[in] tire is the tire data to be applied.
+ */
+ void setTireData(const PxU32 id, const PxVehicleTireData& tire);
+
+ /**
+ \brief Set the direction of travel of the suspension of the idth wheel
+ \param[in] id is the wheel index
+ \param[in] dir is the suspension travel direction to be applied.
+ */
+ void setSuspTravelDirection(const PxU32 id, const PxVec3& dir);
+
+ /**
+ \brief Set the application point of the suspension force of the suspension of the idth wheel.
+ \param[in] id is the wheel index
+ \param[in] offset is the offset from the rigid body center of mass to the application point of the suspension force.
+ \note Specified relative to the centre of mass of the rigid body
+ */
+ void setSuspForceAppPointOffset(const PxU32 id, const PxVec3& offset);
+
+ /**
+ \brief Set the application point of the tire force of the tire of the idth wheel.
+ \param[in] id is the wheel index
+ \param[in] offset is the offset from the rigid body center of mass to the application point of the tire force.
+ \note Specified relative to the centre of mass of the rigid body
+ */
+ void setTireForceAppPointOffset(const PxU32 id, const PxVec3& offset);
+
+ /**
+ \brief Set the offset from the rigid body centre of mass to the centre of the idth wheel.
+ \param[in] id is the wheel index
+ \param[in] offset is the offset from the rigid body center of mass to the center of the wheel at rest.
+ \note Specified relative to the centre of mass of the rigid body
+ */
+ void setWheelCentreOffset(const PxU32 id, const PxVec3& offset);
+
+ /**
+ \brief Set mapping between wheel id and position of corresponding wheel shape in the list of actor shapes.
+
+ \note This mapping is used to pose the correct wheel shapes with the latest wheel rotation angle, steer angle, and suspension travel
+ while allowing arbitrary ordering of the wheel shapes in the actor's list of shapes.
+
+ \note Use setWheelShapeMapping(i,-1) to register that there is no wheel shape corresponding to the ith wheel
+
+ \note Set setWheelShapeMapping(i,k) to register that the ith wheel corresponds to the kth shape in the actor's list of shapes.
+
+ \note The default values correspond to setWheelShapeMapping(i,i) for all wheels.
+
+ \note Calling this function will also pose the relevant PxShape at the rest position of the wheel.
+
+ \param wheelId is the wheel index
+
+ \param shapeId is the shape index.
+
+ @see PxVehicleUpdates, PxVehicleDrive4W::setup, PxVehicleDriveTank::setup, PxVehicleNoDrive::setup, setSceneQueryFilterData, PxRigidActor::getShapes
+ */
+ void setWheelShapeMapping(const PxU32 wheelId, const PxI32 shapeId);
+
+ /**
+ \brief Set the scene query filter data that will be used for raycasts along the travel
+ direction of the specified suspension. The default value is PxFilterData(0,0,0,0)
+ \param suspId is the wheel index
+ \param sqFilterData is the raycast filter data for the suspension raycast.
+ @see setWheelShapeMapping
+ */
+ void setSceneQueryFilterData(const PxU32 suspId, const PxFilterData& sqFilterData);
+
+ /**
+ \brief Set the data that describes the filtering of the tire load to produce smoother handling at large timesteps.
+ \param tireLoadFilter is the smoothing function data.
+ */
+ void setTireLoadFilterData(const PxVehicleTireLoadFilterData& tireLoadFilter);
+
+ /**
+ \brief Set the anti-roll suspension for a pair of wheels.
+
+ \param antiRoll is the anti-roll suspension.
+
+ \note If an anti-roll bar has already been set for the same logical wheel pair
+ (independent of wheel index order specified by PxVehicleAntiRollBar.mWheel0 and PxVehicleAntiRollBar.mWheel0)
+ then the existing anti-roll bar is updated with a new stiffness parameter antiRoll.mStiffness.
+
+ \note If the wheel pair specified by antiRoll does not yet have an anti-roll bar then antiRoll is added to
+ a list of anti-roll bars for the vehicle.
+
+ \return If antiRoll represents a new wheel pair then a unique id is assigned to the anti-roll bar and returned.
+ If antiRoll represents an existing wheel pair then the unique id of the existing anti-roll bar is returned.
+ The return value is always in range (0, getNbAntiRollBars()).
+
+ \note The return value can be used to query the anti-roll bar with getAntiRollBarData(id).
+
+ \note The number of possible anti-roll bars is limited to half the wheel count.
+
+ \note An existing anti-roll bar can be disabled by calling antiRoll.mStiffness to zero.
+
+ @see PxVehicleWheelsSimData::getAntiRollBarData, PxVehicleAntiRollBarData
+ */
+ PxU32 addAntiRollBarData(const PxVehicleAntiRollBarData& antiRoll);
+
+ /**
+ \brief Disable a wheel so that zero suspension forces and zero tire forces are applied to the rigid body from this wheel.
+
+ \note If the vehicle has a differential (PxVehicleNW/PxVehicle4W) then the differential (PxVehicleDifferentialNWData/PxVehicleDifferential4WData)
+ needs to be configured so that no drive torque is delivered to the disabled wheel.
+
+ \note If the vehicle is of type PxVehicleNoDrive then zero drive torque must be applied to the disabled wheel.
+
+ \note For tanks (PxVehicleDriveTank) any drive torque that could be delivered to the wheel through the tank differential will be
+ re-directed to the remaining enabled wheels.
+
+ @see enableWheel
+ @see PxVehicleDifferentialNWData::setDrivenWheel
+ @see PxVehicleDifferential4WData::mFrontLeftRightSplit, PxVehicleDifferential4WData::mRearLeftRightSplit, PxVehicleDifferential4WData::mType
+ @see PxVehicleNoDrive::setDriveTorque
+ @see PxVehicle4WEnable3WTadpoleMode, PxVehicle4WEnable3WDeltaMode
+
+ \note If a PxShape is associated with the disabled wheel then the association must be broken by calling setWheelShapeMapping(wheelId, -1).
+ @see setWheelShapeMapping
+
+ \note A wheel that is disabled must also simultaneously be given zero wheel rotation speed.
+ @see PxVehicleWheelsDynData::setWheelRotationSpeed
+
+ \note Care must be taken with the sprung mass supported by the remaining enabled wheels. Depending on the desired effect, the mass of the rigid body
+ might need to be distributed among the remaining enabled wheels and suspensions.
+
+ \param[in] wheel is the wheel index.
+ */
+ void disableWheel(const PxU32 wheel);
+
+ /**
+ \brief Enable a wheel so that suspension forces and tire forces are applied to the rigid body.
+ All wheels are enabled by default and remain enabled until they are disabled.
+ \param[in] wheel is the wheel index.
+ @see disableWheel
+ */
+ void enableWheel(const PxU32 wheel);
+
+ /**
+ \brief Test if a wheel has been disabled.
+ \param[in] wheel is the wheel index.
+ */
+ bool getIsWheelDisabled(const PxU32 wheel) const;
+
+ /**
+ \brief Set the number of vehicle sub-steps that will be performed when the vehicle's longitudinal
+ speed is below and above a threshold longitudinal speed.
+
+ \note More sub-steps provides better stability but with greater computational cost.
+
+ \note Typically, vehicles require more sub-steps at very low forward speeds.
+
+ \note The threshold longitudinal speed has a default value that is the equivalent of 5 metres per second after accounting for
+ the length scale set in PxTolerancesScale.
+
+ \note The sub-step count below the threshold longitudinal speed has a default of 3.
+
+ \note The sub-step count above the threshold longitudinal speed has a default of 1.
+
+ \note Each sub-step has time advancement equal to the time-step passed to PxVehicleUpdates divided by the number of required sub-steps.
+
+ \note The contact planes of the most recent suspension line raycast are reused across all sub-steps.
+
+ \note Each sub-step computes tire and suspension forces and then advances a velocity, angular velocity and transform.
+
+ \note At the end of all sub-steps the vehicle actor is given the velocity and angular velocity that would move the actor from its start transform prior
+ to the first sub-step to the transform computed at the end of the last substep, assuming it doesn't collide with anything along the way in the next PhysX SDK update.
+
+ \note The global pose of the actor is left unchanged throughout the sub-steps.
+
+ \param[in] thresholdLongitudinalSpeed is a threshold speed that is used to categorize vehicle speed as low speed or high speed.
+ \param[in] lowForwardSpeedSubStepCount is the number of sub-steps performed in PxVehicleUpates for vehicles that have longitudinal speed lower than thresholdLongitudinalSpeed.
+ \param[in] highForwardSpeedSubStepCount is the number of sub-steps performed in PxVehicleUpdates for vehicles that have longitudinal speed graeter than thresholdLongitudinalSpeed.
+ */
+ void setSubStepCount(const PxReal thresholdLongitudinalSpeed, const PxU32 lowForwardSpeedSubStepCount, const PxU32 highForwardSpeedSubStepCount);
+
+ /**
+ \brief Set the minimum denominator used in the longitudinal slip calculation.
+
+ \note The longitudinal slip has a theoretical value of (w*r - vz)/|vz|, where w is the angular speed of the wheel; r is the radius of the wheel;
+ and vz is the component of rigid body velocity (computed at the wheel base) that lies along the longitudinal wheel direction. The term |vz|
+ normalizes the slip, while preserving the sign of the longitudinal tire slip. The difficulty here is that when |vz| approaches zero the
+ longitudinal slip approaches infinity. A solution to this problem is to replace the denominator (|vz|) with a value that never falls below a chosen threshold.
+ The longitudinal slip is then calculated with (w*r - vz)/PxMax(|vz|, minLongSlipDenominator).
+
+ \note The default value is the equivalent of 4 metres per second after accounting for the length scale set in PxTolerancesScale.
+
+ \note Adjust this value upwards if a vehicle has difficulty coming to rest.
+
+ \note Decreasing the timestep (or increasing the number of sub-steps at low longitudinal speed with setSubStepCount) should allow stable stable
+ behavior with smaller values of minLongSlipDenominator.
+ */
+ void setMinLongSlipDenominator(const PxReal minLongSlipDenominator);
+
+ /**
+ \brief Set the vehicle wheel simulation flags.
+
+ \param[in] flags The flags to set (see #PxVehicleWheelsSimFlags).
+
+ Default: no flag set
+
+ @see PxVehicleWheelsSimFlag
+ */
+ void setFlags(PxVehicleWheelsSimFlags flags);
+
+ /**
+ \brief Return the vehicle wheel simulation flags.
+
+ \return The values of the flags.
+
+ @see PxVehicleWheelsSimFlag
+ */
+ PxVehicleWheelsSimFlags getFlags() const;
+
+private:
+
+ /**
+ \brief Graph to filter normalised load
+ @see setTireLoadFilterData, getTireLoadFilterData
+ */
+ PxVehicleTireLoadFilterData mNormalisedLoadFilter;
+
+ /**
+ \brief Wheels data organised in blocks of 4 wheels.
+ */
+ PxVehicleWheels4SimData* mWheels4SimData;
+
+ /**
+ \brief Number of blocks of 4 wheels.
+ */
+ PxU32 mNbWheels4;
+
+ /**
+ \brief Number of actual wheels (<=(mNbWheels4*4))
+ */
+ PxU32 mNbActiveWheels;
+
+ /**
+ \brief Anti-roll bars
+ */
+ PxVehicleAntiRollBarData* mAntiRollBars;
+
+ /**
+ \brief 2 anti-rollbars allocated for each block of 4 wheels.
+ */
+ PxU32 mNbAntiRollBars4;
+
+ /**
+ \brief Number of active anti-roll bars.
+ */
+ PxU32 mNbActiveAntiRollBars;
+
+ /**
+ \brief Which of the mNbActiveWheels are active or disabled?
+ The default is that all mNbActiveWheels wheels are active.
+ */
+ PxU32 mActiveWheelsBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5];
+
+ /**
+ \brief Threshold longitudinal speed used to decide whether to use
+ mLowForwardSpeedSubStepCount or mHighForwardSpeedSubStepCount as the
+ number of sub-steps that will be peformed.
+ */
+ PxF32 mThresholdLongitudinalSpeed;
+
+ /**
+ \brief Number of sub-steps that will be performed if the longitudinal speed
+ of the vehicle is smaller than mThresholdLongitudinalSpeed.
+ */
+ PxU32 mLowForwardSpeedSubStepCount;
+
+ /**
+ \brief Number of sub-steps that will be performed if the longitudinal speed
+ of the vehicle is greater than or equal to mThresholdLongitudinalSpeed.
+ */
+ PxU32 mHighForwardSpeedSubStepCount;
+
+ /**
+ \brief Minimum long slip denominator
+ */
+ PxF32 mMinLongSlipDenominator;
+
+ /**
+ \brief The vehicle wheel simulation flags.
+
+ @see PxVehicleWheelsSimFlags
+ */
+ PxU32 mFlags;
+
+#if PX_P64_FAMILY
+ PxU32 mPad[1];
+#endif
+
+ /**
+ \brief Test if wheel simulation data has been setup with legal values.
+ */
+ bool isValid() const;
+
+ /**
+ \brief see PxVehicleWheels::allocate
+ */
+ static PxU32 computeByteSize(const PxU32 numWheels);
+ static PxU8* patchUpPointers(const PxU32 numWheels, PxVehicleWheelsSimData* simData, PxU8* ptrIn);
+ PxVehicleWheelsSimData(const PxU32 numWheels);
+
+//serialization
+public:
+ PxVehicleWheelsSimData(const PxEMPTY) : mNormalisedLoadFilter(PxEmpty) {}
+ static void getBinaryMetaData(PxOutputStream& stream);
+ PxU32 getNbWheels4() const { return mNbWheels4; }
+ PxU32 getNbSuspensionData() const { return mNbActiveWheels; }
+ PxU32 getNbWheelData() const { return mNbActiveWheels; }
+ PxU32 getNbSuspTravelDirection() const { return mNbActiveWheels; }
+ PxU32 getNbTireData() const { return mNbActiveWheels; }
+ PxU32 getNbSuspForceAppPointOffset() const { return mNbActiveWheels; }
+ PxU32 getNbTireForceAppPointOffset() const { return mNbActiveWheels; }
+ PxU32 getNbWheelCentreOffset() const { return mNbActiveWheels; }
+ PxU32 getNbWheelShapeMapping() const { return mNbActiveWheels; }
+ PxU32 getNbSceneQueryFilterData() const { return mNbActiveWheels; }
+ PxF32 getMinLongSlipDenominator() const {return mMinLongSlipDenominator;}
+ void setThresholdLongSpeed(const PxF32 f) {mThresholdLongitudinalSpeed = f;}
+ PxF32 getThresholdLongSpeed() const {return mThresholdLongitudinalSpeed;}
+ void setLowForwardSpeedSubStepCount(const PxU32 f) {mLowForwardSpeedSubStepCount = f;}
+ PxU32 getLowForwardSpeedSubStepCount() const {return mLowForwardSpeedSubStepCount;}
+ void setHighForwardSpeedSubStepCount(const PxU32 f) {mHighForwardSpeedSubStepCount = f;}
+ PxU32 getHighForwardSpeedSubStepCount() const {return mHighForwardSpeedSubStepCount;}
+ void setWheelEnabledState(const PxU32 wheel, const bool state) {if(state) {enableWheel(wheel);} else {disableWheel(wheel);}}
+ bool getWheelEnabledState(const PxU32 wheel) const {return !getIsWheelDisabled(wheel);}
+ PxU32 getNbWheelEnabledState() const {return mNbActiveWheels;}
+ PxU32 getNbAntiRollBars4() const { return mNbAntiRollBars4; }
+ PxU32 getNbAntiRollBarData() const {return mNbActiveAntiRollBars;}
+ void setAntiRollBarData(const PxU32 id, const PxVehicleAntiRollBarData& antiRoll);
+ PxVehicleWheelsSimData(){}
+ ~PxVehicleWheelsSimData(){}
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelsSimData) & 15));
+
+/**
+\brief Data structure with instanced dynamics data for wheels
+*/
+class PxVehicleWheelsDynData
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleWheels;
+ friend class PxVehicleDrive4W;
+ friend class PxVehicleDriveTank;
+ friend class PxVehicleUpdate;
+
+ PxVehicleWheelsDynData(){}
+ ~PxVehicleWheelsDynData(){}
+
+ /**
+ \brief Set all wheels to their rest state.
+ @see setup
+ */
+ void setToRestState();
+
+ /**
+ \brief Set the tire force shader function
+ \param[in] tireForceShaderFn is the shader function that will be used to compute tire forces.
+ */
+ void setTireForceShaderFunction(PxVehicleComputeTireForce tireForceShaderFn);
+
+ /**
+ \brief Set the tire force shader data for a specific tire
+ \param[in] tireId is the wheel index
+ \param[in] tireForceShaderData is the data describing the tire.
+ */
+ void setTireForceShaderData(const PxU32 tireId, const void* tireForceShaderData);
+
+ /**
+ \brief Get the tire force shader data for a specific tire
+ */
+ const void* getTireForceShaderData(const PxU32 tireId) const;
+
+ /**
+ \brief Set the wheel rotation speed (radians per second) about the rolling axis for the specified wheel.
+ \param[in] wheelIdx is the wheel index
+ \param[in] speed is the rotation speed to be applied to the wheel.
+ */
+ void setWheelRotationSpeed(const PxU32 wheelIdx, const PxReal speed);
+
+ /**
+ \brief Return the rotation speed about the rolling axis of a specified wheel .
+ */
+ PxReal getWheelRotationSpeed(const PxU32 wheelIdx) const;
+
+ /**
+ \brief Set the wheel rotation angle (radians) about the rolling axis of the specified wheel.
+ \param[in] wheelIdx is the wheel index
+ \param[in] angle is the rotation angle to be applied to the wheel.
+ */
+ void setWheelRotationAngle(const PxU32 wheelIdx, const PxReal angle);
+
+ /**
+ \brief Return the rotation angle about the rolling axis for the specified wheel.
+ */
+ PxReal getWheelRotationAngle(const PxU32 wheelIdx) const;
+
+ /**
+ \brief Set the user data pointer for the specified wheel
+ It has a default value of NULL.
+ \param[in] tireIdx is the wheel index
+ \param[in] userData is the data to be associated with the wheel.
+ */
+ void setUserData(const PxU32 tireIdx, void* userData);
+
+ /**
+ \brief Get the user data pointer that was set for the specified wheel
+ */
+ void* getUserData(const PxU32 tireIdx) const;
+
+ /**
+ \brief Copy the dynamics data of a single wheel unit (wheel, suspension, tire) from srcWheel of src to trgWheel.
+ \param[in] src is the data to be copied.
+ \param[in] srcWheel is the wheel whose data will be copied from src.
+ \param[in] trgWheel is the wheel that will be assigned the copied data.
+ */
+ void copy(const PxVehicleWheelsDynData& src, const PxU32 srcWheel, const PxU32 trgWheel);
+
+private:
+
+ /**
+ \brief Dynamics data arranged in blocks of 4 wheels.
+ */
+ PxVehicleWheels4DynData* mWheels4DynData;
+
+ /**
+ \brief Test if wheel dynamics data have legal values.
+ */
+ bool isValid() const;
+
+ /**
+ \brief Shader data and function for tire force calculations.
+ */
+ PxVehicleTireForceCalculator* mTireForceCalculators;
+
+ /**
+ \brief A userData pointer can be stored for each wheel.
+ @see setUserData, getUserData
+ */
+ void** mUserDatas;
+
+ /**
+ \brief Number of blocks of 4 wheels.
+ */
+ PxU32 mNbWheels4;
+
+ /**
+ \brief Number of wheels (mNbActiveWheels <= (mNbWheels4*4))
+ */
+ PxU32 mNbActiveWheels;
+
+ PxU32 mPad[3];
+
+ /**
+ \brief see PxVehicleWheels::allocate
+ */
+ static PxU32 computeByteSize(const PxU32 numWheels);
+ static PxU8* patchUpPointers(const PxU32 numWheels, PxVehicleWheelsDynData* dynData, PxU8* ptr);
+ PxVehicleWheelsDynData(const PxU32 numWheels);
+
+//serialization
+public:
+ static void getBinaryMetaData(PxOutputStream& stream);
+ PxU32 getNbWheelRotationSpeed() const { return mNbActiveWheels; }
+ PxU32 getNbWheelRotationAngle() const { return mNbActiveWheels; }
+ PxVehicleWheels4DynData* getWheel4DynData() const { return mWheels4DynData; }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelsDynData) & 15));
+
+/**
+\brief Data structure with instanced dynamics data and configuration data of a vehicle with just wheels
+@see PxVehicleDrive, PxVehicleDrive4W, PxVehicleDriveTank
+*/
+class PxVehicleWheels : public PxBase
+{
+//= ATTENTION! =====================================================================================
+// Changing the data layout of this class breaks the binary serialization format. See comments for
+// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
+// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
+// accordingly.
+//==================================================================================================
+public:
+
+ friend class PxVehicleUpdate;
+ friend class PxVehicleConstraintShader;
+
+ /**
+ \brief Return the type of vehicle
+ @see PxVehicleTypes
+ */
+ PX_FORCE_INLINE PxU32 getVehicleType() const {return mType;}
+
+ /**
+ \brief Get non-const ptr to PxRigidDynamic instance that is the vehicle's physx representation
+ */
+ PX_FORCE_INLINE PxRigidDynamic* getRigidDynamicActor() {return mActor;}
+
+ /**
+ \brief Get const ptr to PxRigidDynamic instance that is the vehicle's physx representation
+ */
+ PX_FORCE_INLINE const PxRigidDynamic* getRigidDynamicActor() const {return mActor;}
+
+ /**
+ \brief Compute the rigid body velocity component along the forward vector of the rigid body transform.
+ @see PxVehicleSetBasisVectors
+ */
+ PxReal computeForwardSpeed() const;
+
+ /**
+ \brief Compute the rigid body velocity component along the right vector of the rigid body transform.
+ @see PxVehicleSetBasisVectors
+ */
+ PxReal computeSidewaysSpeed() const;
+
+ /**
+ \brief Data describing the setup of all the wheels/suspensions/tires.
+ */
+ PxVehicleWheelsSimData mWheelsSimData;
+
+ /**
+ \brief Data describing the dynamic state of all wheels/suspension/tires.
+ */
+ PxVehicleWheelsDynData mWheelsDynData;
+
+protected:
+
+ /**
+ \brief Set all wheels to their rest state
+ */
+ void setToRestState();
+
+ /**
+ \brief Test that all configuration and instanced dynamics data is valid.
+ */
+ bool isValid() const;
+
+ /**
+ @see PxVehicleDrive4W::allocate, PxVehicleDriveTank::allocate
+ */
+ static PxU32 computeByteSize(const PxU32 nbWheels);
+ static PxU8* patchupPointers(const PxU32 nbWheels, PxVehicleWheels* vehWheels, PxU8* ptr);
+ virtual void init(const PxU32 numWheels);
+
+ /**
+ \brief Deallocate a PxVehicleWheels instance.
+ @see PxVehicleDrive4W::free, PxVehicleDriveTank::free
+ */
+ void free();
+
+ /*
+ \brief Deferred deletion.
+ */
+ void onConstraintRelease();
+
+ /**
+ @see PxVehicleDrive4W::setup, PxVehicleDriveTank::setup
+ */
+ void setup
+ (PxPhysics* physics, PxRigidDynamic* vehActor,
+ const PxVehicleWheelsSimData& wheelsData,
+ const PxU32 nbDrivenWheels, const PxU32 nbNonDrivenWheels);
+
+ /**
+ \brief The rigid body actor that represents the vehicle in the PhysX SDK.
+ */
+ PxRigidDynamic* mActor;
+
+private:
+
+ /**
+ \brief Count the number of constraint connectors that have hit their callback when deleting a vehicle.
+ Can only delete the vehicle's memory when all constraint connectors have hit their callback.
+ */
+ PxU32 mNbNonDrivenWheels;
+
+ PxU8 mOnConstraintReleaseCounter;
+
+protected:
+
+ /**
+ \brief Vehicle type (eVehicleDriveTypes)
+ */
+ PxU8 mType;
+
+#if PX_P64_FAMILY
+ PxU8 mPad0[14];
+#else
+ PxU8 mPad0[14];
+#endif
+
+//serialization
+public:
+ virtual void requiresObjects(PxProcessPxBaseCallback& c);
+ virtual const char* getConcreteTypeName() const { return "PxVehicleWheels"; }
+ virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleWheels", name) || PxBase::isKindOf(name); }
+ virtual void preExportDataReset() {}
+ virtual void exportExtraData(PxSerializationContext&);
+ void importExtraData(PxDeserializationContext&);
+ void resolveReferences(PxDeserializationContext&);
+ static void getBinaryMetaData(PxOutputStream& stream);
+ PX_FORCE_INLINE PxU32 getNbNonDrivenWheels() const { return mNbNonDrivenWheels; }
+ PxVehicleWheels(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
+ PxVehicleWheels(PxBaseFlags baseFlags) : PxBase(baseFlags), mWheelsSimData(PxEmpty) {}
+ virtual ~PxVehicleWheels() {}
+ virtual void release() { free(); }
+//~serialization
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheels) & 15));
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_WHEELS_H
diff --git a/sources/PhysX/PhysX/source/fastxml/include/PsFastXml.h b/sources/PhysX/PhysX/source/fastxml/include/PsFastXml.h
new file mode 100644
index 00000000..4e7ddcd9
--- /dev/null
+++ b/sources/PhysX/PhysX/source/fastxml/include/PsFastXml.h
@@ -0,0 +1,167 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFASTXML_PSFASTXML_H
+#define PSFASTXML_PSFASTXML_H
+
+#include "foundation/PxSimpleTypes.h" // defines basic data types; modify for your platform as needed.
+#include "foundation/PxIO.h"
+#include "foundation/PxAssert.h"
+#include "PsAllocator.h"
+
+namespace physx
+{
+namespace shdfnd
+{
+
+class FastXml
+{
+ PX_NOCOPY(FastXml)
+
+ public:
+ class AttributePairs
+ {
+ int argc;
+ const char** argv;
+
+ public:
+ AttributePairs() : argc(0), argv(NULL)
+ {
+ }
+ AttributePairs(int c, const char** v) : argc(c), argv(v)
+ {
+ }
+
+ PX_INLINE int getNbAttr() const
+ {
+ return argc / 2;
+ }
+
+ const char* getKey(uint32_t index) const
+ {
+ PX_ASSERT((index * 2) < uint32_t(argc));
+ return argv[index * 2];
+ }
+
+ const char* getValue(uint32_t index) const
+ {
+ PX_ASSERT((index * 2 + 1) < uint32_t(argc));
+ return argv[index * 2 + 1];
+ }
+
+ const char* get(const char* attr) const
+ {
+ int32_t count = argc / 2;
+ for(int32_t i = 0; i < count; ++i)
+ {
+ const char* key = argv[i * 2], *value = argv[i * 2 + 1];
+ if(strcmp(key, attr) == 0)
+ return value;
+ }
+
+ return NULL;
+ }
+ };
+
+ /***
+ * Callbacks to the user with the contents of the XML file properly digested.
+ */
+ class Callback
+ {
+ public:
+ virtual ~Callback()
+ {
+ }
+ virtual bool processComment(const char* comment) = 0; // encountered a comment in the XML
+
+ // 'element' is the name of the element that is being closed.
+ // depth is the recursion depth of this element.
+ // Return true to continue processing the XML file.
+ // Return false to stop processing the XML file; leaves the read pointer of the stream right after this close
+ // tag.
+ // The bool 'isError' indicates whether processing was stopped due to an error, or intentionally canceled early.
+ virtual bool processClose(const char* element, uint32_t depth, bool& isError) = 0; // process the 'close'
+ // indicator for a previously
+ // encountered element
+
+ // return true to continue processing the XML document, false to skip.
+ virtual bool processElement(const char* elementName, // name of the element
+ const char* elementData, // element data, null if none
+ const AttributePairs& attr, // attributes
+ int32_t lineno) = 0; // line number in the source XML file
+
+ // process the XML declaration header
+ virtual bool processXmlDeclaration(const AttributePairs&, // attributes
+ const char* /*elementData*/, int32_t /*lineno*/)
+ {
+ return true;
+ }
+
+ virtual bool processDoctype(const char* /*rootElement*/, // Root element tag
+ const char* /*type*/, // SYSTEM or PUBLIC
+ const char* /*fpi*/, // Formal Public Identifier
+ const char* /*uri*/) // Path to schema file
+ {
+ return true;
+ }
+
+ virtual void* allocate(uint32_t size)
+ {
+ return getAllocator().allocate(size, "FastXml", __FILE__, __LINE__);
+ }
+
+ virtual void deallocate(void* ptr)
+ {
+ getAllocator().deallocate(ptr);
+ }
+ };
+
+ virtual bool processXml(PxInputData& buff, bool streamFromMemory = false) = 0;
+
+ virtual const char* getError(int32_t& lineno) = 0; // report the reason for a parsing error, and the line number
+ // where it occurred.
+
+ FastXml()
+ {
+ }
+
+ virtual void release(void) = 0;
+
+ protected:
+ virtual ~FastXml()
+ {
+ }
+};
+
+FastXml* createFastXml(FastXml::Callback* iface);
+
+} // shdfnd
+} // physx
+
+#endif // PSFASTXML_PSFASTXML_H
diff --git a/sources/PhysX/PhysX/source/foundation/include/Ps.h b/sources/PhysX/PhysX/source/foundation/include/Ps.h
new file mode 100644
index 00000000..ca4c50d0
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/Ps.h
@@ -0,0 +1,70 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PS_H
+#define PSFOUNDATION_PS_H
+
+/*! \file top level include file for shared foundation */
+
+#include "foundation/Px.h"
+
+/**
+Platform specific defines
+*/
+#if PX_WINDOWS_FAMILY || PX_XBOXONE
+#pragma intrinsic(memcmp)
+#pragma intrinsic(memcpy)
+#pragma intrinsic(memset)
+#pragma intrinsic(abs)
+#pragma intrinsic(labs)
+#endif
+
+// An expression that should expand to nothing in non PX_CHECKED builds.
+// We currently use this only for tagging the purpose of containers for memory use tracking.
+#if PX_CHECKED
+#define PX_DEBUG_EXP(x) (x)
+#else
+#define PX_DEBUG_EXP(x)
+#endif
+
+#define PX_SIGN_BITMASK 0x80000000
+
+namespace physx
+{
+namespace shdfnd
+{
+// Int-as-bool type - has some uses for efficiency and with SIMD
+typedef int IntBool;
+static const IntBool IntFalse = 0;
+static const IntBool IntTrue = 1;
+}
+
+} // namespace physx
+
+#endif // #ifndef PSFOUNDATION_PS_H
diff --git a/sources/PhysX/PhysX/source/foundation/include/PsAlignedMalloc.h b/sources/PhysX/PhysX/source/foundation/include/PsAlignedMalloc.h
new file mode 100644
index 00000000..a7fdb2f2
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/PsAlignedMalloc.h
@@ -0,0 +1,88 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PSALIGNEDMALLOC_H
+#define PSFOUNDATION_PSALIGNEDMALLOC_H
+
+#include "PsUserAllocated.h"
+
+/*!
+Allocate aligned memory.
+Alignment must be a power of 2!
+-- should be templated by a base allocator
+*/
+
+namespace physx
+{
+namespace shdfnd
+{
+/**
+Allocator, which is used to access the global PxAllocatorCallback instance
+(used for dynamic data types template instantiation), which can align memory
+*/
+
+// SCS: AlignedMalloc with 3 params not found, seems not used on PC either
+// disabled for now to avoid GCC error
+
+template
+class AlignedAllocator : public BaseAllocator
+{
+ public:
+ AlignedAllocator(const BaseAllocator& base = BaseAllocator()) : BaseAllocator(base)
+ {
+ }
+
+ void* allocate(size_t size, const char* file, int line)
+ {
+ size_t pad = N - 1 + sizeof(size_t); // store offset for delete.
+ uint8_t* base = reinterpret_cast(BaseAllocator::allocate(size + pad, file, line));
+ if(!base)
+ return NULL;
+
+ uint8_t* ptr = reinterpret_cast(size_t(base + pad) & ~(size_t(N) - 1)); // aligned pointer, ensuring N
+ // is a size_t
+ // wide mask
+ reinterpret_cast(ptr)[-1] = size_t(ptr - base); // store offset
+
+ return ptr;
+ }
+ void deallocate(void* ptr)
+ {
+ if(ptr == NULL)
+ return;
+
+ uint8_t* base = reinterpret_cast(ptr) - reinterpret_cast(ptr)[-1];
+ BaseAllocator::deallocate(base);
+ }
+};
+
+} // namespace shdfnd
+} // namespace physx
+
+#endif // #ifndef PSFOUNDATION_PSALIGNEDMALLOC_H
diff --git a/sources/PhysX/PhysX/source/foundation/include/PsAlloca.h b/sources/PhysX/PhysX/source/foundation/include/PsAlloca.h
new file mode 100644
index 00000000..cf331b82
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/PsAlloca.h
@@ -0,0 +1,76 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PSALLOCA_H
+#define PSFOUNDATION_PSALLOCA_H
+
+#include "PsTempAllocator.h"
+
+namespace physx
+{
+namespace shdfnd
+{
+template
+class ScopedPointer : private Alloc
+{
+ public:
+ ~ScopedPointer()
+ {
+ if(mOwned)
+ Alloc::deallocate(mPointer);
+ }
+
+ operator T*() const
+ {
+ return mPointer;
+ }
+
+ T* mPointer;
+ bool mOwned;
+};
+
+} // namespace shdfnd
+} // namespace physx
+
+/*! Stack allocation for \c count instances of \c type. Falling back to temp allocator if using more than 1kB. */
+#ifdef __SPU__
+#define PX_ALLOCA(var, type, count) type* var = reinterpret_cast(PxAlloca(sizeof(type) * (count)))
+#else
+#define PX_ALLOCA(var, type, count) \
+ physx::shdfnd::ScopedPointer var; \
+ { \
+ uint32_t size = sizeof(type) * (count); \
+ var.mOwned = size > 1024; \
+ if(var.mOwned) \
+ var.mPointer = reinterpret_cast(physx::shdfnd::TempAllocator().allocate(size, __FILE__, __LINE__)); \
+ else \
+ var.mPointer = reinterpret_cast(PxAlloca(size)); \
+ }
+#endif
+#endif // #ifndef PSFOUNDATION_PSALLOCA_H
diff --git a/sources/PhysX/PhysX/source/foundation/include/PsAllocator.h b/sources/PhysX/PhysX/source/foundation/include/PsAllocator.h
new file mode 100644
index 00000000..38b70fc3
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/PsAllocator.h
@@ -0,0 +1,367 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PSALLOCATOR_H
+#define PSFOUNDATION_PSALLOCATOR_H
+
+#include "foundation/PxAllocatorCallback.h"
+#include "foundation/PxAssert.h"
+#include "PxFoundation.h"
+#include "Ps.h"
+
+#if(PX_WINDOWS_FAMILY || PX_XBOXONE)
+ #include
+ #include
+#endif
+#if(PX_APPLE_FAMILY)
+ #include
+#endif
+
+#include
+
+// Allocation macros going through user allocator
+#if PX_CHECKED
+ #define PX_ALLOC(n, name) physx::shdfnd::NamedAllocator(name).allocate(n, __FILE__, __LINE__)
+#else
+ #define PX_ALLOC(n, name) physx::shdfnd::NonTrackingAllocator().allocate(n, __FILE__, __LINE__)
+#endif
+#define PX_ALLOC_TEMP(n, name) PX_ALLOC(n, name)
+#define PX_FREE(x) physx::shdfnd::NonTrackingAllocator().deallocate(x)
+#define PX_FREE_AND_RESET(x) \
+ { \
+ PX_FREE(x); \
+ x = 0; \
+ }
+
+// The following macros support plain-old-types and classes derived from UserAllocated.
+#define PX_NEW(T) new (physx::shdfnd::ReflectionAllocator(), __FILE__, __LINE__) T
+#define PX_NEW_TEMP(T) PX_NEW(T)
+#define PX_DELETE(x) delete x
+#define PX_DELETE_AND_RESET(x) \
+ { \
+ PX_DELETE(x); \
+ x = 0; \
+ }
+#define PX_DELETE_POD(x) \
+ { \
+ PX_FREE(x); \
+ x = 0; \
+ }
+#define PX_DELETE_ARRAY(x) \
+ { \
+ PX_DELETE([] x); \
+ x = 0; \
+ }
+
+// aligned allocation
+#define PX_ALIGNED16_ALLOC(n) physx::shdfnd::AlignedAllocator<16>().allocate(n, __FILE__, __LINE__)
+#define PX_ALIGNED16_FREE(x) physx::shdfnd::AlignedAllocator<16>().deallocate(x)
+
+//! placement new macro to make it easy to spot bad use of 'new'
+#define PX_PLACEMENT_NEW(p, T) new (p) T
+
+#if PX_DEBUG || PX_CHECKED
+ #define PX_USE_NAMED_ALLOCATOR 1
+#else
+ #define PX_USE_NAMED_ALLOCATOR 0
+#endif
+
+// Don't use inline for alloca !!!
+#if PX_WINDOWS_FAMILY
+ #include
+ #define PxAlloca(x) _alloca(x)
+#elif PX_LINUX || PX_ANDROID
+ #include
+ #define PxAlloca(x) alloca(x)
+#elif PX_APPLE_FAMILY
+ #include
+ #define PxAlloca(x) alloca(x)
+#elif PX_PS4
+ #include
+ #define PxAlloca(x) alloca(x)
+#elif PX_XBOXONE
+ #include
+ #define PxAlloca(x) alloca(x)
+#elif PX_SWITCH
+ #include
+ #define PxAlloca(x) alloca(x)
+#endif
+
+#define PxAllocaAligned(x, alignment) ((size_t(PxAlloca(x + alignment)) + (alignment - 1)) & ~size_t(alignment - 1))
+
+namespace physx
+{
+namespace shdfnd
+{
+
+PX_FOUNDATION_API PxAllocatorCallback& getAllocator();
+
+/**
+Allocator used to access the global PxAllocatorCallback instance without providing additional information.
+*/
+
+class PX_FOUNDATION_API Allocator
+{
+ public:
+ Allocator(const char* = 0)
+ {
+ }
+ void* allocate(size_t size, const char* file, int line);
+ void deallocate(void* ptr);
+};
+
+/*
+ * Bootstrap allocator using malloc/free.
+ * Don't use unless your objects get allocated before foundation is initialized.
+ */
+class RawAllocator
+{
+ public:
+ RawAllocator(const char* = 0)
+ {
+ }
+ void* allocate(size_t size, const char*, int)
+ {
+ // malloc returns valid pointer for size==0, no need to check
+ return ::malloc(size);
+ }
+ void deallocate(void* ptr)
+ {
+ // free(0) is guaranteed to have no side effect, no need to check
+ ::free(ptr);
+ }
+};
+
+/*
+ * Allocator that simply calls straight back to the application without tracking.
+ * This is used by the heap (Foundation::mNamedAllocMap) that tracks allocations
+ * because it needs to be able to grow as a result of an allocation.
+ * Making the hash table re-entrant to deal with this may not make sense.
+ */
+class NonTrackingAllocator
+{
+ public:
+ PX_FORCE_INLINE NonTrackingAllocator(const char* = 0)
+ {
+ }
+ PX_FORCE_INLINE void* allocate(size_t size, const char* file, int line)
+ {
+ return !size ? 0 : getAllocator().allocate(size, "NonTrackedAlloc", file, line);
+ }
+ PX_FORCE_INLINE void deallocate(void* ptr)
+ {
+ if(ptr)
+ getAllocator().deallocate(ptr);
+ }
+};
+
+/*
+\brief Virtual allocator callback used to provide run-time defined allocators to foundation types like Array or Bitmap.
+ This is used by VirtualAllocator
+*/
+class VirtualAllocatorCallback
+{
+ public:
+ VirtualAllocatorCallback()
+ {
+ }
+ virtual ~VirtualAllocatorCallback()
+ {
+ }
+ virtual void* allocate(const size_t size, const char* file, const int line) = 0;
+ virtual void deallocate(void* ptr) = 0;
+};
+
+/*
+\brief Virtual allocator to be used by foundation types to provide run-time defined allocators.
+Due to the fact that Array extends its allocator, rather than contains a reference/pointer to it, the VirtualAllocator
+must
+be a concrete type containing a pointer to a virtual callback. The callback may not be available at instantiation time,
+therefore
+methods are provided to set the callback later.
+*/
+class VirtualAllocator
+{
+ public:
+ VirtualAllocator(VirtualAllocatorCallback* callback = NULL) : mCallback(callback)
+ {
+ }
+
+ void* allocate(const size_t size, const char* file, const int line)
+ {
+ PX_ASSERT(mCallback);
+ if(size)
+ return mCallback->allocate(size, file, line);
+ return NULL;
+ }
+ void deallocate(void* ptr)
+ {
+ PX_ASSERT(mCallback);
+ if(ptr)
+ mCallback->deallocate(ptr);
+ }
+
+ void setCallback(VirtualAllocatorCallback* callback)
+ {
+ mCallback = callback;
+ }
+ VirtualAllocatorCallback* getCallback()
+ {
+ return mCallback;
+ }
+
+ private:
+ VirtualAllocatorCallback* mCallback;
+ VirtualAllocator& operator=(const VirtualAllocator&);
+};
+
+#if PX_USE_NAMED_ALLOCATOR // can be slow, so only use in debug/checked
+class PX_FOUNDATION_API NamedAllocator
+{
+ public:
+ NamedAllocator(const PxEMPTY);
+ NamedAllocator(const char* name = 0); // todo: should not have default argument!
+ NamedAllocator(const NamedAllocator&);
+ ~NamedAllocator();
+ NamedAllocator& operator=(const NamedAllocator&);
+ void* allocate(size_t size, const char* filename, int line);
+ void deallocate(void* ptr);
+};
+#else
+class NamedAllocator;
+#endif // PX_DEBUG
+
+/**
+Allocator used to access the global PxAllocatorCallback instance using a static name derived from T.
+*/
+
+template
+class ReflectionAllocator
+{
+ static const char* getName()
+ {
+ if(!PxGetFoundation().getReportAllocationNames())
+ return "";
+#if PX_GCC_FAMILY
+ return __PRETTY_FUNCTION__;
+#else
+ // name() calls malloc(), raw_name() wouldn't
+ return typeid(T).name();
+#endif
+ }
+
+ public:
+ ReflectionAllocator(const PxEMPTY)
+ {
+ }
+ ReflectionAllocator(const char* = 0)
+ {
+ }
+ inline ReflectionAllocator(const ReflectionAllocator&)
+ {
+ }
+ void* allocate(size_t size, const char* filename, int line)
+ {
+ return size ? getAllocator().allocate(size, getName(), filename, line) : 0;
+ }
+ void deallocate(void* ptr)
+ {
+ if(ptr)
+ getAllocator().deallocate(ptr);
+ }
+};
+
+template
+struct AllocatorTraits
+{
+#if PX_USE_NAMED_ALLOCATOR
+ typedef NamedAllocator Type;
+#else
+ typedef ReflectionAllocator Type;
+#endif
+};
+
+// if you get a build error here, you are trying to PX_NEW a class
+// that is neither plain-old-type nor derived from UserAllocated
+template
+union EnableIfPod
+{
+ int i;
+ T t;
+ typedef X Type;
+};
+
+} // namespace shdfnd
+} // namespace physx
+
+// Global placement new for ReflectionAllocator templated by
+// plain-old-type. Allows using PX_NEW for pointers and built-in-types.
+//
+// ATTENTION: You need to use PX_DELETE_POD or PX_FREE to deallocate
+// memory, not PX_DELETE. PX_DELETE_POD redirects to PX_FREE.
+//
+// Rationale: PX_DELETE uses global operator delete(void*), which we dont' want to overload.
+// Any other definition of PX_DELETE couldn't support array syntax 'PX_DELETE([]a);'.
+// PX_DELETE_POD was preferred over PX_DELETE_ARRAY because it is used
+// less often and applies to both single instances and arrays.
+template
+PX_INLINE void* operator new(size_t size, physx::shdfnd::ReflectionAllocator alloc, const char* fileName,
+ typename physx::shdfnd::EnableIfPod::Type line)
+{
+ return alloc.allocate(size, fileName, line);
+}
+
+template
+PX_INLINE void* operator new [](size_t size, physx::shdfnd::ReflectionAllocator alloc, const char* fileName,
+ typename physx::shdfnd::EnableIfPod::Type line)
+{ return alloc.allocate(size, fileName, line); }
+
+// If construction after placement new throws, this placement delete is being called.
+template
+PX_INLINE void operator delete(void* ptr, physx::shdfnd::ReflectionAllocator alloc, const char* fileName,
+ typename physx::shdfnd::EnableIfPod::Type line)
+{
+ PX_UNUSED(fileName);
+ PX_UNUSED(line);
+
+ alloc.deallocate(ptr);
+}
+
+// If construction after placement new throws, this placement delete is being called.
+template
+PX_INLINE void operator delete [](void* ptr, physx::shdfnd::ReflectionAllocator alloc, const char* fileName,
+ typename physx::shdfnd::EnableIfPod::Type line)
+{
+ PX_UNUSED(fileName);
+ PX_UNUSED(line);
+
+ alloc.deallocate(ptr);
+}
+
+#endif // #ifndef PSFOUNDATION_PSALLOCATOR_H
diff --git a/sources/PhysX/PhysX/source/foundation/include/PsAoS.h b/sources/PhysX/PhysX/source/foundation/include/PsAoS.h
new file mode 100644
index 00000000..ff7d0848
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/PsAoS.h
@@ -0,0 +1,45 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PSAOS_H
+#define PSFOUNDATION_PSAOS_H
+
+#include "foundation/Px.h"
+
+#if PX_WINDOWS && !PX_NEON
+#include "windows/PsWindowsAoS.h"
+#elif(PX_UNIX_FAMILY || PX_PS4 || PX_SWITCH || (PX_UWP && PX_NEON))
+#include "unix/PsUnixAoS.h"
+#elif PX_XBOXONE
+#include "XboxOne/PsXboxOneAoS.h"
+#else
+#error "Platform not supported!"
+#endif
+
+#endif
diff --git a/sources/PhysX/PhysX/source/foundation/include/PsArray.h b/sources/PhysX/PhysX/source/foundation/include/PsArray.h
new file mode 100644
index 00000000..96f44bbd
--- /dev/null
+++ b/sources/PhysX/PhysX/source/foundation/include/PsArray.h
@@ -0,0 +1,721 @@
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PSFOUNDATION_PSARRAY_H
+#define PSFOUNDATION_PSARRAY_H
+
+#include "foundation/PxAssert.h"
+#include "foundation/PxIntrinsics.h"
+#include "PsAllocator.h"
+#include "PsBasicTemplates.h"
+
+namespace physx
+{
+namespace shdfnd
+{
+template
+void exportArray(Serializer& stream, const void* data, uint32_t size, uint32_t sizeOfElement, uint32_t capacity);
+char* importArray(char* address, void** data, uint32_t size, uint32_t sizeOfElement, uint32_t capacity);
+
+/*!
+An array is a sequential container.
+
+Implementation note
+* entries between 0 and size are valid objects
+* we use inheritance to build this because the array is included inline in a lot
+ of objects and we want the allocator to take no space if it's not stateful, which
+ aggregation doesn't allow. Also, we want the metadata at the front for the inline
+ case where the allocator contains some inline storage space
+*/
+template ::Type>
+class Array : protected Alloc
+{
+ public:
+ typedef T* Iterator;
+ typedef const T* ConstIterator;
+
+ explicit Array(const PxEMPTY v) : Alloc(v)
+ {
+ if(mData)
+ mCapacity |= PX_SIGN_BITMASK;
+ }
+
+ /*!
+ Default array constructor. Initialize an empty array
+ */
+ PX_INLINE explicit Array(const Alloc& alloc = Alloc()) : Alloc(alloc), mData(0), mSize(0), mCapacity(0)
+ {
+ }
+
+ /*!
+ Initialize array with given capacity
+ */
+ PX_INLINE explicit Array(uint32_t size, const T& a = T(), const Alloc& alloc = Alloc())
+ : Alloc(alloc), mData(0), mSize(0), mCapacity(0)
+ {
+ resize(size, a);
+ }
+
+ /*!
+ Copy-constructor. Copy all entries from other array
+ */
+ template
+ PX_INLINE explicit Array(const Array& other, const Alloc& alloc = Alloc())
+ : Alloc(alloc)
+ {
+ copy(other);
+ }
+
+ // This is necessary else the basic default copy constructor is used in the case of both arrays being of the same
+ // template instance
+ // The C++ standard clearly states that a template constructor is never a copy constructor [2]. In other words,
+ // the presence of a template constructor does not suppress the implicit declaration of the copy constructor.
+ // Also never make a copy constructor explicit, or copy-initialization* will no longer work. This is because
+ // 'binding an rvalue to a const reference requires an accessible copy constructor' (http://gcc.gnu.org/bugs/)
+ // *http://stackoverflow.com/questions/1051379/is-there-a-difference-in-c-between-copy-initialization-and-assignment-initializ
+ PX_INLINE Array(const Array& other, const Alloc& alloc = Alloc()) : Alloc(alloc)
+ {
+ copy(other);
+ }
+
+ /*!
+ Initialize array with given length
+ */
+ PX_INLINE explicit Array(const T* first, const T* last, const Alloc& alloc = Alloc())
+ : Alloc(alloc), mSize(last < first ? 0 : uint32_t(last - first)), mCapacity(mSize)
+ {
+ mData = allocate(mSize);
+ copy(mData, mData + mSize, first);
+ }
+
+ /*!
+ Destructor
+ */
+ PX_INLINE ~Array()
+ {
+ destroy(mData, mData + mSize);
+
+ if(capacity() && !isInUserMemory())
+ deallocate(mData);
+ }
+
+ /*!
+ Assignment operator. Copy content (deep-copy)
+ */
+ template
+ PX_INLINE Array& operator=(const Array& rhs)
+ {
+ if(&rhs == this)
+ return *this;
+
+ clear();
+ reserve(rhs.mSize);
+ copy(mData, mData + rhs.mSize, rhs.mData);
+
+ mSize = rhs.mSize;
+ return *this;
+ }
+
+ PX_INLINE Array& operator=(const Array& t) // Needs to be declared, see comment at copy-constructor
+ {
+ return operator=(t);
+ }
+
+ /*!
+ Array indexing operator.
+ \param i
+ The index of the element that will be returned.
+ \return
+ The element i in the array.
+ */
+ PX_FORCE_INLINE const T& operator[](uint32_t i) const
+ {
+ PX_ASSERT(i < mSize);
+ return mData[i];
+ }
+
+ /*!
+ Array indexing operator.
+ \param i
+ The index of the element that will be returned.
+ \return
+ The element i in the array.
+ */
+ PX_FORCE_INLINE T& operator[](uint32_t i)
+ {
+ PX_ASSERT(i < mSize);
+ return mData[i];
+ }
+
+ /*!
+ Returns a pointer to the initial element of the array.
+ \return
+ a pointer to the initial element of the array.
+ */
+ PX_FORCE_INLINE ConstIterator begin() const
+ {
+ return mData;
+ }
+
+ PX_FORCE_INLINE Iterator begin()
+ {
+ return mData;
+ }
+
+ /*!
+ Returns an iterator beyond the last element of the array. Do not dereference.
+ \return
+ a pointer to the element beyond the last element of the array.
+ */
+
+ PX_FORCE_INLINE ConstIterator end() const
+ {
+ return mData + mSize;
+ }
+
+ PX_FORCE_INLINE Iterator end()
+ {
+ return mData + mSize;
+ }
+
+ /*!
+ Returns a reference to the first element of the array. Undefined if the array is empty.
+ \return a reference to the first element of the array
+ */
+
+ PX_FORCE_INLINE const T& front() const
+ {
+ PX_ASSERT(mSize);
+ return mData[0];
+ }
+
+ PX_FORCE_INLINE T& front()
+ {
+ PX_ASSERT(mSize);
+ return mData[0];
+ }
+
+ /*!
+ Returns a reference to the last element of the array. Undefined if the array is empty
+ \return a reference to the last element of the array
+ */
+
+ PX_FORCE_INLINE const T& back() const
+ {
+ PX_ASSERT(mSize);
+ return mData[mSize - 1];
+ }
+
+ PX_FORCE_INLINE T& back()
+ {
+ PX_ASSERT(mSize);
+ return mData[mSize - 1];
+ }
+
+ /*!
+ Returns the number of entries in the array. This can, and probably will,
+ differ from the array capacity.
+ \return
+ The number of of entries in the array.
+ */
+ PX_FORCE_INLINE uint32_t size() const
+ {
+ return mSize;
+ }
+
+ /*!
+ Clears the array.
+ */
+ PX_INLINE void clear()
+ {
+ destroy(mData, mData + mSize);
+ mSize = 0;
+ }
+
+ /*!
+ Returns whether the array is empty (i.e. whether its size is 0).
+ \return
+ true if the array is empty
+ */
+ PX_FORCE_INLINE bool empty() const
+ {
+ return mSize == 0;
+ }
+
+ /*!
+ Finds the first occurrence of an element in the array.
+ \param a
+ The element to find.
+ */
+
+ PX_INLINE Iterator find(const T& a)
+ {
+ uint32_t index;
+ for(index = 0; index < mSize && mData[index] != a; index++)
+ ;
+ return mData + index;
+ }
+
+ PX_INLINE ConstIterator find(const T& a) const
+ {
+ uint32_t index;
+ for(index = 0; index < mSize && mData[index] != a; index++)
+ ;
+ return mData + index;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Adds one element to the end of the array. Operation is O(1).
+ \param a
+ The element that will be added to this array.
+ */
+ /////////////////////////////////////////////////////////////////////////
+
+ PX_FORCE_INLINE T& pushBack(const T& a)
+ {
+ if(capacity() <= mSize)
+ return growAndPushBack(a);
+
+ PX_PLACEMENT_NEW(reinterpret_cast(mData + mSize), T)(a);
+
+ return mData[mSize++];
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Returns the element at the end of the array. Only legal if the array is non-empty.
+ */
+ /////////////////////////////////////////////////////////////////////////
+ PX_INLINE T popBack()
+ {
+ PX_ASSERT(mSize);
+ T t = mData[mSize - 1];
+
+ mData[--mSize].~T();
+
+ return t;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Construct one element at the end of the array. Operation is O(1).
+ */
+ /////////////////////////////////////////////////////////////////////////
+ PX_INLINE T& insert()
+ {
+ if(capacity() <= mSize)
+ grow(capacityIncrement());
+
+ T* ptr = mData + mSize++;
+ new (ptr) T; // not 'T()' because PODs should not get default-initialized.
+ return *ptr;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Subtracts the element on position i from the array and replace it with
+ the last element.
+ Operation is O(1)
+ \param i
+ The position of the element that will be subtracted from this array.
+ */
+ /////////////////////////////////////////////////////////////////////////
+ PX_INLINE void replaceWithLast(uint32_t i)
+ {
+ PX_ASSERT(i < mSize);
+ mData[i] = mData[--mSize];
+
+ mData[mSize].~T();
+ }
+
+ PX_INLINE void replaceWithLast(Iterator i)
+ {
+ replaceWithLast(static_cast(i - mData));
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Replaces the first occurrence of the element a with the last element
+ Operation is O(n)
+ \param a
+ The position of the element that will be subtracted from this array.
+ \return true if the element has been removed.
+ */
+ /////////////////////////////////////////////////////////////////////////
+
+ PX_INLINE bool findAndReplaceWithLast(const T& a)
+ {
+ uint32_t index = 0;
+ while(index < mSize && mData[index] != a)
+ ++index;
+ if(index == mSize)
+ return false;
+ replaceWithLast(index);
+ return true;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Subtracts the element on position i from the array. Shift the entire
+ array one step.
+ Operation is O(n)
+ \param i
+ The position of the element that will be subtracted from this array.
+ */
+ /////////////////////////////////////////////////////////////////////////
+ PX_INLINE void remove(uint32_t i)
+ {
+ PX_ASSERT(i < mSize);
+
+ T* it = mData + i;
+ it->~T();
+ while (++i < mSize)
+ {
+ new (it) T(mData[i]);
+ ++it;
+ it->~T();
+ }
+ --mSize;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /*!
+ Removes a range from the array. Shifts the array so order is maintained.
+ Operation is O(n)
+ \param begin
+ The starting position of the element that will be subtracted from this array.
+ \param count
+ The number of elments that will be subtracted from this array.
+ */
+ /////////////////////////////////////////////////////////////////////////
+ PX_INLINE void removeRange(uint32_t begin, uint32_t count)
+ {
+ PX_ASSERT(begin < mSize);
+ PX_ASSERT((begin + count) <= mSize);
+
+ for(uint32_t i = 0; i < count; i++)
+ mData[begin + i].~T(); // call the destructor on the ones being removed first.
+
+ T* dest = &mData[begin]; // location we are copying the tail end objects to
+ T* src = &mData[begin + count]; // start of tail objects
+ uint32_t move_count = mSize - (begin + count); // compute remainder that needs to be copied down
+
+ for(uint32_t i = 0; i < move_count; i++)
+ {
+ new (dest) T(*src); // copy the old one to the new location
+ src->~T(); // call the destructor on the old location
+ dest++;
+ src++;
+ }
+ mSize -= count;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Resize array
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_NOINLINE void resize(const uint32_t size, const T& a = T());
+
+ PX_NOINLINE void resizeUninitialized(const uint32_t size);
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Resize array such that only as much memory is allocated to hold the
+ existing elements
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_INLINE void shrink()
+ {
+ recreate(mSize);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Deletes all array elements and frees memory.
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_INLINE void reset()
+ {
+ resize(0);
+ shrink();
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Ensure that the array has at least size capacity.
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_INLINE void reserve(const uint32_t capacity)
+ {
+ if(capacity > this->capacity())
+ grow(capacity);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Query the capacity(allocated mem) for the array.
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_FORCE_INLINE uint32_t capacity() const
+ {
+ return mCapacity & ~PX_SIGN_BITMASK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Unsafe function to force the size of the array
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_FORCE_INLINE void forceSize_Unsafe(uint32_t size)
+ {
+ PX_ASSERT(size <= mCapacity);
+ mSize = size;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Swap contents of an array without allocating temporary storage
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_INLINE void swap(Array& other)
+ {
+ shdfnd::swap(mData, other.mData);
+ shdfnd::swap(mSize, other.mSize);
+ shdfnd::swap(mCapacity, other.mCapacity);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ /*!
+ Assign a range of values to this vector (resizes to length of range)
+ */
+ //////////////////////////////////////////////////////////////////////////
+ PX_INLINE void assign(const T* first, const T* last)
+ {
+ resizeUninitialized(uint32_t(last - first));
+ copy(begin(), end(), first);
+ }
+
+ // We need one bit to mark arrays that have been deserialized from a user-provided memory block.
+ // For alignment & memory saving purpose we store that bit in the rarely used capacity member.
+ PX_FORCE_INLINE uint32_t isInUserMemory() const
+ {
+ return mCapacity & PX_SIGN_BITMASK;
+ }
+
+ /// return reference to allocator
+ PX_INLINE Alloc& getAllocator()
+ {
+ return *this;
+ }
+
+ protected:
+ // constructor for where we don't own the memory
+ Array(T* memory, uint32_t size, uint32_t capacity, const Alloc& alloc = Alloc())
+ : Alloc(alloc), mData(memory), mSize(size), mCapacity(capacity | PX_SIGN_BITMASK)
+ {
+ }
+
+ template
+ PX_NOINLINE void copy(const Array& other);
+
+ PX_INLINE T* allocate(uint32_t size)
+ {
+ if(size > 0)
+ {
+ T* p = reinterpret_cast(Alloc::allocate(sizeof(T) * size, __FILE__, __LINE__));
+/**
+Mark a specified amount of memory with 0xcd pattern. This is used to check that the meta data
+definition for serialized classes is complete in checked builds.
+*/
+#if PX_CHECKED
+ if(p)
+ {
+ for(uint32_t i = 0; i < (sizeof(T) * size); ++i)
+ reinterpret_cast(p)[i] = 0xcd;
+ }
+#endif
+ return p;
+ }
+ return 0;
+ }
+
+ PX_INLINE void deallocate(void* mem)
+ {
+ Alloc::deallocate(mem);
+ }
+
+ static PX_INLINE void create(T* first, T* last, const T& a)
+ {
+ for(; first < last; ++first)
+ ::new (first) T(a);
+ }
+
+ static PX_INLINE void copy(T* first, T* last, const T* src)
+ {
+ if(last <= first)
+ return;
+
+ for(; first < last; ++first, ++src)
+ ::new (first) T(*src);
+ }
+
+ static PX_INLINE void destroy(T* first, T* last)
+ {
+ for(; first < last; ++first)
+ first->~T();
+ }
+
+ /*!
+ Called when pushBack() needs to grow the array.
+ \param a The element that will be added to this array.
+ */
+ PX_NOINLINE T& growAndPushBack(const T& a);
+
+ /*!
+ Resizes the available memory for the array.
+
+ \param capacity
+ The number of entries that the set should be able to hold.
+ */
+ PX_INLINE void grow(uint32_t capacity)
+ {
+ PX_ASSERT(this->capacity() < capacity);
+ recreate(capacity);
+ }
+
+ /*!
+ Creates a new memory block, copies all entries to the new block and destroys old entries.
+
+ \param capacity
+ The number of entries that the set should be able to hold.
+ */
+ PX_NOINLINE void recreate(uint32_t capacity);
+
+ // The idea here is to prevent accidental bugs with pushBack or insert. Unfortunately
+ // it interacts badly with InlineArrays with smaller inline allocations.
+ // TODO(dsequeira): policy template arg, this is exactly what they're for.
+ PX_INLINE uint32_t capacityIncrement() const
+ {
+ const uint32_t capacity = this->capacity();
+ return capacity == 0 ? 1 : capacity * 2;
+ }
+
+ T* mData;
+ uint32_t mSize;
+ uint32_t mCapacity;
+};
+
+template
+PX_NOINLINE void Array::resize(const uint32_t size, const T& a)
+{
+ reserve(size);
+ create(mData + mSize, mData + size, a);
+ destroy(mData + size, mData + mSize);
+ mSize = size;
+}
+
+template
+template
+PX_NOINLINE void Array::copy(const Array& other)
+{
+ if(!other.empty())
+ {
+ mData = allocate(mSize = mCapacity = other.size());
+ copy(mData, mData + mSize, other.begin());
+ }
+ else
+ {
+ mData = NULL;
+ mSize = 0;
+ mCapacity = 0;
+ }
+
+ // mData = allocate(other.mSize);
+ // mSize = other.mSize;
+ // mCapacity = other.mSize;
+ // copy(mData, mData + mSize, other.mData);
+}
+
+template
+PX_NOINLINE void Array