aboutsummaryrefslogtreecommitdiff
path: root/sdk/extensions/physx/include
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
committerBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
commite1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch)
tree9f0cfce09c71a2c27ff19589fcad6cd83504477c /sdk/extensions/physx/include
parentfirst commit (diff)
downloadblast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz
blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'sdk/extensions/physx/include')
-rw-r--r--sdk/extensions/physx/include/NvBlastExtImpactDamageManager.h142
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPx.h29
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPxActor.h83
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPxAsset.h201
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPxFamily.h223
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPxListener.h55
-rw-r--r--sdk/extensions/physx/include/NvBlastExtPxManager.h245
-rw-r--r--sdk/extensions/physx/include/NvBlastExtStressSolver.h209
-rw-r--r--sdk/extensions/physx/include/NvBlastExtSync.h213
9 files changed, 1400 insertions, 0 deletions
diff --git a/sdk/extensions/physx/include/NvBlastExtImpactDamageManager.h b/sdk/extensions/physx/include/NvBlastExtImpactDamageManager.h
new file mode 100644
index 0000000..ac3576d
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtImpactDamageManager.h
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTIMPACTDAMAGEMANAGER_H
+#define NVBLASTEXTIMPACTDAMAGEMANAGER_H
+
+#include "PxFiltering.h"
+#include "NvPreprocessor.h"
+
+// Forward declarations
+namespace physx
+{
+struct PxContactPair;
+struct PxContactPairHeader;
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class ExtPxActor;
+class ExtPxManager;
+
+
+/**
+Custom Damage Function
+*/
+typedef bool(*ExtImpactDamageFunction)(void* data, ExtPxActor* actor, physx::PxShape* shape, physx::PxVec3 worldPos, physx::PxVec3 worldForce);
+
+
+/**
+Impact Damage Manager Settings.
+*/
+struct ExtImpactSettings
+{
+ bool isSelfCollissionEnabled; //!< family's self collision enabled
+ float fragility; //!< global fragility factor
+ ExtImpactDamageFunction damageFunction; //!< custom damage function, can be nullptr, default internal one will be used in that case.
+ void* damageFunctionData; //!< data to be passed in custom damage function
+
+
+ ExtImpactSettings() :
+ isSelfCollissionEnabled(false),
+ fragility(1.0f),
+ damageFunction(nullptr)
+ {}
+};
+
+
+/**
+Impact Damage Manager.
+
+Requires ExtPxManager.
+Call onContact from PxSimulationEventCallback onContact to accumulate damage.
+Call applyDamage to apply accumulated damage.
+*/
+class NV_DLL_EXPORT ExtImpactDamageManager
+{
+public:
+ //////// manager creation ////////
+
+ /**
+ Create a new ExtImpactDamageManager.
+
+ \param[in] pxManager The ExtPxManager instance to be used by impact damage manager.
+ \param[in] settings The settings to be set on ExtImpactDamageManager.
+
+ \return the new ExtImpactDamageManager if successful, NULL otherwise.
+ */
+ static ExtImpactDamageManager* create(ExtPxManager* pxManager, ExtImpactSettings settings = ExtImpactSettings());
+
+ /**
+ Release this manager.
+ */
+ virtual void release() = 0;
+
+
+ //////// interface ////////
+
+ /**
+ Set ExtImpactDamageManager settings.
+
+ \param[in] settings The settings to be set on ExtImpactDamageManager.
+ */
+ virtual void setSettings(const ExtImpactSettings& settings) = 0;
+
+ /**
+ This method is equal to PxSimulationEventCallback::onContact.
+
+ User should implement own PxSimulationEventCallback onContact and call this method in order ExtImpactDamageManager to work correctly.
+
+ Contacts will be processed and impact damage will be accumulated.
+
+ \param[in] pairHeader Information on the two actors whose shapes triggered a contact report.
+ \param[in] pairs The contact pairs of two actors for which contact reports have been requested. @see PxContactPair.
+ \param[in] nbPairs The number of provided contact pairs.
+
+ @see PxSimulationEventCallback
+ */
+ virtual void onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, uint32_t nbPairs) = 0;
+
+
+ /**
+ Apply accumulated impact damage.
+ */
+ virtual void applyDamage() = 0;
+
+
+ //////// filter shader ////////
+
+ /**
+ Custom implementation of PxSimulationFilterShader, enables necessary information to be passed in onContact().
+ Set it in your PxScene PxSceneDesc in order to impact damage to work correctly or implement your own.
+
+ @see PxSimulationFilterShader
+ */
+ static physx::PxFilterFlags FilterShader(
+ physx::PxFilterObjectAttributes attributes0,
+ physx::PxFilterData filterData0,
+ physx::PxFilterObjectAttributes attributes1,
+ physx::PxFilterData filterData1,
+ physx::PxPairFlags& pairFlags,
+ const void* constantBlock,
+ uint32_t constantBlockSize);
+
+};
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTIMPACTDAMAGEMANAGER_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPx.h b/sdk/extensions/physx/include/NvBlastExtPx.h
new file mode 100644
index 0000000..b2d938b
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPx.h
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPX_H
+#define NVBLASTEXTPX_H
+
+
+/**
+This is the main include header for the BlastExt Physics, for users who
+want to use a single #include file.
+
+Alternatively, one can instead directly #include a subset of the below files.
+*/
+
+#include "NvBlastExtPxActor.h"
+#include "NvBlastExtPxAsset.h"
+#include "NvBlastExtPxFamily.h"
+#include "NvBlastExtPxListener.h"
+#include "NvBlastExtPxManager.h"
+
+
+#endif // ifndef NVBLASTEXTPX_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPxActor.h b/sdk/extensions/physx/include/NvBlastExtPxActor.h
new file mode 100644
index 0000000..994ace7
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPxActor.h
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPXACTOR_H
+#define NVBLASTEXTPXACTOR_H
+
+#include "NvBlastTypes.h"
+
+
+// Forward declarations
+namespace physx
+{
+ class PxRigidDynamic;
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class ExtPxFamily;
+class TkActor;
+
+
+/**
+Actor.
+
+Corresponds one to one to PxRigidDynamic and ExtActor.
+*/
+class ExtPxActor
+{
+public:
+ /**
+ Get the number of visible chunks for this actor. May be used in conjunction with getChunkIndices().
+
+ \return the number of visible chunk indices for the actor.
+ */
+ virtual uint32_t getChunkCount() const = 0;
+
+ /**
+ Access actor's array of chunk indices. Use getChunkCount() to get a size of this array.
+
+ \return a pointer to an array of chunk indices of an actor.
+ */
+ virtual const uint32_t* getChunkIndices() const = 0;
+
+ /**
+ Every actor has corresponding PxActor.
+
+ /return a pointer to PxRigidDynamic actor.
+ */
+ virtual physx::PxRigidDynamic& getPhysXActor() const = 0;
+
+ /**
+ Every actor has corresponding TkActor.
+
+ /return a pointer to TkActor actor.
+ */
+ virtual TkActor& getTkActor() const = 0;
+
+ /**
+ Every actor has corresponding ExtPxFamily.
+
+ /return a pointer to ExtPxFamily family.
+ */
+ virtual ExtPxFamily& getFamily() const = 0;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTPXACTOR_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPxAsset.h b/sdk/extensions/physx/include/NvBlastExtPxAsset.h
new file mode 100644
index 0000000..a4dbe0e
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPxAsset.h
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPXASSET_H
+#define NVBLASTEXTPXASSET_H
+
+#include "NvBlastTkFramework.h"
+#include "PxConvexMeshGeometry.h"
+#include "PxTransform.h"
+#include "NvBlastPreprocessor.h"
+
+
+// Forward declarations
+namespace physx
+{
+class PxCooking;
+
+namespace general_PxIOStream2
+{
+class PxFileBuf;
+}
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+/**
+Descriptor for PxAsset creation.
+
+PxAsset creates TkAsset internally, so TkAssetDesc must be filled.
+In addition it needs physics chunks data. Every chunk can have any amount of Convexes (Subchunks).
+*/
+struct ExtPxAssetDesc : public TkAssetDesc
+{
+ /**
+ Physics Subchunk.
+
+ Represents convex and it's position.
+ */
+ struct SubchunkDesc
+ {
+ physx::PxTransform transform; //!< convex local transform
+ physx::PxConvexMeshGeometry geometry; //!< convex geometry
+ };
+
+ /**
+ Physics Chunk.
+
+ Contains any amount of subchunks. Empty subchunks array makes chunk invisible.
+ */
+ struct ChunkDesc
+ {
+ SubchunkDesc* subchunks; //!< array of subchunks for chunk, can be empty
+ uint32_t subchunkCount; //!< size array of subchunks for chunk, can be 0
+ bool isStatic; //!< is chunk static. Static chunk makes PxActor Kinematic.
+ };
+
+ ChunkDesc* pxChunks; //!< array of chunks in asset, should be of size chunkCount (@see NvBlastAssetDesc)
+};
+
+
+/**
+Physics Subchunk.
+
+Represents convex and it's local position.
+*/
+struct ExtPxSubchunk
+{
+ physx::PxTransform transform; //!< convex local transform
+ physx::PxConvexMeshGeometry geometry; //!< convex geometry
+};
+
+
+/**
+Physics Chunk.
+
+Contains any amount of subchunks.
+*/
+struct ExtPxChunk
+{
+ uint32_t firstSubchunkIndex; //!< first Subchunk index in Subchunk's array in ExtPhyicsAsset
+ uint32_t subchunkCount; //!< Subchunk count. Can be 0.
+ bool isStatic; //!< is chunk static (kinematic)?.
+};
+
+
+/**
+Asset.
+
+Keeps all the static data needed for physics.
+*/
+class NV_DLL_EXPORT ExtPxAsset
+{
+public:
+
+ /**
+ Create a new ExtPxAsset.
+
+ \param[in] desc The ExtPxAssetDesc descriptor to be used, @see ExtPxAssetDesc.
+ \param[in] framework The TkFramework instance to be used to create TkAsset.
+
+ \return the new ExtPxAsset if successful, NULL otherwise.
+ */
+ static ExtPxAsset* create(const ExtPxAssetDesc& desc, TkFramework& framework);
+
+
+ /*
+ Factory method for deserialization
+
+ Doesn't specify chunks or subchunks as they'll be fed in during deserialization to avoid copying stuff around.
+
+ */
+ static ExtPxAsset* create(TkAsset* asset);
+
+
+ /**
+ Deserialize an ExtPxAsset object from the given stream.
+
+ \param[in] stream User-defined stream object.
+ \param[in] framework The TkFramework instance to be used to deserialize TkAsset.
+ \param[in] physics The PxPhysics instance to be to deserialize PxConvexMesh(s).
+
+ \return pointer the deserialized ExtPxAsset object if successful, or NULL if unsuccessful.
+ */
+ static ExtPxAsset* deserialize(physx::general_PxIOStream2::PxFileBuf& stream, TkFramework& framework, physx::PxPhysics& physics);
+
+ /**
+ Release this ExtPxAsset.
+ */
+ virtual void release() = 0;
+
+ /**
+ Write the asset's data to the user-defined PxFileBuf stream. Underlying TkAsset would be also serialized.
+
+ \param[in] stream User-defined stream object.
+ \param[in] cooking The PxCooking instance to be used to serialize PxConvexMesh(s).
+
+ \return true if serialization was successful, false otherwise.
+ */
+ virtual bool serialize(physx::general_PxIOStream2::PxFileBuf& stream, physx::PxCooking& cooking) const = 0;
+
+ /**
+ Every ExtPxAsset has corresponding TkAsset.
+
+ /return a pointer to TkAsset actor.
+ */
+ virtual const TkAsset& getTkAsset() const = 0;
+
+ /**
+ Get the number of chunks for this asset. May be used in conjunction with getChunks().
+
+ \return the number of chunks for the asset.
+ */
+ virtual uint32_t getChunkCount() const = 0;
+
+ /**
+ Access asset's array of chunks. Use getChunkCount() to get the size of this array.
+
+ \return a pointer to an array of chunk of an asset.
+ */
+ virtual const ExtPxChunk* getChunks() const = 0;
+
+ /**
+ Get the number of subchunks for this asset. May be used in conjunction with getSubchunks().
+ Subchunk count is the maximum value of ExtPxChunk: (firstSubchunkIndex + subchunkCount).
+
+ \return the number of subchunks for the asset.
+ */
+ virtual uint32_t getSubchunkCount() const = 0;
+
+ /**
+ Access asset's array of subchunks. Use getSubchunkCount() to get the size of this array.
+
+ \return a pointer to an array of subchunks of an asset.
+ */
+ virtual const ExtPxSubchunk* getSubchunks() const = 0;
+
+ /**
+ Pointer field available to the user.
+ */
+ void* userData;
+};
+
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTPXASSET_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPxFamily.h b/sdk/extensions/physx/include/NvBlastExtPxFamily.h
new file mode 100644
index 0000000..7805c15
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPxFamily.h
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPXFAMILY_H
+#define NVBLASTEXTPXFAMILY_H
+
+#include "PxFiltering.h"
+
+
+// Forward declarations
+namespace physx
+{
+class PxRigidDynamic;
+class PxMaterial;
+class PxScene;
+class PxTransform;
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class ExtPxActor;
+class ExtPxAsset;
+class ExtPxListener;
+class TkFamily;
+
+
+/**
+PxShape Desc.
+
+Used to set settings for newly created PxShapes.
+
+@see PxShape
+*/
+struct ExtPxShapeDescTemplate
+{
+ uint8_t flags; //!< PxShapeFlags flags
+ physx::PxFilterData simulationFilterData; //!< user definable collision filter data
+ physx::PxFilterData queryFilterData; //!< user definable query filter data.
+ float contactOffset; //!< contact offset
+ float restOffset; //!< rest offset
+};
+
+
+/**
+PxActor Desc.
+
+Used to set settings for newly created PxActors.
+*/
+struct ExtPxActorDescTemplate
+{
+ uint8_t flags; //!< actor flags
+};
+
+
+/**
+Physics Spawn Settings.
+
+This Struct unifies setting to be used when PhysX actors are created.
+*/
+struct ExtPxSpawnSettings
+{
+ physx::PxScene* scene; //!< PxScene for PxActors to be spawned
+ physx::PxMaterial* material; //!< default PxMaterial
+ float density; //!< default density for PhysX
+};
+
+
+/**
+PxFamily.
+
+A collection of actors. Maps 1 to 1 with TkFamily.
+*/
+class ExtPxFamily
+{
+public:
+ /**
+ Spawn ExtPxFamily. Can be called only once. Actual PhysX actors will created and placed in PxScene
+
+ \param[in] pose World transform.
+ \param[in] scale Scale applied to spawned actors.
+ \param[in] settings Spawn settings.
+
+ \return true if spawn was successful, false otherwise.
+ */
+ virtual bool spawn(const physx::PxTransform& pose, const physx::PxVec3& scale, const ExtPxSpawnSettings& settings) = 0;
+
+
+ /**
+ Despawn this ExtPxFamily. This removes the PhysX actors from PxScene and deletes them, as well as
+ deleting the created ExtPxActors
+
+ This does not call release() on the family.
+
+ \returns true if successful.
+ */
+ virtual bool despawn() = 0;
+
+
+ /**
+ The number of actors currently in this family.
+
+ \return the number of ExtPxActor that currently exist in this family.
+ */
+ virtual uint32_t getActorCount() const = 0;
+
+ /**
+ Retrieve an array of pointers (into the user-supplied buffer) to actors.
+
+ \param[out] buffer A user-supplied array of ExtPxActor pointers.
+ \param[in] bufferSize The number of elements available to write into buffer.
+
+ \return the number of ExtPxActor pointers written to the buffer.
+ */
+ virtual uint32_t getActors(ExtPxActor** buffer, uint32_t bufferSize) const = 0;
+
+ /**
+ Every family has corresponding TkFamily.
+
+ /return a pointer to TkFamily actor.
+ */
+ virtual TkFamily& getTkFamily() const = 0;
+
+ /**
+ Access an array of shapes of subchunks. The size of array is equal getPxAsset()->getSubchunkCount().
+ For every corresponding subchunk it contains pointer to created PxShape or nullptr.
+
+ \return the pointer to subchunk shapes array.
+ */
+ virtual const physx::PxShape* const* getSubchunkShapes() const = 0;
+
+ /**
+ Every family has an associated asset.
+
+ \return a pointer to the (const) ExtPxAsset object.
+ */
+ virtual const ExtPxAsset& getPxAsset() const = 0;
+
+ /**
+ Set the default material to be used for PxRigidDynamic creation.
+
+ \param[in] material The material to be the new default.
+ */
+ virtual void setMaterial(physx::PxMaterial& material) = 0;
+
+ /*
+ Set ExtPxPxShapeDesc to be used on all newly created PxShapes.
+
+ NOTE: Using it will override marking LEAF_CHUNK in simulationFilterData.word3 now.
+
+ \param[in] pxShapeDesc The PxShape desc to be the new default. Can be nullptr.
+ */
+ virtual void setPxShapeDescTemplate(const ExtPxShapeDescTemplate* pxShapeDesc) = 0;
+
+ /**
+ Get the default ExtPxPxShapeDesc to be used on all newly created PxShapes.
+
+ \return a pointer to the default PxShape desc. Can be nullptr.
+ */
+ virtual const ExtPxShapeDescTemplate* getPxShapeDescTemplate() const = 0;
+
+ /*
+ Set ExtPxPxActorDesc to be used on all newly created PxActors.
+
+ \param[in] pxActorDesc The PxActor desc to be the new default. Can be nullptr.
+ */
+ virtual void setPxActorDesc(const ExtPxActorDescTemplate* pxActorDesc) = 0;
+
+ /**
+ Get the default ExtPxPxActorDesc to be used on all newly created PxActors.
+
+ \return a pointer to the default PxActor desc. Can be nullptr.
+ */
+ virtual const ExtPxActorDescTemplate* getPxActorDesc() const = 0;
+
+ /**
+ Add a user implementation of ExtPxListener to this family's list of listeners.
+
+ \param[in] listener The event listener to add.
+ */
+ virtual void subscribe(ExtPxListener& listener) = 0;
+
+ /**
+ Remove a user implementation of ExtPxListener from this family's list of listeners.
+
+ \param[in] listener The event listener to remove.
+ */
+ virtual void unsubscribe(ExtPxListener& listener) = 0;
+
+ /**
+ Call after split.
+ */
+ virtual void postSplitUpdate() = 0;
+
+ /**
+ Release this family.
+ */
+ virtual void release() = 0;
+
+ /**
+ UserData pointer. Free to be used by user in any way.
+ */
+ void* userData;
+};
+
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTPXFAMILY_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPxListener.h b/sdk/extensions/physx/include/NvBlastExtPxListener.h
new file mode 100644
index 0000000..4c43283
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPxListener.h
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPXLISTENER_H
+#define NVBLASTEXTPXLISTENER_H
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class ExtPxFamily;
+class ExtPxActor;
+
+
+/**
+Physics Listener Interface.
+
+Actor create/destroy events listener.
+*/
+class ExtPxListener
+{
+public:
+ /**
+ Interface to be implemented by the user. Will be called when ExtPxFamily creates new actor.
+
+ \param[in] family Corresponding ExtPxFamily with new actor.
+ \param[in] actor The new actor.
+ */
+ virtual void onActorCreated(ExtPxFamily& family, ExtPxActor& actor) = 0;
+
+ /**
+ Interface to be implemented by the user. Will be called when ExtPxFamily destroy an actor.
+
+ \param[in] family Corresponding ExtPxFamily.
+ \param[in] actor The actor to be destroyed.
+ */
+ virtual void onActorDestroyed(ExtPxFamily& family, ExtPxActor& actor) = 0;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTPXLISTENER_H
diff --git a/sdk/extensions/physx/include/NvBlastExtPxManager.h b/sdk/extensions/physx/include/NvBlastExtPxManager.h
new file mode 100644
index 0000000..9d73898
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtPxManager.h
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTPXMANAGER_H
+#define NVBLASTEXTPXMANAGER_H
+
+#include "NvBlastTypes.h"
+#include "PxConvexMeshGeometry.h"
+#include "PxTransform.h"
+#include "NvPreprocessor.h"
+
+
+// Forward declarations
+namespace physx
+{
+class PxPhysics;
+class PxRigidDynamic;
+class PxJoint;
+
+namespace general_PxIOStream2
+{
+class PxFileBuf;
+}
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class ExtPxActor;
+class ExtPxAsset;
+class ExtPxFamily;
+class ExtPxListener;
+class TkFamily;
+class TkFramework;
+class TkGroup;
+class TkJoint;
+
+
+/**
+Family Desc.
+
+Used to create Physics Family.
+*/
+struct ExtPxFamilyDesc
+{
+ const ExtPxAsset* pxAsset; //!< px asset to create from, pointer will be stored in family.
+ NvBlastActorDesc actorDesc; //!< actor descriptor to be used when creating TkActor.
+ TkGroup* group; //!< if not nullptr, created TkActor will be placed in group
+};
+
+
+/**
+Function pointer for PxJoint creation.
+
+It will be called when new joints are being created. It should return valid PxJoint pointer or nullptr.
+*/
+typedef physx::PxJoint*(*ExtPxCreateJointFunction)(ExtPxActor* actor0, const physx::PxTransform& localFrame0, ExtPxActor* actor1, const physx::PxTransform& localFrame1, physx::PxPhysics& physics, TkJoint& joint);
+
+
+/**
+Physics Manager.
+
+Used to create and manage Physics Families.
+*/
+class NV_DLL_EXPORT ExtPxManager
+{
+public:
+ //////// manager creation ////////
+
+ /**
+ Create a new ExtPxManager.
+
+ \param[in] physics The PxPhysics instance to be used by ExtPxManager.
+ \param[in] framework The TkFramework instance to be used by ExtPxManager.
+ \param[in] createFn The function to be used when creating joints, can be nullptr.
+ \param[in] useUserData Flag if ExtPxManager is allowed to override PxActor's userData, it will store pointer to PxActor there.
+ It is recommended as fastest way. If set to 'false' HashMap will be used.
+
+ \return the new ExtPxManager if successful, NULL otherwise.
+ */
+ static ExtPxManager* create(physx::PxPhysics& physics, TkFramework& framework, ExtPxCreateJointFunction createFn = nullptr, bool useUserData = true);
+
+ /**
+ Release this manager.
+ */
+ virtual void release() = 0;
+
+
+ //////// impact ////////
+
+ /**
+ Simulation Filter data to be set on leaf chunk actors
+ */
+ enum FilterDataAttributes
+ {
+ LEAF_CHUNK = 1,
+ };
+
+
+ //////// interface ////////
+
+ /**
+ Create a px family from the given descriptor.
+
+ \param[in] desc The family descriptor (see ExtPxFamilyDesc).
+
+ \return the created family, if the descriptor was valid and memory was available for the operation. Otherwise, returns NULL.
+ */
+ virtual ExtPxFamily* createFamily(const ExtPxFamilyDesc& desc) = 0;
+
+ /**
+ Create a px joint associated with TkJoint.
+
+ ExtPxCreateJointFunction will be called after this call.
+ ExtPxCreateJointFunction must be set, nothing will happen otherwise.
+
+ \param[in] joint TkJoint to be used to create px joint.
+
+ \return true iff Joint was created.
+ */
+ virtual bool createJoint(TkJoint& joint) = 0;
+
+ /**
+ Destroy a px joint associated with TkJoint.
+
+ \param[in] joint TkJoint to be used to destroy px joint.
+ */
+ virtual void destroyJoint(TkJoint& joint) = 0;
+
+ /**
+ Set ExtPxCreateJointFunction to be used when new joints are being created.\
+
+ \param[in] createFn Create function pointer to set, can be nullptr.
+ */
+ virtual void setCreateJointFunction(ExtPxCreateJointFunction createFn) = 0;
+
+ /**
+ The number of families currently in this manager.
+
+ \return the number of ExtPxFamily that currently exist in this manger.
+ */
+ virtual uint32_t getFamilyCount() const = 0;
+
+ /**
+ Retrieve an array of pointers (into the user-supplied buffer) to families.
+
+ \param[out] buffer A user-supplied array of ExtPxFamily pointers.
+ \param[in] bufferSize The number of elements available to write into buffer.
+
+ \return the number of ExtPxFamily pointers written to the buffer.
+ */
+ virtual uint32_t getFamilies(ExtPxFamily** buffer, uint32_t bufferSize) const = 0;
+
+ /**
+ Look up an associated ExtPxFamily by TkFamily pointer.
+
+ \param[in] family The TkFamily pointer to look up.
+
+ \return pointer to the ExtPxFamily object if it exists, NULL otherwise.
+ */
+ virtual ExtPxFamily* getFamilyFromTkFamily(TkFamily& family) const = 0;
+
+ /**
+ Look up an associated ExtPxActor by PxRigidDynamic pointer.
+
+ \param[in] pxActor The PxRigidDynamic pointer to look up.
+
+ \return pointer to the ExtPxActor object if it exists, NULL otherwise.
+ */
+ virtual ExtPxActor* getActorFromPhysXActor(const physx::PxRigidDynamic& pxActor) const = 0;
+
+ /**
+ Get a PxPhysics object pointer used upon manager creation.
+
+ \return a pointer to the (const) PxPhysics object.
+ */
+ virtual physx::PxPhysics& getPhysics() const = 0;
+
+ /**
+ Get a TkFramework object pointer used upon manager creation.
+
+ \return a pointer to the TkFramework object.
+ */
+ virtual TkFramework& getFramework() const = 0;
+
+ /**
+ Get if useUserData was set upon manager creation.
+
+ \return true iff PxActor userData is used by manager.
+ */
+ virtual bool isPxUserDataUsed() const = 0;
+
+ /**
+ Limits the total number of actors that can exist at a given time. A value of zero disables this (gives no limit).
+
+ \param[in] limit If not zero, the maximum number of actors that will be allowed to exist.
+ */
+ virtual void setActorCountLimit(uint32_t limit) = 0;
+
+ /**
+ Retrieve the limit to the total number of actors that can exist at a given time. A value of zero disables this (gives no limit).
+
+ \return the limit to the total number of actors that can exist at a given time (or zero if there is no limit).
+ */
+ virtual uint32_t getActorCountLimit() = 0;
+
+ /**
+ The total number of PxActors generated by Blast.
+
+ \return the total number of PxActors generated by Blast.
+ */
+ virtual uint32_t getPxActorCount() const = 0;
+
+ /**
+ Add a user implementation of ExtPxListener to this family's list of listeners.
+
+ \param[in] listener The event listener to add.
+ */
+ virtual void subscribe(ExtPxListener& listener) = 0;
+
+ /**
+ Remove a user implementation of ExtPxListener from this family's list of listeners.
+
+ \param[in] listener The event listener to remove.
+ */
+ virtual void unsubscribe(ExtPxListener& listener) = 0;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTPXMANAGER_H
diff --git a/sdk/extensions/physx/include/NvBlastExtStressSolver.h b/sdk/extensions/physx/include/NvBlastExtStressSolver.h
new file mode 100644
index 0000000..2fd389d
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtStressSolver.h
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTSTRESSSOLVER_H
+#define NVBLASTEXTSTRESSSOLVER_H
+
+#include "common/PxRenderBuffer.h"
+#include <vector>
+#include "NvPreprocessor.h"
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// forward declarations
+class ExtPxFamily;
+class ExtPxActor;
+
+/**
+Stress Solver Settings
+
+Stress on every bond is calculated as
+stress = bond.linearStress * stressLinearFactor + bond.angularStress * stressAngularFactor
+where:
+bond.linearStress - is linear stress force on particular bond
+bond.angularStress - is angular stress force on particular bond
+stressLinearFactor, stressAngularFactor - are a multiplier parameter set by this struct
+
+Support graph reduction:
+2 ^ reduction level = max node count to be aggregated during graph reduction, so 0 is 2 % 0 = 1, basically use support graph.
+So N nodes graph will be simplified to contain ~ N / (2 ^ reduction level)
+*/
+struct ExtStressSolverSettings
+{
+ float stressLinearFactor; //!< linear stress on bond multiplier
+ float stressAngularFactor; //!< angular stress on bond multiplier
+ uint32_t bondIterationsPerFrame; //!< number of bond iterations to perform per frame, @see getIterationsPerFrame() below
+ uint32_t graphReductionLevel; //!< graph reduction level
+
+ ExtStressSolverSettings() :
+ stressLinearFactor(0.00004f),
+ stressAngularFactor(0.00007f),
+ bondIterationsPerFrame(18000),
+ graphReductionLevel(3)
+ {}
+};
+
+
+/**
+Stress Solver.
+
+Uses ExtPxFamily, allocates and prepares it's graph once when it's created. Then it's being quickly updated on every
+actor split.
+Works on both dynamic and static actor's within family.
+For static actors it applies gravity.
+For dynamic actors it applies centrifugal force.
+Additionally applyImpulse() method can be used to apply external impulse (like impact damage).
+*/
+class NV_DLL_EXPORT ExtStressSolver
+{
+public:
+ //////// creation ////////
+
+ /**
+ Create a new ExtStressSolver.
+
+ \param[in] family The ExtPxFamily instance to calculate stress on.
+ \param[in] settings The settings to be set on ExtStressSolver.
+
+ \return the new ExtStressSolver if successful, NULL otherwise.
+ */
+ static ExtStressSolver* create(ExtPxFamily& family, ExtStressSolverSettings settings = ExtStressSolverSettings());
+
+
+ //////// interface ////////
+
+ /**
+ Release this stress solver.
+ */
+ virtual void release() = 0;
+
+ /**
+ Set stress solver settings.
+ Changing graph reduction level will lead to graph being rebuilt (which is fast, but still not recommended).
+ All other settings are applied instantly and can be changed every frame.
+
+ \param[in] settings The settings to be set on ExtStressSolver.
+ */
+ virtual void setSettings(const ExtStressSolverSettings& settings) = 0;
+
+ /**
+ Get stress solver settings.
+
+ \return the pointer to stress solver settings currently set.
+ */
+ virtual const ExtStressSolverSettings& getSettings() const = 0;
+
+ /**
+ Apply external impulse on particular actor of family
+
+ \param[in] actor The ExtPxActor to apply impulse on.
+ \param[in] position Local position in actor's coordinates to apply impulse on.
+ \param[in] force Impulse to apply (kg * m / s).
+ */
+ virtual void applyImpulse(ExtPxActor& actor, physx::PxVec3 position, physx::PxVec3 force) = 0;
+
+ /**
+ Update stress solver.
+
+ Calculate stress and optionally apply damage.
+
+ \param[in] doDamage If 'true' damage will be applied after stress solver.
+ */
+ virtual void update(bool doDamage = true) = 0;
+
+ /**
+ Reset stress solver.
+
+ Stress solver uses warm start internally, calling this function will flush all previous data calculated and also zeros frame count.
+ This function is to be used for debug purposes.
+ */
+ virtual void reset() = 0;
+
+ /**
+ Debug Render Mode
+ */
+ enum DebugRenderMode
+ {
+ STRESS_GRAPH = 0, //!< render only stress graph
+ STRESS_GRAPH_NODES_IMPULSES = 1, //!< render stress graph + nodes impulses after solving stress
+ STRESS_GRAPH_BONDS_IMPULSES = 2 //!< render stress graph + bonds impulses after solving stress
+ };
+
+ /**
+ Fill debug render for passed array of support graph nodes.
+
+ \param[in] nodes Node indices of support graph to debug render for.
+ \param[out] lines Lines array to fill.
+ \param[in] mode Debug render mode.
+ \param[in] scale Scale to be applied on impulses.
+ */
+ virtual void fillDebugRender(const std::vector<uint32_t>& nodes, std::vector<physx::PxDebugLine>& lines, DebugRenderMode mode, float scale = 1.0f) = 0;
+
+ /**
+ Get stress solver linear error.
+
+ \return the total linear error of stress calculation.
+ */
+ virtual float getStressErrorLinear() const = 0;
+
+ /**
+ Get stress solver angular error.
+
+ \return the total angular error of stress calculation.
+ */
+ virtual float getStressErrorAngular() const = 0;
+
+ /**
+ Get stress solver total iterations count since it was created (or reset).
+
+ \return the iterations count.
+ */
+ virtual uint32_t getIterationCount() const = 0;
+
+ /**
+ Get stress solver total frames count (update() calls) since it was created (or reset).
+
+ \return the frames count.
+ */
+ virtual uint32_t getFrameCount() const = 0;
+
+ /**
+ Get stress solver bonds count, after graph reduction was applied.
+
+ \return the bonds count.
+ */
+ virtual uint32_t getBondCount() const = 0;
+
+
+ //////// helpers ////////
+
+ /**
+ Get iteration per frame (update() call).
+
+ Helper method to know how many solver iterations are made per frame.
+
+ \return the iterations per frame count.
+ */
+ uint32_t getIterationsPerFrame() const
+ {
+ uint32_t perFrame = getSettings().bondIterationsPerFrame / (getBondCount() + 1);
+ return perFrame > 0 ? perFrame : 1;
+ }
+};
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTSTRESSSOLVER_H
diff --git a/sdk/extensions/physx/include/NvBlastExtSync.h b/sdk/extensions/physx/include/NvBlastExtSync.h
new file mode 100644
index 0000000..805378a
--- /dev/null
+++ b/sdk/extensions/physx/include/NvBlastExtSync.h
@@ -0,0 +1,213 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTSYNC_H
+#define NVBLASTEXTSYNC_H
+
+#include "NvBlastTk.h"
+#include "foundation/PxTransform.h"
+#include "foundation/PxAllocatorCallback.h"
+#include "NvPreprocessor.h"
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+class ExtPxFamily;
+class ExtPxManager;
+
+
+/**
+Sync Event types
+*/
+struct ExtSyncEventType
+{
+ enum Enum
+ {
+ Fracture = 0, //!< Contains Fracture commands
+ FamilySync, //!< Contains full family Family blob
+ Physics, //!< Contains actor's physical info, like transforms
+
+ Count
+ };
+};
+
+
+/**
+Generic Sync Event
+*/
+struct NV_DLL_EXPORT ExtSyncEvent
+{
+ ExtSyncEvent(ExtSyncEventType::Enum t) : type(t) {}
+ virtual ~ExtSyncEvent() {}
+
+ template<class T>
+ const T* getEvent() const { return reinterpret_cast<const T*>(this); }
+
+ /**
+ Any Event can be copied (cloned).
+
+ \return the pointer to the new copy of event.
+ */
+ virtual ExtSyncEvent* clone() const = 0;
+
+ void release();
+
+ ExtSyncEventType::Enum type; //!< Event type
+ uint64_t timestamp; //!< Event timestamp
+ NvBlastID familyID; //!< TkFamily ID
+};
+
+
+/**
+Generic CRTP for Sync Events
+*/
+template <class T, ExtSyncEventType::Enum eventType>
+struct ExtSyncEventInstance : public ExtSyncEvent
+{
+ ExtSyncEventInstance() : ExtSyncEvent(eventType) {}
+
+ static const ExtSyncEventType::Enum EVENT_TYPE = eventType;
+
+ ExtSyncEvent* clone() const override
+ {
+ return new (NvBlastTkFrameworkGet()->getAllocatorCallback().allocate(sizeof(T), nullptr, __FILE__, __LINE__)) T(*(T*)this);
+ }
+};
+
+
+/**
+Fracture Sync Event
+*/
+struct ExtSyncEventFracture : public ExtSyncEventInstance<ExtSyncEventFracture, ExtSyncEventType::Fracture>
+{
+ std::vector<NvBlastBondFractureData> bondFractures; //!< bond fracture data
+ std::vector<NvBlastChunkFractureData> chunkFractures; //!< chunk fracture data
+};
+
+
+/**
+Family Sync Event
+*/
+struct ExtSyncEventFamilySync : public ExtSyncEventInstance<ExtSyncEventFamilySync, ExtSyncEventType::FamilySync>
+{
+ std::vector<char> family; //!< family binary blob
+};
+
+
+/**
+Physics Sync Event
+*/
+struct ExtSyncEventPhysicsSync : public ExtSyncEventInstance<ExtSyncEventPhysicsSync, ExtSyncEventType::Physics>
+{
+ struct ActorData
+ {
+ uint32_t actorIndex; //!< actor index in family
+ physx::PxTransform transform; //!< actor world transform
+ };
+
+ std::vector<ActorData> data; //!< actors data
+};
+
+
+/**
+Sync Manager.
+
+Implements TkEventListener interface. It can be directly subscribed to listen for family events.
+*/
+class NV_DLL_EXPORT ExtSync : public TkEventListener
+{
+public:
+ //////// creation ////////
+
+ /**
+ Create a new ExtSync.
+
+ \return the new ExtSync if successful, NULL otherwise.
+ */
+ static ExtSync* create();
+
+
+ //////// common interface ////////
+
+ /**
+ Release Sync manager.
+ */
+ virtual void release() = 0;
+
+
+ //////// server-side interface ////////
+
+ /**
+ TkEventListener interface.
+
+ \param[in] events The array of events being dispatched.
+ \param[in] eventCount The number of events in the array.
+ */
+ virtual void receive(const TkEvent* events, uint32_t eventCount) = 0;
+
+ /**
+ Sync family state. Writes to internal sync buffer.
+
+ \param[in] family The TkFamily to sync
+ */
+ virtual void syncFamily(const TkFamily& family) = 0;
+
+ /**
+ Sync PxFamily state. Writes to internal sync buffer.
+
+ \param[in] family The ExtPxFamily to sync
+ */
+ virtual void syncFamily(const ExtPxFamily& family) = 0;
+
+ /**
+ The size of internal sync buffer (events count).
+
+ \return the number of events in internal sync buffer.
+ */
+ virtual uint32_t getSyncBufferSize() const = 0;
+
+ /**
+ Acquire internal sync buffer.
+
+ \param[in] buffer Reference to sync event buffer pointer to be set.
+ \param[in] size Reference to the size of the buffer array to be set.
+ */
+ virtual void acquireSyncBuffer(const ExtSyncEvent*const*& buffer, uint32_t& size) const = 0;
+
+ /**
+ Clear internal sync buffer.
+ */
+ virtual void releaseSyncBuffer() = 0;
+
+
+ //////// client-side interface ////////
+
+ /**
+ Apply external sync buffer on TkFramework and possibly ExtPxManager. This function call will result in
+ respective families/actors changes in order to synchronize state.
+
+ \param[in] framework The TkFramework instance to be used.
+ \param[in] buffer Sync buffer array pointer.
+ \param[in] size Sync buffer array size.
+ \param[in] groupForNewActors TkGroup to be used for newly created actors. Can be nullptr.
+ \param[in] manager The ExtPxManager instance to be used. Can be nullptr, physics sync events will be ignored in that case.
+ */
+ virtual void applySyncBuffer(TkFramework& framework, const ExtSyncEvent** buffer, uint32_t size, TkGroup* groupForNewActors, ExtPxManager* manager = nullptr) = 0;
+
+};
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTSYNC_H