feat(physics): wire physx sdk into build

This commit is contained in:
2026-04-15 12:22:15 +08:00
parent 5bf258df6d
commit 31f40e2cbb
2044 changed files with 752623 additions and 1 deletions

View File

@@ -0,0 +1,236 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-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_BASE_H
#define PX_BASE_H
#include "foundation/PxFlags.h"
#include "foundation/PxString.h"
#include "foundation/PxFoundation.h"
#include "common/PxSerialFramework.h"
#include "common/PxCollection.h"
#include "common/PxTypeInfo.h"
#include "foundation/PxAssert.h"
#define PX_IS_KIND_OF(query, classname, baseclass) \
PX_ASSERT(query != NULL); \
if(query == NULL) \
{ \
PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "isKindOf called with invalid string"); \
return false; \
} \
return !Pxstrcmp(classname, query) || baseclass::isKindOf(query)
#if !PX_DOXYGEN
namespace physx
{
#endif
typedef PxU16 PxType;
/**
\brief Flags for PxBase.
*/
struct PxBaseFlag
{
enum Enum
{
eOWNS_MEMORY = (1<<0),
eIS_RELEASABLE = (1<<1)
};
};
typedef PxFlags<PxBaseFlag::Enum, PxU16> PxBaseFlags;
PX_FLAGS_OPERATORS(PxBaseFlag::Enum, PxU16)
/**
\brief Base class for objects that can be members of a PxCollection.
All PxBase sub-classes can be serialized.
\see PxCollection
*/
class PxBase
{
public:
/**
\brief Releases the PxBase instance, please check documentation of release in derived class.
*/
virtual void release() = 0;
/**
\brief Returns string name of dynamic type.
\return Class name of most derived type of this object.
*/
virtual const char* getConcreteTypeName() const = 0;
/* brief Implements dynamic cast functionality.
Example use:
if(actor->is<PxRigidDynamic>()) {...}
\return A pointer to the specified type if object matches, otherwise NULL
*/
template<class T> T* is() { return typeMatch<T>() ? static_cast<T*>(this) : NULL; }
/* brief Implements dynamic cast functionality for const objects.
Example use:
if(actor->is<PxRigidDynamic>()) {...}
\return A pointer to the specified type if object matches, otherwise NULL
*/
template<class T> const T* is() const { return typeMatch<T>() ? static_cast<const T*>(this) : NULL; }
/**
\brief Returns concrete type of object.
\return PxConcreteType::Enum of serialized object
\see PxConcreteType
*/
PX_FORCE_INLINE PxType getConcreteType() const { return mConcreteType; }
/**
\brief Set PxBaseFlag
\param[in] flag The flag to be set
\param[in] value The flags new value
*/
PX_FORCE_INLINE void setBaseFlag(PxBaseFlag::Enum flag, bool value) { mBaseFlags = value ? mBaseFlags|flag : mBaseFlags&~flag; }
/**
\brief Set PxBaseFlags
\param[in] inFlags The flags to be set
\see PxBaseFlags
*/
PX_FORCE_INLINE void setBaseFlags(PxBaseFlags inFlags) { mBaseFlags = inFlags; }
/**
\brief Returns PxBaseFlags
\return PxBaseFlags
\see PxBaseFlags
*/
PX_FORCE_INLINE PxBaseFlags getBaseFlags() const { return mBaseFlags; }
/**
\brief Whether the object is subordinate.
A class is subordinate, if it can only be instantiated in the context of another class.
\return Whether the class is subordinate
\see PxSerialization::isSerializable
*/
virtual bool isReleasable() const { return mBaseFlags & PxBaseFlag::eIS_RELEASABLE; }
protected:
/**
\brief Constructor setting concrete type and base flags.
*/
PX_INLINE PxBase(PxType concreteType, PxBaseFlags baseFlags)
: mConcreteType(concreteType), mBaseFlags(baseFlags), mBuiltInRefCount(1) {}
/**
\brief Deserialization constructor setting base flags.
*/
PX_INLINE PxBase(PxBaseFlags baseFlags) : mBaseFlags(baseFlags)
{
PX_ASSERT(mBuiltInRefCount == 1);
}
/**
\brief Destructor.
*/
virtual ~PxBase() {}
/**
\brief Returns whether a given type name matches with the type of this instance
*/
virtual bool isKindOf(const char* superClass) const { return !Pxstrcmp(superClass, "PxBase"); }
template<class T> bool typeMatch() const
{
return PxU32(PxTypeInfo<T>::eFastTypeId)!=PxU32(PxConcreteType::eUNDEFINED) ?
PxU32(getConcreteType()) == PxU32(PxTypeInfo<T>::eFastTypeId) : isKindOf(PxTypeInfo<T>::name());
}
protected:
PxType mConcreteType; // concrete type identifier - see PxConcreteType.
PxBaseFlags mBaseFlags; // internal flags
PxU32 mBuiltInRefCount;
};
/**
\brief Base class for ref-counted objects.
*/
class PxRefCounted : public PxBase
{
public:
/**
\brief Decrements the reference count of the object and releases it if the new reference count is zero.
*/
virtual void release() = 0;
/**
\brief Returns the reference count of the object.
At creation, the reference count of the object is 1. Every other object referencing this object increments the
count by 1. When the reference count reaches 0, and only then, the object gets destroyed automatically.
\return the current reference count.
*/
virtual PxU32 getReferenceCount() const = 0;
/**
\brief Acquires a counted reference to this object.
This method increases the reference count of the object by 1. Decrement the reference count by calling release()
*/
virtual void acquireReference() = 0;
protected:
virtual void onRefCountZero() { delete this; }
PX_INLINE PxRefCounted(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
PX_INLINE PxRefCounted(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
virtual ~PxRefCounted() {}
virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxRefCounted", PxBase); }
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,273 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_COLLECTION_H
#define PX_COLLECTION_H
#include "common/PxSerialFramework.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxBase;
/**
\brief Collection class for serialization.
A collection is a set of PxBase objects. PxBase objects can be added to the collection
regardless of other objects they depend on. Objects may be named using PxSerialObjectId values in order
to resolve dependencies between objects of different collections.
Serialization and deserialization only work through collections.
A scene is typically serialized using the following steps:
-# create a serialization registry
-# create a collection for scene objects
-# complete the scene objects (adds all dependent objects, e.g. meshes)
-# serialize collection
-# release collection
-# release serialization registry
For example the code may look like this:
\code
PxPhysics* physics; // The physics
PxScene* scene; // The physics scene
SerialStream s; // The user-defined stream doing the actual write to disk
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 1)
PxCollection* collection = PxSerialization::createCollection(*scene); // step 2)
PxSerialization::complete(*collection, *registry); // step 3)
PxSerialization::serializeCollectionToBinary(s, *collection, *registry); // step 4)
collection->release(); // step 5)
registry->release(); // step 6)
\endcode
A scene is typically deserialized using the following steps:
-# load a serialized collection into memory
-# create a serialization registry
-# create a collection by passing the serialized memory block
-# add collected objects to scene
-# release collection
-# release serialization registry
For example the code may look like this:
\code
PxPhysics* physics; // The physics
PxScene* scene; // The physics scene
void* memory128; // a 128-byte aligned buffer previously loaded from disk by the user - step 1)
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 2)
PxCollection* collection = PxSerialization::createCollectionFromBinary(memory128, *registry); // step 3)
scene->addCollection(*collection); // step 4)
collection->release(); // step 5)
registry->release(); // step 6)
\endcode
\see PxBase, PxCreateCollection()
*/
class PxCollection
{
public:
/**
\brief Adds a PxBase object to the collection.
Adds a PxBase object to the collection. Optionally a PxSerialObjectId can be provided
in order to resolve dependencies between collections. A PxSerialObjectId value of PX_SERIAL_OBJECT_ID_INVALID
means the object remains without id. Objects can be added regardless of other objects they require. If the object
is already in the collection, the ID will be set if it was PX_SERIAL_OBJECT_ID_INVALID previously, otherwise the
operation fails.
\param[in] object Object to be added to the collection
\param[in] id Optional PxSerialObjectId id
*/
virtual void add(PxBase& object, PxSerialObjectId id = PX_SERIAL_OBJECT_ID_INVALID) = 0;
/**
\brief Removes a PxBase member object from the collection.
Object needs to be contained by the collection.
\param[in] object PxBase object to be removed
*/
virtual void remove(PxBase& object) = 0;
/**
\brief Returns whether the collection contains a certain PxBase object.
\param[in] object PxBase object
\return Whether object is contained.
*/
virtual bool contains(PxBase& object) const = 0;
/**
\brief Adds an id to a member PxBase object.
If the object is already associated with an id within the collection, the id is replaced.
May only be called for objects that are members of the collection. The id needs to be unique
within the collection.
\param[in] object Member PxBase object
\param[in] id PxSerialObjectId id to be given to the object
*/
virtual void addId(PxBase& object, PxSerialObjectId id) = 0;
/**
\brief Removes id from a contained PxBase object.
May only be called for ids that are associated with an object in the collection.
\param[in] id PxSerialObjectId value
*/
virtual void removeId(PxSerialObjectId id) = 0;
/**
\brief Adds all PxBase objects and their ids of collection to this collection.
PxBase objects already in this collection are ignored. Object ids need to be conflict
free, i.e. the same object may not have two different ids within the two collections.
\param[in] collection Collection to be added
*/
virtual void add(PxCollection& collection) = 0;
/**
\brief Removes all PxBase objects of collection from this collection.
PxBase objects not present in this collection are ignored. Ids of objects
which are removed are also removed.
\param[in] collection Collection to be removed
*/
virtual void remove(PxCollection& collection) = 0;
/**
\brief Gets number of PxBase objects in this collection.
\return Number of objects in this collection
*/
virtual PxU32 getNbObjects() const = 0;
/**
\brief Gets the PxBase object of this collection given its index.
\param[in] index PxBase index in [0, getNbObjects())
\return PxBase object at index index
*/
virtual PxBase& getObject(PxU32 index) const = 0;
/**
\brief Copies member PxBase pointers to a user specified buffer.
\param[out] userBuffer Array of PxBase pointers
\param[in] bufferSize Capacity of userBuffer
\param[in] startIndex Offset into list of member PxBase objects
\return number of members PxBase objects that have been written to the userBuffer
*/
virtual PxU32 getObjects(PxBase** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
/**
\brief Looks for a PxBase object given a PxSerialObjectId value.
If there is no PxBase object in the collection with the given id, NULL is returned.
\param[in] id PxSerialObjectId value to look for
\return PxBase object with the given id value or NULL
*/
virtual PxBase* find(PxSerialObjectId id) const = 0;
/**
\brief Gets number of PxSerialObjectId names in this collection.
\return Number of PxSerialObjectId names in this collection
*/
virtual PxU32 getNbIds() const = 0;
/**
\brief Copies member PxSerialObjectId values to a user specified buffer.
\param[out] userBuffer Array of PxSerialObjectId values
\param[in] bufferSize Capacity of userBuffer
\param[in] startIndex Offset into list of member PxSerialObjectId values
\return number of members PxSerialObjectId values that have been written to the userBuffer
*/
virtual PxU32 getIds(PxSerialObjectId* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
/**
\brief Gets the PxSerialObjectId name of a PxBase object within the collection.
The PxBase object needs to be a member of the collection.
\param[in] object PxBase object to get id for
\return PxSerialObjectId name of the object or PX_SERIAL_OBJECT_ID_INVALID if the object is unnamed
*/
virtual PxSerialObjectId getId(const PxBase& object) const = 0;
/**
\brief Deletes a collection object.
This function only deletes the collection object, i.e. the container class. It doesn't delete objects
that are part of the collection.
\see PxCreateCollection()
*/
virtual void release() = 0;
protected:
PxCollection() {}
virtual ~PxCollection() {}
};
#if !PX_DOXYGEN
} // namespace physx
#endif
/**
\brief Creates a collection object.
Objects can only be serialized or deserialized through a collection.
For serialization, users must add objects to the collection and serialize the collection as a whole.
For deserialization, the system gives back a collection of deserialized objects to users.
\return The new collection object.
\see PxCollection, PxCollection::release()
*/
PX_C_EXPORT PX_PHYSX_COMMON_API physx::PxCollection* PX_CALL_CONV PxCreateCollection();
#endif

View File

@@ -0,0 +1,242 @@
// 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_CORE_UTILITY_TYPES_H
#define PX_CORE_UTILITY_TYPES_H
#include "foundation/PxAssert.h"
#include "foundation/PxMemory.h"
#include "foundation/PxIO.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
struct PxBoundedData
{
/**
\brief The offset in bytes between consecutive samples in the data.
<b>Default:</b> 0
*/
const void* data;
PxU32 stride;
PxU32 count;
PxBoundedData() : data( NULL ), stride(0), count(0) {}
PxBoundedData(void* data_, PxU32 stride_ = 0, PxU32 count_ = 0)
: data(data_)
, stride(stride_)
, count(count_)
{
}
template<typename TDataType>
PX_INLINE const TDataType& at( PxU32 idx ) const
{
PxU32 theStride( stride );
if ( theStride == 0 )
theStride = sizeof( TDataType );
PxU32 offset( theStride * idx );
return *(reinterpret_cast<const TDataType*>( reinterpret_cast< const PxU8* >( data ) + offset ));
}
};
typedef PX_DEPRECATED PxBoundedData PxStridedData;
template<typename TDataType>
struct PxTypedBoundedData
{
TDataType* data;
PxU32 stride;
PxU32 count;
PxTypedBoundedData()
: data(NULL)
, stride(0)
, count(0)
{
}
PxTypedBoundedData(TDataType* data_, PxU32 stride_ = 0, PxU32 count_ = 0)
: data(data_)
, stride(stride_)
, count(count_)
{
}
PX_CUDA_CALLABLE PX_INLINE const TDataType& at(PxU32 idx) const
{
PxU32 theStride(stride);
if (theStride == 0)
theStride = sizeof(TDataType);
PxU32 offset(theStride * idx);
return *(reinterpret_cast<const TDataType*>(reinterpret_cast<const PxU8*>(data) + offset));
}
PX_CUDA_CALLABLE PX_INLINE TDataType& atRef(PxU32 idx)
{
PxU32 theStride(stride);
if (theStride == 0)
theStride = sizeof(TDataType);
PxU32 offset(theStride * idx);
return *(reinterpret_cast<TDataType*>(reinterpret_cast<PxU8*>(data) + offset));
}
};
template<typename TDataType>
PX_DEPRECATED struct PxTypedStridedData : public PxTypedBoundedData<TDataType>
{
PxTypedStridedData() : PxTypedBoundedData<TDataType>()
{
}
PxTypedStridedData(TDataType* data_, PxU32 stride_ = 0) : PxTypedBoundedData<TDataType>(data_, stride_)
{
}
};
template<PxU8 TNumBytes>
struct PxPadding
{
PxU8 mPadding[TNumBytes];
PxPadding()
{
for ( PxU8 idx =0; idx < TNumBytes; ++idx )
mPadding[idx] = 0;
}
};
template <PxU32 NB_ELEMENTS> class PxFixedSizeLookupTable
{
public:
PxFixedSizeLookupTable()
: mNbDataPairs(0)
{
}
PxFixedSizeLookupTable(const PxEMPTY) {}
PxFixedSizeLookupTable(const PxReal* dataPairs, const PxU32 numDataPairs)
{
PxMemCopy(mDataPairs,dataPairs,sizeof(PxReal)*2*numDataPairs);
mNbDataPairs=numDataPairs;
}
PxFixedSizeLookupTable(const PxFixedSizeLookupTable& src)
{
PxMemCopy(mDataPairs,src.mDataPairs,sizeof(PxReal)*2*src.mNbDataPairs);
mNbDataPairs=src.mNbDataPairs;
}
~PxFixedSizeLookupTable()
{
}
PxFixedSizeLookupTable& operator=(const PxFixedSizeLookupTable& src)
{
PxMemCopy(mDataPairs,src.mDataPairs,sizeof(PxReal)*2*src.mNbDataPairs);
mNbDataPairs=src.mNbDataPairs;
return *this;
}
PX_FORCE_INLINE void addPair(const PxReal x, const PxReal y)
{
PX_ASSERT(mNbDataPairs<NB_ELEMENTS);
mDataPairs[2*mNbDataPairs+0]=x;
mDataPairs[2*mNbDataPairs+1]=y;
mNbDataPairs++;
}
PX_FORCE_INLINE PxReal getYVal(const PxReal x) const
{
if(0==mNbDataPairs)
{
PX_ASSERT(false);
return 0;
}
if(1==mNbDataPairs || x<getX(0))
{
return getY(0);
}
PxReal x0=getX(0);
PxReal y0=getY(0);
for(PxU32 i=1;i<mNbDataPairs;i++)
{
const PxReal x1=getX(i);
const PxReal y1=getY(i);
if((x>=x0)&&(x<x1))
{
return (y0+(y1-y0)*(x-x0)/(x1-x0));
}
x0=x1;
y0=y1;
}
PX_ASSERT(x>=getX(mNbDataPairs-1));
return getY(mNbDataPairs-1);
}
PxU32 getNbDataPairs() const {return mNbDataPairs;}
void clear()
{
PxMemSet(mDataPairs, 0, NB_ELEMENTS*2*sizeof(PxReal));
mNbDataPairs = 0;
}
PX_FORCE_INLINE PxReal getX(const PxU32 i) const
{
return mDataPairs[2*i];
}
PX_FORCE_INLINE PxReal getY(const PxU32 i) const
{
return mDataPairs[2*i+1];
}
PxReal mDataPairs[2*NB_ELEMENTS];
PxU32 mNbDataPairs;
PxU32 mPad[3];
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,75 @@
// 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_INSERTION_CALLBACK_H
#define PX_INSERTION_CALLBACK_H
#include "common/PxBase.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief Callback interface that permits TriangleMesh, Heightfield, ConvexMesh or BVH to be used
directly without the need to store the cooking results into a stream.
Using this is advised only if real-time cooking is required; using "offline" cooking and
streams is otherwise preferred.
The default PxInsertionCallback implementations must be used. The PxPhysics
default callback can be obtained using the PxPhysics::getPhysicsInsertionCallback().
The PxCooking default callback can be obtained using the PxCooking::getStandaloneInsertionCallback().
\see PxCooking PxPhysics
*/
class PxInsertionCallback
{
public:
PxInsertionCallback() {}
/**
\brief Builds object (TriangleMesh, Heightfield, ConvexMesh or BVH) from given data in PxPhysics.
\param type Object type to build.
\param data Object data
\return PxBase Created object in PxPhysics.
*/
virtual PxBase* buildObjectFromData(PxConcreteType::Enum type, void* data) = 0;
protected:
virtual ~PxInsertionCallback() {}
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,126 @@
// 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_PHYSX_COMMON_CONFIG_H
#define PX_PHYSX_COMMON_CONFIG_H
#include "foundation/PxSimpleTypes.h"
//Fills almost all allocated (host and device memory) with 0xcdcdcdcd (=3452816845)
#define PX_STOMP_ALLOCATED_MEMORY 0
/*Disable support for VS2017 prior version 15.5.1 for windows platform, because of a compiler bug:
https://developercommunity.visualstudio.com/content/problem/66047/possible-compiler-bug.html
*/
#if (PX_VC == 15) && PX_WINDOWS && (_MSC_FULL_VER < 191225830)
#error Visual studio 2017 prior to 15.5.1 is not supported because of a compiler bug.
#endif
// define API function declaration (public API only needed because of extensions)
#if defined PX_PHYSX_STATIC_LIB
#define PX_PHYSX_CORE_API
#else
#if PX_WINDOWS_FAMILY
#if defined PX_PHYSX_CORE_EXPORTS
#define PX_PHYSX_CORE_API __declspec(dllexport)
#else
#define PX_PHYSX_CORE_API __declspec(dllimport)
#endif
#elif PX_UNIX_FAMILY
#define PX_PHYSX_CORE_API PX_UNIX_EXPORT
#else
#define PX_PHYSX_CORE_API
#endif
#endif
#if PX_SUPPORT_GPU_PHYSX
// define API function declaration
#if defined PX_PHYSX_GPU_STATIC
#define PX_PHYSX_GPU_API
#else
#if PX_WINDOWS
#if defined PX_PHYSX_GPU_EXPORTS
#define PX_PHYSX_GPU_API __declspec(dllexport)
#else
#define PX_PHYSX_GPU_API __declspec(dllimport)
#endif
#elif PX_UNIX_FAMILY
#define PX_PHYSX_GPU_API PX_UNIX_EXPORT
#else
#define PX_PHYSX_GPU_API
#endif
#endif
#else // PX_SUPPORT_GPU_PHYSX
#define PX_PHYSX_GPU_API
#endif // PX_SUPPORT_GPU_PHYSX
#if defined PX_PHYSX_STATIC_LIB
#define PX_PHYSX_COMMON_API
#else
#if PX_WINDOWS_FAMILY && !PX_CUDA_COMPILER
#if defined PX_PHYSX_COMMON_EXPORTS
#define PX_PHYSX_COMMON_API __declspec(dllexport)
#else
#define PX_PHYSX_COMMON_API __declspec(dllimport)
#endif
#elif PX_UNIX_FAMILY
#define PX_PHYSX_COMMON_API PX_UNIX_EXPORT
#else
#define PX_PHYSX_COMMON_API
#endif
#endif
// PT: typical "invalid" value in various CD algorithms
#define PX_INVALID_U32 0xffffffff
#define PX_INVALID_U16 0xffff
// Changing these parameters requires recompilation of the SDK
// Enable debug visualization
#define PX_ENABLE_DEBUG_VISUALIZATION 1
#define PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
// Enable simulation statistics generation
#define PX_ENABLE_SIM_STATS 1
#define PX_CATCH_UNDEFINED_ENABLE_SIM_STATS
#if !PX_DOXYGEN
namespace physx
{
#endif
typedef PxU32 PxTriangleID;
typedef PxU16 PxMaterialTableIndex;
typedef PxU16 PxDeformableMaterialTableIndex;
typedef PX_DEPRECATED PxU16 PxFEMMaterialTableIndex;
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,56 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_ZONE_H
#define PX_PROFILE_ZONE_H
#include "foundation/PxProfiler.h"
#include "foundation/PxFoundation.h"
#if PX_DEBUG || PX_CHECKED || PX_PROFILE
#define PX_PROFILE_ZONE(x, y) \
physx::PxProfileScoped PX_CONCAT(_scoped, __LINE__)(PxGetProfilerCallback(), x, false, y)
#define PX_PROFILE_START_CROSSTHREAD(x, y) \
if(PxGetProfilerCallback()) \
PxGetProfilerCallback()->zoneStart(x, true, y)
#define PX_PROFILE_STOP_CROSSTHREAD(x, y) \
if(PxGetProfilerCallback()) \
PxGetProfilerCallback()->zoneEnd(NULL, x, true, y)
#define PX_PROFILE_VALUE(x, y, z) \
if(PxGetProfilerCallback()) \
PxGetProfilerCallback()->recordData(x, y, z)
#define PX_PROFILE_FRAME(x, y) \
if(PxGetProfilerCallback()) \
PxGetProfilerCallback()->recordFrame(x, y)
#else
#define PX_PROFILE_ZONE(x, y)
#define PX_PROFILE_START_CROSSTHREAD(x, y)
#define PX_PROFILE_STOP_CROSSTHREAD(x, y)
#define PX_PROFILE_VALUE(x, y, z)
#define PX_PROFILE_FRAME(x, y)
#endif
#endif

View File

@@ -0,0 +1,163 @@
// 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_RENDER_BUFFER_H
#define PX_RENDER_BUFFER_H
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxVec3.h"
#include "foundation/PxMat33.h"
#include "foundation/PxBounds3.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief Default color values used for debug rendering.
*/
struct PxDebugColor
{
enum Enum
{
eARGB_BLACK = 0xff000000,
eARGB_RED = 0xffff0000,
eARGB_GREEN = 0xff00ff00,
eARGB_BLUE = 0xff0000ff,
eARGB_YELLOW = 0xffffff00,
eARGB_MAGENTA = 0xffff00ff,
eARGB_CYAN = 0xff00ffff,
eARGB_WHITE = 0xffffffff,
eARGB_GREY = 0xff808080,
eARGB_DARKRED = 0xff880000,
eARGB_DARKGREEN = 0xff008800,
eARGB_DARKBLUE = 0xff000088
};
};
/**
\brief Used to store a single point and colour for debug rendering.
*/
struct PxDebugPoint
{
PxDebugPoint(const PxVec3& p, const PxU32& c)
: pos(p), color(c) {}
PxVec3 pos;
PxU32 color;
};
/**
\brief Used to store a single line and colour for debug rendering.
*/
struct PxDebugLine
{
PxDebugLine(const PxVec3& p0, const PxVec3& p1, const PxU32& c)
: pos0(p0), color0(c), pos1(p1), color1(c) {}
PxVec3 pos0;
PxU32 color0;
PxVec3 pos1;
PxU32 color1;
};
/**
\brief Used to store a single triangle and colour for debug rendering.
*/
struct PxDebugTriangle
{
PxDebugTriangle(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const PxU32& c)
: pos0(p0), color0(c), pos1(p1), color1(c), pos2(p2), color2(c) {}
PxVec3 pos0;
PxU32 color0;
PxVec3 pos1;
PxU32 color1;
PxVec3 pos2;
PxU32 color2;
};
/**
\brief Used to store a text for debug rendering. Doesn't own 'string' array.
*/
struct PxDebugText
{
PxDebugText() : string(0)
{
}
PxDebugText(const PxVec3& pos, const PxReal& sz, const PxU32& clr, const char* str)
: position(pos), size(sz), color(clr), string(str)
{
}
PxVec3 position;
PxReal size;
PxU32 color;
const char* string;
};
/**
\brief Interface for points, lines, triangles, and text buffer.
*/
class PxRenderBuffer
{
public:
virtual ~PxRenderBuffer() {}
virtual PxU32 getNbPoints() const = 0;
virtual const PxDebugPoint* getPoints() const = 0;
virtual void addPoint(const PxDebugPoint& point) = 0;
virtual PxU32 getNbLines() const = 0;
virtual const PxDebugLine* getLines() const = 0;
virtual void addLine(const PxDebugLine& line) = 0;
virtual PxDebugLine* reserveLines(const PxU32 nbLines) = 0;
virtual PxDebugPoint* reservePoints(const PxU32 nbLines) = 0;
virtual PxU32 getNbTriangles() const = 0;
virtual const PxDebugTriangle* getTriangles() const = 0;
virtual void addTriangle(const PxDebugTriangle& triangle) = 0;
virtual void append(const PxRenderBuffer& other) = 0;
virtual void clear() = 0;
virtual void shift(const PxVec3& delta) = 0;
virtual bool empty() const = 0;
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,404 @@
// 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_RENDER_OUTPUT_H
#define PX_RENDER_OUTPUT_H
#include "foundation/PxMat44.h"
#include "foundation/PxBasicTemplates.h"
#include "PxRenderBuffer.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
#if PX_VC
#pragma warning(push)
#pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
#endif
/**
Output stream to fill RenderBuffer
*/
class PxRenderOutput
{
public:
enum Primitive
{
POINTS,
LINES,
LINESTRIP,
TRIANGLES,
TRIANGLESTRIP
};
PxRenderOutput(PxRenderBuffer& buffer)
: mPrim(POINTS),
mColor(0),
mVertex0(0.0f),
mVertex1(0.0f),
mVertexCount(0),
mTransform(PxIdentity),
mBuffer(buffer)
{
}
PX_INLINE PxRenderOutput& operator<<(Primitive prim);
PX_INLINE PxRenderOutput& operator<<(PxU32 color) ;
PX_INLINE PxRenderOutput& operator<<(const PxMat44& transform);
PX_INLINE PxRenderOutput& operator<<(const PxTransform& t);
PX_INLINE PxRenderOutput& operator<<(const PxVec3& vertex);
PX_INLINE PxDebugLine* reserveSegments(PxU32 nbSegments);
PX_INLINE PxDebugPoint* reservePoints(PxU32 nbSegments);
PX_INLINE void outputSegment(const PxVec3& v0, const PxVec3& v1);
PX_INLINE PxRenderOutput& outputCapsule(PxF32 radius, PxF32 halfHeight, const PxMat44& absPose);
private:
PxRenderOutput& operator=(const PxRenderOutput&);
Primitive mPrim;
PxU32 mColor;
PxVec3 mVertex0, mVertex1;
PxU32 mVertexCount;
PxMat44 mTransform;
PxRenderBuffer& mBuffer;
};
struct PxDebugBox
{
explicit PxDebugBox(const PxVec3& extents, bool wireframe_ = true)
: minimum(-extents), maximum(extents), wireframe(wireframe_) {}
explicit PxDebugBox(const PxVec3& pos, const PxVec3& extents, bool wireframe_ = true)
: minimum(pos - extents), maximum(pos + extents), wireframe(wireframe_) {}
explicit PxDebugBox(const PxBounds3& bounds, bool wireframe_ = true)
: minimum(bounds.minimum), maximum(bounds.maximum), wireframe(wireframe_) {}
PxVec3 minimum, maximum;
bool wireframe;
};
PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out, const PxDebugBox& box)
{
if (box.wireframe)
{
out << PxRenderOutput::LINESTRIP;
out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
out << PxVec3(box.maximum.x, box.maximum.y, box.minimum.z);
out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
out << PxVec3(box.maximum.x, box.minimum.y, box.maximum.z);
out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
out << PxRenderOutput::LINES;
out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
out << PxVec3(box.maximum.x, box.minimum.y, box.maximum.z);
out << PxVec3(box.maximum.x, box.maximum.y, box.minimum.z);
out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
}
else
{
out << PxRenderOutput::TRIANGLESTRIP;
out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z); // 0
out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z); // 2
out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z); // 1
out << PxVec3(box.maximum.x, box.maximum.y, box.minimum.z); // 3
out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z); // 7
out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z); // 2
out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z); // 6
out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z); // 0
out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z); // 4
out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z); // 1
out << PxVec3(box.maximum.x, box.minimum.y, box.maximum.z); // 5
out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z); // 7
out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z); // 4
out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z); // 6
}
return out;
}
struct PxDebugArrow
{
PxDebugArrow(const PxVec3& pos, const PxVec3& vec)
: base(pos), tip(pos + vec), headLength(vec.magnitude()*0.15f) {}
PxDebugArrow(const PxVec3& pos, const PxVec3& vec, PxReal headLength_)
: base(pos), tip(pos + vec), headLength(headLength_) {}
PxVec3 base, tip;
PxReal headLength;
};
PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, PxVec3& tangent1)
{
tangent0 = PxAbs(normal.x) < 0.70710678f ? PxVec3(0, -normal.z, normal.y) : PxVec3(-normal.y, normal.x, 0);
tangent0.normalize();
tangent1 = normal.cross(tangent0);
}
PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out, const PxDebugArrow& arrow)
{
PxVec3 t0 = arrow.tip - arrow.base, t1, t2;
t0.normalize();
normalToTangents(t0, t1, t2);
const PxReal tipAngle = 0.25f;
t1 *= arrow.headLength * tipAngle;
t2 *= arrow.headLength * tipAngle * PxSqrt(3.0f);
PxVec3 headBase = arrow.tip - t0 * arrow.headLength;
out << PxRenderOutput::LINES;
out << arrow.base << arrow.tip;
out << PxRenderOutput::TRIANGLESTRIP;
out << arrow.tip;
out << headBase + t1 + t1;
out << headBase - t1 - t2;
out << headBase - t1 + t2;
out << arrow.tip;
out << headBase + t1 + t1;
return out;
}
struct PxDebugBasis
{
PxDebugBasis(const PxVec3& ext, PxU32 cX = PxU32(PxDebugColor::eARGB_RED),
PxU32 cY = PxU32(PxDebugColor::eARGB_GREEN), PxU32 cZ = PxU32(PxDebugColor::eARGB_BLUE))
: extends(ext), colorX(cX), colorY(cY), colorZ(cZ) {}
PxVec3 extends;
PxU32 colorX, colorY, colorZ;
};
PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out, const PxDebugBasis& basis)
{
const PxReal headLength = basis.extends.magnitude() * 0.15f;
out << basis.colorX << PxDebugArrow(PxVec3(0.0f), PxVec3(basis.extends.x, 0, 0), headLength);
out << basis.colorY << PxDebugArrow(PxVec3(0.0f), PxVec3(0, basis.extends.y, 0), headLength);
out << basis.colorZ << PxDebugArrow(PxVec3(0.0f), PxVec3(0, 0, basis.extends.z), headLength);
return out;
}
struct PxDebugCircle
{
PxDebugCircle(PxU32 s, PxReal r)
: nSegments(s), radius(r) {}
PxU32 nSegments;
PxReal radius;
};
PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out, const PxDebugCircle& circle)
{
const PxF32 step = PxTwoPi / PxF32(circle.nSegments);
PxF32 angle = 0;
out << PxRenderOutput::LINESTRIP;
for (PxU32 i = 0; i < circle.nSegments; i++, angle += step)
out << PxVec3(circle.radius * PxSin(angle), circle.radius * PxCos(angle), 0);
out << PxVec3(0, circle.radius, 0);
return out;
}
struct PxDebugArc
{
PxDebugArc(PxU32 s, PxReal r, PxReal minAng, PxReal maxAng)
: nSegments(s), radius(r), minAngle(minAng), maxAngle(maxAng) {}
PxU32 nSegments;
PxReal radius;
PxReal minAngle, maxAngle;
};
PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out, const PxDebugArc& arc)
{
const PxF32 step = (arc.maxAngle - arc.minAngle) / PxF32(arc.nSegments);
PxF32 angle = arc.minAngle;
out << PxRenderOutput::LINESTRIP;
for (PxU32 i = 0; i < arc.nSegments; i++, angle += step)
out << PxVec3(arc.radius * PxSin(angle), arc.radius * PxCos(angle), 0);
out << PxVec3(arc.radius * PxSin(arc.maxAngle), arc.radius * PxCos(arc.maxAngle), 0);
return out;
}
PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(Primitive prim)
{
mPrim = prim;
mVertexCount = 0;
return *this;
}
PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(PxU32 color)
{
mColor = color;
return *this;
}
PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(const PxMat44& transform)
{
mTransform = transform;
return *this;
}
PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(const PxTransform& t)
{
mTransform = PxMat44(t);
return *this;
}
PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(const PxVec3& vertexIn)
{
// apply transformation
const PxVec3 vertex = mTransform.transform(vertexIn);
++mVertexCount;
// add primitive to render buffer
switch (mPrim)
{
case POINTS:
mBuffer.addPoint(PxDebugPoint(vertex, mColor)); break;
case LINES:
if (mVertexCount == 2)
{
mBuffer.addLine(PxDebugLine(mVertex0, vertex, mColor));
mVertexCount = 0;
}
break;
case LINESTRIP:
if (mVertexCount >= 2)
mBuffer.addLine(PxDebugLine(mVertex0, vertex, mColor));
break;
case TRIANGLES:
if (mVertexCount == 3)
{
mBuffer.addTriangle(PxDebugTriangle(mVertex1, mVertex0, vertex, mColor));
mVertexCount = 0;
}
break;
case TRIANGLESTRIP:
if (mVertexCount >= 3)
mBuffer.addTriangle(PxDebugTriangle(
(mVertexCount & 0x1) ? mVertex0 : mVertex1,
(mVertexCount & 0x1) ? mVertex1 : mVertex0, vertex, mColor));
break;
}
// cache the last 2 vertices (for strips)
if (1 < mVertexCount)
{
mVertex1 = mVertex0;
mVertex0 = vertex;
}
else
{
mVertex0 = vertex;
}
return *this;
}
PX_INLINE PxDebugLine* PxRenderOutput::reserveSegments(PxU32 nbSegments)
{
return mBuffer.reserveLines(nbSegments);
}
PX_INLINE PxDebugPoint* PxRenderOutput::reservePoints(PxU32 nbPoints)
{
return mBuffer.reservePoints(nbPoints);
}
// PT: using the operators is just too slow.
PX_INLINE void PxRenderOutput::outputSegment(const PxVec3& v0, const PxVec3& v1)
{
PxDebugLine* segment = mBuffer.reserveLines(1);
segment->pos0 = v0;
segment->pos1 = v1;
segment->color0 = segment->color1 = mColor;
}
PX_INLINE PxRenderOutput& PxRenderOutput::outputCapsule(PxF32 radius, PxF32 halfHeight, const PxMat44& absPose)
{
PxRenderOutput& out = *this;
const PxVec3 vleft2(-halfHeight, 0.0f, 0.0f);
PxMat44 left2 = absPose;
left2.column3 += PxVec4(left2.rotate(vleft2), 0.0f);
out << left2 << PxDebugArc(100, radius, PxPi, PxTwoPi);
PxMat44 rotPose = left2;
PxSwap(rotPose.column1, rotPose.column2);
rotPose.column1 = -rotPose.column1;
out << rotPose << PxDebugArc(100, radius, PxPi, PxTwoPi);
PxSwap(rotPose.column0, rotPose.column2);
rotPose.column0 = -rotPose.column0;
out << rotPose << PxDebugCircle(100, radius);
const PxVec3 vright2(halfHeight, 0.0f, 0.0f);
PxMat44 right2 = absPose;
right2.column3 += PxVec4(right2.rotate(vright2), 0.0f);
out << right2 << PxDebugArc(100, radius, 0.0f, PxPi);
rotPose = right2;
PxSwap(rotPose.column1, rotPose.column2);
rotPose.column1 = -rotPose.column1;
out << rotPose << PxDebugArc(100, radius, 0.0f, PxPi);
PxSwap(rotPose.column0, rotPose.column2);
rotPose.column0 = -rotPose.column0;
out << rotPose << PxDebugCircle(100, radius);
out << absPose;
out.outputSegment(absPose.transform(PxVec3(-halfHeight, radius, 0)),
absPose.transform(PxVec3(halfHeight, radius, 0)));
out.outputSegment(absPose.transform(PxVec3(-halfHeight, -radius, 0)),
absPose.transform(PxVec3(halfHeight, -radius, 0)));
out.outputSegment(absPose.transform(PxVec3(-halfHeight, 0, radius)),
absPose.transform(PxVec3(halfHeight, 0, radius)));
out.outputSegment(absPose.transform(PxVec3(-halfHeight, 0, -radius)),
absPose.transform(PxVec3(halfHeight, 0, -radius)));
return *this;
}
#if PX_VC
#pragma warning(pop)
#endif
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,385 @@
// 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_SERIAL_FRAMEWORK_H
#define PX_SERIAL_FRAMEWORK_H
#include "common/PxPhysXCommonConfig.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
#if !PX_DOXYGEN // need to exclude, confuses api doc build about duplicate declaration
typedef PxU16 PxType;
#endif
class PxBase;
class PxSerializationContext;
class PxRepXSerializer;
class PxSerializer;
class PxPhysics;
class PxCollection;
class PxOutputStream;
//! Default serialization alignment
#define PX_SERIAL_ALIGN 16
//! Serialized input data must be aligned to this value
#define PX_SERIAL_FILE_ALIGN 128
//! PxSerialObjectId value for objects that do not have an ID
#define PX_SERIAL_OBJECT_ID_INVALID 0
//! ID type for PxBase objects in a PxCollection
typedef PxU64 PxSerialObjectId;
//! Bit to mark pointer type references, \see PxDeserializationContext
#define PX_SERIAL_REF_KIND_PTR_TYPE_BIT (1u<<31)
//! Reference kind value for PxBase objects
#define PX_SERIAL_REF_KIND_PXBASE (0 | PX_SERIAL_REF_KIND_PTR_TYPE_BIT)
//! Reference kind value for material indices
#define PX_SERIAL_REF_KIND_MATERIAL_IDX (1)
//! Used to fix multi-byte characters warning from gcc for situations like: PxU32 foo = 'CCTS';
#define PX_MAKE_FOURCC(a, b, c, d) ( (a) | ((b)<<8) | ((c)<<16) | ((d)<<24) )
/**
\brief Callback class used to process PxBase objects.
\see PxSerializer::requires
*/
class PxProcessPxBaseCallback
{
public:
virtual ~PxProcessPxBaseCallback() {}
virtual void process(PxBase&) = 0;
};
/**
\brief Binary serialization context class.
This class is used to register reference values and write object
and object extra data during serialization.
It is mainly used by the serialization framework. Except for custom
serializable types, users should not have to worry about it.
\see PxDeserializationContext
*/
class PxSerializationContext
{
public:
/**
\brief Registers a reference value corresponding to a PxBase object.
This method is assumed to be called in the implementation of PxSerializer::registerReferences for serialized
references that need to be resolved on deserialization.
A reference needs to be associated with exactly one PxBase object in either the collection or the
external references collection.
Different kinds of references are supported and need to be specified. In the most common case
(PX_SERIAL_REF_KIND_PXBASE) the PxBase object matches the reference value (which is the pointer
to the PxBase object). Integer references maybe registered as well (used for internal material
indices with PX_SERIAL_REF_KIND_MATERIAL_IDX). Other kinds could be added with the restriction that
for pointer types the kind value needs to be marked with the PX_SERIAL_REF_KIND_PTR_TYPE_BIT.
\param[in] base PxBase object associated with the reference
\param[in] kind What kind of reference this is (PX_SERIAL_REF_KIND_PXBASE, PX_SERIAL_REF_KIND_MATERIAL_IDX or custom kind)
\param[in] reference Value of reference
\see PxDeserializationContext::resolveReference, PX_SERIAL_REF_KIND_PXBASE, PX_SERIAL_REF_KIND_MATERIAL_IDX, PxSerializer::registerReferences
*/
virtual void registerReference(PxBase& base, PxU32 kind, size_t reference) = 0;
/**
\brief Returns the collection that is being serialized.
*/
virtual const PxCollection& getCollection() const = 0;
/**
\brief Serializes object data and object extra data.
This function is assumed to be called within the implementation of PxSerializer::exportData and PxSerializer::exportExtraData.
\see PxSerializer::exportData, PxSerializer::exportExtraData, PxSerializer::createObject, PxDeserializationContext::readExtraData
*/
virtual void writeData(const void* data, PxU32 size) = 0;
/**
\brief Aligns the serialized data.
This function is assumed to be called within the implementation of PxSerializer::exportData and PxSerializer::exportExtraData.
\see PxSerializer::exportData, PxSerializer::exportExtraData, PxDeserializationContext::alignExtraData
*/
virtual void alignData(PxU32 alignment = PX_SERIAL_ALIGN) = 0;
/**
\brief Helper function to write a name to the extraData if serialization is configured to save names.
This function is assumed to be called within the implementation of PxSerializer::exportExtraData.
\see PxSerialization::serializeCollectionToBinary, PxDeserializationContext::readName
*/
virtual void writeName(const char* name) = 0;
protected:
PxSerializationContext() {}
virtual ~PxSerializationContext() {}
};
/**
\brief Binary deserialization context class.
This class is used to resolve references and access extra data during deserialization.
It is mainly used by the serialization framework. Except for custom
serializable types, users should not have to worry about it.
\see PxSerializationContext
*/
class PxDeserializationContext
{
public:
/**
\brief Retrieves a pointer to a deserialized PxBase object given a corresponding deserialized reference value
This method is assumed to be called in the implementation of PxSerializer::createObject in order
to update reference values on deserialization.
To update a PxBase reference the corresponding deserialized pointer value needs to be provided in order to retrieve
the location of the corresponding deserialized PxBase object. (PxDeserializationContext::translatePxBase simplifies
this common case).
For other kinds of references the reverence values need to be updated by deduction given the corresponding PxBase instance.
\param[in] kind What kind of reference this is (PX_SERIAL_REF_KIND_PXBASE, PX_SERIAL_REF_KIND_MATERIAL_IDX or custom kind)
\param[in] reference Deserialized reference value
\return PxBase object associated with the reference value
\see PxSerializationContext::registerReference, PX_SERIAL_REF_KIND_PXBASE, PX_SERIAL_REF_KIND_MATERIAL_IDX, translatePxBase
*/
virtual PxBase* resolveReference(PxU32 kind, size_t reference) const = 0;
/**
\brief Helper function to update PxBase pointer on deserialization
\see resolveReference, PX_SERIAL_REF_KIND_PXBASE
*/
template<typename T>
void translatePxBase(T*& base) { if (base) { base = static_cast<T*>(resolveReference(PX_SERIAL_REF_KIND_PXBASE, size_t(base))); } }
/**
\brief Helper function to read a name from the extra data during deserialization.
This function is assumed to be called within the implementation of PxSerializer::createObject.
\see PxSerializationContext::writeName
*/
PX_INLINE void readName(const char*& name)
{
PxU32 len = *reinterpret_cast<PxU32*>(mExtraDataAddress);
mExtraDataAddress += sizeof(len);
name = len ? reinterpret_cast<const char*>(mExtraDataAddress) : NULL;
mExtraDataAddress += len;
}
/**
\brief Function to read extra data during deserialization.
This function is assumed to be called within the implementation of PxSerializer::createObject.
\see PxSerializationContext::writeData, PxSerializer::createObject
*/
template<typename T>
PX_INLINE T* readExtraData(PxU32 count=1)
{
T* data = reinterpret_cast<T*>(mExtraDataAddress);
mExtraDataAddress += sizeof(T)*count;
return data;
}
/**
\brief Function to read extra data during deserialization optionally aligning the extra data stream before reading.
This function is assumed to be called within the implementation of PxSerializer::createObject.
\see PxSerializationContext::writeData, PxDeserializationContext::alignExtraData, PxSerializer::createObject
*/
template<typename T, PxU32 alignment>
PX_INLINE T* readExtraData(PxU32 count=1)
{
alignExtraData(alignment);
return readExtraData<T>(count);
}
/**
\brief Function to align the extra data stream to a power of 2 alignment
This function is assumed to be called within the implementation of PxSerializer::createObject.
\see PxSerializationContext::alignData, PxSerializer::createObject
*/
PX_INLINE void alignExtraData(PxU32 alignment = PX_SERIAL_ALIGN)
{
size_t addr = size_t(mExtraDataAddress);
addr = (addr+alignment-1)&~size_t(alignment-1);
mExtraDataAddress = reinterpret_cast<PxU8*>(addr);
}
protected:
PxDeserializationContext() {}
virtual ~PxDeserializationContext() {}
PxU8* mExtraDataAddress;
};
/**
\brief Class serving as a registry for XML (RepX) and binary serializable types.
In order to serialize and deserialize objects the application needs
to maintain an instance of this class. It can be created with
PxSerialization::createSerializationRegistry() and released with
PxSerializationRegistry::release().
\see PxSerialization::createSerializationRegistry
*/
class PxSerializationRegistry
{
public:
/************************************************************************************************/
/** \name Binary Serialization Functionality
*/
//\{
/**
\brief Register a serializer for a concrete type
\param type PxConcreteType corresponding to the serializer
\param serializer The PxSerializer to be registered
\see PxConcreteType, PxSerializer, PxSerializationRegistry::unregisterSerializer
*/
virtual void registerSerializer(PxType type, PxSerializer& serializer) = 0;
/**
\brief Unregister a serializer for a concrete type, and retrieves the corresponding serializer object.
\param type PxConcreteType for which the serializer should be unregistered
\return Unregistered serializer corresponding to type, NULL for types for which no serializer has been registered.
\see PxConcreteType, PxSerializationRegistry::registerSerializer, PxSerializationRegistry::release
*/
virtual PxSerializer* unregisterSerializer(PxType type) = 0;
/**
\brief Returns PxSerializer corresponding to type
\param type PxConcreteType of the serializer requested.
\return Registered PxSerializer object corresponding to type
\see PxConcreteType
*/
virtual const PxSerializer* getSerializer(PxType type) const = 0;
//\}
/************************************************************************************************/
/** \name RepX (XML) Serialization Functionality
*/
//\{
/**
\brief Register a RepX serializer for a concrete type
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
\param type PxConcreteType corresponding to the RepX serializer
\param serializer The PxRepXSerializer to be registered
\see PxConcreteType, PxRepXSerializer
*/
PX_DEPRECATED virtual void registerRepXSerializer(PxType type, PxRepXSerializer& serializer) = 0;
/**
\brief Unregister a RepX serializer for a concrete type, and retrieves the corresponding serializer object.
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
\param type PxConcreteType for which the RepX serializer should be unregistered
\return Unregistered PxRepxSerializer corresponding to type, NULL for types for which no RepX serializer has been registered.
\see PxConcreteType, PxSerializationRegistry::registerRepXSerializer, PxSerializationRegistry::release
*/
PX_DEPRECATED virtual PxRepXSerializer* unregisterRepXSerializer(PxType type) = 0;
/**
\brief Returns RepX serializer given the corresponding type name
\deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics.
\param typeName Name of the type
\return Registered PxRepXSerializer object corresponding to type name
\see PxRepXSerializer, PxTypeInfo, PX_DEFINE_TYPEINFO
*/
PX_DEPRECATED virtual PxRepXSerializer* getRepXSerializer(const char* typeName) const = 0;
//\}
/************************************************************************************************/
/**
\brief Releases PxSerializationRegistry instance.
This unregisters all PhysX and PhysXExtension serializers. Make sure to unregister all custom type
serializers before releasing the PxSerializationRegistry.
\see PxSerializationRegistry::unregisterSerializer, PxSerializationRegistry::unregisterRepXSerializer
*/
virtual void release() = 0;
protected:
virtual ~PxSerializationRegistry(){}
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,259 @@
// 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_SERIALIZER_H
#define PX_SERIALIZER_H
#include "foundation/PxAssert.h"
#include "foundation/PxAllocatorCallback.h"
#include "foundation/PxFoundation.h"
#include "common/PxSerialFramework.h"
#include "common/PxCollection.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief Serialization interface class.
PxSerializer is used to extend serializable PxBase classes with serialization functionality. The
interface is structured such that per-class adapter instances can be used as opposed to per-object
adapter instances, avoiding per object allocations. Hence the methods take a reference to PxBase as a parameter.
The PxSerializer interface needs to be implemented for binary or RepX serialization to work on custom
types. If only RepX serialization is needed, some methods can be left empty, as they are only needed
for binary serialization.
A default implementation is available as a template adapter (PxSerializerDefaultAdapter).
\see PxSerializerDefaultAdapter, PX_NEW_SERIALIZER_ADAPTER, PxSerializationRegistry::registerSerializer
*/
class PxSerializer
{
public:
/**********************************************************************************************************************/
/** \name Basics needed for Binary- and RepX-Serialization
*/
//\{
/**
\brief Returns string name of dynamic type.
\return Class name of most derived type of this object.
*/
virtual const char* getConcreteTypeName() const = 0;
/**
\brief Adds required objects to the collection.
This method does not add the required objects recursively, e.g. objects required by required objects.
\see PxCollection, PxSerialization::complete
*/
virtual void requiresObjects(PxBase&, PxProcessPxBaseCallback&) const = 0;
/**
\brief Whether the object is subordinate.
A class is subordinate, if it can only be instantiated in the context of another class.
\return Whether the class is subordinate
\see PxSerialization::isSerializable
*/
virtual bool isSubordinate() const = 0;
//\}
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/** \name Functionality needed for Binary Serialization only
*/
//\{
/**
\brief Exports object's extra data to stream.
*/
virtual void exportExtraData(PxBase&, PxSerializationContext&) const = 0;
/**
\brief Exports object's data to stream.
*/
virtual void exportData(PxBase&, PxSerializationContext&) const = 0;
/**
\brief Register references that the object maintains to other objects.
*/
virtual void registerReferences(PxBase& obj, PxSerializationContext& s) const = 0;
/**
\brief Returns size needed to create the class instance.
\return sizeof class instance.
*/
virtual size_t getClassSize() const = 0;
/**
\brief Create object at a given address, resolve references and import extra data.
\param address Location at which object is created. Address is increased by the size of the created object.
\param context Context for reading external data and resolving references.
\return Created PxBase pointer (needs to be identical to address before increment).
*/
virtual PxBase* createObject(PxU8*& address, PxDeserializationContext& context) const = 0;
//\}
/**********************************************************************************************************************/
virtual ~PxSerializer() {}
};
/**
\brief Default PxSerializer implementation.
*/
template<class T>
class PxSerializerDefaultAdapter : public PxSerializer
{
public:
/************************************************************************************************/
/** \name Basics needed for Binary- and RepX-Serialization
*/
//\{
PxSerializerDefaultAdapter(const char* name) : mTypeName(name){}
virtual const char* getConcreteTypeName() const
{
return mTypeName;
}
virtual void requiresObjects(PxBase& obj, PxProcessPxBaseCallback& c) const
{
T& t = static_cast<T&>(obj);
t.requiresObjects(c);
}
virtual bool isSubordinate() const
{
return false;
}
//\}
/************************************************************************************************/
/** \name Functionality needed for Binary Serialization only
*/
//\{
// object methods
virtual void exportExtraData(PxBase& obj, PxSerializationContext& s) const
{
T& t = static_cast<T&>(obj);
t.exportExtraData(s);
}
virtual void exportData(PxBase& obj, PxSerializationContext& s) const
{
PxAllocatorCallback& allocator = *PxGetAllocatorCallback();
T* copy = reinterpret_cast<T*>(allocator.allocate(sizeof(T), "TmpAllocExportData", PX_FL));
PxMemCopy(copy, &obj, sizeof(T));
copy->preExportDataReset();
s.writeData(copy, sizeof(T));
allocator.deallocate(copy);
}
virtual void registerReferences(PxBase& obj, PxSerializationContext& s) const
{
T& t = static_cast<T&>(obj);
s.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj));
struct RequiresCallback : public PxProcessPxBaseCallback
{
RequiresCallback(PxSerializationContext& c) : context(c) {}
RequiresCallback& operator=(RequiresCallback&) { PX_ASSERT(0); return *this; }
void process(physx::PxBase& base)
{
context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE, size_t(&base));
}
PxSerializationContext& context;
};
RequiresCallback callback(s);
t.requiresObjects(callback);
}
// class methods
virtual size_t getClassSize() const
{
return sizeof(T);
}
virtual PxBase* createObject(PxU8*& address, PxDeserializationContext& context) const
{
return T::createObject(address, context);
}
//\}
/************************************************************************************************/
private:
const char* mTypeName;
};
/**
\brief Preprocessor Macro to simplify adapter creation.
Note: that the allocator used for creation needs to match with the one used in PX_DELETE_SERIALIZER_ADAPTER.
*/
#define PX_NEW_SERIALIZER_ADAPTER(x) \
*new( PxGetAllocatorCallback()->allocate(sizeof(PxSerializerDefaultAdapter<x>), \
"PxSerializerDefaultAdapter", PX_FL)) PxSerializerDefaultAdapter<x>(#x)
/**
\brief Preprocessor Macro to simplify adapter deletion.
*/
#define PX_DELETE_SERIALIZER_ADAPTER(x) \
{ PxSerializer* s = x; if (s) { s->~PxSerializer(); PxGetAllocatorCallback()->deallocate(s); } }
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,67 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_STRING_TABLE_H
#define PX_STRING_TABLE_H
#include "foundation/PxPreprocessor.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
* \brief a table to manage strings. Strings allocated through this object are expected to be owned by this object.
*/
class PxStringTable
{
protected:
virtual ~PxStringTable(){}
public:
/**
* \brief Allocate a new string.
*
* \param[in] inSrc Source string, null terminated or null.
*
* \return *Always* a valid null terminated string. "" is returned if "" or null is passed in.
*/
virtual const char* allocateStr( const char* inSrc ) = 0;
/**
* Release the string table and all the strings associated with it.
*/
virtual void release() = 0;
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,103 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOLERANCES_SCALE_H
#define PX_TOLERANCES_SCALE_H
#include "common/PxPhysXCommonConfig.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief Class to define the scale at which simulation runs. Most simulation tolerances are
calculated in terms of the values here.
\note if you change the simulation scale, you will probably also wish to change the scene's
default value of gravity, and stable simulation will probably require changes to the scene's
bounceThreshold also.
*/
class PxTolerancesScale
{
public:
/**
\brief The approximate size of objects in the simulation.
For simulating roughly human-sized in metric units, 1 is a good choice.
If simulation is done in centimetres, use 100 instead. This is used to
estimate certain length-related tolerances.
*/
PxReal length;
/**
\brief The typical magnitude of velocities of objects in simulation. This is used to estimate
whether a contact should be treated as bouncing or resting based on its impact velocity,
and a kinetic energy threshold below which the simulation may put objects to sleep.
For normal physical environments, a good choice is the approximate speed of an object falling
under gravity for one second.
*/
PxReal speed;
/**
\brief constructor sets to default
\param[in] defaultLength Default length
\param[in] defaultSpeed Default speed
*/
PX_INLINE explicit PxTolerancesScale(float defaultLength=1.0f, float defaultSpeed=10.0f);
/**
\brief Returns true if the descriptor is valid.
\return true if the current settings are valid (returns always true).
*/
PX_INLINE bool isValid() const;
};
PX_INLINE PxTolerancesScale::PxTolerancesScale(float defaultLength, float defaultSpeed) :
length (defaultLength),
speed (defaultSpeed)
{
}
PX_INLINE bool PxTolerancesScale::isValid() const
{
return length>0.0f;
}
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View 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_TYPE_INFO_H
#define PX_TYPE_INFO_H
#include "common/PxPhysXCommonConfig.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief an enumeration of concrete classes inheriting from PxBase
Enumeration space is reserved for future PhysX core types, PhysXExtensions,
PhysXVehicle and Custom application types.
\see PxBase, PxTypeInfo
*/
struct PxConcreteType
{
enum Enum
{
eUNDEFINED,
eHEIGHTFIELD,
eCONVEX_MESH,
eTRIANGLE_MESH_BVH33 PX_DEPRECATED, //!< \deprecated Will be removed together with deprecated BVH33.
eTRIANGLE_MESH_BVH34,
eTETRAHEDRON_MESH,
eDEFORMABLE_VOLUME_MESH,
eSOFTBODY_MESH PX_DEPRECATED = eDEFORMABLE_VOLUME_MESH, //!< \deprecated
eRIGID_DYNAMIC,
eRIGID_STATIC,
eSHAPE,
eMATERIAL,
eDEFORMABLE_SURFACE_MATERIAL,
eDEFORMABLE_VOLUME_MATERIAL,
eSOFTBODY_MATERIAL PX_DEPRECATED = eDEFORMABLE_VOLUME_MATERIAL, //!< \deprecated
ePBD_MATERIAL,
eCONSTRAINT,
eAGGREGATE,
eARTICULATION_REDUCED_COORDINATE,
eARTICULATION_LINK,
eARTICULATION_JOINT_REDUCED_COORDINATE,
eARTICULATION_SPATIAL_TENDON,
eARTICULATION_FIXED_TENDON,
eARTICULATION_ATTACHMENT,
eARTICULATION_TENDON_JOINT,
eARTICULATION_MIMIC_JOINT,
ePRUNING_STRUCTURE,
eBVH,
eDEFORMABLE_VOLUME,
eSOFT_BODY PX_DEPRECATED = eDEFORMABLE_VOLUME, //!< \deprecated
eDEFORMABLE_VOLUME_STATE,
eSOFT_BODY_STATE PX_DEPRECATED = eDEFORMABLE_VOLUME_STATE, //!< \deprecated
ePBD_PARTICLESYSTEM,
eDEFORMABLE_SURFACE,
eDEFORMABLE_ATTACHMENT,
eDEFORMABLE_ELEMENT_FILTER,
ePARTICLE_BUFFER,
ePARTICLE_DIFFUSE_BUFFER,
ePARTICLE_CLOTH_BUFFER,
ePARTICLE_RIGID_BUFFER,
ePHYSX_CORE_COUNT,
eFIRST_PHYSX_EXTENSION = 256,
eFIRST_VEHICLE_EXTENSION = 512,
eFIRST_USER_EXTENSION = 1024
};
};
/**
\brief a structure containing per-type information for types inheriting from PxBase
\see PxBase, PxConcreteType
*/
template<typename T> struct PxTypeInfo {};
#define PX_DEFINE_TYPEINFO(_name, _fastType) \
class _name; \
template <> struct PxTypeInfo<_name> { static const char* name() { return #_name; } enum { eFastTypeId = _fastType }; };
/* the semantics of the fastType are as follows: an object A can be cast to a type B if B's fastType is defined, and A has the same fastType.
* This implies that B has no concrete subclasses or superclasses.
*/
PX_DEFINE_TYPEINFO(PxBase, PxConcreteType::eUNDEFINED)
PX_DEFINE_TYPEINFO(PxMaterial, PxConcreteType::eMATERIAL)
PX_DEFINE_TYPEINFO(PxDeformableSurfaceMaterial, PxConcreteType::eDEFORMABLE_SURFACE_MATERIAL)
PX_DEFINE_TYPEINFO(PxDeformableVolumeMaterial, PxConcreteType::eDEFORMABLE_VOLUME_MATERIAL)
PX_DEFINE_TYPEINFO(PxPBDMaterial, PxConcreteType::ePBD_MATERIAL)
PX_DEFINE_TYPEINFO(PxConvexMesh, PxConcreteType::eCONVEX_MESH)
PX_DEFINE_TYPEINFO(PxTriangleMesh, PxConcreteType::eUNDEFINED)
PX_DEFINE_TYPEINFO(PxBVH33TriangleMesh, PxConcreteType::eTRIANGLE_MESH_BVH33)
PX_DEFINE_TYPEINFO(PxBVH34TriangleMesh, PxConcreteType::eTRIANGLE_MESH_BVH34)
PX_DEFINE_TYPEINFO(PxTetrahedronMesh, PxConcreteType::eTETRAHEDRON_MESH)
PX_DEFINE_TYPEINFO(PxHeightField, PxConcreteType::eHEIGHTFIELD)
PX_DEFINE_TYPEINFO(PxActor, PxConcreteType::eUNDEFINED)
PX_DEFINE_TYPEINFO(PxRigidActor, PxConcreteType::eUNDEFINED)
PX_DEFINE_TYPEINFO(PxRigidBody, PxConcreteType::eUNDEFINED)
PX_DEFINE_TYPEINFO(PxRigidDynamic, PxConcreteType::eRIGID_DYNAMIC)
PX_DEFINE_TYPEINFO(PxRigidStatic, PxConcreteType::eRIGID_STATIC)
PX_DEFINE_TYPEINFO(PxArticulationLink, PxConcreteType::eARTICULATION_LINK)
PX_DEFINE_TYPEINFO(PxArticulationJointReducedCoordinate, PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE)
PX_DEFINE_TYPEINFO(PxArticulationReducedCoordinate, PxConcreteType::eARTICULATION_REDUCED_COORDINATE)
PX_DEFINE_TYPEINFO(PxAggregate, PxConcreteType::eAGGREGATE)
PX_DEFINE_TYPEINFO(PxConstraint, PxConcreteType::eCONSTRAINT)
PX_DEFINE_TYPEINFO(PxShape, PxConcreteType::eSHAPE)
PX_DEFINE_TYPEINFO(PxPruningStructure, PxConcreteType::ePRUNING_STRUCTURE)
PX_DEFINE_TYPEINFO(PxPBDParticleSystem, PxConcreteType::ePBD_PARTICLESYSTEM)
PX_DEFINE_TYPEINFO(PxDeformableSurface, PxConcreteType::eDEFORMABLE_SURFACE)
PX_DEFINE_TYPEINFO(PxDeformableVolume, PxConcreteType::eDEFORMABLE_VOLUME)
PX_DEFINE_TYPEINFO(PxDeformableAttachment, PxConcreteType::eDEFORMABLE_ATTACHMENT)
PX_DEFINE_TYPEINFO(PxDeformableElementFilter, PxConcreteType::eDEFORMABLE_ELEMENT_FILTER)
PX_DEFINE_TYPEINFO(PxParticleBuffer, PxConcreteType::ePARTICLE_BUFFER)
PX_DEFINE_TYPEINFO(PxParticleAndDiffuseBuffer, PxConcreteType::ePARTICLE_DIFFUSE_BUFFER)
PX_DEFINE_TYPEINFO(PxParticleClothBuffer, PxConcreteType::ePARTICLE_CLOTH_BUFFER)
PX_DEFINE_TYPEINFO(PxParticleRigidBuffer, PxConcreteType::ePARTICLE_RIGID_BUFFER)
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif

View File

@@ -0,0 +1,96 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_WINDOWS_DELAY_LOAD_HOOK_H
#define PX_WINDOWS_DELAY_LOAD_HOOK_H
#include "foundation/PxPreprocessor.h"
#include "common/PxPhysXCommonConfig.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
/**
\brief PxDelayLoadHook
This is a helper class for delay loading the PhysXCommon dll and PhysXFoundation dll.
If a PhysXCommon dll or PhysXFoundation dll with a non-default file name needs to be loaded,
PxDelayLoadHook can be sub-classed to provide the custom filenames.
Once the names are set, the instance must be set for use by PhysX.dll using PxSetPhysXDelayLoadHook(),
PhysXCooking.dll using PxSetPhysXCookingDelayLoadHook() or by PhysXCommon.dll using PxSetPhysXCommonDelayLoadHook().
\see PxSetPhysXDelayLoadHook(), PxSetPhysXCookingDelayLoadHook(), PxSetPhysXCommonDelayLoadHook()
*/
class PxDelayLoadHook
{
public:
PxDelayLoadHook() {}
virtual ~PxDelayLoadHook() {}
virtual const char* getPhysXFoundationDllName() const = 0;
virtual const char* getPhysXCommonDllName() const = 0;
protected:
private:
};
/**
\brief Sets delay load hook instance for PhysX dll.
\param[in] hook Delay load hook.
\see PxDelayLoadHook
*/
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxSetPhysXDelayLoadHook(const physx::PxDelayLoadHook* hook);
/**
\brief Sets delay load hook instance for PhysXCooking dll.
\param[in] hook Delay load hook.
\see PxDelayLoadHook
*/
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxSetPhysXCookingDelayLoadHook(const physx::PxDelayLoadHook* hook);
/**
\brief Sets delay load hook instance for PhysXCommon dll.
\param[in] hook Delay load hook.
\see PxDelayLoadHook
*/
PX_C_EXPORT PX_PHYSX_COMMON_API void PX_CALL_CONV PxSetPhysXCommonDelayLoadHook(const physx::PxDelayLoadHook* hook);
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif