feat(physics): wire physx sdk into build
This commit is contained in:
282
engine/third_party/physx/include/geometry/PxBVH.h
vendored
Normal file
282
engine/third_party/physx/include/geometry/PxBVH.h
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
// 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_BVH_H
|
||||
#define PX_BVH_H
|
||||
|
||||
#include "common/PxBase.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "geometry/PxGeometryQueryFlags.h"
|
||||
#include "geometry/PxReportCallback.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGeometry;
|
||||
class PxPlane;
|
||||
|
||||
/**
|
||||
\brief Class representing a bounding volume hierarchy.
|
||||
|
||||
PxBVH can be provided to PxScene::addActor. In this case the scene query
|
||||
pruning structure inside PhysX SDK will store/update one bound per actor.
|
||||
The scene queries against such an actor will query actor bounds and then
|
||||
make a local space query against the provided BVH, which is in actor's
|
||||
local space.
|
||||
|
||||
PxBVH can also be used as a standalone data-structure for arbitrary
|
||||
purposes, unrelated to PxScene / PxActor.
|
||||
|
||||
\see PxScene::addActor
|
||||
*/
|
||||
class PxBVH : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
struct RaycastCallback
|
||||
{
|
||||
RaycastCallback() {}
|
||||
virtual ~RaycastCallback() {}
|
||||
|
||||
// Reports one raycast or sweep hit.
|
||||
// boundsIndex [in] Index of touched bounds
|
||||
// distance [in/out] Impact distance. Shrinks the ray if written out.
|
||||
// return false to abort the query
|
||||
virtual bool reportHit(PxU32 boundsIndex, PxReal& distance) = 0;
|
||||
};
|
||||
|
||||
struct OverlapCallback
|
||||
{
|
||||
OverlapCallback() {}
|
||||
virtual ~OverlapCallback() {}
|
||||
|
||||
// Reports one overlap hit.
|
||||
// boundsIndex [in] Index of touched bounds
|
||||
// return false to abort the query
|
||||
virtual bool reportHit(PxU32 boundsIndex) = 0;
|
||||
};
|
||||
|
||||
struct TraversalCallback
|
||||
{
|
||||
TraversalCallback() {}
|
||||
virtual ~TraversalCallback() {}
|
||||
|
||||
// Reports one visited node.
|
||||
// bounds [in] node bounds
|
||||
// return true to continue traversing this branch
|
||||
virtual bool visitNode(const PxBounds3& bounds) = 0;
|
||||
|
||||
// Reports one validated leaf node. Called on leaf nodes after visitNode returns true on them.
|
||||
// nbPrims [in] number of primitives in the node
|
||||
// prims [in] primitives in the node (nbPrims entries)
|
||||
// return false to abort the query
|
||||
virtual bool reportLeaf(PxU32 nbPrims, const PxU32* prims) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Raycast test against a BVH.
|
||||
|
||||
\param[in] origin The origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] maxDist Maximum ray length, has to be in the [0, inf) range
|
||||
\param[in] cb Raycast callback, called once per hit
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return false if query has been aborted
|
||||
*/
|
||||
virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, float maxDist, RaycastCallback& cb, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sweep test against a BVH.
|
||||
|
||||
\param[in] geom The query volume
|
||||
\param[in] pose The pose of the query volume
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] maxDist Maximum sweep length, has to be in the [0, inf) range
|
||||
\param[in] cb Raycast callback, called once per hit
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return false if query has been aborted
|
||||
*/
|
||||
virtual bool sweep(const PxGeometry& geom, const PxTransform& pose, const PxVec3& unitDir, float maxDist, RaycastCallback& cb, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Overlap test against a BVH.
|
||||
|
||||
\param[in] geom The query volume
|
||||
\param[in] pose The pose of the query volume
|
||||
\param[in] cb Overlap callback, called once per hit
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return false if query has been aborted
|
||||
*/
|
||||
virtual bool overlap(const PxGeometry& geom, const PxTransform& pose, OverlapCallback& cb, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Frustum culling test against a BVH.
|
||||
|
||||
This is similar in spirit to an overlap query using a convex object around the frustum.
|
||||
However this specialized query has better performance, and can support more than the 6 planes
|
||||
of a frustum, which can be useful in portal-based engines.
|
||||
|
||||
On the other hand this test only returns a conservative number of bounds, i.e. some of the returned
|
||||
bounds may actually be outside the frustum volume, close to it but not touching it. This is usually
|
||||
an ok performance trade-off when the function is used for view-frustum culling.
|
||||
|
||||
\param[in] nbPlanes Number of planes. Only 32 planes max are supported.
|
||||
\param[in] planes Array of planes, should be in the same space as the BVH.
|
||||
\param[in] cb Overlap callback, called once per visible object
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return false if query has been aborted
|
||||
*/
|
||||
virtual bool cull(PxU32 nbPlanes, const PxPlane* planes, OverlapCallback& cb, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of bounds in the BVH.
|
||||
|
||||
You can use #getBounds() to retrieve the bounds.
|
||||
|
||||
\note These are the user-defined bounds passed to the BVH builder, not the internal bounds around each BVH node.
|
||||
|
||||
\return Number of bounds in the BVH.
|
||||
|
||||
\see getBounds() getBoundsForModification()
|
||||
*/
|
||||
virtual PxU32 getNbBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the read-only bounds in the BVH.
|
||||
|
||||
\note These are the user-defined bounds passed to the BVH builder, not the internal bounds around each BVH node.
|
||||
|
||||
\see PxBounds3 getNbBounds() getBoundsForModification()
|
||||
*/
|
||||
virtual const PxBounds3* getBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the bounds in the BVH.
|
||||
|
||||
These bounds can be modified. Call refit() after modifications are done.
|
||||
|
||||
\note These are the user-defined bounds passed to the BVH builder, not the internal bounds around each BVH node.
|
||||
|
||||
\see PxBounds3 getNbBounds() getBounds() refit() updateBounds() partialRefit()
|
||||
*/
|
||||
PX_FORCE_INLINE PxBounds3* getBoundsForModification()
|
||||
{
|
||||
return const_cast<PxBounds3*>(getBounds());
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Refit the BVH.
|
||||
|
||||
This function "refits" the tree, i.e. takes the new (leaf) bounding boxes into account and
|
||||
recomputes all the BVH bounds accordingly. This is an O(n) operation with n = number of bounds in the BVH.
|
||||
|
||||
This works best with minor bounds modifications, i.e. when the bounds remain close to their initial values.
|
||||
With large modifications the tree quality degrades more and more, and subsequent query performance suffers.
|
||||
It might be a better strategy to create a brand new BVH if bounds change drastically.
|
||||
|
||||
This function refits the whole tree after an arbitrary number of bounds have potentially been modified by
|
||||
users (via getBoundsForModification()). If you only have a small number of bounds to update, it might be
|
||||
more efficient to use setBounds() and partialRefit() instead.
|
||||
|
||||
\see getNbBounds() getBoundsForModification() updateBounds() partialRefit()
|
||||
*/
|
||||
virtual void refit() = 0;
|
||||
|
||||
/**
|
||||
\brief Update single bounds.
|
||||
|
||||
This is an alternative to getBoundsForModification() / refit(). If you only have a small set of bounds to
|
||||
update, it can be inefficient to call the refit() function, because it refits the whole BVH.
|
||||
|
||||
Instead, one can update individual bounds with this updateBounds() function. It sets the new bounds and
|
||||
marks the corresponding BVH nodes for partial refit. Once all the individual bounds have been updated,
|
||||
call partialRefit() to only refit the subset of marked nodes.
|
||||
|
||||
\param[in] boundsIndex Index of updated bounds. Valid range is between 0 and getNbBounds().
|
||||
\param[in] newBounds Updated bounds.
|
||||
|
||||
\return true if success
|
||||
|
||||
\see getNbBounds() getBoundsForModification() refit() partialRefit()
|
||||
*/
|
||||
virtual bool updateBounds(PxU32 boundsIndex, const PxBounds3& newBounds) = 0;
|
||||
|
||||
/**
|
||||
\brief Refits subset of marked nodes.
|
||||
|
||||
This is an alternative to the refit() function, to be called after updateBounds() calls.
|
||||
See updateBounds() for details.
|
||||
|
||||
\see getNbBounds() getBoundsForModification() refit() updateBounds()
|
||||
*/
|
||||
virtual void partialRefit() = 0;
|
||||
|
||||
/**
|
||||
\brief Generic BVH traversal function.
|
||||
|
||||
This can be used to implement custom BVH traversal functions if provided ones are not enough.
|
||||
In particular this can be used to visualize the tree's bounds.
|
||||
|
||||
\param[in] cb Traversal callback, called for each visited node
|
||||
\return false if query has been aborted
|
||||
*/
|
||||
virtual bool traverse(TraversalCallback& cb) const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE PX_FINAL { return "PxBVH"; }
|
||||
protected:
|
||||
PX_INLINE PxBVH(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxBVH(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
virtual ~PxBVH() {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxBVH", PxBase); }
|
||||
};
|
||||
|
||||
struct PxGeomIndexPair;
|
||||
|
||||
/**
|
||||
\brief BVH-vs-BVH overlap test
|
||||
|
||||
This function returns pairs of box indices that belong to both the first & second input bvhs.
|
||||
|
||||
\param[in] callback The callback object used to report results
|
||||
\param[in] bvh0 First bvh
|
||||
\param[in] bvh1 Second bvh
|
||||
\return true if an overlap has been detected
|
||||
|
||||
\see PxBVH PxReportCallback
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_COMMON_API bool PX_CALL_CONV PxFindOverlap(PxReportCallback<PxGeomIndexPair>& callback, const PxBVH& bvh0, const PxBVH& bvh1);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
58
engine/third_party/physx/include/geometry/PxBVHBuildStrategy.h
vendored
Normal file
58
engine/third_party/physx/include/geometry/PxBVHBuildStrategy.h
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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_BVH_BUILD_STRATEGY_H
|
||||
#define PX_BVH_BUILD_STRATEGY_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Desired build strategy for bounding-volume hierarchies
|
||||
*/
|
||||
struct PxBVHBuildStrategy
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eFAST = 0, //!< Fast build strategy. Fast build speed, good runtime performance in most cases. Recommended for runtime cooking.
|
||||
eDEFAULT = 1, //!< Default build strategy. Medium build speed, good runtime performance in all cases.
|
||||
eSAH = 2, //!< SAH build strategy. Slower builds, slightly improved runtime performance in some cases.
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
113
engine/third_party/physx/include/geometry/PxBoxGeometry.h
vendored
Normal file
113
engine/third_party/physx/include/geometry/PxBoxGeometry.h
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
// 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_BOX_GEOMETRY_H
|
||||
#define PX_BOX_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Class representing the geometry of a box.
|
||||
|
||||
The geometry of a box can be fully specified by its half extents. This is the half of its width, height, and depth.
|
||||
\note The scaling of the box is expected to be baked into these values, there is no additional scaling parameter.
|
||||
*/
|
||||
class PxBoxGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor to initialize half extents from scalar parameters.
|
||||
\param hx Initial half extents' x component.
|
||||
\param hy Initial half extents' y component.
|
||||
\param hz Initial half extents' z component.
|
||||
*/
|
||||
PX_INLINE PxBoxGeometry(PxReal hx=0.0f, PxReal hy=0.0f, PxReal hz=0.0f) : PxGeometry(PxGeometryType::eBOX), halfExtents(hx, hy, hz) {}
|
||||
|
||||
/**
|
||||
\brief Constructor to initialize half extents from vector parameter.
|
||||
\param halfExtents_ Initial half extents.
|
||||
*/
|
||||
PX_INLINE PxBoxGeometry(PxVec3 halfExtents_) : PxGeometry(PxGeometryType::eBOX), halfExtents(halfExtents_) {}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxBoxGeometry(const PxBoxGeometry& that) : PxGeometry(that), halfExtents(that.halfExtents) {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxBoxGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
halfExtents = that.halfExtents;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid
|
||||
|
||||
\note A valid box has a positive extent in each direction (halfExtents.x > 0, halfExtents.y > 0, halfExtents.z > 0).
|
||||
It is illegal to call PxPhysics::createShape with a box that has zero extent in any direction.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief Half of the width, height, and depth of the box.
|
||||
*/
|
||||
PxVec3 halfExtents;
|
||||
};
|
||||
|
||||
PX_INLINE bool PxBoxGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eBOX)
|
||||
return false;
|
||||
if(!halfExtents.isFinite())
|
||||
return false;
|
||||
if(halfExtents.x <= 0.0f || halfExtents.y <= 0.0f || halfExtents.z <= 0.0f)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
115
engine/third_party/physx/include/geometry/PxCapsuleGeometry.h
vendored
Normal file
115
engine/third_party/physx/include/geometry/PxCapsuleGeometry.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_CAPSULE_GEOMETRY_H
|
||||
#define PX_CAPSULE_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "foundation/PxFoundationConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Class representing the geometry of a capsule.
|
||||
|
||||
Capsules are shaped as the union of a cylinder of length 2 * halfHeight and with the
|
||||
given radius centered at the origin and extending along the x axis, and two hemispherical ends.
|
||||
\note The scaling of the capsule is expected to be baked into these values, there is no additional scaling parameter.
|
||||
|
||||
The function PxTransformFromSegment is a helper for generating an appropriate transform for the capsule from the capsule's interior line segment.
|
||||
|
||||
\see PxTransformFromSegment
|
||||
*/
|
||||
class PxCapsuleGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor, initializes to a capsule with passed radius and half height.
|
||||
*/
|
||||
PX_INLINE PxCapsuleGeometry(PxReal radius_=0.0f, PxReal halfHeight_=0.0f) : PxGeometry(PxGeometryType::eCAPSULE), radius(radius_), halfHeight(halfHeight_) {}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxCapsuleGeometry(const PxCapsuleGeometry& that) : PxGeometry(that), radius(that.radius), halfHeight(that.halfHeight) {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxCapsuleGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
radius = that.radius;
|
||||
halfHeight = that.halfHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid.
|
||||
|
||||
\note A valid capsule has radius > 0, halfHeight >= 0.
|
||||
It is illegal to call PxPhysics::createShape with a capsule that has zero radius or height.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief The radius of the capsule.
|
||||
*/
|
||||
PxReal radius;
|
||||
|
||||
/**
|
||||
\brief half of the capsule's height, measured between the centers of the hemispherical ends.
|
||||
*/
|
||||
PxReal halfHeight;
|
||||
};
|
||||
|
||||
PX_INLINE bool PxCapsuleGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eCAPSULE)
|
||||
return false;
|
||||
if(!PxIsFinite(radius) || !PxIsFinite(halfHeight))
|
||||
return false;
|
||||
if(radius <= 0.0f || halfHeight < 0.0f)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
360
engine/third_party/physx/include/geometry/PxConvexCoreGeometry.h
vendored
Normal file
360
engine/third_party/physx/include/geometry/PxConvexCoreGeometry.h
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
// 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_CORE_GEOMETRY_H
|
||||
#define PX_CONVEX_CORE_GEOMETRY_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Pre-authored cores for convex core geometry
|
||||
*/
|
||||
class PxConvexCore
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Enumeration of core types for convex core geometries.
|
||||
|
||||
This enum defines the various cores that can be used as the basis
|
||||
for creating convex core geometries. Each type represents a different
|
||||
fundamental shape that can be extended with a margin to create more
|
||||
complex convex shapes.
|
||||
*/
|
||||
enum Type
|
||||
{
|
||||
ePOINT,
|
||||
eSEGMENT,
|
||||
eBOX,
|
||||
eELLIPSOID,
|
||||
eCYLINDER,
|
||||
eCONE,
|
||||
|
||||
eCOUNT
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Point core data
|
||||
|
||||
The point core has no additional data. The point is located
|
||||
at the origin of the geometry's local space
|
||||
*/
|
||||
struct Point
|
||||
{
|
||||
static const Type TYPE = ePOINT;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Segment core data
|
||||
|
||||
The segment is defined by its length and goes along the geometry's
|
||||
local space X axis, from -length/2 to length/2
|
||||
*/
|
||||
struct Segment
|
||||
{
|
||||
static const Type TYPE = eSEGMENT;
|
||||
|
||||
/// Segment length
|
||||
PxReal length;
|
||||
|
||||
PX_INLINE Segment() {}
|
||||
|
||||
/**
|
||||
\brief Constructs a SegmentCore with a specified length
|
||||
\param _length Segment length
|
||||
*/
|
||||
PX_INLINE Segment(PxReal _length) : length(_length) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Box core data
|
||||
|
||||
The box is defined by its extents, centered at the origin of the
|
||||
geometry's local space, and aligned with the local space's axes
|
||||
*/
|
||||
struct Box
|
||||
{
|
||||
static const Type TYPE = eBOX;
|
||||
|
||||
/// Box extents
|
||||
PxVec3 extents;
|
||||
|
||||
PX_INLINE Box() {}
|
||||
|
||||
/**
|
||||
\brief Constructs a BoxCore with specified extents
|
||||
\param eX Extent in the x direction
|
||||
\param eY Extent in the y direction
|
||||
\param eZ Extent in the z direction
|
||||
*/
|
||||
PX_INLINE Box(PxReal eX, PxReal eY, PxReal eZ) : extents(eX, eY, eZ) {}
|
||||
|
||||
/**
|
||||
\brief Constructs a BoxCore with specified extents
|
||||
\param _extents Vector containing extents in x, y, and z directions
|
||||
*/
|
||||
PX_INLINE Box(const PxVec3& _extents) : extents(_extents) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Ellipsoid core data
|
||||
|
||||
The ellipsoid is defined by its radii and is centered at the origin
|
||||
of the geometry's local space
|
||||
*/
|
||||
struct Ellipsoid
|
||||
{
|
||||
static const Type TYPE = eELLIPSOID;
|
||||
|
||||
/// Ellipsoid radii
|
||||
PxVec3 radii;
|
||||
|
||||
PX_INLINE Ellipsoid() {}
|
||||
|
||||
/**
|
||||
\brief Constructs an EllipsoidCore with specified radii
|
||||
\param rX Radius in the x direction
|
||||
\param rY Radius in the y direction
|
||||
\param rZ Radius in the z direction
|
||||
*/
|
||||
PX_INLINE Ellipsoid(PxReal rX, PxReal rY, PxReal rZ) : radii(rX, rY, rZ) {}
|
||||
|
||||
/**
|
||||
\brief Constructs an EllipsoidCore with specified radii
|
||||
\param _radii Vector containing radii in x, y, and z directions
|
||||
*/
|
||||
PX_INLINE Ellipsoid(const PxVec3& _radii) : radii(_radii) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Cylinder core data
|
||||
|
||||
The cylinder is defined by its height and radius. It is centered at the origin
|
||||
of the geometry's local space with its axis along the X axis
|
||||
*/
|
||||
struct Cylinder
|
||||
{
|
||||
static const Type TYPE = eCYLINDER;
|
||||
|
||||
/// Cylinder height
|
||||
PxReal height;
|
||||
|
||||
/// Cylinder radius
|
||||
PxReal radius;
|
||||
|
||||
PX_INLINE Cylinder() {}
|
||||
|
||||
/**
|
||||
\brief Constructs a CylinderCore with specified height and radius
|
||||
\param _height Cylinder height
|
||||
\param _radius Cylinder radius
|
||||
*/
|
||||
PX_INLINE Cylinder(PxReal _height, PxReal _radius) : height(_height), radius(_radius) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Cone core data
|
||||
|
||||
The cone is defined by its height and base radius. It is centered at the origin
|
||||
of the geometry's local space with its axis along the X axis and the base
|
||||
at x = -height/2
|
||||
*/
|
||||
struct Cone
|
||||
{
|
||||
static const Type TYPE = eCONE;
|
||||
|
||||
/// Cone height
|
||||
PxReal height;
|
||||
|
||||
/// Cone base radius
|
||||
PxReal radius;
|
||||
|
||||
PX_INLINE Cone() {}
|
||||
|
||||
/**
|
||||
\brief Constructs a ConeCore with specified height and radius
|
||||
\param _height Cone height
|
||||
\param _radius Cone base radius
|
||||
*/
|
||||
PX_INLINE Cone(PxReal _height, PxReal _radius) : height(_height), radius(_radius) {}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Convex core geometry class.
|
||||
|
||||
This class allows users to create a variety of convex shapes. Each shape is defined by:
|
||||
1. A core, specified by one of the pre-authored GJK support functions.
|
||||
2. A margin, which is an arbitrary distance that extends the core.
|
||||
|
||||
The resulting convex shape includes both the core and the surrounding space within the margin.
|
||||
|
||||
Simple examples include:
|
||||
- A sphere: created from a point core with a non-zero margin (radius).
|
||||
- A capsule: created from a segment core with a non-zero margin.
|
||||
*/
|
||||
class PxConvexCoreGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
PX_INLINE PxConvexCoreGeometry();
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
\tparam Core The type of the core
|
||||
\param core The core to use
|
||||
\param margin The margin to add around the core. Defaults to 0
|
||||
*/
|
||||
template <typename Core>
|
||||
PX_INLINE PxConvexCoreGeometry(const Core& core, PxReal margin = 0);
|
||||
|
||||
/**
|
||||
\brief Copy constructor
|
||||
\param that The geometry to copy from
|
||||
*/
|
||||
PX_INLINE PxConvexCoreGeometry(const PxConvexCoreGeometry& that);
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
\param that The geometry to assign from
|
||||
*/
|
||||
PX_INLINE PxConvexCoreGeometry& operator=(const PxConvexCoreGeometry& that);
|
||||
|
||||
/**
|
||||
\brief Get the type of the core
|
||||
\return The type of the core
|
||||
*/
|
||||
PX_INLINE PxConvexCore::Type getCoreType() const;
|
||||
|
||||
/// Maximum size of the core data in bytes.
|
||||
static const PxU32 MAX_CORE_SIZE = sizeof(PxReal) * 6;
|
||||
|
||||
/**
|
||||
\brief Get a pointer to the core data.
|
||||
\return A pointer to the core data.
|
||||
*/
|
||||
PX_INLINE const void* getCoreData() const;
|
||||
|
||||
/**
|
||||
\brief Get the core.
|
||||
\return The core.
|
||||
*/
|
||||
template <typename Core>
|
||||
PX_INLINE const Core& getCore() const;
|
||||
|
||||
/**
|
||||
\brief Get the margin of the convex core geometry.
|
||||
\return The margin size.
|
||||
*/
|
||||
PX_INLINE PxReal getMargin() const;
|
||||
|
||||
/**
|
||||
\brief Check if the convex core geometry is valid.
|
||||
\return True if the geometry is valid, false otherwise.
|
||||
*/
|
||||
PX_PHYSX_COMMON_API bool isValid() const;
|
||||
|
||||
private:
|
||||
|
||||
// Core type
|
||||
PxConvexCore::Type mCoreType;
|
||||
// Core data
|
||||
PxU8 mCore[MAX_CORE_SIZE];
|
||||
// Margin
|
||||
PxReal mMargin;
|
||||
};
|
||||
|
||||
PX_INLINE PxConvexCoreGeometry::PxConvexCoreGeometry()
|
||||
:
|
||||
PxGeometry(PxGeometryType::eCONVEXCORE),
|
||||
mCoreType(PxConvexCore::Type(-1)), mMargin(0)
|
||||
{}
|
||||
|
||||
template <typename Core>
|
||||
PX_INLINE PxConvexCoreGeometry::PxConvexCoreGeometry(const Core& core, PxReal margin)
|
||||
:
|
||||
PxGeometry(PxGeometryType::eCONVEXCORE),
|
||||
mCoreType(Core::TYPE), mMargin(margin)
|
||||
{
|
||||
PX_ASSERT(sizeof(Core) <= MAX_CORE_SIZE);
|
||||
PxMemCopy(mCore, &core, sizeof(Core));
|
||||
}
|
||||
|
||||
PX_INLINE PxConvexCoreGeometry::PxConvexCoreGeometry(const PxConvexCoreGeometry& that)
|
||||
:
|
||||
PxGeometry(that),
|
||||
mCoreType(that.getCoreType()), mMargin(that.getMargin())
|
||||
{
|
||||
PxMemCopy(mCore, that.mCore, MAX_CORE_SIZE);
|
||||
}
|
||||
|
||||
PX_INLINE PxConvexCoreGeometry& PxConvexCoreGeometry::operator = (const PxConvexCoreGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
mCoreType = that.mCoreType;
|
||||
mMargin = that.mMargin;
|
||||
PxMemCopy(mCore, that.mCore, MAX_CORE_SIZE);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxConvexCore::Type PxConvexCoreGeometry::getCoreType() const
|
||||
{
|
||||
return mCoreType;
|
||||
}
|
||||
|
||||
PX_INLINE const void* PxConvexCoreGeometry::getCoreData() const
|
||||
{
|
||||
return mCore;
|
||||
}
|
||||
|
||||
template <typename Core>
|
||||
PX_INLINE const Core& PxConvexCoreGeometry::getCore() const
|
||||
{
|
||||
PX_ASSERT(Core::TYPE == mCoreType);
|
||||
return *reinterpret_cast<const Core*>(getCoreData());
|
||||
}
|
||||
|
||||
PX_INLINE PxReal PxConvexCoreGeometry::getMargin() const
|
||||
{
|
||||
return mMargin;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
184
engine/third_party/physx/include/geometry/PxConvexMesh.h
vendored
Normal file
184
engine/third_party/physx/include/geometry/PxConvexMesh.h
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
// 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_H
|
||||
#define PX_CONVEX_MESH_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
class PxBounds3;
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Polygon data
|
||||
|
||||
Plane format: (mPlane[0],mPlane[1],mPlane[2]).dot(x) + mPlane[3] = 0
|
||||
With the normal outward-facing from the hull.
|
||||
*/
|
||||
struct PxHullPolygon
|
||||
{
|
||||
PxReal mPlane[4]; //!< Plane equation for this polygon
|
||||
PxU16 mNbVerts; //!< Number of vertices/edges in the polygon
|
||||
PxU16 mIndexBase; //!< Offset in index buffer
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A convex mesh.
|
||||
|
||||
Internally represented as a list of convex polygons. The number
|
||||
of polygons is limited to 256.
|
||||
|
||||
To avoid duplicating data when you have several instances of a particular
|
||||
mesh positioned differently, you do not use this class to represent a
|
||||
convex object directly. Instead, you create an instance of this mesh via
|
||||
the PxConvexMeshGeometry and PxShape classes.
|
||||
|
||||
<h3>Creation</h3>
|
||||
|
||||
To create an instance of this class call PxPhysics::createConvexMesh(),
|
||||
and PxConvexMesh::release() to delete it. This is only possible
|
||||
once you have released all of its #PxShape instances.
|
||||
|
||||
<h3>Visualizations:</h3>
|
||||
\li #PxVisualizationParameter::eCOLLISION_AABBS
|
||||
\li #PxVisualizationParameter::eCOLLISION_SHAPES
|
||||
\li #PxVisualizationParameter::eCOLLISION_AXES
|
||||
\li #PxVisualizationParameter::eCOLLISION_FNORMALS
|
||||
\li #PxVisualizationParameter::eCOLLISION_EDGES
|
||||
|
||||
\see PxConvexMeshDesc PxPhysics.createConvexMesh()
|
||||
*/
|
||||
class PxConvexMesh : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Returns the number of vertices.
|
||||
\return Number of vertices.
|
||||
\see getVertices()
|
||||
*/
|
||||
virtual PxU32 getNbVertices() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the vertices.
|
||||
\return Array of vertices.
|
||||
\see getNbVertices()
|
||||
*/
|
||||
virtual const PxVec3* getVertices() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the index buffer.
|
||||
\return Index buffer.
|
||||
\see getNbPolygons() getPolygonData()
|
||||
*/
|
||||
virtual const PxU8* getIndexBuffer() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of polygons.
|
||||
\return Number of polygons.
|
||||
\see getIndexBuffer() getPolygonData()
|
||||
*/
|
||||
virtual PxU32 getNbPolygons() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the polygon data.
|
||||
\param[in] index Polygon index in [0 ; getNbPolygons()[.
|
||||
\param[out] data Polygon data.
|
||||
\return True if success.
|
||||
\see getIndexBuffer() getNbPolygons()
|
||||
*/
|
||||
virtual bool getPolygonData(PxU32 index, PxHullPolygon& data) const = 0;
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of a convex mesh and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createConvexMesh() PxConvexMeshGeometry PxShape
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the mass properties of the mesh assuming unit density.
|
||||
|
||||
The following relationship holds between mass and volume:
|
||||
|
||||
mass = volume * density
|
||||
|
||||
The mass of a unit density mesh is equal to its volume, so this function returns the volume of the mesh.
|
||||
|
||||
Similarly, to obtain the localInertia of an identically shaped object with a uniform density of d, simply multiply the
|
||||
localInertia of the unit density mesh by d.
|
||||
|
||||
\param[out] mass The mass of the mesh assuming unit density.
|
||||
\param[out] localInertia The inertia tensor in mesh local space assuming unit density.
|
||||
\param[out] localCenterOfMass Position of center of mass (or centroid) in mesh local space.
|
||||
*/
|
||||
virtual void getMassInformation(PxReal& mass, PxMat33& localInertia, PxVec3& localCenterOfMass) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the local-space (vertex space) AABB from the convex mesh.
|
||||
|
||||
\return local-space bounds
|
||||
*/
|
||||
virtual PxBounds3 getLocalBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the local-space Signed Distance Field for this mesh if it has one.
|
||||
\return local-space SDF.
|
||||
*/
|
||||
virtual const PxReal* getSDF() const = 0;
|
||||
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE PX_FINAL { return "PxConvexMesh"; }
|
||||
|
||||
/**
|
||||
\brief This method decides whether a convex mesh is gpu compatible. If the total number of vertices are more than 64 or any number of vertices in a polygon is more than 32, or
|
||||
convex hull data was not cooked with GPU data enabled during cooking or was loaded from a serialized collection, the convex hull is incompatible with GPU collision detection. Otherwise
|
||||
it is compatible.
|
||||
|
||||
\return True if the convex hull is gpu compatible
|
||||
*/
|
||||
virtual bool isGpuCompatible() const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
PX_INLINE PxConvexMesh(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxConvexMesh(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxConvexMesh() {}
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxConvexMesh", PxRefCounted); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
158
engine/third_party/physx/include/geometry/PxConvexMeshGeometry.h
vendored
Normal file
158
engine/third_party/physx/include/geometry/PxConvexMeshGeometry.h
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
// 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_GEOMETRY_H
|
||||
#define PX_CONVEX_MESH_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxMeshScale.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
#include "geometry/PxConvexMesh.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxConvexMesh;
|
||||
|
||||
/**
|
||||
\brief Flags controlling the simulated behavior of the convex mesh geometry.
|
||||
|
||||
Used in ::PxConvexMeshGeometryFlags.
|
||||
*/
|
||||
struct PxConvexMeshGeometryFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eTIGHT_BOUNDS = (1<<0) //!< Use tighter (but more expensive to compute) bounds around the convex geometry.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxConvexMeshGeometryFlag.
|
||||
|
||||
\see PxConvexMeshGeometryFlag
|
||||
*/
|
||||
typedef PxFlags<PxConvexMeshGeometryFlag::Enum,PxU8> PxConvexMeshGeometryFlags;
|
||||
PX_FLAGS_OPERATORS(PxConvexMeshGeometryFlag::Enum,PxU8)
|
||||
|
||||
/**
|
||||
\brief Convex mesh geometry class.
|
||||
|
||||
This class unifies a convex mesh object with a scaling transform, and
|
||||
lets the combined object be used anywhere a PxGeometry is needed.
|
||||
|
||||
The scaling is a transform along arbitrary axes contained in the scale object.
|
||||
The vertices of the mesh in geometry (or shape) space is the
|
||||
PxMeshScale::toMat33() transform, multiplied by the vertex space vertices
|
||||
in the PxConvexMesh object.
|
||||
*/
|
||||
class PxConvexMeshGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor. By default creates an empty object with a NULL mesh and identity scale.
|
||||
|
||||
\param[in] mesh Mesh pointer. May be NULL, though this will not make the object valid for shape construction.
|
||||
\param[in] scaling Scale factor.
|
||||
\param[in] flags Mesh flags.
|
||||
\
|
||||
*/
|
||||
PX_INLINE PxConvexMeshGeometry( PxConvexMesh* mesh = NULL,
|
||||
const PxMeshScale& scaling = PxMeshScale(),
|
||||
PxConvexMeshGeometryFlags flags = PxConvexMeshGeometryFlag::eTIGHT_BOUNDS) :
|
||||
PxGeometry (PxGeometryType::eCONVEXMESH),
|
||||
scale (scaling),
|
||||
convexMesh (mesh),
|
||||
meshFlags (flags)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxConvexMeshGeometry(const PxConvexMeshGeometry& that) :
|
||||
PxGeometry (that),
|
||||
scale (that.scale),
|
||||
convexMesh (that.convexMesh),
|
||||
meshFlags (that.meshFlags)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxConvexMeshGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
scale = that.scale;
|
||||
convexMesh = that.convexMesh;
|
||||
meshFlags = that.meshFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid for shape creation.
|
||||
|
||||
\note A valid convex mesh has a positive scale value in each direction (scale.x > 0, scale.y > 0, scale.z > 0).
|
||||
It is illegal to call PxPhysics::createShape with a convex that has zero extent in any direction.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
PxMeshScale scale; //!< The scaling transformation (from vertex space to shape space).
|
||||
PxConvexMesh* convexMesh; //!< A reference to the convex mesh object.
|
||||
PxConvexMeshGeometryFlags meshFlags; //!< Mesh flags.
|
||||
PxPadding<3> paddingFromFlags; //!< padding for mesh flags
|
||||
};
|
||||
|
||||
|
||||
PX_INLINE bool PxConvexMeshGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eCONVEXMESH)
|
||||
return false;
|
||||
if(!scale.scale.isFinite() || !scale.rotation.isUnit())
|
||||
return false;
|
||||
if(!scale.isValidForConvexMesh())
|
||||
return false;
|
||||
if(!convexMesh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
308
engine/third_party/physx/include/geometry/PxCustomGeometry.h
vendored
Normal file
308
engine/third_party/physx/include/geometry/PxCustomGeometry.h
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
// 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_CUSTOMGEOMETRY_H
|
||||
#define PX_CUSTOMGEOMETRY_H
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxGeometryHit.h"
|
||||
#include "geometry/PxGeometryQueryContext.h"
|
||||
#include "foundation/PxFoundationConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
class PxContactBuffer;
|
||||
class PxRenderOutput;
|
||||
class PxMassProperties;
|
||||
|
||||
/**
|
||||
\brief Custom geometry class. This class allows user to create custom geometries by providing a set of virtual callback functions.
|
||||
*/
|
||||
class PxCustomGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief For internal use
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static PxU32 getUniqueID();
|
||||
|
||||
/**
|
||||
\brief The type of a custom geometry. Allows to identify a particular kind of it.
|
||||
*/
|
||||
struct Type
|
||||
{
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
PX_INLINE Type() : mID(getUniqueID()) {}
|
||||
|
||||
/**
|
||||
\brief Default constructor
|
||||
*/
|
||||
PX_INLINE Type(const Type& t) : mID(t.mID) {}
|
||||
|
||||
/**
|
||||
\brief Assigment operator
|
||||
*/
|
||||
PX_INLINE Type& operator = (const Type& t) { mID = t.mID; return *this; }
|
||||
|
||||
/**
|
||||
\brief Equality operator
|
||||
*/
|
||||
PX_INLINE bool operator == (const Type& t) const { return mID == t.mID; }
|
||||
|
||||
/**
|
||||
\brief Inequality operator
|
||||
*/
|
||||
PX_INLINE bool operator != (const Type& t) const { return mID != t.mID; }
|
||||
|
||||
/**
|
||||
\brief Invalid type
|
||||
*/
|
||||
PX_INLINE static Type INVALID() { PxU32 z(0); return reinterpret_cast<const Type&>(z); }
|
||||
|
||||
private:
|
||||
PxU32 mID;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Custom geometry callbacks structure. User should inherit this and implement all pure virtual functions.
|
||||
*/
|
||||
struct Callbacks
|
||||
{
|
||||
/**
|
||||
\brief Return custom type. The type purpose is for user to differentiate custom geometries. Not used by PhysX.
|
||||
|
||||
\return Unique ID of a custom geometry type.
|
||||
|
||||
\note User should use DECLARE_CUSTOM_GEOMETRY_TYPE and IMPLEMENT_CUSTOM_GEOMETRY_TYPE intead of overwriting this function.
|
||||
*/
|
||||
virtual Type getCustomType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Return local bounds.
|
||||
|
||||
\param[in] geometry This geometry.
|
||||
|
||||
\return Bounding box in the geometry local space.
|
||||
*/
|
||||
virtual PxBounds3 getLocalBounds(const PxGeometry& geometry) const = 0;
|
||||
|
||||
/**
|
||||
\brief Contacts generation. Generate collision contacts between two geometries in given poses.
|
||||
|
||||
\param[in] geom0 This custom geometry
|
||||
\param[in] geom1 The other geometry
|
||||
\param[in] pose0 This custom geometry pose
|
||||
\param[in] pose1 The other geometry pose
|
||||
\param[in] contactDistance The distance at which contacts begin to be generated between the pairs
|
||||
\param[in] meshContactMargin The mesh contact margin.
|
||||
\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 write contacts to.
|
||||
|
||||
\return True if there are contacts. False otherwise.
|
||||
*/
|
||||
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 = 0;
|
||||
|
||||
/**
|
||||
\brief Raycast. Cast a ray against the geometry in given pose.
|
||||
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] geom This custom geometry
|
||||
\param[in] pose This custom geometry pose
|
||||
\param[in] maxDist Length of the ray. Has to be in the [0, inf) range.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback.
|
||||
\param[in] maxHits max number of returned hits = size of 'rayHits' buffer
|
||||
\param[out] rayHits Ray hits.
|
||||
\param[in] stride Ray hit structure stride.
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return Number of hits.
|
||||
*/
|
||||
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* threadContext) const = 0;
|
||||
|
||||
/**
|
||||
\brief Overlap. Test if geometries overlap.
|
||||
|
||||
\param[in] geom0 This custom geometry
|
||||
\param[in] pose0 This custom geometry pose
|
||||
\param[in] geom1 The other geometry
|
||||
\param[in] pose1 The other geometry pose
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return True if there is overlap. False otherwise.
|
||||
*/
|
||||
virtual bool overlap(const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext* threadContext) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sweep. Sweep geom1 against geom0.
|
||||
|
||||
\param[in] unitDir Normalized direction of the sweep. geom1 is swept along this direction.
|
||||
\param[in] maxDist Length of the sweep. Has to be in the [0, inf) range.
|
||||
\param[in] geom0 This custom geometry
|
||||
\param[in] pose0 This custom geometry pose
|
||||
\param[in] geom1 The other geometry
|
||||
\param[in] pose1 The other geometry pose
|
||||
\param[out] sweepHit Used to report the sweep hit.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback.
|
||||
\param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping.
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return True if there is hit. False otherwise.
|
||||
*/
|
||||
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* threadContext) const = 0;
|
||||
|
||||
/**
|
||||
\brief Visualize custom geometry for debugging. Optional.
|
||||
|
||||
\param[in] geometry This geometry.
|
||||
\param[in] out Render output.
|
||||
\param[in] absPose Geometry absolute transform.
|
||||
\param[in] cullbox Region to visualize.
|
||||
*/
|
||||
virtual void visualize(const PxGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox) const = 0;
|
||||
|
||||
/**
|
||||
\brief Compute custom geometry mass properties. For geometries usable with dynamic rigidbodies.
|
||||
|
||||
\param[in] geometry This geometry.
|
||||
\param[out] massProperties Mass properties to compute.
|
||||
*/
|
||||
virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const = 0;
|
||||
|
||||
/**
|
||||
\brief Compatible with PhysX's PCM feature. Allows to optimize contact generation.
|
||||
|
||||
\param[in] geometry This geometry.
|
||||
\param[out] breakingThreshold The threshold to trigger contacts re-generation.
|
||||
*/
|
||||
virtual bool usePersistentContactManifold(const PxGeometry& geometry, PxReal& breakingThreshold) const = 0;
|
||||
|
||||
/* Destructor */
|
||||
virtual ~Callbacks() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Default constructor.
|
||||
|
||||
Creates an empty object with a NULL callbacks pointer.
|
||||
*/
|
||||
PX_INLINE PxCustomGeometry() :
|
||||
PxGeometry(PxGeometryType::eCUSTOM),
|
||||
callbacks(NULL)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Constructor.
|
||||
*/
|
||||
PX_INLINE PxCustomGeometry(Callbacks& _callbacks) :
|
||||
PxGeometry(PxGeometryType::eCUSTOM),
|
||||
callbacks(&_callbacks)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxCustomGeometry(const PxCustomGeometry& that) :
|
||||
PxGeometry(that),
|
||||
callbacks(that.callbacks)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxCustomGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
callbacks = that.callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid for shape creation.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief Returns the custom type of the custom geometry.
|
||||
*/
|
||||
PX_INLINE Type getCustomType() const
|
||||
{
|
||||
return callbacks ? callbacks->getCustomType() : Type::INVALID();
|
||||
}
|
||||
|
||||
public:
|
||||
Callbacks* callbacks; //!< A reference to the callbacks object.
|
||||
};
|
||||
|
||||
PX_INLINE bool PxCustomGeometry::isValid() const
|
||||
{
|
||||
return mType == PxGeometryType::eCUSTOM && callbacks != NULL;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Used in pair with IMPLEMENT_CUSTOM_GEOMETRY_TYPE to overwrite Callbacks::getCustomType() callback.
|
||||
*/
|
||||
#define DECLARE_CUSTOM_GEOMETRY_TYPE \
|
||||
static ::physx::PxCustomGeometry::Type TYPE(); \
|
||||
virtual ::physx::PxCustomGeometry::Type getCustomType() const;
|
||||
|
||||
/**
|
||||
\brief Used in pair with DECLARE_CUSTOM_GEOMETRY_TYPE to overwrite Callbacks::getCustomType() callback.
|
||||
*/
|
||||
#define IMPLEMENT_CUSTOM_GEOMETRY_TYPE(CLASS) \
|
||||
::physx::PxCustomGeometry::Type CLASS::TYPE() \
|
||||
{ \
|
||||
static ::physx::PxCustomGeometry::Type customType; \
|
||||
return customType; \
|
||||
} \
|
||||
::physx::PxCustomGeometry::Type CLASS::getCustomType() const \
|
||||
{ \
|
||||
return TYPE(); \
|
||||
}
|
||||
|
||||
#endif
|
||||
106
engine/third_party/physx/include/geometry/PxGeometry.h
vendored
Normal file
106
engine/third_party/physx/include/geometry/PxGeometry.h
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// 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_GEOMETRY_H
|
||||
#define PX_GEOMETRY_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxMath.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A geometry type.
|
||||
|
||||
Used to distinguish the type of a ::PxGeometry object.
|
||||
*/
|
||||
struct PxGeometryType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eSPHERE,
|
||||
ePLANE,
|
||||
eCAPSULE,
|
||||
eBOX,
|
||||
eCONVEXCORE,
|
||||
eCONVEXMESH,
|
||||
ePARTICLESYSTEM,
|
||||
eTETRAHEDRONMESH,
|
||||
eTRIANGLEMESH,
|
||||
eHEIGHTFIELD,
|
||||
eCUSTOM,
|
||||
|
||||
eGEOMETRY_COUNT, //!< internal use only!
|
||||
eINVALID = -1 //!< internal use only!
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A geometry object.
|
||||
|
||||
A geometry object defines the characteristics of a spatial object, but without any information
|
||||
about its placement in the world.
|
||||
|
||||
\note This is an abstract class. You cannot create instances directly. Create an instance of one of the derived classes instead.
|
||||
*/
|
||||
class PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Returns the type of the geometry.
|
||||
\return The type of the object.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum getType() const { return mType; }
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
}
|
||||
|
||||
protected:
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometry(PxGeometryType::Enum type) : mType(type) {}
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometry(const PxGeometry& that) : mType(that.mType) {}
|
||||
|
||||
PxGeometryType::Enum mType;
|
||||
|
||||
public:
|
||||
float mTypePadding; // PT: padding bytes on x64, used internally
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
187
engine/third_party/physx/include/geometry/PxGeometryHelpers.h
vendored
Normal file
187
engine/third_party/physx/include/geometry/PxGeometryHelpers.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_GEOMETRY_HELPERS_H
|
||||
#define PX_GEOMETRY_HELPERS_H
|
||||
|
||||
#include "foundation/PxPlane.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxUnionCast.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxBoxGeometry.h"
|
||||
#include "geometry/PxSphereGeometry.h"
|
||||
#include "geometry/PxCapsuleGeometry.h"
|
||||
#include "geometry/PxPlaneGeometry.h"
|
||||
#include "geometry/PxConvexMeshGeometry.h"
|
||||
#include "geometry/PxHeightFieldGeometry.h"
|
||||
#include "geometry/PxParticleSystemGeometry.h"
|
||||
#include "geometry/PxTetrahedronMeshGeometry.h"
|
||||
#include "geometry/PxCustomGeometry.h"
|
||||
#include "geometry/PxConvexCoreGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Geometry holder class
|
||||
|
||||
This class contains enough space to hold a value of any PxGeometry subtype.
|
||||
|
||||
Its principal use is as a convenience class to allow geometries to be returned polymorphically from functions.
|
||||
*/
|
||||
|
||||
PX_ALIGN_PREFIX(8)
|
||||
class PxGeometryHolder
|
||||
{
|
||||
class PxInvalidGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
PX_INLINE PxInvalidGeometry() : PxGeometry(PxGeometryType::eINVALID) {}
|
||||
};
|
||||
|
||||
public:
|
||||
PX_FORCE_INLINE PxGeometryType::Enum getType() const
|
||||
{
|
||||
return any().getType();
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxGeometry& any()
|
||||
{
|
||||
return *PxUnionCast<PxGeometry*>(&bytes.geometry);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE const PxGeometry& any() const
|
||||
{
|
||||
return *PxUnionCast<const PxGeometry*>(&bytes.geometry);
|
||||
}
|
||||
|
||||
//! \cond
|
||||
PX_FORCE_INLINE PxSphereGeometry& sphere() { return get<PxSphereGeometry, PxGeometryType::eSPHERE>(); }
|
||||
PX_FORCE_INLINE const PxSphereGeometry& sphere() const { return get<const PxSphereGeometry, PxGeometryType::eSPHERE>(); }
|
||||
|
||||
PX_FORCE_INLINE PxPlaneGeometry& plane() { return get<PxPlaneGeometry, PxGeometryType::ePLANE>(); }
|
||||
PX_FORCE_INLINE const PxPlaneGeometry& plane() const { return get<const PxPlaneGeometry, PxGeometryType::ePLANE>(); }
|
||||
|
||||
PX_FORCE_INLINE PxCapsuleGeometry& capsule() { return get<PxCapsuleGeometry, PxGeometryType::eCAPSULE>(); }
|
||||
PX_FORCE_INLINE const PxCapsuleGeometry& capsule() const { return get<const PxCapsuleGeometry, PxGeometryType::eCAPSULE>(); }
|
||||
|
||||
PX_FORCE_INLINE PxBoxGeometry& box() { return get<PxBoxGeometry, PxGeometryType::eBOX>(); }
|
||||
PX_FORCE_INLINE const PxBoxGeometry& box() const { return get<const PxBoxGeometry, PxGeometryType::eBOX>(); }
|
||||
|
||||
PX_FORCE_INLINE PxConvexCoreGeometry& convexCore() { return get<PxConvexCoreGeometry, PxGeometryType::eCONVEXCORE>(); }
|
||||
PX_FORCE_INLINE const PxConvexCoreGeometry& convexCore() const { return get<const PxConvexCoreGeometry, PxGeometryType::eCONVEXCORE>(); }
|
||||
|
||||
PX_FORCE_INLINE PxConvexMeshGeometry& convexMesh() { return get<PxConvexMeshGeometry, PxGeometryType::eCONVEXMESH>(); }
|
||||
PX_FORCE_INLINE const PxConvexMeshGeometry& convexMesh() const { return get<const PxConvexMeshGeometry, PxGeometryType::eCONVEXMESH>(); }
|
||||
|
||||
PX_FORCE_INLINE PxTetrahedronMeshGeometry& tetMesh() { return get<PxTetrahedronMeshGeometry, PxGeometryType::eTETRAHEDRONMESH>(); }
|
||||
PX_FORCE_INLINE const PxTetrahedronMeshGeometry& tetMesh() const { return get<const PxTetrahedronMeshGeometry, PxGeometryType::eTETRAHEDRONMESH>(); }
|
||||
|
||||
PX_FORCE_INLINE PxTriangleMeshGeometry& triangleMesh() { return get<PxTriangleMeshGeometry, PxGeometryType::eTRIANGLEMESH>(); }
|
||||
PX_FORCE_INLINE const PxTriangleMeshGeometry& triangleMesh() const { return get<const PxTriangleMeshGeometry, PxGeometryType::eTRIANGLEMESH>(); }
|
||||
|
||||
PX_FORCE_INLINE PxHeightFieldGeometry& heightField() { return get<PxHeightFieldGeometry, PxGeometryType::eHEIGHTFIELD>(); }
|
||||
PX_FORCE_INLINE const PxHeightFieldGeometry& heightField() const { return get<const PxHeightFieldGeometry, PxGeometryType::eHEIGHTFIELD>(); }
|
||||
|
||||
PX_FORCE_INLINE PxParticleSystemGeometry& particleSystem() { return get<PxParticleSystemGeometry, PxGeometryType::ePARTICLESYSTEM>(); }
|
||||
PX_FORCE_INLINE const PxParticleSystemGeometry& particleSystem() const { return get<const PxParticleSystemGeometry, PxGeometryType::ePARTICLESYSTEM>(); }
|
||||
|
||||
PX_FORCE_INLINE PxCustomGeometry& custom() { return get<PxCustomGeometry, PxGeometryType::eCUSTOM>(); }
|
||||
PX_FORCE_INLINE const PxCustomGeometry& custom() const { return get<const PxCustomGeometry, PxGeometryType::eCUSTOM>(); }
|
||||
//! \endcond
|
||||
|
||||
PX_FORCE_INLINE void storeAny(const PxGeometry& geometry)
|
||||
{
|
||||
PX_ASSERT_WITH_MESSAGE( (geometry.getType() >= PxGeometryType::eSPHERE) &&
|
||||
(geometry.getType() < PxGeometryType::eGEOMETRY_COUNT),
|
||||
"Unexpected GeometryType in PxGeometryHolder::storeAny");
|
||||
|
||||
switch(geometry.getType())
|
||||
{
|
||||
case PxGeometryType::eSPHERE: put<PxSphereGeometry>(geometry); break;
|
||||
case PxGeometryType::ePLANE: put<PxPlaneGeometry>(geometry); break;
|
||||
case PxGeometryType::eCAPSULE: put<PxCapsuleGeometry>(geometry); break;
|
||||
case PxGeometryType::eBOX: put<PxBoxGeometry>(geometry); break;
|
||||
case PxGeometryType::eCONVEXCORE: put<PxConvexCoreGeometry>(geometry); break;
|
||||
case PxGeometryType::eCONVEXMESH: put<PxConvexMeshGeometry>(geometry); break;
|
||||
case PxGeometryType::eTRIANGLEMESH: put<PxTriangleMeshGeometry>(geometry); break;
|
||||
case PxGeometryType::eTETRAHEDRONMESH: put<PxTetrahedronMeshGeometry>(geometry); break;
|
||||
case PxGeometryType::eHEIGHTFIELD: put<PxHeightFieldGeometry>(geometry); break;
|
||||
case PxGeometryType::ePARTICLESYSTEM: put<PxParticleSystemGeometry>(geometry); break;
|
||||
case PxGeometryType::eCUSTOM: put<PxCustomGeometry>(geometry); break;
|
||||
case PxGeometryType::eGEOMETRY_COUNT:
|
||||
case PxGeometryType::eINVALID: break;
|
||||
}
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxGeometryHolder() { put<PxInvalidGeometry>(PxInvalidGeometry()); }
|
||||
PX_FORCE_INLINE PxGeometryHolder(const PxGeometry& geometry){ storeAny(geometry); }
|
||||
|
||||
private:
|
||||
template<typename T> void put(const PxGeometry& geometry)
|
||||
{
|
||||
static_cast<T&>(any()) = static_cast<const T&>(geometry);
|
||||
}
|
||||
|
||||
template<typename T, PxGeometryType::Enum type> T& get()
|
||||
{
|
||||
PX_ASSERT(getType() == type);
|
||||
return static_cast<T&>(any());
|
||||
}
|
||||
|
||||
template<typename T, PxGeometryType::Enum type> T& get() const
|
||||
{
|
||||
PX_ASSERT(getType() == type);
|
||||
return static_cast<T&>(any());
|
||||
}
|
||||
|
||||
union {
|
||||
PxU8 geometry[sizeof(PxGeometry)];
|
||||
PxU8 box[sizeof(PxBoxGeometry)];
|
||||
PxU8 sphere[sizeof(PxSphereGeometry)];
|
||||
PxU8 capsule[sizeof(PxCapsuleGeometry)];
|
||||
PxU8 plane[sizeof(PxPlaneGeometry)];
|
||||
PxU8 convex[sizeof(PxConvexCoreGeometry)];
|
||||
PxU8 convexMesh[sizeof(PxConvexMeshGeometry)];
|
||||
PxU8 tetMesh[sizeof(PxTetrahedronMeshGeometry)];
|
||||
PxU8 mesh[sizeof(PxTriangleMeshGeometry)];
|
||||
PxU8 heightfield[sizeof(PxHeightFieldGeometry)];
|
||||
PxU8 particleSystem[sizeof(PxParticleSystemGeometry)];
|
||||
PxU8 custom[sizeof(PxCustomGeometry)];
|
||||
} bytes;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(8);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
202
engine/third_party/physx/include/geometry/PxGeometryHit.h
vendored
Normal file
202
engine/third_party/physx/include/geometry/PxGeometryHit.h
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
// 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_GEOMETRY_HIT_H
|
||||
#define PX_GEOMETRY_HIT_H
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Scene query and geometry query behavior flags.
|
||||
|
||||
PxHitFlags are used for 3 different purposes:
|
||||
|
||||
1) To request hit fields to be filled in by scene queries (such as hit position, normal, face index or UVs).
|
||||
2) Once query is completed, to indicate which fields are valid (note that a query may produce more valid fields than requested).
|
||||
3) To specify additional options for the narrow phase and mid-phase intersection routines.
|
||||
|
||||
All these flags apply to both scene queries and geometry queries (PxGeometryQuery).
|
||||
|
||||
\see PxRaycastHit PxSweepHit PxOverlapHit PxScene.raycast PxScene.sweep PxScene.overlap PxGeometryQuery PxFindFaceIndex
|
||||
*/
|
||||
struct PxHitFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePOSITION = (1<<0), //!< "position" member of #PxQueryHit is valid
|
||||
eNORMAL = (1<<1), //!< "normal" member of #PxQueryHit is valid
|
||||
eUV = (1<<3), //!< "u" and "v" barycentric coordinates of #PxQueryHit are valid. Not applicable to sweep queries.
|
||||
eASSUME_NO_INITIAL_OVERLAP = (1<<4), //!< Performance hint flag for sweeps when it is known upfront there's no initial overlap.
|
||||
//!< NOTE: using this flag may cause undefined results if shapes are initially overlapping.
|
||||
eANY_HIT = (1<<5), //!< Report any first hit. Used for geometries that contain more than one primitive. For meshes,
|
||||
//!< if neither eMESH_MULTIPLE nor eANY_HIT is specified, a single closest hit will be reported.
|
||||
eMESH_MULTIPLE = (1<<6), //!< Report all hits for meshes rather than just the first. Not applicable to sweep queries.
|
||||
eMESH_BOTH_SIDES = (1<<7), //!< Report hits with back faces of mesh triangles. Also report hits for raycast
|
||||
//!< originating on mesh surface and facing away from the surface normal. Not applicable to sweep queries.
|
||||
//!< Please refer to the user guide for heightfield-specific differences.
|
||||
ePRECISE_SWEEP = (1<<8), //!< Use more accurate but slower narrow phase sweep tests.
|
||||
//!< May provide better compatibility with PhysX 3.2 sweep behavior.
|
||||
eMTD = (1<<9), //!< Report the minimum translation depth, normal and contact point.
|
||||
eFACE_INDEX = (1<<10), //!< "face index" member of #PxQueryHit is valid
|
||||
|
||||
eDEFAULT = ePOSITION|eNORMAL|eFACE_INDEX,
|
||||
|
||||
/** \brief Only this subset of flags can be modified by pre-filter. Other modifications will be discarded. */
|
||||
eMODIFIABLE_FLAGS = eMESH_MULTIPLE|eMESH_BOTH_SIDES|eASSUME_NO_INITIAL_OVERLAP|ePRECISE_SWEEP
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxHitFlag.
|
||||
|
||||
\see PxHitFlag
|
||||
*/
|
||||
PX_FLAGS_TYPEDEF(PxHitFlag, PxU16)
|
||||
|
||||
/**
|
||||
\brief Scene query hit information.
|
||||
*/
|
||||
struct PxQueryHit
|
||||
{
|
||||
PX_INLINE PxQueryHit() : faceIndex(0xFFFFffff) {}
|
||||
|
||||
/**
|
||||
Face index of touched triangle, for triangle meshes, convex meshes and height fields.
|
||||
|
||||
\note This index will default to 0xFFFFffff value for overlap queries.
|
||||
\note Please refer to the user guide for more details for sweep queries.
|
||||
\note This index is remapped by mesh cooking. Use #PxTriangleMesh::getTrianglesRemap() to convert to original mesh index.
|
||||
\note For convex meshes use #PxConvexMesh::getPolygonData() to retrieve touched polygon data.
|
||||
*/
|
||||
PxU32 faceIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Scene query hit information for raycasts and sweeps returning hit position and normal information.
|
||||
|
||||
::PxHitFlag flags can be passed to scene query functions, as an optimization, to cause the SDK to
|
||||
only generate specific members of this structure.
|
||||
*/
|
||||
struct PxLocationHit : PxQueryHit
|
||||
{
|
||||
PX_INLINE PxLocationHit() : flags(0), position(PxVec3(0)), normal(PxVec3(0)), distance(PX_MAX_REAL) {}
|
||||
|
||||
/**
|
||||
\note For raycast hits: true for shapes overlapping with raycast origin.
|
||||
\note For sweep hits: true for shapes overlapping at zero sweep distance.
|
||||
|
||||
\see PxRaycastHit PxSweepHit
|
||||
*/
|
||||
PX_INLINE bool hadInitialOverlap() const { return (distance <= 0.0f); }
|
||||
|
||||
// the following fields are set in accordance with the #PxHitFlags
|
||||
PxHitFlags flags; //!< Hit flags specifying which members contain valid values.
|
||||
PxVec3 position; //!< World-space hit position (flag: #PxHitFlag::ePOSITION)
|
||||
PxVec3 normal; //!< World-space hit normal (flag: #PxHitFlag::eNORMAL)
|
||||
|
||||
/**
|
||||
\brief Distance to hit.
|
||||
\note If the eMTD flag is used, distance will be a negative value if shapes are overlapping indicating the penetration depth.
|
||||
\note Otherwise, this value will be >= 0 */
|
||||
PxF32 distance;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Stores results of raycast queries.
|
||||
|
||||
::PxHitFlag flags can be passed to raycast function, as an optimization, to cause the SDK to only compute specified members of this
|
||||
structure.
|
||||
|
||||
Some members like barycentric coordinates are currently only computed for triangle meshes and height fields, but next versions
|
||||
might provide them in other cases. The client code should check #flags to make sure returned values are valid.
|
||||
|
||||
\see PxScene.raycast
|
||||
*/
|
||||
struct PxGeomRaycastHit : PxLocationHit
|
||||
{
|
||||
PX_INLINE PxGeomRaycastHit() : u(0.0f), v(0.0f) {}
|
||||
|
||||
// the following fields are set in accordance with the #PxHitFlags
|
||||
|
||||
PxReal u, v; //!< barycentric coordinates of hit point, for triangle mesh and height field (flag: #PxHitFlag::eUV)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Stores results of overlap queries.
|
||||
|
||||
\see PxScene.overlap
|
||||
*/
|
||||
struct PxGeomOverlapHit : PxQueryHit
|
||||
{
|
||||
PX_INLINE PxGeomOverlapHit() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Stores results of sweep queries.
|
||||
|
||||
\see PxScene.sweep
|
||||
*/
|
||||
struct PxGeomSweepHit : PxLocationHit
|
||||
{
|
||||
PX_INLINE PxGeomSweepHit() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pair of indices, typically either object or triangle indices.
|
||||
*/
|
||||
struct PxGeomIndexPair
|
||||
{
|
||||
PX_FORCE_INLINE PxGeomIndexPair() {}
|
||||
PX_FORCE_INLINE PxGeomIndexPair(PxU32 _id0, PxU32 _id1) : id0(_id0), id1(_id1) {}
|
||||
|
||||
PxU32 id0, id1;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Pair of indices and a distance between involved objects or triangles.
|
||||
*/
|
||||
struct PxGeomIndexClosePair : PxGeomIndexPair
|
||||
{
|
||||
PX_FORCE_INLINE PxGeomIndexClosePair() {}
|
||||
PX_FORCE_INLINE PxGeomIndexClosePair(PxU32 _id0, PxU32 _id1, float d) :
|
||||
PxGeomIndexPair(_id0, _id1), distance(d) {}
|
||||
|
||||
float distance;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
120
engine/third_party/physx/include/geometry/PxGeometryInternal.h
vendored
Normal file
120
engine/third_party/physx/include/geometry/PxGeometryInternal.h
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
// 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_GEOMETRY_INTERNAL_H
|
||||
#define PX_GEOMETRY_INTERNAL_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "geometry/PxTriangleMesh.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxTriangleMesh;
|
||||
|
||||
struct PxTriangleMeshInternalData
|
||||
{
|
||||
PxU32 mNbVertices;
|
||||
PxU32 mNbTriangles;
|
||||
PxVec3* mVertices;
|
||||
void* mTriangles;
|
||||
PxU32* mFaceRemap;
|
||||
PxVec3 mAABB_Center;
|
||||
PxVec3 mAABB_Extents;
|
||||
PxReal mGeomEpsilon;
|
||||
PxU8 mFlags;
|
||||
//
|
||||
PxU32 mNbNodes;
|
||||
PxU32 mNodeSize;
|
||||
void* mNodes;
|
||||
PxU32 mInitData;
|
||||
PxVec3 mCenterOrMinCoeff;
|
||||
PxVec3 mExtentsOrMaxCoeff;
|
||||
bool mQuantized;
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofVerticesInBytes() const
|
||||
{
|
||||
return mNbVertices * sizeof(PxVec3);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofTrianglesInBytes() const
|
||||
{
|
||||
const PxU32 triangleSize = mFlags & PxTriangleMeshFlag::e16_BIT_INDICES ? sizeof(PxU16) : sizeof(PxU32);
|
||||
return mNbTriangles * 3 * triangleSize;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofFaceRemapInBytes() const
|
||||
{
|
||||
return mNbTriangles * sizeof(PxU32);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofNodesInBytes() const
|
||||
{
|
||||
return mNbNodes * mNodeSize;
|
||||
}
|
||||
};
|
||||
|
||||
PX_C_EXPORT PX_PHYSX_COMMON_API bool PX_CALL_CONV PxGetTriangleMeshInternalData(PxTriangleMeshInternalData& data, const PxTriangleMesh& mesh, bool takeOwnership);
|
||||
|
||||
class PxBVH;
|
||||
|
||||
struct PxBVHInternalData
|
||||
{
|
||||
PxU32 mNbIndices;
|
||||
PxU32 mNbNodes;
|
||||
PxU32 mNodeSize;
|
||||
void* mNodes;
|
||||
PxU32* mIndices; // Can be null
|
||||
void* mBounds;
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofNodesInBytes() const
|
||||
{
|
||||
return mNbNodes * mNodeSize;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofIndicesInBytes() const
|
||||
{
|
||||
return mNbIndices * sizeof(PxU32);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSizeofBoundsInBytes() const
|
||||
{
|
||||
return (mNbIndices+1)*6;
|
||||
}
|
||||
};
|
||||
|
||||
PX_C_EXPORT PX_PHYSX_COMMON_API bool PX_CALL_CONV PxGetBVHInternalData(PxBVHInternalData& data, const PxBVH& bvh, bool takeOwnership);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
251
engine/third_party/physx/include/geometry/PxGeometryQuery.h
vendored
Normal file
251
engine/third_party/physx/include/geometry/PxGeometryQuery.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_GEOMETRY_QUERY_H
|
||||
#define PX_GEOMETRY_QUERY_H
|
||||
|
||||
/**
|
||||
\brief Maximum sweep distance for scene sweeps. The distance parameter for sweep functions will be clamped to this value.
|
||||
The reason for this is GJK support cannot be evaluated near infinity. A viable alternative can be a sweep followed by an infinite raycast.
|
||||
|
||||
\see PxScene
|
||||
*/
|
||||
#define PX_MAX_SWEEP_DISTANCE 1e8f
|
||||
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "geometry/PxGeometryHit.h"
|
||||
#include "geometry/PxGeometryQueryFlags.h"
|
||||
#include "geometry/PxGeometryQueryContext.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGeometry;
|
||||
class PxContactBuffer;
|
||||
class PxBounds3;
|
||||
|
||||
/**
|
||||
\brief Collection of geometry object queries (sweeps, raycasts, overlaps, ...).
|
||||
*/
|
||||
class PxGeometryQuery
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Raycast test against a geometry object.
|
||||
|
||||
All geometry types are supported except PxParticleSystemGeometry and PxTetrahedronMeshGeometry.
|
||||
|
||||
\param[in] origin The origin of the ray to test the geometry object against
|
||||
\param[in] unitDir Normalized direction of the ray to test the geometry object against
|
||||
\param[in] geom The geometry object to test the ray against
|
||||
\param[in] pose Pose of the geometry object
|
||||
\param[in] maxDist Maximum ray length, has to be in the [0, inf) range
|
||||
\param[in] hitFlags Specification of the kind of information to retrieve on hit. Combination of #PxHitFlag flags
|
||||
\param[in] maxHits max number of returned hits = size of 'rayHits' buffer
|
||||
\param[out] rayHits Raycast hits information
|
||||
\param[in] stride Stride value (in number of bytes) for rayHits array. Typically sizeof(PxGeomRaycastHit) for packed arrays.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return Number of hits between the ray and the geometry object
|
||||
|
||||
\see PxGeomRaycastHit PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static PxU32 raycast( const PxVec3& origin, const PxVec3& unitDir,
|
||||
const PxGeometry& geom, const PxTransform& pose,
|
||||
PxReal maxDist, PxHitFlags hitFlags,
|
||||
PxU32 maxHits, PxGeomRaycastHit* PX_RESTRICT rayHits, PxU32 stride = sizeof(PxGeomRaycastHit), PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
|
||||
PxRaycastThreadContext* threadContext = NULL);
|
||||
|
||||
/**
|
||||
\brief Overlap test for two geometry objects.
|
||||
|
||||
All combinations are supported except:
|
||||
\li PxPlaneGeometry vs. {PxPlaneGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
\li PxTriangleMeshGeometry vs. PxHeightFieldGeometry
|
||||
\li PxHeightFieldGeometry vs. PxHeightFieldGeometry
|
||||
\li Anything involving PxParticleSystemGeometry or PxTetrahedronMeshGeometry
|
||||
|
||||
\param[in] geom0 The first geometry object
|
||||
\param[in] pose0 Pose of the first geometry object
|
||||
\param[in] geom1 The second geometry object
|
||||
\param[in] pose1 Pose of the second geometry object
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return True if the two geometry objects overlap
|
||||
|
||||
\see PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool overlap(const PxGeometry& geom0, const PxTransform& pose0,
|
||||
const PxGeometry& geom1, const PxTransform& pose1,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxOverlapThreadContext* threadContext=NULL);
|
||||
|
||||
/**
|
||||
\brief Sweep a specified geometry object in space and test for collision with a given object.
|
||||
|
||||
The following combinations are supported.
|
||||
|
||||
\li PxSphereGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexCoreGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
\li PxCapsuleGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexCoreGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
\li PxBoxGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexCoreGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
\li PxConvexCoreGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexCoreGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
\li PxConvexMeshGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexCoreGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}
|
||||
|
||||
\param[in] unitDir Normalized direction along which object geom0 should be swept
|
||||
\param[in] maxDist Maximum sweep distance, has to be in the [0, inf) range
|
||||
\param[in] geom0 The geometry object to sweep. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry, #PxBoxGeometry, #PxConvexCoreGeometry, and #PxConvexMeshGeometry
|
||||
\param[in] pose0 Pose of the geometry object to sweep
|
||||
\param[in] geom1 The geometry object to test the sweep against
|
||||
\param[in] pose1 Pose of the geometry object to sweep against
|
||||
\param[out] sweepHit The sweep hit information. Only valid if this method returns true.
|
||||
\param[in] hitFlags Specify which properties per hit should be computed and written to result hit array. Combination of #PxHitFlag flags
|
||||
\param[in] inflation Surface of the swept shape is additively extruded in the normal direction, rounding corners and edges.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\param[in] threadContext Optional user-defined per-thread context.
|
||||
|
||||
\return True if the swept geometry object geom0 hits the object geom1
|
||||
|
||||
\see PxGeomSweepHit PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool sweep( const PxVec3& unitDir, const PxReal maxDist,
|
||||
const PxGeometry& geom0, const PxTransform& pose0,
|
||||
const PxGeometry& geom1, const PxTransform& pose1,
|
||||
PxGeomSweepHit& sweepHit, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
|
||||
const PxReal inflation = 0.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
|
||||
PxSweepThreadContext* threadContext = NULL);
|
||||
|
||||
/**
|
||||
\brief Compute minimum translational distance (MTD) between two geometry objects.
|
||||
|
||||
All combinations of geom objects are supported except:
|
||||
- plane/plane
|
||||
- plane/mesh
|
||||
- plane/heightfield
|
||||
- mesh/mesh
|
||||
- mesh/heightfield
|
||||
- heightfield/heightfield
|
||||
- anything involving PxParticleSystemGeometry, PxTetrahedronMeshGeometry
|
||||
|
||||
The function returns a unit vector ('direction') and a penetration depth ('depth').
|
||||
|
||||
The depenetration vector D = direction * depth should be applied to the first object, to
|
||||
get out of the second object.
|
||||
|
||||
Returned depth should always be positive or null.
|
||||
|
||||
If objects do not overlap, the function can not compute the MTD and returns false.
|
||||
|
||||
\param[out] direction Computed MTD unit direction
|
||||
\param[out] depth Penetration depth. Always positive or null.
|
||||
\param[in] geom0 The first geometry object
|
||||
\param[in] pose0 Pose of the first geometry object
|
||||
\param[in] geom1 The second geometry object
|
||||
\param[in] pose1 Pose of the second geometry object
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return True if the MTD has successfully been computed, i.e. if objects do overlap.
|
||||
|
||||
\see PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool computePenetration( PxVec3& direction, PxF32& depth,
|
||||
const PxGeometry& geom0, const PxTransform& pose0,
|
||||
const PxGeometry& geom1, const PxTransform& pose1,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
|
||||
/**
|
||||
\brief Computes distance between a point and a geometry object.
|
||||
|
||||
Currently supported geometry objects: box, sphere, capsule, convex core, convex mesh, mesh.
|
||||
|
||||
\note For meshes, only the BVH34 midphase data-structure is supported.
|
||||
|
||||
\param[in] point The point P
|
||||
\param[in] geom The geometry object
|
||||
\param[in] pose Pose of the geometry object
|
||||
\param[out] closestPoint Optionally returned closest point to P on the geom object. Only valid when returned distance is strictly positive.
|
||||
\param[out] closestIndex Optionally returned closest (triangle) index. Only valid for triangle meshes.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return Square distance between the point and the geom object, or 0.0 if the point is inside the object, or -1.0 if an error occured (geometry type is not supported, or invalid pose)
|
||||
|
||||
\see PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static PxReal pointDistance(const PxVec3& point, const PxGeometry& geom, const PxTransform& pose,
|
||||
PxVec3* closestPoint=NULL, PxU32* closestIndex=NULL,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
|
||||
/**
|
||||
\brief computes the bounds for a geometry object
|
||||
|
||||
\param[out] bounds Returned computed bounds
|
||||
\param[in] geom The geometry object
|
||||
\param[in] pose Pose of the geometry object
|
||||
\param[in] offset Offset for computed bounds. This value is added to the geom's extents.
|
||||
\param[in] inflation Scale factor for computed bounds. The geom's extents are multiplied by this value.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
|
||||
\see PxGeometry PxTransform
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static void computeGeomBounds(PxBounds3& bounds, const PxGeometry& geom, const PxTransform& pose, float offset=0.0f, float inflation=1.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
|
||||
/**
|
||||
\brief Generate collision contacts between a convex geometry and a single triangle
|
||||
|
||||
\param[in] geom The geometry object. Can be a capsule, a box or a convex mesh
|
||||
\param[in] pose Pose of the geometry object
|
||||
\param[in] triangleVertices Triangle vertices in local space
|
||||
\param[in] triangleIndex Triangle index
|
||||
\param[in] contactDistance The distance at which contacts begin to be generated between the pairs
|
||||
\param[in] meshContactMargin The mesh contact margin.
|
||||
\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 write contacts to.
|
||||
|
||||
\return True if there was collision
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool generateTriangleContacts(const PxGeometry& geom, const PxTransform& pose, const PxVec3 triangleVertices[3], PxU32 triangleIndex, PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength, PxContactBuffer& contactBuffer);
|
||||
|
||||
/**
|
||||
\brief Checks if provided geometry is valid.
|
||||
|
||||
\param[in] geom The geometry object.
|
||||
\return True if geometry is valid.
|
||||
|
||||
\see PxGeometry
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool isValid(const PxGeometry& geom);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
74
engine/third_party/physx/include/geometry/PxGeometryQueryContext.h
vendored
Normal file
74
engine/third_party/physx/include/geometry/PxGeometryQueryContext.h
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// 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_GEOMETRY_QUERY_CONTEXT_H
|
||||
#define PX_GEOMETRY_QUERY_CONTEXT_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A per-thread context passed to low-level query functions.
|
||||
|
||||
This is a user-defined optional parameter that gets passed down to low-level query functions (raycast / overlap / sweep).
|
||||
|
||||
This is not used directly in PhysX, although the context in this case is the PxHitCallback used in the query. This allows
|
||||
user-defined query functions, such as the ones from PxCustomGeometry, to get some additional data about the query. In this
|
||||
case this is a 'per-query' context rather than 'per-thread', but the initial goal of this parameter is to give custom
|
||||
query callbacks access to per-thread data structures (e.g. caches) that could be needed to implement the callbacks.
|
||||
|
||||
In any case this is mostly for user-controlled query systems.
|
||||
*/
|
||||
struct PxQueryThreadContext
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A per-thread context passed to low-level raycast functions.
|
||||
*/
|
||||
typedef PxQueryThreadContext PxRaycastThreadContext;
|
||||
|
||||
/**
|
||||
\brief A per-thread context passed to low-level overlap functions.
|
||||
*/
|
||||
typedef PxQueryThreadContext PxOverlapThreadContext;
|
||||
|
||||
/**
|
||||
\brief A per-thread context passed to low-level sweep functions.
|
||||
*/
|
||||
typedef PxQueryThreadContext PxSweepThreadContext;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
engine/third_party/physx/include/geometry/PxGeometryQueryFlags.h
vendored
Normal file
68
engine/third_party/physx/include/geometry/PxGeometryQueryFlags.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_GEOMETRY_QUERY_FLAGS_H
|
||||
#define PX_GEOMETRY_QUERY_FLAGS_H
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Geometry-level query flags.
|
||||
|
||||
\see PxScene::raycast PxScene::overlap PxScene::sweep PxBVH::raycast PxBVH::overlap PxBVH::sweep PxGeometryQuery::raycast PxGeometryQuery::overlap PxGeometryQuery::sweep
|
||||
\see PxGeometryQuery::computePenetration PxGeometryQuery::pointDistance PxGeometryQuery::computeGeomBounds
|
||||
\see PxMeshQuery::findOverlapTriangleMesh PxMeshQuery::findOverlapHeightField PxMeshQuery::sweep
|
||||
*/
|
||||
struct PxGeometryQueryFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eSIMD_GUARD = (1<<0), //!< Saves/restores SIMD control word for each query (safer but slower). Omit this if you took care of it yourself in your app.
|
||||
|
||||
eDEFAULT = eSIMD_GUARD
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxGeometryQueryFlag.
|
||||
|
||||
\see PxGeometryQueryFlag
|
||||
*/
|
||||
PX_FLAGS_TYPEDEF(PxGeometryQueryFlag, PxU32)
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
143
engine/third_party/physx/include/geometry/PxGjkQuery.h
vendored
Normal file
143
engine/third_party/physx/include/geometry/PxGjkQuery.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_GJK_QUERY_H
|
||||
#define PX_GJK_QUERY_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Collection of GJK query functions (sweeps, raycasts, overlaps, ...).
|
||||
*/
|
||||
class PxGjkQuery
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Abstract interface for a user defined shape GJK mapping support.
|
||||
A user defined shape consists of a core shape and a margin. If the distance
|
||||
between two shapes' cores is equal to the sum of their margins, these shapes are
|
||||
considered touching.
|
||||
*/
|
||||
struct Support
|
||||
{
|
||||
virtual ~Support() {}
|
||||
/**
|
||||
\brief Return the user defined shape margin. Margin should be greater than or equal to 0
|
||||
|
||||
\return Margin.
|
||||
*/
|
||||
virtual PxReal getMargin() const = 0;
|
||||
/**
|
||||
\brief Return the farthest point on the user defined shape's core in given direction.
|
||||
|
||||
\param[in] dir Direction
|
||||
|
||||
\return Farthest point in given direction.
|
||||
*/
|
||||
virtual PxVec3 supportLocal(const PxVec3& dir) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Computes proximity information for 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 proximity info begins to be computed 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] pointA The closest/deepest point on shape A surface
|
||||
\param[out] pointB The closest/deepest point on shape B surface
|
||||
\param[out] separatingAxis Translating shape B along 'separatingAxis' by 'separation' makes the shapes touching
|
||||
\param[out] separation Translating shape B along 'separatingAxis' by 'separation' makes the shapes touching
|
||||
|
||||
\return False if the distance is greater than contactDistance.
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool proximityInfo(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB,
|
||||
PxReal contactDistance, PxReal toleranceLength, PxVec3& pointA, PxVec3& pointB, PxVec3& separatingAxis, PxReal& separation);
|
||||
|
||||
/**
|
||||
\brief Raycast test against the given shape.
|
||||
|
||||
\param[in] shape Shape support mapping
|
||||
\param[in] pose Shape transformation
|
||||
\param[in] rayStart The start point of the ray to test the shape against
|
||||
\param[in] unitDir Normalized direction of the ray to test the shape against
|
||||
\param[in] maxDist Maximum ray length, has to be in the [0, inf) range
|
||||
\param[out] t Hit distance
|
||||
\param[out] n Hit normal
|
||||
\param[out] p Hit point
|
||||
|
||||
\return True if there is a hit.
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool raycast(const Support& shape, const PxTransform& pose, const PxVec3& rayStart,
|
||||
const PxVec3& unitDir, PxReal maxDist, PxReal& t, PxVec3& n, PxVec3& p);
|
||||
|
||||
/**
|
||||
\brief Overlap test for two shapes.
|
||||
|
||||
\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
|
||||
|
||||
\return True if the shapes overlap.
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool overlap(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB);
|
||||
|
||||
/**
|
||||
\brief Sweep the shape B in space and test for collision with the shape A.
|
||||
|
||||
\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] unitDir Normalized direction of the ray to test the shape against
|
||||
\param[in] maxDist Maximum ray length, has to be in the [0, inf) range
|
||||
\param[out] t Hit distance
|
||||
\param[out] n Hit normal
|
||||
\param[out] p Hit point
|
||||
|
||||
\return True if there is a hit.
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool sweep(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB,
|
||||
const PxVec3& unitDir, PxReal maxDist, PxReal& t, PxVec3& n, PxVec3& p);
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
240
engine/third_party/physx/include/geometry/PxHeightField.h
vendored
Normal file
240
engine/third_party/physx/include/geometry/PxHeightField.h
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
// 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_HEIGHTFIELD_H
|
||||
#define PX_HEIGHTFIELD_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "geometry/PxHeightFieldFlag.h"
|
||||
#include "geometry/PxHeightFieldSample.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxHeightFieldDesc;
|
||||
|
||||
/**
|
||||
\brief A height field class.
|
||||
|
||||
Height fields work in a similar way as triangle meshes specified to act as
|
||||
height fields, with some important differences:
|
||||
|
||||
Triangle meshes can be made of nonuniform geometry, while height fields are
|
||||
regular, rectangular grids. This means that with PxHeightField, you sacrifice
|
||||
flexibility in return for improved performance and decreased memory consumption.
|
||||
|
||||
In local space rows extend in X direction, columns in Z direction and height in Y direction.
|
||||
|
||||
Like Convexes and TriangleMeshes, HeightFields are referenced by shape instances
|
||||
(see #PxHeightFieldGeometry, #PxShape).
|
||||
|
||||
To avoid duplicating data when you have several instances of a particular
|
||||
height field differently, you do not use this class to represent a
|
||||
height field object directly. Instead, you create an instance of this height field
|
||||
via the PxHeightFieldGeometry and PxShape classes.
|
||||
|
||||
<h3>Creation</h3>
|
||||
|
||||
To create an instance of this class call PxPhysics::createHeightField() or
|
||||
PxCooking::createHeightField(const PxHeightFieldDesc&, PxInsertionCallback&).
|
||||
To delete it call release(). This is only possible
|
||||
once you have released all of its PxHeightFiedShape instances.
|
||||
|
||||
<h3>Visualizations:</h3>
|
||||
\li #PxVisualizationParameter::eCOLLISION_AABBS
|
||||
\li #PxVisualizationParameter::eCOLLISION_SHAPES
|
||||
\li #PxVisualizationParameter::eCOLLISION_AXES
|
||||
\li #PxVisualizationParameter::eCOLLISION_FNORMALS
|
||||
\li #PxVisualizationParameter::eCOLLISION_EDGES
|
||||
|
||||
\see PxHeightFieldDesc PxHeightFieldGeometry PxShape PxPhysics.createHeightField() PxCooking.createHeightField()
|
||||
*/
|
||||
|
||||
class PxHeightField : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Decrements the reference count of a height field and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createHeightField() PxHeightFieldDesc PxHeightFieldGeometry PxShape
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Writes out the sample data array.
|
||||
|
||||
The user provides destBufferSize bytes storage at destBuffer.
|
||||
The data is formatted and arranged as PxHeightFieldDesc.samples.
|
||||
|
||||
\param[out] destBuffer The destination buffer for the sample data.
|
||||
\param[in] destBufferSize The size of the destination buffer.
|
||||
\return The number of bytes written.
|
||||
|
||||
\see PxHeightFieldDesc.samples
|
||||
*/
|
||||
virtual PxU32 saveCells(void* destBuffer, PxU32 destBufferSize) const = 0;
|
||||
|
||||
/**
|
||||
\brief Replaces a rectangular subfield in the sample data array.
|
||||
|
||||
The user provides the description of a rectangular subfield in subfieldDesc.
|
||||
The data is formatted and arranged as PxHeightFieldDesc.samples.
|
||||
|
||||
\param[in] startCol First cell in the destination heightfield to be modified. Can be negative.
|
||||
\param[in] startRow First row in the destination heightfield to be modified. Can be negative.
|
||||
\param[in] subfieldDesc Description of the source subfield to read the samples from.
|
||||
\param[in] shrinkBounds If left as false, the bounds will never shrink but only grow. If set to true the bounds will be recomputed from all HF samples at O(nbColums*nbRows) perf cost.
|
||||
\return True on success, false on failure. Failure can occur due to format mismatch.
|
||||
|
||||
\note Modified samples are constrained to the same height quantization range as the original heightfield.
|
||||
Source samples that are out of range of target heightfield will be clipped with no error.
|
||||
PhysX does not keep a mapping from the heightfield to heightfield shapes that reference it.
|
||||
Call PxShape::setGeometry on each shape which references the height field, to ensure that internal data structures are updated to reflect the new geometry.
|
||||
Please note that PxShape::setGeometry does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.
|
||||
|
||||
\see PxHeightFieldDesc.samples PxShape.setGeometry
|
||||
*/
|
||||
virtual bool modifySamples(PxI32 startCol, PxI32 startRow, const PxHeightFieldDesc& subfieldDesc, bool shrinkBounds = false) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the number of sample rows in the samples array.
|
||||
|
||||
\return The number of sample rows in the samples array.
|
||||
|
||||
\see PxHeightFieldDesc.nbRows
|
||||
*/
|
||||
virtual PxU32 getNbRows() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the number of sample columns in the samples array.
|
||||
|
||||
\return The number of sample columns in the samples array.
|
||||
|
||||
\see PxHeightFieldDesc.nbColumns
|
||||
*/
|
||||
virtual PxU32 getNbColumns() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the format of the sample data.
|
||||
|
||||
\return The format of the sample data.
|
||||
|
||||
\see PxHeightFieldDesc.format PxHeightFieldFormat
|
||||
*/
|
||||
virtual PxHeightFieldFormat::Enum getFormat() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the offset in bytes between consecutive samples in the array.
|
||||
|
||||
\return The offset in bytes between consecutive samples in the array.
|
||||
|
||||
\see PxHeightFieldDesc.sampleStride
|
||||
*/
|
||||
virtual PxU32 getSampleStride() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the convex edge threshold.
|
||||
|
||||
\return The convex edge threshold.
|
||||
|
||||
\see PxHeightFieldDesc.convexEdgeThreshold
|
||||
*/
|
||||
virtual PxReal getConvexEdgeThreshold() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the flags bits, combined from values of the enum ::PxHeightFieldFlag.
|
||||
|
||||
\return The flags bits, combined from values of the enum ::PxHeightFieldFlag.
|
||||
|
||||
\see PxHeightFieldDesc.flags PxHeightFieldFlag
|
||||
*/
|
||||
virtual PxHeightFieldFlags getFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the height at the given coordinates in grid space.
|
||||
|
||||
\return The height at the given coordinates or 0 if the coordinates are out of range.
|
||||
*/
|
||||
virtual PxReal getHeight(PxReal x, PxReal z) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns material table index of given triangle
|
||||
|
||||
\note This function takes a post cooking triangle index.
|
||||
|
||||
\param[in] triangleIndex (internal) index of desired triangle
|
||||
\return Material table index, or 0xffff if no per-triangle materials are used
|
||||
*/
|
||||
virtual PxMaterialTableIndex getTriangleMaterialIndex(PxTriangleID triangleIndex) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns a triangle face normal for a given triangle index
|
||||
|
||||
\note This function takes a post cooking triangle index.
|
||||
|
||||
\param[in] triangleIndex (internal) index of desired triangle
|
||||
\return Triangle normal for a given triangle index
|
||||
*/
|
||||
virtual PxVec3 getTriangleNormal(PxTriangleID triangleIndex) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns heightfield sample of given row and column
|
||||
|
||||
\param[in] row Given heightfield row
|
||||
\param[in] column Given heightfield column
|
||||
\return Heightfield sample
|
||||
*/
|
||||
virtual const PxHeightFieldSample& getSample(PxU32 row, PxU32 column) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of times the heightfield data has been modified
|
||||
|
||||
This method returns the number of times modifySamples has been called on this heightfield, so that code that has
|
||||
retained state that depends on the heightfield can efficiently determine whether it has been modified.
|
||||
|
||||
\return the number of times the heightfield sample data has been modified.
|
||||
*/
|
||||
virtual PxU32 getTimestamp() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE PX_FINAL { return "PxHeightField"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxHeightField(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxHeightField(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxHeightField() {}
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxHeightField", PxRefCounted); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
181
engine/third_party/physx/include/geometry/PxHeightFieldDesc.h
vendored
Normal file
181
engine/third_party/physx/include/geometry/PxHeightFieldDesc.h
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
// 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_HEIGHTFIELD_DESC_H
|
||||
#define PX_HEIGHTFIELD_DESC_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "geometry/PxHeightFieldFlag.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Descriptor class for #PxHeightField.
|
||||
|
||||
\note The heightfield data is *copied* when a PxHeightField object is created from this descriptor. After the call the
|
||||
user may discard the height data.
|
||||
|
||||
\see PxHeightField PxHeightFieldGeometry PxShape PxPhysics.createHeightField() PxCooking.createHeightField()
|
||||
*/
|
||||
class PxHeightFieldDesc
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Number of sample rows in the height field samples array.
|
||||
|
||||
\note Local space X-axis corresponds to rows.
|
||||
|
||||
<b>Range:</b> >1<br>
|
||||
<b>Default:</b> 0
|
||||
*/
|
||||
PxU32 nbRows;
|
||||
|
||||
/**
|
||||
\brief Number of sample columns in the height field samples array.
|
||||
|
||||
\note Local space Z-axis corresponds to columns.
|
||||
|
||||
<b>Range:</b> >1<br>
|
||||
<b>Default:</b> 0
|
||||
*/
|
||||
PxU32 nbColumns;
|
||||
|
||||
/**
|
||||
\brief Format of the sample data.
|
||||
|
||||
Currently the only supported format is PxHeightFieldFormat::eS16_TM:
|
||||
|
||||
<b>Default:</b> PxHeightFieldFormat::eS16_TM
|
||||
|
||||
\see PxHeightFormat PxHeightFieldDesc.samples
|
||||
*/
|
||||
PxHeightFieldFormat::Enum format;
|
||||
|
||||
/**
|
||||
\brief The samples array.
|
||||
|
||||
It is copied to the SDK's storage at creation time.
|
||||
|
||||
There are nbRows * nbColumn samples in the array,
|
||||
which define nbRows * nbColumn vertices and cells,
|
||||
of which (nbRows - 1) * (nbColumns - 1) cells are actually used.
|
||||
|
||||
The array index of sample(row, column) = row * nbColumns + column.
|
||||
The byte offset of sample(row, column) = sampleStride * (row * nbColumns + column).
|
||||
The sample data follows at the offset and spans the number of bytes defined by the format.
|
||||
Then there are zero or more unused bytes depending on sampleStride before the next sample.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
\see PxHeightFormat
|
||||
*/
|
||||
PxStridedData samples;
|
||||
|
||||
/**
|
||||
This threshold is used by the collision detection to determine if a height field edge is convex
|
||||
and can generate contact points.
|
||||
Usually the convexity of an edge is determined from the angle (or cosine of the angle) between
|
||||
the normals of the faces sharing that edge.
|
||||
The height field allows a more efficient approach by comparing height values of neighboring vertices.
|
||||
This parameter offsets the comparison. Smaller changes than 0.5 will not alter the set of convex edges.
|
||||
The rule of thumb is that larger values will result in fewer edge contacts.
|
||||
|
||||
This parameter is ignored in contact generation with sphere and capsule primitives.
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 0
|
||||
*/
|
||||
PxReal convexEdgeThreshold;
|
||||
|
||||
/**
|
||||
\brief Flags bits, combined from values of the enum ::PxHeightFieldFlag.
|
||||
|
||||
<b>Default:</b> 0
|
||||
|
||||
\see PxHeightFieldFlag PxHeightFieldFlags
|
||||
*/
|
||||
PxHeightFieldFlags flags;
|
||||
|
||||
/**
|
||||
\brief Constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxHeightFieldDesc();
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault();
|
||||
|
||||
/**
|
||||
\brief Returns true if the descriptor is valid.
|
||||
\return True if the current settings are valid.
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
};
|
||||
|
||||
PX_INLINE PxHeightFieldDesc::PxHeightFieldDesc() //constructor sets to default
|
||||
{
|
||||
nbColumns = 0;
|
||||
nbRows = 0;
|
||||
format = PxHeightFieldFormat::eS16_TM;
|
||||
convexEdgeThreshold = 0.0f;
|
||||
flags = PxHeightFieldFlags();
|
||||
}
|
||||
|
||||
PX_INLINE void PxHeightFieldDesc::setToDefault()
|
||||
{
|
||||
*this = PxHeightFieldDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxHeightFieldDesc::isValid() const
|
||||
{
|
||||
if (nbColumns < 2)
|
||||
return false;
|
||||
if (nbRows < 2)
|
||||
return false;
|
||||
if(format != PxHeightFieldFormat::eS16_TM)
|
||||
return false;
|
||||
if (samples.stride < 4)
|
||||
return false;
|
||||
if (convexEdgeThreshold < 0)
|
||||
return false;
|
||||
if ((flags & PxHeightFieldFlag::eNO_BOUNDARY_EDGES) != flags)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
156
engine/third_party/physx/include/geometry/PxHeightFieldFlag.h
vendored
Normal file
156
engine/third_party/physx/include/geometry/PxHeightFieldFlag.h
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
// 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_HEIGHT_FIELD_FLAG_H
|
||||
#define PX_HEIGHT_FIELD_FLAG_H
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Describes the format of height field samples.
|
||||
\see PxHeightFieldDesc.format PxHeightFieldDesc.samples
|
||||
*/
|
||||
struct PxHeightFieldFormat
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Height field height data is 16 bit signed integers, followed by triangle materials.
|
||||
|
||||
Each sample is 32 bits wide arranged as follows:
|
||||
|
||||
\image html heightFieldFormat_S16_TM.png
|
||||
|
||||
1) First there is a 16 bit height value.
|
||||
2) Next, two one byte material indices, with the high bit of each byte reserved for special use.
|
||||
(so the material index is only 7 bits).
|
||||
The high bit of material0 is the tess-flag.
|
||||
The high bit of material1 is reserved for future use.
|
||||
|
||||
There are zero or more unused bytes before the next sample depending on PxHeightFieldDesc.sampleStride,
|
||||
where the application may eventually keep its own data.
|
||||
|
||||
This is the only format supported at the moment.
|
||||
|
||||
\see PxHeightFieldDesc.format PxHeightFieldDesc.samples
|
||||
*/
|
||||
eS16_TM = (1 << 0)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Determines the tessellation of height field cells.
|
||||
\see PxHeightFieldDesc.format PxHeightFieldDesc.samples
|
||||
*/
|
||||
struct PxHeightFieldTessFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief This flag determines which way each quad cell is subdivided.
|
||||
|
||||
The flag lowered indicates subdivision like this: (the 0th vertex is referenced by only one triangle)
|
||||
|
||||
\image html heightfieldTriMat2.PNG
|
||||
|
||||
<pre>
|
||||
+--+--+--+---> column
|
||||
| /| /| /|
|
||||
|/ |/ |/ |
|
||||
+--+--+--+
|
||||
| /| /| /|
|
||||
|/ |/ |/ |
|
||||
+--+--+--+
|
||||
|
|
||||
|
|
||||
V row
|
||||
</pre>
|
||||
|
||||
The flag raised indicates subdivision like this: (the 0th vertex is shared by two triangles)
|
||||
|
||||
\image html heightfieldTriMat1.PNG
|
||||
|
||||
<pre>
|
||||
+--+--+--+---> column
|
||||
|\ |\ |\ |
|
||||
| \| \| \|
|
||||
+--+--+--+
|
||||
|\ |\ |\ |
|
||||
| \| \| \|
|
||||
+--+--+--+
|
||||
|
|
||||
|
|
||||
V row
|
||||
</pre>
|
||||
|
||||
\see PxHeightFieldDesc.format PxHeightFieldDesc.samples
|
||||
*/
|
||||
e0TH_VERTEX_SHARED = (1 << 0)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Enum with flag values to be used in PxHeightFieldDesc.flags.
|
||||
*/
|
||||
struct PxHeightFieldFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Disable collisions with height field with boundary edges.
|
||||
|
||||
Raise this flag if several terrain patches are going to be placed adjacent to each other,
|
||||
to avoid a bump when sliding across.
|
||||
|
||||
This flag is ignored in contact generation with sphere and capsule shapes.
|
||||
|
||||
\see PxHeightFieldDesc.flags
|
||||
*/
|
||||
eNO_BOUNDARY_EDGES = (1 << 0)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxHeightFieldFlag.
|
||||
|
||||
\see PxHeightFieldFlag
|
||||
*/
|
||||
typedef PxFlags<PxHeightFieldFlag::Enum,PxU16> PxHeightFieldFlags;
|
||||
PX_FLAGS_OPERATORS(PxHeightFieldFlag::Enum,PxU16)
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
159
engine/third_party/physx/include/geometry/PxHeightFieldGeometry.h
vendored
Normal file
159
engine/third_party/physx/include/geometry/PxHeightFieldGeometry.h
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
// 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_HEIGHT_FIELD_GEOMETRY_H
|
||||
#define PX_HEIGHT_FIELD_GEOMETRY_H
|
||||
#include "geometry/PxTriangleMeshGeometry.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#define PX_MIN_HEIGHTFIELD_XZ_SCALE 1e-8f
|
||||
#define PX_MIN_HEIGHTFIELD_Y_SCALE (0.0001f / PxReal(0xFFFF))
|
||||
|
||||
class PxHeightField;
|
||||
|
||||
/**
|
||||
\brief Height field geometry class.
|
||||
|
||||
This class allows to create a scaled height field geometry instance.
|
||||
|
||||
There is a minimum allowed value for Y and XZ scaling - PX_MIN_HEIGHTFIELD_XZ_SCALE, heightfield creation will fail if XZ value is below this value.
|
||||
*/
|
||||
class PxHeightFieldGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor.
|
||||
*/
|
||||
PX_INLINE PxHeightFieldGeometry(PxHeightField* hf = NULL,
|
||||
PxMeshGeometryFlags flags = PxMeshGeometryFlag::Enum(0),
|
||||
PxReal heightScale_ = 1.0f,
|
||||
PxReal rowScale_ = 1.0f,
|
||||
PxReal columnScale_ = 1.0f) :
|
||||
PxGeometry (PxGeometryType::eHEIGHTFIELD),
|
||||
heightField (hf),
|
||||
heightScale (heightScale_),
|
||||
rowScale (rowScale_),
|
||||
columnScale (columnScale_),
|
||||
heightFieldFlags (flags)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxHeightFieldGeometry(const PxHeightFieldGeometry& that) :
|
||||
PxGeometry (that),
|
||||
heightField (that.heightField),
|
||||
heightScale (that.heightScale),
|
||||
rowScale (that.rowScale),
|
||||
columnScale (that.columnScale),
|
||||
heightFieldFlags (that.heightFieldFlags)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxHeightFieldGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
heightField = that.heightField;
|
||||
heightScale = that.heightScale;
|
||||
rowScale = that.rowScale;
|
||||
columnScale = that.columnScale;
|
||||
heightFieldFlags = that.heightFieldFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid
|
||||
|
||||
\note A valid height field has a positive scale value in each direction (heightScale > 0, rowScale > 0, columnScale > 0).
|
||||
It is illegal to call PxPhysics::createShape with a height field that has zero extents in any direction.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief The height field data.
|
||||
*/
|
||||
PxHeightField* heightField;
|
||||
|
||||
/**
|
||||
\brief The scaling factor for the height field in vertical direction (y direction in local space).
|
||||
*/
|
||||
PxReal heightScale;
|
||||
|
||||
/**
|
||||
\brief The scaling factor for the height field in the row direction (x direction in local space).
|
||||
*/
|
||||
PxReal rowScale;
|
||||
|
||||
/**
|
||||
\brief The scaling factor for the height field in the column direction (z direction in local space).
|
||||
*/
|
||||
PxReal columnScale;
|
||||
|
||||
/**
|
||||
\brief Flags to specify some collision properties for the height field.
|
||||
*/
|
||||
PxMeshGeometryFlags heightFieldFlags;
|
||||
|
||||
PxPadding<3> paddingFromFlags; //!< padding for mesh flags.
|
||||
};
|
||||
|
||||
|
||||
PX_INLINE bool PxHeightFieldGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eHEIGHTFIELD)
|
||||
return false;
|
||||
if(!PxIsFinite(heightScale) || !PxIsFinite(rowScale) || !PxIsFinite(columnScale))
|
||||
return false;
|
||||
if(rowScale < PX_MIN_HEIGHTFIELD_XZ_SCALE || columnScale < PX_MIN_HEIGHTFIELD_XZ_SCALE || heightScale < PX_MIN_HEIGHTFIELD_Y_SCALE)
|
||||
return false;
|
||||
if(!heightField)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
112
engine/third_party/physx/include/geometry/PxHeightFieldSample.h
vendored
Normal file
112
engine/third_party/physx/include/geometry/PxHeightFieldSample.h
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
// 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_HEIGHT_FIELD_SAMPLE_H
|
||||
#define PX_HEIGHT_FIELD_SAMPLE_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxBitAndData.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Special material index values for height field samples.
|
||||
|
||||
\see PxHeightFieldSample.materialIndex0 PxHeightFieldSample.materialIndex1
|
||||
*/
|
||||
struct PxHeightFieldMaterial
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eHOLE = 127 //!< A material indicating that the triangle should be treated as a hole in the mesh.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Heightfield sample format.
|
||||
|
||||
This format corresponds to the #PxHeightFieldFormat member PxHeightFieldFormat::eS16_TM.
|
||||
|
||||
An array of heightfield samples are used when creating a PxHeightField to specify
|
||||
the elevation of the heightfield points. In addition the material and tessellation of the adjacent
|
||||
triangles are specified.
|
||||
|
||||
\see PxHeightField PxHeightFieldDesc PxHeightFieldDesc.samples
|
||||
*/
|
||||
struct PxHeightFieldSample
|
||||
{
|
||||
/**
|
||||
\brief The height of the heightfield sample
|
||||
|
||||
This value is scaled by PxHeightFieldGeometry::heightScale.
|
||||
|
||||
\see PxHeightFieldGeometry
|
||||
*/
|
||||
PxI16 height;
|
||||
|
||||
/**
|
||||
\brief The triangle material index of the quad's lower triangle + tesselation flag
|
||||
|
||||
An index pointing into the material table of the shape which instantiates the heightfield.
|
||||
This index determines the material of the lower of the quad's two triangles (i.e. the quad whose
|
||||
upper-left corner is this sample, see the Guide for illustrations).
|
||||
|
||||
Special values of the 7 data bits are defined by PxHeightFieldMaterial
|
||||
|
||||
The tesselation flag specifies which way the quad is split whose upper left corner is this sample.
|
||||
If the flag is set, the diagonal of the quad will run from this sample to the opposite vertex; if not,
|
||||
it will run between the other two vertices (see the Guide for illustrations).
|
||||
|
||||
\see PxHeightFieldGeometry materialIndex1 PxShape.setmaterials() PxShape.getMaterials()
|
||||
*/
|
||||
PxBitAndByte materialIndex0;
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 tessFlag() const { return PxU8(materialIndex0.isBitSet() ? 1 : 0); } // PT: explicit conversion to make sure we don't break the code
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE void setTessFlag() { materialIndex0.setBit(); }
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE void clearTessFlag() { materialIndex0.clearBit(); }
|
||||
|
||||
/**
|
||||
\brief The triangle material index of the quad's upper triangle + reserved flag
|
||||
|
||||
An index pointing into the material table of the shape which instantiates the heightfield.
|
||||
This index determines the material of the upper of the quad's two triangles (i.e. the quad whose
|
||||
upper-left corner is this sample, see the Guide for illustrations).
|
||||
|
||||
\see PxHeightFieldGeometry materialIndex0 PxShape.setmaterials() PxShape.getMaterials()
|
||||
*/
|
||||
PxBitAndByte materialIndex1;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
283
engine/third_party/physx/include/geometry/PxMeshQuery.h
vendored
Normal file
283
engine/third_party/physx/include/geometry/PxMeshQuery.h
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
// 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_MESH_QUERY_H
|
||||
#define PX_MESH_QUERY_H
|
||||
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "geometry/PxGeometryHit.h"
|
||||
#include "geometry/PxGeometryQueryFlags.h"
|
||||
#include "geometry/PxReportCallback.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxGeometry;
|
||||
class PxConvexMeshGeometry;
|
||||
class PxTriangleMeshGeometry;
|
||||
class PxHeightFieldGeometry;
|
||||
|
||||
class PxTriangle;
|
||||
|
||||
struct PxMeshMeshQueryFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDEFAULT = 0, //!< Report all overlaps
|
||||
eDISCARD_COPLANAR = (1<<0), //!< Ignore coplanar triangle-triangle overlaps
|
||||
eRESERVED = (1<<1), //!< Reserved flag
|
||||
eRESERVED1 = (1<<1), //!< Reserved flag
|
||||
eRESERVED2 = (1<<2), //!< Reserved flag
|
||||
eRESERVED3 = (1<<3) //!< Reserved flag
|
||||
};
|
||||
};
|
||||
|
||||
PX_FLAGS_TYPEDEF(PxMeshMeshQueryFlag, PxU32)
|
||||
|
||||
class PxMeshQuery
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Retrieves triangle data from a triangle ID.
|
||||
|
||||
This function can be used together with #findOverlapTriangleMesh() to retrieve triangle properties.
|
||||
|
||||
\param[in] triGeom Geometry of the triangle mesh to extract the triangle from.
|
||||
\param[in] transform Transform for the triangle mesh
|
||||
\param[in] triangleIndex The index of the triangle to retrieve.
|
||||
\param[out] triangle Triangle points in world space.
|
||||
\param[out] vertexIndices Returned vertex indices for given triangle
|
||||
\param[out] adjacencyIndices Returned 3 triangle adjacency internal face indices (0xFFFFFFFF if no adjacency). The mesh must be cooked with cooking param buildTriangleAdjacencies enabled.
|
||||
|
||||
\note This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.
|
||||
|
||||
\see PxTriangle PxTriangleFlags PxTriangleID findOverlapTriangleMesh()
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static void getTriangle(const PxTriangleMeshGeometry& triGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);
|
||||
|
||||
|
||||
/**
|
||||
\brief Retrieves triangle data from a triangle ID.
|
||||
|
||||
This function can be used together with #findOverlapHeightField() to retrieve triangle properties.
|
||||
|
||||
\param[in] hfGeom Geometry of the height field to extract the triangle from.
|
||||
\param[in] transform Transform for the height field.
|
||||
\param[in] triangleIndex The index of the triangle to retrieve.
|
||||
\param[out] triangle Triangle points in world space.
|
||||
\param[out] vertexIndices Returned vertex indices for given triangle
|
||||
\param[out] adjacencyIndices Returned 3 triangle adjacency triangle indices (0xFFFFFFFF if no adjacency).
|
||||
|
||||
\note This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.
|
||||
\note TriangleIndex is an index used in internal format, which does have an index out of the bounds in last row.
|
||||
To traverse all tri indices in the HF, the following code can be applied:
|
||||
for (PxU32 row = 0; row < (nbRows - 1); row++)
|
||||
{
|
||||
for (PxU32 col = 0; col < (nbCols - 1); col++)
|
||||
{
|
||||
for (PxU32 k = 0; k < 2; k++)
|
||||
{
|
||||
const PxU32 triIndex = 2 * (row*nbCols + col) + k;
|
||||
....
|
||||
}
|
||||
}
|
||||
}
|
||||
\see PxTriangle PxTriangleFlags PxTriangleID findOverlapHeightField()
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static void getTriangle(const PxHeightFieldGeometry& hfGeom, const PxTransform& transform, PxTriangleID triangleIndex, PxTriangle& triangle, PxU32* vertexIndices=NULL, PxU32* adjacencyIndices=NULL);
|
||||
|
||||
|
||||
/**
|
||||
\brief Find the mesh triangles which touch the specified geometry object.
|
||||
|
||||
For mesh-vs-mesh overlap tests, please use the specialized function below.
|
||||
|
||||
Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
|
||||
|
||||
\param[in] geom The geometry object to test for mesh triangle overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry
|
||||
\param[in] geomPose Pose of the geometry object
|
||||
\param[in] meshGeom The triangle mesh geometry to check overlap against
|
||||
\param[in] meshPose Pose of the triangle mesh
|
||||
\param[out] results Indices of overlapping triangles
|
||||
\param[in] maxResults Size of 'results' buffer
|
||||
\param[in] startIndex Index of first result to be retrieved. Previous indices are skipped.
|
||||
\param[out] overflow True if a buffer overflow occurred
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return Number of overlaps found, i.e. number of elements written to the results buffer
|
||||
|
||||
\see PxTriangleMeshGeometry getTriangle() PxGeometryQueryFlags
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static PxU32 findOverlapTriangleMesh( const PxGeometry& geom, const PxTransform& geomPose,
|
||||
const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose,
|
||||
PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
|
||||
/**
|
||||
\brief Mesh-vs-mesh overlap test
|
||||
|
||||
A specialized findOverlapTriangleMesh function for mesh-vs-mesh. The other findOverlapTriangleMesh() function above cannot be used
|
||||
directly since it only returns a single set of triangle indices that belongs to one of the meshes only. This function returns pairs
|
||||
of triangle indices that belong to both the first & second input meshes.
|
||||
|
||||
Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
|
||||
|
||||
\note This is only implemented for the PxMeshMidPhase::eBVH34 data structure.
|
||||
|
||||
\param[in] callback The callback object used to report results
|
||||
\param[in] meshGeom0 First triangle mesh geometry
|
||||
\param[in] meshPose0 Pose of first triangle mesh geometry
|
||||
\param[in] meshGeom1 Second triangle mesh geometry
|
||||
\param[in] meshPose1 Pose of second triangle mesh geometry
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\param[in] meshMeshFlags Optional flags controlling the query.
|
||||
\param[in] tolerance Optional tolerance distance
|
||||
\return true if an overlap has been detected, false if the meshes are disjoint
|
||||
|
||||
\see PxTriangleMeshGeometry getTriangle() PxReportCallback PxGeometryQueryFlags PxMeshMeshQueryFlags
|
||||
*/
|
||||
PX_DEPRECATED PX_PHYSX_COMMON_API static bool findOverlapTriangleMesh(PxReportCallback<PxGeomIndexPair>& callback,
|
||||
const PxTriangleMeshGeometry& meshGeom0, const PxTransform& meshPose0,
|
||||
const PxTriangleMeshGeometry& meshGeom1, const PxTransform& meshPose1,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
|
||||
PxMeshMeshQueryFlags meshMeshFlags = PxMeshMeshQueryFlag::eDEFAULT,
|
||||
float tolerance = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Mesh-vs-mesh overlap test
|
||||
|
||||
A specialized findOverlapTriangleMesh function for mesh-vs-mesh. The other findOverlapTriangleMesh() function above cannot be used
|
||||
directly since it only returns a single set of triangle indices that belongs to one of the meshes only. This function returns pairs
|
||||
of triangle indices that belong to both the first & second input meshes.
|
||||
|
||||
Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
|
||||
|
||||
If a non-zero tolerance is used, the function performs distance queries (rather than pure overlaps) between involved triangles,
|
||||
and returned data also includes the distance between reported triangles.
|
||||
|
||||
\note This is only implemented for the PxMeshMidPhase::eBVH34 data structure.
|
||||
|
||||
\param[in] callback The callback object used to report results
|
||||
\param[in] meshGeom0 First triangle mesh geometry
|
||||
\param[in] meshPose0 Pose of first triangle mesh geometry
|
||||
\param[in] meshGeom1 Second triangle mesh geometry
|
||||
\param[in] meshPose1 Pose of second triangle mesh geometry
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\param[in] meshMeshFlags Optional flags controlling the query.
|
||||
\param[in] tolerance Optional tolerance distance
|
||||
\return true if an overlap has been detected, false if the meshes are disjoint
|
||||
|
||||
\see PxTriangleMeshGeometry getTriangle() PxReportCallback PxGeometryQueryFlags PxMeshMeshQueryFlags
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool findOverlapTriangleMesh(PxReportCallback<PxGeomIndexClosePair>& callback,
|
||||
const PxTriangleMeshGeometry& meshGeom0, const PxTransform& meshPose0,
|
||||
const PxTriangleMeshGeometry& meshGeom1, const PxTransform& meshPose1,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
|
||||
PxMeshMeshQueryFlags meshMeshFlags = PxMeshMeshQueryFlag::eDEFAULT,
|
||||
float tolerance = 0.0f);
|
||||
|
||||
/**
|
||||
\brief Find the height field triangles which touch the specified geometry object.
|
||||
|
||||
Returned triangle indices can be used with #getTriangle() to retrieve the triangle properties.
|
||||
|
||||
\param[in] geom The geometry object to test for height field overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry. The sphere and capsule queries are currently conservative estimates.
|
||||
\param[in] geomPose Pose of the geometry object
|
||||
\param[in] hfGeom The height field geometry to check overlap against
|
||||
\param[in] hfPose Pose of the height field
|
||||
\param[out] results Indices of overlapping triangles
|
||||
\param[in] maxResults Size of 'results' buffer
|
||||
\param[in] startIndex Index of first result to be retrieved. Previous indices are skipped.
|
||||
\param[out] overflow True if a buffer overflow occurred
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return Number of overlaps found, i.e. number of elements written to the results buffer
|
||||
|
||||
\see PxHeightFieldGeometry getTriangle() PxGeometryQueryFlags
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static PxU32 findOverlapHeightField(const PxGeometry& geom, const PxTransform& geomPose,
|
||||
const PxHeightFieldGeometry& hfGeom, const PxTransform& hfPose,
|
||||
PxU32* results, PxU32 maxResults, PxU32 startIndex, bool& overflow,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
|
||||
|
||||
/**
|
||||
\brief Sweep a specified geometry object in space and test for collision with a set of given triangles.
|
||||
|
||||
This function simply sweeps input geometry against each input triangle, in the order they are given.
|
||||
This is an O(N) operation with N = number of input triangles. It does not use any particular acceleration structure.
|
||||
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be larger than 0. Clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[in] geom The geometry object to sweep. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry
|
||||
\param[in] pose Pose of the geometry object to sweep.
|
||||
\param[in] triangleCount Number of specified triangles
|
||||
\param[in] triangles Array of triangles to sweep against
|
||||
\param[out] sweepHit The sweep hit information. See the notes below for limitations about returned results.
|
||||
\param[in] hitFlags Specification of the kind of information to retrieve on hit. Combination of #PxHitFlag flags. See the notes below for limitations about supported flags.
|
||||
\param[in] cachedIndex Cached triangle index for subsequent calls. Cached triangle is tested first. Optional parameter.
|
||||
\param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
|
||||
\param[in] doubleSided Counterpart of PxMeshGeometryFlag::eDOUBLE_SIDED for input triangles.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
\return True if the swept geometry object hits the specified triangles
|
||||
|
||||
\note Only the following geometry types are currently supported: PxSphereGeometry, PxCapsuleGeometry, PxBoxGeometry
|
||||
\note If a shape from the scene is already overlapping with the query shape in its starting position, the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified.
|
||||
\note This function returns a single closest hit across all the input triangles. Multiple hits are not supported.
|
||||
\note Supported hitFlags are PxHitFlag::eDEFAULT, PxHitFlag::eASSUME_NO_INITIAL_OVERLAP, PxHitFlag::ePRECISE_SWEEP, PxHitFlag::eMESH_BOTH_SIDES, PxHitFlag::eANY_HIT.
|
||||
\note ePOSITION is only defined when there is no initial overlap (sweepHit.hadInitialOverlap() == false)
|
||||
\note The returned normal for initially overlapping sweeps is set to -unitDir.
|
||||
\note Otherwise the returned normal is the front normal of the triangle even if PxHitFlag::eMESH_BOTH_SIDES is set.
|
||||
\note The returned PxGeomSweepHit::faceIndex parameter will hold the index of the hit triangle in input array, i.e. the range is [0; triangleCount). For initially overlapping sweeps, this is the index of overlapping triangle.
|
||||
\note The inflation parameter is not compatible with PxHitFlag::ePRECISE_SWEEP.
|
||||
|
||||
\see PxTriangle PxSweepHit PxGeometry PxTransform PxGeometryQueryFlags
|
||||
*/
|
||||
PX_PHYSX_COMMON_API static bool sweep(const PxVec3& unitDir,
|
||||
const PxReal distance,
|
||||
const PxGeometry& geom,
|
||||
const PxTransform& pose,
|
||||
PxU32 triangleCount,
|
||||
const PxTriangle* triangles,
|
||||
PxGeomSweepHit& sweepHit,
|
||||
PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
|
||||
const PxU32* cachedIndex = NULL,
|
||||
const PxReal inflation = 0.0f,
|
||||
bool doubleSided = false,
|
||||
PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
162
engine/third_party/physx/include/geometry/PxMeshScale.h
vendored
Normal file
162
engine/third_party/physx/include/geometry/PxMeshScale.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_MESH_SCALE_H
|
||||
#define PX_MESH_SCALE_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
|
||||
/** \brief Minimum allowed absolute magnitude for each of mesh scale's components (x,y,z).
|
||||
\note Only positive scale values are allowed for convex meshes. */
|
||||
#define PX_MESH_SCALE_MIN 1e-6f
|
||||
|
||||
/** \brief Maximum allowed absolute magnitude for each of mesh scale's components (x,y,z).
|
||||
\note Only positive scale values are allowed for convex meshes. */
|
||||
#define PX_MESH_SCALE_MAX 1e6f
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A class expressing a nonuniform scaling transformation.
|
||||
|
||||
The scaling is along arbitrary axes that are specified by PxMeshScale::rotation. Specifically, PxMeshScale::rotation
|
||||
describes the rotation from the scaling-axes frame to the mesh-local frame, i.e. PxMeshScale::rotation.rotate(v) transforms
|
||||
the coordinates of vertex v from the mesh-local frame to the scaling-axes frame.
|
||||
|
||||
\note Negative scale values are supported for PxTriangleMeshGeometry
|
||||
with absolute values for each component within [PX_MIN_ABS_MESH_SCALE, PX_MAX_ABS_MESH_SCALE] range.
|
||||
Negative scale causes a reflection around the specified axis, in addition PhysX will flip the normals
|
||||
for mesh triangles when scale.x*scale.y*scale.z < 0.
|
||||
\note Only positive scale values are supported for PxConvexMeshGeometry
|
||||
with values for each component within [PX_MIN_ABS_MESH_SCALE, PX_MAX_ABS_MESH_SCALE] range).
|
||||
|
||||
\see PxConvexMeshGeometry PxTriangleMeshGeometry
|
||||
*/
|
||||
class PxMeshScale
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor initializes to identity scale.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(): scale(1.0f), rotation(PxIdentity)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Constructor from scalar.
|
||||
*/
|
||||
explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(PxReal r): scale(r), rotation(PxIdentity)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Constructor to initialize to arbitrary scale and identity scale rotation.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s)
|
||||
{
|
||||
scale = s;
|
||||
rotation = PxQuat(PxIdentity);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Constructor to initialize to arbitrary scaling.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s, const PxQuat& r)
|
||||
{
|
||||
PX_ASSERT(r.isUnit());
|
||||
scale = s;
|
||||
rotation = r;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the scaling is an identity transformation.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isIdentity() const
|
||||
{
|
||||
return (scale.x == 1.0f && scale.y == 1.0f && scale.z == 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the inverse of this scaling transformation.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale getInverse() const
|
||||
{
|
||||
return PxMeshScale(PxVec3(1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z), rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Converts this transformation to a 3x3 matrix representation.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 toMat33() const
|
||||
{
|
||||
PxMat33 rot(rotation);
|
||||
PxMat33 trans = rot.getTranspose();
|
||||
trans.column0 *= scale[0];
|
||||
trans.column1 *= scale[1];
|
||||
trans.column2 *= scale[2];
|
||||
return trans * rot;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if combination of negative scale components will cause the triangle normal to flip. The SDK will flip the normals internally.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNegativeDeterminant() const
|
||||
{
|
||||
return (scale.x * scale.y * scale.z < 0.0f);
|
||||
}
|
||||
|
||||
PxVec3 transform(const PxVec3& v) const
|
||||
{
|
||||
return rotation.rotateInv(scale.multiply(rotation.rotate(v)));
|
||||
}
|
||||
|
||||
bool isValidForTriangleMesh() const
|
||||
{
|
||||
PxVec3 absXYZ = scale.abs();
|
||||
return (absXYZ.maxElement() <= PX_MESH_SCALE_MAX) && (absXYZ.minElement() >= PX_MESH_SCALE_MIN);
|
||||
}
|
||||
|
||||
bool isValidForConvexMesh() const
|
||||
{
|
||||
return (scale.maxElement() <= PX_MESH_SCALE_MAX) && (scale.minElement() >= PX_MESH_SCALE_MIN);
|
||||
}
|
||||
|
||||
PxVec3 scale; //!< A nonuniform scaling
|
||||
PxQuat rotation; //!< The orientation of the scaling axes
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
95
engine/third_party/physx/include/geometry/PxParticleSystemGeometry.h
vendored
Normal file
95
engine/third_party/physx/include/geometry/PxParticleSystemGeometry.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
// 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_PARTICLESYSTEM_GEOMETRY_H
|
||||
#define PX_PARTICLESYSTEM_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
#include "PxParticleSystem.h"
|
||||
#include "PxParticleSolverType.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Particle system geometry class.
|
||||
|
||||
*/
|
||||
class PxParticleSystemGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Default constructor.
|
||||
|
||||
Creates an empty object with no particles.
|
||||
*/
|
||||
PX_INLINE PxParticleSystemGeometry() : PxGeometry(PxGeometryType::ePARTICLESYSTEM){}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxParticleSystemGeometry(const PxParticleSystemGeometry& that) : PxGeometry(that) {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxParticleSystemGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
mSolverType = that.mSolverType;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid for shape creation.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::ePARTICLESYSTEM)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PX_DEPRECATED PxParticleSolverType::Enum mSolverType;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
95
engine/third_party/physx/include/geometry/PxPlaneGeometry.h
vendored
Normal file
95
engine/third_party/physx/include/geometry/PxPlaneGeometry.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
// 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_PLANE_GEOMETRY_H
|
||||
#define PX_PLANE_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "foundation/PxFoundationConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Class describing a plane geometry.
|
||||
|
||||
The plane geometry specifies the half-space volume x<=0. As with other geometry types,
|
||||
when used in a PxShape the collision volume is obtained by transforming the halfspace
|
||||
by the shape local pose and the actor global pose.
|
||||
|
||||
To generate a PxPlane from a PxTransform, transform PxPlane(1,0,0,0).
|
||||
|
||||
To generate a PxTransform from a PxPlane, use PxTransformFromPlaneEquation.
|
||||
|
||||
\see PxShape.setGeometry() PxShape.getPlaneGeometry() PxTransformFromPlaneEquation
|
||||
*/
|
||||
class PxPlaneGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor.
|
||||
*/
|
||||
PX_INLINE PxPlaneGeometry() : PxGeometry(PxGeometryType::ePLANE) {}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxPlaneGeometry(const PxPlaneGeometry& that) : PxGeometry(that) {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxPlaneGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
};
|
||||
|
||||
PX_INLINE bool PxPlaneGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::ePLANE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
268
engine/third_party/physx/include/geometry/PxReportCallback.h
vendored
Normal file
268
engine/third_party/physx/include/geometry/PxReportCallback.h
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
// 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_REPORT_CALLBACK_H
|
||||
#define PX_REPORT_CALLBACK_H
|
||||
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Base class for all report callbacks.
|
||||
|
||||
\see PxRegularReportCallback PxLocalStorageReportCallback PxExternalStorageReportCallback PxDynamicArrayReportCallback
|
||||
*/
|
||||
class PxReportCallbackBase
|
||||
{
|
||||
public:
|
||||
PxReportCallbackBase(PxU32 capacity=0) : mCapacity(capacity), mSize(0) {}
|
||||
virtual ~PxReportCallbackBase() {}
|
||||
|
||||
PxU32 mCapacity; // Capacity of mBuffer. If mBuffer is NULL, this controls how many items are reported to users at the same time (with a limit of 256).
|
||||
PxU32 mSize; // Current number of items in the buffer. This is entirely managed by the system.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Base class for callback reporting an unknown number of items to users.
|
||||
|
||||
This can be used as-is and customized by users, or several pre-designed callbacks can be used instead (see below).
|
||||
|
||||
This design lets users decide how to retrieve the results of a query:
|
||||
- either one by one via a regular callback
|
||||
- or one batch at a time via a callback
|
||||
- or written out directly to their own C-style buffer
|
||||
- or pushed back to their own PxArray
|
||||
- etc
|
||||
|
||||
\see PxRegularReportCallback PxLocalStorageReportCallback PxExternalStorageReportCallback PxDynamicArrayReportCallback
|
||||
*/
|
||||
template<class T>
|
||||
class PxReportCallback : public PxReportCallbackBase
|
||||
{
|
||||
public:
|
||||
PxReportCallback(T* buffer=NULL, PxU32 capacity=0) : PxReportCallbackBase(capacity), mBuffer(buffer) {}
|
||||
virtual ~PxReportCallback() {}
|
||||
|
||||
T* mBuffer; // Destination buffer for writing results. if NULL, the system will use its internal buffer and set that pointer as it sees fit.
|
||||
// Otherwise users can set it to where they want the results to be written.
|
||||
|
||||
/**
|
||||
\brief Reports query results to users.
|
||||
|
||||
This will be called by the system as many times as necessary to report all results.
|
||||
|
||||
\param[in] nbItems Number of reported items
|
||||
\param[in] items array of reported items
|
||||
|
||||
\return true to continue the query, false to abort the query
|
||||
*/
|
||||
virtual bool flushResults(PxU32 nbItems, const T* items) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Regular report callback
|
||||
|
||||
This reports results like a regular callback would:
|
||||
- without explicit buffer management from users
|
||||
- by default, one item at a time
|
||||
|
||||
This customized callback sends results to users via the processResults() function.
|
||||
|
||||
The capacity parameter dictates how many items can be reported at a time,
|
||||
i.e. how many times the flushResults/processResults function will be called by the system.
|
||||
|
||||
\see PxReportCallback
|
||||
*/
|
||||
template<class T>
|
||||
class PxRegularReportCallback : public PxReportCallback<T>
|
||||
{
|
||||
public:
|
||||
PxRegularReportCallback(const PxU32 capacity=1)
|
||||
{
|
||||
PX_ASSERT(capacity<=256);
|
||||
this->mCapacity = capacity;
|
||||
}
|
||||
|
||||
virtual bool flushResults(PxU32 nbItems, const T* items)
|
||||
{
|
||||
PX_ASSERT(nbItems<=this->mCapacity);
|
||||
PX_ASSERT(items==this->mBuffer);
|
||||
return processResults(nbItems, items);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Reports query results to users.
|
||||
|
||||
\param[in] nbItems Number of reported items
|
||||
\param[in] items array of reported items
|
||||
|
||||
\return true to continue the query, false to abort the query
|
||||
*/
|
||||
virtual bool processResults(PxU32 nbItems, const T* items) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Local storage report callback
|
||||
|
||||
This is the same as a regular callback, except the destination buffer is a local buffer within the class.
|
||||
|
||||
This customized callback sends results to users via the processResults() function.
|
||||
|
||||
The capacity of the embedded buffer (determined by a template parameter) dictates how many items can be reported at a time,
|
||||
i.e. how many times the flushResults/processResults function will be called by the system.
|
||||
|
||||
\see PxReportCallback
|
||||
*/
|
||||
template<class T, const PxU32 capacityT>
|
||||
class PxLocalStorageReportCallback : public PxReportCallback<T>
|
||||
{
|
||||
T mLocalStorage[capacityT];
|
||||
|
||||
public:
|
||||
PxLocalStorageReportCallback()
|
||||
{
|
||||
this->mBuffer = mLocalStorage;
|
||||
this->mCapacity = capacityT;
|
||||
}
|
||||
|
||||
virtual bool flushResults(PxU32 nbItems, const T* items)
|
||||
{
|
||||
PX_ASSERT(items==mLocalStorage);
|
||||
PX_ASSERT(nbItems<=this->mCapacity);
|
||||
return processResults(nbItems, items);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Reports query results to users.
|
||||
|
||||
\param[in] nbItems Number of reported items
|
||||
\param[in] items array of reported items
|
||||
|
||||
\return true to continue the query, false to abort the query
|
||||
*/
|
||||
virtual bool processResults(PxU32 nbItems, const T* items) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief External storage report callback
|
||||
|
||||
This is the same as a regular callback, except the destination buffer is a user-provided external buffer.
|
||||
|
||||
Typically the provided buffer can be larger here than for PxLocalStorageReportCallback, and it could
|
||||
even be a scratchpad-kind of memory shared by multiple sub-systems.
|
||||
|
||||
This would be the same as having a C-style buffer to write out results in the query interface.
|
||||
|
||||
This customized callback sends results to users via the processResults() function.
|
||||
|
||||
The capacity parameter dictates how many items can be reported at a time,
|
||||
i.e. how many times the flushResults/processResults function will be called by the system.
|
||||
|
||||
\see PxReportCallback
|
||||
*/
|
||||
template<class T>
|
||||
class PxExternalStorageReportCallback : public PxReportCallback<T>
|
||||
{
|
||||
public:
|
||||
PxExternalStorageReportCallback(T* buffer, PxU32 capacity)
|
||||
{
|
||||
this->mBuffer = buffer;
|
||||
this->mCapacity = capacity;
|
||||
}
|
||||
|
||||
virtual bool flushResults(PxU32 nbItems, const T* items)
|
||||
{
|
||||
PX_ASSERT(items==this->mBuffer);
|
||||
PX_ASSERT(nbItems<=this->mCapacity);
|
||||
return processResults(nbItems, items);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Reports query results to users.
|
||||
|
||||
\param[in] nbItems Number of reported items
|
||||
\param[in] items array of reported items
|
||||
|
||||
\return true to continue the query, false to abort the query
|
||||
*/
|
||||
virtual bool processResults(PxU32 nbItems, const T* items) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Dynamic array report callback
|
||||
|
||||
This callback emulates the behavior of pushing results to a (user-provided) dynamic array.
|
||||
|
||||
This customized callback does not actually call users back during the query, results are
|
||||
available afterwards in the provided dynamic array. This would be the same as having a PxArray
|
||||
directly in the query interface.
|
||||
|
||||
\see PxReportCallback
|
||||
*/
|
||||
template<class T>
|
||||
class PxDynamicArrayReportCallback : public PxReportCallback<T>
|
||||
{
|
||||
public:
|
||||
PxDynamicArrayReportCallback(PxArray<T>& results) : mResults(results)
|
||||
{
|
||||
mResults.reserve(32);
|
||||
this->mBuffer = mResults.begin();
|
||||
this->mCapacity = mResults.capacity();
|
||||
}
|
||||
|
||||
virtual bool flushResults(PxU32 nbItems, const T* /*items*/)
|
||||
{
|
||||
const PxU32 size = mResults.size();
|
||||
const PxU32 capa = mResults.capacity();
|
||||
const PxU32 newSize = size+nbItems;
|
||||
PX_ASSERT(newSize<=capa);
|
||||
mResults.forceSize_Unsafe(newSize);
|
||||
if(newSize==capa)
|
||||
{
|
||||
const PxU32 newCapa = capa*2;
|
||||
mResults.reserve(newCapa);
|
||||
this->mBuffer = mResults.begin() + newSize;
|
||||
this->mCapacity = mResults.capacity() - newSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PxArray<T>& mResults;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
160
engine/third_party/physx/include/geometry/PxSimpleTriangleMesh.h
vendored
Normal file
160
engine/third_party/physx/include/geometry/PxSimpleTriangleMesh.h
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
// 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_TRIANGLE_MESH_H
|
||||
#define PX_SIMPLE_TRIANGLE_MESH_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Enum with flag values to be used in PxSimpleTriangleMesh::flags.
|
||||
*/
|
||||
struct PxMeshFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Specifies if the SDK should flip normals.
|
||||
|
||||
The PhysX libraries assume that the face normal of a triangle with vertices [a,b,c] can be computed as:
|
||||
edge1 = b-a
|
||||
edge2 = c-a
|
||||
face_normal = edge1 x edge2.
|
||||
|
||||
Note: This is the same as a counterclockwise winding in a right handed coordinate system or
|
||||
alternatively a clockwise winding order in a left handed coordinate system.
|
||||
|
||||
If this does not match the winding order for your triangles, raise the below flag.
|
||||
*/
|
||||
eFLIPNORMALS = (1<<0),
|
||||
e16_BIT_INDICES = (1<<1) //!< Denotes the use of 16-bit vertex indices
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxMeshFlag.
|
||||
|
||||
\see PxMeshFlag
|
||||
*/
|
||||
typedef PxFlags<PxMeshFlag::Enum,PxU16> PxMeshFlags;
|
||||
PX_FLAGS_OPERATORS(PxMeshFlag::Enum,PxU16)
|
||||
|
||||
|
||||
/**
|
||||
\brief A structure describing a triangle mesh.
|
||||
*/
|
||||
class PxSimpleTriangleMesh
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Pointer to first vertex point.
|
||||
*/
|
||||
PxBoundedData points;
|
||||
|
||||
/**
|
||||
\brief Pointer to first triangle.
|
||||
|
||||
Caller may add triangleStrideBytes bytes to the pointer to access the next triangle.
|
||||
|
||||
These are triplets of 0 based indices:
|
||||
vert0 vert1 vert2
|
||||
vert0 vert1 vert2
|
||||
vert0 vert1 vert2
|
||||
...
|
||||
|
||||
where vertex is either a 32 or 16 bit unsigned integer. There are numTriangles*3 indices.
|
||||
|
||||
This is declared as a void pointer because it is actually either an PxU16 or a PxU32 pointer.
|
||||
*/
|
||||
PxBoundedData triangles;
|
||||
|
||||
/**
|
||||
\brief Flags bits, combined from values of the enum ::PxMeshFlag
|
||||
*/
|
||||
PxMeshFlags flags;
|
||||
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxSimpleTriangleMesh();
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault();
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
};
|
||||
|
||||
|
||||
PX_INLINE PxSimpleTriangleMesh::PxSimpleTriangleMesh()
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE void PxSimpleTriangleMesh::setToDefault()
|
||||
{
|
||||
*this = PxSimpleTriangleMesh();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxSimpleTriangleMesh::isValid() const
|
||||
{
|
||||
// Check geometry
|
||||
if(points.count > 0xffff && flags & PxMeshFlag::e16_BIT_INDICES)
|
||||
return false;
|
||||
if(!points.data)
|
||||
return false;
|
||||
if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
|
||||
return false;
|
||||
|
||||
// Check topology
|
||||
// The triangles pointer is not mandatory
|
||||
if(triangles.data)
|
||||
{
|
||||
// Indexed mesh
|
||||
PxU32 limit = (flags & PxMeshFlag::e16_BIT_INDICES) ? sizeof(PxU16)*3 : sizeof(PxU32)*3;
|
||||
if(triangles.stride < limit)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
104
engine/third_party/physx/include/geometry/PxSphereGeometry.h
vendored
Normal file
104
engine/third_party/physx/include/geometry/PxSphereGeometry.h
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// 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_SPHERE_GEOMETRY_H
|
||||
#define PX_SPHERE_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A class representing the geometry of a sphere.
|
||||
|
||||
Spheres are defined by their radius.
|
||||
\note The scaling of the sphere is expected to be baked into this value, there is no additional scaling parameter.
|
||||
*/
|
||||
class PxSphereGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor.
|
||||
*/
|
||||
PX_INLINE PxSphereGeometry(PxReal ir=0.0f) : PxGeometry(PxGeometryType::eSPHERE), radius(ir) {}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxSphereGeometry(const PxSphereGeometry& that) : PxGeometry(that), radius(that.radius) {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxSphereGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
radius = that.radius;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid
|
||||
|
||||
\note A valid sphere has radius > 0.
|
||||
It is illegal to call PxPhysics::createShape with a sphere that has zero radius.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief The radius of the sphere.
|
||||
*/
|
||||
PxReal radius;
|
||||
};
|
||||
|
||||
PX_INLINE bool PxSphereGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eSPHERE)
|
||||
return false;
|
||||
if(!PxIsFinite(radius))
|
||||
return false;
|
||||
if(radius <= 0.0f)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
107
engine/third_party/physx/include/geometry/PxTetrahedron.h
vendored
Normal file
107
engine/third_party/physx/include/geometry/PxTetrahedron.h
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// 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_H
|
||||
#define PX_TETRAHEDRON_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Tetrahedron class.
|
||||
*/
|
||||
class PxTetrahedron
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_FORCE_INLINE PxTetrahedron() {}
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
|
||||
\param[in] p0 Point 0
|
||||
\param[in] p1 Point 1
|
||||
\param[in] p2 Point 2
|
||||
\param[in] p3 Point 3
|
||||
*/
|
||||
PX_FORCE_INLINE PxTetrahedron(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const PxVec3& p3)
|
||||
{
|
||||
verts[0] = p0;
|
||||
verts[1] = p1;
|
||||
verts[2] = p2;
|
||||
verts[3] = p3;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor
|
||||
|
||||
\param[in] tetrahedron copy
|
||||
*/
|
||||
PX_FORCE_INLINE PxTetrahedron(const PxTetrahedron& tetrahedron)
|
||||
{
|
||||
verts[0] = tetrahedron.verts[0];
|
||||
verts[1] = tetrahedron.verts[1];
|
||||
verts[2] = tetrahedron.verts[2];
|
||||
verts[3] = tetrahedron.verts[3];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Destructor
|
||||
*/
|
||||
PX_FORCE_INLINE ~PxTetrahedron() {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_FORCE_INLINE void operator=(const PxTetrahedron& tetrahedron)
|
||||
{
|
||||
verts[0] = tetrahedron.verts[0];
|
||||
verts[1] = tetrahedron.verts[1];
|
||||
verts[2] = tetrahedron.verts[2];
|
||||
verts[3] = tetrahedron.verts[3];
|
||||
}
|
||||
/**
|
||||
\brief Array of Vertices.
|
||||
*/
|
||||
PxVec3 verts[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
392
engine/third_party/physx/include/geometry/PxTetrahedronMesh.h
vendored
Normal file
392
engine/third_party/physx/include/geometry/PxTetrahedronMesh.h
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
// 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_H
|
||||
#define PX_TETRAHEDRON_MESH_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxTetrahedronMeshFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
e16_BIT_INDICES = (1 << 1) //!< The tetrahedron mesh has 16bits vertex indices
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxTetrahedronMeshFlag.
|
||||
|
||||
\see PxTetrahedronMeshFlag
|
||||
*/
|
||||
typedef PxFlags<PxTetrahedronMeshFlag::Enum, PxU8> PxTetrahedronMeshFlags;
|
||||
PX_FLAGS_OPERATORS(PxTetrahedronMeshFlag::Enum, PxU8)
|
||||
|
||||
|
||||
/**
|
||||
\brief A data container providing mass, rest pose and other information required for deformable simulation
|
||||
|
||||
Stores properties of deformable volume like inverse mass per node, rest pose matrix per tetrahedral element etc.
|
||||
Mainly used internally to store runtime data.
|
||||
|
||||
*/
|
||||
class PxDeformableVolumeAuxData : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Decrements the reference count of a tetrahedron mesh and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createTetrahedronMesh()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Get the inverse mass of each vertex of the tetrahedron mesh.
|
||||
|
||||
\return PxReal* A pointer to an array of inverse mass for each vertex of the tetrahedron mesh. Size: number of vertices * sizeof(PxReal).
|
||||
*/
|
||||
virtual PxReal* getGridModelInvMass() = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxDeformableVolumeAuxData(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxDeformableVolumeAuxData(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxDeformableVolumeAuxData() {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxDeformableVolumeAuxData", PxRefCounted); }
|
||||
};
|
||||
|
||||
typedef PX_DEPRECATED PxDeformableVolumeAuxData PxSoftBodyAuxData;
|
||||
|
||||
/**
|
||||
\brief A tetramedron mesh, also called a 'tetrahedron soup'.
|
||||
|
||||
It is represented as an indexed tetrahedron list. There are no restrictions on the
|
||||
tetrahedron data.
|
||||
|
||||
To avoid duplicating data when you have several instances of a particular
|
||||
mesh positioned differently, you do not use this class to represent a
|
||||
mesh object directly. Instead, you create an instance of this mesh via
|
||||
the PxTetrahedronMeshGeometry and PxShape classes.
|
||||
|
||||
<h3>Creation</h3>
|
||||
|
||||
To create an instance of this class call PxPhysics::createTetrahedronMesh(),
|
||||
and release() to delete it. This is only possible
|
||||
once you have released all of its PxShape instances.
|
||||
|
||||
|
||||
<h3>Visualizations:</h3>
|
||||
\li #PxVisualizationParameter::eCOLLISION_AABBS
|
||||
\li #PxVisualizationParameter::eCOLLISION_SHAPES
|
||||
\li #PxVisualizationParameter::eCOLLISION_AXES
|
||||
\li #PxVisualizationParameter::eCOLLISION_FNORMALS
|
||||
\li #PxVisualizationParameter::eCOLLISION_EDGES
|
||||
|
||||
\see PxTetrahedronMeshDesc PxTetrahedronMeshGeometry PxShape PxPhysics.createTetrahedronMesh()
|
||||
*/
|
||||
class PxTetrahedronMesh : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Returns the number of vertices.
|
||||
\return number of vertices
|
||||
\see getVertices()
|
||||
*/
|
||||
virtual PxU32 getNbVertices() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the vertices
|
||||
\return array of vertices
|
||||
\see getNbVertices()
|
||||
*/
|
||||
virtual const PxVec3* getVertices() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Returns the number of tetrahedrons.
|
||||
\return number of tetrahedrons
|
||||
\see getTetrahedrons()
|
||||
*/
|
||||
virtual PxU32 getNbTetrahedrons() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the tetrahedron indices.
|
||||
|
||||
The indices can be 16 or 32bit depending on the number of tetrahedrons in the mesh.
|
||||
Call getTetrahedronMeshFlags() to know if the indices are 16 or 32 bits.
|
||||
|
||||
The number of indices is the number of tetrahedrons * 4.
|
||||
|
||||
\return array of tetrahedrons
|
||||
\see getNbTetrahedron() getTetrahedronMeshFlags() getTetrahedraRemap()
|
||||
*/
|
||||
virtual const void* getTetrahedrons() const = 0;
|
||||
|
||||
/**
|
||||
\brief Reads the PxTetrahedronMesh flags.
|
||||
|
||||
See the list of flags #PxTetrahedronMeshFlags
|
||||
|
||||
\return The values of the PxTetrahedronMesh flags.
|
||||
*/
|
||||
virtual PxTetrahedronMeshFlags getTetrahedronMeshFlags() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Returns the tetrahedra remapping table.
|
||||
|
||||
The tetrahedra are internally sorted according to various criteria. Hence the internal tetrahedron order
|
||||
does not always match the original (user-defined) order. The remapping table helps finding the old
|
||||
indices knowing the new ones:
|
||||
|
||||
remapTable[ internalTetrahedronIndex ] = originalTetrahedronIndex
|
||||
|
||||
\return the remapping table (or NULL if 'PxCookingParams::suppressTriangleMeshRemapTable' has been used)
|
||||
\see getNbTetrahedron() getTetrahedrons() PxCookingParams::suppressTriangleMeshRemapTable
|
||||
*/
|
||||
virtual const PxU32* getTetrahedraRemap() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the local-space (vertex space) AABB from the tetrahedron mesh.
|
||||
|
||||
\return local-space bounds
|
||||
*/
|
||||
virtual PxBounds3 getLocalBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of a tetrahedron mesh and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createTetrahedronMesh()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxTetrahedronMesh(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxTetrahedronMesh(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxTetrahedronMesh() {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxTetrahedronMesh", PxRefCounted); }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A deformable volume mesh, containing structures to store collision shape, simulation shape and deformation state
|
||||
|
||||
The class bundles shapes and deformation state of a deformable volume that is simulated using FEM. The meshes used for
|
||||
collision detection and for the FEM calculations are both tetrahedral meshes. While collision detection requires
|
||||
a mesh that matches the surface of the simulated body as exactly as possible, the simulation mesh has more freedom
|
||||
such that it can be optimized for tetrahedra without small angles and nodes that aren't shared by too many elements.
|
||||
|
||||
<h3>Creation</h3>
|
||||
|
||||
To create an instance of this class call PxPhysics::createDeformableVolumeMesh(),
|
||||
and release() to delete it. This is only possible
|
||||
once you have released all of its PxShape instances.
|
||||
|
||||
*/
|
||||
class PxDeformableVolumeMesh : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Const accecssor to the deformable volume's collision mesh.
|
||||
|
||||
\see PxTetrahedronMesh
|
||||
*/
|
||||
virtual const PxTetrahedronMesh* getCollisionMesh() const = 0;
|
||||
|
||||
/**
|
||||
\brief Accecssor to the deformable volume's collision mesh.
|
||||
|
||||
\see PxTetrahedronMesh
|
||||
*/
|
||||
virtual PxTetrahedronMesh* getCollisionMesh() = 0;
|
||||
|
||||
/**
|
||||
\brief Const accessor to the deformable volume's simulation mesh.
|
||||
|
||||
\see PxTetrahedronMesh
|
||||
*/
|
||||
virtual const PxTetrahedronMesh* getSimulationMesh() const = 0;
|
||||
|
||||
/**
|
||||
\brief Accecssor to the deformable volume's simulation mesh.
|
||||
|
||||
\see PxTetrahedronMesh
|
||||
*/
|
||||
virtual PxTetrahedronMesh* getSimulationMesh() = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Const accessor to the deformable volume's simulation state.
|
||||
|
||||
\see PxDeformableVolumeAuxData
|
||||
*/
|
||||
virtual const PxDeformableVolumeAuxData* getDeformableVolumeAuxData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see getDeformableVolumeAuxData
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE const PxDeformableVolumeAuxData* getSoftBodyAuxData() const
|
||||
{
|
||||
return getDeformableVolumeAuxData();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Accessor to the deformable volume's auxilary data like mass and rest pose information
|
||||
|
||||
\see PxDeformableVolumeAuxData
|
||||
*/
|
||||
virtual PxDeformableVolumeAuxData* getDeformableVolumeAuxData() = 0;
|
||||
|
||||
/**
|
||||
\brief Deprecated
|
||||
\see getDeformableVolumeAuxData
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE PxDeformableVolumeAuxData* getSoftBodyAuxData()
|
||||
{
|
||||
return getDeformableVolumeAuxData();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of a tetrahedron mesh and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createTetrahedronMesh()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
|
||||
protected:
|
||||
PX_INLINE PxDeformableVolumeMesh(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxDeformableVolumeMesh(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxDeformableVolumeMesh() {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxDeformableVolumeMesh", PxRefCounted); }
|
||||
};
|
||||
|
||||
typedef PX_DEPRECATED PxDeformableVolumeMesh PxSoftBodyMesh;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
\brief Contains information about how to update the collision mesh's vertices given a deformed simulation tetmesh.
|
||||
|
||||
\see PxTetrahedronMeshData
|
||||
*/
|
||||
class PxCollisionMeshMappingData : public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual ~PxCollisionMeshMappingData() {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
\brief Stores data to accelerate collision detection of a tetrahedral mesh
|
||||
|
||||
\see PxTetrahedronMeshData
|
||||
*/
|
||||
class PxDeformableVolumeCollisionData : public PxUserAllocated
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
typedef PX_DEPRECATED PxDeformableVolumeCollisionData PxSoftBodyCollisionData;
|
||||
|
||||
/**
|
||||
|
||||
\brief Contains raw geometry information describing the tetmesh's vertices and its elements (tetrahedra)
|
||||
|
||||
\see PxTetrahedronMeshData
|
||||
*/
|
||||
class PxTetrahedronMeshData : public PxUserAllocated
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
\brief Stores data to compute and store the state of a deformed tetrahedral mesh
|
||||
|
||||
\see PxTetrahedronMeshData
|
||||
*/
|
||||
class PxDeformableVolumeSimulationData : public PxUserAllocated
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
typedef PX_DEPRECATED PxDeformableVolumeSimulationData PxSoftBodySimulationData;
|
||||
|
||||
/**
|
||||
|
||||
\brief Conbines PxTetrahedronMeshData and PxDeformableVolumeCollisionData
|
||||
|
||||
\see PxTetrahedronMeshData PxDeformableVolumeCollisionData
|
||||
*/
|
||||
class PxCollisionTetrahedronMeshData : public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
virtual const PxTetrahedronMeshData* getMesh() const = 0;
|
||||
virtual PxTetrahedronMeshData* getMesh() = 0;
|
||||
virtual const PxDeformableVolumeCollisionData* getData() const = 0;
|
||||
virtual PxDeformableVolumeCollisionData* getData() = 0;
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual ~PxCollisionTetrahedronMeshData() {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
\brief Conbines PxTetrahedronMeshData and PxDeformableVolumeSimulationData
|
||||
|
||||
\see PxTetrahedronMeshData PxDeformableVolumeSimulationData
|
||||
*/
|
||||
class PxSimulationTetrahedronMeshData : public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
virtual PxTetrahedronMeshData* getMesh() = 0;
|
||||
virtual PxDeformableVolumeSimulationData* getData() = 0;
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual ~PxSimulationTetrahedronMeshData() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
107
engine/third_party/physx/include/geometry/PxTetrahedronMeshGeometry.h
vendored
Normal file
107
engine/third_party/physx/include/geometry/PxTetrahedronMeshGeometry.h
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// 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_GEOMETRY_H
|
||||
#define PX_TETRAHEDRON_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxMeshScale.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
class PxTetrahedronMesh;
|
||||
|
||||
/**
|
||||
\brief Tetrahedron mesh geometry class.
|
||||
|
||||
This class wraps a tetrahedron mesh such that it can be used in contexts where a PxGeometry type is needed.
|
||||
*/
|
||||
class PxTetrahedronMeshGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor. By default creates an empty object with a NULL mesh and identity scale.
|
||||
*/
|
||||
PX_INLINE PxTetrahedronMeshGeometry(PxTetrahedronMesh* mesh = NULL) :
|
||||
PxGeometry(PxGeometryType::eTETRAHEDRONMESH),
|
||||
tetrahedronMesh(mesh)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxTetrahedronMeshGeometry(const PxTetrahedronMeshGeometry& that) :
|
||||
PxGeometry(that),
|
||||
tetrahedronMesh(that.tetrahedronMesh)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxTetrahedronMeshGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
tetrahedronMesh = that.tetrahedronMesh;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid for shape creation.
|
||||
|
||||
\note A valid tetrahedron mesh has a positive scale value in each direction (scale.scale.x > 0, scale.scale.y > 0, scale.scale.z > 0).
|
||||
It is illegal to call PxPhysics::createShape with a tetrahedron mesh that has zero extents in any direction.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
PxTetrahedronMesh* tetrahedronMesh; //!< A reference to the mesh object.
|
||||
};
|
||||
|
||||
PX_INLINE bool PxTetrahedronMeshGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eTETRAHEDRONMESH)
|
||||
return false;
|
||||
|
||||
if(!tetrahedronMesh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
153
engine/third_party/physx/include/geometry/PxTriangle.h
vendored
Normal file
153
engine/third_party/physx/include/geometry/PxTriangle.h
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
// 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_H
|
||||
#define PX_TRIANGLE_H
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Triangle class.
|
||||
*/
|
||||
class PxTriangle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_FORCE_INLINE PxTriangle() {}
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
|
||||
\param[in] p0 Point 0
|
||||
\param[in] p1 Point 1
|
||||
\param[in] p2 Point 2
|
||||
*/
|
||||
PX_FORCE_INLINE PxTriangle(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2)
|
||||
{
|
||||
verts[0] = p0;
|
||||
verts[1] = p1;
|
||||
verts[2] = p2;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor
|
||||
|
||||
\param[in] triangle Tri to copy
|
||||
*/
|
||||
PX_FORCE_INLINE PxTriangle(const PxTriangle& triangle)
|
||||
{
|
||||
verts[0] = triangle.verts[0];
|
||||
verts[1] = triangle.verts[1];
|
||||
verts[2] = triangle.verts[2];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Destructor
|
||||
*/
|
||||
PX_FORCE_INLINE ~PxTriangle() {}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_FORCE_INLINE void operator=(const PxTriangle& triangle)
|
||||
{
|
||||
verts[0] = triangle.verts[0];
|
||||
verts[1] = triangle.verts[1];
|
||||
verts[2] = triangle.verts[2];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the normal of the Triangle.
|
||||
|
||||
\param[out] _normal Triangle normal.
|
||||
*/
|
||||
PX_FORCE_INLINE void normal(PxVec3& _normal) const
|
||||
{
|
||||
_normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
|
||||
_normal.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the unnormalized normal of the triangle.
|
||||
|
||||
\param[out] _normal Triangle normal (not normalized).
|
||||
*/
|
||||
PX_FORCE_INLINE void denormalizedNormal(PxVec3& _normal) const
|
||||
{
|
||||
_normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the area of the triangle.
|
||||
|
||||
\return Area of the triangle.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal area() const
|
||||
{
|
||||
const PxVec3& p0 = verts[0];
|
||||
const PxVec3& p1 = verts[1];
|
||||
const PxVec3& p2 = verts[2];
|
||||
return ((p0 - p1).cross(p0 - p2)).magnitude() * 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
\return Computes a point on the triangle from u and v barycentric coordinates.
|
||||
*/
|
||||
PX_FORCE_INLINE PxVec3 pointFromUV(PxReal u, PxReal v) const
|
||||
{
|
||||
return (1.0f-u-v)*verts[0] + u*verts[1] + v*verts[2];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Array of Vertices.
|
||||
*/
|
||||
PxVec3 verts[3];
|
||||
};
|
||||
|
||||
//! A padded version of PxTriangle, to safely load its data using SIMD
|
||||
class PxTrianglePadded : public PxTriangle
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE PxTrianglePadded() {}
|
||||
PX_FORCE_INLINE ~PxTrianglePadded() {}
|
||||
PxU32 padding;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
335
engine/third_party/physx/include/geometry/PxTriangleMesh.h
vendored
Normal file
335
engine/third_party/physx/include/geometry/PxTriangleMesh.h
vendored
Normal file
@@ -0,0 +1,335 @@
|
||||
// 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_H
|
||||
#define PX_TRIANGLE_MESH_H
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Mesh midphase structure. This enum is used to select the desired acceleration structure for midphase queries
|
||||
(i.e. raycasts, overlaps, sweeps vs triangle meshes).
|
||||
|
||||
The PxMeshMidPhase::eBVH33 structure is the one used in recent PhysX versions (up to PhysX 3.3). It has great performance and is
|
||||
supported on all platforms. It is deprecated since PhysX 5.x.
|
||||
|
||||
The PxMeshMidPhase::eBVH34 structure is a revisited implementation introduced in PhysX 3.4. It can be significantly faster both
|
||||
in terms of cooking performance and runtime performance.
|
||||
*/
|
||||
struct PxMeshMidPhase
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eBVH33 = 0, //!< \deprecated Use eBVH34 instead. Used to be default midphase mesh structure up to PhysX 3.3
|
||||
eBVH34 = 1, //!< New midphase mesh structure, introduced in PhysX 3.4
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Flags for the mesh geometry properties.
|
||||
|
||||
Used in ::PxTriangleMeshFlags.
|
||||
*/
|
||||
struct PxTriangleMeshFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
e16_BIT_INDICES = (1<<1), //!< The triangle mesh has 16bits vertex indices.
|
||||
eADJACENCY_INFO = (1<<2), //!< The triangle mesh has adjacency information build.
|
||||
ePREFER_NO_SDF_PROJ = (1<<3)//!< Indicates that this mesh would preferably not be the mesh projected for mesh-mesh collision. This can indicate that the mesh is not well tessellated.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxTriangleMeshFlag.
|
||||
|
||||
\see PxTriangleMeshFlag
|
||||
*/
|
||||
typedef PxFlags<PxTriangleMeshFlag::Enum,PxU8> PxTriangleMeshFlags;
|
||||
PX_FLAGS_OPERATORS(PxTriangleMeshFlag::Enum,PxU8)
|
||||
|
||||
/**
|
||||
|
||||
\brief A triangle mesh, also called a 'polygon soup'.
|
||||
|
||||
It is represented as an indexed triangle list. There are no restrictions on the
|
||||
triangle data.
|
||||
|
||||
To avoid duplicating data when you have several instances of a particular
|
||||
mesh positioned differently, you do not use this class to represent a
|
||||
mesh object directly. Instead, you create an instance of this mesh via
|
||||
the PxTriangleMeshGeometry and PxShape classes.
|
||||
|
||||
<h3>Creation</h3>
|
||||
|
||||
To create an instance of this class call PxPhysics::createTriangleMesh(),
|
||||
and release() to delete it. This is only possible
|
||||
once you have released all of its PxShape instances.
|
||||
|
||||
|
||||
<h3>Visualizations:</h3>
|
||||
\li #PxVisualizationParameter::eCOLLISION_AABBS
|
||||
\li #PxVisualizationParameter::eCOLLISION_SHAPES
|
||||
\li #PxVisualizationParameter::eCOLLISION_AXES
|
||||
\li #PxVisualizationParameter::eCOLLISION_FNORMALS
|
||||
\li #PxVisualizationParameter::eCOLLISION_EDGES
|
||||
|
||||
\see PxTriangleMeshDesc PxTriangleMeshGeometry PxShape PxPhysics.createTriangleMesh()
|
||||
*/
|
||||
class PxTriangleMesh : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Returns the number of vertices.
|
||||
\return number of vertices
|
||||
\see getVertices()
|
||||
*/
|
||||
virtual PxU32 getNbVertices() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the vertices.
|
||||
\return array of vertices
|
||||
\see getNbVertices()
|
||||
*/
|
||||
virtual const PxVec3* getVertices() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns all mesh vertices for modification.
|
||||
|
||||
This function will return the vertices of the mesh so that their positions can be changed in place.
|
||||
After modifying the vertices you must call refitBVH for the refitting to actually take place.
|
||||
This function maintains the old mesh topology (triangle indices).
|
||||
|
||||
\return inplace vertex coordinates for each existing mesh vertex.
|
||||
|
||||
\note It is recommended to use this feature for scene queries only.
|
||||
\note Size of array returned is equal to the number returned by getNbVertices().
|
||||
\note This function operates on cooked vertex indices.
|
||||
\note This means the index mapping and vertex count can be different from what was provided as an input to the cooking routine.
|
||||
\note To achieve unchanged 1-to-1 index mapping with orignal mesh data (before cooking) please use the following cooking flags:
|
||||
\note eWELD_VERTICES = 0, eDISABLE_CLEAN_MESH = 1.
|
||||
\note It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled.
|
||||
\see getNbVertices()
|
||||
\see refitBVH()
|
||||
*/
|
||||
virtual PxVec3* getVerticesForModification() = 0;
|
||||
|
||||
/**
|
||||
\brief Refits BVH for mesh vertices.
|
||||
|
||||
This function will refit the mesh BVH to correctly enclose the new positions updated by getVerticesForModification.
|
||||
Mesh BVH will not be reoptimized by this function so significantly different new positions will cause significantly reduced performance.
|
||||
|
||||
\return New bounds for the entire mesh.
|
||||
|
||||
\note For PxMeshMidPhase::eBVH34 trees the refit operation is only available on non-quantized trees (see PxBVH34MidphaseDesc::quantized)
|
||||
\note PhysX does not keep a mapping from the mesh to mesh shapes that reference it.
|
||||
\note Call PxShape::setGeometry on each shape which references the mesh, to ensure that internal data structures are updated to reflect the new geometry.
|
||||
\note PxShape::setGeometry does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.
|
||||
\note It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled.
|
||||
\note Active edges information will be lost during refit, the rigid body mesh contact generation might not perform as expected.
|
||||
\see getNbVertices()
|
||||
\see getVerticesForModification()
|
||||
\see PxBVH34MidphaseDesc::quantized
|
||||
*/
|
||||
virtual PxBounds3 refitBVH() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of triangles.
|
||||
\return number of triangles
|
||||
\see getTriangles() getTrianglesRemap()
|
||||
*/
|
||||
virtual PxU32 getNbTriangles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the triangle indices.
|
||||
|
||||
The indices can be 16 or 32bit depending on the number of triangles in the mesh.
|
||||
Call getTriangleMeshFlags() to know if the indices are 16 or 32 bits.
|
||||
|
||||
The number of indices is the number of triangles * 3.
|
||||
|
||||
\return array of triangles
|
||||
\see getNbTriangles() getTriangleMeshFlags() getTrianglesRemap()
|
||||
*/
|
||||
virtual const void* getTriangles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Reads the PxTriangleMesh flags.
|
||||
|
||||
See the list of flags #PxTriangleMeshFlag
|
||||
|
||||
\return The values of the PxTriangleMesh flags.
|
||||
|
||||
\see PxTriangleMesh
|
||||
*/
|
||||
virtual PxTriangleMeshFlags getTriangleMeshFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the triangle remapping table.
|
||||
|
||||
The triangles are internally sorted according to various criteria. Hence the internal triangle order
|
||||
does not always match the original (user-defined) order. The remapping table helps finding the old
|
||||
indices knowing the new ones:
|
||||
|
||||
remapTable[ internalTriangleIndex ] = originalTriangleIndex
|
||||
|
||||
\return the remapping table (or NULL if 'PxCookingParams::suppressTriangleMeshRemapTable' has been used)
|
||||
\see getNbTriangles() getTriangles() PxCookingParams::suppressTriangleMeshRemapTable
|
||||
*/
|
||||
virtual const PxU32* getTrianglesRemap() const = 0;
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of a triangle mesh and releases it if the new reference count is zero.
|
||||
|
||||
\see PxPhysics.createTriangleMesh()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns material table index of given triangle
|
||||
|
||||
This function takes a post cooking triangle index.
|
||||
|
||||
\param[in] triangleIndex (internal) index of desired triangle
|
||||
\return Material table index, or 0xffff if no per-triangle materials are used
|
||||
*/
|
||||
virtual PxMaterialTableIndex getTriangleMaterialIndex(PxTriangleID triangleIndex) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the local-space (vertex space) AABB from the triangle mesh.
|
||||
|
||||
\return local-space bounds
|
||||
*/
|
||||
virtual PxBounds3 getLocalBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the local-space Signed Distance Field for this mesh if it has one.
|
||||
\return local-space SDF.
|
||||
*/
|
||||
virtual const PxReal* getSDF() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the resolution of the local-space dense SDF.
|
||||
*/
|
||||
virtual void getSDFDimensions(PxU32& numX, PxU32& numY, PxU32& numZ) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets whether this mesh should be preferred for SDF projection.
|
||||
|
||||
By default, meshes are flagged as preferring projection and the decisions on which mesh to project is based on the triangle and vertex
|
||||
count. The model with the fewer triangles is projected onto the SDF of the more detailed mesh.
|
||||
If one of the meshes is set to prefer SDF projection (default) and the other is set to not prefer SDF projection, model flagged as
|
||||
preferring SDF projection will be projected onto the model flagged as not preferring, regardless of the detail of the respective meshes.
|
||||
Where both models are flagged as preferring no projection, the less detailed model will be projected as before.
|
||||
|
||||
\param[in] preferProjection Indicates if projection is preferred
|
||||
*/
|
||||
virtual void setPreferSDFProjection(bool preferProjection) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns whether this mesh prefers SDF projection.
|
||||
\return whether this mesh prefers SDF projection.
|
||||
*/
|
||||
virtual bool getPreferSDFProjection() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the mass properties of the mesh assuming unit density.
|
||||
|
||||
The following relationship holds between mass and volume:
|
||||
|
||||
mass = volume * density
|
||||
|
||||
The mass of a unit density mesh is equal to its volume, so this function returns the volume of the mesh.
|
||||
|
||||
Similarly, to obtain the localInertia of an identically shaped object with a uniform density of d, simply multiply the
|
||||
localInertia of the unit density mesh by d.
|
||||
|
||||
\param[out] mass The mass of the mesh assuming unit density.
|
||||
\param[out] localInertia The inertia tensor in mesh local space assuming unit density.
|
||||
\param[out] localCenterOfMass Position of center of mass (or centroid) in mesh local space.
|
||||
*/
|
||||
virtual void getMassInformation(PxReal& mass, PxMat33& localInertia, PxVec3& localCenterOfMass) const = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxTriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags) {}
|
||||
PX_INLINE PxTriangleMesh(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxTriangleMesh() {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxTriangleMesh", PxRefCounted); }
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated Use PxBVH34TriangleMesh instead.
|
||||
|
||||
\brief A triangle mesh containing the PxMeshMidPhase::eBVH33 structure.
|
||||
|
||||
\see PxMeshMidPhase
|
||||
*/
|
||||
class PX_DEPRECATED PxBVH33TriangleMesh : public PxTriangleMesh
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
PX_INLINE PxBVH33TriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxTriangleMesh(concreteType, baseFlags) {}
|
||||
PX_INLINE PxBVH33TriangleMesh(PxBaseFlags baseFlags) : PxTriangleMesh(baseFlags) {}
|
||||
virtual ~PxBVH33TriangleMesh() {}
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxBVH33TriangleMesh", PxTriangleMesh); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
\brief A triangle mesh containing the PxMeshMidPhase::eBVH34 structure.
|
||||
|
||||
\see PxMeshMidPhase
|
||||
*/
|
||||
class PxBVH34TriangleMesh : public PxTriangleMesh
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
PX_INLINE PxBVH34TriangleMesh(PxType concreteType, PxBaseFlags baseFlags) : PxTriangleMesh(concreteType, baseFlags) {}
|
||||
PX_INLINE PxBVH34TriangleMesh(PxBaseFlags baseFlags) : PxTriangleMesh(baseFlags) {}
|
||||
virtual ~PxBVH34TriangleMesh() {}
|
||||
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxBVH34TriangleMesh", PxTriangleMesh); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
157
engine/third_party/physx/include/geometry/PxTriangleMeshGeometry.h
vendored
Normal file
157
engine/third_party/physx/include/geometry/PxTriangleMeshGeometry.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
// 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_GEOMETRY_H
|
||||
#define PX_TRIANGLE_MESH_GEOMETRY_H
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxMeshScale.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxTriangleMesh;
|
||||
|
||||
/**
|
||||
\brief Flags controlling the simulated behavior of the triangle mesh geometry.
|
||||
|
||||
Used in ::PxMeshGeometryFlags.
|
||||
*/
|
||||
struct PxMeshGeometryFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eTIGHT_BOUNDS = (1<<0), //!< Use tighter (but more expensive to compute) bounds around the triangle mesh geometry.
|
||||
eDOUBLE_SIDED = (1<<1) //!< Meshes with this flag set are treated as double-sided.
|
||||
//!< This flag is currently only used for raycasts and sweeps. It is ignored for overlap queries and has no effect on contact generation, i.e. simulation.
|
||||
//!< For detailed specifications of this flag for meshes and heightfields please refer to the Geometry Query section of the user guide.
|
||||
//!< For double-sided collision meshes, consider duplicating their faces with flipped normals.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxMeshGeometryFlag.
|
||||
|
||||
\see PxMeshGeometryFlag
|
||||
*/
|
||||
typedef PxFlags<PxMeshGeometryFlag::Enum,PxU8> PxMeshGeometryFlags;
|
||||
PX_FLAGS_OPERATORS(PxMeshGeometryFlag::Enum,PxU8)
|
||||
|
||||
/**
|
||||
\brief Triangle mesh geometry class.
|
||||
|
||||
This class unifies a mesh object with a scaling transform, and
|
||||
lets the combined object be used anywhere a PxGeometry is needed.
|
||||
|
||||
The scaling is a transform along arbitrary axes contained in the scale object.
|
||||
The vertices of the mesh in geometry (or shape) space is the
|
||||
PxMeshScale::toMat33() transform, multiplied by the vertex space vertices
|
||||
in the PxTriangleMeshGeometry object.
|
||||
*/
|
||||
class PxTriangleMeshGeometry : public PxGeometry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Constructor. By default creates an empty object with a NULL mesh and identity scale.
|
||||
|
||||
\param[in] mesh Mesh pointer. May be NULL, though this will not make the object valid for shape construction.
|
||||
\param[in] scaling Scale factor.
|
||||
\param[in] flags Mesh flags.
|
||||
*/
|
||||
PX_INLINE PxTriangleMeshGeometry( PxTriangleMesh* mesh = NULL,
|
||||
const PxMeshScale& scaling = PxMeshScale(),
|
||||
PxMeshGeometryFlags flags = PxMeshGeometryFlags()) :
|
||||
PxGeometry (PxGeometryType::eTRIANGLEMESH),
|
||||
scale (scaling),
|
||||
meshFlags (flags),
|
||||
triangleMesh(mesh)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
|
||||
\param[in] that Other object
|
||||
*/
|
||||
PX_INLINE PxTriangleMeshGeometry(const PxTriangleMeshGeometry& that) :
|
||||
PxGeometry (that),
|
||||
scale (that.scale),
|
||||
meshFlags (that.meshFlags),
|
||||
triangleMesh(that.triangleMesh)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator=(const PxTriangleMeshGeometry& that)
|
||||
{
|
||||
mType = that.mType;
|
||||
scale = that.scale;
|
||||
meshFlags = that.meshFlags;
|
||||
triangleMesh = that.triangleMesh;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns true if the geometry is valid.
|
||||
|
||||
\return True if the current settings are valid for shape creation.
|
||||
|
||||
\note A valid triangle mesh has a positive scale value in each direction (scale.scale.x > 0, scale.scale.y > 0, scale.scale.z > 0).
|
||||
It is illegal to call PxPhysics::createShape with a triangle mesh that has zero extents in any direction.
|
||||
|
||||
\see PxPhysics::createShape
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
|
||||
public:
|
||||
PxMeshScale scale; //!< The scaling transformation.
|
||||
PxMeshGeometryFlags meshFlags; //!< Mesh flags.
|
||||
PxPadding<3> paddingFromFlags; //!< padding for mesh flags
|
||||
PxTriangleMesh* triangleMesh; //!< A reference to the mesh object.
|
||||
};
|
||||
|
||||
PX_INLINE bool PxTriangleMeshGeometry::isValid() const
|
||||
{
|
||||
if(mType != PxGeometryType::eTRIANGLEMESH)
|
||||
return false;
|
||||
if(!scale.scale.isFinite() || !scale.rotation.isUnit())
|
||||
return false;
|
||||
if(!scale.isValidForTriangleMesh())
|
||||
return false;
|
||||
if(!triangleMesh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user