feat(physics): wire physx sdk into build
This commit is contained in:
70
engine/third_party/physx/include/extensions/PxBroadPhaseExt.h
vendored
Normal file
70
engine/third_party/physx/include/extensions/PxBroadPhaseExt.h
vendored
Normal file
@@ -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-2025 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_BROAD_PHASE_EXT_H
|
||||
#define PX_BROAD_PHASE_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
class PxBounds3;
|
||||
#endif
|
||||
|
||||
class PxBroadPhaseExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Creates regions for PxSceneDesc, from a global box.
|
||||
|
||||
This helper simply subdivides the given global box into a 2D grid of smaller boxes. Each one of those smaller boxes
|
||||
is a region of interest for the broadphase. There are nbSubdiv*nbSubdiv regions in the 2D grid. The function does not
|
||||
subdivide along the given up axis.
|
||||
|
||||
This is the simplest setup one can use with PxBroadPhaseType::eMBP. A more sophisticated setup would try to cover
|
||||
the game world with a non-uniform set of regions (i.e. not just a grid).
|
||||
|
||||
\param[out] regions Regions computed from the input global box
|
||||
\param[in] globalBounds World-space box covering the game world
|
||||
\param[in] nbSubdiv Grid subdivision level. The function will create nbSubdiv*nbSubdiv regions.
|
||||
\param[in] upAxis Up axis (0 for X, 1 for Y, 2 for Z).
|
||||
\return number of regions written out to the 'regions' array
|
||||
|
||||
\see PxSceneDesc PxBroadPhaseType
|
||||
*/
|
||||
static PxU32 createRegionsFromWorldBounds(PxBounds3* regions, const PxBounds3& globalBounds, PxU32 nbSubdiv, PxU32 upAxis=1);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
115
engine/third_party/physx/include/extensions/PxCollectionExt.h
vendored
Normal file
115
engine/third_party/physx/include/extensions/PxCollectionExt.h
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// 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-2025 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_COLLECTION_EXT_H
|
||||
#define PX_COLLECTION_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxCollection.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxCollection;
|
||||
class PxScene;
|
||||
|
||||
class PxCollectionExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Removes and releases all object from a collection.
|
||||
|
||||
The Collection itself is not released.
|
||||
|
||||
If the releaseExclusiveShapes flag is not set to true, release() will not be called on exclusive shapes.
|
||||
|
||||
It is assumed that the application holds a reference to each of the objects in the collection, with the exception of objects that are not releasable
|
||||
(PxBase::isReleasable()). In general, objects that violate this assumption need to be removed from the collection prior to calling releaseObjects.
|
||||
|
||||
\note when a shape is created with PxRigidActorExt::createExclusiveShape(), the only counted reference is held by the actor.
|
||||
If such a shape and its actor are present in the collection, the reference count will be decremented once when the actor is released, and once when the
|
||||
shape is released, resulting in undefined behavior. Shape reference counts can be incremented with PxShape::acquireReference().
|
||||
|
||||
\param[in] collection to remove and release all object from.
|
||||
\param[in] releaseExclusiveShapes if this parameter is set to false, release() will not be called on exclusive shapes.
|
||||
*/
|
||||
static void releaseObjects(PxCollection& collection, bool releaseExclusiveShapes = true);
|
||||
|
||||
/**
|
||||
\brief Removes objects of a given type from a collection, potentially adding them to another collection.
|
||||
|
||||
\param[in,out] collection Collection from which objects are removed
|
||||
\param[in] concreteType PxConcreteType of sdk objects that should be removed
|
||||
\param[in,out] to Optional collection to which the removed objects are added
|
||||
|
||||
\see PxCollection, PxConcreteType
|
||||
*/
|
||||
static void remove(PxCollection& collection, PxType concreteType, PxCollection* to = NULL);
|
||||
|
||||
/**
|
||||
\brief Collects all objects in PxPhysics that are shareable across multiple scenes.
|
||||
|
||||
This function creates a new collection from all objects that are shareable across multiple
|
||||
scenes. Instances of the following types are included: PxConvexMesh, PxTriangleMesh,
|
||||
PxHeightField, PxShape and PxMaterial.
|
||||
|
||||
This is a helper function to ease the creation of collections for serialization.
|
||||
|
||||
\param[in] physics The physics SDK instance from which objects are collected. See #PxPhysics
|
||||
\return Collection to which objects are added. See #PxCollection
|
||||
|
||||
\see PxCollection, PxPhysics
|
||||
*/
|
||||
static PxCollection* createCollection(PxPhysics& physics);
|
||||
|
||||
/**
|
||||
\brief Collects all objects from a PxScene.
|
||||
|
||||
This function creates a new collection from all objects that were added to the specified
|
||||
PxScene. Instances of the following types are included: PxActor, PxAggregate,
|
||||
PxArticulationReducedCoordinate and PxJoint (other PxConstraint types are not included).
|
||||
|
||||
This is a helper function to ease the creation of collections for serialization.
|
||||
The function PxSerialization.complete() can be used to complete the collection with required objects prior to
|
||||
serialization.
|
||||
|
||||
\param[in] scene The PxScene instance from which objects are collected. See #PxScene
|
||||
\return Collection to which objects are added. See #PxCollection
|
||||
|
||||
\see PxCollection, PxScene, PxSerialization.complete()
|
||||
*/
|
||||
static PxCollection* createCollection(PxScene& scene);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
63
engine/third_party/physx/include/extensions/PxConstraintExt.h
vendored
Normal file
63
engine/third_party/physx/include/extensions/PxConstraintExt.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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-2025 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_CONSTRAINT_EXT_H
|
||||
#define PX_CONSTRAINT_EXT_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Unique identifiers for extensions classes which implement a constraint based on PxConstraint.
|
||||
|
||||
\note Users which want to create their own custom constraint types should choose an ID larger or equal to eNEXT_FREE_ID
|
||||
and not eINVALID_ID.
|
||||
|
||||
\see PxConstraint PxSimulationEventCallback.onConstraintBreak()
|
||||
*/
|
||||
struct PxConstraintExtIDs
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eJOINT,
|
||||
eVEHICLE_JOINT,
|
||||
eNEXT_FREE_ID,
|
||||
eINVALID_ID = 0x7fffffff
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
76
engine/third_party/physx/include/extensions/PxConvexCoreExt.h
vendored
Normal file
76
engine/third_party/physx/include/extensions/PxConvexCoreExt.h
vendored
Normal file
@@ -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-2025 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_CONVEX_GEOMETRY_EXT_H
|
||||
#define PX_CONVEX_GEOMETRY_EXT_H
|
||||
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "geometry/PxConvexCoreGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBounds3;
|
||||
class PxRenderOutput;
|
||||
|
||||
/**
|
||||
\brief Convex geometry helpers
|
||||
*/
|
||||
class PxConvexCoreExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Compute mass properties of the convex core geometry.
|
||||
\param convex The convex geometry.
|
||||
\param[out] density1Mass The mass of the geometry assuming unit density.
|
||||
\param[out] inertiaTensor The inertia tensor of the geometry.
|
||||
\param[out] centerOfMass The center of mass of the geometry.
|
||||
*/
|
||||
static void computeMassInfo(const PxConvexCoreGeometry& convex, PxReal& density1Mass, PxMat33& inertiaTensor, PxVec3& centerOfMass);
|
||||
|
||||
/**
|
||||
\brief Visualize the convex core geometry
|
||||
\param convex The convex geometry.
|
||||
\param pose The pose of the geometry in world space
|
||||
\param drawCore If true, draw the core inside the full convex geometry including the margin
|
||||
\param cullbox The culling box for visualization
|
||||
\param out The render output object to use for visualization
|
||||
*/
|
||||
static void visualize(const PxConvexCoreGeometry& convex, const PxTransform& pose, bool drawCore, const PxBounds3& cullbox, PxRenderOutput& out);
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
engine/third_party/physx/include/extensions/PxConvexMeshExt.h
vendored
Normal file
68
engine/third_party/physx/include/extensions/PxConvexMeshExt.h
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
// 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-2025 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_CONVEX_MESH_EXT_H
|
||||
#define PX_CONVEX_MESH_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxConvexMeshGeometry;
|
||||
|
||||
/**
|
||||
\brief Computes closest polygon of the convex hull geometry for a given impact point
|
||||
and impact direction. When doing sweeps against a scene, one might want to delay
|
||||
the rather expensive computation of the hit face index for convexes until it is clear
|
||||
the information is really needed and then use this method to get the corresponding
|
||||
face index.
|
||||
|
||||
\param[in] convexGeom The convex mesh geometry.
|
||||
\param[in] geomPose Pose for the geometry object.
|
||||
\param[in] impactPos Impact position.
|
||||
\param[in] unitDir Normalized impact direction.
|
||||
|
||||
\return Closest face index of the convex geometry.
|
||||
|
||||
\see PxTransform PxConvexMeshGeometry
|
||||
*/
|
||||
PxU32 PxFindFaceIndex(const PxConvexMeshGeometry& convexGeom,
|
||||
const PxTransform& geomPose,
|
||||
const PxVec3& impactPos,
|
||||
const PxVec3& unitDir);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
317
engine/third_party/physx/include/extensions/PxCudaHelpersExt.h
vendored
Normal file
317
engine/third_party/physx/include/extensions/PxCudaHelpersExt.h
vendored
Normal file
@@ -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-2025 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_CUDA_HELPERS_EXT_H
|
||||
#define PX_CUDA_HELPERS_EXT_H
|
||||
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if PX_SUPPORT_GPU_PHYSX
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "cudamanager/PxCudaContextManager.h"
|
||||
#include "cudamanager/PxCudaContext.h"
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
|
||||
namespace physx
|
||||
{
|
||||
namespace Ext
|
||||
{
|
||||
|
||||
class PxCudaHelpersExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Allocates a device buffer and returns the pointer to the memory
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the allocation should be attributed to.
|
||||
* \param[in] numElements the number of elements of type T to allocate.
|
||||
*
|
||||
* \return a pointer to the allocated memory.
|
||||
*/
|
||||
template<typename T>
|
||||
static T* allocDeviceBuffer(PxCudaContextManager& cudaContextManager, PxU64 numElements)
|
||||
{
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
|
||||
CUdeviceptr ptr = 0;
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memAlloc(&ptr, numElements * sizeof(T));
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "allocDeviceBuffer failed with error code %i!\n", PxI32(result));
|
||||
|
||||
return reinterpret_cast<T*>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Frees a device buffer
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the device buffer is attributed to.
|
||||
* \param[in] deviceBuffer reference to a pointer pointing to the device memory buffer.
|
||||
*/
|
||||
template<typename T>
|
||||
static void freeDeviceBuffer(PxCudaContextManager& cudaContextManager, T*& deviceBuffer)
|
||||
{
|
||||
if (deviceBuffer)
|
||||
{
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memFree(reinterpret_cast<CUdeviceptr>(deviceBuffer));
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "freeDeviceBuffer failed with error code %i!\n", PxI32(result));
|
||||
|
||||
deviceBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Allocates a pinned host buffer and returns the pointer to the memory
|
||||
*
|
||||
* A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the allocation should be attributed to.
|
||||
* \param[in] numElements the number of elements of type T to allocate.
|
||||
*
|
||||
* \return a pointer to the allocated memory.
|
||||
*/
|
||||
template<typename T>
|
||||
static T* allocPinnedHostBuffer(PxCudaContextManager& cudaContextManager, PxU64 numElements)
|
||||
{
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
|
||||
void* ptr = NULL;
|
||||
const unsigned int cuMemhostallocDevicemap = 0x02;
|
||||
const unsigned int cuMemhostallocPortable = 0x01;
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memHostAlloc(&ptr, numElements * sizeof(T), cuMemhostallocDevicemap | cuMemhostallocPortable);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "allocPinnedHostBuffer failed with error code %i!\n", PxI32(result));
|
||||
|
||||
return reinterpret_cast<T*>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Frees a pinned host buffer
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the pinned memory buffer is attributed to.
|
||||
* \param[in] pinnedHostBuffer reference to a pointer pointing to the pinned memory buffer.
|
||||
*/
|
||||
template<typename T>
|
||||
static void freePinnedHostBuffer(PxCudaContextManager& cudaContextManager, T*& pinnedHostBuffer)
|
||||
{
|
||||
if (pinnedHostBuffer)
|
||||
{
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memFreeHost(pinnedHostBuffer);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "freePinnedHostBuffer failed with error code %i!\n", PxI32(result));
|
||||
|
||||
pinnedHostBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Copies a device buffer to the host
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] hostBuffer pointer to the destination (pinned) host memory buffer.
|
||||
* \param[in] deviceBuffer pointer to the source device buffer.
|
||||
* \param[in] numElements the number of elements of type T to copy.
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToH(PxCudaContextManager& cudaContextManager, T* hostBuffer, const T* deviceBuffer, PxU64 numElements)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memcpyDtoH(hostBuffer, CUdeviceptr(deviceBuffer), numBytes);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDToH failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Copies a host buffer to the device
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] deviceBuffer pointer to the destination device buffer.
|
||||
* \param[in] hostBuffer pointer to the source (pinned) host memory buffer.
|
||||
* \param[in] numElements the number of elements of type T to copy.
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToD(PxCudaContextManager& cudaContextManager, T* deviceBuffer, const T* hostBuffer, PxU64 numElements)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memcpyHtoD(CUdeviceptr(deviceBuffer), hostBuffer, numBytes);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyHtoD failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to host copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] hostBuffer pointer to the destination (pinned) host memory buffer.
|
||||
* \param[in] deviceBuffer pointer to the source device buffer.
|
||||
* \param[in] numElements the number of elements of type T to copy.
|
||||
* \param[in] stream the CUDA stream to perform the operation on.
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToHAsync(PxCudaContextManager& cudaContextManager, T* hostBuffer, const T* deviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memcpyDtoHAsync(hostBuffer, CUdeviceptr(deviceBuffer), numBytes, stream);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDtoHAsync failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules host to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] deviceBuffer pointer to the destination device buffer.
|
||||
* \param[in] hostBuffer pointer to the source (pinned) host memory buffer.
|
||||
* \param[in] numElements the number of elements of type T to copy.
|
||||
* \param[in] stream the CUDA stream to perform the operation on.
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToDAsync(PxCudaContextManager& cudaContextManager, T* deviceBuffer, const T* hostBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memcpyHtoDAsync(CUdeviceptr(deviceBuffer), hostBuffer, numBytes, stream);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyHtoDAsync failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] dstDeviceBuffer pointer to the destination device buffer.
|
||||
* \param[in] srcDeviceBuffer pointer to the source device buffer.
|
||||
* \param[in] numElements the number of elements of type T to copy.
|
||||
* \param[in] stream the CUDA stream to perform the operation on.
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToDAsync(PxCudaContextManager& cudaContextManager, T* dstDeviceBuffer, const T* srcDeviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!srcDeviceBuffer || !dstDeviceBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memcpyDtoDAsync(CUdeviceptr(dstDeviceBuffer), CUdeviceptr(srcDeviceBuffer), numBytes, stream);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDtoDAsync failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules a memset operation on the device on the specified stream. Only supported for 1 bytes or 4 byte data types.
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*
|
||||
* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
|
||||
* \param[in] dstDeviceBuffer pointer to the destination device buffer.
|
||||
* \param[in] value the value to set the memory to.
|
||||
* \param[in] numElements the number of elements of type T to set.
|
||||
* \param[in] stream the CUDA stream to perform the operation on.
|
||||
*/
|
||||
template<typename T>
|
||||
static void memsetAsync(PxCudaContextManager& cudaContextManager, T* dstDeviceBuffer, const T& value, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PX_COMPILE_TIME_ASSERT(sizeof(T) == sizeof(PxU32) || sizeof(T) == sizeof(PxU8));
|
||||
|
||||
if (!dstDeviceBuffer)
|
||||
return;
|
||||
|
||||
PxScopedCudaLock lock(cudaContextManager);
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
if (sizeof(T) == sizeof(PxU32))
|
||||
{
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memsetD32Async(CUdeviceptr(dstDeviceBuffer), reinterpret_cast<const PxU32&>(value), numBytes >> 2, stream);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "memsetAsync failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
PxCUresult result = cudaContextManager.getCudaContext()->memsetD8Async(CUdeviceptr(dstDeviceBuffer), reinterpret_cast<const PxU8&>(value), numBytes, stream);
|
||||
if (result != 0)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "memsetAsync failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define PX_EXT_DEVICE_MEMORY_ALLOC(T, cudaContextManager, numElements) physx::Ext::PxCudaHelpersExt::allocDeviceBuffer<T>(cudaContextManager, numElements)
|
||||
#define PX_EXT_DEVICE_MEMORY_FREE(cudaContextManager, deviceBuffer) physx::Ext::PxCudaHelpersExt::freeDeviceBuffer(cudaContextManager, deviceBuffer);
|
||||
|
||||
#define PX_EXT_PINNED_MEMORY_ALLOC(T, cudaContextManager, numElements) physx::Ext::PxCudaHelpersExt::allocPinnedHostBuffer<T>(cudaContextManager, numElements)
|
||||
#define PX_EXT_PINNED_MEMORY_FREE(cudaContextManager, pinnedHostBuffer) physx::Ext::PxCudaHelpersExt::freePinnedHostBuffer(cudaContextManager, pinnedHostBuffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
221
engine/third_party/physx/include/extensions/PxCustomGeometryExt.h
vendored
Normal file
221
engine/third_party/physx/include/extensions/PxCustomGeometryExt.h
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
// 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-2025 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_CUSTOM_GEOMETRY_EXT_H
|
||||
#define PX_CUSTOM_GEOMETRY_EXT_H
|
||||
|
||||
#include "geometry/PxCustomGeometry.h"
|
||||
#include "geometry/PxGjkQuery.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGeometry;
|
||||
class PxMassProperties;
|
||||
class PxGeometryHolder;
|
||||
struct PxContactPoint;
|
||||
|
||||
/**
|
||||
\brief Pre-made custom geometry callbacks implementations.
|
||||
*/
|
||||
class PxCustomGeometryExt
|
||||
{
|
||||
public:
|
||||
|
||||
/// \cond PRIVATE
|
||||
struct BaseConvexCallbacks : PxCustomGeometry::Callbacks, PxGjkQuery::Support
|
||||
{
|
||||
BaseConvexCallbacks(float _margin) : margin(_margin) {}
|
||||
|
||||
// override PxCustomGeometry::Callbacks
|
||||
virtual PxBounds3 getLocalBounds(const PxGeometry& geometry) const;
|
||||
virtual bool generateContacts(const PxGeometry& geom0, const PxGeometry& geom1, const PxTransform& pose0, const PxTransform& pose1,
|
||||
const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength,
|
||||
PxContactBuffer& contactBuffer) const;
|
||||
virtual PxU32 raycast(const PxVec3& origin, const PxVec3& unitDir, const PxGeometry& geom, const PxTransform& pose,
|
||||
PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit* rayHits, PxU32 stride, PxRaycastThreadContext*) const;
|
||||
virtual bool overlap(const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext*) const;
|
||||
virtual bool sweep(const PxVec3& unitDir, const PxReal maxDist,
|
||||
const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1,
|
||||
PxGeomSweepHit& sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext*) const;
|
||||
virtual bool usePersistentContactManifold(const PxGeometry& geometry, PxReal& breakingThreshold) const;
|
||||
|
||||
// override PxGjkQuery::Support
|
||||
virtual PxReal getMargin() const { return margin; }
|
||||
// set margin
|
||||
void setMargin(float m);
|
||||
|
||||
protected:
|
||||
|
||||
// Shape margin
|
||||
float margin;
|
||||
|
||||
// Substitute geometry
|
||||
virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const = 0;
|
||||
};
|
||||
/// \endcond
|
||||
|
||||
/**
|
||||
\brief Cylinder geometry callbacks
|
||||
*/
|
||||
struct CylinderCallbacks : BaseConvexCallbacks
|
||||
{
|
||||
/**
|
||||
\brief Construct cylinder geometry callbacks object
|
||||
|
||||
\param[in] height The cylinder height.
|
||||
\param[in] radius The cylinder radius.
|
||||
\param[in] axis The cylinder axis (0 - X, 1 - Y, 2 - Z).
|
||||
\param[in] margin The cylinder margin.
|
||||
*/
|
||||
CylinderCallbacks(float height, float radius, int axis = 0, float margin = 0);
|
||||
|
||||
/// \brief Set cylinder height
|
||||
/// \param[in] h The cylinder height
|
||||
void setHeight(float h);
|
||||
/// \brief Get cylinder height
|
||||
/// \return The cylinder height
|
||||
float getHeight() const { return height; }
|
||||
|
||||
/// \brief Set cylinder radius
|
||||
/// \param[in] r The cylinder radius.
|
||||
void setRadius(float r);
|
||||
/// \brief Get cylinder radius
|
||||
/// \return The cylinder radius
|
||||
float getRadius() const { return radius; }
|
||||
|
||||
/// \brief Set cylinder axis
|
||||
/// \param[in] a The cylinder axis (0 - X, 1 - Y, 2 - Z).
|
||||
void setAxis(int a);
|
||||
/// \brief Get cylinder axis
|
||||
/// \return The cylinder axis
|
||||
int getAxis() const { return axis; }
|
||||
|
||||
/// \cond PRIVATE
|
||||
// override PxCustomGeometry::Callbacks
|
||||
DECLARE_CUSTOM_GEOMETRY_TYPE
|
||||
virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const;
|
||||
virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const;
|
||||
|
||||
// override PxGjkQuery::Support
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const;
|
||||
|
||||
protected:
|
||||
|
||||
// Cylinder height
|
||||
float height;
|
||||
// Cylinder radius
|
||||
float radius;
|
||||
// Cylinder axis
|
||||
int axis;
|
||||
|
||||
// Substitute geometry
|
||||
virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const;
|
||||
|
||||
// Radius at height
|
||||
float getRadiusAtHeight(float height) const;
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Cone geometry callbacks
|
||||
*/
|
||||
struct ConeCallbacks : BaseConvexCallbacks
|
||||
{
|
||||
/**
|
||||
\brief Construct cone geometry callbacks object
|
||||
|
||||
\param[in] height The cylinder height.
|
||||
\param[in] radius The cylinder radius.
|
||||
\param[in] axis The cylinder axis (0 - X, 1 - Y, 2 - Z).
|
||||
\param[in] margin The cylinder margin.
|
||||
*/
|
||||
ConeCallbacks(float height, float radius, int axis = 0, float margin = 0);
|
||||
|
||||
/// \brief Set cone height
|
||||
/// \param[in] h The cone height
|
||||
void setHeight(float h);
|
||||
/// \brief Get cone height
|
||||
/// \return The cone height
|
||||
float getHeight() const { return height; }
|
||||
|
||||
/// \brief Set cone radius
|
||||
/// \param[in] r The cone radius
|
||||
void setRadius(float r);
|
||||
/// \brief Get cone radius
|
||||
/// \return The cone radius
|
||||
float getRadius() const { return radius; }
|
||||
|
||||
/// \brief Set cone axis
|
||||
/// \param[in] a The cone axis
|
||||
void setAxis(int a);
|
||||
/// \brief Get cone axis
|
||||
/// \return The cone axis
|
||||
int getAxis() const { return axis; }
|
||||
|
||||
/// \cond PRIVATE
|
||||
// override PxCustomGeometry::Callbacks
|
||||
DECLARE_CUSTOM_GEOMETRY_TYPE
|
||||
virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const;
|
||||
virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const;
|
||||
|
||||
// override PxGjkQuery::Support
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const;
|
||||
|
||||
protected:
|
||||
|
||||
// Cone height
|
||||
float height;
|
||||
// Cone radius
|
||||
float radius;
|
||||
// Cone axis
|
||||
int axis;
|
||||
|
||||
// Substitute geometry
|
||||
virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const;
|
||||
|
||||
// Radius at height
|
||||
float getRadiusAtHeight(float height) const;
|
||||
/// \endcond
|
||||
};
|
||||
};
|
||||
|
||||
/// \cond PRIVATE
|
||||
// OmniPVD friendly aliases
|
||||
typedef PxCustomGeometryExt::BaseConvexCallbacks PxCustomGeometryExtBaseConvexCallbacks;
|
||||
typedef PxCustomGeometryExt::CylinderCallbacks PxCustomGeometryExtCylinderCallbacks;
|
||||
typedef PxCustomGeometryExt::ConeCallbacks PxCustomGeometryExtConeCallbacks;
|
||||
/// \endcond
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
187
engine/third_party/physx/include/extensions/PxCustomSceneQuerySystem.h
vendored
Normal file
187
engine/third_party/physx/include/extensions/PxCustomSceneQuerySystem.h
vendored
Normal file
@@ -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-2025 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_NEW_SCENE_QUERY_SYSTEM_H
|
||||
#define PX_NEW_SCENE_QUERY_SYSTEM_H
|
||||
|
||||
#include "PxSceneQuerySystem.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A custom scene query system.
|
||||
|
||||
This is an example of a custom scene query system. It augments the PxSceneQuerySystem API to support an arbitrary number
|
||||
of "pruners", instead of the usual hardcoded two.
|
||||
|
||||
It might not be possible to support the whole PxSceneQuerySystem API in this context. See the source code for details.
|
||||
|
||||
\see PxSceneQuerySystem
|
||||
*/
|
||||
class PxCustomSceneQuerySystem : public PxSceneQuerySystem
|
||||
{
|
||||
public:
|
||||
PxCustomSceneQuerySystem() {}
|
||||
virtual ~PxCustomSceneQuerySystem() {}
|
||||
|
||||
/**
|
||||
\brief Adds a pruner to the system.
|
||||
|
||||
The internal PhysX scene-query system uses two regular pruners (one for static shapes, one for dynamic shapes) and an optional
|
||||
compound pruner. Our custom scene query system supports an arbitrary number of regular pruners.
|
||||
|
||||
This can be useful to reduce the load on each pruner, in particular during updates, when internal trees are rebuilt in the
|
||||
background. On the other hand this implementation simply iterates over all created pruners to perform queries, so their cost
|
||||
might increase if a large number of pruners is used.
|
||||
|
||||
In any case this serves as an example of how the PxSceneQuerySystem API can be used to customize scene queries.
|
||||
|
||||
\param[in] primaryType Desired primary (main) type for the new pruner
|
||||
\param[in] secondaryType Secondary type when primary type is PxPruningStructureType::eDYNAMIC_AABB_TREE.
|
||||
\param[in] preallocated Optional number of preallocated shapes in the new pruner
|
||||
|
||||
\return A pruner index
|
||||
|
||||
\see PxCustomSceneQuerySystem PxSceneQueryUpdateMode PxCustomSceneQuerySystemAdapter PxSceneDesc::sceneQuerySystem
|
||||
*/
|
||||
virtual PxU32 addPruner(PxPruningStructureType::Enum primaryType, PxDynamicTreeSecondaryPruner::Enum secondaryType, PxU32 preallocated=0) = 0;
|
||||
|
||||
/**
|
||||
\brief Start custom build-steps for all pruners
|
||||
|
||||
This function is used in combination with customBuildstep() and finishCustomBuildstep() to let users take control
|
||||
of the pruners' build-step & commit calls - basically the pruners' update functions. These functions should be used
|
||||
with the PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED update mode, otherwise the build-steps will happen
|
||||
automatically in fetchResults. For N pruners it can be more efficient to use these custom build-step functions to
|
||||
perform the updates in parallel:
|
||||
|
||||
- call startCustomBuildstep() first (one synchronous call)
|
||||
- for each pruner, call customBuildstep() (asynchronous calls from multiple threads)
|
||||
- once it is done, call finishCustomBuildstep() to finish the update (synchronous call)
|
||||
|
||||
The multi-threaded update is more efficient here than what it is in PxScene, because the "flushShapes()" call is
|
||||
also multi-threaded (while it is not in PxScene).
|
||||
|
||||
Note that users are responsible for locks here, and these calls should not overlap with other SQ calls. In particular
|
||||
one should not add new objects to the SQ system or perform queries while these calls are happening.
|
||||
|
||||
\return The number of pruners in the system.
|
||||
|
||||
\see customBuildstep finishCustomBuildstep PxSceneQueryUpdateMode
|
||||
*/
|
||||
virtual PxU32 startCustomBuildstep() = 0;
|
||||
|
||||
/**
|
||||
\brief Perform a custom build-step for a given pruner.
|
||||
|
||||
\param[in] index Pruner index (should be between 0 and the number returned by startCustomBuildstep)
|
||||
|
||||
\see startCustomBuildstep finishCustomBuildstep
|
||||
*/
|
||||
virtual void customBuildstep(PxU32 index) = 0;
|
||||
|
||||
/**
|
||||
\brief Finish custom build-steps
|
||||
|
||||
Call this function once after all the customBuildstep() calls are done.
|
||||
|
||||
\see startCustomBuildstep customBuildstep
|
||||
*/
|
||||
virtual void finishCustomBuildstep() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief An adapter class to customize the object-to-pruner mapping.
|
||||
|
||||
In the regular PhysX code static shapes went to the static pruner, and dynamic shapes went to the
|
||||
dynamic pruner.
|
||||
|
||||
This class is a replacement for this mapping when N user-defined pruners are involved.
|
||||
*/
|
||||
class PxCustomSceneQuerySystemAdapter
|
||||
{
|
||||
public:
|
||||
PxCustomSceneQuerySystemAdapter() {}
|
||||
virtual ~PxCustomSceneQuerySystemAdapter() {}
|
||||
|
||||
/**
|
||||
\brief Gets a pruner index for an actor/shape.
|
||||
|
||||
This user-defined function tells the system in which pruner a given actor/shape should go.
|
||||
|
||||
\note The returned index must be valid, i.e. it must have been previously returned to users by PxCustomSceneQuerySystem::addPruner.
|
||||
|
||||
\param[in] actor The actor
|
||||
\param[in] shape The shape
|
||||
|
||||
\return A pruner index for this actor/shape.
|
||||
|
||||
\see PxRigidActor PxShape PxCustomSceneQuerySystem::addPruner
|
||||
*/
|
||||
virtual PxU32 getPrunerIndex(const PxRigidActor& actor, const PxShape& shape) const = 0;
|
||||
|
||||
/**
|
||||
\brief Pruner filtering callback.
|
||||
|
||||
This will be called for each query to validate whether it should process a given pruner.
|
||||
|
||||
\param[in] prunerIndex The index of currently processed pruner
|
||||
\param[in] context The query context
|
||||
\param[in] filterData The query's filter data
|
||||
\param[in] filterCall The query's filter callback
|
||||
|
||||
\return True to process the pruner, false to skip it entirely
|
||||
*/
|
||||
virtual bool processPruner(PxU32 prunerIndex, const PxQueryThreadContext* context, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Creates a custom scene query system.
|
||||
|
||||
This is similar to PxCreateExternalSceneQuerySystem, except this function creates a PxCustomSceneQuerySystem object.
|
||||
It can be plugged to PxScene the same way, via PxSceneDesc::sceneQuerySystem.
|
||||
|
||||
\param[in] sceneQueryUpdateMode Desired update mode
|
||||
\param[in] contextID Context ID parameter, sent to the profiler
|
||||
\param[in] adapter Adapter class implementing our extended API
|
||||
\param[in] usesTreeOfPruners True to keep pruners themselves in a BVH, which might increase query performance if a lot of pruners are involved
|
||||
|
||||
\return A custom SQ system instance
|
||||
|
||||
\see PxCustomSceneQuerySystem PxSceneQueryUpdateMode PxCustomSceneQuerySystemAdapter PxSceneDesc::sceneQuerySystem
|
||||
*/
|
||||
PxCustomSceneQuerySystem* PxCreateCustomSceneQuerySystem(PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode, PxU64 contextID, const PxCustomSceneQuerySystemAdapter& adapter, bool usesTreeOfPruners=false);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
632
engine/third_party/physx/include/extensions/PxD6Joint.h
vendored
Normal file
632
engine/third_party/physx/include/extensions/PxD6Joint.h
vendored
Normal file
@@ -0,0 +1,632 @@
|
||||
// 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-2025 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_D6_JOINT_H
|
||||
#define PX_D6_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
#include "extensions/PxJointLimit.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxD6Joint;
|
||||
|
||||
/**
|
||||
\brief Create a D6 joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
PxD6Joint* PxD6JointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
/**
|
||||
\brief Used to specify one of the degrees of freedom of a D6 joint.
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
struct PxD6Axis
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eX = 0, //!< motion along the X axis
|
||||
eY = 1, //!< motion along the Y axis
|
||||
eZ = 2, //!< motion along the Z axis
|
||||
eTWIST = 3, //!< motion around the X axis
|
||||
eSWING1 = 4, //!< motion around the Y axis
|
||||
eSWING2 = 5, //!< motion around the Z axis
|
||||
eCOUNT = 6
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Used to specify the range of motions allowed for a degree of freedom in a D6 joint.
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
struct PxD6Motion
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLOCKED, //!< The DOF is locked, it does not allow relative motion.
|
||||
eLIMITED, //!< The DOF is limited, it only allows motion within a specific range.
|
||||
eFREE //!< The DOF is free and has its full range of motion.
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief The configuration to use for driving to the angular component of a target pose or velocity.
|
||||
|
||||
\see PxD6Joint::setAngularDriveConfig() PxD6Drive PxD6Joint::setDrive()
|
||||
*/
|
||||
struct PxD6AngularDriveConfig
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief The joint tries to reach the angular drive target by separately driving along each angular degree of freedom.
|
||||
|
||||
Each angular degree of freedom can have its own set of drive parameters. The degrees of freedom are covered by a twist and two swing axes.
|
||||
As a consequence, only the following options are available when setting the drive parameters: PxD6Drive::eSWING1, PxD6Drive::eSWING2,
|
||||
PxD6Drive::eTWIST (see #PxD6Joint::setDrive()).
|
||||
*/
|
||||
eSWING_TWIST,
|
||||
|
||||
/**
|
||||
\brief The joint tries to reach the angular drive target by following a spherical linear interpolation (SLERP) based path.
|
||||
|
||||
A single set of drive parameters will be used for all angular degrees of freedom and PxD6Drive::eSLERP is the only valid option to set
|
||||
those parameters (see #PxD6Joint::setDrive()).
|
||||
*/
|
||||
eSLERP,
|
||||
|
||||
/**
|
||||
\deprecated
|
||||
|
||||
\brief Legacy mode that uses a precedence system to either use the slerp or swing/twist angular drive model.
|
||||
|
||||
\note In this config it is not possible to set separate drive parameters for the two swing axes.
|
||||
|
||||
For compatibility with previous versions of PhysX, drive parameters for PxD6Drive::eTWIST, PxD6Drive::eSWING and PxD6Drive::eSLERP
|
||||
can be set alltogether with ::eSLERP taking precedence (see #PxD6Joint::setDrive()). Use of PxD6Drive::eSWING1 and PxD6Drive::eSWING2
|
||||
is not allowed.
|
||||
*/
|
||||
eLEGACY PX_DEPRECATED
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Used to specify which axes of a D6 joint are driven.
|
||||
|
||||
Each drive is an implicit force-limited damped spring:
|
||||
|
||||
force = spring * (target position - position) + damping * (targetVelocity - velocity)
|
||||
|
||||
Alternatively, the spring may be configured to generate a specified acceleration instead of a force.
|
||||
|
||||
A linear axis is affected by drive only if the corresponding drive flag is set. There are two possible models
|
||||
for angular drive: swing/twist, which may be used to drive one or more angular degrees of freedom, or slerp,
|
||||
which may only be used to drive all three angular degrees simultaneously. Please use #PxD6AngularDriveConfig
|
||||
to configure the angular drive model.
|
||||
|
||||
\see PxD6Joint PxD6AngularDriveConfig
|
||||
*/
|
||||
struct PxD6Drive
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eX = 0, //!< drive along the X-axis
|
||||
eY = 1, //!< drive along the Y-axis
|
||||
eZ = 2, //!< drive along the Z-axis
|
||||
|
||||
/**
|
||||
\deprecated
|
||||
|
||||
\brief rotational drive around the Y- and Z-axis
|
||||
|
||||
\note Only allowed if the angular drive configuration is set to PxD6AngularDriveConfig::eLEGACY.
|
||||
*/
|
||||
eSWING PX_DEPRECATED = 3,
|
||||
|
||||
/**
|
||||
\brief rotational drive around the X-axis
|
||||
|
||||
\note Only allowed if the angular drive configuration is set to PxD6AngularDriveConfig::eLEGACY or
|
||||
PxD6AngularDriveConfig::eSWING_TWIST.
|
||||
*/
|
||||
eTWIST = 4,
|
||||
|
||||
/**
|
||||
\brief drive of all three angular degrees along a SLERP-path
|
||||
|
||||
\note Only allowed if the angular drive configuration is set to PxD6AngularDriveConfig::eSLERP or
|
||||
PxD6AngularDriveConfig::eLEGACY.
|
||||
|
||||
\note If the angular drive configuration is set to PxD6AngularDriveConfig::eLEGACY, then eSLERP takes
|
||||
precedence over eSWING/eTWIST
|
||||
*/
|
||||
eSLERP = 5,
|
||||
|
||||
/**
|
||||
\brief rotational drive around the Y-axis
|
||||
|
||||
\note Only allowed if the angular drive configuration is set to PxD6AngularDriveConfig::eSWING_TWIST.
|
||||
*/
|
||||
eSWING1 = 6,
|
||||
|
||||
/**
|
||||
\brief rotational drive around the Z-axis
|
||||
|
||||
\note Only allowed if the angular drive configuration is set to PxD6AngularDriveConfig::eSWING_TWIST.
|
||||
*/
|
||||
eSWING2 = 7,
|
||||
|
||||
eCOUNT = 8
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief flags for configuring the drive model of a PxD6Joint
|
||||
|
||||
\see PxD6JointDrive PxD6Joint
|
||||
*/
|
||||
struct PxD6JointDriveFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eACCELERATION = (1 << 0), //!< drive spring is for the acceleration at the joint (rather than the force)
|
||||
|
||||
/**
|
||||
\brief Add drive force/torque to the joint force/torque total.
|
||||
|
||||
If this flag is raised, the force/torque value from this drive constraint will be accumulated
|
||||
in the force/torque total that is reported for the underlying PxConstraint object. Note that
|
||||
because the force/torque total changes, the joint break behavior will change too.
|
||||
|
||||
<b>Default:</b> False
|
||||
|
||||
\see PxConstraint::getForce()
|
||||
*/
|
||||
eOUTPUT_FORCE = (1 << 1)
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxD6JointDriveFlag::Enum, PxU32> PxD6JointDriveFlags;
|
||||
PX_FLAGS_OPERATORS(PxD6JointDriveFlag::Enum, PxU32)
|
||||
|
||||
/**
|
||||
\brief parameters for configuring the drive model of a PxD6Joint
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
class PxD6JointDrive : public PxSpring
|
||||
{
|
||||
public:
|
||||
PxReal forceLimit; //!< the force limit of the drive - may be an impulse or a force depending on PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES
|
||||
PxD6JointDriveFlags flags; //!< the joint drive flags
|
||||
|
||||
/**
|
||||
\brief default constructor for PxD6JointDrive.
|
||||
*/
|
||||
PxD6JointDrive(): PxSpring(0,0), forceLimit(PX_MAX_F32), flags(0) {}
|
||||
|
||||
/**
|
||||
\brief constructor a PxD6JointDrive.
|
||||
|
||||
\param[in] driveStiffness The stiffness of the drive spring.
|
||||
\param[in] driveDamping The damping of the drive spring
|
||||
\param[in] driveForceLimit The maximum impulse or force that can be exerted by the drive
|
||||
\param[in] isAcceleration Whether the drive is an acceleration drive or a force drive
|
||||
*/
|
||||
PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration = false)
|
||||
: PxSpring(driveStiffness, driveDamping)
|
||||
, forceLimit(driveForceLimit)
|
||||
, flags(isAcceleration?PxU32(PxD6JointDriveFlag::eACCELERATION) : 0)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief returns true if the drive is valid
|
||||
*/
|
||||
bool isValid() const
|
||||
{
|
||||
return PxIsFinite(stiffness) && stiffness>=0 &&
|
||||
PxIsFinite(damping) && damping >=0 &&
|
||||
PxIsFinite(forceLimit) && forceLimit >=0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief A D6 joint is a general constraint between two actors.
|
||||
|
||||
It allows the application to individually define the linear and rotational degrees of freedom,
|
||||
and also to configure a variety of limits and driven degrees of freedom.
|
||||
|
||||
By default all degrees of freedom are locked. So to create a prismatic joint with free motion
|
||||
along the x-axis:
|
||||
|
||||
\code
|
||||
...
|
||||
joint->setMotion(PxD6Axis::eX, PxD6JointMotion::eFREE);
|
||||
...
|
||||
\endcode
|
||||
|
||||
Or a Revolute joint with motion free allowed around the x-axis:
|
||||
|
||||
\code
|
||||
...
|
||||
joint->setMotion(PxD6Axis::eTWIST, PxD6JointMotion::eFREE);
|
||||
...
|
||||
\endcode
|
||||
|
||||
Degrees of freedom may also be set to limited instead of locked.
|
||||
|
||||
There are two different kinds of linear limits available. The first kind is a single limit value
|
||||
for all linear degrees of freedom, which may act as a linear, circular, or spherical limit depending
|
||||
on which degrees of freedom are limited. This is similar to a distance limit. Then, the second kind
|
||||
supports a pair of limit values for each linear axis, which can be used to implement a traditional
|
||||
prismatic joint for example.
|
||||
|
||||
If the twist degree of freedom is limited, is supports upper and lower limits. The two swing degrees
|
||||
of freedom are limited with a cone limit.
|
||||
\see PxD6JointCreate() PxJoint
|
||||
*/
|
||||
class PxD6Joint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Set the motion type around the specified axis.
|
||||
|
||||
Each axis may independently specify that the degree of freedom is locked (blocking relative movement
|
||||
along or around this axis), limited by the corresponding limit, or free.
|
||||
|
||||
\param[in] axis the axis around which motion is specified
|
||||
\param[in] type the motion type around the specified axis
|
||||
|
||||
<b>Default:</b> all degrees of freedom are locked
|
||||
|
||||
\see getMotion() PxD6Axis PxD6Motion
|
||||
*/
|
||||
virtual void setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the motion type around the specified axis.
|
||||
|
||||
\see setMotion() PxD6Axis PxD6Motion
|
||||
|
||||
\param[in] axis the degree of freedom around which the motion type is specified
|
||||
\return the motion type around the specified axis
|
||||
*/
|
||||
virtual PxD6Motion::Enum getMotion(PxD6Axis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief get the twist angle of the joint, in the range (-2*Pi, 2*Pi]
|
||||
*/
|
||||
virtual PxReal getTwistAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief get the twist angle of the joint
|
||||
|
||||
\deprecated Use getTwistAngle instead. Deprecated since PhysX version 4.0
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE PxReal getTwist() const { return getTwistAngle(); }
|
||||
|
||||
/**
|
||||
\brief get the swing angle of the joint from the Y axis
|
||||
*/
|
||||
virtual PxReal getSwingYAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief get the swing angle of the joint from the Z axis
|
||||
*/
|
||||
virtual PxReal getSwingZAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the distance limit for the joint.
|
||||
|
||||
A single limit constraints all linear limited degrees of freedom, forming a linear, circular
|
||||
or spherical constraint on motion depending on the number of limited degrees. This is similar
|
||||
to a distance limit.
|
||||
|
||||
\param[in] limit the distance limit structure
|
||||
|
||||
\see getDistanceLimit() PxJointLinearLimit
|
||||
*/
|
||||
virtual void setDistanceLimit(const PxJointLinearLimit& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the distance limit for the joint.
|
||||
|
||||
\return the distance limit structure
|
||||
|
||||
\see setDistanceLimit() PxJointLinearLimit
|
||||
*/
|
||||
virtual PxJointLinearLimit getDistanceLimit() const = 0;
|
||||
|
||||
/**
|
||||
\deprecated Use setDistanceLimit instead. Deprecated since PhysX version 4.0
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE void setLinearLimit(const PxJointLinearLimit& limit) { setDistanceLimit(limit); }
|
||||
|
||||
/**
|
||||
\deprecated Use getDistanceLimit instead. Deprecated since PhysX version 4.0
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE PxJointLinearLimit getLinearLimit() const { return getDistanceLimit(); }
|
||||
|
||||
/**
|
||||
\brief Set the linear limit for a given linear axis.
|
||||
|
||||
This function extends the previous setDistanceLimit call with the following features:
|
||||
- there can be a different limit for each linear axis
|
||||
- each limit is defined by two values, i.e. it can now be asymmetric
|
||||
|
||||
This can be used to create prismatic joints similar to PxPrismaticJoint, or point-in-quad joints,
|
||||
or point-in-box joints.
|
||||
|
||||
\param[in] axis The limited linear axis (must be PxD6Axis::eX, PxD6Axis::eY or PxD6Axis::eZ)
|
||||
\param[in] limit The linear limit pair structure
|
||||
|
||||
\see getLinearLimit()
|
||||
*/
|
||||
virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the linear limit for a given linear axis.
|
||||
|
||||
\param[in] axis The limited linear axis (must be PxD6Axis::eX, PxD6Axis::eY or PxD6Axis::eZ)
|
||||
|
||||
\return the linear limit pair structure from desired axis
|
||||
|
||||
\see setLinearLimit() PxJointLinearLimit
|
||||
*/
|
||||
virtual PxJointLinearLimitPair getLinearLimit(PxD6Axis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the twist limit for the joint.
|
||||
|
||||
The twist limit controls the range of motion around the twist axis.
|
||||
|
||||
The limit angle range is (-2*Pi, 2*Pi).
|
||||
|
||||
\param[in] limit the twist limit structure
|
||||
|
||||
\see getTwistLimit() PxJointAngularLimitPair
|
||||
*/
|
||||
virtual void setTwistLimit(const PxJointAngularLimitPair& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the twist limit for the joint.
|
||||
|
||||
\return the twist limit structure
|
||||
|
||||
\see setTwistLimit() PxJointAngularLimitPair
|
||||
*/
|
||||
virtual PxJointAngularLimitPair getTwistLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the swing cone limit for the joint.
|
||||
|
||||
The cone limit is used if either or both swing axes are limited. The extents are
|
||||
symmetrical and measured in the frame of the parent. If only one swing degree of freedom
|
||||
is limited, the corresponding value from the cone limit defines the limit range.
|
||||
|
||||
\param[in] limit the cone limit structure
|
||||
|
||||
\see getLimitCone() PxJointLimitCone
|
||||
*/
|
||||
virtual void setSwingLimit(const PxJointLimitCone& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the cone limit for the joint.
|
||||
|
||||
\return the swing limit structure
|
||||
|
||||
\see setLimitCone() PxJointLimitCone
|
||||
*/
|
||||
virtual PxJointLimitCone getSwingLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set a pyramidal swing limit for the joint.
|
||||
|
||||
The pyramid limits will only be used in the following cases:
|
||||
- both swing Y and Z are limited. The limit shape is then a pyramid.
|
||||
- Y is limited and Z is locked, or vice versa. The limit shape is an asymmetric angular section, similar to
|
||||
what is supported for the twist axis.
|
||||
The remaining cases (Y limited and Z is free, or vice versa) are not supported.
|
||||
|
||||
\param[in] limit the cone limit structure
|
||||
|
||||
\see getLimitCone() PxJointLimitPyramid
|
||||
*/
|
||||
virtual void setPyramidSwingLimit(const PxJointLimitPyramid& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the pyramidal swing limit for the joint.
|
||||
|
||||
\return the swing limit structure
|
||||
|
||||
\see setLimitCone() PxJointLimitPyramid
|
||||
*/
|
||||
virtual PxJointLimitPyramid getPyramidSwingLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the drive parameters for the specified drive type.
|
||||
|
||||
\note The angular drive configuration (see #PxD6AngularDriveConfig) defines what type of
|
||||
angular drives will be accepted.
|
||||
|
||||
\param[in] index the type of drive being specified
|
||||
\param[in] drive the drive parameters
|
||||
|
||||
\see getDrive() PxD6JointDrive PxD6AngularDriveConfig
|
||||
|
||||
<b>Default</b> The default drive spring and damping values are zero, the force limit is PX_MAX_F32, and no flags are set.
|
||||
*/
|
||||
virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive& drive) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the drive parameters for the specified drive type.
|
||||
|
||||
\note The angular drive configuration (see #PxD6AngularDriveConfig) defines what type of
|
||||
angular drives will be accepted.
|
||||
|
||||
\param[in] index the specified drive type
|
||||
|
||||
\see setDrive() PxD6JointDrive PxD6AngularDriveConfig
|
||||
*/
|
||||
virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the drive goal pose
|
||||
|
||||
The goal is relative to the constraint frame of actor[0]
|
||||
|
||||
<b>Default</b> the identity transform
|
||||
|
||||
\param[in] pose The goal drive pose if positional drive is in use.
|
||||
\param[in] autowake If true and the attached actors are in a scene, this call wakes them up and increases their
|
||||
wake counters to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value.
|
||||
|
||||
\see setDrivePosition()
|
||||
*/
|
||||
virtual void setDrivePosition(const PxTransform& pose, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the drive goal pose.
|
||||
|
||||
\see getDrivePosition()
|
||||
*/
|
||||
virtual PxTransform getDrivePosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the target goal velocity for drive.
|
||||
|
||||
The velocity is measured in the constraint frame of actor[0]
|
||||
|
||||
\param[in] linear The goal velocity for linear drive
|
||||
\param[in] angular The goal velocity for angular drive
|
||||
\param[in] autowake If true and the attached actors are in a scene, this call wakes them up and increases their
|
||||
wake counters to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value.
|
||||
|
||||
\see getDriveVelocity()
|
||||
*/
|
||||
virtual void setDriveVelocity(const PxVec3& linear, const PxVec3& angular, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the target goal velocity for joint drive.
|
||||
|
||||
\param[in] linear The goal velocity for linear drive
|
||||
\param[in] angular The goal velocity for angular drive
|
||||
|
||||
\see setDriveVelocity()
|
||||
*/
|
||||
virtual void getDriveVelocity(PxVec3& linear, PxVec3& angular) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxD6Joint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxD6Joint"; }
|
||||
|
||||
protected:
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxD6Joint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxD6Joint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief Returns the GPU D6 joint index.
|
||||
|
||||
\note Only use in combination with enabled GPU dynamics and enabled direct GPU API
|
||||
(see #PxSceneFlag::eENABLE_GPU_DYNAMICS, #PxSceneFlag::eENABLE_DIRECT_GPU_API,
|
||||
#PxBroadPhaseType::eGPU)
|
||||
|
||||
\return The GPU index, or PX_INVALID_D6_JOINT_GPU_INDEX if the joint is not part of a PxScene.
|
||||
|
||||
\see PxDirectGPUAPI::getD6JointData()
|
||||
*/
|
||||
virtual PxD6JointGPUIndex getGPUIndex() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the angular drive model to apply.
|
||||
|
||||
\note The configuration will limit the allowed set of angular drive types (see #PxD6Drive) to use
|
||||
when calling #PxD6Joint::setDrive().
|
||||
|
||||
\note Changing the angular drive model, will reset all the parameters for the angular drives to
|
||||
their default values (see #PxD6Joint::setDrive() for information on the default values).
|
||||
|
||||
\param[in] config The angular drive model to apply.
|
||||
|
||||
\see PxD6AngularDriveConfig getAngularDriveConfig()
|
||||
|
||||
<b>Default</b> PxD6AngularDriveConfig::eLEGACY but will soon change to PxD6AngularDriveConfig::eSWING_TWIST
|
||||
*/
|
||||
virtual void setAngularDriveConfig(PxD6AngularDriveConfig::Enum config) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the angular drive model to apply.
|
||||
|
||||
\return The angular drive model to apply.
|
||||
|
||||
\see PxD6AngularDriveConfig setAngularDriveConfig()
|
||||
*/
|
||||
virtual PxD6AngularDriveConfig::Enum getAngularDriveConfig() const = 0;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
251
engine/third_party/physx/include/extensions/PxD6JointCreate.h
vendored
Normal file
251
engine/third_party/physx/include/extensions/PxD6JointCreate.h
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
// 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-2025 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_D6_JOINT_CREATE_H
|
||||
#define PX_D6_JOINT_CREATE_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxPhysics;
|
||||
class PxRigidActor;
|
||||
class PxJoint;
|
||||
|
||||
/**
|
||||
\brief Helper function to create a fixed joint, using either a PxD6Joint or PxFixedJoint.
|
||||
|
||||
For fixed joints it is important that the joint frames have the same orientation. This helper function uses an identity rotation for both.
|
||||
It is also important that the joint frames have an equivalent position in world space. The function does not check this, so it is up to users
|
||||
to ensure that this is the case.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxFixedJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxFixedJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Fixed(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, bool useD6);
|
||||
|
||||
/**
|
||||
\brief Helper function to create a distance joint, using either a PxD6Joint or PxDistanceJoint.
|
||||
|
||||
This helper function only supports a maximum distance constraint, because PxD6Joint does not support a minimum distance constraint (contrary
|
||||
to PxDistanceJoint).
|
||||
|
||||
The distance is computed between the joint frames' world-space positions. The joint frames' orientations are irrelevant here so the function
|
||||
sets them to identity.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] maxDist The maximum allowed distance
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxDistanceJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxDistanceJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Distance(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, float maxDist, bool useD6);
|
||||
|
||||
/**
|
||||
\brief Helper function to create a prismatic joint, using either a PxD6Joint or PxPrismaticJoint.
|
||||
|
||||
This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired translation axis.
|
||||
This orientation is computed by the function, so users only have to define the desired translation axis (typically 1;0;0 or 0;1;0 or 0;0;1).
|
||||
|
||||
The translation can be limited. Limits are enforced if minLimit<maxLimit. If minLimit=maxLimit the axis is locked. If minLimit>maxLimit the
|
||||
limits are not enforced and the axis is free. The limit values are computed relative to the position of actor0's joint frame.
|
||||
|
||||
The function creates hard limits, and uses PhysX's default contact distance parameter.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] axis The axis along which objects are allowed to move, expressed in the actors' local space
|
||||
\param[in] minLimit The minimum allowed position along the axis
|
||||
\param[in] maxLimit The maximum allowed position along the axis
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxPrismaticJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxPrismaticJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Prismatic(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float minLimit, float maxLimit, bool useD6);
|
||||
|
||||
/**
|
||||
\brief Helper function to create a revolute joint, using either a PxD6Joint or PxRevoluteJoint.
|
||||
|
||||
This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired rotation axis.
|
||||
This orientation is computed by the function, so users only have to define the desired rotation axis (typically 1;0;0 or 0;1;0 or 0;0;1).
|
||||
|
||||
The rotation can be limited. Limits are enforced if minLimit<maxLimit. If minLimit=maxLimit the axis is locked. If minLimit>maxLimit the
|
||||
limits are not enforced and the axis is free. The limit values are computed relative to the rotation of actor0's joint frame.
|
||||
|
||||
The function creates hard limits, and uses PhysX's default contact distance parameter.
|
||||
|
||||
Limits are expressed in radians. Allowed range is ]-2*PI;+2*PI[
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] axis The axis around which objects are allowed to move, expressed in the actors' local space
|
||||
\param[in] minLimit The minimum allowed rotation along the axis
|
||||
\param[in] maxLimit The maximum allowed rotation along the axis
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxRevoluteJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxRevoluteJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Revolute(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float minLimit, float maxLimit, bool useD6);
|
||||
|
||||
/**
|
||||
\brief Helper function to create a spherical joint, using either a PxD6Joint or PxSphericalJoint.
|
||||
|
||||
This function supports a cone limit shape, defined by a cone axis and two angular limit values.
|
||||
|
||||
This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired cone axis.
|
||||
This orientation is computed by the function, so users only have to define the desired cone axis (typically 1;0;0 or 0;1;0 or 0;0;1).
|
||||
|
||||
The rotations can be limited. Limits are enforced if limit1>0 and limit2>0. Otherwise the motion is free. The limit values define an ellipse,
|
||||
which is the cross-section of the cone limit shape.
|
||||
|
||||
The function creates hard limits, and uses PhysX's default contact distance parameter.
|
||||
|
||||
Limits are expressed in radians. Allowed range is ]0;PI[. Limits are symmetric around the cone axis.
|
||||
|
||||
The cone axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] axis The cone axis, expressed in the actors' local space
|
||||
\param[in] limit1 Max angular limit for the ellipse along the joint frame's second axis (first axis = cone axis)
|
||||
\param[in] limit2 Max angular limit for the ellipse along the joint frame's third axis (first axis = cone axis)
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxSphericalJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxSphericalJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Spherical(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float limit1, float limit2, bool useD6);
|
||||
|
||||
/**
|
||||
\brief Helper function to create a spherical joint, using either a PxD6Joint or PxSphericalJoint.
|
||||
|
||||
This function supports a cone limit shape, defined by two pairs of angular limit values. This can be used to create an asymmetric cone. If the
|
||||
angular limit values are symmetric (i.e. minLimit1=-maxLimit1 and minLimit2=-maxLimit2) then the cone axis is the X axis in actor0's space.
|
||||
If the limits are not symmetric, the function rotates the cone axis accordingly so that limits remain symmetric for PhysX. If this happens,
|
||||
the initial joint frames will be different for both actors. By default minLimit1/maxLimit1 are limits around the joint's Y axis, and
|
||||
minLimit2/maxLimit2 are limits around the joint's Z axis.
|
||||
|
||||
The function creates hard limits, and uses PhysX's default contact distance parameter.
|
||||
|
||||
Limits are expressed in radians. Allowed range is ]-PI;PI[.
|
||||
|
||||
The cone axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited.
|
||||
|
||||
The returned apiroty and apirotz values can later be added to retrieved Y and Z swing angle values (from the joint), to remap
|
||||
angle values to the given input range.
|
||||
|
||||
\param[out] apiroty Amount of rotation around Y used to setup actor0's joint frame
|
||||
\param[out] apirotz Amount of rotation around Z used to setup actor0's joint frame
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] minLimit1 Min angular limit along the joint frame's second axis (first axis = cone axis)
|
||||
\param[in] maxLimit1 Max angular limit along the joint frame's second axis (first axis = cone axis)
|
||||
\param[in] minLimit2 Min angular limit along the joint frame's third axis (first axis = cone axis)
|
||||
\param[in] maxLimit2 Max angular limit along the joint frame's third axis (first axis = cone axis)
|
||||
\param[in] useD6 True to use a PxD6Joint, false to use a PxSphericalJoint;
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint PxSphericalJoint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_GenericCone(float& apiroty, float& apirotz, PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, float minLimit1, float maxLimit1, float minLimit2, float maxLimit2, bool useD6);
|
||||
|
||||
|
||||
/**
|
||||
\brief Helper function to create a D6 joint with pyramidal swing limits.
|
||||
|
||||
This function supports a pyramid limit shape, defined by two pairs of angular limit values. This can be used to create an asymmetric pyramid. If the
|
||||
angular limit values are symmetric (i.e. minLimit1=-maxLimit1 and minLimit2=-maxLimit2) then the pyramid axis is the X axis in actor0's space.
|
||||
By default minLimit1/maxLimit1 are limits around the joint's Y axis, and minLimit2/maxLimit2 are limits around the joint's Z axis.
|
||||
|
||||
The function creates hard limits, and uses PhysX's default contact distance parameter.
|
||||
|
||||
Limits are expressed in radians. Allowed range is ]-PI;PI[.
|
||||
|
||||
The pyramid axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos0 The position of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localPos1 The position of the joint relative to actor1
|
||||
\param[in] axis The pyramid axis, expressed in the actors' local space
|
||||
\param[in] minLimit1 Min angular limit along the joint frame's second axis (first axis = pyramid axis)
|
||||
\param[in] maxLimit1 Max angular limit along the joint frame's second axis (first axis = pyramid axis)
|
||||
\param[in] minLimit2 Min angular limit along the joint frame's third axis (first axis = pyramid axis)
|
||||
\param[in] maxLimit2 Max angular limit along the joint frame's third axis (first axis = pyramid axis)
|
||||
|
||||
\return The created joint.
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
PxJoint* PxD6JointCreate_Pyramid(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis,
|
||||
float minLimit1, float maxLimit1, float minLimit2, float maxLimit2);
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
111
engine/third_party/physx/include/extensions/PxDefaultAllocator.h
vendored
Normal file
111
engine/third_party/physx/include/extensions/PxDefaultAllocator.h
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
// 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-2025 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_DEFAULT_ALLOCATOR_H
|
||||
#define PX_DEFAULT_ALLOCATOR_H
|
||||
|
||||
#include "foundation/PxAllocatorCallback.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if PX_WINDOWS_FAMILY || PX_LINUX_FAMILY || PX_SWITCH
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_WINDOWS_FAMILY
|
||||
// on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation fns
|
||||
PX_FORCE_INLINE void* platformAlignedAlloc(size_t size)
|
||||
{
|
||||
return _aligned_malloc(size, 16);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void platformAlignedFree(void* ptr)
|
||||
{
|
||||
_aligned_free(ptr);
|
||||
}
|
||||
#elif PX_LINUX_FAMILY || PX_SWITCH
|
||||
PX_FORCE_INLINE void* platformAlignedAlloc(size_t size)
|
||||
{
|
||||
return ::memalign(16, size);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void platformAlignedFree(void* ptr)
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
#else
|
||||
// on all other platforms we get 16-byte alignment by default
|
||||
PX_FORCE_INLINE void* platformAlignedAlloc(size_t size)
|
||||
{
|
||||
return ::malloc(size);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void platformAlignedFree(void* ptr)
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief default implementation of the allocator interface required by the SDK
|
||||
*/
|
||||
class PxDefaultAllocator : public PxAllocatorCallback
|
||||
{
|
||||
public:
|
||||
virtual void* allocate(size_t size, const char*, const char*, int)
|
||||
{
|
||||
void* ptr = platformAlignedAlloc(size);
|
||||
PX_ASSERT((size_t(ptr) & 15)==0);
|
||||
#if PX_STOMP_ALLOCATED_MEMORY
|
||||
if(ptr != NULL)
|
||||
{
|
||||
PxMemSet(ptr, PxI32(0xcd), PxU32(size));
|
||||
}
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
virtual void deallocate(void* ptr)
|
||||
{
|
||||
platformAlignedFree(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
119
engine/third_party/physx/include/extensions/PxDefaultCpuDispatcher.h
vendored
Normal file
119
engine/third_party/physx/include/extensions/PxDefaultCpuDispatcher.h
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
// 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-2025 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_DEFAULT_CPU_DISPATCHER_H
|
||||
#define PX_DEFAULT_CPU_DISPATCHER_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "task/PxCpuDispatcher.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A default implementation for a CPU task dispatcher.
|
||||
|
||||
\see PxDefaultCpuDispatcherCreate() PxCpuDispatcher
|
||||
*/
|
||||
class PxDefaultCpuDispatcher : public PxCpuDispatcher
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Deletes the dispatcher.
|
||||
|
||||
Do not keep a reference to the deleted instance.
|
||||
|
||||
\see PxDefaultCpuDispatcherCreate()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Enables profiling at task level.
|
||||
|
||||
\note By default enabled only in profiling builds.
|
||||
|
||||
\param[in] runProfiled True if tasks should be profiled.
|
||||
*/
|
||||
virtual void setRunProfiled(bool runProfiled) = 0;
|
||||
|
||||
/**
|
||||
\brief Checks if profiling is enabled at task level.
|
||||
|
||||
\return True if tasks should be profiled.
|
||||
*/
|
||||
virtual bool getRunProfiled() const = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief If a thread ends up waiting for work it will find itself in a spin-wait loop until work becomes available.
|
||||
Three strategies are available to limit wasted cycles.
|
||||
The strategies are as follows:
|
||||
a) wait until a work task signals the end of the spin-wait period.
|
||||
b) yield the thread by providing a hint to reschedule thread execution, thereby allowing other threads to run.
|
||||
c) yield the processor by informing it that it is waiting for work and requesting it to more efficiently use compute resources.
|
||||
*/
|
||||
struct PxDefaultCpuDispatcherWaitForWorkMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eWAIT_FOR_WORK,
|
||||
eYIELD_THREAD,
|
||||
eYIELD_PROCESSOR
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Create default dispatcher, extensions SDK needs to be initialized first.
|
||||
|
||||
\param[in] numThreads Number of worker threads the dispatcher should use.
|
||||
\param[in] affinityMasks Array with affinity mask for each thread. If not defined, default masks will be used.
|
||||
\param[in] mode is the strategy employed when a busy-wait is encountered.
|
||||
\param[in] yieldProcessorCount specifies the number of times a OS-specific yield processor command will be executed
|
||||
during each cycle of a busy-wait in the event that the specified mode is eYIELD_PROCESSOR
|
||||
|
||||
\note numThreads may be zero in which case no worker thread are initialized and
|
||||
simulation tasks will be executed on the thread that calls PxScene::simulate()
|
||||
|
||||
\note yieldProcessorCount must be greater than zero if eYIELD_PROCESSOR is the chosen mode and equal to zero for all other modes.
|
||||
|
||||
\note eYIELD_THREAD and eYIELD_PROCESSOR modes will use compute resources even if the simulation is not running.
|
||||
It is left to users to keep threads inactive, if so desired, when no simulation is running.
|
||||
|
||||
\see PxDefaultCpuDispatcher
|
||||
*/
|
||||
PxDefaultCpuDispatcher* PxDefaultCpuDispatcherCreate(PxU32 numThreads, PxU32* affinityMasks = NULL, PxDefaultCpuDispatcherWaitForWorkMode::Enum mode = PxDefaultCpuDispatcherWaitForWorkMode::eWAIT_FOR_WORK, PxU32 yieldProcessorCount = 0);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
engine/third_party/physx/include/extensions/PxDefaultErrorCallback.h
vendored
Normal file
61
engine/third_party/physx/include/extensions/PxDefaultErrorCallback.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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-2025 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_DEFAULT_ERROR_CALLBACK_H
|
||||
#define PX_DEFAULT_ERROR_CALLBACK_H
|
||||
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief default implementation of the error callback
|
||||
|
||||
This class is provided in order to enable the SDK to be started with the minimum of user code. Typically an application
|
||||
will use its own error callback, and log the error to file or otherwise make it visible. Warnings and error messages from
|
||||
the SDK are usually indicative that changes are required in order for PhysX to function correctly, and should not be ignored.
|
||||
*/
|
||||
|
||||
class PxDefaultErrorCallback : public PxErrorCallback
|
||||
{
|
||||
public:
|
||||
PxDefaultErrorCallback();
|
||||
virtual ~PxDefaultErrorCallback();
|
||||
|
||||
virtual void reportError(PxErrorCode::Enum code, const char* message, const char* file, int line) PX_OVERRIDE;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
182
engine/third_party/physx/include/extensions/PxDefaultProfiler.h
vendored
Normal file
182
engine/third_party/physx/include/extensions/PxDefaultProfiler.h
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
// 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-2025 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_DEFAULT_PROFILER_H
|
||||
#define PX_DEFAULT_PROFILER_H
|
||||
|
||||
#include "foundation/PxProfiler.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief The major and minor version of the current Default Profiler file format.
|
||||
*/
|
||||
#define PX_PROFILER_VERSION_MAJOR 0
|
||||
#define PX_PROFILER_VERSION_MINOR 1
|
||||
|
||||
|
||||
/**
|
||||
\brief The various profiler data types that describe what data follows in the stream.
|
||||
*/
|
||||
struct PxDefaultProfilerDataType
|
||||
{
|
||||
enum Enum : PxU64
|
||||
{
|
||||
eTHREAD_BLOCK = 0, //!< A thread ID follows a thread tag. All data following a thread block are from this thread.
|
||||
|
||||
/*!
|
||||
A key, size and character string follows a name registration tag. Event names are only written once per thread.
|
||||
|
||||
Ensure names are global or static so the character pointer is static and does not change.
|
||||
Pointers values are used as keys to look up names. It is especially important for cross thread
|
||||
zones so the zone names can be found across threads.
|
||||
*/
|
||||
eNAME_REGISTRATION,
|
||||
|
||||
eZONE_START, //!< A PxProfilerCallback::zoneStart callback. A time tag, context and name key follows a zone start tag.
|
||||
eZONE_END, //!< A PxProfilerCallback::zoneEnd callback. A time tag, context and name key follows a zone end tag.
|
||||
eZONE_START_CROSS_THREAD, //!< A PxProfilerCallback::zoneStart callback with detached set to true indicating a cross thread zone.
|
||||
eZONE_END_CROSS_THREAD, //!< A PxProfilerCallback::zoneEnd callback with detached set to true indicating a cross thread zone.
|
||||
eVALUE_INT, //!< A PxProfilerCallback::recordData callback with an integer value.
|
||||
eVALUE_FLOAT, //!< A PxProfilerCallback::recordData callback with a floating point value.
|
||||
eFRAME //!< A PxProfilerCallback::recordFrame callback. Frames are simple markers that are identifable in the profiling tools.
|
||||
};
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerVersionInfo
|
||||
{
|
||||
PxU32 major; //!< The major version of the current file format.
|
||||
PxU32 minor; //!< The minor version of the current file format.
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerHeader
|
||||
{
|
||||
PxDefaultProfilerDataType::Enum type; //!< The type of event or data that follows this header. See PxDefaultProfilerDataType.
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerThread
|
||||
{
|
||||
PxU64 threadId; //!< The thread identifier for all of the data that follows.
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerName
|
||||
{
|
||||
PxU64 key; //!< The key to the profiler name. Used to store the name in a map for quick look ups. It is also the pointer to the character string.
|
||||
PxU32 size; //!< Byte size of the null terminated string that follows the PxDefaultProfilerName entry in the stream. Note that due to padding the size can be larger than the string size itself.
|
||||
|
||||
/// @cond
|
||||
PxU32 padding;
|
||||
/// @endcond
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerEvent
|
||||
{
|
||||
PxU64 time; //!< The time the event was received, in tens of nano seconds.
|
||||
PxU64 contextId; //!< The context sent with the event. User controlled data to associate with the event.
|
||||
PxU64 nameKey; //!< The key to look up the name at a later time so strings are not stored with every event.
|
||||
};
|
||||
|
||||
struct PxDefaultProfilerValueEvent : public PxDefaultProfilerEvent
|
||||
{
|
||||
union
|
||||
{
|
||||
PxI32 intValue; //!< Either integer or float data that is to be graphed.
|
||||
PxF32 floatValue; //!< Either integer or float data that is to be graphed.
|
||||
};
|
||||
|
||||
/// @cond
|
||||
PxU32 padding;
|
||||
/// @endcond
|
||||
};
|
||||
|
||||
class PxOutputStream;
|
||||
|
||||
/**
|
||||
|
||||
\brief Default implementation of PxProfilerCallback to record profiling events.
|
||||
|
||||
The profiling events are stored in a memory buffer which gets flushed to a user provided stream when the
|
||||
buffer is full, or when flush or release is called.
|
||||
|
||||
\see PxDefaultProfilerCreate()
|
||||
*/
|
||||
class PxDefaultProfiler : public PxProfilerCallback
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Deletes the profiler.
|
||||
|
||||
Do not keep a reference to the deleted instance.
|
||||
|
||||
\see PxDefaultProfilerCreate()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Write all of the collected profiling data to the output stream.
|
||||
|
||||
This call is not thread safe, so it should only be called during a sync point or when all threads have yielded.
|
||||
Calling this regularly, at appropriate times will prevent the buffers from filling up and forcing a write
|
||||
to the stream at unexpected times because writes will affect performance.
|
||||
*/
|
||||
virtual void flush() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Create default profiler.
|
||||
|
||||
\note The PhysXExtensions SDK needs to be initialized first before using this method (see #PxInitExtensions)
|
||||
|
||||
\param[in] outputStream A PxOutputStream used to write all of the recorded
|
||||
profiler events received. Writing to the stream occurs when the
|
||||
buffer is full or when flush or release is called.
|
||||
\param[in] numberOfBuffers The number of buffers to pre-allocate. One buffer is
|
||||
used per thread, so a number larger than the anticipated number of threads is best.
|
||||
If more buffers are needed, additional memory is allocated as needed, but this may
|
||||
affect performance.
|
||||
\param[in] bufferSize The number of bytes to allocate per thread for recording all
|
||||
profiler events received on that thread. Once the buffer is full, the profiling data
|
||||
is written to the stream, which will cause a slight delay. Use a larger buffer size
|
||||
to prevent this, if memory permits. The minimum buffer size is 32,767 bytes, which is also
|
||||
the default setting.
|
||||
*/
|
||||
PxDefaultProfiler* PxDefaultProfilerCreate(PxOutputStream& outputStream, PxU32 numberOfBuffers = 16, PxU32 bufferSize = 32767);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
265
engine/third_party/physx/include/extensions/PxDefaultSimulationFilterShader.h
vendored
Normal file
265
engine/third_party/physx/include/extensions/PxDefaultSimulationFilterShader.h
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
// 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-2025 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_DEFAULT_SIMULATION_FILTER_SHADER_H
|
||||
#define PX_DEFAULT_SIMULATION_FILTER_SHADER_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#include "PxFiltering.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxActor;
|
||||
|
||||
/**
|
||||
\brief 64-bit mask used for collision filtering.
|
||||
|
||||
The collision filtering equation for 2 objects o0 and o1 is:
|
||||
|
||||
<pre> (G0 op0 K0) op2 (G1 op1 K1) == b </pre>
|
||||
|
||||
with
|
||||
|
||||
<ul>
|
||||
<li> G0 = PxGroupsMask for object o0. See PxSetGroupsMask </li>
|
||||
<li> G1 = PxGroupsMask for object o1. See PxSetGroupsMask </li>
|
||||
<li> K0 = filtering constant 0. See PxSetFilterConstants </li>
|
||||
<li> K1 = filtering constant 1. See PxSetFilterConstants </li>
|
||||
<li> b = filtering boolean. See PxSetFilterBool </li>
|
||||
<li> op0, op1, op2 = filtering operations. See PxSetFilterOps </li>
|
||||
</ul>
|
||||
|
||||
If the filtering equation is true, collision detection is enabled.
|
||||
|
||||
\see PxSetFilterOps()
|
||||
*/
|
||||
class PxGroupsMask
|
||||
{
|
||||
public:
|
||||
PX_INLINE PxGroupsMask():bits0(0),bits1(0),bits2(0),bits3(0) {}
|
||||
PX_INLINE ~PxGroupsMask() {}
|
||||
|
||||
PxU16 bits0, bits1, bits2, bits3;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Collision filtering operations.
|
||||
|
||||
\see PxGroupsMask
|
||||
*/
|
||||
struct PxFilterOp
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
PX_FILTEROP_AND,
|
||||
PX_FILTEROP_OR,
|
||||
PX_FILTEROP_XOR,
|
||||
PX_FILTEROP_NAND,
|
||||
PX_FILTEROP_NOR,
|
||||
PX_FILTEROP_NXOR,
|
||||
PX_FILTEROP_SWAP_AND
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Implementation of a simple filter shader that emulates PhysX 2.8.x filtering
|
||||
|
||||
This shader provides the following logic:
|
||||
\li If one of the two filter objects is a trigger, the pair is acccepted and #PxPairFlag::eTRIGGER_DEFAULT will be used for trigger reports
|
||||
\li Else, if the filter mask logic (see further below) discards the pair it will be suppressed (#PxFilterFlag::eSUPPRESS)
|
||||
\li Else, the pair gets accepted and collision response gets enabled (#PxPairFlag::eCONTACT_DEFAULT)
|
||||
|
||||
Filter mask logic:
|
||||
Given the two #PxFilterData structures fd0 and fd1 of two collision objects, the pair passes the filter if the following
|
||||
conditions are met:
|
||||
|
||||
1) Collision groups of the pair are enabled
|
||||
2) Collision filtering equation is satisfied
|
||||
|
||||
Each actor can belong to a single collision group. Use PxSetGroup to set the group of an actor and PxGetGroup to retrieve the group of an actor.
|
||||
A collision group is an integer value between 0 and 31 defining which group the actor belongs to. Because that value is written to an actor's
|
||||
shapes internally (it is stored in the shapes' PxFilterData), this feature does not work with shared shapes, unless they all belong to actors
|
||||
whose groups are similar. For example it would not work to share a shape between actors A and B, and then assign A to group 0 and B to group 1,
|
||||
as they would both internally try to write different group values to the same shape.
|
||||
|
||||
Once actors are assigned to groups, it is possible to define how groups collide with each-other using the PxSetGroupCollisionFlag function.
|
||||
Use this function to set a simple boolean value per group pairs, defining if the corresponding groups should collide. If not, collisions between
|
||||
actors of these non-colliding groups will be automatically disabled by the PxDefaultSimulationFilterShader.
|
||||
|
||||
\see PxSimulationFilterShader PxGetGroupCollisionFlag PxSetGroupCollisionFlag PxGetGroup PxSetGroup
|
||||
*/
|
||||
PxFilterFlags PxDefaultSimulationFilterShader(
|
||||
PxFilterObjectAttributes attributes0, PxFilterData filterData0,
|
||||
PxFilterObjectAttributes attributes1, PxFilterData filterData1,
|
||||
PxPairFlags& pairFlags,
|
||||
const void* constantBlock, PxU32 constantBlockSize);
|
||||
|
||||
/**
|
||||
\brief Determines if collision detection is performed between a pair of groups
|
||||
|
||||
\note Collision group is an integer between 0 and 31.
|
||||
\note PxGetGroupCollisionFlag(a, b) is the same as PxGetGroupCollisionFlag(b, a)
|
||||
|
||||
\param[in] group1 First Group
|
||||
\param[in] group2 Second Group
|
||||
|
||||
\return True if the groups should collide
|
||||
|
||||
\see PxSetGroupCollisionFlag
|
||||
*/
|
||||
bool PxGetGroupCollisionFlag(const PxU16 group1, const PxU16 group2);
|
||||
|
||||
/**
|
||||
\brief Specifies if collision should be performed by a pair of groups
|
||||
|
||||
\note Collision group is an integer between 0 and 31.
|
||||
\note PxSetGroupCollisionFlag(a, b) is the same as PxSetGroupCollisionFlag(b, a)
|
||||
|
||||
\param[in] group1 First Group
|
||||
\param[in] group2 Second Group
|
||||
\param[in] enable True to enable collision between the groups
|
||||
|
||||
\see PxGetGroupCollisionFlag
|
||||
*/
|
||||
void PxSetGroupCollisionFlag(const PxU16 group1, const PxU16 group2, const bool enable);
|
||||
|
||||
/**
|
||||
\brief Retrieves the value set with PxSetGroup()
|
||||
|
||||
\note Collision group is an integer between 0 and 31.
|
||||
|
||||
\param[in] actor The actor
|
||||
|
||||
\return The collision group this actor belongs to
|
||||
|
||||
\see PxSetGroup
|
||||
*/
|
||||
PxU16 PxGetGroup(const PxActor& actor);
|
||||
|
||||
/**
|
||||
\brief Sets which collision group this actor is part of
|
||||
|
||||
\note Collision group is an integer between 0 and 31.
|
||||
|
||||
\param[in] actor The actor
|
||||
\param[in] collisionGroup Collision group this actor belongs to
|
||||
|
||||
\see PxGetGroup
|
||||
*/
|
||||
void PxSetGroup(PxActor& actor, const PxU16 collisionGroup);
|
||||
|
||||
/**
|
||||
\brief Retrieves filtering operation. See comments for PxGroupsMask
|
||||
|
||||
\param[out] op0 First filter operator.
|
||||
\param[out] op1 Second filter operator.
|
||||
\param[out] op2 Third filter operator.
|
||||
|
||||
\see PxSetFilterOps PxSetFilterBool PxSetFilterConstants
|
||||
*/
|
||||
void PxGetFilterOps(PxFilterOp::Enum& op0, PxFilterOp::Enum& op1, PxFilterOp::Enum& op2);
|
||||
|
||||
/**
|
||||
\brief Setups filtering operations. See comments for PxGroupsMask
|
||||
|
||||
\param[in] op0 Filter op 0.
|
||||
\param[in] op1 Filter op 1.
|
||||
\param[in] op2 Filter op 2.
|
||||
|
||||
\see PxSetFilterBool PxSetFilterConstants
|
||||
*/
|
||||
void PxSetFilterOps(const PxFilterOp::Enum& op0, const PxFilterOp::Enum& op1, const PxFilterOp::Enum& op2);
|
||||
|
||||
/**
|
||||
\brief Retrieves filtering's boolean value. See comments for PxGroupsMask
|
||||
|
||||
\return flag Boolean value for filter.
|
||||
|
||||
\see PxSetFilterBool PxSetFilterConstants
|
||||
*/
|
||||
bool PxGetFilterBool();
|
||||
|
||||
/**
|
||||
\brief Setups filtering's boolean value. See comments for PxGroupsMask
|
||||
|
||||
\param[in] enable Boolean value for filter.
|
||||
|
||||
\see PxSetFilterOps PxSsetFilterConstants
|
||||
*/
|
||||
void PxSetFilterBool(const bool enable);
|
||||
|
||||
/**
|
||||
\brief Gets filtering constant K0 and K1. See comments for PxGroupsMask
|
||||
|
||||
\param[out] c0 the filtering constants, as a mask. See #PxGroupsMask.
|
||||
\param[out] c1 the filtering constants, as a mask. See #PxGroupsMask.
|
||||
|
||||
\see PxSetFilterOps PxSetFilterBool PxSetFilterConstants
|
||||
*/
|
||||
void PxGetFilterConstants(PxGroupsMask& c0, PxGroupsMask& c1);
|
||||
|
||||
/**
|
||||
\brief Setups filtering's K0 and K1 value. See comments for PxGroupsMask
|
||||
|
||||
\param[in] c0 The new group mask. See #PxGroupsMask.
|
||||
\param[in] c1 The new group mask. See #PxGroupsMask.
|
||||
|
||||
\see PxSetFilterOps PxSetFilterBool PxGetFilterConstants
|
||||
*/
|
||||
void PxSetFilterConstants(const PxGroupsMask& c0, const PxGroupsMask& c1);
|
||||
|
||||
/**
|
||||
\brief Gets 64-bit mask used for collision filtering. See comments for PxGroupsMask
|
||||
|
||||
\param[in] actor The actor
|
||||
|
||||
\return The group mask for the actor.
|
||||
|
||||
\see PxSetGroupsMask()
|
||||
*/
|
||||
PxGroupsMask PxGetGroupsMask(const PxActor& actor);
|
||||
|
||||
/**
|
||||
\brief Sets 64-bit mask used for collision filtering. See comments for PxGroupsMask
|
||||
|
||||
\param[in] actor The actor
|
||||
\param[in] mask The group mask to set for the actor.
|
||||
|
||||
\see PxGetGroupsMask()
|
||||
*/
|
||||
void PxSetGroupsMask(PxActor& actor, const PxGroupsMask& mask);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
143
engine/third_party/physx/include/extensions/PxDefaultStreams.h
vendored
Normal file
143
engine/third_party/physx/include/extensions/PxDefaultStreams.h
vendored
Normal file
@@ -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-2025 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_DEFAULT_STREAMS_H
|
||||
#define PX_DEFAULT_STREAMS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxIO.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
typedef FILE* PxFileHandle;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief default implementation of a memory write stream
|
||||
|
||||
\see PxOutputStream
|
||||
*/
|
||||
|
||||
class PxDefaultMemoryOutputStream: public PxOutputStream
|
||||
{
|
||||
public:
|
||||
PxDefaultMemoryOutputStream(PxAllocatorCallback &allocator = *PxGetAllocatorCallback());
|
||||
virtual ~PxDefaultMemoryOutputStream();
|
||||
|
||||
virtual PxU32 write(const void* src, PxU32 count);
|
||||
|
||||
virtual PxU32 getSize() const { return mSize; }
|
||||
virtual PxU8* getData() const { return mData; }
|
||||
|
||||
private:
|
||||
PxDefaultMemoryOutputStream(const PxDefaultMemoryOutputStream&);
|
||||
PxDefaultMemoryOutputStream& operator=(const PxDefaultMemoryOutputStream&);
|
||||
|
||||
PxAllocatorCallback& mAllocator;
|
||||
PxU8* mData;
|
||||
PxU32 mSize;
|
||||
PxU32 mCapacity;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief default implementation of a memory read stream
|
||||
|
||||
\see PxInputData
|
||||
*/
|
||||
|
||||
class PxDefaultMemoryInputData: public PxInputData
|
||||
{
|
||||
public:
|
||||
PxDefaultMemoryInputData(PxU8* data, PxU32 length);
|
||||
|
||||
virtual PxU32 read(void* dest, PxU32 count);
|
||||
virtual PxU32 getLength() const;
|
||||
virtual void seek(PxU32 pos);
|
||||
virtual PxU32 tell() const;
|
||||
|
||||
private:
|
||||
PxU32 mSize;
|
||||
const PxU8* mData;
|
||||
PxU32 mPos;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief default implementation of a file write stream
|
||||
|
||||
\see PxOutputStream
|
||||
*/
|
||||
|
||||
class PxDefaultFileOutputStream: public PxOutputStream
|
||||
{
|
||||
public:
|
||||
PxDefaultFileOutputStream(const char* name);
|
||||
virtual ~PxDefaultFileOutputStream();
|
||||
|
||||
virtual PxU32 write(const void* src, PxU32 count);
|
||||
virtual bool isValid();
|
||||
private:
|
||||
PxFileHandle mFile;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief default implementation of a file read stream
|
||||
|
||||
\see PxInputData
|
||||
*/
|
||||
|
||||
class PxDefaultFileInputData: public PxInputData
|
||||
{
|
||||
public:
|
||||
PxDefaultFileInputData(const char* name);
|
||||
virtual ~PxDefaultFileInputData();
|
||||
|
||||
virtual PxU32 read(void* dest, PxU32 count);
|
||||
virtual void seek(PxU32 pos);
|
||||
virtual PxU32 tell() const;
|
||||
virtual PxU32 getLength() const;
|
||||
|
||||
bool isValid() const;
|
||||
private:
|
||||
PxFileHandle mFile;
|
||||
PxU32 mLength;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
99
engine/third_party/physx/include/extensions/PxDeformableSkinningExt.h
vendored
Normal file
99
engine/third_party/physx/include/extensions/PxDeformableSkinningExt.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// 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-2025 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_DEFORMABLE_SKINNING_EXT_H
|
||||
#define PX_DEFORMABLE_SKINNING_EXT_H
|
||||
|
||||
#include "PxDeformableSkinning.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxCookingParams;
|
||||
class PxSimpleTriangleMesh;
|
||||
class PxInsertionCallback;
|
||||
|
||||
/**
|
||||
\brief Utility functions for deformable surface and volume skinning
|
||||
*/
|
||||
class PxDeformableSkinningExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Initializes the interpolated vertices from guide vertices, normals, and triangles for deformable surface skinning
|
||||
|
||||
This function calculates the skinning embedding information for a deformable surface mesh,
|
||||
where each embedded vertex is interpolated based on the surrounding guide vertices and triangles.
|
||||
|
||||
\param[out] embeddingInfo A pointer to a PxTriangleMeshEmbeddingInfo object that will store the calculated embedding information. Must be of length numEmbeddedVertices
|
||||
\param[in] guideVertices A pointer to an array of guide vertices used for interpolation
|
||||
\param[in] guideNormals A pointer to an array of guide normals corresponding to the guide vertices
|
||||
\param[in] guideTriangles A pointer to an array of indices defining the guide triangles
|
||||
\param[in] nbGuideTriangles The number of guide triangles
|
||||
\param[in] embeddedVertices A pointer to an array of vertices that will be embedded and interpolated
|
||||
\param[in] nbEmbeddedVertices The number of embedded vertices
|
||||
|
||||
\see PxTriangleMeshEmbeddingInfo
|
||||
*/
|
||||
static void initializeInterpolatedVertices(
|
||||
PxTriangleMeshEmbeddingInfo* embeddingInfo,
|
||||
const PxVec3* guideVertices, const PxVec3* guideNormals,
|
||||
const PxU32* guideTriangles, PxU32 nbGuideTriangles, const PxVec3* embeddedVertices,
|
||||
PxU32 nbEmbeddedVertices);
|
||||
|
||||
/**
|
||||
\brief Initializes the interpolated vertices from guide vertices and tetrahedra for deformable volume skinning
|
||||
|
||||
This function calculates the skinning embedding information for a deformable volume mesh,
|
||||
where each embedded vertex is interpolated based on the surrounding guide vertices and tetrahedra.
|
||||
|
||||
\param[out] embeddingInfo A pointer to a PxTetrahedronMeshEmbeddingInfo object that will store the calculated embedding information. Must be of length numEmbeddedVertices
|
||||
\param[in] guideVertices A pointer to an array of guide vertices used for interpolation
|
||||
\param[in] guideTetrahedra A pointer to an array of indices defining the guide tetrahedra
|
||||
\param[in] nbGuideTetrahedra The number of guide tetrahedra
|
||||
\param[in] embeddedVertices A pointer to an array of vertices that will be embedded and interpolated
|
||||
\param[in] nbEmbeddedVertices The number of embedded vertices
|
||||
|
||||
\see PxTetrahedronMeshEmbeddingInfo
|
||||
*/
|
||||
static void initializeInterpolatedVertices(
|
||||
PxTetrahedronMeshEmbeddingInfo* embeddingInfo,
|
||||
const PxVec3* guideVertices,
|
||||
const PxU32* guideTetrahedra, PxU32 nbGuideTetrahedra, const PxVec3* embeddedVertices,
|
||||
PxU32 nbEmbeddedVertices);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif // PX_DEFORMABLE_SKINNING_EXT_H
|
||||
177
engine/third_party/physx/include/extensions/PxDeformableSurfaceExt.h
vendored
Normal file
177
engine/third_party/physx/include/extensions/PxDeformableSurfaceExt.h
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
// 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-2025 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_DEFORMABLE_SURFACE_EXT_H
|
||||
#define PX_DEFORMABLE_SURFACE_EXT_H
|
||||
|
||||
#include "PxDeformableSurface.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "cudamanager/PxCudaContextManager.h"
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Utility functions for use with PxDeformableSurface
|
||||
*/
|
||||
class PxDeformableSurfaceExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Uploads prepared deformable surface data to the GPU.
|
||||
|
||||
\param[in] deformableSurface The deformable surface to perform the data upload to.
|
||||
\param[in] flags Specifies which buffers the data transfer should include.
|
||||
\param[in] nbVertices The number of vertices in the surface deformable mesh.
|
||||
\param[in] positionsPinned A pointer to a pinned host memory buffer containing position and inverse mass for each vertex.
|
||||
\param[in] velocitiesPinned A pointer to a pinned host memory buffer containing the velocity for each vertex.
|
||||
\param[in] restPositionsPinned A pointer to a pinned host memory buffer containing the rest position for each vertex.
|
||||
\param[in] copyStream An optional cuda stream to schedule the copy on.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static void copyToDevice(PxDeformableSurface& deformableSurface, PxDeformableSurfaceDataFlags flags, PxU32 nbVertices,
|
||||
PxVec4* positionsPinned, PxVec4* velocitiesPinned, PxVec4* restPositionsPinned,
|
||||
CUstream copyStream = CUstream(0));
|
||||
|
||||
/**
|
||||
\brief Distributes a list of triangles masses to vertices.
|
||||
|
||||
The mass for each triangle will be distributed in equal parts to the vertices of said triangle.
|
||||
|
||||
\param[in] deformableSurface The deformable surface to perform the operation on.
|
||||
\param[in] triangleMasses A list of floats specifying the mass of each triangle.
|
||||
\param[in] positionInvMassPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static void distributeTriangleMassToVertices(PxDeformableSurface& deformableSurface, const PxReal* triangleMasses,
|
||||
PxVec4* positionInvMassPinned);
|
||||
|
||||
/**
|
||||
\brief Distributes a uniform density to the vertices of a deformable surface.
|
||||
|
||||
This method distributes mass based on a specified mass per unit area. The mass for each vertex is calculated
|
||||
according to the area of the triangles connected to it, and the resulting mass is assigned to the vertex.
|
||||
|
||||
\param[in] deformableSurface The deformable surface to perform the operation on.
|
||||
\param[in] massPerVolume The mass per unit volume (=density) to be distributed across the vertices.
|
||||
\param[in] clothThickness The cloth thickness to compute the mass
|
||||
\param[in] positionInvMassPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static void distributeDensityToVertices(PxDeformableSurface& deformableSurface, PxReal massPerVolume, PxReal clothThickness,
|
||||
PxVec4* positionInvMassPinned);
|
||||
|
||||
/**
|
||||
\brief Distributes a total mass uniformly to the vertices of a deformable surface.
|
||||
|
||||
This method calculates the total mass to be distributed across all vertices, and assigns a proportional mass to each
|
||||
vertex based on the geometry of the surface. The mass is distributed equally to ensure the total mass of the surface
|
||||
matches the specified value.
|
||||
|
||||
\param[in] deformableSurface The deformable surface to perform the operation on.
|
||||
\param[in] totalMass The total mass to be distributed across the vertices.
|
||||
\param[in] positionInvMassPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static void distributeMassToVertices(PxDeformableSurface& deformableSurface, PxReal totalMass,
|
||||
PxVec4* positionInvMassPinned);
|
||||
|
||||
/**
|
||||
\brief Allocates and initializes a pinned host memory from a PxTriangleMesh attached to a PxDeformableSurface using a PxShape.
|
||||
|
||||
\note The user is responsible for deallocation and lifetime management of the positionInvMassPinned, velocityPinned
|
||||
and restPositionsPinned buffers.
|
||||
|
||||
This method fails if the deformable surface does not have a shape attached to it.
|
||||
|
||||
\param[in] deformableSurface The deformable surface to perform the operation on.
|
||||
\param[in] positions The initial positions of the surface deformable vertices.
|
||||
\param[in] velocities The initial velocities of the surface deformable vertices.
|
||||
\param[in] restPositions The rest positions of the surface deformable vertices.
|
||||
\param[in] mass The mass of the deformable surface, will be distributed equally among vertices.
|
||||
\param[in] transform The world-space transform of the deformable surface.
|
||||
\param[in] cudaContextManager The PxCudaContextManager of the scene this deformable surface will be simulated in.
|
||||
\param[in] positionInvMassPinned A reference to a pointer for the return value of the positionInvMassPinned buffer, will be set by this function.
|
||||
\param[in] velocityPinned A reference to a pointer for the return value of the velocityPinned buffer, will be set by this function.
|
||||
\param[in] restPositionPinned A reference to a pointer for the return value of the restPositionPinned buffer, will be set by this function.
|
||||
|
||||
\return The number of vertices in the surface deformable mesh.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static PxU32 allocateAndInitializeHostMirror(PxDeformableSurface& deformableSurface, const PxVec3* positions,
|
||||
const PxVec3* velocities, const PxVec3* restPositions, float mass,
|
||||
const PxTransform& transform, PxCudaContextManager* cudaContextManager,
|
||||
PxVec4*& positionInvMassPinned, PxVec4*& velocityPinned,
|
||||
PxVec4*& restPositionPinned);
|
||||
|
||||
/**
|
||||
\brief Allocates and initializes a pinned host memory from given positions, velocities, and rest positions.
|
||||
|
||||
\note The user is responsible for deallocation and lifetime management of the positionInvMassPinned, velocityPinned
|
||||
and restPositionsPinned buffers.
|
||||
|
||||
If the input 'restPositions' is a null pointer, positions are used in place of restPositions.
|
||||
If the input 'velocities' is a null pointer, zero velocities are assigned to velocityPinned.
|
||||
|
||||
\param[in] positions The positions of the surface deformable vertices, will be used to assign positionInvMassPinned buffer.
|
||||
\param[in] velocities The velocities of the surface deformable vertices, will be used to assign velocityPinned buffer.
|
||||
\param[in] restPositions The rest positions of the surface deformable vertices, will be used to assign restPositionPinned buffer.
|
||||
\param[in] nbVertices The number of vertices in the surface deformable mesh.
|
||||
\param[in] mass The mass of the deformable surface, will be distributed equally among vertices.
|
||||
\param[in] transform The world-space transform of the deformable surface.
|
||||
\param[in] cudaContextManager The PxCudaContextManager of the scene this deformable surface will be simulated in.
|
||||
\param[in] positionInvMassPinned A reference to a pointer for the return value of the positionInvMassPinned buffer, will be set by this function.
|
||||
\param[in] velocityPinned A reference to a pointer for the return value of the velocityPinned buffer, will be set by this function.
|
||||
\param[in] restPositionPinned A reference to a pointer for the return value of the restPositionPinned buffer, will be set by this function.
|
||||
|
||||
\return The number of vertices in the surface deformable mesh.
|
||||
|
||||
\see PxDeformableSurface
|
||||
*/
|
||||
static PxU32 allocateAndInitializeHostMirror(const PxVec3* positions, const PxVec3* velocities,
|
||||
const PxVec3* restPositions, PxU32 nbVertices, float mass,
|
||||
const PxTransform& transform, PxCudaContextManager* cudaContextManager,
|
||||
PxVec4*& positionInvMassPinned, PxVec4*& velocityPinned,
|
||||
PxVec4*& restPositionPinned);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif // PX_DEFORMABLE_SURFACE_EXT_H
|
||||
297
engine/third_party/physx/include/extensions/PxDeformableVolumeExt.h
vendored
Normal file
297
engine/third_party/physx/include/extensions/PxDeformableVolumeExt.h
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
// 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-2025 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_DEFORMABLE_VOLUME_EXT_H
|
||||
#define PX_DEFORMABLE_VOLUME_EXT_H
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "PxDeformableVolume.h"
|
||||
#include "PxDeformableVolumeFlag.h"
|
||||
#include "cudamanager/PxCudaContextManager.h"
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxCookingParams;
|
||||
class PxSimpleTriangleMesh;
|
||||
class PxInsertionCallback;
|
||||
class PxDeformableVolumeMesh;
|
||||
|
||||
/**
|
||||
\brief Utility functions for use with PxDeformableVolume and subclasses
|
||||
*/
|
||||
class PxDeformableVolumeExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Computes the deformable volume's vertex masses from the provided density and the volume of the tetrahedra
|
||||
|
||||
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD()
|
||||
|
||||
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh's position buffer.
|
||||
|
||||
\param[in] deformableVolume The deformable volume which will get its mass updated
|
||||
\param[in] density The density to used to calculate the mass from the body's volume
|
||||
\param[in] maxInvMassRatio Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh
|
||||
\param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
|
||||
|
||||
\see PxDeformableVolume PxDeformableVolume::getSimPositionInvMassBufferD()
|
||||
*/
|
||||
static void updateMass(PxDeformableVolume& deformableVolume, const PxReal density, const PxReal maxInvMassRatio, PxVec4* simPositionsPinned);
|
||||
|
||||
/**
|
||||
\brief Computes the deformable volume's vertex masses such that the sum of all masses is equal to the provided mass
|
||||
|
||||
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD()) and getSimVelocityBufferD()
|
||||
|
||||
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh's position buffer.
|
||||
|
||||
\param[in] deformableVolume The deformable volume which will get its mass updated
|
||||
\param[in] mass The deformable volume's mass
|
||||
\param[in] maxInvMassRatio Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh
|
||||
\param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
|
||||
|
||||
\see PxDeformableVolume PxDeformableVolume::getSimPositionInvMassBufferD()
|
||||
*/
|
||||
static void setMass(PxDeformableVolume& deformableVolume, const PxReal mass, const PxReal maxInvMassRatio, PxVec4* simPositionsPinned);
|
||||
|
||||
/**
|
||||
\brief Transforms a deformable volume
|
||||
|
||||
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD()
|
||||
|
||||
Applies a transformation to the simulation mesh's positions an velocities. Velocities only get rotated and scaled (translation is not applicable to direction vectors).
|
||||
It does not modify the body's mass.
|
||||
If the method is called multiple times, the transformation will compound with the ones previously applied.
|
||||
|
||||
\param[in] deformableVolume The deformable volume which is transformed
|
||||
\param[in] transform The transform to apply
|
||||
\param[in] scale A scaling factor
|
||||
\param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
|
||||
\param[in] simVelocitiesPinned A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh.
|
||||
\param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
|
||||
\param[in] restPositionsPinned A pointer to a pinned host memory buffer containing rest positions of the collision mesh.
|
||||
|
||||
\see PxDeformableVolume
|
||||
*/
|
||||
static void transform(PxDeformableVolume& deformableVolume, const PxTransform& transform, const PxReal scale, PxVec4* simPositionsPinned, PxVec4* simVelocitiesPinned, PxVec4* collPositionsPinned, PxVec4* restPositionsPinned);
|
||||
|
||||
/**
|
||||
\brief Updates the collision mesh's vertex positions to match the simulation mesh's transformation and scale.
|
||||
|
||||
The buffer affected by this operation can be obtained from the deformable volume using the method getPositionInvMassBufferD()
|
||||
|
||||
\param[in] deformableVolume The deformable volume which will get its collision mesh vertices updated
|
||||
\param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
|
||||
\param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
|
||||
|
||||
\see PxDeformableVolume
|
||||
*/
|
||||
static void updateEmbeddedCollisionMesh(PxDeformableVolume& deformableVolume, PxVec4* simPositionsPinned, PxVec4* collPositionsPinned);
|
||||
|
||||
/**
|
||||
\brief Uploads prepared deformable volume data to the GPU. It ensures that the embedded collision mesh matches the simulation mesh's transformation and scale.
|
||||
|
||||
\param[in] deformableVolume The deformable volume which will perform the data upload
|
||||
\param[in] flags Specifies which buffers the data transfer should include
|
||||
\param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
|
||||
\param[in] simVelocitiesPinned A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh.
|
||||
\param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
|
||||
\param[in] restPositionsPinned A pointer to a pinned host memory buffer containing rest positions of the collision mesh.
|
||||
\param[in] stream A cuda stream to perform the copies.
|
||||
|
||||
\see PxDeformableVolume
|
||||
*/
|
||||
static void copyToDevice(PxDeformableVolume& deformableVolume, PxDeformableVolumeDataFlags flags, PxVec4* simPositionsPinned, PxVec4* simVelocitiesPinned, PxVec4* collPositionsPinned, PxVec4* restPositionsPinned, CUstream stream = CUstream(0));
|
||||
|
||||
/**
|
||||
\brief Creates a full deformable volume mesh matching the shape given as input. Uses a voxel mesh for FEM simulation and a surface-matching mesh for collision detection.
|
||||
|
||||
\param[in] params Cooking params instance required for mesh processing
|
||||
\param[in] surfaceMesh Input triangle mesh that represents the surface of the deformable volume
|
||||
\param[in] numVoxelsAlongLongestAABBAxis The number of voxels along the longest bounding box axis
|
||||
\param[in] insertionCallback The insertion interface from PxPhysics
|
||||
\param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies
|
||||
\return Deformable volume mesh if cooking was successful, NULL otherwise
|
||||
\see PxDeformableVolumeMesh
|
||||
*/
|
||||
static PxDeformableVolumeMesh* createDeformableVolumeMesh(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback& insertionCallback, const bool validate = true);
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see createDeformableVolumeMesh
|
||||
*/
|
||||
PX_DEPRECATED static PX_FORCE_INLINE PxDeformableVolumeMesh* createSoftBodyMesh(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback& insertionCallback, const bool validate = true)
|
||||
{
|
||||
return createDeformableVolumeMesh(params, surfaceMesh, numVoxelsAlongLongestAABBAxis, insertionCallback, validate);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Creates a full deformable volume mesh matching the shape given as input. Uses the same surface-matching mesh for collision detection and FEM simulation.
|
||||
|
||||
\param[in] params Cooking params instance required for mesh processing
|
||||
\param[in] surfaceMesh Input triangle mesh that represents the surface of the deformable volume
|
||||
\param[in] insertionCallback The insertion interface from PxPhysics
|
||||
\param[in] maxWeightRatioInTet Upper limit for the ratio of node weights that are adjacent to the same tetrahedron. The closer to one (while remaining larger than one), the more stable the simulation.
|
||||
\param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies
|
||||
\return Deformable volume mesh if cooking was successful, NULL otherwise
|
||||
\see PxDeformableVolumeMesh
|
||||
*/
|
||||
static PxDeformableVolumeMesh* createDeformableVolumeMeshNoVoxels(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh,
|
||||
PxInsertionCallback& insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true);
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see createDeformableVolumeMeshNoVoxels
|
||||
*/
|
||||
PX_DEPRECATED static PX_FORCE_INLINE PxDeformableVolumeMesh* createSoftBodyMeshNoVoxels(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh,
|
||||
PxInsertionCallback& insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true)
|
||||
{
|
||||
return createDeformableVolumeMeshNoVoxels(params, surfaceMesh, insertionCallback, maxWeightRatioInTet, validate);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Creates a deformable volume instance from a deformable volume mesh
|
||||
|
||||
\param[in] deformableVolumeMesh The deformable volume mesh
|
||||
\param[in] transform The transform that defines initial position and orientation of the deformable volume
|
||||
\param[in] material The material
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\param[in] density The density used to compute the mass properties
|
||||
\param[in] scale The scaling of the deformable volume
|
||||
\return Deformable volume instance
|
||||
\see PxDeformableVolumeMesh, PxDeformableVolume
|
||||
*/
|
||||
static PxDeformableVolume* createDeformableVolumeFromMesh(PxDeformableVolumeMesh* deformableVolumeMesh, const PxTransform& transform,
|
||||
const PxDeformableVolumeMaterial& material, PxCudaContextManager& cudaContextManager, PxReal density = 100.0f, PxReal scale = 1.0f);
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see createDeformableVolumeFromMesh
|
||||
*/
|
||||
PX_DEPRECATED static PX_FORCE_INLINE PxDeformableVolume* createSoftBodyFromMesh(PxDeformableVolumeMesh* deformableVolumeMesh, const PxTransform& transform,
|
||||
const PxDeformableVolumeMaterial& material, PxCudaContextManager& cudaContextManager, PxReal density = 100.0f, PxU32 solverIterationCount = 30,
|
||||
const PxFEMParameters& femParams = PxFEMParameters(), PxReal scale = 1.0f)
|
||||
{
|
||||
PxDeformableVolume* deformableVolume = createDeformableVolumeFromMesh(deformableVolumeMesh, transform, material,
|
||||
cudaContextManager, density, scale);
|
||||
deformableVolume->setParameter(femParams);
|
||||
deformableVolume->setSolverIterationCounts(solverIterationCount);
|
||||
return deformableVolume;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Creates a deformable volume instance with a box shape
|
||||
|
||||
\param[in] transform The transform that defines initial position and orientation of the deformable volume
|
||||
\param[in] boxDimensions The dimensions (side lengths) of the box shape
|
||||
\param[in] material The material
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\param[in] maxEdgeLength The maximal length of a triangle edge. Subdivision will get applied until the edge length criteria is matched. -1 means no subdivision is applied.
|
||||
\param[in] density The density used to compute the mass properties
|
||||
\param[in] numVoxelsAlongLongestAABBAxis The number of voxels to use for the simulation mesh along the longest bounding box dimension
|
||||
\param[in] scale The scaling of the deformable volume
|
||||
\return Deformable volume instance
|
||||
\see PxDeformableVolumeMesh, PxDeformableVolume
|
||||
*/
|
||||
static PxDeformableVolume* createDeformableVolumeBox(const PxTransform& transform, const PxVec3& boxDimensions, const PxDeformableVolumeMaterial& material,
|
||||
PxCudaContextManager& cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f);
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see createDeformableVolumeBox
|
||||
*/
|
||||
PX_DEPRECATED static PX_FORCE_INLINE PxDeformableVolume* createSoftBodyBox(const PxTransform& transform, const PxVec3& boxDimensions, const PxDeformableVolumeMaterial& material,
|
||||
PxCudaContextManager& cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 solverIterationCount = 30,
|
||||
const PxFEMParameters& femParams = PxFEMParameters(), PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f)
|
||||
{
|
||||
PxDeformableVolume* deformableVolume = createDeformableVolumeBox(transform, boxDimensions, material, cudaContextManager, maxEdgeLength, density,
|
||||
numVoxelsAlongLongestAABBAxis, scale);
|
||||
deformableVolume->setParameter(femParams);
|
||||
deformableVolume->setSolverIterationCounts(solverIterationCount);
|
||||
return deformableVolume;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief allocates and initializes pinned host memory buffers from an actor with shape.
|
||||
|
||||
\param[in] deformableVolume A PxDeformableVolume that has a valid shape attached to it.
|
||||
\param[in] cudaContextManager The PxCudaContextManager of the scene this deformable volume will be simulated in
|
||||
\param[in] simPositionInvMassPinned A reference to a pointer for the return value of the simPositionInvMassPinned buffer, will be set by this function.
|
||||
\param[in] simVelocityPinned A reference to a pointer for the return value of the simVelocityPinned buffer, will be set by this function.
|
||||
\param[in] collPositionInvMassPinned A reference to a pointer for the return value of the collPositionInvMassPinned buffer, will be set by this function.
|
||||
\param[in] restPositionPinned A reference to a pointer for the return value of the restPositionPinned buffer, will be set by this function.
|
||||
|
||||
\see PxDeformableVolume
|
||||
*/
|
||||
static void allocateAndInitializeHostMirror(PxDeformableVolume& deformableVolume, PxCudaContextManager* cudaContextManager, PxVec4*& simPositionInvMassPinned, PxVec4*& simVelocityPinned, PxVec4*& collPositionInvMassPinned, PxVec4*& restPositionPinned);
|
||||
|
||||
/**
|
||||
\brief Given a set of points and a set of tetrahedra, it finds the equilibrium state of the deformable volume. Every input point is either fixed or can move freely.
|
||||
|
||||
\param[in] verticesOriginal Mesh vertex positions in undeformed original state.
|
||||
\param[in] verticesDeformed Mesh vertex positions in new deformed state. Only fixed vertices must have their final location, all other locations will get updated by the method.
|
||||
\param[in] nbVertices The number of vertices.
|
||||
\param[in] tetrahedra The tetrahedra.
|
||||
\param[in] nbTetraheda The number of tetrahedra.
|
||||
\param[in] vertexIsFixed Optional input that specifies which vertex is fixed and which one can move to relax the tension. If not provided, vertices from verticesOriginal which have a .w value of 0 will be considered fixed.
|
||||
\param[in] numIterations The number of stress relaxation iterations to run.
|
||||
*/
|
||||
static void relaxDeformableVolumeMesh(const PxVec4* verticesOriginal, PxVec4* verticesDeformed, PxU32 nbVertices,
|
||||
const PxU32* tetrahedra, PxU32 nbTetraheda, const bool* vertexIsFixed = NULL, PxU32 numIterations = 200);
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see relaxDeformableVolumeMesh
|
||||
*/
|
||||
PX_DEPRECATED static PX_FORCE_INLINE void relaxSoftBodyMesh(const PxVec4* verticesOriginal, PxVec4* verticesDeformed, PxU32 nbVertices, const PxU32* tetrahedra, PxU32 nbTetraheda, const bool* vertexIsFixed = NULL, PxU32 numIterations = 200)
|
||||
{
|
||||
relaxDeformableVolumeMesh(verticesOriginal, verticesDeformed, nbVertices, tetrahedra, nbTetraheda, vertexIsFixed, numIterations);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Converts the tet id and barycentric from the collision mesh to the tet id and barycentric of the simulation mesh.
|
||||
|
||||
\param[in] deformableVolume The deformable volume to perform the operation on.
|
||||
\param[in] tetId The tet id of the deformable volume's collision mesh.
|
||||
\param[in] tetBarycentric The barycentric coordinates of the tetrahedron specified with tetId.
|
||||
\param[out] outTetId The tet id of the deformable volume's simulation mesh.
|
||||
\param[out] outTetBarycentric The barycentric coordinates of the tetrahedron specified with outTetId.
|
||||
*/
|
||||
static void convertCollisionToSimulationTet(PxDeformableVolume& deformableVolume, PxU32 tetId, const PxVec4& tetBarycentric, PxU32& outTetId, PxVec4& outTetBarycentric);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif // PX_DEFORMABLE_VOLUME_EXT_H
|
||||
264
engine/third_party/physx/include/extensions/PxDistanceJoint.h
vendored
Normal file
264
engine/third_party/physx/include/extensions/PxDistanceJoint.h
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
// 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-2025 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_DISTANCE_JOINT_H
|
||||
#define PX_DISTANCE_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxDistanceJoint;
|
||||
|
||||
/**
|
||||
\brief Create a distance Joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxDistanceJoint
|
||||
*/
|
||||
PxDistanceJoint* PxDistanceJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
|
||||
/**
|
||||
\brief flags for configuring the drive of a PxDistanceJoint
|
||||
|
||||
\see PxDistanceJoint
|
||||
*/
|
||||
struct PxDistanceJointFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eMAX_DISTANCE_ENABLED = 1<<1,
|
||||
eMIN_DISTANCE_ENABLED = 1<<2,
|
||||
eSPRING_ENABLED = 1<<3
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxDistanceJointFlag::Enum, PxU16> PxDistanceJointFlags;
|
||||
PX_FLAGS_OPERATORS(PxDistanceJointFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
||||
|
||||
\see PxDistanceJointCreate PxJoint
|
||||
*/
|
||||
class PxDistanceJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Return the current distance of the joint
|
||||
*/
|
||||
virtual PxReal getDistance() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the allowed minimum distance for the joint.
|
||||
|
||||
The minimum distance must be no more than the maximum distance
|
||||
|
||||
<b>Default</b> 0.0f
|
||||
<b>Range</b> [0, PX_MAX_F32)
|
||||
|
||||
\param[in] distance the minimum distance
|
||||
|
||||
\see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED getMinDistance()
|
||||
*/
|
||||
virtual void setMinDistance(PxReal distance) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the allowed minimum distance for the joint.
|
||||
|
||||
\return the allowed minimum distance
|
||||
|
||||
\see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED setMinDistance()
|
||||
*/
|
||||
virtual PxReal getMinDistance() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the allowed maximum distance for the joint.
|
||||
|
||||
The maximum distance must be no less than the minimum distance.
|
||||
|
||||
<b>Default</b> 0.0f
|
||||
<b>Range</b> [0, PX_MAX_F32)
|
||||
|
||||
\param[in] distance the maximum distance
|
||||
|
||||
\see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED getMinDistance()
|
||||
*/
|
||||
virtual void setMaxDistance(PxReal distance) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the allowed maximum distance for the joint.
|
||||
|
||||
\return the allowed maximum distance
|
||||
|
||||
\see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED setMaxDistance()
|
||||
*/
|
||||
virtual PxReal getMaxDistance() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the error tolerance of the joint.
|
||||
|
||||
\param[in] tolerance the distance beyond the allowed range at which the joint becomes active
|
||||
|
||||
\see PxDistanceJoint::tolerance, getTolerance()
|
||||
*/
|
||||
virtual void setTolerance(PxReal tolerance) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the error tolerance of the joint.
|
||||
|
||||
the distance beyond the joint's [min, max] range before the joint becomes active.
|
||||
|
||||
<b>Default</b> 0.25f * PxTolerancesScale::length
|
||||
<b>Range</b> (0, PX_MAX_F32)
|
||||
|
||||
This value should be used to ensure that if the minimum distance is zero and the
|
||||
spring function is in use, the rest length of the spring is non-zero.
|
||||
|
||||
\see PxDistanceJoint::tolerance, setTolerance()
|
||||
*/
|
||||
virtual PxReal getTolerance() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the strength of the joint spring.
|
||||
|
||||
The spring is used if enabled, and the distance exceeds the range [min-error, max+error].
|
||||
|
||||
<b>Default</b> 0.0f
|
||||
<b>Range</b> [0, PX_MAX_F32)
|
||||
|
||||
\param[in] stiffness the spring strength of the joint
|
||||
|
||||
\see PxDistanceJointFlag::eSPRING_ENABLED getStiffness()
|
||||
*/
|
||||
virtual void setStiffness(PxReal stiffness) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the strength of the joint spring.
|
||||
|
||||
\return stiffness the spring strength of the joint
|
||||
|
||||
\see PxDistanceJointFlag::eSPRING_ENABLED setStiffness()
|
||||
*/
|
||||
virtual PxReal getStiffness() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the damping of the joint spring.
|
||||
|
||||
The spring is used if enabled, and the distance exceeds the range [min-error, max+error].
|
||||
|
||||
<b>Default</b> 0.0f
|
||||
<b>Range</b> [0, PX_MAX_F32)
|
||||
|
||||
\param[in] damping the degree of damping of the joint spring of the joint
|
||||
|
||||
\see PxDistanceJointFlag::eSPRING_ENABLED setDamping()
|
||||
*/
|
||||
virtual void setDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the damping of the joint spring.
|
||||
|
||||
\return the degree of damping of the joint spring of the joint
|
||||
|
||||
\see PxDistanceJointFlag::eSPRING_ENABLED setDamping()
|
||||
*/
|
||||
virtual PxReal getDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the flags specific to the Distance Joint.
|
||||
|
||||
<b>Default</b> PxDistanceJointFlag::eMAX_DISTANCE_ENABLED
|
||||
|
||||
\param[in] flags The joint flags.
|
||||
|
||||
\see PxDistanceJointFlag setFlag() getFlags()
|
||||
*/
|
||||
virtual void setDistanceJointFlags(PxDistanceJointFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Set a single flag specific to a Distance Joint to true or false.
|
||||
|
||||
\param[in] flag The flag to set or clear.
|
||||
\param[in] value the value to which to set the flag
|
||||
|
||||
\see PxDistanceJointFlag, getFlags() setFlags()
|
||||
*/
|
||||
virtual void setDistanceJointFlag(PxDistanceJointFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the flags specific to the Distance Joint.
|
||||
|
||||
\return the joint flags
|
||||
|
||||
\see PxDistanceJoint::flags, PxDistanceJointFlag setFlag() setFlags()
|
||||
*/
|
||||
virtual PxDistanceJointFlags getDistanceJointFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxDistanceJoint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxDistanceJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxDistanceJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxDistanceJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxDistanceJoint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
89
engine/third_party/physx/include/extensions/PxExtensionsAPI.h
vendored
Normal file
89
engine/third_party/physx/include/extensions/PxExtensionsAPI.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
// 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-2025 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_EXTENSIONS_API_H
|
||||
#define PX_EXTENSIONS_API_H
|
||||
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
#include "extensions/PxDefaultAllocator.h"
|
||||
#include "extensions/PxConstraintExt.h"
|
||||
#include "extensions/PxDistanceJoint.h"
|
||||
#include "extensions/PxFixedJoint.h"
|
||||
#include "extensions/PxPrismaticJoint.h"
|
||||
#include "extensions/PxRevoluteJoint.h"
|
||||
#include "extensions/PxSphericalJoint.h"
|
||||
#include "extensions/PxD6Joint.h"
|
||||
#include "extensions/PxGearJoint.h"
|
||||
#include "extensions/PxRackAndPinionJoint.h"
|
||||
#include "extensions/PxDefaultSimulationFilterShader.h"
|
||||
#include "extensions/PxDefaultErrorCallback.h"
|
||||
#include "extensions/PxDefaultStreams.h"
|
||||
#include "extensions/PxRigidActorExt.h"
|
||||
#include "extensions/PxRigidBodyExt.h"
|
||||
#include "extensions/PxShapeExt.h"
|
||||
#include "extensions/PxTriangleMeshExt.h"
|
||||
#include "extensions/PxSerialization.h"
|
||||
#include "extensions/PxDefaultCpuDispatcher.h"
|
||||
#include "extensions/PxSmoothNormals.h"
|
||||
#include "extensions/PxSimpleFactory.h"
|
||||
#include "extensions/PxStringTableExt.h"
|
||||
#include "extensions/PxBroadPhaseExt.h"
|
||||
#include "extensions/PxMassProperties.h"
|
||||
#include "extensions/PxSceneQueryExt.h"
|
||||
#include "extensions/PxSceneQuerySystemExt.h"
|
||||
#include "extensions/PxCustomSceneQuerySystem.h"
|
||||
#include "extensions/PxConvexMeshExt.h"
|
||||
#include "extensions/PxSamplingExt.h"
|
||||
#include "extensions/PxTetrahedronMeshExt.h"
|
||||
#include "extensions/PxCustomGeometryExt.h"
|
||||
#include "extensions/PxDeformableSurfaceExt.h"
|
||||
|
||||
/** \brief Initialize the PhysXExtensions library.
|
||||
|
||||
This should be called before calling any functions or methods in extensions which may require allocation.
|
||||
\note This function does not need to be called before creating a PxDefaultAllocator object.
|
||||
|
||||
\param physics a PxPhysics object
|
||||
\param pvd an PxPvd (PhysX Visual Debugger) object
|
||||
|
||||
\see PxCloseExtensions PxFoundation PxPhysics
|
||||
*/
|
||||
PX_C_EXPORT bool PX_CALL_CONV PxInitExtensions(physx::PxPhysics& physics, physx::PxPvd* pvd);
|
||||
|
||||
/** \brief Shut down the PhysXExtensions library.
|
||||
|
||||
This function should be called to cleanly shut down the PhysXExtensions library before application exit.
|
||||
|
||||
\note This function is required to be called to release foundation usage.
|
||||
|
||||
\see PxInitExtensions
|
||||
*/
|
||||
PX_C_EXPORT void PX_CALL_CONV PxCloseExtensions();
|
||||
|
||||
#endif
|
||||
|
||||
96
engine/third_party/physx/include/extensions/PxFixedJoint.h
vendored
Normal file
96
engine/third_party/physx/include/extensions/PxFixedJoint.h
vendored
Normal file
@@ -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-2025 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_FIXED_JOINT_H
|
||||
#define PX_FIXED_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxFixedJoint;
|
||||
|
||||
/**
|
||||
\brief Create a fixed joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxFixedJoint
|
||||
*/
|
||||
PxFixedJoint* PxFixedJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
/**
|
||||
\brief A fixed joint permits no relative movement between two bodies. ie the bodies are glued together.
|
||||
|
||||
\image html fixedJoint.png
|
||||
|
||||
\see PxFixedJointCreate() PxJoint
|
||||
*/
|
||||
class PxFixedJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxFixedJoint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxFixedJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxFixedJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxFixedJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxFixedJoint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
125
engine/third_party/physx/include/extensions/PxGearJoint.h
vendored
Normal file
125
engine/third_party/physx/include/extensions/PxGearJoint.h
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// 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-2025 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_GEAR_JOINT_H
|
||||
#define PX_GEAR_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGearJoint;
|
||||
|
||||
/**
|
||||
\brief Create a gear Joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxGearJoint
|
||||
*/
|
||||
PxGearJoint* PxGearJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
/**
|
||||
\brief A joint that connects two existing revolute joints and constrains their relative angular velocity with respect to each other.
|
||||
|
||||
\see PxGearJointCreate PxJoint
|
||||
*/
|
||||
class PxGearJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Set the hinge/revolute joints connected by the gear joint.
|
||||
|
||||
The passed joints can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate.
|
||||
The joints must define degrees of freedom around the twist axis.
|
||||
|
||||
Note that these joints are only used to compute the positional error correction term,
|
||||
used to adjust potential drift between jointed actors. The gear joint can run without
|
||||
calling this function, but in that case some visible overlap may develop over time between
|
||||
the teeth of the gear meshes.
|
||||
|
||||
\note Calling this function resets the internal positional error correction term.
|
||||
|
||||
\param[in] hinge0 The first hinge joint
|
||||
\param[in] hinge1 The second hinge joint
|
||||
\return true if success
|
||||
*/
|
||||
virtual bool setHinges(const PxBase* hinge0, const PxBase* hinge1) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the hinge/revolute joints connected by the gear joint.
|
||||
|
||||
\param[out] hinge0 The first hinge joint
|
||||
\param[out] hinge1 The second hinge joint
|
||||
*/
|
||||
virtual void getHinges(const PxBase*& hinge0, const PxBase*& hinge1) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the desired gear ratio.
|
||||
|
||||
For two gears with n0 and n1 teeth respectively, the gear ratio is n0/n1.
|
||||
|
||||
\note You may need to use a negative gear ratio if the joint frames of involved actors are not oriented in the same direction.
|
||||
|
||||
\note Calling this function resets the internal positional error correction term.
|
||||
|
||||
\param[in] ratio Desired ratio between the two hinges.
|
||||
*/
|
||||
virtual void setGearRatio(float ratio) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the gear ratio.
|
||||
|
||||
\return Current ratio
|
||||
*/
|
||||
virtual float getGearRatio() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxGearJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
PX_INLINE PxGearJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
PX_INLINE PxGearJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxGearJoint", PxJoint); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
234
engine/third_party/physx/include/extensions/PxGjkQueryExt.h
vendored
Normal file
234
engine/third_party/physx/include/extensions/PxGjkQueryExt.h
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
// 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-2025 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_GJK_QUERY_EXT_H
|
||||
#define PX_GJK_QUERY_EXT_H
|
||||
|
||||
#include "geometry/PxGjkQuery.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxSphereGeometry;
|
||||
class PxCapsuleGeometry;
|
||||
class PxBoxGeometry;
|
||||
class PxConvexCoreGeometry;
|
||||
class PxConvexMeshGeometry;
|
||||
class PxContactBuffer;
|
||||
class PxConvexMesh;
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for built-in convex geometry types.
|
||||
*/
|
||||
class PxGjkQueryExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Pre-made support mapping for a sphere
|
||||
*/
|
||||
struct SphereSupport : PxGjkQuery::Support
|
||||
{
|
||||
PxReal radius;
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
SphereSupport();
|
||||
/**
|
||||
\brief Constructs a SphereSupport for a sphere radius
|
||||
*/
|
||||
SphereSupport(PxReal radius);
|
||||
/**
|
||||
\brief Constructs a SphereSupport for a PxSphereGeometry
|
||||
*/
|
||||
SphereSupport(const PxSphereGeometry& geom);
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for a capsule
|
||||
*/
|
||||
struct CapsuleSupport : PxGjkQuery::Support
|
||||
{
|
||||
PxReal radius, halfHeight;
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
CapsuleSupport();
|
||||
/**
|
||||
\brief Constructs a CapsuleSupport for capsule radius and halfHeight
|
||||
*/
|
||||
CapsuleSupport(PxReal radius, PxReal halfHeight);
|
||||
/**
|
||||
\brief Constructs a CapsuleSupport for a PxCapsuleGeometry
|
||||
*/
|
||||
CapsuleSupport(const PxCapsuleGeometry& geom);
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for a box
|
||||
*/
|
||||
struct BoxSupport : PxGjkQuery::Support
|
||||
{
|
||||
PxVec3 halfExtents;
|
||||
PxReal margin;
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
BoxSupport();
|
||||
/**
|
||||
\brief Constructs a BoxSupport for a box halfExtents with optional margin
|
||||
*/
|
||||
BoxSupport(const PxVec3& halfExtents, PxReal margin = 0);
|
||||
/**
|
||||
\brief Constructs a BoxSupport for a PxBoxGeometry
|
||||
*/
|
||||
BoxSupport(const PxBoxGeometry& box, PxReal margin = 0);
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for a convex core
|
||||
*/
|
||||
struct ConvexCoreSupport : PxGjkQuery::Support
|
||||
{
|
||||
PxU64 shapeData[10];
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
ConvexCoreSupport();
|
||||
/**
|
||||
\brief Constructs a ConvexCoreSupport for a PxConvexCoreGeometry
|
||||
*/
|
||||
ConvexCoreSupport(const PxConvexCoreGeometry& geom, PxReal margin = 0);
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for a convex mesh
|
||||
*/
|
||||
struct ConvexMeshSupport : PxGjkQuery::Support
|
||||
{
|
||||
const PxConvexMesh* convexMesh;
|
||||
PxVec3 scale;
|
||||
PxQuat scaleRotation;
|
||||
PxReal margin;
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
ConvexMeshSupport();
|
||||
/**
|
||||
\brief Constructs a BoxSupport for a PxConvexMesh
|
||||
*/
|
||||
ConvexMeshSupport(const PxConvexMesh& convexMesh, const PxVec3& scale = PxVec3(1), const PxQuat& scaleRotation = PxQuat(PxIdentity), PxReal margin = 0);
|
||||
/**
|
||||
\brief Constructs a BoxSupport for a PxConvexMeshGeometry
|
||||
*/
|
||||
ConvexMeshSupport(const PxConvexMeshGeometry& convexMesh, PxReal margin = 0);
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pre-made support mapping for any PhysX's convex geometry (sphere, capsule, box, convex mesh)
|
||||
*/
|
||||
struct ConvexGeomSupport : PxGjkQuery::Support
|
||||
{
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
ConvexGeomSupport();
|
||||
/**
|
||||
\brief Constructs a BoxSupport for a PxGeometry
|
||||
*/
|
||||
ConvexGeomSupport(const PxGeometry& geom, PxReal margin = 0);
|
||||
/**
|
||||
\brief Destructor
|
||||
*/
|
||||
~ConvexGeomSupport();
|
||||
|
||||
/**
|
||||
\brief Returns false if ConvexGeomSupport was constructed from non-convex geometry
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
virtual PxReal getMargin() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const PX_OVERRIDE PX_FINAL;
|
||||
|
||||
private:
|
||||
PxGeometryType::Enum mType;
|
||||
union {
|
||||
void* alignment;
|
||||
PxU8 sphere[sizeof(SphereSupport)];
|
||||
PxU8 capsule[sizeof(CapsuleSupport)];
|
||||
PxU8 box[sizeof(BoxSupport)];
|
||||
PxU8 convexCore[sizeof(ConvexCoreSupport)];
|
||||
PxU8 convexMesh[sizeof(ConvexMeshSupport)];
|
||||
} mSupport;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Generates a contact point between two shapes using GJK-EPA algorithm
|
||||
|
||||
\param[in] a Shape A support mapping
|
||||
\param[in] b Shape B support mapping
|
||||
\param[in] poseA Shape A transformation
|
||||
\param[in] poseB Shape B transformation
|
||||
\param[in] contactDistance The distance at which contacts begin to be generated between the shapes
|
||||
\param[in] toleranceLength The toleranceLength. Used for scaling distance-based thresholds internally to produce appropriate results given simulations in different units
|
||||
\param[out] contactBuffer A buffer to store the contact
|
||||
|
||||
\return True if there is a contact.
|
||||
*/
|
||||
static bool generateContacts(const PxGjkQuery::Support& a, const PxGjkQuery::Support& b, const PxTransform& poseA, const PxTransform& poseB,
|
||||
PxReal contactDistance, PxReal toleranceLength, PxContactBuffer& contactBuffer);
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
395
engine/third_party/physx/include/extensions/PxJoint.h
vendored
Normal file
395
engine/third_party/physx/include/extensions/PxJoint.h
vendored
Normal file
@@ -0,0 +1,395 @@
|
||||
// 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-2025 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_JOINT_H
|
||||
#define PX_JOINT_H
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "PxRigidActor.h"
|
||||
#include "PxConstraint.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxRigidActor;
|
||||
class PxScene;
|
||||
class PxPhysics;
|
||||
class PxConstraint;
|
||||
|
||||
/**
|
||||
\brief an enumeration of PhysX' built-in joint types
|
||||
|
||||
\see PxJoint
|
||||
*/
|
||||
struct PxJointConcreteType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eSPHERICAL = PxConcreteType::eFIRST_PHYSX_EXTENSION,
|
||||
eREVOLUTE,
|
||||
ePRISMATIC,
|
||||
eFIXED,
|
||||
eDISTANCE,
|
||||
eD6,
|
||||
eGEAR,
|
||||
eRACK_AND_PINION,
|
||||
eLast
|
||||
};
|
||||
};
|
||||
|
||||
PX_DEFINE_TYPEINFO(PxJoint, PxConcreteType::eUNDEFINED)
|
||||
PX_DEFINE_TYPEINFO(PxRackAndPinionJoint, PxJointConcreteType::eRACK_AND_PINION)
|
||||
PX_DEFINE_TYPEINFO(PxGearJoint, PxJointConcreteType::eGEAR)
|
||||
PX_DEFINE_TYPEINFO(PxD6Joint, PxJointConcreteType::eD6)
|
||||
PX_DEFINE_TYPEINFO(PxDistanceJoint, PxJointConcreteType::eDISTANCE)
|
||||
PX_DEFINE_TYPEINFO(PxFixedJoint, PxJointConcreteType::eFIXED)
|
||||
PX_DEFINE_TYPEINFO(PxPrismaticJoint, PxJointConcreteType::ePRISMATIC)
|
||||
PX_DEFINE_TYPEINFO(PxRevoluteJoint, PxJointConcreteType::eREVOLUTE)
|
||||
PX_DEFINE_TYPEINFO(PxSphericalJoint, PxJointConcreteType::eSPHERICAL)
|
||||
|
||||
|
||||
/**
|
||||
\brief an enumeration for specifying one or other of the actors referenced by a joint
|
||||
|
||||
\see PxJoint
|
||||
*/
|
||||
|
||||
struct PxJointActorIndex
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eACTOR0,
|
||||
eACTOR1,
|
||||
COUNT
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief a base interface providing common functionality for PhysX joints
|
||||
*/
|
||||
|
||||
class PxJoint : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Set the actors for this joint.
|
||||
|
||||
An actor may be NULL to indicate the world frame. At most one of the actors may be NULL.
|
||||
|
||||
\param[in] actor0 the first actor.
|
||||
\param[in] actor1 the second actor
|
||||
|
||||
\see getActors()
|
||||
*/
|
||||
virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the actors for this joint.
|
||||
|
||||
\param[out] actor0 the first actor.
|
||||
\param[out] actor1 the second actor
|
||||
|
||||
\see setActors()
|
||||
*/
|
||||
virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the joint local pose for an actor.
|
||||
|
||||
This is the relative pose which locates the joint frame relative to the actor.
|
||||
|
||||
\param[in] actor 0 for the first actor, 1 for the second actor.
|
||||
\param[in] localPose the local pose for the actor this joint
|
||||
|
||||
\see getLocalPose()
|
||||
*/
|
||||
virtual void setLocalPose(PxJointActorIndex::Enum actor, const PxTransform& localPose) = 0;
|
||||
|
||||
/**
|
||||
\brief get the joint local pose for an actor.
|
||||
|
||||
\param[in] actor 0 for the first actor, 1 for the second actor.
|
||||
|
||||
return the local pose for this joint
|
||||
|
||||
\see setLocalPose()
|
||||
*/
|
||||
virtual PxTransform getLocalPose(PxJointActorIndex::Enum actor) const = 0;
|
||||
|
||||
/**
|
||||
\brief get the relative pose for this joint
|
||||
|
||||
This function returns the pose of the joint frame of actor1 relative to actor0
|
||||
|
||||
*/
|
||||
virtual PxTransform getRelativeTransform() const = 0;
|
||||
|
||||
/**
|
||||
\brief get the relative linear velocity of the joint
|
||||
|
||||
This function returns the linear velocity of the origin of the constraint frame of actor1, relative to the origin of the constraint
|
||||
frame of actor0. The value is returned in the constraint frame of actor0
|
||||
*/
|
||||
virtual PxVec3 getRelativeLinearVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief get the relative angular velocity of the joint
|
||||
|
||||
This function returns the angular velocity of actor1 relative to actor0. The value is returned in the constraint frame of actor0
|
||||
*/
|
||||
virtual PxVec3 getRelativeAngularVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the break force for this joint.
|
||||
|
||||
if the constraint force or torque on the joint exceeds the specified values, the joint will break,
|
||||
at which point it will not constrain the two actors and the flag PxConstraintFlag::eBROKEN will be set. The
|
||||
force and torque are measured in the joint frame of the first actor
|
||||
|
||||
\param[in] force the maximum force the joint can apply before breaking
|
||||
\param[in] torque the maximum torque the joint can apply before breaking
|
||||
*/
|
||||
virtual void setBreakForce(PxReal force, PxReal torque) = 0;
|
||||
|
||||
/**
|
||||
\brief get the break force for this joint.
|
||||
|
||||
\param[out] force the maximum force the joint can apply before breaking
|
||||
\param[out] torque the maximum torque the joint can apply before breaking
|
||||
|
||||
\see setBreakForce()
|
||||
*/
|
||||
virtual void getBreakForce(PxReal& force, PxReal& torque) const = 0;
|
||||
|
||||
/**
|
||||
\brief set the constraint flags for this joint.
|
||||
|
||||
\param[in] flags the constraint flags
|
||||
|
||||
\see PxConstraintFlag
|
||||
*/
|
||||
virtual void setConstraintFlags(PxConstraintFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief set a constraint flags for this joint to a specified value.
|
||||
|
||||
\param[in] flag the constraint flag
|
||||
\param[in] value the value to which to set the flag
|
||||
|
||||
\see PxConstraintFlag
|
||||
*/
|
||||
virtual void setConstraintFlag(PxConstraintFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief get the constraint flags for this joint.
|
||||
|
||||
\return the constraint flags
|
||||
|
||||
\see PxConstraintFlag
|
||||
*/
|
||||
virtual PxConstraintFlags getConstraintFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the inverse mass scale for actor0.
|
||||
|
||||
\param[in] invMassScale the scale to apply to the inverse mass of actor 0 for resolving this constraint
|
||||
|
||||
\see getInvMassScale0
|
||||
*/
|
||||
virtual void setInvMassScale0(PxReal invMassScale) = 0;
|
||||
|
||||
/**
|
||||
\brief get the inverse mass scale for actor0.
|
||||
|
||||
\return inverse mass scale for actor0
|
||||
|
||||
\see setInvMassScale0
|
||||
*/
|
||||
virtual PxReal getInvMassScale0() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the inverse inertia scale for actor0.
|
||||
|
||||
\param[in] invInertiaScale the scale to apply to the inverse inertia of actor0 for resolving this constraint
|
||||
|
||||
\see getInvMassScale0
|
||||
*/
|
||||
virtual void setInvInertiaScale0(PxReal invInertiaScale) = 0;
|
||||
|
||||
/**
|
||||
\brief get the inverse inertia scale for actor0.
|
||||
|
||||
\return inverse inertia scale for actor0
|
||||
|
||||
\see setInvInertiaScale0
|
||||
*/
|
||||
virtual PxReal getInvInertiaScale0() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the inverse mass scale for actor1.
|
||||
|
||||
\param[in] invMassScale the scale to apply to the inverse mass of actor 1 for resolving this constraint
|
||||
|
||||
\see getInvMassScale1
|
||||
*/
|
||||
virtual void setInvMassScale1(PxReal invMassScale) = 0;
|
||||
|
||||
/**
|
||||
\brief get the inverse mass scale for actor1.
|
||||
|
||||
\return inverse mass scale for actor1
|
||||
|
||||
\see setInvMassScale1
|
||||
*/
|
||||
virtual PxReal getInvMassScale1() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the inverse inertia scale for actor1.
|
||||
|
||||
\param[in] invInertiaScale the scale to apply to the inverse inertia of actor1 for resolving this constraint
|
||||
|
||||
\see getInvInertiaScale1
|
||||
*/
|
||||
virtual void setInvInertiaScale1(PxReal invInertiaScale) = 0;
|
||||
|
||||
/**
|
||||
\brief get the inverse inertia scale for actor1.
|
||||
|
||||
\return inverse inertia scale for actor1
|
||||
|
||||
\see setInvInertiaScale1
|
||||
*/
|
||||
virtual PxReal getInvInertiaScale1() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the PxConstraint corresponding to this joint.
|
||||
|
||||
This can be used to determine, among other things, the force applied at the joint.
|
||||
|
||||
\return the constraint
|
||||
*/
|
||||
virtual PxConstraint* getConstraint() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets a name string for the object that can be retrieved with getName().
|
||||
|
||||
This is for debugging and is not used by the SDK. The string is not copied by the SDK,
|
||||
only the pointer is stored.
|
||||
|
||||
\param[in] name String to set the objects name to.
|
||||
|
||||
\see getName()
|
||||
*/
|
||||
virtual void setName(const char* name) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the name string set with setName().
|
||||
|
||||
\return Name string associated with object.
|
||||
|
||||
\see setName()
|
||||
*/
|
||||
virtual const char* getName() const = 0;
|
||||
|
||||
/**
|
||||
\brief Deletes the joint.
|
||||
|
||||
\note This call does not wake up the connected rigid bodies.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the scene which this joint belongs to.
|
||||
|
||||
\return Owner Scene. NULL if not part of a scene.
|
||||
|
||||
\see PxScene
|
||||
*/
|
||||
virtual PxScene* getScene() const = 0;
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
virtual ~PxJoint() {}
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxJoint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxJoint(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxJoint", PxBase); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
class PxSpring
|
||||
{
|
||||
public:
|
||||
|
||||
PxReal stiffness; //!< the spring strength of the drive: that is, the force proportional to the position error
|
||||
PxReal damping; //!< the damping strength of the drive: that is, the force proportional to the velocity error
|
||||
|
||||
PxSpring(PxReal stiffness_, PxReal damping_): stiffness(stiffness_), damping(damping_) {}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** \brief Helper function to setup a joint's global frame
|
||||
|
||||
This replaces the following functions from previous SDK versions:
|
||||
|
||||
void NxJointDesc::setGlobalAnchor(const NxVec3& wsAnchor);
|
||||
void NxJointDesc::setGlobalAxis(const NxVec3& wsAxis);
|
||||
|
||||
The function sets the joint's localPose using world-space input parameters.
|
||||
|
||||
\param[in] wsAnchor Global frame anchor point. <b>Range:</b> position vector
|
||||
\param[in] wsAxis Global frame axis. <b>Range:</b> direction vector
|
||||
\param[in,out] joint Joint having its global frame set.
|
||||
*/
|
||||
|
||||
PX_C_EXPORT void PX_CALL_CONV PxSetJointGlobalFrame(physx::PxJoint& joint, const physx::PxVec3* wsAnchor, const physx::PxVec3* wsAxis);
|
||||
|
||||
#endif
|
||||
483
engine/third_party/physx/include/extensions/PxJointLimit.h
vendored
Normal file
483
engine/third_party/physx/include/extensions/PxJointLimit.h
vendored
Normal file
@@ -0,0 +1,483 @@
|
||||
// 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-2025 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_JOINT_LIMIT_H
|
||||
#define PX_JOINT_LIMIT_H
|
||||
|
||||
#include "foundation/PxMath.h"
|
||||
#include "common/PxTolerancesScale.h"
|
||||
#include "extensions/PxJoint.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Describes the parameters for a joint limit.
|
||||
|
||||
Limits are enabled or disabled by setting flags or other configuration parameters joints, see the
|
||||
documentation for specific joint types for details.
|
||||
*/
|
||||
class PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Controls the amount of bounce when the joint hits a limit.
|
||||
|
||||
A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit.
|
||||
A value of zero causes the joint to stop dead.
|
||||
|
||||
In situations where the joint has many locked DOFs (e.g. 5) the restitution may not be applied
|
||||
correctly. This is due to a limitation in the solver which causes the restitution velocity to become zero
|
||||
as the solver enforces constraints on the other DOFs.
|
||||
|
||||
This limitation applies to both angular and linear limits, however it is generally most apparent with limited
|
||||
angular DOFs. Disabling joint projection and increasing the solver iteration count may improve this behavior
|
||||
to some extent.
|
||||
|
||||
Also, combining soft joint limits with joint drives driving against those limits may affect stability.
|
||||
|
||||
<b>Range:</b> [0,1]<br>
|
||||
<b>Default:</b> 0.0
|
||||
*/
|
||||
PxReal restitution;
|
||||
|
||||
/**
|
||||
determines the minimum impact velocity which will cause the joint to bounce
|
||||
*/
|
||||
PxReal bounceThreshold;
|
||||
|
||||
/**
|
||||
\brief if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 0.0
|
||||
*/
|
||||
PxReal stiffness;
|
||||
|
||||
/**
|
||||
\brief if spring is greater than zero, this is the damping of the limit spring
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 0.0
|
||||
*/
|
||||
PxReal damping;
|
||||
|
||||
PxJointLimitParameters() :
|
||||
restitution (0.0f),
|
||||
bounceThreshold (0.0f),
|
||||
stiffness (0.0f),
|
||||
damping (0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
PxJointLimitParameters(const PxJointLimitParameters& p) :
|
||||
restitution (p.restitution),
|
||||
bounceThreshold (p.bounceThreshold),
|
||||
stiffness (p.stiffness),
|
||||
damping (p.damping)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the current settings are valid.
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxIsFinite(restitution) && restitution >= 0 && restitution <= 1 &&
|
||||
PxIsFinite(stiffness) && stiffness >= 0 &&
|
||||
PxIsFinite(damping) && damping >= 0 &&
|
||||
PxIsFinite(bounceThreshold) && bounceThreshold >= 0;
|
||||
}
|
||||
|
||||
PX_INLINE bool isSoft() const
|
||||
{
|
||||
return damping>0 || stiffness>0;
|
||||
}
|
||||
|
||||
protected:
|
||||
~PxJointLimitParameters() {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Describes a one-sided linear limit.
|
||||
*/
|
||||
class PxJointLinearLimit : public PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief the extent of the limit.
|
||||
|
||||
<b>Range:</b> (0, PX_MAX_F32) <br>
|
||||
<b>Default:</b> PX_MAX_F32
|
||||
*/
|
||||
PxReal value;
|
||||
|
||||
/**
|
||||
\brief construct a linear hard limit
|
||||
|
||||
\param[in] extent The extent of the limit
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLinearLimit(PxReal extent) : value(extent)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief construct a linear soft limit
|
||||
|
||||
\param[in] extent the extent of the limit
|
||||
\param[in] spring the stiffness and damping parameters for the limit spring
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLinearLimit(PxReal extent, const PxSpring& spring) : value(extent)
|
||||
{
|
||||
stiffness = spring.stiffness;
|
||||
damping = spring.damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the limit is valid
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxJointLimitParameters::isValid() &&
|
||||
PxIsFinite(value) &&
|
||||
value > 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Describes a two-sided limit.
|
||||
*/
|
||||
class PxJointLinearLimitPair : public PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief the range of the limit. The upper limit must be no lower than the
|
||||
lower limit, and if they are equal the limited degree of freedom will be treated as locked.
|
||||
|
||||
<b>Range:</b> See the joint on which the limit is used for details<br>
|
||||
<b>Default:</b> lower = -PX_MAX_F32/3, upper = PX_MAX_F32/3
|
||||
*/
|
||||
PxReal upper, lower;
|
||||
|
||||
/**
|
||||
\brief Construct a linear hard limit pair. The lower distance value must be less than the upper distance value.
|
||||
|
||||
\param[in] scale A PxTolerancesScale struct. Should be the same as used when creating the PxPhysics object.
|
||||
\param[in] lowerLimit The lower distance of the limit
|
||||
\param[in] upperLimit The upper distance of the limit
|
||||
|
||||
\see PxJointLimitParameters PxTolerancesScale
|
||||
*/
|
||||
PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit = -PX_MAX_F32/3.0f, PxReal upperLimit = PX_MAX_F32/3.0f) :
|
||||
upper(upperLimit),
|
||||
lower(lowerLimit)
|
||||
{
|
||||
bounceThreshold = 2.0f*scale.length;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief construct a linear soft limit pair
|
||||
|
||||
\param[in] lowerLimit The lower distance of the limit
|
||||
\param[in] upperLimit The upper distance of the limit
|
||||
\param[in] spring The stiffness and damping parameters of the limit spring
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) :
|
||||
upper(upperLimit),
|
||||
lower(lowerLimit)
|
||||
{
|
||||
stiffness = spring.stiffness;
|
||||
damping = spring.damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the limit is valid.
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxJointLimitParameters::isValid() &&
|
||||
PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower &&
|
||||
PxIsFinite(upper - lower);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PxJointAngularLimitPair : public PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief the range of the limit. The upper limit must be no lower than the lower limit.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> See the joint on which the limit is used for details<br>
|
||||
<b>Default:</b> lower = -PI/2, upper = PI/2
|
||||
*/
|
||||
PxReal upper, lower;
|
||||
|
||||
/**
|
||||
\brief construct an angular hard limit pair.
|
||||
|
||||
The lower value must be less than the upper value.
|
||||
|
||||
\param[in] lowerLimit The lower angle of the limit
|
||||
\param[in] upperLimit The upper angle of the limit
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit) :
|
||||
upper(upperLimit),
|
||||
lower(lowerLimit)
|
||||
{
|
||||
bounceThreshold = 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief construct an angular soft limit pair.
|
||||
|
||||
The lower value must be less than the upper value.
|
||||
|
||||
\param[in] lowerLimit The lower angle of the limit
|
||||
\param[in] upperLimit The upper angle of the limit
|
||||
\param[in] spring The stiffness and damping of the limit spring
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) :
|
||||
upper(upperLimit),
|
||||
lower(lowerLimit)
|
||||
{
|
||||
stiffness = spring.stiffness;
|
||||
damping = spring.damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the limit is valid.
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxJointLimitParameters::isValid() &&
|
||||
PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes an elliptical conical joint limit. Note that very small or highly elliptical limit cones may
|
||||
result in jitter.
|
||||
|
||||
\see PxD6Joint PxSphericalJoint
|
||||
*/
|
||||
class PxJointLimitCone : public PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief the maximum angle from the Y axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (0,PI)<br>
|
||||
<b>Default:</b> PI/2
|
||||
*/
|
||||
PxReal yAngle;
|
||||
|
||||
/**
|
||||
\brief the maximum angle from the Z-axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (0,PI)<br>
|
||||
<b>Default:</b> PI/2
|
||||
*/
|
||||
PxReal zAngle;
|
||||
|
||||
/**
|
||||
\brief Construct a cone hard limit.
|
||||
|
||||
\param[in] yLimitAngle The limit angle from the Y-axis of the constraint frame
|
||||
\param[in] zLimitAngle The limit angle from the Z-axis of the constraint frame
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle) :
|
||||
yAngle(yLimitAngle),
|
||||
zAngle(zLimitAngle)
|
||||
{
|
||||
bounceThreshold = 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Construct a cone soft limit.
|
||||
|
||||
\param[in] yLimitAngle The limit angle from the Y-axis of the constraint frame
|
||||
\param[in] zLimitAngle The limit angle from the Z-axis of the constraint frame
|
||||
\param[in] spring The stiffness and damping of the limit spring
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring& spring) :
|
||||
yAngle(yLimitAngle),
|
||||
zAngle(zLimitAngle)
|
||||
{
|
||||
stiffness = spring.stiffness;
|
||||
damping = spring.damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the limit is valid.
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxJointLimitParameters::isValid() &&
|
||||
PxIsFinite(yAngle) && yAngle>0 && yAngle<PxPi &&
|
||||
PxIsFinite(zAngle) && zAngle>0 && zAngle<PxPi;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a pyramidal joint limit.
|
||||
|
||||
\see PxD6Joint
|
||||
*/
|
||||
class PxJointLimitPyramid : public PxJointLimitParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief the minimum angle from the Y axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (-PI,PI)<br>
|
||||
<b>Default:</b> -PI/2
|
||||
*/
|
||||
PxReal yAngleMin;
|
||||
|
||||
/**
|
||||
\brief the maximum angle from the Y axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (-PI,PI)<br>
|
||||
<b>Default:</b> PI/2
|
||||
*/
|
||||
PxReal yAngleMax;
|
||||
|
||||
/**
|
||||
\brief the minimum angle from the Z-axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (-PI,PI)<br>
|
||||
<b>Default:</b> -PI/2
|
||||
*/
|
||||
PxReal zAngleMin;
|
||||
|
||||
/**
|
||||
\brief the maximum angle from the Z-axis of the constraint frame.
|
||||
|
||||
<b>Unit:</b> Angular: Radians
|
||||
<b>Range:</b> Angular: (-PI,PI)<br>
|
||||
<b>Default:</b> PI/2
|
||||
*/
|
||||
PxReal zAngleMax;
|
||||
|
||||
/**
|
||||
\brief Construct a pyramid hard limit.
|
||||
|
||||
\param[in] yLimitAngleMin The minimum limit angle from the Y-axis of the constraint frame
|
||||
\param[in] yLimitAngleMax The maximum limit angle from the Y-axis of the constraint frame
|
||||
\param[in] zLimitAngleMin The minimum limit angle from the Z-axis of the constraint frame
|
||||
\param[in] zLimitAngleMax The maximum limit angle from the Z-axis of the constraint frame
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax) :
|
||||
yAngleMin(yLimitAngleMin),
|
||||
yAngleMax(yLimitAngleMax),
|
||||
zAngleMin(zLimitAngleMin),
|
||||
zAngleMax(zLimitAngleMax)
|
||||
{
|
||||
bounceThreshold = 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Construct a pyramid soft limit.
|
||||
|
||||
\param[in] yLimitAngleMin The minimum limit angle from the Y-axis of the constraint frame
|
||||
\param[in] yLimitAngleMax The maximum limit angle from the Y-axis of the constraint frame
|
||||
\param[in] zLimitAngleMin The minimum limit angle from the Z-axis of the constraint frame
|
||||
\param[in] zLimitAngleMax The maximum limit angle from the Z-axis of the constraint frame
|
||||
\param[in] spring The stiffness and damping of the limit spring
|
||||
|
||||
\see PxJointLimitParameters
|
||||
*/
|
||||
PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, const PxSpring& spring) :
|
||||
yAngleMin(yLimitAngleMin),
|
||||
yAngleMax(yLimitAngleMax),
|
||||
zAngleMin(zLimitAngleMin),
|
||||
zAngleMax(zLimitAngleMax)
|
||||
{
|
||||
stiffness = spring.stiffness;
|
||||
damping = spring.damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the limit is valid.
|
||||
|
||||
\return true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
return PxJointLimitParameters::isValid() &&
|
||||
PxIsFinite(yAngleMin) && yAngleMin>-PxPi && yAngleMin<PxPi &&
|
||||
PxIsFinite(yAngleMax) && yAngleMax>-PxPi && yAngleMax<PxPi &&
|
||||
PxIsFinite(zAngleMin) && zAngleMin>-PxPi && zAngleMin<PxPi &&
|
||||
PxIsFinite(zAngleMax) && zAngleMax>-PxPi && zAngleMax<PxPi &&
|
||||
yAngleMax>=yAngleMin && zAngleMax>=zAngleMin;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
370
engine/third_party/physx/include/extensions/PxMassProperties.h
vendored
Normal file
370
engine/third_party/physx/include/extensions/PxMassProperties.h
vendored
Normal file
@@ -0,0 +1,370 @@
|
||||
// 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-2025 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_MASS_PROPERTIES_H
|
||||
#define PX_MASS_PROPERTIES_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxMath.h"
|
||||
#include "foundation/PxMathUtils.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxBoxGeometry.h"
|
||||
#include "geometry/PxSphereGeometry.h"
|
||||
#include "geometry/PxCapsuleGeometry.h"
|
||||
#include "geometry/PxConvexMeshGeometry.h"
|
||||
#include "geometry/PxConvexMesh.h"
|
||||
#include "geometry/PxCustomGeometry.h"
|
||||
#include "geometry/PxConvexCoreGeometry.h"
|
||||
#include "geometry/PxTriangleMeshGeometry.h"
|
||||
#include "geometry/PxTriangleMesh.h"
|
||||
#include "PxConvexCoreExt.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Utility class to compute and manipulate mass and inertia tensor properties.
|
||||
|
||||
In most cases #PxRigidBodyExt::updateMassAndInertia(), #PxRigidBodyExt::setMassAndUpdateInertia() should be enough to
|
||||
setup the mass properties of a rigid body. This utility class targets users that need to customize the mass properties
|
||||
computation.
|
||||
*/
|
||||
class PxMassProperties
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Default constructor.
|
||||
*/
|
||||
PX_FORCE_INLINE PxMassProperties() : inertiaTensor(PxIdentity), centerOfMass(0.0f), mass(1.0f) {}
|
||||
|
||||
/**
|
||||
\brief Construct from individual elements.
|
||||
*/
|
||||
PX_FORCE_INLINE PxMassProperties(const PxReal m, const PxMat33& inertiaT, const PxVec3& com) : inertiaTensor(inertiaT), centerOfMass(com), mass(m) {}
|
||||
|
||||
/**
|
||||
\brief Compute mass properties based on a provided geometry structure.
|
||||
|
||||
This constructor assumes the geometry has a density of 1. Mass and inertia tensor scale linearly with density.
|
||||
|
||||
\param[in] geometry The geometry to compute the mass properties for. Supported geometry types are: sphere, box, capsule and convex mesh.
|
||||
*/
|
||||
PxMassProperties(const PxGeometry& geometry)
|
||||
{
|
||||
switch (geometry.getType())
|
||||
{
|
||||
case PxGeometryType::eSPHERE:
|
||||
{
|
||||
const PxSphereGeometry& s = static_cast<const PxSphereGeometry&>(geometry);
|
||||
mass = (4.0f / 3.0f) * PxPi * s.radius * s.radius * s.radius;
|
||||
inertiaTensor = PxMat33::createDiagonal(PxVec3(2.0f / 5.0f * mass * s.radius * s.radius));
|
||||
centerOfMass = PxVec3(0.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eBOX:
|
||||
{
|
||||
const PxBoxGeometry& b = static_cast<const PxBoxGeometry&>(geometry);
|
||||
mass = b.halfExtents.x * b.halfExtents.y * b.halfExtents.z * 8.0f;
|
||||
PxVec3 d2 = b.halfExtents.multiply(b.halfExtents);
|
||||
inertiaTensor = PxMat33::createDiagonal(PxVec3(d2.y + d2.z, d2.x + d2.z, d2.x + d2.y)) * (mass * 1.0f / 3.0f);
|
||||
centerOfMass = PxVec3(0.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eCAPSULE:
|
||||
{
|
||||
const PxCapsuleGeometry& c = static_cast<const PxCapsuleGeometry&>(geometry);
|
||||
PxReal r = c.radius, h = c.halfHeight;
|
||||
mass = ((4.0f / 3.0f) * r + 2 * c.halfHeight) * PxPi * r * r;
|
||||
|
||||
PxReal a = r*r*r * (8.0f / 15.0f) + h*r*r * (3.0f / 2.0f) + h*h*r * (4.0f / 3.0f) + h*h*h * (2.0f / 3.0f);
|
||||
PxReal b = r*r*r * (8.0f / 15.0f) + h*r*r;
|
||||
inertiaTensor = PxMat33::createDiagonal(PxVec3(b, a, a) * PxPi * r * r);
|
||||
centerOfMass = PxVec3(0.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eCONVEXCORE:
|
||||
{
|
||||
const PxConvexCoreGeometry& g = static_cast<const PxConvexCoreGeometry&>(geometry);
|
||||
PxConvexCoreExt::computeMassInfo(g, mass, inertiaTensor, centerOfMass);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eCONVEXMESH:
|
||||
{
|
||||
const PxConvexMeshGeometry& c = static_cast<const PxConvexMeshGeometry&>(geometry);
|
||||
PxVec3 unscaledCoM;
|
||||
PxMat33 unscaledInertiaTensorNonCOM; // inertia tensor of convex mesh in mesh local space
|
||||
PxMat33 unscaledInertiaTensorCOM;
|
||||
PxReal unscaledMass;
|
||||
c.convexMesh->getMassInformation(unscaledMass, unscaledInertiaTensorNonCOM, unscaledCoM);
|
||||
|
||||
// inertia tensor relative to center of mass
|
||||
unscaledInertiaTensorCOM[0][0] = unscaledInertiaTensorNonCOM[0][0] - unscaledMass*PxReal((unscaledCoM.y*unscaledCoM.y+unscaledCoM.z*unscaledCoM.z));
|
||||
unscaledInertiaTensorCOM[1][1] = unscaledInertiaTensorNonCOM[1][1] - unscaledMass*PxReal((unscaledCoM.z*unscaledCoM.z+unscaledCoM.x*unscaledCoM.x));
|
||||
unscaledInertiaTensorCOM[2][2] = unscaledInertiaTensorNonCOM[2][2] - unscaledMass*PxReal((unscaledCoM.x*unscaledCoM.x+unscaledCoM.y*unscaledCoM.y));
|
||||
unscaledInertiaTensorCOM[0][1] = unscaledInertiaTensorCOM[1][0] = (unscaledInertiaTensorNonCOM[0][1] + unscaledMass*PxReal(unscaledCoM.x*unscaledCoM.y));
|
||||
unscaledInertiaTensorCOM[1][2] = unscaledInertiaTensorCOM[2][1] = (unscaledInertiaTensorNonCOM[1][2] + unscaledMass*PxReal(unscaledCoM.y*unscaledCoM.z));
|
||||
unscaledInertiaTensorCOM[0][2] = unscaledInertiaTensorCOM[2][0] = (unscaledInertiaTensorNonCOM[0][2] + unscaledMass*PxReal(unscaledCoM.z*unscaledCoM.x));
|
||||
|
||||
const PxMeshScale& s = c.scale;
|
||||
mass = unscaledMass * s.scale.x * s.scale.y * s.scale.z;
|
||||
centerOfMass = s.transform(unscaledCoM);
|
||||
inertiaTensor = scaleInertia(unscaledInertiaTensorCOM, s.rotation, s.scale);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eCUSTOM:
|
||||
{
|
||||
*this = PxMassProperties();
|
||||
static_cast<const PxCustomGeometry&>(geometry).callbacks->computeMassProperties(geometry, *this);
|
||||
}
|
||||
break;
|
||||
|
||||
case PxGeometryType::eTRIANGLEMESH:
|
||||
{
|
||||
const PxTriangleMeshGeometry& g = static_cast<const PxTriangleMeshGeometry&>(geometry);
|
||||
|
||||
PxVec3 unscaledCoM;
|
||||
PxMat33 unscaledInertiaTensorNonCOM; // inertia tensor of convex mesh in mesh local space
|
||||
PxMat33 unscaledInertiaTensorCOM;
|
||||
PxReal unscaledMass;
|
||||
g.triangleMesh->getMassInformation(unscaledMass, unscaledInertiaTensorNonCOM, unscaledCoM);
|
||||
|
||||
// inertia tensor relative to center of mass
|
||||
unscaledInertiaTensorCOM[0][0] = unscaledInertiaTensorNonCOM[0][0] - unscaledMass * PxReal((unscaledCoM.y*unscaledCoM.y + unscaledCoM.z*unscaledCoM.z));
|
||||
unscaledInertiaTensorCOM[1][1] = unscaledInertiaTensorNonCOM[1][1] - unscaledMass * PxReal((unscaledCoM.z*unscaledCoM.z + unscaledCoM.x*unscaledCoM.x));
|
||||
unscaledInertiaTensorCOM[2][2] = unscaledInertiaTensorNonCOM[2][2] - unscaledMass * PxReal((unscaledCoM.x*unscaledCoM.x + unscaledCoM.y*unscaledCoM.y));
|
||||
unscaledInertiaTensorCOM[0][1] = unscaledInertiaTensorCOM[1][0] = (unscaledInertiaTensorNonCOM[0][1] + unscaledMass * PxReal(unscaledCoM.x*unscaledCoM.y));
|
||||
unscaledInertiaTensorCOM[1][2] = unscaledInertiaTensorCOM[2][1] = (unscaledInertiaTensorNonCOM[1][2] + unscaledMass * PxReal(unscaledCoM.y*unscaledCoM.z));
|
||||
unscaledInertiaTensorCOM[0][2] = unscaledInertiaTensorCOM[2][0] = (unscaledInertiaTensorNonCOM[0][2] + unscaledMass * PxReal(unscaledCoM.z*unscaledCoM.x));
|
||||
|
||||
const PxMeshScale& s = g.scale;
|
||||
mass = unscaledMass * s.scale.x * s.scale.y * s.scale.z;
|
||||
centerOfMass = s.transform(unscaledCoM);
|
||||
inertiaTensor = scaleInertia(unscaledInertiaTensorCOM, s.rotation, s.scale);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
*this = PxMassProperties();
|
||||
}
|
||||
}
|
||||
|
||||
PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite());
|
||||
PX_ASSERT(centerOfMass.isFinite());
|
||||
PX_ASSERT(PxIsFinite(mass));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Scale mass properties.
|
||||
|
||||
\param[in] scale The linear scaling factor to apply to the mass properties.
|
||||
\return The scaled mass properties.
|
||||
*/
|
||||
PX_FORCE_INLINE PxMassProperties operator*(const PxReal scale) const
|
||||
{
|
||||
PX_ASSERT(PxIsFinite(scale));
|
||||
|
||||
return PxMassProperties(mass * scale, inertiaTensor * scale, centerOfMass);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Translate the center of mass by a given vector and adjust the inertia tensor accordingly.
|
||||
|
||||
\param[in] t The translation vector for the center of mass.
|
||||
*/
|
||||
PX_FORCE_INLINE void translate(const PxVec3& t)
|
||||
{
|
||||
PX_ASSERT(t.isFinite());
|
||||
|
||||
inertiaTensor = translateInertia(inertiaTensor, mass, t);
|
||||
centerOfMass += t;
|
||||
|
||||
PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite());
|
||||
PX_ASSERT(centerOfMass.isFinite());
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the entries of the diagonalized inertia tensor and the corresponding reference rotation.
|
||||
|
||||
\param[in] inertia The inertia tensor to diagonalize.
|
||||
\param[out] massFrame The frame the diagonalized tensor refers to.
|
||||
\return The entries of the diagonalized inertia tensor.
|
||||
*/
|
||||
PX_FORCE_INLINE static PxVec3 getMassSpaceInertia(const PxMat33& inertia, PxQuat& massFrame)
|
||||
{
|
||||
PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite());
|
||||
|
||||
PxVec3 diagT = PxDiagonalize(inertia, massFrame);
|
||||
PX_ASSERT(diagT.isFinite());
|
||||
PX_ASSERT(massFrame.isFinite());
|
||||
return diagT;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Translate an inertia tensor using the parallel axis theorem
|
||||
|
||||
\param[in] inertia The inertia tensor to translate.
|
||||
\param[in] mass The mass of the object.
|
||||
\param[in] t The relative frame to translate the inertia tensor to.
|
||||
\return The translated inertia tensor.
|
||||
*/
|
||||
PX_FORCE_INLINE static PxMat33 translateInertia(const PxMat33& inertia, const PxReal mass, const PxVec3& t)
|
||||
{
|
||||
PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite());
|
||||
PX_ASSERT(PxIsFinite(mass));
|
||||
PX_ASSERT(t.isFinite());
|
||||
|
||||
PxMat33 s( PxVec3(0,t.z,-t.y),
|
||||
PxVec3(-t.z,0,t.x),
|
||||
PxVec3(t.y,-t.x,0) );
|
||||
|
||||
PxMat33 translatedIT = s.getTranspose() * s * mass + inertia;
|
||||
PX_ASSERT(translatedIT.column0.isFinite() && translatedIT.column1.isFinite() && translatedIT.column2.isFinite());
|
||||
return translatedIT;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Rotate an inertia tensor around the center of mass
|
||||
|
||||
\param[in] inertia The inertia tensor to rotate.
|
||||
\param[in] q The rotation from the new to the old coordinate frame, i.e. q.rotate(v) transforms
|
||||
the coordinates of vector v from the old to the new coordinate frame.
|
||||
\return The rotated inertia tensor.
|
||||
*/
|
||||
PX_FORCE_INLINE static PxMat33 rotateInertia(const PxMat33& inertia, const PxQuat& q)
|
||||
{
|
||||
PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite());
|
||||
PX_ASSERT(q.isUnit());
|
||||
|
||||
PxMat33 m(q);
|
||||
PxMat33 rotatedIT = m * inertia * m.getTranspose();
|
||||
PX_ASSERT(rotatedIT.column0.isFinite() && rotatedIT.column1.isFinite() && rotatedIT.column2.isFinite());
|
||||
return rotatedIT;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Non-uniform scaling of the inertia tensor
|
||||
|
||||
\param[in] inertia The inertia tensor to scale.
|
||||
\param[in] scaleRotation The rotation from the scaling frame to the frame that inertia is expressed in.
|
||||
I.e. scaleRotation.rotate(v) transforms the coordinates of vertex v from inertia's frame to the scaling-axes frame.
|
||||
\param[in] scale The scaling factor for each axis (relative to the frame specified with scaleRotation).
|
||||
\return The scaled inertia tensor.
|
||||
*/
|
||||
static PxMat33 scaleInertia(const PxMat33& inertia, const PxQuat& scaleRotation, const PxVec3& scale)
|
||||
{
|
||||
PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite());
|
||||
PX_ASSERT(scaleRotation.isUnit());
|
||||
PX_ASSERT(scale.isFinite());
|
||||
|
||||
PxMat33 localInertiaT = rotateInertia(inertia, scaleRotation); // rotate inertia into scaling frame
|
||||
PxVec3 diagonal(localInertiaT[0][0], localInertiaT[1][1], localInertiaT[2][2]);
|
||||
|
||||
PxVec3 xyz2 = PxVec3(diagonal.dot(PxVec3(0.5f))) - diagonal; // original x^2, y^2, z^2
|
||||
PxVec3 scaledxyz2 = xyz2.multiply(scale).multiply(scale);
|
||||
|
||||
PxReal xx = scaledxyz2.y + scaledxyz2.z,
|
||||
yy = scaledxyz2.z + scaledxyz2.x,
|
||||
zz = scaledxyz2.x + scaledxyz2.y;
|
||||
|
||||
PxReal xy = localInertiaT[0][1] * scale.x * scale.y,
|
||||
xz = localInertiaT[0][2] * scale.x * scale.z,
|
||||
yz = localInertiaT[1][2] * scale.y * scale.z;
|
||||
|
||||
PxMat33 scaledInertia( PxVec3(xx, xy, xz),
|
||||
PxVec3(xy, yy, yz),
|
||||
PxVec3(xz, yz, zz));
|
||||
|
||||
PxMat33 scaledIT = rotateInertia(scaledInertia * (scale.x * scale.y * scale.z), scaleRotation.getConjugate());
|
||||
PX_ASSERT(scaledIT.column0.isFinite() && scaledIT.column1.isFinite() && scaledIT.column2.isFinite());
|
||||
return scaledIT;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sum up individual mass properties.
|
||||
|
||||
\param[in] props Array of mass properties to sum up.
|
||||
\param[in] transforms Reference transforms for each mass properties entry.
|
||||
\param[in] count The number of mass properties to sum up.
|
||||
\return The summed up mass properties.
|
||||
*/
|
||||
static PxMassProperties sum(const PxMassProperties* props, const PxTransform* transforms, const PxU32 count)
|
||||
{
|
||||
PxReal combinedMass = 0.0f;
|
||||
PxVec3 combinedCoM(0.0f);
|
||||
PxMat33 combinedInertiaT = PxMat33(PxZero);
|
||||
|
||||
for(PxU32 i = 0; i < count; i++)
|
||||
{
|
||||
PX_ASSERT(props[i].inertiaTensor.column0.isFinite() && props[i].inertiaTensor.column1.isFinite() && props[i].inertiaTensor.column2.isFinite());
|
||||
PX_ASSERT(props[i].centerOfMass.isFinite());
|
||||
PX_ASSERT(PxIsFinite(props[i].mass));
|
||||
|
||||
combinedMass += props[i].mass;
|
||||
const PxVec3 comTm = transforms[i].transform(props[i].centerOfMass);
|
||||
combinedCoM += comTm * props[i].mass;
|
||||
}
|
||||
|
||||
if(combinedMass > 0.f)
|
||||
combinedCoM /= combinedMass;
|
||||
|
||||
for(PxU32 i = 0; i < count; i++)
|
||||
{
|
||||
const PxVec3 comTm = transforms[i].transform(props[i].centerOfMass);
|
||||
combinedInertiaT += translateInertia(rotateInertia(props[i].inertiaTensor, transforms[i].q), props[i].mass, combinedCoM - comTm);
|
||||
}
|
||||
|
||||
PX_ASSERT(combinedInertiaT.column0.isFinite() && combinedInertiaT.column1.isFinite() && combinedInertiaT.column2.isFinite());
|
||||
PX_ASSERT(combinedCoM.isFinite());
|
||||
PX_ASSERT(PxIsFinite(combinedMass));
|
||||
|
||||
return PxMassProperties(combinedMass, combinedInertiaT, combinedCoM);
|
||||
}
|
||||
|
||||
|
||||
PxMat33 inertiaTensor; //!< The inertia tensor of the object.
|
||||
PxVec3 centerOfMass; //!< The center of mass of the object.
|
||||
PxReal mass; //!< The mass of the object.
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
122
engine/third_party/physx/include/extensions/PxParticleClothCooker.h
vendored
Normal file
122
engine/third_party/physx/include/extensions/PxParticleClothCooker.h
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// 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-2025 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_PARTICLE_CLOTH_COOKER_H
|
||||
#define PX_PARTICLE_CLOTH_COOKER_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
namespace ExtGpu
|
||||
{
|
||||
|
||||
/**
|
||||
\brief Holds all the information for a particle cloth constraint used in the PxParticleClothCooker.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
struct PX_DEPRECATED PxParticleClothConstraint
|
||||
{
|
||||
enum
|
||||
{
|
||||
eTYPE_INVALID_CONSTRAINT = 0,
|
||||
eTYPE_HORIZONTAL_CONSTRAINT = 1,
|
||||
eTYPE_VERTICAL_CONSTRAINT = 2,
|
||||
eTYPE_DIAGONAL_CONSTRAINT = 4,
|
||||
eTYPE_BENDING_CONSTRAINT = 8,
|
||||
eTYPE_DIAGONAL_BENDING_CONSTRAINT = 16,
|
||||
eTYPE_ALL = eTYPE_HORIZONTAL_CONSTRAINT | eTYPE_VERTICAL_CONSTRAINT | eTYPE_DIAGONAL_CONSTRAINT | eTYPE_BENDING_CONSTRAINT | eTYPE_DIAGONAL_BENDING_CONSTRAINT
|
||||
};
|
||||
PxU32 particleIndexA; //!< The first particle index of this constraint.
|
||||
PxU32 particleIndexB; //!< The second particle index of this constraint.
|
||||
PxReal length; //!< The distance between particle A and B.
|
||||
PxU32 constraintType; //!< The type of constraint, see the constraint type enum.
|
||||
};
|
||||
|
||||
/*
|
||||
\brief Generates PxParticleClothConstraint constraints that connect the individual particles of a particle cloth.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleClothCooker
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Generate the constraint list and triangle index list.
|
||||
|
||||
\param[in] constraints A pointer to an array of PxParticleClothConstraint constraints. If NULL, the cooker will generate all the constraints. Otherwise, the user-provided constraints will be added.
|
||||
\param[in] numConstraints The number of user-provided PxParticleClothConstraint s.
|
||||
*/
|
||||
virtual void cookConstraints(const PxParticleClothConstraint* constraints = NULL, const PxU32 numConstraints = 0) = 0;
|
||||
|
||||
virtual PxU32* getTriangleIndices() = 0; //!< \return A pointer to the triangle indices.
|
||||
virtual PxU32 getTriangleIndicesCount() = 0; //!< \return The number of triangle indices.
|
||||
virtual PxParticleClothConstraint* getConstraints() = 0; //!< \return A pointer to the PxParticleClothConstraint constraints.
|
||||
virtual PxU32 getConstraintCount() = 0; //!< \return The number of constraints.
|
||||
virtual void calculateMeshVolume() = 0; //!< Computes the volume of a closed mesh and the contraintScale. Expects vertices in local space - 'close' to origin.
|
||||
virtual PxReal getMeshVolume() = 0; //!< \return The mesh volume calculated by PxParticleClothCooker::calculateMeshVolume.
|
||||
|
||||
protected:
|
||||
virtual ~PxParticleClothCooker() {}
|
||||
};
|
||||
|
||||
} // namespace ExtGpu
|
||||
|
||||
/**
|
||||
\brief Creates a PxParticleClothCooker.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] vertexCount The number of vertices of the particle cloth.
|
||||
\param[in] inVertices The vertex positions of the particle cloth.
|
||||
\param[in] triangleIndexCount The number of triangles of the cloth mesh.
|
||||
\param[in] inTriangleIndices The triangle indices of the cloth mesh
|
||||
\param[in] constraintTypeFlags The types of constraints to generate. See PxParticleClothConstraint.
|
||||
\param[in] verticalDirection The vertical direction of the cloth mesh. This is needed to generate the correct horizontal and vertical constraints to model shear stiffness.
|
||||
\param[in] bendingConstraintMaxAngle The maximum angle (in radians) considered in the bending constraints.
|
||||
|
||||
\return A pointer to the new PxParticleClothCooker.
|
||||
*/
|
||||
PX_DEPRECATED ExtGpu::PxParticleClothCooker* PxCreateParticleClothCooker(PxU32 vertexCount, physx::PxVec4* inVertices, PxU32 triangleIndexCount, PxU32* inTriangleIndices,
|
||||
PxU32 constraintTypeFlags = ExtGpu::PxParticleClothConstraint::eTYPE_ALL,
|
||||
PxVec3 verticalDirection = PxVec3(0.0f, 1.0f, 0.0f), PxReal bendingConstraintMaxAngle = 20.0f*PxTwoPi/360.0f
|
||||
);
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
410
engine/third_party/physx/include/extensions/PxParticleExt.h
vendored
Normal file
410
engine/third_party/physx/include/extensions/PxParticleExt.h
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
// 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-2025 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_PARTICLE_EXT_H
|
||||
#define PX_PARTICLE_EXT_H
|
||||
|
||||
#include "PxPBDParticleSystem.h"
|
||||
#include "PxParticleBuffer.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "foundation/PxHashMap.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "PxDeformableAttachment.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
namespace ExtGpu
|
||||
{
|
||||
|
||||
/**
|
||||
\brief Structure to define user-defined particle state when constructing a new particle system.
|
||||
*/
|
||||
struct PxParticleBufferDesc
|
||||
{
|
||||
PxVec4* positions;
|
||||
PxVec4* velocities;
|
||||
PxU32* phases;
|
||||
PxParticleVolume* volumes;
|
||||
PxU32 numActiveParticles;
|
||||
PxU32 maxParticles;
|
||||
PxU32 numVolumes;
|
||||
PxU32 maxVolumes;
|
||||
|
||||
PxParticleBufferDesc() : positions(NULL), velocities(NULL), phases(NULL), volumes(NULL), numActiveParticles(0), maxParticles(0), numVolumes(0), maxVolumes(0) { }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to define user-defined particle state when constructing a new particle system that includes diffuse particles.
|
||||
*/
|
||||
struct PxParticleAndDiffuseBufferDesc : public PxParticleBufferDesc
|
||||
{
|
||||
PxDiffuseParticleParams diffuseParams;
|
||||
PxU32 maxDiffuseParticles;
|
||||
PxU32 maxActiveDiffuseParticles;
|
||||
|
||||
PxParticleAndDiffuseBufferDesc() : PxParticleBufferDesc() { }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to define user-defined particle state when constructing a new particle system that includes shape-matched rigid bodies.
|
||||
*/
|
||||
struct PxParticleRigidDesc
|
||||
{
|
||||
PxParticleRigidDesc() : rigidOffsets(NULL), rigidCoefficients(NULL), rigidTranslations(NULL), rigidRotations(NULL),
|
||||
rigidLocalPositions(NULL), rigidLocalNormals(NULL), maxRigids(0), numActiveRigids(0) { }
|
||||
|
||||
PxU32* rigidOffsets;
|
||||
PxReal* rigidCoefficients;
|
||||
PxVec4* rigidTranslations;
|
||||
PxQuat* rigidRotations;
|
||||
PxVec4* rigidLocalPositions;
|
||||
PxVec4* rigidLocalNormals;
|
||||
PxU32 maxRigids;
|
||||
PxU32 numActiveRigids;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
\brief Helper class to manage PxParticleClothDesc buffers used for communicating particle based cloths to PxParticleClothBuffer.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleClothBufferHelper
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual PxU32 getMaxCloths() const = 0; //!< \return The maximum number of cloths this PxParticleClothBufferHelper can hold.
|
||||
virtual PxU32 getNumCloths() const = 0; //!< \return The current number of cloths in this PxParticleClothBufferHelper.
|
||||
virtual PxU32 getMaxSprings() const = 0; //!< \return The maximum number of springs this PxParticleClothBufferHelper can hold.
|
||||
virtual PxU32 getNumSprings() const = 0; //!< \return The current number of springs in this PxParticleClothBufferHelper.
|
||||
virtual PxU32 getMaxTriangles() const = 0; //!< \return The maximum number of triangles this PxParticleClothBufferHelper can hold.
|
||||
virtual PxU32 getNumTriangles() const = 0; //!< \return The current number of triangles in this PxParticleClothBufferHelper.
|
||||
virtual PxU32 getMaxParticles() const = 0; //!< \return The maximum number of particles this PxParticleClothBufferHelper can hold.
|
||||
virtual PxU32 getNumParticles() const = 0; //!< \return The current number of particles in this PxParticleClothBufferHelper.
|
||||
|
||||
/**
|
||||
\brief Adds a PxParticleCloth to this PxParticleClothBufferHelper instance.
|
||||
|
||||
\param[in] particleCloth The PxParticleCloth to be added.
|
||||
\param[in] triangles A pointer to the triangles
|
||||
\param[in] numTriangles The number of triangles
|
||||
\param[in] springs A pointer to the springs
|
||||
\param[in] numSprings The number of springs
|
||||
\param[in] restPositions A pointer to the particle rest positions
|
||||
\param[in] numParticles The number of particles in this cloth
|
||||
|
||||
\see PxParticleCloth PxParticleSpring
|
||||
*/
|
||||
virtual void addCloth(const PxParticleCloth& particleCloth,
|
||||
const PxU32* triangles, const PxU32 numTriangles,
|
||||
const PxParticleSpring* springs, const PxU32 numSprings, const PxVec4* restPositions, const PxU32 numParticles) = 0;
|
||||
|
||||
/**
|
||||
\brief Adds a cloth to this PxParticleClothBufferHelper instance.
|
||||
|
||||
Adds a cloth to this PxParticleClothBufferHelper instance. With this method the relevant parameters for inflatable simulation
|
||||
(restVolume, pressure) can be set directly.
|
||||
|
||||
\param[in] blendScale This should be 1.f / (numPartitions + 1) if the springs are partitioned by the user. Otherwise this will be set during spring partitioning.
|
||||
\param[in] restVolume The rest volume of the inflatable
|
||||
\param[in] pressure The pressure of the inflatable. The target inflatable volume is defined as restVolume * pressure. Setting this to > 0.0 will enable inflatable simulation.
|
||||
\param[in] triangles A pointer to the triangles
|
||||
\param[in] numTriangles The number of triangles
|
||||
\param[in] springs A pointer to the springs
|
||||
\param[in] numSprings The number of springs
|
||||
\param[in] restPositions A pointer to the particle rest positions
|
||||
\param[in] numParticles The number of particles in this cloth
|
||||
|
||||
\see PxParticleSpring
|
||||
*/
|
||||
virtual void addCloth(const PxReal blendScale, const PxReal restVolume, const PxReal pressure,
|
||||
const PxU32* triangles, const PxU32 numTriangles,
|
||||
const PxParticleSpring* springs, const PxU32 numSprings,
|
||||
const PxVec4* restPositions, const PxU32 numParticles) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns a PxParticleClothDesc for this PxParticleClothBufferHelper instance to be used for spring partitioning.
|
||||
|
||||
\return the PxParticleClothDesc.
|
||||
|
||||
\see PxCreateAndPopulateParticleClothBuffer, PxParticleClothPreProcessor::partitionSprings
|
||||
*/
|
||||
virtual PxParticleClothDesc& getParticleClothDesc() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxParticleClothBufferHelper() {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Helper struct that holds information about a specific mesh in a PxParticleVolumeBufferHelper.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
struct PX_DEPRECATED PxParticleVolumeMesh
|
||||
{
|
||||
PxU32 startIndex; //!< The index of the first triangle of this mesh in the triangle array of the PxParticleVolumeBufferHelper instance.
|
||||
PxU32 count; //!< The number of triangles of this mesh.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Helper class to manage communicating PxParticleVolumes data to PxParticleBuffer.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleVolumeBufferHelper
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual PxU32 getMaxVolumes() const = 0; //!< \return The maximum number of PxParticleVolume this PxParticleVolumeBufferHelper instance can hold.
|
||||
virtual PxU32 getNumVolumes() const = 0; //!< \return The current number of PxParticleVolume in this PxParticleVolumeBufferHelper instance.
|
||||
virtual PxU32 getMaxTriangles() const = 0; //!< \return The maximum number of triangles this PxParticleVolumeBufferHelper instance can hold.
|
||||
virtual PxU32 getNumTriangles() const = 0; //!< \return The current number of triangles in this PxParticleVolumeBufferHelper instance.
|
||||
|
||||
virtual PxParticleVolume* getParticleVolumes() = 0; //!< \return A pointer to the PxParticleVolume s of this PxParticleVolumeBufferHelper instance.
|
||||
virtual PxParticleVolumeMesh* getParticleVolumeMeshes() = 0; //!< \return A pointer to the PxParticleVolumeMesh structs describing the PxParticleVolumes of this PxParticleVolumeBufferHelper instance.
|
||||
virtual PxU32* getTriangles() = 0; //!< \return A pointer to the triangle indices in this PxParticleVolumeBufferHelper instance.
|
||||
|
||||
/**
|
||||
\brief Adds a PxParticleVolume with a PxParticleVolumeMesh
|
||||
|
||||
\param[in] volume The PxParticleVolume to be added.
|
||||
\param[in] volumeMesh A PxParticleVolumeMesh that describes the volumes to be added. startIndex is the index into the triangle list of the PxParticleVolumeBufferHelper instance.
|
||||
\param[in] triangles A pointer to the triangle indices of the PxParticleVolume to be added.
|
||||
\param[in] numTriangles The number of triangles of the PxParticleVolume to be added.
|
||||
*/
|
||||
virtual void addVolume(const PxParticleVolume& volume, const PxParticleVolumeMesh& volumeMesh, const PxU32* triangles, const PxU32 numTriangles) = 0;
|
||||
|
||||
/**
|
||||
\brief Adds a volume
|
||||
|
||||
\param[in] particleOffset The index of the first particle of the cloth that maps to this volume in the PxParticleClothBufferHelper instance.
|
||||
\param[in] numParticles The number of particles of the cloth that maps to this volume in the PxParticleClothBufferHelper instance.
|
||||
\param[in] triangles A pointer to the triangle indices of this volume.
|
||||
\param[in] numTriangles The number of triangles in this volume.
|
||||
*/
|
||||
virtual void addVolume(const PxU32 particleOffset, const PxU32 numParticles, const PxU32* triangles, const PxU32 numTriangles) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxParticleVolumeBufferHelper() {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Helper class to manage PxParticleRigidDesc buffers used for communicating particle based rigids to PxPaticleSystem.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleRigidBufferHelper
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual PxU32 getMaxRigids() const = 0; //!< \return The maximum number of rigids this PxParticleRigidBufferHelper instance can hold.
|
||||
virtual PxU32 getNumRigids() const = 0; //!< \return The current number of rigids in this PxParticleRigidBufferHelper instance.
|
||||
virtual PxU32 getMaxParticles() const = 0; //!< \return The maximum number of particles this PxParticleRigidBufferHelper instance can hold.
|
||||
virtual PxU32 getNumParticles() const = 0; //!< \return The current number of particles in this PxParticleRigidBufferHelper instance.
|
||||
|
||||
/**
|
||||
\brief Adds a rigid.
|
||||
|
||||
\param[in] translation The world-space location of the rigid.
|
||||
\param[in] rotation The world-space rotation of the rigid.
|
||||
\param[in] coefficient The stiffness of the rigid.
|
||||
\param[in] localPositions The particle positions in local space.
|
||||
\param[in] localNormals The surface normal for all the particles in local space. Each PxVec4 has the normal in the first 3 components and the SDF in the last component.
|
||||
\param[in] numParticles The number of particles in this rigid.
|
||||
*/
|
||||
virtual void addRigid(const PxVec3& translation, const PxQuat& rotation, const PxReal coefficient,
|
||||
const PxVec4* localPositions, const PxVec4* localNormals, PxU32 numParticles) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the PxParticleRigidDesc for this buffer.
|
||||
|
||||
\returns A PxParticleRigidDesc.
|
||||
*/
|
||||
virtual PxParticleRigidDesc& getParticleRigidDesc() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxParticleRigidBufferHelper() {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
\brief Holds user-defined attachment data to attach particles to other bodies
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleAttachmentBuffer : public PxUserAllocated
|
||||
{
|
||||
PxArray<PxParticleRigidAttachment> mAttachments;
|
||||
PxArray<PxParticleRigidFilterPair> mFilters;
|
||||
PxHashMap<PxRigidActor*, PxU32> mReferencedBodies;
|
||||
PxArray<PxRigidActor*> mNewReferencedBodies;
|
||||
PxArray<PxRigidActor*> mDestroyedRefrencedBodies;
|
||||
|
||||
PxParticleBuffer& mParticleBuffer;
|
||||
|
||||
PxParticleRigidAttachment* mDeviceAttachments;
|
||||
PxParticleRigidFilterPair* mDeviceFilters;
|
||||
PxU32 mNumDeviceAttachments;
|
||||
PxU32 mNumDeviceFilters;
|
||||
|
||||
PxCudaContextManager* mCudaContextManager;
|
||||
|
||||
PxParticleSystem& mParticleSystem;
|
||||
|
||||
bool mDirty;
|
||||
|
||||
PX_NOCOPY(PxParticleAttachmentBuffer)
|
||||
|
||||
public:
|
||||
|
||||
PxParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxPBDParticleSystem& particleSystem);
|
||||
|
||||
~PxParticleAttachmentBuffer();
|
||||
|
||||
// adds attachment to attachment buffer - localPose is in actor space for attachments to all types of rigids.
|
||||
void addRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID, const PxVec3& localPose, PxConeLimitedConstraint* coneLimit = NULL);
|
||||
bool removeRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID);
|
||||
void addRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID);
|
||||
bool removeRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID);
|
||||
|
||||
void copyToDevice(CUstream stream = 0);
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Creates a PxParticleRigidBufferHelper.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] maxRigids The maximum number of rigids this PxParticleRigidsBuffers instance should hold.
|
||||
\param[in] maxParticles The maximum number of particles this PxParticleRigidBufferHelper instance should hold.
|
||||
\param[in] cudaContextManager A pointer to a PxCudaContextManager.
|
||||
|
||||
\return A pointer to the new PxParticleRigidBufferHelper.
|
||||
*/
|
||||
PX_DEPRECATED PxParticleRigidBufferHelper* PxCreateParticleRigidBufferHelper(PxU32 maxRigids, PxU32 maxParticles, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates a PxParticleClothBufferHelper helper.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] maxCloths The maximum number of cloths this PxParticleClothBufferHelper should hold.
|
||||
\param[in] maxTriangles The maximum number of triangles this PxParticleClothBufferHelper should hold.
|
||||
\param[in] maxSprings The maximum number of springs this PxParticleClothBufferHelper should hold.
|
||||
\param[in] maxParticles The maximum number of particles this PxParticleClothBufferHelper should hold.
|
||||
\param[in] cudaContextManager A pointer to a PxCudaContextManager.
|
||||
|
||||
\return A pointer to the PxParticleClothBufferHelper that was created.
|
||||
*/
|
||||
PX_DEPRECATED PxParticleClothBufferHelper* PxCreateParticleClothBufferHelper(const PxU32 maxCloths, const PxU32 maxTriangles, const PxU32 maxSprings, const PxU32 maxParticles, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates a PxParticleVolumeBufferHelper.
|
||||
|
||||
\param[in] maxVolumes The maximum number of PxParticleVolume s this PxParticleVolumeBufferHelper instance should hold.
|
||||
\param[in] maxTriangles The maximum number of triangles this PxParticleVolumeBufferHelper instance should hold.
|
||||
\param[in] cudaContextManager A pointer to a PxCudaContextManager.
|
||||
|
||||
\return A pointer to the new PxParticleVolumeBufferHelper.
|
||||
*/
|
||||
PX_DEPRECATED PxParticleVolumeBufferHelper* PxCreateParticleVolumeBufferHelper(PxU32 maxVolumes, PxU32 maxTriangles, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates a particle attachment buffer
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] particleBuffer The particle buffer that contains particles that should get attached to something
|
||||
\param[in] particleSystem The particle system that is used to simulate the userBuffer
|
||||
\return An attachment buffer ready to use
|
||||
*/
|
||||
PX_DEPRECATED PxParticleAttachmentBuffer* PxCreateParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxParticleSystem& particleSystem);
|
||||
|
||||
/**
|
||||
\brief Creates and populates a particle buffer
|
||||
|
||||
\param[in] desc The particle buffer descriptor
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\return A fully populated particle buffer ready to use
|
||||
*/
|
||||
PxParticleBuffer* PxCreateAndPopulateParticleBuffer(const ExtGpu::PxParticleBufferDesc& desc, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates and populates a particle buffer that includes support for diffuse particles
|
||||
|
||||
\param[in] desc The particle buffer descriptor
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\return A fully populated particle buffer ready to use
|
||||
*/
|
||||
PxParticleAndDiffuseBuffer* PxCreateAndPopulateParticleAndDiffuseBuffer(const ExtGpu::PxParticleAndDiffuseBufferDesc& desc, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates and populates a particle cloth buffer
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] desc The particle buffer descriptor
|
||||
\param[in] clothDesc The cloth descriptor
|
||||
\param[out] output A cloth output object to further configure the behavior of the cloth
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\return A fully populated particle cloth buffer ready to use
|
||||
*/
|
||||
PX_DEPRECATED PxParticleClothBuffer* PxCreateAndPopulateParticleClothBuffer(const ExtGpu::PxParticleBufferDesc& desc, const PxParticleClothDesc& clothDesc,
|
||||
PxPartitionedParticleCloth& output, PxCudaContextManager* cudaContextManager);
|
||||
|
||||
/**
|
||||
\brief Creates and populates a particle rigid buffer. Particle rigids are particles that try to keep their relative positions. They are a bit commpressible similar to softbodies.
|
||||
|
||||
\deprecated Particle-cloth, -rigids, -attachments and -volumes have been deprecated.
|
||||
|
||||
\param[in] desc The particle buffer descriptor
|
||||
\param[in] rigidDesc The rigid descriptor
|
||||
\param[in] cudaContextManager A cuda context manager
|
||||
\return A fully populated particle rigid buffer ready to use
|
||||
*/
|
||||
PX_DEPRECATED PxParticleRigidBuffer* PxCreateAndPopulateParticleRigidBuffer(const ExtGpu::PxParticleBufferDesc& desc, const ExtGpu::PxParticleRigidDesc& rigidDesc,
|
||||
PxCudaContextManager* cudaContextManager);
|
||||
|
||||
} // namespace ExtGpu
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
174
engine/third_party/physx/include/extensions/PxPrismaticJoint.h
vendored
Normal file
174
engine/third_party/physx/include/extensions/PxPrismaticJoint.h
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
// 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-2025 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_PRISMATIC_JOINT_H
|
||||
#define PX_PRISMATIC_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
#include "extensions/PxJointLimit.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxPrismaticJoint;
|
||||
|
||||
/**
|
||||
\brief Create a prismatic joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxPrismaticJoint
|
||||
*/
|
||||
PxPrismaticJoint* PxPrismaticJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
|
||||
/**
|
||||
\brief Flags specific to the prismatic joint.
|
||||
|
||||
\see PxPrismaticJoint
|
||||
*/
|
||||
struct PxPrismaticJointFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLIMIT_ENABLED = 1<<1
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxPrismaticJointFlag::Enum, PxU16> PxPrismaticJointFlags;
|
||||
PX_FLAGS_OPERATORS(PxPrismaticJointFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief A prismatic joint permits relative translational movement between two bodies along
|
||||
an axis, but no relative rotational movement.
|
||||
|
||||
The axis on each body is defined as the line containing the origin of the joint frame and
|
||||
extending along the x-axis of that frame.
|
||||
|
||||
\image html prismJoint.png
|
||||
|
||||
\see PxPrismaticJointCreate() PxJoint
|
||||
*/
|
||||
class PxPrismaticJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief returns the displacement of the joint along its axis.
|
||||
*/
|
||||
virtual PxReal getPosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief returns the velocity of the joint along its axis
|
||||
*/
|
||||
virtual PxReal getVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief sets the joint limit parameters.
|
||||
|
||||
The limit range is [-PX_MAX_F32, PX_MAX_F32], but note that the width of the limit (upper-lower) must also be
|
||||
a valid float.
|
||||
|
||||
\see PxJointLinearLimitPair getLimit()
|
||||
*/
|
||||
virtual void setLimit(const PxJointLinearLimitPair&) = 0;
|
||||
|
||||
/**
|
||||
\brief gets the joint limit parameters.
|
||||
|
||||
\see PxJointLinearLimit getLimit()
|
||||
*/
|
||||
virtual PxJointLinearLimitPair getLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the flags specific to the Prismatic Joint.
|
||||
|
||||
<b>Default</b> PxPrismaticJointFlags(0)
|
||||
|
||||
\param[in] flags The joint flags.
|
||||
|
||||
\see PxPrismaticJointFlag setFlag() getFlags()
|
||||
*/
|
||||
virtual void setPrismaticJointFlags(PxPrismaticJointFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Set a single flag specific to a Prismatic Joint to true or false.
|
||||
|
||||
\param[in] flag The flag to set or clear.
|
||||
\param[in] value The value to which to set the flag
|
||||
|
||||
\see PxPrismaticJointFlag, getFlags() setFlags()
|
||||
*/
|
||||
virtual void setPrismaticJointFlag(PxPrismaticJointFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the flags specific to the Prismatic Joint.
|
||||
|
||||
\return the joint flags
|
||||
|
||||
\see PxPrismaticJoint::flags, PxPrismaticJointFlag setFlag() setFlags()
|
||||
*/
|
||||
virtual PxPrismaticJointFlags getPrismaticJointFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxPrismaticJoint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxPrismaticJoint"; }
|
||||
|
||||
protected:
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxPrismaticJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxPrismaticJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxPrismaticJoint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
140
engine/third_party/physx/include/extensions/PxRackAndPinionJoint.h
vendored
Normal file
140
engine/third_party/physx/include/extensions/PxRackAndPinionJoint.h
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
// 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-2025 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_RACK_AND_PINION_JOINT_H
|
||||
#define PX_RACK_AND_PINION_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxRackAndPinionJoint;
|
||||
|
||||
/**
|
||||
\brief Create a rack & pinion Joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxRackAndPinionJoint
|
||||
*/
|
||||
PxRackAndPinionJoint* PxRackAndPinionJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
/**
|
||||
\brief A joint that connects an existing revolute joint to an existing prismatic joint,
|
||||
and constrains their relative angular/linear velocity and position with respect to each other.
|
||||
|
||||
\see PxRackAndPinionJointCreate PxJoint
|
||||
*/
|
||||
class PxRackAndPinionJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Set the hinge & prismatic joints connected by the rack & pinion joint.
|
||||
|
||||
The passed hinge joint can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate.
|
||||
The passed prismatic joint can be either PxPrismaticJoint or PxD6Joint.
|
||||
|
||||
Note that these joints are only used to compute the positional error correction term,
|
||||
used to adjust potential drift between jointed actors. The rack & pinion joint can run without
|
||||
calling this function, but in that case some visible overlap may develop over time between
|
||||
the teeth of the rack & pinion meshes.
|
||||
|
||||
\note Calling this function resets the internal positional error correction term.
|
||||
|
||||
\param[in] hinge The hinge joint (pinion)
|
||||
\param[in] prismatic The prismatic joint (rack)
|
||||
\return true if success
|
||||
*/
|
||||
virtual bool setJoints(const PxBase* hinge, const PxBase* prismatic) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the hinge & prismatic joints connected by the rack & pinion joint.
|
||||
|
||||
\param[out] hinge The hinge joint (pinion)
|
||||
\param[out] prismatic The prismatic joint (rack)
|
||||
*/
|
||||
virtual void getJoints(const PxBase*& hinge, const PxBase*& prismatic) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the desired ratio directly.
|
||||
|
||||
\note You may need to use a negative gear ratio if the joint frames of involved actors are not oriented in the same direction.
|
||||
|
||||
\note Calling this function resets the internal positional error correction term.
|
||||
|
||||
\param[in] ratio Desired ratio between the hinge and the prismatic.
|
||||
*/
|
||||
virtual void setRatio(float ratio) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the ratio.
|
||||
|
||||
\return Current ratio
|
||||
*/
|
||||
virtual float getRatio() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the desired ratio indirectly.
|
||||
|
||||
This is a simple helper function that computes the ratio from passed data:
|
||||
|
||||
ratio = (PI*2*nbRackTeeth)/(rackLength*nbPinionTeeth)
|
||||
|
||||
\note Calling this function resets the internal positional error correction term.
|
||||
|
||||
\param[in] nbRackTeeth Number of teeth on the rack (cannot be zero)
|
||||
\param[in] nbPinionTeeth Number of teeth on the pinion (cannot be zero)
|
||||
\param[in] rackLength Length of the rack
|
||||
\return true if success
|
||||
*/
|
||||
virtual bool setData(PxU32 nbRackTeeth, PxU32 nbPinionTeeth, float rackLength) = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxRackAndPinionJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
PX_INLINE PxRackAndPinionJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
PX_INLINE PxRackAndPinionJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxRackAndPinionJoint", PxJoint); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
105
engine/third_party/physx/include/extensions/PxRaycastCCD.h
vendored
Normal file
105
engine/third_party/physx/include/extensions/PxRaycastCCD.h
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
// 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-2025 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_RAYCAST_CCD_H
|
||||
#define PX_RAYCAST_CCD_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
class PxShape;
|
||||
class PxRigidDynamic;
|
||||
class RaycastCCDManagerInternal;
|
||||
|
||||
/**
|
||||
\brief Raycast-CCD manager.
|
||||
|
||||
Raycast-CCD is a simple and potentially cheaper alternative to the SDK's built-in continuous collision detection algorithm.
|
||||
|
||||
This implementation has some limitations:
|
||||
- it is only implemented for PxRigidDynamic objects (not for PxArticulationLink)
|
||||
- it is only implemented for simple actors with 1 shape (not for "compounds")
|
||||
|
||||
Also, since it is raycast-based, the solution is not perfect. In particular:
|
||||
- small dynamic objects can still go through the static world if the ray goes through a crack between edges, or a small
|
||||
hole in the world (like the keyhole from a door).
|
||||
- dynamic-vs-dynamic CCD is very approximate. It only works well for fast-moving dynamic objects colliding against
|
||||
slow-moving dynamic objects.
|
||||
|
||||
Finally, since it is using the SDK's scene queries under the hood, it only works provided the simulation shapes also have
|
||||
scene-query shapes associated with them. That is, if the objects in the scene only use PxShapeFlag::eSIMULATION_SHAPE
|
||||
(and no PxShapeFlag::eSCENE_QUERY_SHAPE), then the raycast-CCD system will not work.
|
||||
*/
|
||||
class RaycastCCDManager
|
||||
{
|
||||
public:
|
||||
RaycastCCDManager(PxScene* scene);
|
||||
~RaycastCCDManager();
|
||||
|
||||
/**
|
||||
\brief Register dynamic object for raycast CCD.
|
||||
|
||||
\param[in] actor object's actor
|
||||
\param[in] shape object's shape
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
bool registerRaycastCCDObject(PxRigidDynamic* actor, PxShape* shape);
|
||||
|
||||
/**
|
||||
\brief Unregister dynamic object for raycast CCD.
|
||||
|
||||
\param[in] actor object's actor
|
||||
\param[in] shape object's shape
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
bool unregisterRaycastCCDObject(PxRigidDynamic* actor, PxShape* shape);
|
||||
|
||||
/**
|
||||
\brief Perform raycast CCD. Call this after your simulate/fetchResults calls.
|
||||
|
||||
\param[in] doDynamicDynamicCCD True to enable dynamic-vs-dynamic CCD (more expensive, not always needed)
|
||||
*/
|
||||
void doRaycastCCD(bool doDynamicDynamicCCD);
|
||||
|
||||
private:
|
||||
RaycastCCDManagerInternal* mImpl;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
87
engine/third_party/physx/include/extensions/PxRemeshingExt.h
vendored
Normal file
87
engine/third_party/physx/include/extensions/PxRemeshingExt.h
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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-2025 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_REMESHING_EXT_H
|
||||
#define PX_REMESHING_EXT_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Provides methods to adjust the tessellation of meshes
|
||||
*/
|
||||
class PxRemeshingExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Processes a triangle mesh and makes sure that no triangle edge is longer than the maximal edge length specified
|
||||
|
||||
To shorten edges that are too long, additional points get inserted at their center leading to a subdivision of the input mesh.
|
||||
This process is executed repeatedly until the maximum edge length criterion is satisfied
|
||||
|
||||
\param[in,out] triangles The triangles of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
|
||||
\param[in,out] points The vertices of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
|
||||
\param[in] maxEdgeLength The maximum edge length allowed after processing the input
|
||||
\param[in] maxIterations The maximum number of subdivision iterations
|
||||
\param[out] triangleMap An optional map that provides the index of the original triangle for every triangle after the subdivision
|
||||
\param[in] triangleCountThreshold Optional limit to the number of triangles. Not guaranteed to match exactly, the algorithm will just stop as soon as possible after reaching the limit.
|
||||
|
||||
\return True if any remeshing was applied
|
||||
*/
|
||||
static bool limitMaxEdgeLength(PxArray<PxU32>& triangles, PxArray<PxVec3>& points, PxReal maxEdgeLength,
|
||||
PxU32 maxIterations = 100, PxArray<PxU32>* triangleMap = NULL, PxU32 triangleCountThreshold = 0xFFFFFFFF);
|
||||
|
||||
/**
|
||||
\brief Processes a triangle mesh and makes sure that no triangle edge is longer than the maximal edge length specified
|
||||
|
||||
To shorten edges that are too long, additional points get inserted at their center leading to a subdivision of the input mesh.
|
||||
This process is executed repeatedly until the maximum edge length criterion is satisfied
|
||||
|
||||
\param[in,out] triangles The triangles of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
|
||||
\param[in,out] points The vertices of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
|
||||
\param[in] maxEdgeLength The maximum edge length allowed after processing the input
|
||||
\param[in] maxIterations The maximum number of subdivision iterations
|
||||
\param[out] triangleMap An optional map that provides the index of the original triangle for every triangle after the subdivision
|
||||
\param[in] triangleCountThreshold Optional limit to the number of triangles. Not guaranteed to match exactly, the algorithm will just stop as soon as possible after reaching the limit.
|
||||
|
||||
\return True if any remeshing was applied
|
||||
*/
|
||||
static bool reduceSliverTriangles(PxArray<PxU32>& triangles, PxArray<PxVec3>& points, PxReal maxEdgeLength,
|
||||
PxU32 maxIterations = 3, PxArray<PxU32>* triangleMap = NULL, PxU32 triangleCountThreshold = 0xFFFFFFFF);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
152
engine/third_party/physx/include/extensions/PxRepXSerializer.h
vendored
Normal file
152
engine/third_party/physx/include/extensions/PxRepXSerializer.h
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
// 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-2025 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_REPX_SERIALIZER_H
|
||||
#define PX_REPX_SERIALIZER_H
|
||||
|
||||
#include "common/PxBase.h"
|
||||
#include "extensions/PxRepXSimpleType.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class XmlMemoryAllocator;
|
||||
class XmlWriter;
|
||||
class XmlReader;
|
||||
class MemoryBuffer;
|
||||
|
||||
/**
|
||||
\brief Serializer interface for RepX (Xml) serialization.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
|
||||
In order to serialize a class to RepX both a PxSerializer and
|
||||
a PxRepXSerializer implementation are needed.
|
||||
|
||||
A repx Serializer provides the ability to capture a live
|
||||
object to a descriptor or static state and the ability to
|
||||
write that state out to a file. Objects allocated
|
||||
by the Serializer using the allocator are freed when the
|
||||
collection itself is freed.
|
||||
SnRepXCoreSerializers.cpp implements a set of Serializers
|
||||
for the core PhysX types.
|
||||
|
||||
\note Implementing a PxRepXSerializer is currently not practical without including the internal PhysXExtension header "SnRepXSerializerImpl.h".
|
||||
|
||||
\see PxSerializer, PX_NEW_REPX_SERIALIZER, PxSerializationRegistry::registerRepXSerializer
|
||||
*/
|
||||
class PX_DEPRECATED PxRepXSerializer
|
||||
{
|
||||
protected:
|
||||
virtual ~PxRepXSerializer(){}
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief The type this Serializer is meant to operate on.
|
||||
\see PxRepXObject::typeName
|
||||
*/
|
||||
virtual const char* getTypeName() = 0;
|
||||
|
||||
/**
|
||||
\brief Convert from a RepX object to a key-value pair hierarchy
|
||||
|
||||
\param[in] inLiveObject The object to convert to the passed in descriptor.
|
||||
\param[in] inCollection The collection to use to find ids of references of this object.
|
||||
\param[in] inWriter Interface to write data to.
|
||||
\param[in] inTempBuffer used to for temporary allocations.
|
||||
\param[in] inArgs The arguments used in create resources and objects.
|
||||
*/
|
||||
virtual void objectToFile( const PxRepXObject& inLiveObject, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs ) = 0;
|
||||
|
||||
/**
|
||||
\brief Convert from a descriptor to a live object. Must be an object of this Serializer type.
|
||||
|
||||
\param[in] inReader The inverse of the writer, a key-value pair database.
|
||||
\param[in] inAllocator An allocator to use for temporary allocations. These will be freed after instantiation completes.
|
||||
\param[in] inArgs The arguments used in create resources and objects.
|
||||
\param[in] inCollection The collection used to find references.
|
||||
|
||||
\return The new live object. It can be an invalid object if the instantiation cannot take place.
|
||||
*/
|
||||
virtual PxRepXObject fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Inline helper template function to create PxRepXObject from TDataType type supporting PxTypeInfo<TDataType>::name.
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
template<typename TDataType>
|
||||
PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType, const physx::PxSerialObjectId inId)
|
||||
{
|
||||
return physx::PxRepXObject(physx::PxTypeInfo<TDataType>::name(), inType, inId);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Inline helper function to create PxRepXObject from a PxBase instance.
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const physx::PxBase* inType, const physx::PxSerialObjectId inId)
|
||||
{
|
||||
PX_ASSERT(inType);
|
||||
return physx::PxRepXObject(inType->getConcreteTypeName(), inType, inId);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Inline helper template function to create PxRepXObject form TDataType type using inType pointer as a PxSerialObjectId id.
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
template<typename TDataType>
|
||||
PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType)
|
||||
{
|
||||
return PxCreateRepXObject(inType, static_cast<physx::PxSerialObjectId>(size_t(inType)));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Preprocessor macro for RepX serializer creation.
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
#define PX_NEW_REPX_SERIALIZER(T) \
|
||||
*PX_PLACEMENT_NEW(PxGetAllocatorCallback()->allocate(sizeof(T), "PxRepXSerializer", PX_FL), T)(*PxGetAllocatorCallback())
|
||||
|
||||
/**
|
||||
\brief Preprocessor Macro to simplify RepX serializer delete.
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
#define PX_DELETE_REPX_SERIALIZER(x) \
|
||||
{ PxRepXSerializer* s = x; if (s) { PxGetAllocatorCallback()->deallocate(s); } }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
103
engine/third_party/physx/include/extensions/PxRepXSimpleType.h
vendored
Normal file
103
engine/third_party/physx/include/extensions/PxRepXSimpleType.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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-2025 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_REPX_SIMPLE_TYPE_H
|
||||
#define PX_REPX_SIMPLE_TYPE_H
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "cooking/PxCooking.h"
|
||||
#include "common/PxStringTable.h"
|
||||
#include "common/PxSerialFramework.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Helper class containing the mapping of id to object, and type name.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
*/
|
||||
struct PX_DEPRECATED PxRepXObject
|
||||
{
|
||||
/**
|
||||
\brief Identifies the extension meant to handle this object.
|
||||
\see PxTypeInfo, PX_DEFINE_TYPEINFO, PxRepXSerializer
|
||||
*/
|
||||
const char* typeName;
|
||||
|
||||
/**
|
||||
\brief Pointer to the serializable this was created from
|
||||
*/
|
||||
const void* serializable;
|
||||
|
||||
/**
|
||||
\brief Id given to this object at some point
|
||||
*/
|
||||
PxSerialObjectId id;
|
||||
PxRepXObject( const char* inTypeName = "", const void* inSerializable = NULL, const PxSerialObjectId inId = 0 )
|
||||
: typeName( inTypeName )
|
||||
, serializable( inSerializable )
|
||||
, id( inId )
|
||||
{
|
||||
}
|
||||
bool isValid() const { return serializable != NULL; }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Arguments required to instantiate a serializable object from RepX.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
|
||||
Extra arguments can be added to the object map under special ids.
|
||||
|
||||
\see PxRepXSerializer::objectToFile, PxRepXSerializer::fileToObject
|
||||
*/
|
||||
struct PX_DEPRECATED PxRepXInstantiationArgs
|
||||
{
|
||||
PxPhysics& physics;
|
||||
const PxCookingParams* cooker;
|
||||
PxStringTable* stringTable;
|
||||
PxRepXInstantiationArgs( PxPhysics& inPhysics, const PxCookingParams* inCooking = NULL , PxStringTable* inStringTable = NULL )
|
||||
: physics( inPhysics )
|
||||
, cooker( inCooking )
|
||||
, stringTable( inStringTable )
|
||||
{
|
||||
}
|
||||
|
||||
PxRepXInstantiationArgs& operator=(const PxRepXInstantiationArgs&);
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
265
engine/third_party/physx/include/extensions/PxRevoluteJoint.h
vendored
Normal file
265
engine/third_party/physx/include/extensions/PxRevoluteJoint.h
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
// 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-2025 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_REVOLUTE_JOINT_H
|
||||
#define PX_REVOLUTE_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
#include "extensions/PxJointLimit.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxRevoluteJoint;
|
||||
|
||||
/**
|
||||
\brief Create a revolute joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxRevoluteJoint
|
||||
*/
|
||||
PxRevoluteJoint* PxRevoluteJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
/**
|
||||
\brief Flags specific to the Revolute Joint.
|
||||
|
||||
\see PxRevoluteJoint
|
||||
*/
|
||||
struct PxRevoluteJointFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLIMIT_ENABLED = 1<<0, //!< enable the limit
|
||||
eDRIVE_ENABLED = 1<<1, //!< enable the drive
|
||||
eDRIVE_FREESPIN = 1<<2 //!< if the existing velocity is beyond the drive velocity, do not add force
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxRevoluteJointFlag::Enum, PxU16> PxRevoluteJointFlags;
|
||||
PX_FLAGS_OPERATORS(PxRevoluteJointFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
|
||||
\brief A joint which behaves in a similar way to a hinge or axle.
|
||||
|
||||
A hinge joint removes all but a single rotational degree of freedom from two objects.
|
||||
The axis along which the two bodies may rotate is specified with a point and a direction
|
||||
vector.
|
||||
|
||||
The position of the hinge on each body is specified by the origin of the body's joint frame.
|
||||
The axis of the hinge is specified as the direction of the x-axis in the body's joint frame.
|
||||
|
||||
\image html revoluteJoint.png
|
||||
|
||||
A revolute joint can be given a motor, so that it can apply a force to rotate the attached actors.
|
||||
It may also be given a limit, to restrict the revolute motion to within a certain range.
|
||||
|
||||
Drive and limits are activated by setting the appropriate flags on the joint.
|
||||
|
||||
\see PxRevoluteJointCreate() PxJoint
|
||||
*/
|
||||
class PxRevoluteJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief return the angle of the joint, in the range (-2*Pi, 2*Pi]
|
||||
*/
|
||||
virtual PxReal getAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief return the velocity of the joint
|
||||
*/
|
||||
virtual PxReal getVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the joint limit parameters.
|
||||
|
||||
The limit is activated using the flag PxRevoluteJointFlag::eLIMIT_ENABLED
|
||||
|
||||
The limit angle range is (-2*Pi, 2*Pi).
|
||||
|
||||
\param[in] limits The joint limit parameters.
|
||||
|
||||
\see PxJointAngularLimitPair getLimit()
|
||||
*/
|
||||
virtual void setLimit(const PxJointAngularLimitPair& limits) = 0;
|
||||
|
||||
/**
|
||||
\brief get the joint limit parameters.
|
||||
|
||||
\return the joint limit parameters
|
||||
|
||||
\see PxJointAngularLimitPair setLimit()
|
||||
*/
|
||||
virtual PxJointAngularLimitPair getLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief set the target velocity for the drive model.
|
||||
|
||||
The motor will only be able to reach this velocity if the maxForce is sufficiently large.
|
||||
If the joint is spinning faster than this velocity, the motor will actually try to brake
|
||||
(see PxRevoluteJointFlag::eDRIVE_FREESPIN.)
|
||||
|
||||
The sign of this variable determines the rotation direction, with positive values going
|
||||
the same way as positive joint angles. Setting a very large target velocity may cause
|
||||
undesirable results.
|
||||
|
||||
\param[in] velocity the drive target velocity
|
||||
\param[in] autowake Whether to wake up the joint rigids if they are asleep.
|
||||
|
||||
<b>Range:</b> (-PX_MAX_F32, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\see PxRevoluteFlags::eDRIVE_FREESPIN
|
||||
*/
|
||||
virtual void setDriveVelocity(PxReal velocity, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief gets the target velocity for the drive model.
|
||||
|
||||
\return the drive target velocity
|
||||
|
||||
\see setDriveVelocity()
|
||||
*/
|
||||
virtual PxReal getDriveVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief sets the maximum torque the drive can exert.
|
||||
|
||||
The value set here may be used either as an impulse limit or a force limit, depending on the flag PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> PX_MAX_F32
|
||||
|
||||
\see setDriveVelocity()
|
||||
*/
|
||||
virtual void setDriveForceLimit(PxReal limit) = 0;
|
||||
|
||||
/**
|
||||
\brief gets the maximum torque the drive can exert.
|
||||
|
||||
\return the torque limit
|
||||
|
||||
\see setDriveVelocity()
|
||||
*/
|
||||
virtual PxReal getDriveForceLimit() const = 0;
|
||||
|
||||
/**
|
||||
\brief sets the gear ratio for the drive.
|
||||
|
||||
When setting up the drive constraint, the velocity of the first actor is scaled by this value, and its response to drive torque is scaled down.
|
||||
So if the drive target velocity is zero, the second actor will be driven to the velocity of the first scaled by the gear ratio
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 1.0
|
||||
|
||||
\param[in] ratio the drive gear ratio
|
||||
|
||||
\see getDriveGearRatio()
|
||||
*/
|
||||
virtual void setDriveGearRatio(PxReal ratio) = 0;
|
||||
|
||||
/**
|
||||
\brief gets the gear ratio.
|
||||
|
||||
\return the drive gear ratio
|
||||
|
||||
\see setDriveGearRatio()
|
||||
*/
|
||||
virtual PxReal getDriveGearRatio() const = 0;
|
||||
|
||||
/**
|
||||
\brief sets the flags specific to the Revolute Joint.
|
||||
|
||||
<b>Default</b> PxRevoluteJointFlags(0)
|
||||
|
||||
\param[in] flags The joint flags.
|
||||
|
||||
\see PxRevoluteJointFlag setFlag() getFlags()
|
||||
*/
|
||||
virtual void setRevoluteJointFlags(PxRevoluteJointFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief sets a single flag specific to a Revolute Joint.
|
||||
|
||||
\param[in] flag The flag to set or clear.
|
||||
\param[in] value the value to which to set the flag
|
||||
|
||||
\see PxRevoluteJointFlag, getFlags() setFlags()
|
||||
*/
|
||||
virtual void setRevoluteJointFlag(PxRevoluteJointFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief gets the flags specific to the Revolute Joint.
|
||||
|
||||
\return the joint flags
|
||||
|
||||
\see PxRevoluteJoint::flags, PxRevoluteJointFlag setFlag() setFlags()
|
||||
*/
|
||||
virtual PxRevoluteJointFlags getRevoluteJointFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxRevoluteJoint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxRevoluteJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxRevoluteJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxRevoluteJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxRevoluteJoint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
162
engine/third_party/physx/include/extensions/PxRigidActorExt.h
vendored
Normal file
162
engine/third_party/physx/include/extensions/PxRigidActorExt.h
vendored
Normal file
@@ -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-2025 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_RIGID_ACTOR_EXT_H
|
||||
#define PX_RIGID_ACTOR_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxPhysics.h"
|
||||
#include "PxRigidActor.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBVH;
|
||||
|
||||
/**
|
||||
\brief utility functions for use with PxRigidActor and subclasses
|
||||
|
||||
\see PxRigidActor PxRigidStatic PxRigidBody PxRigidDynamic PxArticulationLink
|
||||
*/
|
||||
|
||||
class PxRigidActorExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Creates a new shape with default properties and a list of materials and adds it to the list of shapes of this actor.
|
||||
|
||||
This is equivalent to the following
|
||||
|
||||
PxShape* shape(...) = PxGetPhysics().createShape(...); // reference count is 1
|
||||
actor->attachShape(shape); // increments reference count
|
||||
shape->release(); // releases user reference, leaving reference count at 1
|
||||
|
||||
As a consequence, detachShape() will result in the release of the last reference, and the shape will be deleted.
|
||||
|
||||
\note The default shape flags to be set are: eVISUALIZATION, eSIMULATION_SHAPE, eSCENE_QUERY_SHAPE (see #PxShapeFlag).
|
||||
Triangle mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are not supported for
|
||||
non-kinematic PxRigidDynamic instances.
|
||||
|
||||
\note Creating compounds with a very large number of shapes may adversely affect performance and stability.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] actor the actor to which to attach the shape
|
||||
\param[in] geometry the geometry of the shape
|
||||
\param[in] materials a pointer to an array of material pointers
|
||||
\param[in] materialCount the count of materials
|
||||
\param[in] shapeFlags optional PxShapeFlags
|
||||
|
||||
\return The newly created shape.
|
||||
|
||||
\see PxShape PxShape::release(), PxPhysics::createShape(), PxRigidActor::attachShape()
|
||||
*/
|
||||
static PxShape* createExclusiveShape(PxRigidActor& actor, const PxGeometry& geometry, PxMaterial*const* materials, PxU16 materialCount,
|
||||
PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE)
|
||||
{
|
||||
PxShape* shape = PxGetPhysics().createShape(geometry, materials, materialCount, true, shapeFlags);
|
||||
if(shape)
|
||||
{
|
||||
bool status = actor.attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor
|
||||
shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly
|
||||
if(!status)
|
||||
shape = NULL;
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Creates a new shape with default properties and a single material adds it to the list of shapes of this actor.
|
||||
|
||||
This is equivalent to the following
|
||||
|
||||
PxShape* shape(...) = PxGetPhysics().createShape(...); // reference count is 1
|
||||
actor->attachShape(shape); // increments reference count
|
||||
shape->release(); // releases user reference, leaving reference count at 1
|
||||
|
||||
As a consequence, detachShape() will result in the release of the last reference, and the shape will be deleted.
|
||||
|
||||
\note The default shape flags to be set are: eVISUALIZATION, eSIMULATION_SHAPE, eSCENE_QUERY_SHAPE (see #PxShapeFlag).
|
||||
Triangle mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are not supported for
|
||||
non-kinematic PxRigidDynamic instances.
|
||||
|
||||
\note Creating compounds with a very large number of shapes may adversely affect performance and stability.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] actor the actor to which to attach the shape
|
||||
\param[in] geometry the geometry of the shape
|
||||
\param[in] material the material for the shape
|
||||
\param[in] shapeFlags optional PxShapeFlags
|
||||
|
||||
\return The newly created shape.
|
||||
|
||||
\see PxShape PxShape::release(), PxPhysics::createShape(), PxRigidActor::attachShape()
|
||||
*/
|
||||
static PX_FORCE_INLINE PxShape* createExclusiveShape(PxRigidActor& actor, const PxGeometry& geometry, const PxMaterial& material,
|
||||
PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE)
|
||||
{
|
||||
PxMaterial* materialPtr = const_cast<PxMaterial*>(&material);
|
||||
return createExclusiveShape(actor, geometry, &materialPtr, 1, shapeFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets a list of bounds based on shapes in rigid actor. This list can be used to cook/create
|
||||
bounding volume hierarchy though PxCooking API.
|
||||
|
||||
\param[in] actor The actor from which the bounds list is retrieved.
|
||||
\param[out] numBounds Number of bounds in returned list.
|
||||
|
||||
\see PxShape PxBVH PxCooking::createBVH PxCooking::cookBVH
|
||||
*/
|
||||
static PxBounds3* getRigidActorShapeLocalBoundsList(const PxRigidActor& actor, PxU32& numBounds);
|
||||
|
||||
/**
|
||||
\brief Convenience function to create a PxBVH object from a PxRigidActor.
|
||||
|
||||
The computed PxBVH can then be used in PxScene::addActor() or PxAggregate::addActor().
|
||||
After adding the actor & BVH to the scene/aggregate, release the PxBVH object by calling PxBVH::release().
|
||||
|
||||
\param[in] physics The physics object. The function will retrieve the insertion callback from it.
|
||||
\param[in] actor The actor to compute a PxBVH for.
|
||||
|
||||
\return The PxBVH for this actor.
|
||||
|
||||
\see PxBVH PxScene::addActor PxAggregate::addActor
|
||||
*/
|
||||
static PxBVH* createBVHFromActor(PxPhysics& physics, const PxRigidActor& actor);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
444
engine/third_party/physx/include/extensions/PxRigidBodyExt.h
vendored
Normal file
444
engine/third_party/physx/include/extensions/PxRigidBodyExt.h
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
// 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-2025 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_RIGID_BODY_EXT_H
|
||||
#define PX_RIGID_BODY_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxRigidBody.h"
|
||||
#include "PxQueryReport.h"
|
||||
#include "PxQueryFiltering.h"
|
||||
#include "extensions/PxMassProperties.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
struct PxQueryCache;
|
||||
class PxShape;
|
||||
|
||||
/**
|
||||
\brief utility functions for use with PxRigidBody and subclasses
|
||||
|
||||
\see PxRigidBody PxRigidDynamic PxArticulationLink
|
||||
*/
|
||||
|
||||
class PxRigidBodyExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Computation of mass properties for a rigid body actor
|
||||
|
||||
To simulate a dynamic rigid actor, the SDK needs a mass and an inertia tensor.
|
||||
|
||||
This method offers functionality to compute the necessary mass and inertia properties based on the shapes declared in
|
||||
the PxRigidBody descriptor and some additionally specified parameters. For each shape, the shape geometry,
|
||||
the shape positioning within the actor and the specified shape density are used to compute the body's mass and
|
||||
inertia properties.
|
||||
|
||||
<ul>
|
||||
<li>Shapes without PxShapeFlag::eSIMULATION_SHAPE set are ignored unless includeNonSimShapes is true.</li>
|
||||
<li>Shapes with plane, triangle mesh or heightfield geometry and PxShapeFlag::eSIMULATION_SHAPE set are not allowed for PxRigidBody collision.</li>
|
||||
</ul>
|
||||
|
||||
This method will set the mass, center of mass, and inertia tensor
|
||||
|
||||
if no collision shapes are found, the inertia tensor is set to (1,1,1) and the mass to 1
|
||||
|
||||
if massLocalPose is non-NULL, the rigid body's center of mass parameter will be set
|
||||
to the user provided value (massLocalPose) and the inertia tensor will be resolved at that point.
|
||||
|
||||
\note If all shapes of the actor have the same density then the overloaded method updateMassAndInertia() with a single density parameter can be used instead.
|
||||
|
||||
\param[in,out] body The rigid body.
|
||||
\param[in] shapeDensities The per shape densities. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set (or for all shapes if includeNonSimShapes is set to true). Other shapes are ignored. The density values must be greater than 0.
|
||||
\param[in] shapeDensityCount The number of provided density values.
|
||||
\param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
|
||||
\param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
|
||||
\return Boolean. True on success else false.
|
||||
|
||||
\see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass
|
||||
*/
|
||||
static bool updateMassAndInertia(PxRigidBody& body, const PxReal* shapeDensities, PxU32 shapeDensityCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
|
||||
|
||||
/**
|
||||
\brief Computation of mass properties for a rigid body actor
|
||||
|
||||
See previous method for details.
|
||||
|
||||
\param[in,out] body The rigid body.
|
||||
\param[in] density The density of the body. Used to compute the mass of the body. The density must be greater than 0.
|
||||
\param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
|
||||
\param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
|
||||
\return Boolean. True on success else false.
|
||||
|
||||
\see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass
|
||||
*/
|
||||
static bool updateMassAndInertia(PxRigidBody& body, PxReal density, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
|
||||
|
||||
/**
|
||||
\brief Computation of mass properties for a rigid body actor
|
||||
|
||||
This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the sum of all user-supplied
|
||||
shape mass values, and the inertia and center of mass are computed according to the rigid body's shapes and the per shape mass input values.
|
||||
|
||||
If no collision shapes are found, the inertia tensor is set to (1,1,1)
|
||||
|
||||
\note If a single mass value should be used for the actor as a whole then the overloaded method setMassAndUpdateInertia() with a single mass parameter can be used instead.
|
||||
|
||||
\see updateMassAndInertia for more details.
|
||||
|
||||
\param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties.
|
||||
\param[in] shapeMasses The per shape mass values. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set. Other shapes are ignored. The mass values must be greater than 0.
|
||||
\param[in] shapeMassCount The number of provided mass values.
|
||||
\param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
|
||||
\param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
|
||||
\return Boolean. True on success else false.
|
||||
|
||||
\see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass
|
||||
*/
|
||||
static bool setMassAndUpdateInertia(PxRigidBody& body, const PxReal* shapeMasses, PxU32 shapeMassCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
|
||||
|
||||
/**
|
||||
\brief Computation of mass properties for a rigid body actor
|
||||
|
||||
This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the user-supplied
|
||||
value, and the inertia and center of mass are computed according to the rigid body's shapes and the input mass.
|
||||
|
||||
If no collision shapes are found, the inertia tensor is set to (1,1,1)
|
||||
|
||||
\see updateMassAndInertia for more details.
|
||||
|
||||
\param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties.
|
||||
\param[in] mass The mass of the body. Must be greater than 0.
|
||||
\param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
|
||||
\param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
|
||||
\return Boolean. True on success else false.
|
||||
|
||||
\see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass
|
||||
*/
|
||||
static bool setMassAndUpdateInertia(PxRigidBody& body, PxReal mass, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
|
||||
|
||||
/**
|
||||
\brief Compute the mass, inertia tensor and center of mass from a list of shapes.
|
||||
|
||||
\param[in] shapes The shapes to compute the mass properties from.
|
||||
\param[in] shapeCount The number of provided shapes.
|
||||
\return The mass properties from the combined shapes.
|
||||
|
||||
\see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass
|
||||
*/
|
||||
static PxMassProperties computeMassPropertiesFromShapes(const PxShape* const* shapes, PxU32 shapeCount);
|
||||
|
||||
/**
|
||||
\brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular
|
||||
point in global coordinates, to the actor.
|
||||
|
||||
Note that if the force does not act along the center of mass of the actor, this
|
||||
will also add the corresponding torque. Because forces are reset at the end of every timestep,
|
||||
you can maintain a total external force on an object by calling this once every frame.
|
||||
|
||||
\note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire
|
||||
articulation
|
||||
|
||||
::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the
|
||||
force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a
|
||||
given point.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default).
|
||||
|
||||
\param[in] body The rigid body to apply the force to.
|
||||
\param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector
|
||||
\param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
|
||||
\param[in] wakeup Specify if the call should wake up the actor.
|
||||
|
||||
\see PxForceMode
|
||||
\see addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos()
|
||||
*/
|
||||
static void addForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
|
||||
|
||||
/**
|
||||
\brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular
|
||||
point in local coordinates, to the actor.
|
||||
|
||||
Note that if the force does not act along the center of mass of the actor, this
|
||||
will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a
|
||||
total external force on an object by calling this once every frame.
|
||||
|
||||
\note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire
|
||||
articulation
|
||||
|
||||
::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the
|
||||
force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a
|
||||
given point.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default).
|
||||
|
||||
\param[in] body The rigid body to apply the force to.
|
||||
\param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector
|
||||
\param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
|
||||
\param[in] wakeup Specify if the call should wake up the actor.
|
||||
|
||||
\see PxForceMode
|
||||
\see addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos()
|
||||
*/
|
||||
static void addForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
|
||||
|
||||
/**
|
||||
\brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a
|
||||
particular point in global coordinates, to the actor.
|
||||
|
||||
Note that if the force does not act along the center of mass of the actor, this
|
||||
will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a
|
||||
total external force on an object by calling this once every frame.
|
||||
|
||||
\note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire
|
||||
articulation
|
||||
|
||||
::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the
|
||||
force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a
|
||||
given point.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default).
|
||||
|
||||
\param[in] body The rigid body to apply the force to.
|
||||
\param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector
|
||||
\param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
|
||||
\param[in] wakeup Specify if the call should wake up the actor.
|
||||
|
||||
\see PxForceMode
|
||||
\see addForceAtPos() addForceAtLocalPos() addLocalForceAtLocalPos()
|
||||
*/
|
||||
static void addLocalForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
|
||||
|
||||
/**
|
||||
\brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a
|
||||
particular point in local coordinates, to the actor.
|
||||
|
||||
Note that if the force does not act along the center of mass of the actor, this
|
||||
will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a
|
||||
total external force on an object by calling this once every frame.
|
||||
|
||||
\note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire
|
||||
articulation
|
||||
|
||||
::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the
|
||||
force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a
|
||||
given point.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default).
|
||||
|
||||
\param[in] body The rigid body to apply the force to.
|
||||
\param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector
|
||||
\param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
|
||||
\param[in] wakeup Specify if the call should wake up the actor.
|
||||
|
||||
\see PxForceMode
|
||||
\see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos()
|
||||
*/
|
||||
static void addLocalForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
|
||||
|
||||
/**
|
||||
\brief Computes the velocity of a point given in world coordinates if it were attached to the
|
||||
specified body and moving with it.
|
||||
|
||||
\param[in] body The rigid body the point is attached to.
|
||||
\param[in] pos Position we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector
|
||||
\return The velocity of point in the global frame.
|
||||
|
||||
\see getLocalPointVelocity()
|
||||
*/
|
||||
static PxVec3 getVelocityAtPos(const PxRigidBody& body, const PxVec3& pos);
|
||||
|
||||
/**
|
||||
\brief Computes the velocity of a point given in local coordinates if it were attached to the
|
||||
specified body and moving with it.
|
||||
|
||||
\param[in] body The rigid body the point is attached to.
|
||||
\param[in] pos Position we wish to determine the velocity for, defined in the local frame. <b>Range:</b> position vector
|
||||
\return The velocity of point in the local frame.
|
||||
|
||||
\see getLocalPointVelocity()
|
||||
*/
|
||||
static PxVec3 getLocalVelocityAtLocalPos(const PxRigidBody& body, const PxVec3& pos);
|
||||
|
||||
/**
|
||||
\brief Computes the velocity of a point (offset from the origin of the body) given in world coordinates if it were attached to the
|
||||
specified body and moving with it.
|
||||
|
||||
\param[in] body The rigid body the point is attached to.
|
||||
\param[in] pos Position (offset from the origin of the body) we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector
|
||||
\return The velocity of point (offset from the origin of the body) in the global frame.
|
||||
|
||||
\see getLocalPointVelocity()
|
||||
*/
|
||||
static PxVec3 getVelocityAtOffset(const PxRigidBody& body, const PxVec3& pos);
|
||||
|
||||
/**
|
||||
\brief Compute the change to linear and angular velocity that would occur if an impulsive force and torque were to be applied to a specified rigid body.
|
||||
|
||||
The rigid body is left unaffected unless a subsequent independent call is executed that actually applies the computed changes to velocity and angular velocity.
|
||||
|
||||
\note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account.
|
||||
|
||||
\see PxRigidBody::getLinearVelocity, PxRigidBody::setLinearVelocity, PxRigidBody::getAngularVelocity, PxRigidBody::setAngularVelocity
|
||||
|
||||
\param[in] body The body under consideration.
|
||||
\param[in] impulsiveForce The impulsive force that would be applied to the specified rigid body.
|
||||
\param[in] impulsiveTorque The impulsive torque that would be applied to the specified rigid body.
|
||||
\param[out] deltaLinearVelocity The change in linear velocity that would arise if impulsiveForce was to be applied to the specified rigid body.
|
||||
\param[out] deltaAngularVelocity The change in angular velocity that would arise if impulsiveTorque was to be applied to the specified rigid body.
|
||||
*/
|
||||
static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxVec3& impulsiveForce, const PxVec3& impulsiveTorque, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity);
|
||||
|
||||
/**
|
||||
\brief Computes the linear and angular velocity change vectors for a given impulse at a world space position taking a mass and inertia scale into account
|
||||
|
||||
This function is useful for extracting the respective linear and angular velocity changes from a contact or joint when the mass/inertia ratios have been adjusted.
|
||||
|
||||
\note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account.
|
||||
|
||||
\param[in] body The rigid body
|
||||
\param[in] globalPose The body's world space transform
|
||||
\param[in] point The point in world space where the impulse is applied
|
||||
\param[in] impulse The impulse vector in world space
|
||||
\param[in] invMassScale The inverse mass scale
|
||||
\param[in] invInertiaScale The inverse inertia scale
|
||||
\param[out] deltaLinearVelocity The linear velocity change
|
||||
\param[out] deltaAngularVelocity The angular velocity change
|
||||
*/
|
||||
static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale,
|
||||
const PxReal invInertiaScale, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity);
|
||||
|
||||
/**
|
||||
\brief Computes the linear and angular impulse vectors for a given impulse at a world space position taking a mass and inertia scale into account
|
||||
|
||||
This function is useful for extracting the respective linear and angular impulses from a contact or joint when the mass/inertia ratios have been adjusted.
|
||||
|
||||
\param[in] body The rigid body
|
||||
\param[in] globalPose The body's world space transform
|
||||
\param[in] point The point in world space where the impulse is applied
|
||||
\param[in] impulse The impulse vector in world space
|
||||
\param[in] invMassScale The inverse mass scale
|
||||
\param[in] invInertiaScale The inverse inertia scale
|
||||
\param[out] linearImpulse The linear impulse
|
||||
\param[out] angularImpulse The angular impulse
|
||||
*/
|
||||
static void computeLinearAngularImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale,
|
||||
const PxReal invInertiaScale, PxVec3& linearImpulse, PxVec3& angularImpulse);
|
||||
|
||||
/**
|
||||
\brief Performs a linear sweep through space with the body's geometry objects.
|
||||
|
||||
\note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored.
|
||||
\note If eTOUCH is returned from the filter callback, it will trigger an error and the hit will be discarded.
|
||||
|
||||
The function sweeps all shapes attached to a given rigid body through space and reports the nearest
|
||||
object in the scene which intersects any of of the shapes swept paths.
|
||||
Information about the closest intersection is written to a #PxSweepHit structure.
|
||||
|
||||
\param[in] body The rigid body to sweep.
|
||||
\param[in] scene The scene object to process the query.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information.
|
||||
\param[out] closestHit Closest hit result.
|
||||
\param[out] shapeIndex Index of the body shape that caused the closest hit.
|
||||
\param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering,
|
||||
otherwise shape->getQueryFilterData() will be used instead.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
\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.
|
||||
|
||||
\return True if a blocking hit was found.
|
||||
|
||||
\see PxScene PxQueryFlags PxFilterData PxSweepHit
|
||||
*/
|
||||
static bool linearSweepSingle(
|
||||
PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance,
|
||||
PxHitFlags outputFlags,
|
||||
PxSweepHit& closestHit, PxU32& shapeIndex,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(),
|
||||
PxQueryFilterCallback* filterCall = NULL,
|
||||
const PxQueryCache* cache = NULL,
|
||||
const PxReal inflation=0.0f);
|
||||
|
||||
/**
|
||||
\brief Performs a linear sweep through space with the body's geometry objects, returning all overlaps.
|
||||
|
||||
\note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored.
|
||||
|
||||
This function sweeps all shapes attached to a given rigid body through space and reports all
|
||||
objects in the scene that intersect any of the shapes' swept paths until there are no more objects to report
|
||||
or a blocking hit is encountered.
|
||||
|
||||
\param[in] body The rigid body to sweep.
|
||||
\param[in] scene The scene object to process the query.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information.
|
||||
\param[out] touchHitBuffer Raycast hit information buffer. If the buffer overflows, an arbitrary subset of touch hits
|
||||
is returned (typically the query should be restarted with a larger buffer).
|
||||
\param[out] touchHitShapeIndices After the query is completed, touchHitShapeIndices[i] will contain the body index that caused the hit stored in hitBuffer[i]
|
||||
\param[in] touchHitBufferSize Size of both touch hit buffers in elements.
|
||||
\param[out] block Closest blocking hit is returned via this reference.
|
||||
\param[out] blockingShapeIndex Set to -1 if if a blocking hit was not found, otherwise set to closest blocking hit shape index. The touching hits are reported separately in hitBuffer.
|
||||
\param[out] overflow Set to true if touchHitBuffer didn't have enough space for all results. Touch hits will be incomplete if overflow occurred. Possible solution is to restart the query with a larger buffer.
|
||||
\param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering,
|
||||
otherwise shape->getQueryFilterData() will be used instead.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
\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.
|
||||
|
||||
\return the number of touching hits. If overflow is set to true, the results are incomplete. In case of overflow there are also no guarantees that all touching hits returned are closer than the blocking hit.
|
||||
|
||||
\see PxScene PxQueryFlags PxFilterData PxSweepHit
|
||||
*/
|
||||
static PxU32 linearSweepMultiple(
|
||||
PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance,
|
||||
PxHitFlags outputFlags,
|
||||
PxSweepHit* touchHitBuffer, PxU32* touchHitShapeIndices, PxU32 touchHitBufferSize,
|
||||
PxSweepHit& block, PxI32& blockingShapeIndex, bool& overflow,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(),
|
||||
PxQueryFilterCallback* filterCall = NULL,
|
||||
const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
183
engine/third_party/physx/include/extensions/PxSamplingExt.h
vendored
Normal file
183
engine/third_party/physx/include/extensions/PxSamplingExt.h
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
// 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-2025 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_SAMPLING_EXT_H
|
||||
#define PX_SAMPLING_EXT_H
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "geometry/PxSimpleTriangleMesh.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief utility functions to sample vertices on or inside a triangle mesh or other geometries
|
||||
*/
|
||||
class PxSamplingExt
|
||||
{
|
||||
public:
|
||||
/** Computes samples on a triangle mesh's surface that are not closer to each other than a given distance. Optionally the mesh's interior can be filled with samples as well.
|
||||
|
||||
\param[in] mesh The triangle mesh
|
||||
\param[in] r The closest distance two surface samples are allowed to have
|
||||
\param[out] result Equally distributed samples on and if specified inside the triangle mesh
|
||||
\param[in] rVolume The average distance of samples inside the mesh. If set to zero, samples will only be placed on the mesh's surface
|
||||
\param[out] triangleIds Optional output containing the index of the triangle for all samples on the mesh's surface. The array will contain less entries than output vertices if volume samples are active since volume samples are not on the surface.
|
||||
\param[out] barycentricCoordinates Optional output containing the barycentric coordinates for all samples on the mesh's surface. The array will contain less entries than output vertices if volume samples are active since volume samples are not on the surface.
|
||||
\param[in] axisAlignedBox A box that limits the space where samples can get created
|
||||
\param[in] boxOrientation The orientation of the box that limits the space where samples can get created
|
||||
\param[in] maxNumSamples If larger than zero, the sampler will stop when the sample count reaches maxNumSamples
|
||||
\param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc.
|
||||
\return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii.
|
||||
*/
|
||||
static bool poissonSample(const PxSimpleTriangleMesh& mesh, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f, PxArray<PxI32>* triangleIds = NULL, PxArray<PxVec3>* barycentricCoordinates = NULL,
|
||||
const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30);
|
||||
|
||||
/** Computes samples on a geometry's surface that are not closer to each other than a given distance.
|
||||
|
||||
\param[in] geometry The geometry that defines the surface on which the samples get created
|
||||
\param[in] transform The geometry's global pose
|
||||
\param[in] worldBounds The geometry's bounding box
|
||||
\param[in] r The closest distance two surface samples are allowed to have
|
||||
\param[out] result Equally distributed samples on and if specified inside the triangle mesh
|
||||
\param[in] rVolume The average distance of samples inside the mesh. If set to zero, samples will only be placed on the mesh's surface
|
||||
\param[in] axisAlignedBox A box that limits the space where samples can get created
|
||||
\param[in] boxOrientation The orientation of the box that limits the space where samples can get created
|
||||
\param[in] maxNumSamples If larger than zero, the sampler will stop when the sample count reaches maxNumSamples
|
||||
\param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc.
|
||||
\return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii.
|
||||
*/
|
||||
static bool poissonSample(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f,
|
||||
const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30);
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Sampler to generate Poisson Samples locally on a triangle mesh or a shape. For every local addition of new samples, an individual sampling density can be used.
|
||||
*/
|
||||
class PxPoissonSampler : public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
/** Sets the sampling radius
|
||||
\param[in] samplingRadius The closest distance two surface samples are allowed to have. Changing the sampling radius is a bit an expensive operation.
|
||||
\return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii.
|
||||
*/
|
||||
virtual bool setSamplingRadius(PxReal samplingRadius) = 0;
|
||||
|
||||
/** Adds samples
|
||||
\param[in] samples The samples to add. Adding samples is a bit an expensive operation.
|
||||
*/
|
||||
virtual void addSamples(const PxArray<PxVec3>& samples) = 0;
|
||||
|
||||
/** Adds samples
|
||||
\param[in] samples The samples to remove. Removing samples is a bit an expensive operation.
|
||||
\return Returns the number of removed samples. If some samples were not found, then the number of actually removed samples will be smaller than the number of samples requested to remove
|
||||
*/
|
||||
virtual PxU32 removeSamples(const PxArray<PxVec3>& samples) = 0;
|
||||
|
||||
/** Adds new Poisson Samples inside the sphere specified
|
||||
\param[in] sphereCenter The sphere's center. Used to define the region where new samples get added.
|
||||
\param[in] sphereRadius The sphere's radius. Used to define the region where new samples get added.
|
||||
\param[in] createVolumeSamples If set to true, samples will also get generated inside of the mesh, not just on its surface.
|
||||
*/
|
||||
virtual void addSamplesInSphere(const PxVec3& sphereCenter, PxReal sphereRadius, bool createVolumeSamples = false) = 0;
|
||||
|
||||
/** Adds new Poisson Samples inside the box specified
|
||||
\param[in] axisAlignedBox The axis aligned bounding box. Used to define the region where new samples get added.
|
||||
\param[in] boxOrientation The orientation making an oriented bounding box out of the axis aligned one. Used to define the region where new samples get added.
|
||||
\param[in] createVolumeSamples If set to true, samples will also get generated inside of the mesh, not just on its surface.
|
||||
*/
|
||||
virtual void addSamplesInBox(const PxBounds3& axisAlignedBox, const PxQuat& boxOrientation, bool createVolumeSamples = false) = 0;
|
||||
|
||||
/** Gets the Poisson Samples
|
||||
\return Returns the generated Poisson Samples
|
||||
*/
|
||||
virtual const PxArray<PxVec3>& getSamples() const = 0;
|
||||
|
||||
virtual ~PxPoissonSampler() { }
|
||||
};
|
||||
|
||||
|
||||
/** Creates a shape sampler
|
||||
\param[in] geometry The shape that defines the surface on which the samples get created
|
||||
\param[in] transform The shape's global pose
|
||||
\param[in] worldBounds The shapes bounding box
|
||||
\param[in] initialSamplingRadius The closest distance two surface samples are allowed to have
|
||||
\param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc.
|
||||
\return Returns the sampler
|
||||
*/
|
||||
PxPoissonSampler* PxCreateShapeSampler(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30);
|
||||
|
||||
|
||||
/**
|
||||
\brief Sampler to generate Poisson Samples on a triangle mesh.
|
||||
*/
|
||||
class PxTriangleMeshPoissonSampler : public virtual PxPoissonSampler
|
||||
{
|
||||
public:
|
||||
/** Gets the Poisson Samples' triangle indices
|
||||
\return Returns the generated Poisson Samples' triangle indices
|
||||
*/
|
||||
virtual const PxArray<PxI32>& getSampleTriangleIds() const = 0;
|
||||
|
||||
/** Gets the Poisson Samples' barycentric coordinates
|
||||
\return Returns the generated Poisson Samples' barycentric coordinates
|
||||
*/
|
||||
virtual const PxArray<PxVec3>& getSampleBarycentrics() const = 0;
|
||||
|
||||
/** Checks whether a point is inside the triangle mesh
|
||||
\return Returns true if the point is inside the triangle mesh
|
||||
*/
|
||||
virtual bool isPointInTriangleMesh(const PxVec3& p) = 0;
|
||||
|
||||
virtual ~PxTriangleMeshPoissonSampler() { }
|
||||
};
|
||||
|
||||
|
||||
/** Creates a triangle mesh sampler
|
||||
\param[in] triangles The triangle indices of the mesh
|
||||
\param[in] numTriangles The total number of triangles
|
||||
\param[in] vertices The vertices of the mesh
|
||||
\param[in] numVertices The total number of vertices
|
||||
\param[in] initialSamplingRadius The closest distance two surface samples are allowed to have
|
||||
\param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc.
|
||||
\return Returns the sampler
|
||||
*/
|
||||
PxTriangleMeshPoissonSampler* PxCreateTriangleMeshSampler(const PxU32* triangles, PxU32 numTriangles, const PxVec3* vertices, PxU32 numVertices, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30);
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
504
engine/third_party/physx/include/extensions/PxSceneQueryExt.h
vendored
Normal file
504
engine/third_party/physx/include/extensions/PxSceneQueryExt.h
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
// 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-2025 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_SCENE_QUERY_EXT_H
|
||||
#define PX_SCENE_QUERY_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#include "PxScene.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
// These types have been deprecated (removed) in PhysX 3.4. We typedef them to the new types here for easy migration from 3.3 to 3.4.
|
||||
// We will not remove these aliases for convenience.
|
||||
typedef PxQueryHit PxSceneQueryHit;
|
||||
typedef PxQueryFilterData PxSceneQueryFilterData;
|
||||
typedef PxQueryFilterCallback PxSceneQueryFilterCallback;
|
||||
typedef PxQueryCache PxSceneQueryCache;
|
||||
typedef PxHitFlag PxSceneQueryFlag;
|
||||
typedef PxHitFlags PxSceneQueryFlags;
|
||||
|
||||
/**
|
||||
\brief Utility functions for use with PxScene, related to scene queries.
|
||||
|
||||
Some of these functions have been deprecated (removed) in PhysX 3.4. We re-implement them here for easy migration from 3.3 to 3.4.
|
||||
We will not remove them for convenience.
|
||||
*/
|
||||
class PxSceneQueryExt
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Raycast returning any blocking hit, not necessarily the closest.
|
||||
|
||||
Returns whether any rigid actor is hit along the ray.
|
||||
|
||||
\note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] distance Length of the ray. Needs to be larger than 0.
|
||||
\param[out] hit Raycast hit information.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first. If no hit is found the ray gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\return True if a blocking hit was found.
|
||||
|
||||
\see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache PxSceneQueryHit
|
||||
*/
|
||||
static bool raycastAny( const PxScene& scene,
|
||||
const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL);
|
||||
|
||||
/**
|
||||
\brief Raycast returning a single result.
|
||||
|
||||
Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored.
|
||||
|
||||
\note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] distance Length of the ray. Needs to be larger than 0.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information
|
||||
\param[out] hit Raycast hit information.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\return True if a blocking hit was found.
|
||||
|
||||
\see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
|
||||
*/
|
||||
static bool raycastSingle( const PxScene& scene,
|
||||
const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryFlags outputFlags, PxRaycastHit& hit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL);
|
||||
|
||||
/**
|
||||
\brief Raycast returning multiple results.
|
||||
|
||||
Find all rigid actors that get hit along the ray. Each result contains data as specified by the outputFlags field.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
|
||||
\note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] distance Length of the ray. Needs to be larger than 0.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information
|
||||
\param[out] hitBuffer Raycast hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset
|
||||
of the nearer touching hits (typically the query should be restarted with a larger buffer).
|
||||
\param[in] hitBufferSize Size of the hit buffer.
|
||||
\param[out] blockingHit True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be touching.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\return Number of hits in the buffer, or -1 if the buffer overflowed.
|
||||
|
||||
\see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
|
||||
*/
|
||||
static PxI32 raycastMultiple( const PxScene& scene,
|
||||
const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryFlags outputFlags,
|
||||
PxRaycastHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL);
|
||||
|
||||
/**
|
||||
\brief Sweep returning any blocking hit, not necessarily the closest.
|
||||
|
||||
Returns whether any rigid actor is hit along the sweep path.
|
||||
|
||||
\note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the sweep object.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[in] queryFlags Combination of PxSceneQueryFlag defining the query behavior
|
||||
\param[out] hit Sweep hit information.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\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.
|
||||
\return True if a blocking hit was found.
|
||||
|
||||
\see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryHit PxSceneQueryCache
|
||||
*/
|
||||
static bool sweepAny( const PxScene& scene,
|
||||
const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryFlags queryFlags,
|
||||
PxSceneQueryHit& hit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL,
|
||||
const PxSceneQueryCache* cache = NULL,
|
||||
PxReal inflation = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Sweep returning a single result.
|
||||
|
||||
Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored.
|
||||
|
||||
\note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the sweep object.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information.
|
||||
\param[out] hit Sweep hit information.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\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.
|
||||
\return True if a blocking hit was found.
|
||||
|
||||
\see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
|
||||
*/
|
||||
static bool sweepSingle(const PxScene& scene,
|
||||
const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryFlags outputFlags,
|
||||
PxSweepHit& hit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL,
|
||||
const PxSceneQueryCache* cache = NULL,
|
||||
PxReal inflation=0.0f);
|
||||
|
||||
/**
|
||||
\brief Sweep returning multiple results.
|
||||
|
||||
Find all rigid actors that get hit along the sweep. Each result contains data as specified by the outputFlags field.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
|
||||
\note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the sweep object.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[in] outputFlags Specifies which properties should be written to the hit information.
|
||||
\param[out] hitBuffer Sweep hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset
|
||||
of the nearer touching hits (typically the query should be restarted with a larger buffer).
|
||||
\param[in] hitBufferSize Size of the hit buffer.
|
||||
\param[out] blockingHit True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be touching.
|
||||
\param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\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.
|
||||
\return Number of hits in the buffer, or -1 if the buffer overflowed.
|
||||
|
||||
\see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
|
||||
*/
|
||||
static PxI32 sweepMultiple( const PxScene& scene,
|
||||
const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSceneQueryFlags outputFlags, PxSweepHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL,
|
||||
PxReal inflation = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Test overlap between a geometry and objects in the scene.
|
||||
|
||||
\note Filtering: Overlap tests do not distinguish between touching and blocking hit types. Both get written to the hit buffer.
|
||||
|
||||
\note PxHitFlag::eMESH_MULTIPLE and PxHitFlag::eMESH_BOTH_SIDES have no effect in this case
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the object.
|
||||
\param[out] hitBuffer Buffer to store the overlapping objects to. If the buffer overflows, an arbitrary subset of overlapping objects is stored (typically the query should be restarted with a larger buffer).
|
||||
\param[in] hitBufferSize Size of the hit buffer.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to overlap.
|
||||
\return Number of hits in the buffer, or -1 if the buffer overflowed.
|
||||
|
||||
\see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback
|
||||
*/
|
||||
static PxI32 overlapMultiple( const PxScene& scene,
|
||||
const PxGeometry& geometry, const PxTransform& pose,
|
||||
PxOverlapHit* hitBuffer, PxU32 hitBufferSize,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL);
|
||||
|
||||
/**
|
||||
\brief Test returning, for a given geometry, any overlapping object in the scene.
|
||||
|
||||
\note Filtering: Overlap tests do not distinguish between touching and blocking hit types. Both trigger a hit.
|
||||
|
||||
\note PxHitFlag::eMESH_MULTIPLE and PxHitFlag::eMESH_BOTH_SIDES have no effect in this case
|
||||
|
||||
\param[in] scene The scene
|
||||
\param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the object.
|
||||
\param[out] hit Pointer to store the overlapping object to.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to overlap.
|
||||
\return True if an overlap was found.
|
||||
|
||||
\see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback
|
||||
*/
|
||||
static bool overlapAny( const PxScene& scene,
|
||||
const PxGeometry& geometry, const PxTransform& pose,
|
||||
PxOverlapHit& hit,
|
||||
const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
|
||||
PxSceneQueryFilterCallback* filterCall = NULL);
|
||||
};
|
||||
|
||||
struct PxBatchQueryStatus
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief This is the initial state before a query starts.
|
||||
*/
|
||||
ePENDING = 0,
|
||||
|
||||
/**
|
||||
\brief The query is finished; results have been written into the result and hit buffers.
|
||||
*/
|
||||
eSUCCESS,
|
||||
|
||||
/**
|
||||
\brief The query results were incomplete due to touch hit buffer overflow. Blocking hit is still correct.
|
||||
*/
|
||||
eOVERFLOW
|
||||
};
|
||||
|
||||
static PX_FORCE_INLINE Enum getStatus(const PxRaycastBuffer& r)
|
||||
{
|
||||
return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS);
|
||||
}
|
||||
static PX_FORCE_INLINE Enum getStatus(const PxSweepBuffer& r)
|
||||
{
|
||||
return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS);
|
||||
}
|
||||
static PX_FORCE_INLINE Enum getStatus(const PxOverlapBuffer& r)
|
||||
{
|
||||
return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS);
|
||||
}
|
||||
};
|
||||
|
||||
class PxBatchQueryExt
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Performs a raycast against objects in the scene.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
\note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
|
||||
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] distance Length of the ray. Needs to be larger than 0.
|
||||
\param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit.
|
||||
\param[in] filterData Filtering data passed to the filter shader. See #PxQueryFilterData #PxQueryFilterCallback
|
||||
\param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
|
||||
\note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock
|
||||
and overlapping writes from different threads may result in undefined behavior).
|
||||
|
||||
\return Returns a PxRaycastBuffer pointer that will store the result of the query after execute() is completed.
|
||||
This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor.
|
||||
\see PxCreateBatchQueryExt
|
||||
|
||||
\see PxQueryFilterData PxQueryFilterCallback PxRaycastHit PxScene::raycast
|
||||
*/
|
||||
virtual PxRaycastBuffer* raycast(
|
||||
const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
|
||||
const PxU16 maxNbTouches = 0,
|
||||
PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(),
|
||||
const PxQueryCache* cache = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Performs a sweep test against objects in the scene.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
\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.
|
||||
|
||||
\param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the sweep object.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit.
|
||||
\param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback
|
||||
\param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\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.
|
||||
Note: ePRECISE_SWEEP doesn't support inflation. Therefore the sweep will be performed with zero inflation.
|
||||
|
||||
\note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock
|
||||
and overlapping writes from different threads may result in undefined behavior).
|
||||
|
||||
\return Returns a PxSweepBuffer pointer that will store the result of the query after execute() is completed.
|
||||
This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor.
|
||||
\see PxCreateBatchQueryExt
|
||||
|
||||
\see PxHitFlags PxQueryFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit
|
||||
*/
|
||||
virtual PxSweepBuffer* sweep(
|
||||
const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
|
||||
const PxU16 maxNbTouches = 0,
|
||||
PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(),
|
||||
const PxQueryCache* cache = NULL,
|
||||
const PxReal inflation = 0.0f) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Performs an overlap test of a given geometry against objects in the scene.
|
||||
|
||||
\note Filtering: returning eBLOCK from user filter for overlap queries will cause a warning (see #PxQueryHitType).
|
||||
|
||||
\param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the object.
|
||||
\param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default.
|
||||
\param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback
|
||||
\param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
|
||||
\note eBLOCK should not be returned from user filters for overlap(). Doing so will result in undefined behavior, and a warning will be issued.
|
||||
\note If the PxQueryFlag::eNO_BLOCK flag is set, the eBLOCK will instead be automatically converted to an eTOUCH and the warning suppressed.
|
||||
\note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock
|
||||
and overlapping writes from different threads may result in undefined behavior).
|
||||
|
||||
\return Returns a PxOverlapBuffer pointer that will store the result of the query after execute() is completed.
|
||||
This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor.
|
||||
\see PxCreateBatchQueryExt
|
||||
|
||||
\see PxQueryFilterData PxQueryFilterCallback
|
||||
*/
|
||||
virtual PxOverlapBuffer* overlap(
|
||||
const PxGeometry& geometry, const PxTransform& pose,
|
||||
PxU16 maxNbTouches = 0,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(),
|
||||
const PxQueryCache* cache = NULL) = 0;
|
||||
|
||||
virtual void execute() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxBatchQueryExt() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Create a PxBatchQueryExt without the need for pre-allocated result or touch buffers.
|
||||
|
||||
\param[in] scene Queries will be performed against objects in the specified PxScene
|
||||
\param[in] queryFilterCallback Filtering for all queries is performed using queryFilterCallback. A null pointer results in all shapes being considered.
|
||||
|
||||
\param[in] maxNbRaycasts A result buffer will be allocated that is large enough to accommodate maxNbRaycasts calls to PxBatchQueryExt::raycast()
|
||||
\param[in] maxNbRaycastTouches A touch buffer will be allocated that is large enough to accommodate maxNbRaycastTouches touches for all raycasts in the batch.
|
||||
|
||||
\param[in] maxNbSweeps A result buffer will be allocated that is large enough to accommodate maxNbSweeps calls to PxBatchQueryExt::sweep()
|
||||
\param[in] maxNbSweepTouches A touch buffer will be allocated that is large enough to accommodate maxNbSweepTouches touches for all sweeps in the batch.
|
||||
|
||||
\param[in] maxNbOverlaps A result buffer will be allocated that is large enough to accommodate maxNbOverlaps calls to PxBatchQueryExt::overlap()
|
||||
\param[in] maxNbOverlapTouches A touch buffer will be allocated that is large enough to accommodate maxNbOverlapTouches touches for all overlaps in the batch.
|
||||
|
||||
\return Returns a PxBatchQueryExt instance. A NULL pointer will be returned if the subsequent allocations fail or if any of the arguments are illegal.
|
||||
In the event that a NULL pointer is returned a corresponding error will be issued to the error stream.
|
||||
*/
|
||||
PxBatchQueryExt* PxCreateBatchQueryExt(
|
||||
const PxScene& scene, PxQueryFilterCallback* queryFilterCallback,
|
||||
const PxU32 maxNbRaycasts, const PxU32 maxNbRaycastTouches,
|
||||
const PxU32 maxNbSweeps, const PxU32 maxNbSweepTouches,
|
||||
const PxU32 maxNbOverlaps, const PxU32 maxNbOverlapTouches);
|
||||
|
||||
|
||||
/**
|
||||
\brief Create a PxBatchQueryExt with user-supplied result and touch buffers.
|
||||
|
||||
\param[in] scene Queries will be performed against objects in the specified PxScene
|
||||
\param[in] queryFilterCallback Filtering for all queries is performed using queryFilterCallback. A null pointer results in all shapes being considered.
|
||||
|
||||
\param[in] raycastBuffers This is the array that will be used to store the results of each raycast in a batch.
|
||||
\param[in] maxNbRaycasts This is the length of the raycastBuffers array.
|
||||
\param[in] raycastTouches This is the array that will be used to store the touches generated by all raycasts in a batch.
|
||||
\param[in] maxNbRaycastTouches This is the length of the raycastTouches array.
|
||||
|
||||
\param[in] sweepBuffers This is the array that will be used to store the results of each sweep in a batch.
|
||||
\param[in] maxNbSweeps This is the length of the sweepBuffers array.
|
||||
\param[in] sweepTouches This is the array that will be used to store the touches generated by all sweeps in a batch.
|
||||
\param[in] maxNbSweepTouches This is the length of the sweepTouches array.
|
||||
|
||||
\param[in] overlapBuffers This is the array that will be used to store the results of each overlap in a batch.
|
||||
\param[in] maxNbOverlaps This is the length of the overlapBuffers array.
|
||||
\param[in] overlapTouches This is the array that will be used to store the touches generated by all overlaps in a batch.
|
||||
\param[in] maxNbOverlapTouches This is the length of the overlapTouches array.
|
||||
|
||||
\return Returns a PxBatchQueryExt instance. A NULL pointer will be returned if the subsequent allocations fail or if any of the arguments are illegal.
|
||||
In the event that a NULL pointer is returned a corresponding error will be issued to the error stream.
|
||||
*/
|
||||
PxBatchQueryExt* PxCreateBatchQueryExt(
|
||||
const PxScene& scene, PxQueryFilterCallback* queryFilterCallback,
|
||||
PxRaycastBuffer* raycastBuffers, const PxU32 maxNbRaycasts, PxRaycastHit* raycastTouches, const PxU32 maxNbRaycastTouches,
|
||||
PxSweepBuffer* sweepBuffers, const PxU32 maxNbSweeps, PxSweepHit* sweepTouches, const PxU32 maxNbSweepTouches,
|
||||
PxOverlapBuffer* overlapBuffers, const PxU32 maxNbOverlaps, PxOverlapHit* overlapTouches, const PxU32 maxNbOverlapTouches);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
63
engine/third_party/physx/include/extensions/PxSceneQuerySystemExt.h
vendored
Normal file
63
engine/third_party/physx/include/extensions/PxSceneQuerySystemExt.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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-2025 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_SCENE_QUERY_SYSTEM_EXT_H
|
||||
#define PX_SCENE_QUERY_SYSTEM_EXT_H
|
||||
|
||||
#include "PxSceneQuerySystem.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Creates an external scene query system.
|
||||
|
||||
An external SQ system is the part of a PxScene that deals with scene queries (SQ). This is usually taken care of
|
||||
by an internal implementation inside PxScene, but it is also possible to re-route all SQ calls to an external
|
||||
implementation, potentially opening the door to some customizations in behavior and features for advanced users.
|
||||
|
||||
The following external SQ system is an example of how an implementation would look like. It re-uses much of the
|
||||
same code as the internal version, but it could be re-implemented in a completely different way to match users'
|
||||
specific needs.
|
||||
|
||||
\param[in] desc Scene query descriptor
|
||||
\param[in] contextID Context ID parameter, sent to the profiler
|
||||
|
||||
\return An external SQ system instance
|
||||
|
||||
\see PxSceneQuerySystem PxSceneQueryDesc
|
||||
*/
|
||||
PxSceneQuerySystem* PxCreateExternalSceneQuerySystem(const PxSceneQueryDesc& desc, PxU64 contextID);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
251
engine/third_party/physx/include/extensions/PxSerialization.h
vendored
Normal file
251
engine/third_party/physx/include/extensions/PxSerialization.h
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
// 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-2025 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_SERIALIZATION_H
|
||||
#define PX_SERIALIZATION_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "cooking/PxCooking.h"
|
||||
#include "foundation/PxIO.h"
|
||||
#include "common/PxTolerancesScale.h"
|
||||
#include "common/PxTypeInfo.h"
|
||||
#include "common/PxStringTable.h"
|
||||
|
||||
/**
|
||||
PX_BINARY_SERIAL_VERSION is used to version the PhysX binary data and meta data. The global unique identifier of the PhysX SDK needs to match
|
||||
the one in the data and meta data, otherwise they are considered incompatible. A 32 character wide GUID can be generated with https://www.guidgenerator.com/ for example.
|
||||
*/
|
||||
#define PX_BINARY_SERIAL_VERSION "49FB7605F83144B6825C2673CF3840C9"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Utility functions for serialization
|
||||
|
||||
\see PxCollection, PxSerializationRegistry
|
||||
*/
|
||||
class PxSerialization
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Additional PxScene and PxPhysics options stored in XML serialized data.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
|
||||
The PxXmlMiscParameter parameter can be serialized and deserialized along with PxCollection instances (XML only).
|
||||
This is for application use only and has no impact on how objects are serialized or deserialized.
|
||||
|
||||
\see PxSerialization::createCollectionFromXml, PxSerialization::serializeCollectionToXml
|
||||
*/
|
||||
struct PX_DEPRECATED PxXmlMiscParameter
|
||||
{
|
||||
/**
|
||||
\brief Up vector for the scene reference coordinate system.
|
||||
*/
|
||||
PxVec3 upVector;
|
||||
|
||||
/**
|
||||
\brief Tolerances scale to be used for the scene.
|
||||
*/
|
||||
PxTolerancesScale scale;
|
||||
|
||||
PxXmlMiscParameter() : upVector(0) {}
|
||||
PxXmlMiscParameter(PxVec3& inUpVector, PxTolerancesScale inScale) : upVector(inUpVector), scale(inScale) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Returns whether the collection is serializable with the externalReferences collection.
|
||||
|
||||
Some definitions to explain whether a collection can be serialized or not:
|
||||
|
||||
For definitions of <b>requires</b> and <b>complete</b> see #PxSerialization::complete
|
||||
|
||||
A serializable object is <b>subordinate</b> if it cannot be serialized on its own
|
||||
The following objects are subordinate:
|
||||
- articulation links
|
||||
- articulation joints
|
||||
- joints
|
||||
|
||||
A collection C can be serialized with external references collection D iff
|
||||
- C is complete relative to D (no dangling references)
|
||||
- Every object in D required by an object in C has a valid ID (no unnamed references)
|
||||
- Every subordinate object in C is required by another object in C (no orphans)
|
||||
|
||||
\param[in] collection Collection to be checked
|
||||
\param[in] sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param[in] externalReferences the external References collection
|
||||
\return Whether the collection is serializable
|
||||
\see PxSerialization::complete, PxSerialization::serializeCollectionToBinary, PxSerialization::serializeCollectionToXml, PxSerializationRegistry
|
||||
*/
|
||||
static bool isSerializable(PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* externalReferences = NULL);
|
||||
|
||||
/**
|
||||
\brief Adds to a collection all objects such that it can be successfully serialized.
|
||||
|
||||
A collection C is complete relative to an other collection D if every object required by C is either in C or D.
|
||||
This function adds objects to a collection, such that it becomes complete with respect to the exceptFor collection.
|
||||
Completeness is needed for serialization. See #PxSerialization::serializeCollectionToBinary,
|
||||
#PxSerialization::serializeCollectionToXml.
|
||||
|
||||
Sdk objects require other sdk object according to the following rules:
|
||||
- joints require their actors and constraint
|
||||
- rigid actors require their shapes
|
||||
- shapes require their material(s) and mesh (triangle mesh, convex mesh or height field), if any
|
||||
- articulations require their links and joints
|
||||
- aggregates require their actors
|
||||
|
||||
If followJoints is specified another rule is added:
|
||||
- actors require their joints
|
||||
|
||||
Specifying followJoints will make whole jointed actor chains being added to the collection. Following chains
|
||||
is interrupted whenever a object in exceptFor is encountered.
|
||||
|
||||
\param[in,out] collection Collection which is completed
|
||||
\param[in] sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param[in] exceptFor Optional exemption collection
|
||||
\param[in] followJoints Specifies whether joints should be added for jointed actors
|
||||
\see PxCollection, PxSerialization::serializeCollectionToBinary, PxSerialization::serializeCollectionToXml, PxSerializationRegistry
|
||||
*/
|
||||
static void complete(PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* exceptFor = NULL, bool followJoints = false);
|
||||
|
||||
/**
|
||||
\brief Creates PxSerialObjectId values for unnamed objects in a collection.
|
||||
|
||||
Creates PxSerialObjectId names for unnamed objects in a collection starting at a base value and incrementing,
|
||||
skipping values that are already assigned to objects in the collection.
|
||||
|
||||
\param[in,out] collection Collection for which names are created
|
||||
\param[in] base Start address for PxSerialObjectId names
|
||||
\see PxCollection
|
||||
*/
|
||||
static void createSerialObjectIds(PxCollection& collection, const PxSerialObjectId base);
|
||||
|
||||
/**
|
||||
\brief Creates a PxCollection from XML data.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
|
||||
\param inputData The input data containing the XML collection.
|
||||
\param params Cooking parameters used for sdk object instantiation.
|
||||
\param sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param externalRefs PxCollection used to resolve external references.
|
||||
\param stringTable PxStringTable instance used for storing object names.
|
||||
\param outArgs Optional parameters of physics and scene deserialized from XML. See #PxSerialization::PxXmlMiscParameter
|
||||
\return a pointer to a PxCollection if successful or NULL if it failed.
|
||||
|
||||
\see PxCollection, PxSerializationRegistry, PxInputData, PxStringTable, PxCooking, PxSerialization::PxXmlMiscParameter
|
||||
*/
|
||||
PX_DEPRECATED static PxCollection* createCollectionFromXml(PxInputData& inputData, const PxCookingParams& params, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL, PxStringTable* stringTable = NULL, PxXmlMiscParameter* outArgs = NULL);
|
||||
|
||||
/**
|
||||
\brief Deserializes a PxCollection from memory.
|
||||
|
||||
Creates a collection from memory. If the collection has external dependencies another collection
|
||||
can be provided to resolve these.
|
||||
|
||||
The memory block provided has to be 128 bytes aligned and contain a contiguous serialized collection as written
|
||||
by PxSerialization::serializeCollectionToBinary. The contained binary data needs to be compatible with the current binary format version
|
||||
which is defined by "PX_PHYSICS_VERSION_MAJOR.PX_PHYSICS_VERSION_MINOR.PX_PHYSICS_VERSION_BUGFIX-PX_BINARY_SERIAL_VERSION".
|
||||
For a list of compatible sdk releases refer to the documentation of PX_BINARY_SERIAL_VERSION.
|
||||
|
||||
\param[in] memBlock Pointer to memory block containing the serialized collection
|
||||
\param[in] sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param[in] externalRefs Collection to resolve external dependencies
|
||||
|
||||
\see PxCollection, PxSerialization::complete, PxSerialization::serializeCollectionToBinary, PxSerializationRegistry, PX_BINARY_SERIAL_VERSION
|
||||
*/
|
||||
static PxCollection* createCollectionFromBinary(void* memBlock, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL);
|
||||
|
||||
/**
|
||||
\brief Serializes a physics collection to an XML output stream.
|
||||
|
||||
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
|
||||
|
||||
The collection to be serialized needs to be complete \see PxSerialization.complete.
|
||||
Optionally the XML may contain meshes in binary cooked format for fast loading. It does this when providing a valid non-null PxCooking pointer.
|
||||
|
||||
\note Serialization of objects in a scene that is simultaneously being simulated is not supported and leads to undefined behavior.
|
||||
|
||||
\param outputStream Stream to save collection to.
|
||||
\param collection PxCollection instance which is serialized. The collection needs to be complete with respect to the externalRefs collection.
|
||||
\param sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param params Optional pointer to cooking params. If provided, cooked mesh data is cached for fast loading.
|
||||
\param externalRefs Collection containing external references.
|
||||
\param inArgs Optional parameters of physics and scene serialized to XML along with the collection. See #PxSerialization::PxXmlMiscParameter
|
||||
\return true if the collection is successfully serialized.
|
||||
|
||||
\see PxCollection, PxOutputStream, PxSerializationRegistry, PxCooking, PxSerialization::PxXmlMiscParameter
|
||||
*/
|
||||
PX_DEPRECATED static bool serializeCollectionToXml(PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, const PxCookingParams* params = NULL, const PxCollection* externalRefs = NULL, PxXmlMiscParameter* inArgs = NULL);
|
||||
|
||||
/**
|
||||
\brief Serializes a collection to a binary stream.
|
||||
|
||||
Serializes a collection to a stream. In order to resolve external dependencies the externalReferences collection has to be provided.
|
||||
Optionally names of objects that where set for example with #PxActor::setName are serialized along with the objects.
|
||||
|
||||
The collection can be successfully serialized if isSerializable(collection) returns true. See #isSerializable.
|
||||
|
||||
The implementation of the output stream needs to fulfill the requirements on the memory block input taken by
|
||||
PxSerialization::createCollectionFromBinary.
|
||||
|
||||
\note Serialization of objects in a scene that is simultaneously being simulated is not supported and leads to undefined behavior.
|
||||
|
||||
\param[out] outputStream into which the collection is serialized
|
||||
\param[in] collection Collection to be serialized
|
||||
\param[in] sr PxSerializationRegistry instance with information about registered classes.
|
||||
\param[in] externalRefs Collection used to resolve external dependencies
|
||||
\param[in] exportNames Specifies whether object names are serialized
|
||||
\return Whether serialization was successful
|
||||
|
||||
\see PxCollection, PxOutputStream, PxSerialization::complete, PxSerialization::createCollectionFromBinary, PxSerializationRegistry
|
||||
*/
|
||||
static bool serializeCollectionToBinary(PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL, bool exportNames = false );
|
||||
|
||||
/**
|
||||
\brief Creates an application managed registry for serialization.
|
||||
|
||||
\param[in] physics Physics SDK to generate create serialization registry
|
||||
|
||||
\return PxSerializationRegistry instance.
|
||||
|
||||
\see PxSerializationRegistry
|
||||
*/
|
||||
static PxSerializationRegistry* createSerializationRegistry(PxPhysics& physics);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
155
engine/third_party/physx/include/extensions/PxShapeExt.h
vendored
Normal file
155
engine/third_party/physx/include/extensions/PxShapeExt.h
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
// 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-2025 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_SHAPE_EXT_H
|
||||
#define PX_SHAPE_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#include "PxShape.h"
|
||||
#include "PxRigidActor.h"
|
||||
#include "geometry/PxGeometryQuery.h"
|
||||
#include "PxQueryReport.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief utility functions for use with PxShape
|
||||
|
||||
\see PxShape
|
||||
*/
|
||||
|
||||
class PxShapeExt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Retrieves the world space pose of the shape.
|
||||
|
||||
\param[in] shape The shape for which to get the global pose.
|
||||
\param[in] actor The actor to which the shape is attached
|
||||
|
||||
\return Global pose of shape.
|
||||
*/
|
||||
static PX_INLINE PxTransform getGlobalPose(const PxShape& shape, const PxRigidActor& actor)
|
||||
{
|
||||
// PT:: tag: scalar transform*transform
|
||||
return actor.getGlobalPose() * shape.getLocalPose();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Raycast test against the shape.
|
||||
|
||||
\param[in] shape the shape
|
||||
\param[in] actor the actor to which the shape is attached
|
||||
\param[in] rayOrigin The origin of the ray to test the geometry object against
|
||||
\param[in] rayDir The direction of the ray to test the geometry object against
|
||||
\param[in] maxDist Maximum ray length
|
||||
\param[in] hitFlags Specify which properties per hit should be computed and written to result hit array. 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 shape
|
||||
|
||||
\see PxRaycastHit PxTransform
|
||||
*/
|
||||
static PX_INLINE PxU32 raycast(const PxShape& shape, const PxRigidActor& actor,
|
||||
const PxVec3& rayOrigin, const PxVec3& rayDir, PxReal maxDist, PxHitFlags hitFlags,
|
||||
PxU32 maxHits, PxRaycastHit* rayHits)
|
||||
{
|
||||
return PxGeometryQuery::raycast(
|
||||
rayOrigin, rayDir, shape.getGeometry(), getGlobalPose(shape, actor), maxDist, hitFlags, maxHits, rayHits);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Test overlap between the shape and a geometry object
|
||||
|
||||
\param[in] shape the shape
|
||||
\param[in] actor the actor to which the shape is attached
|
||||
\param[in] otherGeom The other geometry object to test overlap with
|
||||
\param[in] otherGeomPose Pose of the other geometry object
|
||||
\return True if the shape overlaps the geometry object
|
||||
|
||||
\see PxGeometry PxTransform
|
||||
*/
|
||||
static PX_INLINE bool overlap(const PxShape& shape, const PxRigidActor& actor,
|
||||
const PxGeometry& otherGeom, const PxTransform& otherGeomPose)
|
||||
{
|
||||
return PxGeometryQuery::overlap(shape.getGeometry(), getGlobalPose(shape, actor), otherGeom, otherGeomPose);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sweep a geometry object against the shape.
|
||||
|
||||
Currently only box, sphere, capsule and convex mesh shapes are supported, i.e. the swept geometry object must be one of those types.
|
||||
|
||||
\param[in] shape the shape
|
||||
\param[in] actor the actor to which the shape is attached
|
||||
\param[in] unitDir Normalized direction along which the geometry object should be swept.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0.
|
||||
\param[in] otherGeom The geometry object to sweep against the shape
|
||||
\param[in] otherGeomPose Pose of the geometry object
|
||||
\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
|
||||
\return True if the swept geometry object hits the shape
|
||||
|
||||
\see PxGeometry PxTransform PxSweepHit
|
||||
*/
|
||||
static PX_INLINE bool sweep(const PxShape& shape, const PxRigidActor& actor,
|
||||
const PxVec3& unitDir, const PxReal distance, const PxGeometry& otherGeom, const PxTransform& otherGeomPose,
|
||||
PxSweepHit& sweepHit, PxHitFlags hitFlags)
|
||||
{
|
||||
return PxGeometryQuery::sweep(unitDir, distance, otherGeom, otherGeomPose, shape.getGeometry(), getGlobalPose(shape, actor), sweepHit, hitFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Retrieves the axis aligned bounding box enclosing the shape.
|
||||
|
||||
\return The shape's bounding box.
|
||||
|
||||
\param[in] shape the shape
|
||||
\param[in] actor the actor to which the shape is attached
|
||||
\param[in] inflation Scale factor for computed world bounds. Box extents are multiplied by this value.
|
||||
|
||||
\see PxBounds3
|
||||
*/
|
||||
static PX_INLINE PxBounds3 getWorldBounds(const PxShape& shape, const PxRigidActor& actor, float inflation=1.01f)
|
||||
{
|
||||
PxBounds3 bounds;
|
||||
PxGeometryQuery::computeGeomBounds(bounds, shape.getGeometry(), getGlobalPose(shape, actor), 0.0f, inflation);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
293
engine/third_party/physx/include/extensions/PxSimpleFactory.h
vendored
Normal file
293
engine/third_party/physx/include/extensions/PxSimpleFactory.h
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
// 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-2025 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_SIMPLE_FACTORY_H
|
||||
#define PX_SIMPLE_FACTORY_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxPlane.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxPhysics;
|
||||
class PxMaterial;
|
||||
class PxRigidActor;
|
||||
class PxRigidDynamic;
|
||||
class PxRigidStatic;
|
||||
class PxGeometry;
|
||||
class PxShape;
|
||||
|
||||
/** \brief simple method to create a PxRigidDynamic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the global pose of the new object
|
||||
\param[in] geometry the geometry of the new object's shape, which must be a sphere, capsule, box or convex
|
||||
\param[in] material the material for the new object's shape
|
||||
\param[in] density the density of the new object. Must be greater than zero.
|
||||
\param[in] shapeOffset an optional offset for the new shape, defaults to identity
|
||||
|
||||
\return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could
|
||||
not be constructed
|
||||
|
||||
\see PxRigidDynamic PxShapeFlag
|
||||
*/
|
||||
PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
const PxGeometry& geometry,
|
||||
PxMaterial& material,
|
||||
PxReal density,
|
||||
const PxTransform& shapeOffset = PxTransform(PxIdentity));
|
||||
|
||||
/** \brief simple method to create a PxRigidDynamic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the transform of the new object
|
||||
\param[in] shape the shape of the new object
|
||||
\param[in] density the density of the new object. Must be greater than zero.
|
||||
|
||||
\return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could
|
||||
not be constructed
|
||||
|
||||
\see PxRigidDynamic PxShapeFlag
|
||||
*/
|
||||
PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
PxShape& shape,
|
||||
PxReal density);
|
||||
|
||||
/** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the global pose of the new object
|
||||
\param[in] geometry the geometry of the new object's shape
|
||||
\param[in] material the material for the new object's shape
|
||||
\param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation.
|
||||
\param[in] shapeOffset an optional offset for the new shape, defaults to identity
|
||||
|
||||
\note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However,
|
||||
kinematics of other geometry types may not participate in simulation collision and may be used only for
|
||||
triggers or scene queries of moving objects under animation control. In this case the density parameter
|
||||
will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE)
|
||||
|
||||
\return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could
|
||||
not be constructed
|
||||
|
||||
\see PxRigidDynamic PxShapeFlag
|
||||
*/
|
||||
PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
const PxGeometry& geometry,
|
||||
PxMaterial& material,
|
||||
PxReal density,
|
||||
const PxTransform& shapeOffset = PxTransform(PxIdentity));
|
||||
|
||||
/** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the global pose of the new object
|
||||
\param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation.
|
||||
\param[in] shape the shape of the new object
|
||||
|
||||
\note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However,
|
||||
kinematics of other geometry types may not participate in simulation collision and may be used only for
|
||||
triggers or scene queries of moving objects under animation control. In this case the density parameter
|
||||
will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE)
|
||||
|
||||
\return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could
|
||||
not be constructed
|
||||
|
||||
\see PxRigidDynamic PxShapeFlag
|
||||
*/
|
||||
PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
PxShape& shape,
|
||||
PxReal density);
|
||||
|
||||
/** \brief simple method to create a PxRigidStatic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the global pose of the new object
|
||||
\param[in] geometry the geometry of the new object's shape
|
||||
\param[in] material the material for the new object's shape
|
||||
\param[in] shapeOffset an optional offset for the new shape, defaults to identity
|
||||
|
||||
\return a new static actor, or NULL if it could not be constructed
|
||||
|
||||
\see PxRigidStatic
|
||||
*/
|
||||
PxRigidStatic* PxCreateStatic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
const PxGeometry& geometry,
|
||||
PxMaterial& material,
|
||||
const PxTransform& shapeOffset = PxTransform(PxIdentity));
|
||||
|
||||
/** \brief simple method to create a PxRigidStatic actor with a single PxShape.
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] transform the global pose of the new object
|
||||
\param[in] shape the new object's shape
|
||||
|
||||
\return a new static actor, or NULL if it could not be constructed
|
||||
|
||||
\see PxRigidStatic
|
||||
*/
|
||||
PxRigidStatic* PxCreateStatic(PxPhysics& sdk,
|
||||
const PxTransform& transform,
|
||||
PxShape& shape);
|
||||
|
||||
/**
|
||||
\brief create a shape by copying attributes from another shape
|
||||
|
||||
The function clones a PxShape. The following properties are copied:
|
||||
- geometry
|
||||
- flags
|
||||
- materials
|
||||
- actor-local pose
|
||||
- contact offset
|
||||
- rest offset
|
||||
- simulation filter data
|
||||
- query filter data
|
||||
- torsional patch radius
|
||||
- minimum torsional patch radius
|
||||
|
||||
The following are not copied and retain their default values:
|
||||
- name
|
||||
- user data
|
||||
|
||||
\param[in] physicsSDK - the physics SDK used to allocate the shape
|
||||
\param[in] shape the shape from which to take the attributes.
|
||||
\param[in] isExclusive whether the new shape should be an exclusive or shared shape.
|
||||
|
||||
\return the newly-created rigid static
|
||||
*/
|
||||
PxShape* PxCloneShape(PxPhysics& physicsSDK,
|
||||
const PxShape& shape,
|
||||
bool isExclusive);
|
||||
|
||||
/**
|
||||
\brief create a static body by copying attributes from another rigid actor
|
||||
|
||||
The function clones a PxRigidDynamic or PxRigidStatic as a PxRigidStatic. A uniform scale is applied. The following properties are copied:
|
||||
- shapes
|
||||
- actor flags
|
||||
- owner client and client behavior bits
|
||||
- dominance group
|
||||
|
||||
The following are not copied and retain their default values:
|
||||
- name
|
||||
- joints or observers
|
||||
- aggregate or scene membership
|
||||
- user data
|
||||
|
||||
\note Transforms are not copied with bit-exact accuracy.
|
||||
|
||||
\param[in] physicsSDK - the physics SDK used to allocate the rigid static
|
||||
\param[in] actor the rigid actor from which to take the attributes.
|
||||
\param[in] transform the transform of the new static.
|
||||
|
||||
\return the newly-created rigid static
|
||||
*/
|
||||
PxRigidStatic* PxCloneStatic(PxPhysics& physicsSDK,
|
||||
const PxTransform& transform,
|
||||
const PxRigidActor& actor);
|
||||
|
||||
/**
|
||||
\brief create a dynamic body by copying attributes from an existing body
|
||||
|
||||
The following properties are copied:
|
||||
- shapes
|
||||
- actor flags, rigidDynamic flags and rigidDynamic lock flags
|
||||
- mass, moment of inertia, and center of mass frame
|
||||
- linear and angular velocity
|
||||
- linear and angular damping
|
||||
- maximum linear velocity
|
||||
- maximum angular velocity
|
||||
- position and velocity solver iterations
|
||||
- maximum depenetration velocity
|
||||
- sleep threshold
|
||||
- contact report threshold
|
||||
- dominance group
|
||||
- owner client and client behavior bits
|
||||
- name pointer
|
||||
- kinematic target
|
||||
|
||||
The following are not copied and retain their default values:
|
||||
- name
|
||||
- joints or observers
|
||||
- aggregate or scene membership
|
||||
- sleep timer
|
||||
- user data
|
||||
|
||||
\note Transforms are not copied with bit-exact accuracy.
|
||||
|
||||
\param[in] physicsSDK PxPhysics - the physics SDK used to allocate the rigid static
|
||||
\param[in] body the rigid dynamic to clone.
|
||||
\param[in] transform the transform of the new dynamic
|
||||
|
||||
\return the newly-created rigid static
|
||||
*/
|
||||
PxRigidDynamic* PxCloneDynamic(PxPhysics& physicsSDK,
|
||||
const PxTransform& transform,
|
||||
const PxRigidDynamic& body);
|
||||
|
||||
/** \brief create a plane actor. The plane equation is n.x + d = 0
|
||||
|
||||
\param[in] sdk the PxPhysics object
|
||||
\param[in] plane a plane of the form n.x + d = 0
|
||||
\param[in] material the material for the new object's shape
|
||||
|
||||
\return a new static actor, or NULL if it could not be constructed
|
||||
|
||||
\see PxRigidStatic
|
||||
*/
|
||||
PxRigidStatic* PxCreatePlane(PxPhysics& sdk,
|
||||
const PxPlane& plane,
|
||||
PxMaterial& material);
|
||||
|
||||
/**
|
||||
\brief scale a rigid actor by a uniform scale
|
||||
|
||||
The geometry and relative positions of the actor are multiplied by the given scale value. If the actor is a rigid body or an
|
||||
articulation link and the scaleMassProps value is true, the mass properties are scaled assuming the density is constant: the
|
||||
center of mass is linearly scaled, the mass is multiplied by the cube of the scale, and the inertia tensor by the fifth power of the scale.
|
||||
|
||||
\param[in] actor a rigid actor
|
||||
\param[in] scale the scale by which to multiply the actor. Must be >0.
|
||||
\param[in] scaleMassProps whether to scale the mass properties
|
||||
*/
|
||||
void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps = true);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
56
engine/third_party/physx/include/extensions/PxSmoothNormals.h
vendored
Normal file
56
engine/third_party/physx/include/extensions/PxSmoothNormals.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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-2025 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_SMOOTH_NORMALS_H
|
||||
#define PX_SMOOTH_NORMALS_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
/**
|
||||
\brief Builds smooth vertex normals over a mesh.
|
||||
|
||||
- "smooth" because smoothing groups are not supported here
|
||||
- takes angles into account for correct cube normals computation
|
||||
|
||||
To use 32bit indices pass a pointer in dFaces and set wFaces to zero. Alternatively pass a pointer to
|
||||
wFaces and set dFaces to zero.
|
||||
|
||||
\param[in] nbTris Number of triangles
|
||||
\param[in] nbVerts Number of vertices
|
||||
\param[in] verts Array of vertices
|
||||
\param[in] dFaces Array of dword triangle indices, or null
|
||||
\param[in] wFaces Array of word triangle indices, or null
|
||||
\param[out] normals Array of computed normals (assumes nbVerts vectors)
|
||||
\param[in] flip Flips the normals or not
|
||||
\return True on success.
|
||||
*/
|
||||
PX_C_EXPORT bool PX_CALL_CONV PxBuildSmoothNormals(physx::PxU32 nbTris, physx::PxU32 nbVerts, const physx::PxVec3* verts,
|
||||
const physx::PxU32* dFaces, const physx::PxU16* wFaces, physx::PxVec3* normals, bool flip);
|
||||
|
||||
#endif
|
||||
49
engine/third_party/physx/include/extensions/PxSoftBodyExt.h
vendored
Normal file
49
engine/third_party/physx/include/extensions/PxSoftBodyExt.h
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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-2025 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_SOFT_BODY_EXT_H
|
||||
#define PX_SOFT_BODY_EXT_H
|
||||
|
||||
#include "PxDeformableVolumeExt.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see PxDeformableVolumeExt
|
||||
*/
|
||||
typedef PX_DEPRECATED PxDeformableVolumeExt PxSoftBodyExt;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
180
engine/third_party/physx/include/extensions/PxSphericalJoint.h
vendored
Normal file
180
engine/third_party/physx/include/extensions/PxSphericalJoint.h
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
// 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-2025 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_SPHERICAL_JOINT_H
|
||||
#define PX_SPHERICAL_JOINT_H
|
||||
|
||||
#include "extensions/PxJoint.h"
|
||||
#include "extensions/PxJointLimit.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxSphericalJoint;
|
||||
|
||||
/**
|
||||
\brief Create a spherical joint.
|
||||
|
||||
\param[in] physics The physics SDK
|
||||
\param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame0 The position and orientation of the joint relative to actor0
|
||||
\param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
|
||||
\param[in] localFrame1 The position and orientation of the joint relative to actor1
|
||||
|
||||
\see PxSphericalJoint
|
||||
*/
|
||||
PxSphericalJoint* PxSphericalJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
|
||||
|
||||
|
||||
/**
|
||||
\brief Flags specific to the spherical joint.
|
||||
|
||||
\see PxSphericalJoint
|
||||
*/
|
||||
struct PxSphericalJointFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLIMIT_ENABLED = 1<<1 //!< the cone limit for the spherical joint is enabled
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxSphericalJointFlag::Enum, PxU16> PxSphericalJointFlags;
|
||||
PX_FLAGS_OPERATORS(PxSphericalJointFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief A joint which behaves in a similar way to a ball and socket.
|
||||
|
||||
A spherical joint removes all linear degrees of freedom from two objects.
|
||||
|
||||
The position of the joint on each actor is specified by the origin of the body's joint frame.
|
||||
|
||||
A spherical joint may have a cone limit, to restrict the motion to within a certain range.
|
||||
|
||||
Dirve and limits are activated by setting the appropriate flags on the joint.
|
||||
|
||||
\see PxRevoluteJointCreate() PxJoint
|
||||
*/
|
||||
class PxSphericalJoint : public PxJoint
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Set the limit cone.
|
||||
|
||||
If enabled, the limit cone will constrain the angular movement of the joint to lie
|
||||
within an elliptical cone.
|
||||
|
||||
\return the limit cone
|
||||
|
||||
\see PxJointLimitCone setLimit()
|
||||
*/
|
||||
virtual PxJointLimitCone getLimitCone() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the limit cone.
|
||||
|
||||
\param[in] limit the limit cone
|
||||
|
||||
\see PxJointLimitCone getLimit()
|
||||
*/
|
||||
virtual void setLimitCone(const PxJointLimitCone& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief get the swing angle of the joint from the Y axis
|
||||
*/
|
||||
virtual PxReal getSwingYAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief get the swing angle of the joint from the Z axis
|
||||
*/
|
||||
virtual PxReal getSwingZAngle() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the flags specific to the Spherical Joint.
|
||||
|
||||
<b>Default</b> PxSphericalJointFlags(0)
|
||||
|
||||
\param[in] flags The joint flags.
|
||||
|
||||
\see PxSphericalJointFlag setFlag() getFlags()
|
||||
*/
|
||||
virtual void setSphericalJointFlags(PxSphericalJointFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Set a single flag specific to a Spherical Joint to true or false.
|
||||
|
||||
\param[in] flag The flag to set or clear.
|
||||
\param[in] value the value to which to set the flag
|
||||
|
||||
\see PxSphericalJointFlag, getFlags() setFlags()
|
||||
*/
|
||||
virtual void setSphericalJointFlag(PxSphericalJointFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the flags specific to the Spherical Joint.
|
||||
|
||||
\return the joint flags
|
||||
|
||||
\see PxSphericalJoint::flags, PxSphericalJointFlag setFlag() setFlags()
|
||||
*/
|
||||
virtual PxSphericalJointFlags getSphericalJointFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of PxSphericalJoint, used for serialization
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxSphericalJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
//serialization
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_INLINE PxSphericalJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor
|
||||
*/
|
||||
PX_INLINE PxSphericalJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxSphericalJoint", PxJoint); }
|
||||
|
||||
//~serialization
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
56
engine/third_party/physx/include/extensions/PxStringTableExt.h
vendored
Normal file
56
engine/third_party/physx/include/extensions/PxStringTableExt.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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-2025 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_STRING_TABLE_EXT_H
|
||||
#define PX_STRING_TABLE_EXT_H
|
||||
|
||||
#include "foundation/PxAllocatorCallback.h"
|
||||
#include "common/PxStringTable.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief a factory class for creating PxStringTable with a specific allocator.
|
||||
|
||||
\see PxStringTable
|
||||
*/
|
||||
|
||||
class PxStringTableExt
|
||||
{
|
||||
public:
|
||||
static PxStringTable& createStringTable( physx::PxAllocatorCallback& inAllocator );
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
221
engine/third_party/physx/include/extensions/PxTetMakerExt.h
vendored
Normal file
221
engine/third_party/physx/include/extensions/PxTetMakerExt.h
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
// 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-2025 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_TETMAKER_EXT_H
|
||||
#define PX_TETMAKER_EXT_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "PxTriangleMeshAnalysisResult.h"
|
||||
#include "PxTetrahedronMeshAnalysisResult.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxTriangleMesh;
|
||||
class PxTetrahedronMeshDesc;
|
||||
class PxDeformableVolumeSimulationDataDesc;
|
||||
struct PxTetMakerData;
|
||||
class PxSimpleTriangleMesh;
|
||||
|
||||
/**
|
||||
\brief Provides functionality to create a tetrahedral mesh from a triangle mesh.
|
||||
*/
|
||||
class PxTetMaker
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Create conforming tetrahedron mesh using TetMaker
|
||||
|
||||
\param[in] triangleMesh The description of the triangle mesh including vertices and indices
|
||||
\param[out] outVertices The vertices to store the conforming tetrahedral mesh
|
||||
\param[out] outTetIndices The indices to store the conforming tetrahedral mesh
|
||||
\param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies
|
||||
\param[in] volumeThreshold Tetrahedra with a volume smaller than the specified threshold will be removed from the mesh
|
||||
\return True if success
|
||||
*/
|
||||
static bool createConformingTetrahedronMesh(const PxSimpleTriangleMesh& triangleMesh, physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices,
|
||||
const bool validate = true, PxReal volumeThreshold = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Create voxel-based tetrahedron mesh using TetMaker
|
||||
|
||||
\param[in] tetMesh The description of the tetrahedral mesh including vertices and indices
|
||||
\param[in] numVoxelsAlongLongestBoundingBoxAxis The number of voxels along the longest bounding box axis
|
||||
\param[out] outVertices The vertices to store the voxel-based tetrahedral mesh
|
||||
\param[out] outTetIndices The indices to store the voxel-based tetrahedral mesh
|
||||
\param[out] inputPointToOutputTetIndex Buffer with the size of nbTetVerts that contains the tetrahedron index containing the input point with the same index
|
||||
\param[in] anchorNodeIndices Some input vertices may not be referenced by any tetrahedron. They can be mapped to another input vertex that is used by a tetrahedron to support embedding of additional points.
|
||||
\param[in] numTetsPerVoxel The number of tetrahedra used to fill a voxel. Only a value of 5 or 6 is supported. 5 is recommended because it mostly avoids mesh anisotropy.
|
||||
\return True if success
|
||||
*/
|
||||
static bool createVoxelTetrahedronMesh(const PxTetrahedronMeshDesc& tetMesh, const PxU32 numVoxelsAlongLongestBoundingBoxAxis,
|
||||
physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices, PxI32* inputPointToOutputTetIndex = NULL, const PxU32* anchorNodeIndices = NULL, PxU32 numTetsPerVoxel = 5);
|
||||
|
||||
/**
|
||||
\brief Create voxel-based tetrahedron mesh using TetMaker
|
||||
|
||||
\param[in] tetMesh The description of the tetrahedral mesh including vertices and indices
|
||||
\param[in] voxelEdgeLength The edge length of a voxel.Can be adjusted slightly such that a multiple of it matches the input points' bounding box size
|
||||
\param[out] outVertices The vertices to store the voxel-based tetrahedral mesh
|
||||
\param[out] outTetIndices The indices to store the voxel-based tetrahedral mesh
|
||||
\param[out] inputPointToOutputTetIndex Buffer with the size of nbTetVerts that contains the tetrahedron index containing the input point with the same index
|
||||
\param[in] anchorNodeIndices Some input vertices may not be referenced by any tetrahedron. They can be mapped to another input vertex that is used by a tetrahedron to support embedding of additional points.
|
||||
\param[in] numTetsPerVoxel The number of tetrahedra used to fill a voxel. Only a value of 5 or 6 is supported. 5 is recommended because it mostly avoids mesh anisotropy.
|
||||
\return True if success
|
||||
*/
|
||||
static bool createVoxelTetrahedronMeshFromEdgeLength(const PxTetrahedronMeshDesc& tetMesh, const PxReal voxelEdgeLength,
|
||||
physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices, PxI32* inputPointToOutputTetIndex = NULL, const PxU32* anchorNodeIndices = NULL, PxU32 numTetsPerVoxel = 5);
|
||||
|
||||
/**
|
||||
\brief Analyzes the triangle mesh to get a report about deficiencies. Some deficiencies can be handled by the tetmesher, others cannot.
|
||||
|
||||
\param[in] triangleMesh The description of the triangle mesh including vertices and indices
|
||||
\param[in] minVolumeThreshold Minimum volume the mesh must have such that no volume warning is generated
|
||||
\param[in] minTriangleAngleRadians Minimum angle allowed for triangles such that no angle warning is generated
|
||||
\return Flags that describe the triangle mesh's deficiencies
|
||||
*/
|
||||
static PxTriangleMeshAnalysisResults validateTriangleMesh(const PxSimpleTriangleMesh& triangleMesh, const PxReal minVolumeThreshold = 1e-6f, const PxReal minTriangleAngleRadians = 10.0f*3.1415926535898f / 180.0f);
|
||||
|
||||
/**
|
||||
\brief Analyzes the tetrahedron mesh to get a report about deficiencies. Some deficiencies can be handled by the deformable volume cooker, others cannot.
|
||||
|
||||
\param[in] points The mesh's points
|
||||
\param[in] tetrahedra The mesh's tetrahedra (index buffer)
|
||||
\param[in] minTetVolumeThreshold Minimum volume every tetrahedron in the mesh must have such that no volume warning is generated
|
||||
\return Flags that describe the tetrahedron mesh's deficiencies
|
||||
*/
|
||||
static PxTetrahedronMeshAnalysisResults validateTetrahedronMesh(const PxBoundedData& points, const PxBoundedData& tetrahedra, const PxReal minTetVolumeThreshold = 1e-8f);
|
||||
|
||||
/**
|
||||
\brief Simplifies (decimates) a triangle mesh using quadric simplification.
|
||||
|
||||
\param[in] inputVertices The vertices of the input triangle mesh
|
||||
\param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[in] targetTriangleCount Desired number of triangles in the output mesh
|
||||
\param[in] maximalEdgeLength Edges below this length will not be collapsed. A value of zero means there is no limit.
|
||||
\param[out] outputVertices The vertices of the output (decimated) triangle mesh
|
||||
\param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[out] vertexMap Optional parameter which returns the mapping from input to output vertices. Note that multiple input vertices are typically collapsed into the same output vertex.
|
||||
\param[in] edgeLengthCostWeight Factor to scale influence of edge length when prioritizing edge collapses. Has no effect if set to zero.
|
||||
\param[in] flatnessDetectionThreshold Threshold used to detect edges in flat regions and to improve the placement of the collapsed point. If set to a large value it will have no effect.
|
||||
\param[in] projectSimplifiedPointsOnInputMeshSurface If set to true, the simplified points will lie exactly on the original surface.
|
||||
\param[out] outputVertexToInputTriangle Optional indices providing the triangle index per resulting vertex. Only available when projectSimplifiedPointsOnInputMeshSurface is set to true
|
||||
\param[in] removeDisconnectedPatches Enables the optional removal of disconnected triangles in the mesh. Only the largest connected set/patch will be kept
|
||||
*/
|
||||
static void simplifyTriangleMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, int targetTriangleCount, PxF32 maximalEdgeLength,
|
||||
PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices,
|
||||
PxArray<PxU32> *vertexMap = NULL, PxReal edgeLengthCostWeight = 0.1f, PxReal flatnessDetectionThreshold = 0.01f,
|
||||
bool projectSimplifiedPointsOnInputMeshSurface = false, PxArray<PxU32>* outputVertexToInputTriangle = NULL, bool removeDisconnectedPatches = false);
|
||||
|
||||
/**
|
||||
\brief Creates a new mesh from a given mesh. The input mesh is first voxelized. The new surface is created from the voxel surface and subsequent projection to the original mesh.
|
||||
|
||||
\param[in] inputVertices The vertices of the input triangle mesh
|
||||
\param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[in] gridResolution Size of the voxel grid (number of voxels along the longest dimension)
|
||||
\param[out] outputVertices The vertices of the output (decimated) triangle mesh
|
||||
\param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[out] vertexMap Optional parameter which returns a mapping from input to output vertices. Since the meshes are independent, the mapping returns an output vertex that is topologically close to the input vertex.
|
||||
*/
|
||||
static void remeshTriangleMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, PxU32 gridResolution,
|
||||
PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxArray<PxU32> *vertexMap = NULL);
|
||||
|
||||
/**
|
||||
\brief Creates a new mesh from a given mesh. The input mesh is first voxelized. The new surface is created from the voxel surface and subsequent projection to the original mesh.
|
||||
|
||||
\param[in] inputVertices The vertices of the input triangle mesh
|
||||
\param[in] nbVertices The number of vertices of the input triangle mesh
|
||||
\param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[in] nbIndices The number of indices of the input triangle mesh (equal to three times the number of triangles)
|
||||
\param[in] gridResolution Size of the voxel grid (number of voxels along the longest dimension)
|
||||
\param[out] outputVertices The vertices of the output (decimated) triangle mesh
|
||||
\param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[out] vertexMap Optional parameter which returns a mapping from input to output vertices. Since the meshes are independent, the mapping returns an output vertex that is topologically close to the input vertex.
|
||||
*/
|
||||
static void remeshTriangleMesh(const PxVec3* inputVertices, PxU32 nbVertices, const PxU32* inputIndices, PxU32 nbIndices, PxU32 gridResolution,
|
||||
PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxArray<PxU32> *vertexMap = NULL);
|
||||
|
||||
/**
|
||||
\brief Creates a tetrahedral mesh using an octree.
|
||||
|
||||
\param[in] inputVertices The vertices of the input triangle mesh
|
||||
\param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[in] useTreeNodes Using the nodes of the octree as tetrahedral vertices
|
||||
\param[out] outputVertices The vertices of the output tetrahedral mesh
|
||||
\param[out] outputIndices The indices of the output tetrahedral mesh of the form (id0, id1, id2, id3), (id0, id1, id2, id3), ..
|
||||
\param[in] volumeThreshold Tetrahedra with a volume smaller than the specified threshold will be removed from the mesh
|
||||
*/
|
||||
static void createTreeBasedTetrahedralMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices,
|
||||
bool useTreeNodes, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxReal volumeThreshold = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh
|
||||
|
||||
\param[in] inputVertices The vertices of the input triangle mesh
|
||||
\param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[out] outputVertices The vertices of the output tetrahedral mesh
|
||||
\param[out] outputIndices The indices of the output tetrahedral mesh of the form (id0, id1, id2, id3), (id0, id1, id2, id3), ..
|
||||
\param[in] resolution The grid spacing is computed as the diagonal of the bounding box of the input mesh divided by the resolution.
|
||||
\param[in] numRelaxationIterations Number of iterations to pull the tetrahedral mesh towards the input mesh
|
||||
\param[in] relMinTetVolume Constrains the volumes of the tetrahedra to stay abobe relMinTetvolume times the tetrahedron's rest volume.
|
||||
*/
|
||||
static void createRelaxedVoxelTetrahedralMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices,
|
||||
PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices,
|
||||
PxI32 resolution, PxI32 numRelaxationIterations = 5, PxF32 relMinTetVolume = 0.05f);
|
||||
|
||||
/**
|
||||
\brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh
|
||||
|
||||
\param[in] triangles The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), ..
|
||||
\param[in] numTriangles The number of triangles
|
||||
\param[out] islandIndexPerTriangle Every triangle gets an island index assigned. Triangles with the same island index belong to the same patch of connected triangles.
|
||||
*/
|
||||
static void detectTriangleIslands(const PxI32* triangles, PxU32 numTriangles, PxArray<PxU32>& islandIndexPerTriangle);
|
||||
|
||||
/**
|
||||
\brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh
|
||||
|
||||
\param[in] islandIndexPerTriangle An island marker per triangles. All triangles with the same marker belong to an island. Can becomputed using the method detectTriangleIslands.
|
||||
\param[in] numTriangles The number of triangles
|
||||
\return The marker value of the island that contains the most triangles
|
||||
*/
|
||||
static PxU32 findLargestIslandId(const PxU32* islandIndexPerTriangle, PxU32 numTriangles);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
61
engine/third_party/physx/include/extensions/PxTetrahedronMeshAnalysisResult.h
vendored
Normal file
61
engine/third_party/physx/include/extensions/PxTetrahedronMeshAnalysisResult.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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-2025 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef PX_TETRAHEDRON_MESH_ANALYSIS_RESULT_H
|
||||
#define PX_TETRAHEDRON_MESH_ANALYSIS_RESULT_H
|
||||
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief These flags indicate what kind of deficiencies a tetrahedron mesh has and describe if the mesh is considered ok, problematic or invalid for deformable volume cooking
|
||||
*/
|
||||
class PxTetrahedronMeshAnalysisResult
|
||||
{
|
||||
public:
|
||||
enum Enum
|
||||
{
|
||||
eVALID = 0,
|
||||
eDEGENERATE_TETRAHEDRON = (1 << 0), //!< At least one tetrahedron has zero or negative volume. This can happen when the input triangle mesh contains triangles that are very elongated, e. g. one edge is a lot shorther than the other two.
|
||||
|
||||
eMESH_IS_PROBLEMATIC = (1 << 1), //!< flag is set if the mesh is categorized as problematic
|
||||
eMESH_IS_INVALID = (1 << 2) //!< flag is set if the mesh is categorized as invalid
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxTetrahedronMeshAnalysisResult::Enum, PxU32> PxTetrahedronMeshAnalysisResults;
|
||||
PX_FLAGS_OPERATORS(PxTetrahedronMeshAnalysisResult::Enum, PxU32)
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
108
engine/third_party/physx/include/extensions/PxTetrahedronMeshExt.h
vendored
Normal file
108
engine/third_party/physx/include/extensions/PxTetrahedronMeshExt.h
vendored
Normal file
@@ -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-2025 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_TETRAHEDRON_MESH_EXT_H
|
||||
#define PX_TETRAHEDRON_MESH_EXT_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
class PxTetrahedronMesh;
|
||||
|
||||
/**
|
||||
\brief utility functions for use with PxTetrahedronMesh and subclasses
|
||||
*/
|
||||
class PxTetrahedronMeshExt
|
||||
{
|
||||
public:
|
||||
/** Returns the index of the tetrahedron that contains a point
|
||||
|
||||
\param[in] mesh The tetmesh
|
||||
\param[in] point The point to find the enclosing tetrahedron for
|
||||
\param[in] bary The barycentric coordinates of the point inside the enclosing tetrahedron
|
||||
\param[in] tolerance Tolerance value used classify points as inside if they lie exactly a tetrahedron's surface
|
||||
\return The index of the tetrahedron containing the point, -1 if not tetrahedron contains the opoint
|
||||
*/
|
||||
static PxI32 findTetrahedronContainingPoint(const PxTetrahedronMesh* mesh, const PxVec3& point, PxVec4& bary, PxReal tolerance = 1e-6f);
|
||||
|
||||
/** Returns the index of the tetrahedron closest to a point
|
||||
|
||||
\param[in] mesh The tetmesh
|
||||
\param[in] point The point to find the closest tetrahedron for
|
||||
\param[out] bary The barycentric coordinates of the point in the tetrahedron
|
||||
\return The index of the tetrahedron closest to the point
|
||||
*/
|
||||
static PxI32 findTetrahedronClosestToPoint(const PxTetrahedronMesh* mesh, const PxVec3& point, PxVec4& bary);
|
||||
|
||||
/** Associates points with closest tetrahedra from input tetrahedral mesh. If the tetmesh does not have any tetrahedra
|
||||
or points, a warning will be generated and the result arrays will be empty, even if there are query points passed into the method.
|
||||
|
||||
\param[in] tetMeshVertices The tetrahedral mesh vertices
|
||||
\param[in] tetMeshIndices The tetraheral mesh indices
|
||||
\param[in] pointsToEmbed The points for which the embedding should be created
|
||||
\param[in] barycentricCoordinates The output barycentric coordinates for each input point relative to its closest tetrahedron
|
||||
\param[in] tetLinks The output indices of the closest tetrahedron for each input point
|
||||
*/
|
||||
static void createPointsToTetrahedronMap(const PxArray<PxVec3>& tetMeshVertices, const PxArray<PxU32>& tetMeshIndices, const PxArray<PxVec3>& pointsToEmbed, PxArray<PxVec4>& barycentricCoordinates, PxArray<PxU32>& tetLinks);
|
||||
|
||||
/** Extracts the surface triangles of a tetmesh
|
||||
|
||||
The extracted triangle's vertex indices point to the vertex buffer of the tetmesh.
|
||||
|
||||
\param[in] tetrahedra The tetrahedra indices
|
||||
\param[in] numTetrahedra The number of tetrahedra
|
||||
\param[in] sixteenBitIndices If set to true, the tetrahedra indices are read as 16bit integers, otherwise 32bit integers are used
|
||||
\param[in] surfaceTriangles The resulting surface triangles
|
||||
\param[in] surfaceTriangleToTet Optional array to get the index of a tetrahedron that is adjacent to the surface triangle with the corresponding index
|
||||
\param[in] flipTriangleOrientation Reverses the orientation of the ouput triangles
|
||||
*/
|
||||
static void extractTetMeshSurface(const void* tetrahedra, PxU32 numTetrahedra, bool sixteenBitIndices, PxArray<PxU32>& surfaceTriangles, PxArray<PxU32>* surfaceTriangleToTet = NULL, bool flipTriangleOrientation = false);
|
||||
|
||||
/** Extracts the surface triangles of a tetmesh
|
||||
|
||||
The extracted triangle's vertex indices point to the vertex buffer of the tetmesh.
|
||||
|
||||
\param[in] mesh The mesh from which the surface shall be computed
|
||||
\param[in] surfaceTriangles The resulting surface triangles
|
||||
\param[in] surfaceTriangleToTet Optional array to get the index of a tetrahedron that is adjacent to the surface triangle with the corresponding index
|
||||
\param[in] flipTriangleOrientation Reverses the orientation of the ouput triangles
|
||||
*/
|
||||
static void extractTetMeshSurface(const PxTetrahedronMesh* mesh, PxArray<PxU32>& surfaceTriangles, PxArray<PxU32>* surfaceTriangleToTet = NULL, bool flipTriangleOrientation = false);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
70
engine/third_party/physx/include/extensions/PxTriangleMeshAnalysisResult.h
vendored
Normal file
70
engine/third_party/physx/include/extensions/PxTriangleMeshAnalysisResult.h
vendored
Normal file
@@ -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-2025 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef PX_TRIANGLE_MESH_ANALYSIS_RESULT_H
|
||||
#define PX_TRIANGLE_MESH_ANALYSIS_RESULT_H
|
||||
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief These flags indicate what kind of deficiencies a triangle mesh has and describe if the mesh is considered ok, problematic or invalid for tetmeshing
|
||||
*/
|
||||
class PxTriangleMeshAnalysisResult
|
||||
{
|
||||
public:
|
||||
enum Enum
|
||||
{
|
||||
eVALID = 0,
|
||||
eZERO_VOLUME = (1 << 0), //!< invalid: Flat mesh without meaningful amount of volume - cannot be meshed since a tetmesh is volumetric
|
||||
eOPEN_BOUNDARIES = (1 << 1), //!< problematic: Open boundary means that the mesh is not watertight and that there are holes. The mesher can fill holes but the surface might have an unexpected shape where the hole was.
|
||||
eSELF_INTERSECTIONS = (1 << 2), //!< problematic: The surface of the resulting mesh won't match exactly at locations of self-intersections. The tetmesh might be connected at self-intersections even if the input triangle mesh is not
|
||||
eINCONSISTENT_TRIANGLE_ORIENTATION = (1 << 3), //!< invalid: It is not possible to distinguish what is inside and outside of the mesh. If there are no self-intersections and not edges shared by more than two triangles, a call to makeTriOrientationConsistent can fix this. Without fixing it, the output from the tetmesher will be incorrect
|
||||
eCONTAINS_ACUTE_ANGLED_TRIANGLES = (1 << 4), //!< problematic: An ideal mesh for a volume deformable has triangles with similar angles and evenly distributed vertices. Acute angles can be handled but might lead to a poor quality tetmesh.
|
||||
eEDGE_SHARED_BY_MORE_THAN_TWO_TRIANGLES = (1 << 5), //!< problematic: Border case of a self-intersecting mesh. The tetmesh might not match the surace exactly near such edges.
|
||||
eCONTAINS_DUPLICATE_POINTS = (1 << 6), //!< ok: Duplicate points can be handled by the mesher without problems. The resulting tetmesh will only make use of first unique point that is found, duplicate points will get mapped to that unique point in the tetmesh. Therefore the tetmesh can contain points that are not accessed by a tet.
|
||||
eCONTAINS_INVALID_POINTS = (1 << 7), //!< invalid: Points contain NAN, infinity or similar values that will lead to an invalid mesh
|
||||
eREQUIRES_32BIT_INDEX_BUFFER = (1 << 8), //!< invalid: Mesh contains more indices than a 16bit index buffer can address
|
||||
eTRIANGLE_INDEX_OUT_OF_RANGE = (1 << 9), //!< invalid: A mesh triangle index is negative or lager than the size of the vertex buffer
|
||||
|
||||
eMESH_IS_PROBLEMATIC = (1 << 10), //!< flag is set if the mesh is categorized as problematic
|
||||
eMESH_IS_INVALID = (1 << 11) //!< flag is set if the mesh is categorized as invalid
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxTriangleMeshAnalysisResult::Enum, PxU32> PxTriangleMeshAnalysisResults;
|
||||
PX_FLAGS_OPERATORS(PxTriangleMeshAnalysisResult::Enum, PxU32)
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
194
engine/third_party/physx/include/extensions/PxTriangleMeshExt.h
vendored
Normal file
194
engine/third_party/physx/include/extensions/PxTriangleMeshExt.h
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
// 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-2025 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_TRIANGLE_MESH_EXT_H
|
||||
#define PX_TRIANGLE_MESH_EXT_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGeometry;
|
||||
class PxTriangleMesh;
|
||||
class PxTriangleMeshGeometry;
|
||||
class PxHeightFieldGeometry;
|
||||
|
||||
/**
|
||||
\brief Utility class to find mesh triangles touched by a specified geometry object.
|
||||
|
||||
This class is a helper calling PxMeshQuery::findOverlapTriangleMesh or PxMeshQuery::findOverlapHeightField under the hood,
|
||||
while taking care of necessary memory management issues.
|
||||
|
||||
PxMeshQuery::findOverlapTriangleMesh and PxMeshQuery::findOverlapHeightField are the "raw" functions operating on user-provided fixed-size
|
||||
buffers. These functions abort with an error code in case of buffer overflow. PxMeshOverlapUtil is a convenient helper function checking
|
||||
this error code, and resizing buffers appropriately, until the desired call succeeds.
|
||||
|
||||
Returned triangle indices are stored within the class, and can be used with PxMeshQuery::getTriangle() to retrieve the triangle properties.
|
||||
*/
|
||||
class PxMeshOverlapUtil
|
||||
{
|
||||
public:
|
||||
PxMeshOverlapUtil();
|
||||
~PxMeshOverlapUtil();
|
||||
/**
|
||||
\brief Find the mesh triangles which touch the specified geometry object.
|
||||
|
||||
\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
|
||||
\return Number of overlaps found. Triangle indices can then be accessed through the #getResults() function.
|
||||
|
||||
\see PxGeometry PxTransform PxTriangleMeshGeometry PxMeshQuery::findOverlapTriangleMesh
|
||||
*/
|
||||
PxU32 findOverlap(const PxGeometry& geom, const PxTransform& geomPose, const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose);
|
||||
|
||||
/**
|
||||
\brief Find the height field triangles which touch the specified geometry object.
|
||||
|
||||
\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
|
||||
\return Number of overlaps found. Triangle indices can then be accessed through the #getResults() function.
|
||||
|
||||
\see PxGeometry PxTransform PxHeightFieldGeometry PxMeshQuery::findOverlapHeightField
|
||||
*/
|
||||
PxU32 findOverlap(const PxGeometry& geom, const PxTransform& geomPose, const PxHeightFieldGeometry& hfGeom, const PxTransform& hfPose);
|
||||
|
||||
/**
|
||||
\brief Retrieves array of triangle indices after a findOverlap call.
|
||||
\return Indices of touched triangles
|
||||
*/
|
||||
PX_FORCE_INLINE const PxU32* getResults() const { return mResultsMemory; }
|
||||
|
||||
/**
|
||||
\brief Retrieves number of triangle indices after a findOverlap call.
|
||||
\return Number of touched triangles
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbResults() const { return mNbResults; }
|
||||
|
||||
private:
|
||||
PxU32* mResultsMemory;
|
||||
PxU32 mResults[256];
|
||||
PxU32 mNbResults;
|
||||
PxU32 mMaxNbResults;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Computes an approximate minimum translational distance (MTD) between a geometry object and a mesh.
|
||||
|
||||
This iterative function computes an approximate vector that can be used to depenetrate a geom object
|
||||
from a triangle mesh. Returned depenetration vector should be applied to 'geom', to get out of the mesh.
|
||||
|
||||
The function works best when the amount of overlap between the geom object and the mesh is small. If the
|
||||
geom object's center goes inside the mesh, backface culling usually kicks in, no overlap is detected,
|
||||
and the function does not compute an MTD vector.
|
||||
|
||||
The function early exits if no overlap is detected after a depenetration attempt. This means that if
|
||||
maxIter = N, the code will attempt at most N iterations but it might exit earlier if depenetration has
|
||||
been successful. Usually N = 4 gives good results.
|
||||
|
||||
\param[out] direction Computed MTD unit direction
|
||||
\param[out] depth Penetration depth. Always positive or zero.
|
||||
\param[in] geom The geometry object
|
||||
\param[in] geomPose Pose for the geometry object
|
||||
\param[in] meshGeom The mesh geometry
|
||||
\param[in] meshPose Pose for the mesh
|
||||
\param[in] maxIter Max number of iterations before returning.
|
||||
\param[out] usedIter Number of depenetrations attempts performed during the call. Will not be returned if the pointer is NULL.
|
||||
|
||||
\return True if the MTD has successfully been computed, i.e. if objects do overlap.
|
||||
|
||||
\see PxGeometry PxTransform PxTriangleMeshGeometry
|
||||
*/
|
||||
bool PxComputeTriangleMeshPenetration(PxVec3& direction,
|
||||
PxReal& depth,
|
||||
const PxGeometry& geom,
|
||||
const PxTransform& geomPose,
|
||||
const PxTriangleMeshGeometry& meshGeom,
|
||||
const PxTransform& meshPose,
|
||||
PxU32 maxIter,
|
||||
PxU32* usedIter = NULL);
|
||||
|
||||
/**
|
||||
\brief Computes an approximate minimum translational distance (MTD) between a geometry object and a heightfield.
|
||||
|
||||
This iterative function computes an approximate vector that can be used to depenetrate a geom object
|
||||
from a heightfield. Returned depenetration vector should be applied to 'geom', to get out of the heightfield.
|
||||
|
||||
The function works best when the amount of overlap between the geom object and the mesh is small. If the
|
||||
geom object's center goes inside the heightfield, backface culling usually kicks in, no overlap is detected,
|
||||
and the function does not compute an MTD vector.
|
||||
|
||||
The function early exits if no overlap is detected after a depenetration attempt. This means that if
|
||||
maxIter = N, the code will attempt at most N iterations but it might exit earlier if depenetration has
|
||||
been successful. Usually N = 4 gives good results.
|
||||
|
||||
\param[out] direction Computed MTD unit direction
|
||||
\param[out] depth Penetration depth. Always positive or zero.
|
||||
\param[in] geom The geometry object
|
||||
\param[in] geomPose Pose for the geometry object
|
||||
\param[in] heightFieldGeom The heightfield geometry
|
||||
\param[in] heightFieldPose Pose for the heightfield
|
||||
\param[in] maxIter Max number of iterations before returning.
|
||||
\param[out] usedIter Number of depenetrations attempts performed during the call. Will not be returned if the pointer is NULL.
|
||||
|
||||
\return True if the MTD has successfully been computed, i.e. if objects do overlap.
|
||||
|
||||
\see PxGeometry PxTransform PxHeightFieldGeometry
|
||||
*/
|
||||
bool PxComputeHeightFieldPenetration(PxVec3& direction,
|
||||
PxReal& depth,
|
||||
const PxGeometry& geom,
|
||||
const PxTransform& geomPose,
|
||||
const PxHeightFieldGeometry& heightFieldGeom,
|
||||
const PxTransform& heightFieldPose,
|
||||
PxU32 maxIter,
|
||||
PxU32* usedIter = NULL);
|
||||
|
||||
/**
|
||||
\brief Extracts an isosurface from the SDF of a mesh if it the SDF is available.
|
||||
|
||||
\param[in] triangleMesh The triangle mesh
|
||||
\param[out] isosurfaceVertices The vertices of the extracted isosurface
|
||||
\param[out] isosurfaceTriangleIndices The triangles of the extracted isosurface
|
||||
*/
|
||||
bool PxExtractIsosurfaceFromSDF(const PxTriangleMesh& triangleMesh, PxArray<PxVec3>& isosurfaceVertices, PxArray<PxU32>& isosurfaceTriangleIndices);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user