aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/include/destructible
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/include/destructible
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'APEX_1.4/include/destructible')
-rw-r--r--APEX_1.4/include/destructible/DestructibleActor.h721
-rw-r--r--APEX_1.4/include/destructible/DestructibleActorJoint.h190
-rw-r--r--APEX_1.4/include/destructible/DestructibleAsset.h2273
-rw-r--r--APEX_1.4/include/destructible/DestructiblePreview.h55
-rw-r--r--APEX_1.4/include/destructible/DestructibleRenderable.h48
-rw-r--r--APEX_1.4/include/destructible/ExplicitHierarchicalMesh.h1024
-rw-r--r--APEX_1.4/include/destructible/FractureToolsAPI.h453
-rw-r--r--APEX_1.4/include/destructible/FractureToolsStructs.h761
-rw-r--r--APEX_1.4/include/destructible/ModuleDestructible.h880
9 files changed, 6405 insertions, 0 deletions
diff --git a/APEX_1.4/include/destructible/DestructibleActor.h b/APEX_1.4/include/destructible/DestructibleActor.h
new file mode 100644
index 00000000..7ad688c5
--- /dev/null
+++ b/APEX_1.4/include/destructible/DestructibleActor.h
@@ -0,0 +1,721 @@
+/*
+ * Copyright (c) 2008-2015, 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 DESTRUCTIBLE_ACTOR_H
+#define DESTRUCTIBLE_ACTOR_H
+
+#include "foundation/Px.h"
+#include "Actor.h"
+#include "Renderable.h"
+#include "ModuleDestructible.h"
+#include "PxForceMode.h"
+
+namespace physx
+{
+ class PxRigidDynamic;
+};
+
+#define DESTRUCTIBLE_ACTOR_TYPE_NAME "DestructibleActor"
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+struct DestructibleParameters;
+class RenderVolume;
+class EmitterActor;
+class DestructibleRenderable;
+class DestructibleBehaviorGroupDesc;
+
+
+/**
+ Determines which type of emitter to associate with a render volume
+*/
+struct DestructibleEmitterType
+{
+ /**
+ Enum of destructible emitter types
+ */
+ enum Enum
+ {
+ Crumble,
+ Dust, // Note: this is a placeholder. Its implementation has been removed in 1.2.0, and will be restored in later versions.
+ Count
+ };
+};
+
+/**
+ Provides access to specific NvParamterized types provided by the destructible actor
+*/
+struct DestructibleParameterizedType
+{
+ /**
+ Enum of destructible parameterized types
+ */
+ enum Enum
+ {
+ State, // The full state of the actor (including params, chunk data, etc...)
+ Params, // The parameters used to initialize the actor
+ };
+};
+
+/**
+ Hit chunk info. Hit chunks are those directly affected by fracture events. See getHitChunkHistory and forceChunkHits.
+*/
+struct DestructibleHitChunk
+{
+ uint32_t chunkIndex; ///< chunk index
+ uint32_t hitChunkFlags; ///< hit chunk flag
+};
+
+/**
+ Flags for managing the sync state of the destructible actor
+*/
+struct DestructibleActorSyncFlags
+{
+ /**
+ Enum of destructible actor sync flags
+ */
+ enum Enum
+ {
+ None = 0,
+ CopyDamageEvents = (1 << 0),
+ ReadDamageEvents = (1 << 1),
+ CopyFractureEvents = (1 << 2),
+ ReadFractureEvents = (1 << 3),
+ CopyChunkTransform = (1 << 4),
+ ReadChunkTransform = (1 << 5),
+ Last = (1 << 6),
+ };
+};
+
+/**
+ Flags which control which actors are returned by DestructibleActor::acquirePhysXActorBuffer
+*/
+struct DestructiblePhysXActorQueryFlags
+{
+ /**
+ Enum of destructible PhysX actor query flags
+ */
+ enum Enum
+ {
+ None = 0,
+
+ // Actor states
+ Static = (1 << 0), /// Destructible-static, which is a kinematic PhysX actor that hasn't been turned dynamic yet
+ Dynamic = (1 << 1), /// Dynamic, not dormant (not kinematic)
+ Dormant = (1 << 2), /// Dynamic, but dormant (had been made dynamic, but is now in a dormant, PhysX-kinematic state)
+
+ AllStates = Static | Dynamic | Dormant,
+
+ // Other filters
+ /**
+ Whether or not to ensure that PhysX actors are not listed more than once when this NxDestructibleActor is
+ part of an extended structure. If this is true, then some NxDestructibleActors may not return all PhysX actors associated with
+ all of their chunks (and in fact may return no PhysX actors), but after querying all NxDestructibleActors in a given structure,
+ every PhysX actor will be accounted for.
+ */
+ AllowRedundancy = (1 << 3),
+
+ /**
+ Whether or not to allow actors not yet put into the PxScene (e.g. there has not been a simulation step since the actor was created) are also returned.
+ */
+ AllowActorsNotInScenes = (1 << 4)
+ };
+};
+
+/**
+ Tweak-able parameters on source-side for controlling the actor sync state.
+*/
+struct DestructibleActorSyncState
+{
+ uint32_t damageEventFilterDepth; ///< dictates the (inclusive) maximum depth at which damage events will be buffered.
+ uint32_t fractureEventFilterDepth; ///< dictates the (inclusive) maximum depth at which fracture events will be buffered.
+};
+
+/**
+ Tweak-able parameters on source-side for controlling the chunk sync state. DestructibleActorSyncFlags::CopyChunkTransform must first be set.
+*/
+struct DestructibleChunkSyncState
+{
+ bool disableTransformBuffering; ///< a handy switch for controlling whether chunk transforms will be buffered this instance.
+ bool excludeSleepingChunks; ///< dictates whether chunks that are sleeping will be buffered.
+ uint32_t chunkTransformCopyDepth; ///< dictates the (inclusive) maximum depth at which chunk transforms will be buffered.
+};
+
+/**
+ Flags which describe an actor chunk (as opposed to an asset chunk) - takes into account the actor's condition, for example
+ a chunk may be world supported because of the actor's placement
+*/
+struct DestructibleActorChunkFlags
+{
+ /**
+ Enum of destructible actor chunk flags
+ */
+ enum Enum
+ {
+ /**
+ "Use world support" is set in the destructible parameters, and this chunk is a support-depth chunk that
+ overlaps the physx scene's static geometry
+ */
+ ChunkIsWorldSupported = (1<<0),
+ };
+};
+
+/**
+ Destructible actor API. The destructible actor is instanced from an DestructibleAsset.
+*/
+class DestructibleActor : public Actor, public Renderable
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ , public ActorSource
+#endif
+{
+public:
+ /**
+ Get the render mesh actor for the specified mesh type.
+ */
+ virtual const RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const = 0;
+
+ /**
+ Gets the destructible's DestructibleParameter block of parameters. These are initially set from the asset.
+ */
+ virtual const DestructibleParameters& getDestructibleParameters() const = 0;
+
+ /**
+ Sets the destructible's DestructibleParameter block of parameters. These may be set at runtime.
+ */
+ virtual void setDestructibleParameters(const DestructibleParameters& destructibleParameters) = 0;
+
+ /**
+ Gets the global pose used when the actor is added to the scene, in the DestructibleActorDesc
+ */
+ virtual PxMat44 getInitialGlobalPose() const = 0;
+
+ /**
+ Resets the initial global pose used for support calculations when the first simulation step is run.
+ */
+ virtual void setInitialGlobalPose(const PxMat44& pose) = 0;
+
+ /**
+ Gets the destructible actor's 3D (possibly nonuniform) scale
+ */
+ virtual PxVec3 getScale() const = 0;
+
+ /**
+ Returns true iff the destructible actor starts off life dynamic.
+ */
+ virtual bool isInitiallyDynamic() const = 0;
+
+ /**
+ Returns an array of visibility data for each chunk. Each byte in the array is 0 if the
+ corresponding chunkIndex is invisible, 1 if visibile.
+
+ \param visibilityArray a pointer to the byte buffer to hold the visibility values.
+ \param visibilityArraySize the size of the visibilityArray
+ */
+ virtual void getChunkVisibilities(uint8_t* visibilityArray, uint32_t visibilityArraySize) const = 0;
+
+ /**
+ Returns the number of visible chunks. This is the number of 1's written to the visibilityArray by getChunkVisibilities.
+ */
+ virtual uint32_t getNumVisibleChunks() const = 0;
+
+ /**
+ Returns a pointer to an array of visible chunk indices.
+ */
+ virtual const uint16_t* getVisibleChunks() const = 0;
+
+ /**
+ Locks the chunk event buffer, and (if successful) returns the head of the chunk event buffer in the buffer field and the length
+ of the buffer (the number of events) in the bufferSize field. To unlock the buffer, use releaseChunkEventBuffer().
+ See DestructibleChunkEvent. This buffer is filled with chunk events if the DestructibleActor parameter createChunkEvents is set to true.
+ This buffer is not automatically cleared by APEX. The user must clear it using releaseChunkEventBuffer(true).
+
+ N.B. This function only works when the user has *not* requested chunk event callbacks via ModuleDestructible::scheduleChunkStateEventCallback.
+
+ \return Returns true if successful, false otherwise.
+ */
+ virtual bool acquireChunkEventBuffer(const nvidia::DestructibleChunkEvent*& buffer, uint32_t& bufferSize) = 0;
+
+ /**
+ Releases the chunk event buffer, which may have been locked by acquireChunkEventBuffer().
+ If clearBuffer is true, the buffer will be erased before it is unlocked.
+
+ \return Returns true if successful, false otherwise.
+ */
+ virtual bool releaseChunkEventBuffer(bool clearBuffer = true) = 0;
+
+ /**
+ Locks a PhysX actor buffer, and (if successful) returns the head of the buffer in the buffer field and the length
+ of the buffer (the number of PhysX actors) in the bufferSize field.
+ To unlock the buffer, use releasePhysXActorBuffer().
+ The user must release this buffer before another call to releasePhysXActorBuffer.
+
+ \param buffer returned buffer, if successful
+ \param bufferSize returned buffer size, if successful
+ \param flags flags which control which actors are returned. See DestructiblePhysXActorQueryFlags.
+
+ \return Returns true if successful, false otherwise.
+ */
+ virtual bool acquirePhysXActorBuffer(physx::PxRigidDynamic**& buffer, uint32_t& bufferSize, uint32_t flags = DestructiblePhysXActorQueryFlags::AllStates) = 0;
+
+ /**
+ Releases the PhysX actor buffer, which may have been locked by acquirePhysXActorBuffer().
+ The buffer will be erased before it is unlocked.
+
+ \return Returns true if successful, false otherwise.
+ */
+ virtual bool releasePhysXActorBuffer() = 0;
+
+ /**
+ Returns the PhysX actor associated with the given chunk. Note, more than one chunk may be associated with a given PhysX actor, and
+ chunks from different DestructibleActors may even be associated with the same PhysX actor.
+ Caution is recommended when using this function. During APEX scene simulate/fetchResults, this actor may be deleted, replaced, or tampered with.
+ When the chunk in question is not visible, but an ancestor of a visible chunk, the visible ancestor's shapes are returned.
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual physx::PxRigidDynamic* getChunkPhysXActor(uint32_t chunkIndex) = 0;
+
+ /**
+ Returns the PhysX shapes associated with the given chunk.
+ Caution is recommended when using this function. During APEX scene simulate/fetchResults, this actor may be deleted, replaced, or tampered with.
+ It is safe to use the results of this function during the chunk event callback (see ModuleDestructible::setChunkReport).
+
+ \param shapes returned pointer to array of shapes. May be NULL.
+ \param chunkIndex the chunk index within the actor
+
+ \return size of array pointed to by shapes pointer. 0 if shapes == NULL.
+ */
+ virtual uint32_t getChunkPhysXShapes(physx::PxShape**& shapes, uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns current pose of a chunk's reference frame, without scaling. This pose can be used to transform the chunk's hull data
+ from the asset into global space.
+
+ \param chunkIndex the chunk index within the actor
+
+ \note This pose's translation might not be inside the chunk. Use getChunkBounds to get a better representation
+ of where the chunk is located.
+ */
+ virtual PxTransform getChunkPose(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns current pose of a chunk's reference frame, without scaling. This pose can be used to transform the chunk's hull data
+ from the asset into global space.
+
+ \param chunkIndex the chunk index within the actor
+
+ \note This pose's translation might not be inside the chunk. Use getChunkBounds to get a better representation
+ of where the chunk is located.
+ */
+ virtual PxTransform getChunkTransform(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns a chunk's linear velocity in world space.
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual PxVec3 getChunkLinearVelocity(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns a chunk's angular velocity in world space.
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual PxVec3 getChunkAngularVelocity(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the transform of the chunk's graphical representation. This may have
+ a scale component.
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual const PxMat44 getChunkTM(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the behavior group index associated with the chunk. Use getBehaviorGroup() to access the behavior group data.
+ The index will either be -1, in which case it is the default behavior group, or in the range [0, getCustomBehaviorGroupCount()-1].
+ Any of those values is valid for getBehaviorGroup().
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual int32_t getChunkBehaviorGroupIndex(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the DestructibleActorChunkFlags for a chunk. These are flags that describe
+ aspects of the chunk that can only be determined at runtime.
+
+ \param chunkIndex the chunk index within the actor
+ */
+ virtual uint32_t getChunkActorFlags(uint32_t chunkIndex) const = 0;
+
+ /**
+ Set the destructible actor's global pose. This will only be applied to the physx PxActor or PxActor
+ for the static chunks, and therefore will apply to all static chunks in the structure which contains
+ the this destructible actor. This pose should not contain scale, as the scale is already contained
+ in the actor's scale parameter.
+ */
+ virtual void setGlobalPose(const PxMat44& pose) = 0;
+
+ /**
+ Get the destructible actor's global pose. This will be the pose of the physx PxActor or PxActor
+ for the static chunks in the structure containing this actor, if there are static chunks. If there
+ are no static chunks in the structure, pose will not be modified and false will be returned. Otherwise
+ pose will be filled in with a scale-free transform, and true is returned.
+ */
+ virtual bool getGlobalPose(PxMat44& pose) = 0;
+
+ /**
+ Sets the linear velocity of every dynamic chunk to the given value.
+ */
+ virtual void setLinearVelocity(const PxVec3& linearVelocity) = 0;
+
+ /**
+ Sets the angular velocity of every dynamic chunk to the given value.
+ */
+ virtual void setAngularVelocity(const PxVec3& angularVelocity) = 0;
+
+ /**
+ If the indexed chunk is visible, it is made dynamic (if it is not already).
+ If ModuleDestructibleConst::INVALID_CHUNK_INDEX is passed in, all visible chunks in the
+ destructible actor are made dynamic, if they are not already.
+ */
+ virtual void setDynamic(int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) = 0;
+
+ /**
+ Returns true if the chunkIndex is valid, and the indexed chunk is dynamic. Returns false otherwise.
+ */
+ virtual bool isDynamic(uint32_t chunkIndex) const = 0;
+
+ /**
+ If "hard sleeping" is enabled, physx actors for chunk islands that go to sleep will be turned kinematic. If a chunk
+ island has chunks from more than one DestructibleActor, then hard sleeping will be used if ANY of the destructibles
+ have hard sleeping enabled.
+ */
+ virtual void enableHardSleeping() = 0;
+
+ /**
+ See the comments for enableHardSleeping() for a description of this feature. The disableHardSleeping function takes
+ a "wake" parameter, which (if true) will not only turn kinematic-sleeping actors dynamic, but wake them as well.
+ */
+ virtual void disableHardSleeping(bool wake = false)= 0;
+
+ /**
+ Returns true iff hard sleeping is selected for this DestructibleActor.
+ */
+ virtual bool isHardSleepingEnabled() const = 0;
+
+ /**
+ Puts the PxActor associated with the given chunk to sleep, or wakes it up, depending upon the value of the 'awake' bool.
+
+ \param chunkIndex the chunk index within the actor
+ \param awake if true, wakes the actor, otherwise puts the actor to sleep
+
+ Returns true iff successful.
+ */
+ virtual bool setChunkPhysXActorAwakeState(uint32_t chunkIndex, bool awake) = 0;
+
+ /**
+ Apply force to chunk's actor
+
+ \param chunkIndex the chunk index within the actor
+ \param force force, impulse, velocity change, or acceleration (depending on value of mode)
+ \param mode PhysX force mode (PxForceMode::Enum)
+ \param position if not null, applies force at position. Otherwise applies force at center of mass
+ \param wakeup if true, the actor is awakened
+
+ Returns true iff successful.
+ */
+ virtual bool addForce(uint32_t chunkIndex, const PxVec3& force, physx::PxForceMode::Enum mode, const PxVec3* position = NULL, bool wakeup = true) = 0;
+
+ /**
+ Sets the override material.
+ */
+ virtual void setSkinnedOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName) = 0;
+
+ /**
+ Sets the override material.
+ */
+ virtual void setStaticOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName) = 0;
+
+ /**
+ Sets the override fracture pattern.
+ */
+ virtual void setRuntimeFractureOverridePattern(const char* overridePatternName) = 0;
+
+ /**
+ Damage
+ */
+
+ /**
+ Apply damage at a point. Damage will be propagated into the destructible based
+ upon its DestructibleParameters.
+
+ \param damage the amount of damage at the damage point
+ \param momentum the magnitude of the impulse to transfer to the actor
+ \param position the damage location
+ \param direction direction of impact. This is valid even if momentum = 0, for use in deformation calculations.
+ \param chunkIndex which chunk to damage (returned by rayCast and ModuleDestructible::getDestructibleAndChunk).
+ If chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, then the nearest visible chunk hit is found.
+ \param damageUserData pointer which will be returned in damage and fracture event callbacks
+ */
+ virtual void applyDamage(float damage, float momentum, const PxVec3& position, const PxVec3& direction, int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, void* damageUserData = NULL) = 0;
+
+ /**
+ Apply damage to all chunks within a radius. Damage will also propagate into the destructible
+ based upon its DestructibleParameters.
+
+ \param damage the amount of damage at the damage point
+ \param momentum the magnitude of the impulse to transfer to each chunk
+ \param position the damage location
+ \param radius distance from damage location at which chunks will be affected
+ \param falloff whether or not to decrease damage with distance from the damage location. If true,
+ damage will decrease linearly from the full damage (at zero distance) to zero damage (at radius).
+ If false, full damage is applied to all chunks within the radius.
+ \param damageUserData pointer which will be returned in damage and fracture event callbacks
+ */
+ virtual void applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff, void* damageUserData = NULL) = 0;
+
+ /**
+ Register a rigid body impact for impact-based damage. Much like applyDamage, but multplies the input 'force' by the destructible's forceToDamage parameter, and also allows the user
+ to report the impacting PhysX actor
+ */
+ virtual void takeImpact(const PxVec3& force, const PxVec3& position, uint16_t chunkIndex, PxActor const* damageImpactActor) = 0;
+
+ /**
+ PhysX SDK 3.X.
+ Returns the index of the first visible chunk hit in the actor by worldRay, if any.
+ Otherwise returns ModuleDestructibleConst::INVALID_CHUNK_INDEX.
+ If a chunk is hit, the time and normal fields are modified.
+
+ \param[out] time (return value) of the time to the hit chunk, if any.
+ \param[out] normal (return value) the surface normal of the hit chunk's collision volume, if any.
+ \param worldRayOrig origin of the ray to fire at the actor (the direction need not be normalized)
+ \param worldRayDir direction of the ray to fire at the actor (the direction need not be normalized)
+ \param flags raycast control flags (see DestructibleActorRaycastFlags)
+ \param parentChunkIndex (if not equal to ModuleDestructibleConst::INVALID_CHUNK_INDEX)
+ the chunk subhierarchy in which to confine the raycast. If parentChunkIndex =
+ ModuleDestructibleConst::INVALID_CHUNK_INDEX, then the whole actor is searched.
+ */
+ virtual int32_t rayCast(float& time, PxVec3& normal, const PxVec3& worldRayOrig, const PxVec3& worldRayDir, DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) const = 0;
+
+ /**
+ Physx SDK 3.X.
+ Returns the index of the first visible chunk hit in the actor by swept oriented bounding box, if any.
+ Otherwise returns ModuleDestructibleConst::INVALID_CHUNK_INDEX.
+ If a chunk is hit, the time and normal fields are modified.
+
+ \param[out] time (return value) of the time to the hit chunk, if any.
+ \param[out] normal (return value) the surface normal of the hit chunk's collision volume, if any.
+ \param worldBoxCenter the center of the obb to sweep against the actor, oriented in world space
+ \param worldBoxExtents the extents of the obb to sweep against the actor, oriented in world space
+ \param worldBoxRot the rotation of the obb to sweep against the actor, oriented in world space
+ \param worldDisplacement the displacement of the center of the worldBox through the sweep, in world space
+ \param flags raycast control flags (see DestructibleActorRaycastFlags)
+ */
+ virtual int32_t obbSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRot, const PxVec3& worldDisplacement, DestructibleActorRaycastFlags::Enum flags) const = 0;
+
+ /**
+ Enable/disable the crumble emitter
+ */
+ virtual void setCrumbleEmitterState(bool enable) = 0;
+
+ /**
+ Enable/disable the dust emitter
+ Note - this is a placeholder API. The dust feature is disabled in 1.2.0.
+ */
+ virtual void setDustEmitterState(bool enable) = 0;
+
+ /**
+ Sets a preferred render volume for a dust or crumble emitter
+ Note - only crumble emitters are implemented in 1.2.0
+ */
+ virtual void setPreferredRenderVolume(RenderVolume* volume, DestructibleEmitterType::Enum type) = 0;
+
+
+ /**
+ Returns the EmitterActor of either a dust or crumble emitter
+ Note - only crumble emitters are implemented in 1.2.0
+ */
+ virtual EmitterActor* getApexEmitter(DestructibleEmitterType::Enum type) = 0;
+
+ /**
+ * Recreates the Apex Emitter, if necessary. Use this method to re-initialize the crumble or dust emitter after a change has been made to a dependent asset
+ * Note - only crumble emitters are implemented in 1.2.0
+ */
+ virtual bool recreateApexEmitter(DestructibleEmitterType::Enum type) = 0;
+
+ /**
+ * \brief Returns the actor's NvParamaterized interface
+ * This cannot be directly modified! It is read only to the user.
+ * This handle can be used to directly serialize the complete actor state.
+ */
+ virtual const ::NvParameterized::Interface* getNvParameterized(DestructibleParameterizedType::Enum type = DestructibleParameterizedType::State) const = 0;
+
+ /**
+ * \brief Sets the actor's state via the NvParameterized object
+ * This can be used to update the state from deserialized data.
+ * The actor assumes control of the interface.
+ */
+ virtual void setNvParameterized(::NvParameterized::Interface*) = 0;
+
+ /**
+ Set the syncing properties of the destructible actor.
+
+ \param userActorID user-defined value used to identify the syncing actor.
+ This value will be used to identify destructible actors between the server and client.
+ userActorID = 0 is used for unregistering the actor as a syncing actor, and is the default value.
+ The other arguments will then be forcibly set to the default (non-participating) values.
+ userActorID != 0 registers the actor as a participating syncing actor.
+ userActorID can be overwritten. In this case, the destructible actor which used to hold this userActorID
+ will behave exactly like a call to set userActorID to 0.
+
+ \param actorSyncFlags describes the kind of actor information that participates in syncing. See struct DestructibleActorSyncFlags
+
+ \param actorSyncState describes information that allows finer control over the actor that participates in syncing. See struct DestructibleActorSyncState
+
+ \param chunkSyncState describes information that allows finer control over the chunk that participates in syncing. See struct DestructibleChunkSyncState
+
+ \return Returns true if arguments are accepted. Any one invalid argument will cause a return false. In such a case, no changes are made.
+ */
+ virtual bool setSyncParams(uint32_t userActorID, uint32_t actorSyncFlags = 0, const DestructibleActorSyncState * actorSyncState = NULL, const DestructibleChunkSyncState * chunkSyncState = NULL) = 0;
+
+ /**
+ Set the tracking properties of the actor for chunks that are hit. Chunks that are hit are chunks directly affected by fracture events.
+
+ \param flushHistory flushHistory == true indicates that both the cached chunk hit history and the cached damage event core data will be cleared.
+ To get the chunk hit history of this actor, see getHitChunkHistory()
+ To get the damage coloring history of this actor, see getDamageColoringHistory()
+ \param startTracking startTracking == true indicates that chunk hits and damage coloring will begin caching internally. The actor does not cache chunk hits by default.
+ \param trackingDepth the depth at which hit chunks will be cached. This value should not exceed the maximum depth level.
+ \param trackAllChunks trackAllChunks == true indicates that all the chunks will be cached, trackAllChunks == false indicates that only static chunks will be cached.
+
+ Returns true if the function executes correctly with the given arguments.
+ */
+ virtual bool setHitChunkTrackingParams(bool flushHistory, bool startTracking, uint32_t trackingDepth, bool trackAllChunks = true) = 0;
+
+ /**
+ Get the chunk hit history of the actor. To start caching chunk hits, see setHitChunkTrackingParams()
+
+ \return Returns true if the function executes correctly with the given arguments.
+ */
+ virtual bool getHitChunkHistory(const DestructibleHitChunk *& hitChunkContainer, uint32_t & hitChunkCount) const = 0;
+
+ /**
+ Force the actor to register chunk hits.
+
+ \param hitChunkContainer should take in an argument that was generated from another destructible actor. See getHitChunkHistory()
+ \param hitChunkCount hit chunk count
+ \param removeChunks removeChunks == true indicates that the chunks given by hitChunkContainer will be forcibly removed.
+ \param deferredEvent whether to enable deferred event mode. If true, fracture events won't get processed until the next tick.
+ \param damagePosition passed through to ApexDamageEventReportData::hitPosition and hitDirection in the damage notify output by APEX.
+ \param damageDirection passed through to ApexDamageEventReportData::hitPosition and hitDirection in the damage notify output by APEX.
+ */
+ virtual bool forceChunkHits(const DestructibleHitChunk * hitChunkContainer, uint32_t hitChunkCount, bool removeChunks = true, bool deferredEvent = false, PxVec3 damagePosition = PxVec3(0.0f), PxVec3 damageDirection = PxVec3(0.0f)) = 0;
+
+ /**
+ Get the damage coloring history of the actor. To start caching damage coloring, see setHitChunkTrackingParams()
+
+ \return Returns true if the function executes correctly with the given arguments.
+ */
+ virtual bool getDamageColoringHistory(const DamageEventCoreData *& damageEventCoreDataContainer, uint32_t & damageEventCoreDataCount) const = 0;
+
+ /**
+ Force the actor to register damage coloring.
+
+ \param damageEventCoreDataContainer should take in an argument that was generated from another destructible actor. See getDamageColoringHistory()
+ \param damageEventCoreDataCount the count of damageEventCoreDataContainer.
+
+ \return Returns true if the function executes correctly with the given arguments.
+ */
+ virtual bool forceDamageColoring(const DamageEventCoreData * damageEventCoreDataContainer, uint32_t damageEventCoreDataCount) = 0;
+
+ /**
+ Accessor to get the initial locally-aligned bounding box of a destructible actor.
+ */
+ virtual PxBounds3 getLocalBounds() const = 0;
+
+ /**
+ Accessor to get the initial world axis-aligned bounding box of a destructible actor.
+ */
+ virtual PxBounds3 getOriginalBounds() const = 0;
+
+ /**
+ Accessor to query if a chunk is part of a detached island.
+ */
+ virtual bool isChunkSolitary(int32_t chunkIndex) const = 0;
+
+ /**
+ Accessor to query the axis aligned bounding box of a given chunk in world-space.
+ */
+ virtual PxBounds3 getChunkBounds(uint32_t chunkIndex) const = 0;
+
+ /**
+ Accessor to query the axis aligned bounding box of a given chunk in chunk local-space.
+ */
+ virtual PxBounds3 getChunkLocalBounds(uint32_t chunkIndex) const = 0;
+
+ /**
+ Accessor to query if a chunk has been destroyed.
+ */
+ virtual bool isChunkDestroyed(int32_t chunkIndex) const = 0;
+
+ /**
+ Accessor to get the array of chunk indices at the support depth.
+ */
+ virtual uint32_t getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const = 0;
+
+ /**
+ Query the actor's support depth.
+ */
+ virtual uint32_t getSupportDepth() const = 0;
+
+ /**
+ Set the actor to delete its fractured chunks instead of simulating them.
+ */
+ virtual void setDeleteFracturedChunks(bool inDeleteChunkMode) = 0;
+
+ /**
+ Acquire a pointer to the destructible's renderable proxy and increment its reference count. The DestructibleRenderable will
+ only be deleted when its reference count is zero. Calls to DestructibleRenderable::release decrement the reference count, as does
+ a call to DestructibleActor::release(). .
+ */
+ virtual DestructibleRenderable* acquireRenderableReference() = 0;
+
+ /**
+ Access to behavior groups created for this actor. Each chunk has a behavior group index associated with it.
+
+ \return This returns the number of custom (non-default) behavior groups.
+ */
+ virtual uint32_t getCustomBehaviorGroupCount() const = 0;
+
+ /**
+ Access to behavior groups created for this actor. Each chunk has a behavior group index associated with it.
+
+ This returns the indexed behavior group. The index must be either -1 (for the default group) or in the range [0, getCustomBehaviorGroupCount()-1].
+ If any other index is given, this function returns false. Otherwise it returns true and the behavior descriptor is filled in.
+ */
+ virtual bool getBehaviorGroup(nvidia::DestructibleBehaviorGroupDesc& behaviorGroupDesc, int32_t index = -1) const = 0;
+
+protected:
+ virtual ~DestructibleActor() {}
+};
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_ACTOR_H
diff --git a/APEX_1.4/include/destructible/DestructibleActorJoint.h b/APEX_1.4/include/destructible/DestructibleActorJoint.h
new file mode 100644
index 00000000..e5783e9d
--- /dev/null
+++ b/APEX_1.4/include/destructible/DestructibleActorJoint.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2008-2015, 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 DESTRUCTIBLE_ACTOR_JOINT_H
+#define DESTRUCTIBLE_ACTOR_JOINT_H
+
+#include "ModuleDestructible.h"
+
+#include "extensions/PxJoint.h"
+
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+/**
+ Descriptor used to create the Destructible actor joint.
+*/
+class DestructibleActorJointDesc : public ApexDesc
+{
+public:
+
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleActorJointDesc();
+
+ /**
+ \brief Resets descriptor to default settings.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const;
+
+ /**
+ PhysX SDK 3.X only.
+ */
+ physx::PxJointConcreteType::Enum type;
+ /**
+ PhysX SDK 3.X only.
+ */
+ PxRigidActor* actor[2];
+ /**
+ PhysX SDK 3.X only.
+ */
+ PxVec3 localAxis[2];
+ /**
+ PhysX SDK 3.X only.
+ */
+ PxVec3 localAnchor[2];
+ /**
+ PhysX SDK 3.X only.
+ */
+ PxVec3 localNormal[2];
+
+ /**
+ If destructible[i] is not NULL, it will effectively replace the actor[i] in jointDesc.
+ At least one must be non-NULL.
+ */
+ DestructibleActor* destructible[2];
+
+ /**
+ If destructible[i] is not NULL and attachmentChunkIndex[i] is a valid chunk index within that
+ destructible, then that chunk will be used for attachment.
+ If destructible[i] is not NULL and attachmentChunkIndex[i] is NOT a valid chunk index (such as the
+ default ModuleDestructibleConst::INVALID_CHUNK_INDEX), then the nearest chunk to globalAnchor[i] is used instead.
+ Once a chunk is determined, the chunk's associated PxActor will be the PxJoint's attachment actor.
+ */
+ int32_t attachmentChunkIndex[2];
+
+
+ /**
+ Global attachment data. Since destructibles come apart, there is no single referece frame
+ associated with them. Therefore it makes more sense to use a global reference frame
+ when describing the attachment positions and axes.
+ */
+
+ /**
+ \brief global attachment positions
+ */
+ PxVec3 globalAnchor[2];
+
+ /**
+ \brief global axes
+ */
+ PxVec3 globalAxis[2];
+
+ /**
+ \brief global normals
+ */
+ PxVec3 globalNormal[2];
+};
+
+// DestructibleActorJointDesc inline functions
+
+PX_INLINE DestructibleActorJointDesc::DestructibleActorJointDesc() : ApexDesc()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleActorJointDesc::setToDefault()
+{
+ ApexDesc::setToDefault();
+ for (int i=0; i<2; i++)
+ {
+ actor[i] = 0;
+ localAxis[i] = PxVec3(0,0,1);
+ localNormal[i] = PxVec3(1,0,0);
+ localAnchor[i] = PxVec3(0);
+ }
+ for (int i = 0; i < 2; ++i)
+ {
+ destructible[i] = NULL;
+ attachmentChunkIndex[i] = ModuleDestructibleConst::INVALID_CHUNK_INDEX;
+ globalAnchor[i] = PxVec3(0.0f);
+ globalAxis[i] = PxVec3(0.0f, 0.0f, 1.0f);
+ globalNormal[i] = PxVec3(1.0f, 0.0f, 0.0f);
+ }
+}
+
+PX_INLINE bool DestructibleActorJointDesc::isValid() const
+{
+ if (destructible[0] == NULL && destructible[1] == NULL)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < 2; ++i)
+ {
+ if (PxAbs(globalAxis[i].magnitudeSquared() - 1.0f) > 0.1f)
+ {
+ return false;
+ }
+ if (PxAbs(globalNormal[i].magnitudeSquared() - 1.0f) > 0.1f)
+ {
+ return false;
+ }
+ //check orthogonal pairs
+ if (PxAbs(globalAxis[i].dot(globalNormal[i])) > 0.1f)
+ {
+ return false;
+ }
+ }
+
+ return ApexDesc::isValid();
+}
+
+
+/**
+ Destructible actor joint - a wrapper for an PxJoint. This needs to be used because APEX may need to replace an PxJoint
+ when fracturing occurs. Always use the joint() method to get the currently valid joint.
+*/
+class DestructibleActorJoint : public ApexInterface
+{
+public:
+ /**
+ PhysX SDK 3.X
+ Access to the {xJoint represented by the DestructibleActorJoint. This is a temporary interface,
+ and there are some shortcomings and restrictions:
+ 1) The user will have to upcast the result of joint() to the correct joint type in order
+ to access the interface for derived joints.
+ 2) The user must never delete the joint using the PhysX SDK. To release this joint, simply
+ use the release() method of this object (defined in the ApexInterface base class).
+ */
+ virtual PxJoint* joint() = 0;
+
+protected:
+ virtual ~DestructibleActorJoint() {}
+};
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_ACTOR_JOINT_H
diff --git a/APEX_1.4/include/destructible/DestructibleAsset.h b/APEX_1.4/include/destructible/DestructibleAsset.h
new file mode 100644
index 00000000..732fc046
--- /dev/null
+++ b/APEX_1.4/include/destructible/DestructibleAsset.h
@@ -0,0 +1,2273 @@
+/*
+ * Copyright (c) 2008-2015, 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 DESTRUCTIBLE_ASSET_H
+#define DESTRUCTIBLE_ASSET_H
+
+#define DESTRUCTIBLE_AUTHORING_TYPE_NAME "DestructibleAsset"
+
+#include "foundation/Px.h"
+#include "FractureToolsAPI.h"
+// TODO: Remove this include when we remove the APEX_RUNTIME_FRACTURE define
+#include "ModuleDestructible.h"
+
+#if PX_PHYSICS_VERSION_MAJOR == 3
+#include "PxFiltering.h"
+#endif
+
+namespace nvidia
+{
+namespace apex
+{
+
+struct IntPair;
+class DestructibleActor;
+class DestructiblePreview;
+
+PX_PUSH_PACK_DEFAULT
+#if !PX_PS4
+ #pragma warning(push)
+ #pragma warning(disable:4121)
+#endif //!PX_PS4
+
+/**
+ Flags that may be set for all chunks at a particular depth in the fracture hierarchy
+*/
+struct DestructibleDepthParametersFlag
+{
+ /**
+ Enum of destructible depth parameters flag
+ */
+ enum Enum
+ {
+ /**
+ If true, chunks at this hierarchy depth level will take impact damage iff OVERRIDE_IMPACT_DAMAGE = TRUE, no matter the setting of impactDamageDefaultDepth..
+ Note, DestructibleParameters::forceToDamage must also be positive for this
+ to take effect.
+ */
+ OVERRIDE_IMPACT_DAMAGE = (1 << 0),
+
+ /**
+ If OVERRIDE_IMPACT_DAMAGE = TRUE, chunks at this hierarchy depth level will take impact damage iff OVERRIDE_IMPACT_DAMAGE = TRUE, no matter the setting of impactDamageDefaultDepth..
+ */
+ OVERRIDE_IMPACT_DAMAGE_VALUE = (1 << 1),
+
+ /**
+ Chunks at this depth should have pose updates ignored.
+ */
+ IGNORE_POSE_UPDATES = (1 << 2),
+
+ /**
+ Chunks at this depth should be ignored in raycast callbacks.
+ */
+ IGNORE_RAYCAST_CALLBACKS = (1 << 3),
+
+ /**
+ Chunks at this depth should be ignored in contact callbacks.
+ */
+ IGNORE_CONTACT_CALLBACKS = (1 << 4),
+
+ /**
+ User defined flags.
+ */
+ USER_FLAG_0 = (1 << 24),
+ USER_FLAG_1 = (1 << 25),
+ USER_FLAG_2 = (1 << 26),
+ USER_FLAG_3 = (1 << 27)
+ };
+};
+
+
+/**
+ Parameters that may be set for all chunks at a particular depth in the fracture hierarchy
+*/
+struct DestructibleDepthParameters
+{
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleDepthParameters();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ \brief (re)sets the structure to parameters which are likely to be the most computationally expensive.
+ */
+ PX_INLINE void setToMostExpensive();
+
+ /**
+ A convenience function to determine if the OVERRIDE_IMPACT_DAMAGE is set.
+ */
+ PX_INLINE bool overrideImpactDamage() const;
+
+ /**
+ A convenience function to read OVERRIDE_IMPACT_DAMAGE_VALUE is set.
+ */
+ PX_INLINE bool overrideImpactDamageValue() const;
+
+ /**
+ A convenience function to determine if the IGNORE_POSE_UPDATES is set.
+ */
+ PX_INLINE bool ignoresPoseUpdates() const;
+
+ /**
+ A convenience function to determine if the IGNORE_RAYCAST_CALLBACKS is set.
+ */
+ PX_INLINE bool ignoresRaycastCallbacks() const;
+
+ /**
+ A convenience function to determine if the IGNORE_CONTACT_CALLBACKS is set.
+ */
+ PX_INLINE bool ignoresContactCallbacks() const;
+
+ /**
+ A convenience function to determine if the USER_FLAG_0, USER_FLAG_1, USER_FLAG_2, or USER_FLAG_3 flag is set.
+ */
+ PX_INLINE bool hasUserFlagSet(uint32_t flagIndex) const;
+
+ /**
+ A collection of flags defined in DestructibleDepthParametersFlag.
+ */
+ uint32_t flags;
+};
+
+// DestructibleDepthParameters inline functions
+
+PX_INLINE DestructibleDepthParameters::DestructibleDepthParameters()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleDepthParameters::setToDefault()
+{
+ flags = 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::overrideImpactDamage() const
+{
+ return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE) != 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::overrideImpactDamageValue() const
+{
+ return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE_VALUE) != 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::ignoresPoseUpdates() const
+{
+ return (flags & DestructibleDepthParametersFlag::IGNORE_POSE_UPDATES) != 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::ignoresRaycastCallbacks() const
+{
+ return (flags & DestructibleDepthParametersFlag::IGNORE_RAYCAST_CALLBACKS) != 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::ignoresContactCallbacks() const
+{
+ return (flags & DestructibleDepthParametersFlag::IGNORE_CONTACT_CALLBACKS) != 0;
+}
+
+PX_INLINE bool DestructibleDepthParameters::hasUserFlagSet(uint32_t flagIndex) const
+{
+ switch (flagIndex)
+ {
+ case 0:
+ return (flags & DestructibleDepthParametersFlag::USER_FLAG_0) != 0;
+ case 1:
+ return (flags & DestructibleDepthParametersFlag::USER_FLAG_1) != 0;
+ case 2:
+ return (flags & DestructibleDepthParametersFlag::USER_FLAG_2) != 0;
+ case 3:
+ return (flags & DestructibleDepthParametersFlag::USER_FLAG_3) != 0;
+ default:
+ return false;
+ }
+}
+
+/**
+ Parameters for RT Fracture
+*/
+struct DestructibleRTFractureParameters
+{
+ /**
+ If true, align fracture pattern to largest face.
+ If false, the fracture pattern will be aligned to the hit normal with each fracture.
+ */
+ bool sheetFracture;
+
+ /**
+ Number of times deep a chunk can be fractured. Can help limit the number of chunks produced by
+ runtime fracture.
+ */
+ uint32_t depthLimit;
+
+ /**
+ If true, destroy chunks when they hit their depth limit.
+ If false, then chunks at their depth limit will not fracture but will have a force applied.
+ */
+ bool destroyIfAtDepthLimit;
+
+ /**
+ Minimum Convex Size. Minimum size of convex produced by a fracture.
+ */
+ float minConvexSize;
+
+ /**
+ Scales impulse applied by a fracture.
+ */
+ float impulseScale;
+
+ /**
+ Parameters for glass fracture
+ */
+ struct FractureGlass
+ {
+ /**
+ Number of angular slices in the glass fracture pattern.
+ */
+ uint32_t numSectors;
+
+ /**
+ Creates variance in the angle of slices. A value of zero results in all angular slices having the same angle.
+ */
+ float sectorRand;
+
+ /**
+ The minimum shard size. Shards below this size will not be created and thus not visible.
+ */
+ float firstSegmentSize;
+
+ /**
+ Scales the radial spacing in the glass fracture pattern. A larger value results in radially longer shards.
+ */
+ float segmentScale;
+
+ /**
+ Creates variance in the radial size of shards. A value of zero results in a low noise circular pattern.
+ */
+ float segmentRand;
+ }glass; ///< Instance of FractureGlass parameters
+
+ /**
+ Fracture attachment
+ */
+ struct FractureAttachment
+ {
+ /**
+ If true, make the positive x side of the sheet an attachment point.
+ */
+ bool posX;
+
+ /**
+ If true, make the negative x side of the sheet an attachment point.
+ */
+ bool negX;
+
+ /**
+ If true, make the positive y side of the sheet an attachment point.
+ */
+ bool posY;
+
+ /**
+ If true, make the negative y side of the sheet an attachment point.
+ */
+ bool negY;
+
+ /**
+ If true, make the positive z side of the sheet an attachment point.
+ */
+ bool posZ;
+
+ /**
+ If true, make the negative z side of the sheet an attachment point.
+ */
+ bool negZ;
+ }attachment; ///< Instance of FractureAttachment parameters
+
+ /**
+ Set default fracture parameters
+ */
+ PX_INLINE void setToDefault();
+};
+
+PX_INLINE void DestructibleRTFractureParameters::setToDefault()
+{
+ sheetFracture = true;
+ depthLimit = 2;
+ destroyIfAtDepthLimit = false;
+ minConvexSize = 0.02f;
+ impulseScale = 1.0f;
+ glass.numSectors = 10;
+ glass.sectorRand = 0.3f;
+ glass.firstSegmentSize = 0.06f;
+ glass.segmentScale = 1.4f;
+ glass.segmentRand = 0.3f;
+ attachment.posX = false;
+ attachment.negX = false;
+ attachment.posY = false;
+ attachment.negY = false;
+ attachment.posZ = false;
+ attachment.negZ = false;
+}
+
+/**
+ Flags that apply to a destructible actor, settable at runtime
+*/
+struct DestructibleParametersFlag
+{
+ /**
+ Enum of destructible parameters flag
+ */
+ enum Enum
+ {
+ /**
+ If set, chunks will "remember" damage applied to them, so that many applications of a damage amount
+ below damageThreshold will eventually fracture the chunk. If not set, a single application of
+ damage must exceed damageThreshold in order to fracture the chunk.
+ */
+ ACCUMULATE_DAMAGE = (1 << 0),
+
+ /**
+ Whether or not chunks at or deeper than the "debris" depth (see DestructibleParameters::debrisDepth)
+ will time out. The lifetime is a value between DestructibleParameters::debrisLifetimeMin and
+ DestructibleParameters::debrisLifetimeMax, based upon the destructible module's LOD setting.
+ */
+ DEBRIS_TIMEOUT = (1 << 1),
+
+ /**
+ Whether or not chunks at or deeper than the "debris" depth (see DestructibleParameters::debrisDepth)
+ will be removed if they separate too far from their origins. The maxSeparation is a value between
+ DestructibleParameters::debrisMaxSeparationMin and DestructibleParameters::debrisMaxSeparationMax,
+ based upon the destructible module's LOD setting.
+ */
+ DEBRIS_MAX_SEPARATION = (1 << 2),
+
+ /**
+ If set, the smallest chunks may be further broken down, either by fluid crumbles (if a crumble particle
+ system is specified in the DestructibleActorDesc), or by simply removing the chunk if no crumble
+ particle system is specified. Note: the "smallest chunks" are normally defined to be the deepest level
+ of the fracture hierarchy. However, they may be taken from higher levels of the hierarchy if
+ ModuleDestructible::setMaxChunkDepthOffset is called with a non-zero value.
+ */
+ CRUMBLE_SMALLEST_CHUNKS = (1 << 3),
+
+ /**
+ If set, the DestructibleActor::rayCast function will search within the nearest visible chunk hit
+ for collisions with child chunks. This is used to get a better raycast position and normal, in
+ case the parent collision volume does not tightly fit the graphics mesh. The returned chunk index
+ will always be that of the visible parent that is intersected, however.
+ */
+ ACCURATE_RAYCASTS = (1 << 4),
+
+ /**
+ If set, the validBounds field of DestructibleParameters will be used. These bounds are translated
+ (but not scaled or rotated) to the origin of the destructible actor. If a chunk or chunk island moves
+ outside of those bounds, it is destroyed.
+ */
+ USE_VALID_BOUNDS = (1 << 5),
+
+ /**
+ If set, chunk crumbling will be handled via the pattern-based runtime fracture pipeline.
+ If no fracture pattern is specified in the DestructibleActorDesc, or no fracture pattern
+ has been assigned to the destructible actor, chunks will simply be removed.
+ */
+ CRUMBLE_VIA_RUNTIME_FRACTURE = (1 << 6),
+ };
+};
+
+
+/**
+ Parameters that apply to a destructible actor
+*/
+struct DestructibleParameters
+{
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleParameters();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Limits the amount of damage applied to a chunk. This is useful for preventing the entire destructible
+ from getting pulverized by a very large application of damage. This can easily happen when impact damage is
+ used, and the damage amount is proportional to the impact force (see forceToDamage).
+ */
+ float damageCap;
+
+ /**
+ If a chunk is at a depth which takes impact damage (see DestructibleDepthParameters),
+ then when a chunk has a collision in the PxScene, it will take damage equal to forceToDamage mulitplied by
+ the impact force.
+ The default value is zero, which effectively disables impact damage.
+ */
+ float forceToDamage;
+
+ /**
+ Large impact force may be reported if rigid bodies are spawned inside one another. In this case the relative velocity of the two
+ objects will be low. This variable allows the user to set a minimum velocity threshold for impacts to ensure that the objects are
+ moving at a min velocity in order for the impact force to be considered.
+ Default value is zero.
+ */
+ float impactVelocityThreshold;
+
+ /**
+ The chunks will not be broken free below this depth.
+ */
+ uint32_t minimumFractureDepth;
+
+ /**
+ The default depth to which chunks will take impact damage. This default may be overridden in the depth settings.
+ Negative values imply no default impact damage.
+ Default value = -1.
+ */
+ int32_t impactDamageDefaultDepth;
+
+ /**
+ The chunk hierarchy depth at which chunks are considered to be "debris." Chunks at this depth or
+ below will be considered for various debris settings, such as debrisLifetime.
+ Negative values indicate that no chunk depth is considered debris.
+ Default value is -1.
+ */
+ int32_t debrisDepth;
+
+ /**
+ The chunk hierarchy depth up to which chunks will not be eliminated due to LOD considerations.
+ These chunks are considered to be essential either for gameplay or visually.
+ The minimum value is 0, meaning the level 0 chunk is always considered essential.
+ Default value is 0.
+ */
+ uint32_t essentialDepth;
+
+ /**
+ "Debris chunks" (see debrisDepth, above) will be destroyed after a time (in seconds)
+ separated from non-debris chunks. The actual lifetime is interpolated between these
+ two values, based upon the module's LOD setting. To disable lifetime, clear the
+ DestructibleDepthParametersFlag::DEBRIS_TIMEOUT flag in the flags field.
+ If debrisLifetimeMax < debrisLifetimeMin, the mean of the two is used for both.
+ Default debrisLifetimeMin = 1.0, debrisLifetimeMax = 10.0f.
+ */
+ float debrisLifetimeMin;
+
+ /// \see DestructibleAsset::debrisLifetimeMin
+ float debrisLifetimeMax;
+
+ /**
+ "Debris chunks" (see debrisDepth, above) will be destroyed if they are separated from
+ their origin by a distance greater than maxSeparation. The actual maxSeparation is
+ interpolated between these two values, based upon the module's LOD setting. To disable
+ maxSeparation, clear the DestructibleDepthParametersFlag::DEBRIS_MAX_SEPARATION flag in the flags field.
+ If debrisMaxSeparationMax < debrisMaxSeparationMin, the mean of the two is used for both.
+ Default debrisMaxSeparationMin = 1.0, debrisMaxSeparationMax = 10.0f.
+ */
+ float debrisMaxSeparationMin;
+
+ /// \see DestructibleAsset::debrisMaxSeparationMin
+ float debrisMaxSeparationMax;
+
+ /**
+ The probablity that a debris chunk, when fractured, will simply be destroyed instead of becoming
+ dynamic or breaking down further into child chunks. Valid range = [0.0,1.0]. Default value = 0.0.'
+ */
+
+ float debrisDestructionProbability;
+
+ /**
+ A bounding box around each DestructibleActor created, defining a range of validity for chunks that break free.
+ These bounds are scaled and translated with the DestructibleActor's scale and position, but they are *not*
+ rotated with the DestructibleActor.
+ */
+ PxBounds3 validBounds;
+
+ /**
+ If greater than 0, the chunks' speeds will not be allowed to exceed maxChunkSpeed. Use 0
+ to disable this feature (this is the default).
+ */
+ float maxChunkSpeed;
+
+ /**
+ A collection of flags defined in DestructibleParametersFlag.
+ */
+ uint32_t flags;
+
+ /**
+ Scale factor used to apply an impulse force along the normal of chunk when fractured. This is used
+ in order to "push" the pieces out as they fracture.
+ */
+ float fractureImpulseScale;
+
+ /**
+ How deep in the hierarchy damage will be propagated, relative to the chunk hit.
+ Default = UINT16_MAX.
+ */
+ uint16_t damageDepthLimit;
+
+ /**
+ Optional dominance group for dynamic chunks created when fractured. (ignored if > 31)
+ */
+ uint8_t dynamicChunksDominanceGroup;
+
+ /**
+ Whether or not to use dynamicChunksGroupsMask. If false, NULL will be passed into the DestructibleActor upon
+ instantiation, through the DestructibleActorDesc.
+ */
+ bool useDynamicChunksGroupsMask;
+
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ /**
+ Optional groups mask (2.x) or filter data (3.x) for dynamic chunks created when fractured. (Used if useDynamicChunksGroupsMask is true.)
+ */
+ physx::PxFilterData dynamicChunksFilterData;
+#endif
+
+ /**
+ The supportStrength is used for the stress solver. As this value is increased it takes more force to break apart the chunks under the effect of stress solver.
+ */
+ float supportStrength;
+
+ /**
+ Whether or not to use the old chunk bounds testing for damage, or use the module setting. A value of 0 forces the new method to be used.
+ A positive value forces the old method to be used. Negative values cause the global (ModuleDestructible) setting to be used.
+ Default = -1
+ */
+ int8_t legacyChunkBoundsTestSetting;
+
+ /**
+ Whether or not to use the old damage spread method, or use the module setting. A value of 0 forces the new method to be used.
+ A positive value forces the old method to be used. Negative values cause the global (ModuleDestructible) setting to be used.
+ Default = -1
+ */
+ int8_t legacyDamageRadiusSpreadSetting;
+
+ /**
+ The maximum number of DestructibleDepthParameters (see depthParameters).
+ */
+ enum { kDepthParametersCountMax = 16 };
+
+ /**
+ The number of DestructibleDepthParameters (see depthParameters).
+ Must be in the range [0, kDepthParametersCountMax].
+ */
+ uint32_t depthParametersCount;
+
+ /**
+ Parameters that apply to every chunk at a given depth level (see DestructibleDepthParameters).
+ The element [0] of the array applies to the depth 0 (unfractured) chunk, element [1] applies
+ to the level 1 chunks, etc.
+ The number of valid depth parameters must be given in depthParametersCount.
+ */
+ DestructibleDepthParameters depthParameters[kDepthParametersCountMax];
+
+ /**
+ Parameters for RT Fracture.
+ */
+ DestructibleRTFractureParameters rtFractureParameters;
+
+ /**
+ This flag forces drawing of scatter mesh on chunks with depth > 1.
+ By default is false.
+ */
+ bool alwaysDrawScatterMesh;
+};
+
+// DestructibleParameters inline functions
+
+PX_INLINE DestructibleParameters::DestructibleParameters()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleParameters::setToDefault()
+{
+ damageCap = 0;
+ forceToDamage = 0;
+ impactVelocityThreshold = 0.0f;
+ minimumFractureDepth = 0;
+ impactDamageDefaultDepth = -1;
+ debrisDepth = -1;
+ essentialDepth = 0;
+ debrisLifetimeMin = 1.0f;
+ debrisLifetimeMax = 10.0f;
+ debrisMaxSeparationMin = 1.0f;
+ debrisMaxSeparationMax = 10.0f;
+ debrisDestructionProbability = 0.0f;
+ validBounds = PxBounds3(PxVec3(-10000.0f), PxVec3(10000.0f));
+ maxChunkSpeed = 0.0f;
+ fractureImpulseScale = 0.0f;
+ damageDepthLimit = UINT16_MAX;
+ useDynamicChunksGroupsMask = false;
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ dynamicChunksFilterData.word0 = dynamicChunksFilterData.word1 = dynamicChunksFilterData.word2 = dynamicChunksFilterData.word3 = 0;
+#endif
+ supportStrength = -1.0;
+ legacyChunkBoundsTestSetting = -1;
+ legacyDamageRadiusSpreadSetting = -1;
+ dynamicChunksDominanceGroup = 0xFF; // Out of range, so it won't be used.
+ flags = DestructibleParametersFlag::ACCUMULATE_DAMAGE;
+ depthParametersCount = 0;
+ rtFractureParameters.setToDefault();
+ alwaysDrawScatterMesh = false;
+}
+
+/**
+ Flags that apply to a destructible actor when it created
+*/
+struct DestructibleInitParametersFlag
+{
+ /**
+ Enum of destructible init parameters flag
+ */
+ enum Enum
+ {
+ /**
+ If set, then chunks which are tagged as "support" chunks (via DestructibleChunkDesc::isSupportChunk)
+ will have environmental support in static destructibles.
+ Note: if both ASSET_DEFINED_SUPPORT and WORLD_SUPPORT are set, then chunks must be tagged as
+ "support" chunks AND overlap the PxScene's static geometry in order to be environmentally supported.
+ */
+ ASSET_DEFINED_SUPPORT = (1 << 0),
+
+ /**
+ If set, then chunks which overlap the PxScene's static geometry will have environmental support in
+ static destructibles.
+ Note: if both ASSET_DEFINED_SUPPORT and WORLD_SUPPORT are set, then chunks must be tagged as
+ "support" chunks AND overlap the PxScene's static geometry in order to be environmentally supported.
+ */
+ WORLD_SUPPORT = (1 << 1),
+
+ /**
+ If this is set and the destructible is initially static, it will become part of an extended support
+ structure if it is in contact with another static destructible that also has this flag set.
+ */
+ FORM_EXTENDED_STRUCTURES = (1 << 2)
+ };
+};
+
+/**
+ Parameters that apply to a destructible actor at initialization
+*/
+struct DestructibleInitParameters
+{
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleInitParameters();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ The chunk hierarchy depth at which to create a support graph. Higher depth levels give more detailed support,
+ but will give a higher computational load. Chunks below the support depth will never be supported.
+ */
+ uint32_t supportDepth;
+
+ /**
+ A collection of flags defined in DestructibleInitParametersFlag.
+ */
+ uint32_t flags;
+};
+
+
+// DestructibleInitParameters inline functions
+
+PX_INLINE DestructibleInitParameters::DestructibleInitParameters()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleInitParameters::setToDefault()
+{
+ supportDepth = 0;
+ flags = 0;
+}
+
+/**
+ DamageSpreadFunction
+*/
+struct DamageSpreadFunction
+{
+ PX_INLINE DamageSpreadFunction()
+ {
+ setToDefault();
+ }
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault()
+ {
+ minimumRadius = 0.0f;
+ radiusMultiplier = 1.0f;
+ falloffExponent = 1.0f;
+ }
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const
+ {
+ return
+ minimumRadius >= 0.0f &&
+ radiusMultiplier >= 0.0f &&
+ falloffExponent >= 0.0f;
+ }
+
+ float minimumRadius; ///< minimum radius
+ float radiusMultiplier; ///< radius multiplier
+ float falloffExponent; ///< falloff exponent
+};
+
+/**
+ Destructible authoring structure.
+
+ Descriptor to build one chunk in a fracture hierarchy.
+*/
+class DestructibleBehaviorGroupDesc : public ApexDesc
+{
+public:
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleBehaviorGroupDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const;
+
+ /**
+ Defines the chunk to be environmentally supported, if the appropriate DestructibleParametersFlag flags
+ are set in DestructibleParameters.
+ */
+ const char* name; ///< name
+ float damageThreshold; ///< damage threshold
+ float damageToRadius; ///< damage to radius
+ DamageSpreadFunction damageSpread; ///< damage spread
+ DamageSpreadFunction damageColorSpread; ///< damage color spread
+ PxVec4 damageColorChange; ///< damege color change
+ float materialStrength; ///< material strength
+ float density; ///< density
+ float fadeOut; ///< fade out
+ float maxDepenetrationVelocity; ///< maximal depenetration velocity
+ uint64_t userData; ///< user data
+};
+
+// DestructibleChunkDesc inline functions
+
+PX_INLINE DestructibleBehaviorGroupDesc::DestructibleBehaviorGroupDesc()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleBehaviorGroupDesc::setToDefault()
+{
+ ApexDesc::setToDefault();
+
+ // TC_TODO: suitable default values?
+ name = NULL;
+ damageThreshold = 1.0f;
+ damageToRadius = 0.1f;
+ damageSpread.setToDefault();
+ damageColorSpread.setToDefault();
+ damageColorChange.setZero();
+ materialStrength = 0.0f;
+ density = 0;
+ fadeOut = 1;
+ maxDepenetrationVelocity = PX_MAX_F32;
+ userData = (uint64_t)0;
+}
+
+PX_INLINE bool DestructibleBehaviorGroupDesc::isValid() const
+{
+ // TC_TODO: this good enough?
+ if (damageThreshold < 0 ||
+ damageToRadius < 0 ||
+ !damageSpread.isValid() ||
+ !damageColorSpread.isValid() ||
+ materialStrength < 0 ||
+ density < 0 ||
+ fadeOut < 0 ||
+ !(maxDepenetrationVelocity > 0.f))
+ {
+ return false;
+ }
+
+ return ApexDesc::isValid();
+}
+/**
+ Destructible authoring structure.
+
+ Descriptor to build one chunk in a fracture hierarchy.
+*/
+class DestructibleChunkDesc : public ApexDesc
+{
+public:
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleChunkDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const;
+
+ /**
+ Defines the chunk to be environmentally supported, if the appropriate DestructibleParametersFlag flags
+ are set in DestructibleParameters.
+ */
+ bool isSupportChunk;
+
+ /**
+ Defines the chunk to be unfractureable. If this is true, then none of its children will be fractureable.
+ */
+ bool doNotFracture;
+
+ /**
+ Defines the chunk to be undamageable. This means this chunk will not fracture, but its children might.
+ */
+ bool doNotDamage;
+
+ /**
+ Defines the chunk to be uncrumbleable. This means this chunk will not be broken down into fluid mesh particles
+ no matter how much damage it takes. Note: this only applies to chunks with no children. For a chunk with
+ children, then:
+ 1) The chunk may be broken down into its children, and then its children may be crumbled, if the doNotCrumble flag
+ is not set on them.
+ 2) If the Destructible module's chunk depth offset LOD may be set such that this chunk effectively has no children.
+ In this case, the doNotCrumble flag will apply to it.
+ */
+ bool doNotCrumble;
+
+#if APEX_RUNTIME_FRACTURE
+ /**
+ Defines the chunk to use run-time, dynamic fracturing. The chunk will use the fracture pattern provided by the asset
+ to guide it's fracture. The resulting chunks will follow a similar process for subdivision.
+ */
+ bool runtimeFracture;
+#endif
+
+ /**
+ Whether or not to use instancing when rendering this chunk. If useInstancedRendering = TRUE, this chunk will
+ share a draw call with all others that instance the mesh indexed by meshIndex. This may extend to other
+ destructible actors created from this asset. If useInstancedRendering = FALSE, this chunk may share a draw
+ call only with other chunks in this asset which have useInstancedRendering = FALSE.
+ Default = FALSE.
+ */
+ bool useInstancedRendering;
+
+ /**
+ Translation for this chunk mesh within the asset. Normally a chunk needs no translation, but if a chunk is instanced within
+ the asset, then this translation is needed.
+ Default = (0,0,0).
+ */
+ PxVec3 instancePositionOffset;
+
+ /**
+ UV translation for this chunk mesh within the asset. Normally a chunk needs no UV translation, but if a chunk is instanced within
+ the asset, then this translation is usually needed.
+ Default = (0,0).
+ */
+ PxVec2 instanceUVOffset;
+
+ /**
+ If useInstancedRendering = TRUE, this index is the instanced mesh index. If useInstancedRendering = FALSE,
+ this index is the mesh part index for the skinned or statically rendered mesh.
+ This must index a valid DestructibleGeometryDesc (see below).
+ Default = 0xFFFF (invalid).
+ */
+ uint16_t meshIndex;
+
+ /**
+ The parent index of this chunk. If the index is negative, this is a root chunk.
+ Default = -1.
+ */
+ int32_t parentIndex;
+
+ /**
+ A direction used to move the chunk out of the destructible, if an impact kick is applied.
+ */
+ PxVec3 surfaceNormal;
+
+ /**
+ Referring to the behavior group used of this chunk, please check DestructibleAssetCookingDesc::behaviorGroupDescs for more detail.
+ */
+ int8_t behaviorGroupIndex;
+
+ /**
+ The number of scatter mesh instances on this chunk.
+ Default = 0.
+ */
+ uint32_t scatterMeshCount;
+
+ /**
+ Array of indices corresponding the scatter mesh assets set using DestructibleAssetAuthoring::setScatterMeshAssets().
+ The array length must be at least scatterMeshCount. This pointer may be NULL if scatterMeshCount = 0.
+ Default = NULL.
+ */
+ const uint8_t* scatterMeshIndices;
+
+ /**
+ Array of chunk-relative transforms corresponding the scatter mesh assets set using
+ DestructibleAssetAuthoring::setScatterMeshAssets().
+ The array length must be at least scatterMeshCount. This pointer may be NULL if scatterMeshCount = 0.
+ Default = NULL.
+ */
+ const PxMat44* scatterMeshTransforms;
+};
+
+// DestructibleChunkDesc inline functions
+
+PX_INLINE DestructibleChunkDesc::DestructibleChunkDesc()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleChunkDesc::setToDefault()
+{
+ ApexDesc::setToDefault();
+ isSupportChunk = false;
+ doNotFracture = false;
+ doNotDamage = false;
+ doNotCrumble = false;
+#if APEX_RUNTIME_FRACTURE
+ runtimeFracture = false;
+#endif
+ useInstancedRendering = false;
+ instancePositionOffset = PxVec3(0.0f);
+ instanceUVOffset = PxVec2(0.0f);
+ meshIndex = 0xFFFF;
+ parentIndex = -1;
+ surfaceNormal = PxVec3(0.0f);
+ behaviorGroupIndex = -1;
+ scatterMeshCount = 0;
+ scatterMeshIndices = NULL;
+ scatterMeshTransforms = NULL;
+}
+
+PX_INLINE bool DestructibleChunkDesc::isValid() const
+{
+ if (meshIndex == 0xFFFF)
+ {
+ return false;
+ }
+
+ return ApexDesc::isValid();
+}
+
+
+/**
+ Destructible authoring structure.
+
+ Descriptor to build one chunk in a fracture hierarchy.
+*/
+class DestructibleGeometryDesc : public ApexDesc
+{
+public:
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleGeometryDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const;
+
+ /**
+ The convex hulls associated with this chunk. These may be obtained from ExplicitHierarchicalMesh::convexHulls()
+ if authoring using an ExplicitHierarchicalMesh. The length of the array is given by convexHullCount.
+ */
+ const nvidia::ExplicitHierarchicalMesh::ConvexHull** convexHulls;
+
+ /**
+ The length of the convexHulls array. If this is positive, then convexHulls must point to a valid array of this size.
+ If this is zero, then collisionVolumeDesc must not be NULL, and convex hulls will be automatically created for this
+ geometry using collisionVolumeDesc.
+ */
+ uint32_t convexHullCount;
+
+ /**
+ If convexHullCount = 0, then collisionVolumeDesc must not be NULL. In this case convex hulls will automatically be
+ created for this geometry. See CollisionVolumeDesc.
+ */
+ const CollisionVolumeDesc* collisionVolumeDesc;
+};
+
+// DestructibleGeometryDesc inline functions
+
+PX_INLINE DestructibleGeometryDesc::DestructibleGeometryDesc()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleGeometryDesc::setToDefault()
+{
+ ApexDesc::setToDefault();
+ convexHulls = NULL;
+ convexHullCount = 0;
+ collisionVolumeDesc = NULL;
+}
+
+PX_INLINE bool DestructibleGeometryDesc::isValid() const
+{
+ if (convexHullCount == 0 && collisionVolumeDesc == NULL)
+ {
+ return false;
+ }
+
+ if (convexHullCount > 0 && convexHulls == NULL)
+ {
+ return false;
+ }
+
+ return ApexDesc::isValid();
+}
+
+
+/**
+ Destructible authoring structure.
+
+ Descriptor for the cookChunk() method of DestructibleAssetAuthoring
+*/
+class DestructibleAssetCookingDesc : public ApexDesc
+{
+public:
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE DestructibleAssetCookingDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const;
+
+ /**
+ Beginning of array of descriptors, one for each chunk.
+ */
+ DestructibleChunkDesc* chunkDescs;
+
+ /**
+ The size of the chunkDescs array. This must be positive.
+ */
+ uint32_t chunkDescCount;
+
+ /**
+ Default behavior group (corresponds to index of -1).
+ */
+ DestructibleBehaviorGroupDesc defaultBehaviorGroupDesc;
+
+ /**
+ Beginning of array of descriptors, one for each behavior group.
+ */
+ DestructibleBehaviorGroupDesc* behaviorGroupDescs;
+
+ /**
+ The size of the behaviorGroupDescs array. This must be positive.
+ */
+ uint32_t behaviorGroupDescCount;
+
+ /**
+ RT fracture behavior group
+ */
+ int8_t RTFractureBehaviorGroup;
+
+ /**
+ Beginning of array of descriptors, one for each mesh part.
+ */
+ DestructibleGeometryDesc* geometryDescs;
+
+ /**
+ The size of the geometryDescs array. This must be positive.
+ */
+ uint32_t geometryDescCount;
+
+ /**
+ Index pairs that represent chunk connections in the support graph.
+ The indices refer to the chunkDescs array. Only sibling chunks,
+ i.e. chunks at equal depth may be connected.
+ */
+ nvidia::IntPair* supportGraphEdges;
+
+ /**
+ Number of index pairs in supportGraphEdges.
+ */
+ uint32_t supportGraphEdgeCount;
+};
+
+// DestructibleAssetCookingDesc inline functions
+
+PX_INLINE DestructibleAssetCookingDesc::DestructibleAssetCookingDesc()
+{
+ setToDefault();
+}
+
+PX_INLINE void DestructibleAssetCookingDesc::setToDefault()
+{
+ ApexDesc::setToDefault();
+ chunkDescs = NULL;
+ chunkDescCount = 0;
+ geometryDescs = NULL;
+ geometryDescCount = 0;
+ behaviorGroupDescs = 0;
+ behaviorGroupDescCount = 0;
+ supportGraphEdges = 0;
+ supportGraphEdgeCount = 0;
+}
+
+PX_INLINE bool DestructibleAssetCookingDesc::isValid() const
+{
+ if (chunkDescCount == 0 || chunkDescs == NULL)
+ {
+ return false;
+ }
+
+ for (uint32_t i = 0; i < chunkDescCount; ++i )
+ {
+ if (!chunkDescs[i].isValid())
+ {
+ return false;
+ }
+ }
+
+ if (chunkDescCount >= 65535)
+ {
+ return false;
+ }
+
+ if (geometryDescCount == 0 || geometryDescs == NULL)
+ {
+ return false;
+ }
+
+ for (uint32_t i = 0; i < geometryDescCount; ++i )
+ {
+ if (!geometryDescs[i].isValid())
+ {
+ return false;
+ }
+ }
+
+ if (behaviorGroupDescCount > 127)
+ {
+ return false;
+ }
+
+ for (uint32_t i = 0; i < behaviorGroupDescCount; ++i )
+ {
+ if (!behaviorGroupDescs[i].isValid())
+ {
+ return false;
+ }
+ }
+
+ return ApexDesc::isValid();
+}
+
+
+/**
+ Stats for an DestructibleAsset: memory usage, counts, etc.
+*/
+struct DestructibleAssetStats
+{
+ uint32_t totalBytes; ///< total bytes
+ uint32_t chunkCount; ///< chunk count
+ uint32_t chunkBytes; ///< chunk bytes
+ uint32_t chunkHullDataBytes; ///< chunk hull data bytes
+ uint32_t collisionCookedHullDataBytes; ///< collision cooked hull data bytes
+ uint32_t collisionMeshCount; ///< collision mesh count
+ uint32_t maxHullVertexCount; ///< max hull vertex count
+ uint32_t maxHullFaceCount; ///< max hull face count
+ uint32_t chunkWithMaxEdgeCount; ///< chunk with max edge count
+ uint32_t runtimeCookedConvexCount; ///< runtime cooked convex count
+ RenderMeshAssetStats renderMeshAssetStats; ///< render mesh asset stats
+};
+
+/**
+ Authoring API for a destructible asset.
+*/
+class DestructibleAssetAuthoring : public AssetAuthoring
+{
+public:
+
+ /** Fracturing API */
+
+ /**
+ DestructibleAssetAuthoring contains an instantiation of ExplicitHierarchicalMesh.
+ This function gives access to it. See ExplicitHierarchicalMesh for details, it is
+ the object used by the fracturing tool set for mesh fracturing operations and is used
+ to generate the embedded RenderMesh as well as collision and hierarchy data
+ for the destructible asset.
+ */
+ virtual ExplicitHierarchicalMesh& getExplicitHierarchicalMesh() = 0;
+
+ /**
+ DestructibleAssetAuthoring contains a second instantiation of ExplicitHierarchicalMesh
+ used to describe the core mesh for slice fracturing (see FractureTools::FractureSliceDesc),
+ done in createHierarchicallySplitMesh(). This function gives access to it.
+ */
+ virtual ExplicitHierarchicalMesh& getCoreExplicitHierarchicalMesh() = 0;
+
+ /**
+ DestructibleAssetAuthoring contains an instantiation of CutoutSet used to describe the
+ cutout fracturing shapes (see FractureTools::CutoutSet), done in createChippedMesh().
+ This function gives access to it.
+ */
+ virtual FractureTools::CutoutSet& getCutoutSet() = 0;
+
+ /**
+ Partitions (and possibly re-orders) the mesh array if the triangles form disjoint islands.
+
+ \param mesh pointer to array of ExplicitRenderTriangles which make up the mesh
+ \param meshTriangleCount the size of the meshTriangles array
+ \param meshPartition user-allocated array for mesh partition, will be filled with the end elements of contiguous subsets of meshTriangles.
+ \param meshPartitionMaxCount size of user-allocated meshPartitionArray
+ \param padding relative value multiplied by the mesh bounding box. padding gets added to the triangle bounds when calculating triangle neighbors.
+
+ \return Returns the number of partitions. The value may be larger than meshPartitionMaxCount. In that case, the partitions beyond meshPartitionMaxCount are not recorded.
+ */
+ virtual uint32_t partitionMeshByIslands
+ (
+ nvidia::ExplicitRenderTriangle* mesh,
+ uint32_t meshTriangleCount,
+ uint32_t* meshPartition,
+ uint32_t meshPartitionMaxCount,
+ float padding = 0.0001f
+ ) = 0;
+
+ /**
+ Builds a new ExplicitHierarchicalMesh from an array of triangles, used as the starting
+ point for fracturing. It will contain only one chunk, at depth 0.
+
+ \param meshTriangles pointer to array of ExplicitRenderTriangles which make up the mesh
+ \param meshTriangleCount the size of the meshTriangles array
+ \param submeshData pointer to array of ExplicitSubmeshData, describing the submeshes
+ \param submeshCount the size of the submeshData array
+ \param meshPartition if not NULL, an array of size meshPartitionCount, giving the end elements of contiguous subsets of meshTriangles.
+ If meshPartition is NULL, one partition is assumed.
+ When there is one partition, these triangles become the level 0 part.
+ When there is more than one partition, the behavior is determined by firstPartitionIsDepthZero (see below).
+ \param meshPartitionCount if meshPartition is not NULL, this is the size of the meshPartition array.
+ \param parentIndices if not NULL, the parent indices for each chunk (corresponding to a partition in the mesh partition).
+ \param parentIndexCount the size of the parentIndices array. This does not need to match meshPartitionCount. If a mesh partition has an index beyond the end of parentIndices,
+ then the parentIndex is considered to be 0. Therefore, if parentIndexCount = 0, all parents are 0 and so all chunks created will be depth 1. This will cause a
+ depth 0 chunk to be created that is the aggregate of the depth 1 chunks. If parentIndexCount > 0, then the depth-0 chunk must have a parentIndex of -1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = true, set parentIndices to the address of a int32_t containing the value -1, and set parentIndexCount = 1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = false, set parentIndexCount = 0.
+ Note: if parent indices are given, the first one must be -1, and *only* that index may be negative. That is, there may be only one depth-0 mesh and it must be the first mesh.
+ */
+ virtual bool setRootMesh
+ (
+ const ExplicitRenderTriangle* meshTriangles,
+ uint32_t meshTriangleCount,
+ const ExplicitSubmeshData* submeshData,
+ uint32_t submeshCount,
+ uint32_t* meshPartition = NULL,
+ uint32_t meshPartitionCount = 0,
+ int32_t* parentIndices = NULL,
+ uint32_t parentIndexCount = 0
+ ) = 0;
+
+ /**
+ Builds the root ExplicitHierarchicalMesh from an RenderMeshAsset.
+ Since an DestructibleAsset contains no hierarchy information, the input mesh must have only one part.
+
+ \param renderMeshAsset the asset to import
+ \param maxRootDepth cap the root depth at this value. Re-fracturing of the mesh will occur at this depth. Default = UINT32_MAX
+ */
+ virtual bool importRenderMeshAssetToRootMesh(const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
+
+ /**
+ Builds the root ExplicitHierarchicalMesh from an DestructibleAsset.
+ Since an DestructibleAsset contains hierarchy information, the explicit mesh formed
+ will have this hierarchy structure.
+
+ \param destructibleAsset the asset to import
+ \param maxRootDepth cap the root depth at this value. Re-fracturing of the mesh will occur at this depth. Default = UINT32_MAX
+ */
+ virtual bool importDestructibleAssetToRootMesh(const nvidia::DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
+
+ /**
+ Builds a new ExplicitHierarchicalMesh from an array of triangles, used as the core mesh
+ for slice fracture operations (see FractureTools::FractureSliceDesc, passed into
+ createHierarchicallySplitMesh).
+
+ \param mesh pointer to array of ExplicitRenderTriangles which make up the mesh
+ \param meshTriangleCount the size of the meshTriangles array
+ \param submeshData pointer to array of ExplicitSubmeshData, describing the submeshes
+ \param submeshCount the size of the submeshData array
+ \param meshPartition meshPartition array
+ \param meshPartitionCount meshPartition array size
+ */
+ virtual bool setCoreMesh
+ (
+ const ExplicitRenderTriangle* mesh,
+ uint32_t meshTriangleCount,
+ const ExplicitSubmeshData* submeshData,
+ uint32_t submeshCount,
+ uint32_t* meshPartition = NULL,
+ uint32_t meshPartitionCount = 0
+ ) = 0;
+
+ /**
+ Builds a new ExplicitHierarchicalMesh from an array of triangles, externally provided by the user.
+ Note: setRootMesh and setCoreMesh may be implemented as follows:
+ setRootMesh(x) <-> buildExplicitHierarchicalMesh( getExplicitHierarchicalMesh(), x)
+ setCoreMesh(x) <-> buildExplicitHierarchicalMesh( getCoreExplicitHierarchicalMesh(), x)
+
+ \param hMesh new ExplicitHierarchicalMesh
+ \param meshTriangles pointer to array of ExplicitRenderTriangles which make up the mesh
+ \param meshTriangleCount the size of the meshTriangles array
+ \param submeshData pointer to array of ExplicitSubmeshData, describing the submeshes
+ \param submeshCount the size of the submeshData array
+ \param meshPartition if not NULL, an array of size meshPartitionCount, giving the end elements of contiguous subsets of meshTriangles.
+ If meshPartition is NULL, one partition is assumed.
+ When there is one partition, these triangles become the level 0 part.
+ When there is more than one partition, these triangles become level 1 parts, while the union of the parts will be the level 0 part.
+ \param meshPartitionCount if meshPartition is not NULL, this is the size of the meshPartition array.
+ \param parentIndices if not NULL, the parent indices for each chunk (corresponding to a partition in the mesh partition).
+ \param parentIndexCount the size of the parentIndices array. This does not need to match meshPartitionCount. If a mesh partition has an index beyond the end of parentIndices,
+ then the parentIndex is considered to be 0. Therefore, if parentIndexCount = 0, all parents are 0 and so all chunks created will be depth 1. This will cause a
+ depth 0 chunk to be created that is the aggregate of the depth 1 chunks. If parentIndexCount > 0, then the depth-0 chunk must have a parentIndex of -1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = true, set parentIndices to the address of a int32_t containing the value -1, and set parentIndexCount = 1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = false, set parentIndexCount = 0.
+ Note: if parent indices are given, the first one must be -1, and *only* that index may be negative. That is, there may be only one depth-0 mesh and it must be the first mesh.
+ */
+ virtual bool buildExplicitHierarchicalMesh
+ (
+ ExplicitHierarchicalMesh& hMesh,
+ const ExplicitRenderTriangle* meshTriangles,
+ uint32_t meshTriangleCount,
+ const ExplicitSubmeshData* submeshData,
+ uint32_t submeshCount,
+ uint32_t* meshPartition = NULL,
+ uint32_t meshPartitionCount = 0,
+ int32_t* parentIndices = NULL,
+ uint32_t parentIndexCount = 0
+ ) = 0;
+
+ /**
+ Splits the chunk in chunk[0], forming a hierarchy of fractured chunks in chunks[1...] using
+ slice-mode fracturing.
+
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the slicing surfaces (see FractureSliceDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method See CollisionDesc.
+ \param exportCoreMesh if true, the core mesh will be included (at depth 1) in the hierarchically split mesh. Otherwise, it will only be used to create a hollow space.
+ \param coreMeshImprintSubmeshIndex if this is < 0, use the core mesh materials (was applyCoreMeshMaterialToNeighborChunks). Otherwise, use the given submesh
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity. Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool createHierarchicallySplitMesh
+ (
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureSliceDesc& desc,
+ const CollisionDesc& collisionDesc,
+ bool exportCoreMesh,
+ int32_t coreMeshImprintSubmeshIndex,
+ uint32_t randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Splits the mesh in chunk[0], forming a hierarchy of fractured meshes in chunks[1...] using
+ cutout-mode (chippable) fracturing.
+
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the slicing surfaces (see FractureCutoutDesc)
+ \param cutoutSet the cutout set to use for fracturing (see CutoutSet)
+ \param sliceDesc used if desc.chunkFracturingMethod = SliceFractureCutoutChunks
+ \param voronoiDesc used if desc.chunkFracturingMethod = VoronoiFractureCutoutChunks
+ \param collisionDesc convex hulls will be generated for each chunk using the method See CollisionDesc.
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity. Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool createChippedMesh
+ (
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureCutoutDesc& desc,
+ const FractureTools::CutoutSet& cutoutSet,
+ const FractureTools::FractureSliceDesc& sliceDesc,
+ const FractureTools::FractureVoronoiDesc& voronoiDesc,
+ const CollisionDesc& collisionDesc,
+ uint32_t randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Builds an internal cutout set.
+
+ \param pixelBuffer pointer to be beginning of the pixel buffer
+ \param bufferWidth the width of the buffer in pixels
+ \param bufferHeight the height of the buffer in pixels
+ \param snapThreshold the pixel distance at which neighboring cutout vertices and segments may be fudged into alignment.
+ \param periodic whether or not to use periodic boundary conditions when creating cutouts from the map
+ */
+ virtual void buildCutoutSet
+ (
+ const uint8_t* pixelBuffer,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight,
+ float snapThreshold,
+ bool periodic
+ ) = 0;
+
+ /**
+ Calculate the mapping between a cutout fracture map and a given triangle.
+ The result is a 3 by 3 matrix M composed by an affine transformation and a rotation, we can get the 3-D projection for a texture coordinate pair (u,v) with such a formula:
+ (x,y,z) = M*PxVec3(u,v,1)
+
+ \param mapping resulted mapping, composed by an affine transformation and a rotation
+ \param triangle triangle
+ **/
+ virtual bool calculateCutoutUVMapping
+ (
+ PxMat33& mapping,
+ const nvidia::ExplicitRenderTriangle& triangle
+ ) = 0;
+
+ /**
+ Uses the passed-in target direction to find the best triangle in the root mesh with normal near the given targetDirection. If triangles exist
+ with normals within one degree of the given target direction, then one with the greatest area of such triangles is used. Otherwise, the triangle
+ with normal closest to the given target direction is used. The resulting triangle is used to calculate a UV mapping as in the function
+ calculateCutoutUVMapping (above).
+
+ The assumption is that there exists a single mapping for all triangles on a specified face, for this feature to be useful.
+
+ \param mapping resulted mapping, composed by an affine transformation and a rotation
+ \param targetDirection: the target face's normal
+ **/
+ virtual bool calculateCutoutUVMapping
+ (
+ PxMat33& mapping,
+ const PxVec3& targetDirection
+ ) = 0;
+
+ /**
+ Splits the mesh in chunk[0], forming fractured pieces chunks[1...] using
+ Voronoi decomposition fracturing.
+
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the voronoi splitting parameters surfaces (see FractureVoronoiDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method See CollisionDesc.
+ \param exportCoreMesh if true, the core mesh will be included (at depth 1) in the split mesh. Otherwise, it will only be used to create a hollow space.
+ \param coreMeshImprintSubmeshIndex if this is < 0, use the core mesh materials (was applyCoreMeshMaterialToNeighborChunks). Otherwise, use the given submesh
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity. Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool createVoronoiSplitMesh
+ (
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureVoronoiDesc& desc,
+ const CollisionDesc& collisionDesc,
+ bool exportCoreMesh,
+ int32_t coreMeshImprintSubmeshIndex,
+ uint32_t randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Generates a set of uniformly distributed points in the interior of the root mesh.
+
+ \param siteBuffer An array of PxVec3, at least the size of siteCount.
+ \param siteChunkIndices If not NULL, it must be at least the size of siteCount.
+ siteCount indices will be written to this buffer,
+ associating each site with a chunk that contains it.
+ \param siteCount The number of points to write into siteBuffer.
+ \param randomSeed Pointer to a seed for the random number generator, to ensure reproducibility.
+ If NULL, the random number generator will not be re-seeded.
+ \param microgridSize Pointer to a grid size used for BSP creation. If NULL, the default settings will be used.
+ \param meshMode Open mesh handling. Modes: Automatic, Closed, Open (see BSPOpenMode)
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param chunkIndex If this is a valid index, the voronoi sites will only be created within the volume of the indexed chunk. Otherwise,
+ the sites will be created within each of the root-level chunks. Default value is an invalid index.
+
+ \return Returns the number of sites actually created (written to siteBuffer and siteChunkIndices).
+ This may be less than the number of sites requested if site placement fails.
+ */
+ virtual uint32_t createVoronoiSitesInsideMesh
+ (
+ PxVec3* siteBuffer,
+ uint32_t* siteChunkIndices,
+ uint32_t siteCount,
+ uint32_t* randomSeed,
+ uint32_t* microgridSize,
+ BSPOpenMode::Enum meshMode,
+ IProgressListener& progressListener,
+ uint32_t chunkIndex = 0xFFFFFFFF
+ ) = 0;
+
+ /**
+ Creates scatter mesh sites randomly distributed on the mesh.
+
+ \param meshIndices user-allocated array of size scatterMeshInstancesBufferSize which will be filled in by this function, giving the scatter mesh index used
+ \param relativeTransforms user-allocated array of size scatterMeshInstancesBufferSize which will be filled in by this function, giving the chunk-relative transform for each chunk instance
+ \param chunkMeshStarts user-allocated array which will be filled in with offsets into the meshIndices and relativeTransforms array.
+ For a chunk indexed by i, the corresponding range [chunkMeshStart[i], chunkMeshStart[i+1]-1] in meshIndices and relativeTransforms is used.
+ *NOTE*: chunkMeshStart array must be of at least size N+1, where N is the number of chunks in the base explicit hierarchical mesh.
+ \param scatterMeshInstancesBufferSize the size of meshIndices and relativeTransforms array.
+ \param targetChunkCount how many chunks are in the array targetChunkIndices
+ \param targetChunkIndices an array of chunk indices which are candidates for scatter meshes. The elements in the array chunkIndices will come from this array
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param scatterMeshAssetCount the number of different scatter meshes (not instances). Should not exceed 255. If scatterMeshAssetCount > 255, only the first 255 will be used.
+ \param scatterMeshAssets an array of size scatterMeshAssetCount, of the render mesh assets which will be used for the scatter meshes
+ \param minCount an array of size scatterMeshAssetCount, giving the minimum number of instances to place for each mesh
+ \param maxCount an array of size scatterMeshAssetCount, giving the maximum number of instances to place for each mesh
+ \param minScales an array of size scatterMeshAssetCount, giving the minimum scale to apply to each scatter mesh
+ \param maxScales an array of size scatterMeshAssetCount, giving the maximum scale to apply to each scatter mesh
+ \param maxAngles an array of size scatterMeshAssetCount, giving a maximum deviation angle (in degrees) from the surface normal to apply to each scatter mesh
+
+ \return return value: the number of instances placed in indices and relativeTransforms (will not exceed scatterMeshInstancesBufferSize)
+ */
+ virtual uint32_t createScatterMeshSites
+ (
+ uint8_t* meshIndices,
+ PxMat44* relativeTransforms,
+ uint32_t* chunkMeshStarts,
+ uint32_t scatterMeshInstancesBufferSize,
+ uint32_t targetChunkCount,
+ const uint16_t* targetChunkIndices,
+ uint32_t* randomSeed,
+ uint32_t scatterMeshAssetCount,
+ nvidia::RenderMeshAsset** scatterMeshAssets,
+ const uint32_t* minCount,
+ const uint32_t* maxCount,
+ const float* minScales,
+ const float* maxScales,
+ const float* maxAngles
+ ) = 0;
+
+ /**
+ Utility to visualize Voronoi cells for a given set of sites.
+
+ \param debugRender rendering object which will receive the drawing primitives associated with this cell visualization
+ \param sites an array of Voronoi cell sites, of length siteCount
+ \param siteCount the number of Voronoi cell sites (length of sites array)
+ \param cellColors an optional array of colors (see RenderDebug for format) for the cells. If NULL, the white (0xFFFFFFFF) color will be used.
+ If not NULL, this (of length cellColorCount) is used to color the cell graphics. The number cellColorCount need not match siteCount. If
+ cellColorCount is less than siteCount, the cell colors will cycle. That is, site N gets cellColor[N%cellColorCount].
+ \param cellColorCount the number of cell colors (the length of cellColors array)
+ \param bounds defines an axis-aligned bounding box which clips the visualization, since some cells extend to infinity
+ \param cellIndex if this is a valid index (cellIndex < siteCount), then only the cell corresponding to sites[cellIndex] will be drawn. Otherwise, all cells will be drawn.
+ */
+ virtual void visualizeVoronoiCells
+ (
+ nvidia::RenderDebugInterface& debugRender,
+ const PxVec3* sites,
+ uint32_t siteCount,
+ const uint32_t* cellColors,
+ uint32_t cellColorCount,
+ const PxBounds3& bounds,
+ uint32_t cellIndex = 0xFFFFFFFF
+ ) = 0;
+
+ /**
+ Splits the chunk in chunk[chunkIndex], forming a hierarchy of fractured chunks using
+ slice-mode fracturing. The chunks will be rearranged so that they are in breadth-first order.
+
+ \param chunkIndex index of chunk to be split
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the slicing surfaces (see FractureSliceDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity. Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool hierarchicallySplitChunk
+ (
+ uint32_t chunkIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureSliceDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t* randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Splits the chunk in chunk[chunkIndex], forming fractured chunks using
+ Voronoi decomposition fracturing. The chunks will be rearranged so that they are in breadth-first order.
+
+ \param chunkIndex index of chunk to be split
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the voronoi splitting parameters surfaces (see FractureVoronoiDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity. Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool voronoiSplitChunk
+ (
+ uint32_t chunkIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureVoronoiDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t* randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Set the tolerances used in CSG calculations.
+
+ \param linearTolerance relative (to mesh size) tolerance used with angularTolerance to determine coplanarity. Default = 1.0e-4.
+ \param angularTolerance used with linearTolerance to determine coplanarity. Default = 1.0e-3
+ \param baseTolerance relative (to mesh size) tolerance used for spatial partitioning
+ \param clipTolerance relative (to mesh size) tolerance used when clipping triangles for CSG mesh building operations. Default = 1.0e-4.
+ \param cleaningTolerance relative (to mesh size) tolerance used when cleaning the out put mesh generated from the toMesh() function. Default = 1.0e-7.
+ */
+ virtual void setBSPTolerances
+ (
+ float linearTolerance,
+ float angularTolerance,
+ float baseTolerance,
+ float clipTolerance,
+ float cleaningTolerance
+ ) = 0;
+
+ /**
+ Set the parameters used in BSP building operations.
+
+ \param logAreaSigmaThreshold At each step in the tree building process, the surface with maximum triangle area is compared
+ to the other surface triangle areas. If the maximum area surface is far from the "typical" set of
+ surface areas, then that surface is chosen as the next splitting plane. Otherwise, a random
+ test set is chosen and a winner determined based upon the weightings below.
+ The value logAreaSigmaThreshold determines how "atypical" the maximum area surface must be to
+ be chosen in this manner.
+ Default value = 2.0.
+ \param testSetSize Larger values of testSetSize may find better BSP trees, but will take more time to create.
+ testSetSize = 0 is treated as infinity (all surfaces will be tested for each branch).
+ Default value = 10.
+ \param splitWeight How much to weigh the relative number of triangle splits when searching for a BSP surface.
+ Default value = 0.5.
+ \param imbalanceWeight How much to weigh the relative triangle imbalance when searching for a BSP surface.
+ Default value = 0.0.
+ */
+ virtual void setBSPBuildParameters
+ (
+ float logAreaSigmaThreshold,
+ uint32_t testSetSize,
+ float splitWeight,
+ float imbalanceWeight
+ ) = 0;
+
+
+ /**
+ Instantiates an ExplicitHierarchicalMesh::ConvexHull
+
+ See the ConvexHull API for its functionality. Can be used to author chunk hulls in the
+ cookChunks function.
+
+ Use ConvexHull::release() to delete the object.
+ */
+ virtual ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull() = 0;
+
+ /**
+ Builds a mesh used for slice fracturing, given the noise parameters and random seed. This function is mostly intended
+ for visualization - to give the user a "typical" slice surface used for fracturing.
+
+ \return Returns the head of an array of ExplicitRenderTriangles, of length given by the return value.
+ */
+ virtual uint32_t buildSliceMesh(const ExplicitRenderTriangle*& mesh, const FractureTools::NoiseParameters& noiseParameters, const PxPlane& slicePlane, uint32_t randomSeed) = 0;
+
+ /**
+ Serialization of the data associated with the fracture API. This includes
+ the root mesh, core mesh, and cutout set.
+ */
+ virtual void serializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) const = 0;
+
+ /**
+ Deserialization of the data associated with the fracture API. This includes
+ the root mesh, core mesh, and cutout set.
+ */
+ virtual void deserializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) = 0;
+
+ /**
+ Set current depth for chunk overlaps calculations.
+ */
+ virtual void setChunkOverlapsCacheDepth(int32_t depth = -1) = 0;
+
+ /**
+ Gets the RenderMeshAsset associated with this asset.
+ */
+ virtual const RenderMeshAsset* getRenderMeshAsset() const = 0;
+
+ /**
+ Set the RenderMeshAsset associated with this asset.
+ This is the asset used for non-instanced rendering.
+ NULL is a valid argument, and can be used to clear the internal mesh data.
+
+ \return Returns true if successful.
+ */
+ virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0;
+
+ /**
+ Set the RenderMeshAssets used for scatter mesh rendering associated with this asset.
+ These assets will be rendered using instanced rendering.
+ The array cannot contain NULL elements, if an array size greater than zero is specified.
+
+ \return Returns true if successful.
+ */
+ virtual bool setScatterMeshAssets(RenderMeshAsset** scatterMeshAssetArray, uint32_t scatterMeshAssetArraySize) = 0;
+
+ /** Retrieve the number of scatter mesh assets */
+ virtual uint32_t getScatterMeshAssetCount() const = 0;
+
+ /** Retrieve the scatter mesh asset array */
+ virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0;
+
+ /**
+ Get the number of instanced chunk meshes in this asset.
+ */
+ virtual uint32_t getInstancedChunkMeshCount() const = 0;
+
+ /**
+ Set the parameters used for runtime destruction behavior. See DestructibleParameters.
+ */
+ virtual void setDestructibleParameters(const DestructibleParameters&) = 0;
+
+ /**
+ The DestructibleParameters which describe the default fracturing behavior for instanced
+ DestructibleActors. These may be overridden by calling setDestructibleParameters().
+ */
+ virtual DestructibleParameters getDestructibleParameters() const = 0;
+
+ /**
+ Set the parameters used for default destructible initialization. See DestructibleInitParameters.
+ */
+ virtual void setDestructibleInitParameters(const DestructibleInitParameters&) = 0;
+
+ /**
+ The parameters used for default destructible initialization. See DestructibleInitParameters.
+ */
+ virtual DestructibleInitParameters getDestructibleInitParameters() const = 0;
+
+ /**
+ Set the name of the emitter to use when generating crumble particles.
+ */
+ virtual void setCrumbleEmitterName(const char*) = 0;
+
+ /**
+ Set the name of the emitter to use when generating fracture-line dust particles.
+ */
+ virtual void setDustEmitterName(const char*) = 0;
+
+ /**
+ Set the name of the fracture pattern to use when runtime fracture is enabled.
+ */
+ virtual void setFracturePatternName(const char*) = 0;
+
+ /**
+ Set padding used for chunk neighbor tests. This padding is relative to the largest diagonal
+ of the asset's local bounding box.
+ This value must be non-negative.
+ Default value = 0.001f.
+ */
+ virtual void setNeighborPadding(float neighborPadding) = 0;
+
+ /**
+ Get padding used for chunk neighbor tests. Set setNeighborPadding().
+ */
+ virtual float getNeighborPadding() const = 0;
+
+ /**
+ Once the internal ExplicitHierarchicalMesh is built using the fracture tools functions
+ and all emitter names and parameters set, this functions builds the destructible asset.
+ Every chunk (corresponding to a part in the ExplicitHierarchicalMesh) must have
+ destruction-specific data set through the descriptor passed into this function. See
+ DestructibleAssetCookingDesc.
+
+ \param cookingDesc cooking setup
+ \param cacheOverlaps whether the chunk overlaps up to chunkOverlapCacheDepth should be cached in this call
+ \param chunkIndexMapUser2Apex optional user provided uint32_t array that will contains the mapping from user chunk indices (referring to chunks in cookingDesc)
+ to Apex internal chunk indices (referring to chunk is internal chunk array)
+ \param chunkIndexMapApex2User same as chunkIndexMapUser2Apex, but opposite direction
+ \param chunkIndexMapCount size of the user provided mapping arrays
+ */
+ virtual void cookChunks( const DestructibleAssetCookingDesc& cookingDesc, bool cacheOverlaps = true,
+ uint32_t* chunkIndexMapUser2Apex = NULL, uint32_t* chunkIndexMapApex2User = NULL, uint32_t chunkIndexMapCount = 0) = 0;
+
+ /**
+ The scale factor used to apply an impulse force along the normal of chunk when fractured. This is used
+ in order to "push" the pieces out as they fracture.
+ */
+ virtual float getFractureImpulseScale() const = 0;
+
+ /**
+ Large impact force may be reported if rigid bodies are spawned inside one another. In this case the realative velocity of the two
+ objects will be low. This variable allows the user to set a minimum velocity threshold for impacts to ensure that the objects are
+ moving at a min velocity in order for the impact force to be considered.
+ */
+ virtual float getImpactVelocityThreshold() const = 0;
+
+ /**
+ The total number of chunks in the cooked asset.
+ */
+ virtual uint32_t getChunkCount() const = 0;
+
+ /**
+ The total number of fracture hierarchy depth levels in the cooked asset.
+ */
+ virtual uint32_t getDepthCount() const = 0;
+
+ /**
+ Returns the number of children for the given chunk.
+ chunkIndex must be less than getChunkCount(). If it is not, this function returns 0.
+ */
+ virtual uint32_t getChunkChildCount(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the index for the given child of the given chunk.
+ chunkIndex must be less than getChunkCount() and childIndex must be less than getChunkChildCount(chunkIndex).
+ If either of these conditions is not met, the function returns ModuleDestructibleConst::INVALID_CHUNK_INDEX.
+ */
+ virtual int32_t getChunkChild(uint32_t chunkIndex, uint32_t childIndex) const = 0;
+
+ /**
+ If this chunk is instanced within the same asset, then this provides the instancing position offset.
+ Otherwise, this function returns (0,0,0).
+ */
+ virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0;
+
+ /**
+ If this chunk is instanced within the same asset, then this provides the instancing UV offset.
+ Otherwise, this function returns (0,0).
+ */
+ virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0;
+
+ /**
+ The render mesh asset part index associated with this chunk.
+ */
+ virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0;
+
+ /**
+ Trim collision geometry to prevent explosive behavior. maxTrimFraction is the maximum (relative) distance to trim a hull in the direction
+ of each trim plane.
+
+ \return Returns true iff successful.
+ */
+ virtual void trimCollisionGeometry(const uint32_t* partIndices, uint32_t partIndexCount, float maxTrimFraction = 0.2f) = 0;
+
+ /**
+ Returns stats (sizes, counts) for the asset. See DestructibleAssetStats.
+ */
+ virtual void getStats(DestructibleAssetStats& stats) const = 0;
+
+ /**
+ Ensures that the asset has chunk overlap information cached up to the given depth.
+ If depth < 0 (as it is by default), the depth will be taken to be the supportDepth
+ given in the asset's destructibleParameters.
+ It is ok to pass in a depth greater than any chunk depth in the asset.
+ */
+ virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0;
+
+ /**
+ Clears the chunk overlap cache.
+
+ \param depth Depth to be cleared. -1 for all depths.
+ \param keepCachedFlag If the flag is set, the depth is considered to be cached even if the overlaps list is empty.
+ */
+ virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0;
+
+ /**
+ Adds edges to the support graph. Edges must connect chunks of equal depth.
+ The indices refer to the reordered chunk array, a mapping is provided in cookChunks.
+ */
+ virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0;
+
+ /**
+ Removes edges from support graph.
+ The indices refer to the reordered chunk array, a mapping is provided in cookChunks.
+
+ \param supportGraphEdges Integer pairs representing indices to chunks that are linked
+ \param numSupportGraphEdges Number of provided integer pairs.
+ \param keepCachedFlagIfEmpty If the flag is set, the depth is considered to be cached even if the overlaps list is empty.
+ */
+ virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0;
+
+ /**
+ The size of the array returned by getCachedOverlapsAtDepth(depth) (see below).
+ Note: this function will not trigger overlap caching for the given depth. If no overlaps
+ have been calculated for the depth given, this function returns NULL.
+ */
+ virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) = 0;
+
+ /**
+ Array of integer pairs, indexing chunk pairs which touch at a given depth in the heirarcy.
+ The size of the array is given by getCachedOverlapCountAtDepth(depth).
+ Note: this function will not trigger overlap caching for the given depth. If no overlaps
+ have been calculated for the depth given, this function returns NULL.
+ */
+ virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) = 0;
+
+ /**
+ \brief Apply a transformation to destructible asset
+
+ This is a permanent transformation and it changes the object state. Should only be called immediately before serialization
+ and without further modifying the object later on.
+
+ \param transformation This matrix is allowed to contain a translation and a rotation
+ \param scale Apply a uniform scaling as well
+ */
+ virtual void applyTransformation(const PxMat44& transformation, float scale) = 0;
+
+ /**
+ \brief Apply an arbitrary affine transformation to destructible asset
+
+ This is a permanent transformation and it changes the object state. Should only be called immediately before serialization
+ and without further modifying the object later on.
+
+ \param transformation This matrix is allowed to contain translation, rotation, scale and skew
+ */
+ virtual void applyTransformation(const PxMat44& transformation) = 0;
+
+ /**
+ \brief Set a maximum fracture depth for a given platform string
+
+ Returns true if the supplied maxDepth is lesser than the number of chunk depth levels for this asset
+ */
+ virtual bool setPlatformMaxDepth(PlatformTag platform, uint32_t maxDepth) = 0;
+
+ /**
+ \brief Removes the maximum fracture depth limit for a given platform string
+
+ Returns true if the platform's maximum fracture depth was previously set and now removed
+ */
+ virtual bool removePlatformMaxDepth(PlatformTag platform) = 0;
+
+ /**
+ \brief Returns the size of the actor transform array. See getActorTransforms() for a description of this data.
+ */
+ virtual uint32_t getActorTransformCount() const = 0;
+
+ /**
+ \brief Returns the head of the actor transform array. This list is a convenience for placing actors in a level from poses authored in a level editor.
+ The transforms may contain scaling.
+ */
+ virtual const PxMat44* getActorTransforms() const = 0;
+
+ /**
+ \brief Append transforms to the actor transform list. See getActorTransforms() for a description of this data.
+
+ \param transforms Head of an array of transforms
+ \param transformCount Size of transforms
+ */
+ virtual void appendActorTransforms(const PxMat44* transforms, uint32_t transformCount) = 0;
+
+ /**
+ \brief Clear the actor transform array. See getActorTransforms() for a description of this data.
+ */
+ virtual void clearActorTransforms() = 0;
+};
+
+/**
+ Destructible asset API. Destructible actors are instanced from destructible assets.
+*/
+class DestructibleAsset : public Asset
+{
+public:
+ /**
+ Enum of chunk flags
+ */
+ enum ChunkFlags
+ {
+ ChunkEnvironmentallySupported = (1 << 0),
+ ChunkAndDescendentsDoNotFracture = (1 << 1),
+ ChunkDoesNotFracture = (1 << 2),
+ ChunkDoesNotCrumble = (1 << 3),
+#if APEX_RUNTIME_FRACTURE
+ ChunkRuntimeFracture = (1 << 4),
+#endif
+ ChunkIsInstanced = (1 << 16)
+ };
+
+ /** Instancing */
+
+ /**
+ Instances the DestructibleAsset, creating an DestructibleActor, using the DestructibleActorDesc.
+ See DestructibleActor and DestructibleActorDesc. This asset will own the DestructibleActor,
+ so that any DestructibleActor created by it will be released when this asset is released.
+ You may also call the DestructibleActor's release() method at any time.
+ */
+ virtual void releaseDestructibleActor(DestructibleActor& actor) = 0;
+
+
+ /** General */
+
+ /**
+ Create a destructible actor representing the destructible asset in a scene.
+ Unlike a call to createApexActor, here the created actor takes explicit ownership of the provided actorParams.
+ This can represent either the destructible descriptor or previously serialized destructible state.
+ Note: The client should not attempt to use the provided actorParams after calling this method.
+ */
+ virtual DestructibleActor* createDestructibleActorFromDeserializedState(::NvParameterized::Interface* actorParams, Scene& apexScene) = 0;
+
+ /**
+ The DestructibleParameters which describe the default fracturing behavior for instanced
+ DestructibleActors.
+ */
+ virtual DestructibleParameters getDestructibleParameters() const = 0;
+
+ /**
+ The parameters used for default destructible initialization. See DestructibleInitParameters.
+ */
+ virtual DestructibleInitParameters getDestructibleInitParameters() const = 0;
+
+ /**
+ The name of the emitter to use when generating crumble particles.
+ Returns NULL if no emitter is configured.
+ */
+ virtual const char* getCrumbleEmitterName() const = 0;
+
+ /**
+ The name of the emitter to use when generating fracture-line dust particles.
+ Returns NULL if no emitter is configured.
+ */
+ virtual const char* getDustEmitterName() const = 0;
+
+ /**
+ The total number of chunks in the asset.
+ */
+ virtual uint32_t getChunkCount() const = 0;
+
+ /**
+ The total number of fracture hierarchy depth levels in the asset.
+ */
+ virtual uint32_t getDepthCount() const = 0;
+
+ /**
+ Gets the RenderMeshAsset associated with this asset.
+ */
+ virtual const RenderMeshAsset* getRenderMeshAsset() const = 0;
+
+ /**
+ Set the RenderMeshAsset associated with this asset.
+ This is the asset used for non-instanced rendering.
+ NULL is a valid argument, and can be used to clear the internal mesh data.
+ Returns true if successful.
+ */
+ virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0;
+
+ /** Retrieve the number of scatter mesh assets */
+ virtual uint32_t getScatterMeshAssetCount() const = 0;
+
+ /** Retrieve the scatter mesh asset array */
+ virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0;
+
+ /**
+ Get the number of instanced chunk meshes in this asset.
+ */
+ virtual uint32_t getInstancedChunkMeshCount() const = 0;
+
+ /**
+ Returns stats (sizes, counts) for the asset. See DestructibleAssetStats.
+ */
+ virtual void getStats(DestructibleAssetStats& stats) const = 0;
+
+ /**
+ Ensures that the asset has chunk overlap information cached up to the given depth.
+ If depth < 0 (as it is by default), the depth will be taken to be the supportDepth
+ given in the asset's destructibleParameters.
+ It is ok to pass in a depth greater than any chunk depth in the asset.
+ */
+ virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0;
+
+ /**
+ Clears the chunk overlap cache.
+ If depth < 0 (as it is by default), it clears the cache for each depth.
+
+ \param depth Depth to be cleared. -1 for all depths.
+ \param keepCachedFlag If the flag is set, the depth is considered to be cached even if the overlaps list is empty.
+ */
+ virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0;
+
+ /**
+ Adds edges to the support graph. Edges must connect chunks of equal depth.
+ The indices refer to the reordered chunk array, a mapping is provided in cookChunks.
+
+ \param supportGraphEdges Integer pairs representing indices to chunks that are linked
+ \param numSupportGraphEdges Number of provided integer pairs.
+ */
+ virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0;
+
+ /**
+ Removes edges from support graph.
+ The indices refer to the reordered chunk array, a mapping is provided in cookChunks.
+
+ \param supportGraphEdges Integer pairs representing indices to chunks that are linked
+ \param numSupportGraphEdges Number of provided integer pairs.
+ \param keepCachedFlagIfEmpty If the flag is set, the depth is considered to be cached even if the overlaps list is empty.
+ */
+ virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0;
+
+ /**
+ The size of the array returned by getCachedOverlapsAtDepth(depth) (see below).
+ Note: this function will not trigger overlap caching for the given depth.
+ */
+ virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) const = 0;
+
+ /**
+ Array of integer pairs, indexing chunk pairs which touch at a given depth in the hierarchy.
+ The size of the array is given by getCachedOverlapCountAtDepth(depth).
+ Note: this function will not trigger overlap caching for the given depth. If no overlaps
+ have been calculated for the depth given, this function returns NULL.
+ */
+ virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) const = 0;
+
+ /**
+ If this chunk is instanced within the same asset, then this provides the instancing position offset.
+ Otherwise, this function returns (0,0,0).
+ */
+ virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0;
+
+ /**
+ If this chunk is instanced within the same asset, then this provides the instancing UV offset.
+ Otherwise, this function returns (0,0).
+ */
+ virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0;
+
+ /**
+ Retrieve flags (see ChunkFlags) for the given chunk.
+ */
+ virtual uint32_t getChunkFlags(uint32_t chunkIndex) const = 0;
+
+ /**
+ Accessor to query the depth of a given chunk.
+ */
+ virtual uint16_t getChunkDepth(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the index of the given chunk's parent. If the chunk has no parent (is the root of the fracture hierarchy),
+ then -1 is returned.
+ */
+ virtual int32_t getChunkParentIndex(uint32_t chunkIndex) const = 0;
+
+ /**
+ Returns the chunk bounds in the asset (local) space.
+ */
+ virtual PxBounds3 getChunkActorLocalBounds(uint32_t chunkIndex) const = 0;
+
+ /**
+ The render mesh asset part index associated with this chunk.
+ */
+ virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0;
+
+ /**
+ The number of convex hulls associated with a given part.
+ */
+ virtual uint32_t getPartConvexHullCount(const uint32_t partIndex) const = 0;
+
+ /**
+ Returns the head of an array to convex hull NvParamterized::Interface* pointers for a given part.
+ */
+ virtual NvParameterized::Interface** getPartConvexHullArray(const uint32_t partIndex) const = 0;
+
+ /**
+ \brief Returns the size of the actor transform array. See getActorTransforms() for a description of this data.
+ */
+ virtual uint32_t getActorTransformCount() const = 0;
+
+ /**
+ \brief Returns the head of the actor transform array. This list is a convenience for placing actors in a level from poses authored in a level editor.
+ The transforms may contain scaling.
+ */
+ virtual const PxMat44* getActorTransforms() const = 0;
+
+ /**
+ \brief Apply a transformation to destructible asset
+
+ This is a permanent transformation and it changes the object state. Should only be called immediately before serialization
+ and without further modifying the object later on.
+
+ \param transformation This matrix is allowed to contain a translation and a rotation
+ \param scale Apply a uniform scaling as well
+ */
+ virtual void applyTransformation(const PxMat44& transformation, float scale) = 0;
+
+ /**
+ \brief Apply an arbitrary affine transformation to destructible asset
+
+ This is a permanent transformation and it changes the object state. Should only be called immediately before serialization
+ and without further modifying the object later on.
+
+ \param transformation This matrix is allowed to contain translation, rotation, scale and skew
+ */
+ virtual void applyTransformation(const PxMat44& transformation) = 0;
+
+ /**
+ Rebuild the collision volumes for the given chunk, using the geometryDesc (see DestructibleGeometryDesc).
+ Returns true iff successful.
+ */
+ virtual bool rebuildCollisionGeometry(uint32_t partIndex, const DestructibleGeometryDesc& geometryDesc) = 0;
+
+protected:
+ /** Hidden destructor. Use release(). */
+ virtual ~DestructibleAsset() {}
+};
+
+
+#if !PX_PS4
+ #pragma warning(pop)
+#endif //!PX_PS4
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_ASSET_H
diff --git a/APEX_1.4/include/destructible/DestructiblePreview.h b/APEX_1.4/include/destructible/DestructiblePreview.h
new file mode 100644
index 00000000..46830160
--- /dev/null
+++ b/APEX_1.4/include/destructible/DestructiblePreview.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008-2015, 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 DESTRUCTIBLE_PREVIEW_H
+#define DESTRUCTIBLE_PREVIEW_H
+
+#include "AssetPreview.h"
+#include "RenderMeshActor.h"
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+
+/**
+\brief Destructible module's derivation AssetPreview.
+*/
+
+class DestructiblePreview : public AssetPreview
+{
+public:
+
+ /**
+ \brief Returns render mesh actor
+ */
+ virtual const RenderMeshActor* getRenderMeshActor() const = 0;
+
+ /**
+ \brief Sets the preview chunk depth and "explode" amount (pushes the chunks out by that relative distance).
+ \param [in] depth Must be nonnegative. Internally the value will be clamped to the depth range in the asset.
+ \param [in] explode must be nonnegative.
+ */
+ virtual void setExplodeView(uint32_t depth, float explode) = 0;
+
+protected:
+ DestructiblePreview() {}
+};
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_PREVIEW_H
diff --git a/APEX_1.4/include/destructible/DestructibleRenderable.h b/APEX_1.4/include/destructible/DestructibleRenderable.h
new file mode 100644
index 00000000..fd76bc8b
--- /dev/null
+++ b/APEX_1.4/include/destructible/DestructibleRenderable.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008-2015, 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 DESTRUCTIBLE_RENDERABLE_H
+#define DESTRUCTIBLE_RENDERABLE_H
+
+#include "foundation/Px.h"
+#include "ApexInterface.h"
+#include "Renderable.h"
+#include "ModuleDestructible.h"
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+
+/**
+ Destructible renderable API. The destructible renderable contains rendering information for an DestructibleActor.
+*/
+class DestructibleRenderable : public ApexInterface, public Renderable
+{
+public:
+ /**
+ Get the render mesh actor for the specified mesh type.
+ */
+ virtual RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const = 0;
+
+protected:
+ virtual ~DestructibleRenderable() {}
+};
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_RENDERABLE_H
diff --git a/APEX_1.4/include/destructible/ExplicitHierarchicalMesh.h b/APEX_1.4/include/destructible/ExplicitHierarchicalMesh.h
new file mode 100644
index 00000000..5d74c51a
--- /dev/null
+++ b/APEX_1.4/include/destructible/ExplicitHierarchicalMesh.h
@@ -0,0 +1,1024 @@
+/*
+ * Copyright (c) 2008-2015, 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 EXPLICIT_HIERARCHICAL_MESH_H
+#define EXPLICIT_HIERARCHICAL_MESH_H
+
+#include "foundation/Px.h"
+#include "IProgressListener.h"
+#include "RenderMeshAsset.h"
+#include "ConvexHullMethod.h"
+#include "foundation/PxPlane.h"
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+/**
+ ExplicitVertexFormat
+
+ This is used when authoring an VertexBuffer, to define which data channels exist.
+ */
+struct ExplicitVertexFormat
+{
+ /** This value defines which vertex winding orders will be rendered. See RenderCullMode. */
+ uint32_t mWinding;
+
+ /** Whether or not the accompanying vertex data has defined static vertex positions. */
+ bool mHasStaticPositions;
+
+ /** Whether or not the accompanying vertex data has defined static vertex normals. */
+ bool mHasStaticNormals;
+
+ /** Whether or not the accompanying vertex data has defined static vertex tangents. */
+ bool mHasStaticTangents;
+
+ /** Whether or not the accompanying vertex data has defined static vertex binormals. */
+ bool mHasStaticBinormals;
+
+ /** Whether or not the accompanying vertex data has defined static vertex colors. */
+ bool mHasStaticColors;
+
+ /** Whether or not to create separate render resource for a static bone index buffer. */
+ bool mHasStaticSeparateBoneBuffer;
+
+ /** Whether or not the accompanying vertex data has defined dynamic displacement coordinates */
+ bool mHasStaticDisplacements;
+
+ /** Whether or not the accompanying vertex data has defined dynamic vertex positions. */
+ bool mHasDynamicPositions;
+
+ /** Whether or not the accompanying vertex data has defined dynamic vertex normals. */
+ bool mHasDynamicNormals;
+
+ /** Whether or not the accompanying vertex data has defined dynamic vertex tangents. */
+ bool mHasDynamicTangents;
+
+ /** Whether or not the accompanying vertex data has defined dynamic vertex binormals. */
+ bool mHasDynamicBinormals;
+
+ /** Whether or not the accompanying vertex data has defined dynamic vertex colors. */
+ bool mHasDynamicColors;
+
+ /** Whether or not to create separate render resource for a dynamic bone index buffer. */
+ bool mHasDynamicSeparateBoneBuffer;
+
+ /** Whether or not the accompanying vertex data has defined dynamic displacement coordinates */
+ bool mHasDynamicDisplacements;
+
+ /** How many UV coordinate channels there are (per vertex) */
+ uint32_t mUVCount;
+
+ /** How many bones may influence a vertex */
+ uint32_t mBonesPerVertex;
+
+ /** Constructor, calls clear() to set formats to default settings */
+ ExplicitVertexFormat()
+ {
+ clear();
+ }
+
+ /**
+ Set formats to default settings:
+
+ mWinding = RenderCullMode::CLOCKWISE;
+ mHasStaticPositions = false;
+ mHasStaticNormals = false;
+ mHasStaticTangents = false;
+ mHasStaticBinormals = false;
+ mHasStaticColors = false;
+ mHasStaticSeparateBoneBuffer = false;
+ mHasStaticDisplacements = false;
+ mHasDynamicPositions = false;
+ mHasDynamicNormals = false;
+ mHasDynamicTangents = false;
+ mHasDynamicBinormals = false;
+ mHasDynamicColors = false;
+ mHasDynamicSeparateBoneBuffer = false;
+ mHasDynamicDisplacements = false;
+ mUVCount = 0;
+ mBonesPerVertex = 0;
+ */
+ void clear()
+ {
+ mWinding = RenderCullMode::CLOCKWISE;
+ mHasStaticPositions = false;
+ mHasStaticNormals = false;
+ mHasStaticTangents = false;
+ mHasStaticBinormals = false;
+ mHasStaticColors = false;
+ mHasStaticSeparateBoneBuffer = false;
+ mHasStaticDisplacements = false;
+ mHasDynamicPositions = false;
+ mHasDynamicNormals = false;
+ mHasDynamicTangents = false;
+ mHasDynamicBinormals = false;
+ mHasDynamicColors = false;
+ mHasDynamicSeparateBoneBuffer = false;
+ mHasDynamicDisplacements = false;
+ mUVCount = 0;
+ mBonesPerVertex = 0;
+ }
+
+ /**
+ Equality operator. All values are tested for equality except mBonesPerVertex.
+ */
+ bool operator == (const ExplicitVertexFormat& data) const
+ {
+ if (mWinding != data.mWinding)
+ {
+ return false;
+ }
+ if (mHasStaticPositions != data.mHasStaticPositions ||
+ mHasStaticNormals != data.mHasStaticNormals ||
+ mHasStaticTangents != data.mHasStaticTangents ||
+ mHasStaticBinormals != data.mHasStaticBinormals ||
+ mHasStaticColors != data.mHasStaticColors ||
+ mHasStaticSeparateBoneBuffer != data.mHasStaticSeparateBoneBuffer ||
+ mHasStaticDisplacements != data.mHasStaticDisplacements)
+ {
+ return false;
+ }
+ if (mHasDynamicPositions != data.mHasDynamicPositions ||
+ mHasDynamicNormals != data.mHasDynamicNormals ||
+ mHasDynamicTangents != data.mHasDynamicTangents ||
+ mHasDynamicBinormals != data.mHasDynamicBinormals ||
+ mHasDynamicColors != data.mHasDynamicColors ||
+ mHasDynamicSeparateBoneBuffer != data.mHasDynamicSeparateBoneBuffer ||
+ mHasDynamicDisplacements != data.mHasDynamicDisplacements)
+ {
+ return false;
+ }
+ if (mUVCount != data.mUVCount)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Returns the logical complement of the == operator.
+ */
+ bool operator != (const ExplicitVertexFormat& data) const
+ {
+ return !(*this == data);
+ }
+
+ /**
+ Creates a render-ready VertexFormat corresponding to this structure's member values.
+ */
+ void copyToVertexFormat(VertexFormat* format) const
+ {
+ format->reset();
+ uint32_t bi;
+ if (mHasStaticPositions)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::POSITION));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ format->setBufferAccess(bi, mHasDynamicPositions ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ }
+ if (mHasStaticNormals)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::NORMAL));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ format->setBufferAccess(bi, mHasDynamicNormals ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ }
+ if (mHasStaticTangents)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::TANGENT));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ format->setBufferAccess(bi, mHasDynamicTangents ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ }
+ if (mHasStaticBinormals)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BINORMAL));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ format->setBufferAccess(bi, mHasDynamicBinormals ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ }
+ if (mHasStaticDisplacements)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::DISPLACEMENT_TEXCOORD));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ format->setBufferAccess(bi, mHasDynamicDisplacements ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::DISPLACEMENT_FLAGS));
+ format->setBufferFormat(bi, RenderDataFormat::UINT1);
+ format->setBufferAccess(bi, mHasDynamicDisplacements ? RenderDataAccess::DYNAMIC : RenderDataAccess::STATIC);
+ }
+ if (mUVCount > 0)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::TEXCOORD0));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT2);
+ }
+ if (mUVCount > 1)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::TEXCOORD1));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT2);
+ }
+ if (mUVCount > 2)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::TEXCOORD2));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT2);
+ }
+ if (mUVCount > 3)
+ {
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::TEXCOORD3));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT2);
+ }
+ switch (mBonesPerVertex)
+ {
+ case 1:
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_INDEX));
+ format->setBufferFormat(bi, RenderDataFormat::USHORT1);
+ break;
+ case 2:
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_INDEX));
+ format->setBufferFormat(bi, RenderDataFormat::USHORT2);
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_WEIGHT));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT2);
+ break;
+ case 3:
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_INDEX));
+ format->setBufferFormat(bi, RenderDataFormat::USHORT3);
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_WEIGHT));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT3);
+ break;
+ case 4:
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_INDEX));
+ format->setBufferFormat(bi, RenderDataFormat::USHORT4);
+ bi = (uint32_t)format->addBuffer(format->getSemanticName(RenderVertexSemantic::BONE_WEIGHT));
+ format->setBufferFormat(bi, RenderDataFormat::FLOAT4);
+ break;
+ }
+
+ format->setHasSeparateBoneBuffer(mHasStaticSeparateBoneBuffer);
+ format->setWinding((RenderCullMode::Enum)mWinding);
+ }
+};
+
+
+/**
+ ExplicitSubmeshData
+
+ This is used when authoring an RenderMeshAsset.
+
+ This is the per-submesh data: the material name, and vertex format.
+ */
+struct ExplicitSubmeshData
+{
+ /**
+ Enum for storing material name buffer size
+ */
+ enum
+ {
+ MaterialNameBufferSize = 1024
+ };
+
+ /**
+ Material name char buffer
+ */
+ char mMaterialName[MaterialNameBufferSize];
+
+ /**
+ Explicit vertex format
+ \see ExplicitVertexFormat
+ */
+ ExplicitVertexFormat mVertexFormat;
+
+ /**
+ Equal operator for ExplicitSubmeshData
+ */
+ bool operator == (const ExplicitSubmeshData& data) const
+ {
+ return !::strcmp(mMaterialName, data.mMaterialName) && mVertexFormat == data.mVertexFormat;
+ }
+
+ /**
+ Not equal operator for ExplicitSubmeshData
+ */
+ bool operator != (const ExplicitSubmeshData& data) const
+ {
+ return !(*this == data);
+ }
+};
+
+
+/**
+ Collision volume descriptor for a chunk
+*/
+struct CollisionVolumeDesc
+{
+ CollisionVolumeDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set CollisionVolumeDesc to default values
+ */
+ void setToDefault()
+ {
+ mHullMethod = ConvexHullMethod::CONVEX_DECOMPOSITION;
+ mConcavityPercent = 4.0f;
+ mMergeThreshold = 4.0f;
+ mRecursionDepth = 0;
+ mMaxVertexCount = 0;
+ mMaxEdgeCount = 0;
+ mMaxFaceCount = 0;
+ }
+
+ /**
+ How to generate convex hulls for a chunk. See ConvexHullMethod::Enum.
+ Default = CONVEX_DECOMPOSITION.
+ */
+ ConvexHullMethod::Enum mHullMethod;
+
+ /**
+ Allowed concavity if mHullMethod = ConvexHullMethod::CONVEX_DECOMPOSITION.
+ Default = 4.0.
+ */
+ float mConcavityPercent;
+
+ /**
+ Merge threshold if mHullMethod = ConvexHullMethod::CONVEX_DECOMPOSITION.
+ Default = 4.0.
+ */
+ float mMergeThreshold;
+
+ /**
+ Recursion depth if mHullMethod = ConvexHullMethod::CONVEX_DECOMPOSITION.
+ Depth = 0 generates a single convex hull. Higher recursion depths may generate
+ more convex hulls to fit the mesh.
+ Default = 0.
+ */
+ uint32_t mRecursionDepth;
+
+ /**
+ The maximum number of vertices each hull may have. If 0, there is no limit.
+ Default = 0.
+ */
+ uint32_t mMaxVertexCount;
+
+ /**
+ The maximum number of edges each hull may have. If 0, there is no limit.
+ Default = 0.
+ */
+ uint32_t mMaxEdgeCount;
+
+ /**
+ The maximum number of faces each hull may have. If 0, there is no limit.
+ Default = 0.
+ */
+ uint32_t mMaxFaceCount;
+};
+
+
+/**
+ Collision descriptor
+*/
+struct CollisionDesc
+{
+ /**
+ How many collision volume descriptors are in the mVolumeDescs array.
+
+ This count need not match the depth count of the destructible to be created. If it is greater than the depth count of the destructible,
+ the extra volume descriptors will be ignored. If it is less than the depth count of the destructible, then mVolumeDescs[depthCount-1] will
+ be used unless depthCount is zero. In that case, the defeult CollisionVolumeDesc() will be used.
+
+ This may be zero, in which case all volume descriptors will be the default values. If it is not zero, mVolumeDescs must be a valid pointer.
+ */
+ unsigned mDepthCount;
+
+ /**
+ Array of volume descriptors of length depthCount (may be NULL if depthCount is zero).
+ */
+ CollisionVolumeDesc* mVolumeDescs;
+
+ /**
+ The maximum amount to trim overlapping collision hulls (as a percentage of the hulls' widths)
+
+ Default = 0.2f
+ */
+ float mMaximumTrimming;
+
+ /** Constructor sets default values. */
+ CollisionDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set CollisionDesc to default values
+ */
+ void setToDefault()
+ {
+ mDepthCount = 0;
+ mVolumeDescs = NULL;
+ mMaximumTrimming = 0.2f;
+ }
+};
+
+
+/**
+ Enumeration of current fracture methods. Used when an authored mesh needs to know how it was created, for
+ example if we need to re-apply UV mapping information.
+*/
+struct FractureMethod
+{
+ /**
+ Enum of fracture methods
+ */
+ enum Enum
+ {
+ Unknown,
+ Slice,
+ Cutout,
+ Voronoi,
+
+ FractureMethodCount
+ };
+};
+
+
+/**
+ FractureMaterialDesc
+
+ Descriptor for materials applied to interior faces.
+*/
+struct FractureMaterialDesc
+{
+ /** The UV scale (geometric distance/unit texture distance) for interior materials.
+ Default = (1.0f,1.0f).
+ */
+ PxVec2 uvScale;
+
+ /** A UV origin offset for interior materials.
+ Default = (0.0f,0.0f).
+ */
+ PxVec2 uvOffset;
+
+ /** World space vector specifying surface tangent direction. If this vector
+ is (0.0f,0.0f,0.0f), then an arbitrary direction will be chosen.
+ Default = (0.0f,0.0f,0.0f).
+ */
+ PxVec3 tangent;
+
+ /** Angle from tangent direction for the u coordinate axis.
+ Default = 0.0f.
+ */
+ float uAngle;
+
+ /**
+ The submesh index to use for the newly-created triangles.
+ If an invalid index is given, 0 will be used.
+ */
+ uint32_t interiorSubmeshIndex;
+
+ /** Constructor sets defaults */
+ FractureMaterialDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set default values:
+ uvScale = PxVec2(1.0f);
+ uvOffset = PxVec2(0.0f);
+ tangent = PxVec3(0.0f);
+ uAngle = 0.0f;
+ interiorSubmeshIndex = 0;
+ */
+ void setToDefault()
+ {
+ uvScale = PxVec2(1.0f);
+ uvOffset = PxVec2(0.0f);
+ tangent = PxVec3(0.0f);
+ uAngle = 0.0f;
+ interiorSubmeshIndex = 0;
+ }
+};
+
+
+/**
+ A reference frame for applying UV mapping to triangles. Also includes the fracturing method and an index
+ which is used internally for such operations as re-applying UV mapping information.
+*/
+struct MaterialFrame
+{
+ MaterialFrame() :
+ mCoordinateSystem(PxVec4(1.0f)),
+ mUVPlane(PxVec3(0.0f, 0.0f, 1.0f), 0.0f),
+ mUVScale(1.0f),
+ mUVOffset(0.0f),
+ mFractureMethod(FractureMethod::Unknown),
+ mFractureIndex(-1),
+ mSliceDepth(0)
+ {
+ }
+
+ /**
+ Builds coordinate system from material desc
+ */
+ void buildCoordinateSystemFromMaterialDesc(const nvidia::FractureMaterialDesc& materialDesc, const PxPlane& plane)
+ {
+ PxVec3 zAxis = plane.n;
+ zAxis.normalize();
+ PxVec3 xAxis = materialDesc.tangent;
+ PxVec3 yAxis = zAxis.cross(xAxis);
+ const float l2 = yAxis.magnitudeSquared();
+ if (l2 > PX_EPS_F32*PX_EPS_F32)
+ {
+ yAxis *= PxRecipSqrt(l2);
+ }
+ else
+ {
+ uint32_t maxDir = PxAbs(plane.n.x) > PxAbs(plane.n.y) ?
+ (PxAbs(plane.n.x) > PxAbs(plane.n.z) ? 0u : 2u) :
+ (PxAbs(plane.n.y) > PxAbs(plane.n.z) ? 1u : 2u);
+ xAxis = PxMat33(PxIdentity)[(maxDir + 1) % 3];
+ yAxis = zAxis.cross(xAxis);
+ yAxis.normalize();
+ }
+ xAxis = yAxis.cross(zAxis);
+
+ const float c = PxCos(materialDesc.uAngle);
+ const float s = PxSin(materialDesc.uAngle);
+
+ mCoordinateSystem.column0 = PxVec4(c*xAxis + s*yAxis, 0.0f);
+ mCoordinateSystem.column1 = PxVec4(c*yAxis - s*xAxis, 0.0f);
+ mCoordinateSystem.column2 = PxVec4(zAxis, 0.0f);
+ mCoordinateSystem.setPosition(plane.project(PxVec3(0.0f)));
+
+ mUVPlane = plane;
+ mUVScale = materialDesc.uvScale;
+ mUVOffset = materialDesc.uvOffset;
+ }
+
+ PxMat44 mCoordinateSystem; ///< Coordinate system
+ PxPlane mUVPlane; ///< UV plane
+ PxVec2 mUVScale; ///< UV scale
+ PxVec2 mUVOffset; ///< UV offset
+ uint32_t mFractureMethod; ///< Fracture method
+ int32_t mFractureIndex; ///< Fracture index
+ uint32_t mSliceDepth; ///< The depth being created when this split is done. mSliceDepth = 0 means "unknown"
+};
+
+
+/**
+ Interface to a "displacement map volume," used with tessellated fracturing.
+ A displacement map volume captures how to displace a particular point in 3D space
+ along the x, y and z axes. The data is stored as a 3D texture volume, with
+ corresponding displacement coordinates acting as a look-up into this volume.
+ X, Y and Z offsets correspond to R, G, and B color channels
+
+ Various approaches can be used to generate the 3D noise field, in this case
+ Perlin noise is used, with appropriate settings specified by the FractureSliceDesc.
+*/
+class DisplacementMapVolume
+{
+public:
+ /**
+ Fills the specified array and parameters with texture-compatible information.
+
+ The corresponding texture aligns with the displacement UVs generated as fracturing occurs
+ when displacement maps are enabled, with RGB data corresponding to XYZ offsets, respectively.
+ */
+ virtual void getData(uint32_t& width, uint32_t& height, uint32_t& depth, uint32_t& size, unsigned char const** ppData) const = 0;
+
+ virtual ~DisplacementMapVolume() { }
+};
+
+
+/**
+ Handling of open meshes.
+
+ BSPMode::Automatic causes the mesh to be analyzed to determine if it's open or closed
+ BSPOpenMode::Closed means the mesh should be closed and interior faces are created when the mesh is split
+ BSPOpenMode::Open means the mesh should be open and no interior faces are created when it is split
+*/
+struct BSPOpenMode
+{
+ /**
+ Enum of BSP open modes
+ */
+ enum Enum
+ {
+ Automatic,
+ Closed,
+ Open,
+
+ BSPOpenModeCount
+ };
+};
+
+
+/**
+ ExplicitHierarchicalMesh
+
+ An interface to a representation of a render mesh that is used for authoring.
+
+ The "hierarchical" nature of this mesh is represented by extra parent/child relations
+ among the parts that will become the parts of an RenderMeshAsset.
+ */
+class ExplicitHierarchicalMesh
+{
+public:
+ /** Used in the visualize method to determine what to draw. */
+ enum Enum
+ {
+ /**
+ Draws the convex hulls associated with the BSP regions marked "outside," if a BSP has
+ been created for this object (see calculateMeshBSP()).
+ */
+ VisualizeMeshBSPOutsideRegions = (1 << 0),
+
+ /**
+ Draws the convex hulls associated with the BSP regions marked "inside," if a BSP has
+ been created for this object (see calculateMeshBSP()).
+ */
+ VisualizeMeshBSPInsideRegions = (1 << 1),
+
+ /**
+ Draws the convex hull associated with a single BSP regions, if a BSP has
+ been created for this object (see calculateMeshBSP()). The region index must
+ be passed into the visualize function if this flag is set.
+ */
+ VisualizeMeshBSPSingleRegion = (1 << 8),
+
+ /** Currently unused */
+ VisualizeSliceBSPOutsideRegions = (1 << 16),
+
+ /** Currently unused */
+ VisualizeSliceBSPInsideRegions = (1 << 17),
+
+ /** Currently unused */
+ VisualizeSliceBSPSingleRegion = (1 << 24),
+
+ VisualizeMeshBSPAllRegions = VisualizeMeshBSPOutsideRegions | VisualizeMeshBSPInsideRegions
+ };
+
+ /**
+ Used in the serialize and deserialize methods, to embed extra data.
+ The user must implement this class to serialize and deserialize
+ the enumerated data type given.
+ */
+ class Embedding
+ {
+ public:
+ /**
+ Enum of data types
+ */
+ enum DataType
+ {
+ MaterialLibrary
+ };
+
+ /**
+ Serialize the enumerated data type
+ */
+ virtual void serialize(PxFileBuf& stream, Embedding::DataType type) const = 0;
+
+ /**
+ Deserialize the enumerated data type
+ */
+ virtual void deserialize(PxFileBuf& stream, Embedding::DataType type, uint32_t version) = 0;
+ };
+
+ /**
+ Used to access the collision data for each mesh part
+ */
+ class ConvexHull
+ {
+ protected:
+ ConvexHull()
+ {
+ }
+
+ virtual ~ConvexHull()
+ {
+ }
+
+ public:
+ /**
+ Builds the convex hull of the points given.
+ */
+ virtual void buildFromPoints(const void* points, uint32_t numPoints, uint32_t pointStrideBytes) = 0;
+
+ /**
+ The hull's axis aligned bounding box.
+ */
+ virtual const PxBounds3& getBounds() const = 0;
+
+ /**
+ The hull's volume.
+ */
+ virtual float getVolume() const = 0;
+
+ /**
+ This is the number of vertices in the convex hull.
+ */
+ virtual uint32_t getVertexCount() const = 0;
+
+ /**
+ This is the vertex indexed by vertexIndex, which must in
+ the range [0, getVertexCount()-1].
+ */
+ virtual PxVec3 getVertex(uint32_t vertexIndex) const = 0;
+
+ /**
+ This is the number of edges in the convex hull.
+ */
+ virtual uint32_t getEdgeCount() const = 0;
+
+ /**
+ This is an edge endpoint indexed by edgeIndex, which must in
+ the range [0, getEdgeCount()-1], and
+ whichEndpoint, which must be 0 or 1.
+ */
+ virtual PxVec3 getEdgeEndpoint(uint32_t edgeIndex, uint32_t whichEndpoint) const = 0;
+
+ /**
+ This is the number of planes which bound the convex hull.
+ */
+ virtual uint32_t getPlaneCount() const = 0;
+
+ /**
+ This is the plane indexed by planeIndex, which must in
+ the range [0, getPlaneCount()-1].
+ */
+ virtual PxPlane getPlane(uint32_t planeIndex) const = 0;
+
+ /**
+ Perform a ray cast against the convex hull.
+
+ \param in this MUST be set to the minimum 'time' that you wish to have reported for intersection.
+ you may consider this an origin offset for the ray.
+ On exit, if the hull is intersected, this value will contain the time of intersection,
+ or its original value, which ever is larger.
+
+ \param out this MUST be set to the maximum 'time' that you wish to have reported for intersection.
+ you may consider this the endpoint of a line segment intersection.
+ On exit, if the hull is intersected, this value will contain the time that the ray
+ exits the hull, or its original value, which ever is smaller.
+
+ \param orig describe the ray to intersect with the convex hull.
+ \param dir describe the ray to intersect with the convex hull.
+
+ \param localToWorldRT the rotation applied to the convex hull.
+
+ \param scale the scale applied to the convex hull.
+
+ \param normal if not NULL, *normal will contain the surface normal of the convex hull at the
+ point of intersection (at the 'in' time). If the point on the ray at the 'in' time lies
+ within the volume of the convex hull, then *normal will be set to (0,0,0).
+
+ \return returns true if the line segment described by the user's supplied 'in' and 'out'
+ parameters along the ray intersects the convex hull, false otherwise.
+ */
+ virtual bool rayCast(float& in, float& out, const PxVec3& orig, const PxVec3& dir,
+ const PxTransform& localToWorldRT, const PxVec3& scale, PxVec3* normal = NULL) const = 0;
+ /**
+ Removes vertices from the hull until the bounds given in the function's parameters are met.
+ If inflated = true, then the maximum counts given are compared with the cooked hull, which may have higher counts due to beveling.
+
+ \note a value of zero indicates no limit, effectively infinite.
+
+ \return true if successful, i.e. the limits were met. False otherwise.
+ */
+ virtual bool reduceHull(uint32_t maxVertexCount, uint32_t maxEdgeCount, uint32_t maxFaceCount, bool inflated) = 0;
+
+ /**
+ Releases all memory associated with this object and deletes itself.
+ */
+ virtual void release() = 0;
+ };
+
+ /**
+ "Resets" this object to its initial state, freeing all internal data.
+ If keepRoot is true, then parts up to the root depth will not be cleared.
+ (In this case, not all of the submesh data, etc. will be deleted.)
+ The root depth is set when the ExplicitHierarchicalMesh is first created.
+ Fracturing methods create pieces beyond the root depth.
+ */
+ virtual void clear(bool keepRoot = false) = 0;
+
+ /**
+ The maximum child depth in the hierarchy. Depth 0 is the base, depth 1 parts are children of depth 0, etc.
+ If there are no parts, this function returns -1.
+ */
+ virtual int32_t maxDepth() const = 0;
+
+ /**
+ The number of parts in this mesh.
+ */
+ virtual uint32_t partCount() const = 0;
+
+ /**
+ The number of chunks in this mesh.
+ */
+ virtual uint32_t chunkCount() const = 0;
+
+ /**
+ The parent index of the chunk indexed by chunkIndex.
+ Depth 0 parts have no parents, and for those parts this function returns -1.
+ */
+ virtual int32_t* parentIndex(uint32_t chunkIndex) = 0;
+
+ /**
+ A runtime unique identifier for a chunk. During one execution of an application which
+ contains the fracture tools, this chunk ID will be unique for the chunk.
+ */
+ virtual uint64_t chunkUniqueID(uint32_t chunkIndex) = 0;
+
+ /**
+ The geometric part index this chunk references
+ */
+ virtual int32_t* partIndex(uint32_t chunkIndex) = 0;
+
+ /**
+ If instanced, the part instance offset (translation).
+ */
+ virtual PxVec3* instancedPositionOffset(uint32_t chunkIndex) = 0;
+
+ /**
+ If instanced, the part instance offset (UV).
+ */
+ virtual PxVec2* instancedUVOffset(uint32_t chunkIndex) = 0;
+
+ /**
+ The number of triangles in the part indexed by partIndex.
+ This includes all submeshes.
+ */
+ virtual uint32_t meshTriangleCount(uint32_t partIndex) const = 0;
+
+ /**
+ A pointer into the array of ExplicitRenderTriangles which form the mesh
+ of the part indexed by partIndex.
+ */
+ virtual ExplicitRenderTriangle* meshTriangles(uint32_t partIndex) = 0;
+
+ /**
+ The axis aligned bounding box of the triangles for the part index by partIndex.
+ */
+ virtual PxBounds3 meshBounds(uint32_t partIndex) const = 0;
+
+ /**
+ The axis aligned bounding box of the triangles for the chunk index by chunkIndex.
+ */
+ virtual PxBounds3 chunkBounds(uint32_t chunkIndex) const = 0;
+
+ /**
+ Flags describing attributes of the part indexed by partIndex.
+ See DestructibleAsset::ChunkFlags
+ */
+ virtual uint32_t* chunkFlags(uint32_t chunkIndex) const = 0;
+
+ /**
+ Build collision volumes for the part indexed by partIndex, using (See CollisionVolumeDesc.)
+ */
+ virtual void buildCollisionGeometryForPart(uint32_t partIndex, const CollisionVolumeDesc& desc) = 0;
+
+ /**
+ Build collision volumes for all parts referenced by chunks at the root depth.
+
+ If aggregateRootChunkParentCollision, then every chunk which is the parent of root chunks
+ gets all of the collision hulls of its children. Otherwise, all root chunks have their
+ collision volumes separately calculated.
+ */
+ virtual void buildCollisionGeometryForRootChunkParts(const CollisionDesc& desc, bool aggregateRootChunkParentCollision = true) = 0;
+
+ /**
+ Calls IConvexMesh::reduceHull on all part convex hulls. See IConvexMesh::reduceHull.
+ */
+ virtual void reduceHulls(const CollisionDesc& desc, bool inflated) = 0;
+
+ /**
+ The number of convex hulls for the given part.
+ */
+ virtual uint32_t convexHullCount(uint32_t partIndex) const = 0;
+
+ /**
+ The convex hulls for the given part.
+ */
+ virtual const ConvexHull** convexHulls(uint32_t partIndex) const = 0;
+
+ /**
+ The outward surface normal associated with the chunk mesh geometry.
+ */
+ virtual PxVec3* surfaceNormal(uint32_t partIndex) = 0;
+
+ /**
+ The displacement map volume for the mesh.
+ */
+ virtual const DisplacementMapVolume& displacementMapVolume() const = 0;
+
+ /**
+ The number of submeshes. The explicit mesh representation is just a list
+ of ExplicitRenderTriangles for each part, and each ExplicitRenderTriangle has
+ a submesh index. These indices will lie in a contiguous range from 0 to submeshCount()-1.
+ */
+ virtual uint32_t submeshCount() const = 0;
+
+ /**
+ The submeshData indexed by submeshIndex. See ExplicitSubmeshData.
+ */
+ virtual ExplicitSubmeshData* submeshData(uint32_t submeshIndex) = 0;
+
+ /**
+ Creates a submesh and adds it to the list of submeshes, and returns the index of
+ the newly created submesh.
+ */
+ virtual uint32_t addSubmesh(const ExplicitSubmeshData& submeshData) = 0;
+
+ /**
+ If there are interior submeshes, then triangles belonging
+ to those submesh will have materials applied to them with a using a coordinate frame.
+ In the event that materials need to be re-applied (possibly at a different scale), it
+ is convenient to store the material frames used. This function returns the array of
+ material frames. The index extraDataIndex stored in each ExplicitRenderTriangle
+ references this array.
+ */
+ virtual uint32_t getMaterialFrameCount() const = 0;
+ virtual nvidia::MaterialFrame getMaterialFrame(uint32_t index) const = 0; ///< \see ConvexHull::getMaterialFrameCount
+ virtual void setMaterialFrame(uint32_t index, const nvidia::MaterialFrame& materialFrame) = 0; ///< \see ConvexHull::getMaterialFrameCount
+ virtual uint32_t addMaterialFrame() = 0; ///< \see ConvexHull::getMaterialFrameCount
+
+ /**
+ Serialization. The user must instantiate Embedding in order to successfully
+ serialize any embedded data.
+ */
+ virtual void serialize(PxFileBuf& stream, Embedding& embedding) const = 0;
+
+ /**
+ Serialization. The user must instantiate Embedding in order to successfully
+ serialize any embedded data.
+ */
+ virtual void deserialize(PxFileBuf& stream, Embedding& embedding) = 0;
+
+ /**
+ Copies the input mesh in to this object.
+ */
+ virtual void set(const ExplicitHierarchicalMesh& mesh) = 0;
+
+ /**
+ Creates an internal BSP representation of the mesh parts up to the root depth.
+ This is used by authoring tools to perform CSG operations. If the user instantiates
+ IProgressListener, they may pass it in to report progress of this operation.
+ If microgridSize is not NULL, *microgridSize is used in the BSP calculation. Otherwise the
+ default parameters are used.
+ meshMode is used to determine if the mesh is open or closed. See NxMeshProcessingParameters::MeshMode
+ */
+ virtual void calculateMeshBSP(uint32_t randomSeed, IProgressListener* progressListener = NULL, const uint32_t* microgridSize = NULL, BSPOpenMode::Enum meshMode = BSPOpenMode::Automatic) = 0;
+
+ /**
+ Utility to replace the submesh on a set of interior triangles.
+ */
+ virtual void replaceInteriorSubmeshes(uint32_t partIndex, uint32_t frameCount, uint32_t* frameIndices, uint32_t submeshIndex) = 0;
+
+ /**
+ Draws various components of this object to the debugRenderer, as
+ defined by the flags (see the visualization Enum above). Some
+ of the flags require an index be passed in as well.
+ */
+ virtual void visualize(RenderDebugInterface& debugRender, uint32_t flags, uint32_t index = 0) const = 0;
+
+ /**
+ Releases all memory associated with this object and deletes itself.
+ */
+ virtual void release() = 0;
+
+protected:
+ /**
+ Constructor and destructor are not public
+ Use createExplicitHierarchicalMesh() to instantiate an ExplicitHierarchicalMesh and
+ ExplicitHierarchicalMesh::release() to destroy it.
+ */
+ ExplicitHierarchicalMesh() {}
+ virtual ~ExplicitHierarchicalMesh() {}
+
+private:
+ /** The assignment operator is disabled, use set() instead. */
+ ExplicitHierarchicalMesh& operator = (const ExplicitHierarchicalMesh&)
+ {
+ return *this;
+ }
+};
+
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+
+#endif // EXPLICIT_HIERARCHICAL_MESH_H
diff --git a/APEX_1.4/include/destructible/FractureToolsAPI.h b/APEX_1.4/include/destructible/FractureToolsAPI.h
new file mode 100644
index 00000000..49f01be2
--- /dev/null
+++ b/APEX_1.4/include/destructible/FractureToolsAPI.h
@@ -0,0 +1,453 @@
+/*
+ * Copyright (c) 2008-2015, 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 FRACTURE_TOOLS_API_H
+#define FRACTURE_TOOLS_API_H
+
+#include "foundation/Px.h"
+#include "ExplicitHierarchicalMesh.h"
+#include "FractureToolsStructs.h"
+
+PX_PUSH_PACK_DEFAULT
+
+namespace nvidia
+{
+namespace apex
+{
+
+struct IntersectMesh;
+class DestructibleAsset;
+
+/** Fracture tools API */
+class FractureToolsAPI
+{
+public:
+
+ /** Instantiates a blank CutoutSet */
+ virtual FractureTools::CutoutSet* createCutoutSet() = 0;
+
+ /**
+ Builds a cutout set (which must have been initially created by createCutoutSet()).
+ Uses a bitmap described by pixelBuffer, bufferWidth, and bufferHeight. Each pixel is represented
+ by one byte in the buffer.
+
+ \param cutoutSet the CutoutSet to build
+ \param pixelBuffer pointer to be beginning of the pixel buffer
+ \param bufferWidth the width of the buffer in pixels
+ \param bufferHeight the height of the buffer in pixels
+ \param snapThreshold the pixel distance at which neighboring cutout vertices and segments may be fudged into alignment.
+ \param periodic whether or not to use periodic boundary conditions when creating cutouts from the map
+ */
+ virtual void buildCutoutSet(FractureTools::CutoutSet& cutoutSet, const uint8_t* pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight, float snapThreshold, bool periodic) = 0;
+
+ /**
+ Calculate the mapping between a cutout fracture map and a given triangle.
+ The result is a 3 by 3 matrix M composed by an affine transformation and a rotation, we can get the 3-D projection for a texture coordinate pair (u,v) with such a formula:
+ (x,y,z) = M*PxVec3(u,v,1)
+
+ \param triangle the target face's normal
+ \param theMapping resulted mapping, composed by an affine transformation and a rotation
+ */
+ virtual bool calculateCutoutUVMapping(const nvidia::ExplicitRenderTriangle& triangle, PxMat33& theMapping) = 0;
+
+ /**
+ Uses the passed-in target direction to find the best triangle in the root mesh with normal near the given targetDirection. If triangles exist
+ with normals within one degree of the given target direction, then one with the greatest area of such triangles is used. Otherwise, the triangle
+ with normal closest to the given target direction is used. The resulting triangle is used to calculate a UV mapping as in the function
+ calculateCutoutUVMapping (above).
+
+ The assumption is that there exists a single mapping for all triangles on a specified face, for this feature to be useful.
+
+ \param hMesh the explicit mesh with well rectangle-shaped faces
+ \param targetDirection the target face's normal
+ \param theMapping resulted mapping, composed by an affine transformation and a rotation
+ */
+ virtual bool calculateCutoutUVMapping(nvidia::ExplicitHierarchicalMesh& hMesh, const PxVec3& targetDirection, PxMat33& theMapping) = 0;
+
+ /**
+ Splits the mesh in chunk[0], forming fractured pieces chunks[1...] using
+ Voronoi decomposition fracturing.
+
+ \param hMesh the mesh to split
+ \param iHMeshCore if this mesh is not empty, chunk 0 will be used as an indestructible "core" of the fractured
+ mesh. That is, it will be subtracted from hMesh, and placed at level 1 of the hierarchy. The remainder
+ of hMesh will be split as usual, creating chunks at level 1 (and possibly deeper).
+ \param exportCoreMesh if true, a core mesh chunk will be created from iHMeshCore
+ \param coreMeshImprintSubmeshIndex if this is < 0, use the core mesh materials (was applyCoreMeshMaterialToNeighborChunks). Otherwise, use the given submesh
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the voronoi splitting parameters surfaces (see FractureVoronoiDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity.
+ Meant to be set from another thread.
+
+ \return true if successful.
+ */
+ virtual bool createVoronoiSplitMesh
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ nvidia::ExplicitHierarchicalMesh& iHMeshCore,
+ bool exportCoreMesh,
+ int32_t coreMeshImprintSubmeshIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureVoronoiDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t randomSeed,
+ nvidia::IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Generates a set of uniformly distributed points in the interior of the root mesh.
+
+ \param hMesh the mesh in which to distribute sites
+ \param siteBuffer an array of PxVec3, at least the size of siteCount
+ \param siteChunkIndices if not NULL, then must be at least the size of siteCount. siteCount indices will be written to this buffer, associating each site with a chunk that contains it.
+ \param siteCount the number of points to write into siteBuffer
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param microgridSize pointer to a grid size used for BSP creation. If NULL, the default settings will be used.
+ \param meshMode Open mesh handling. Modes: Automatic, Closed, Open (see BSPOpenMode)
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param chunkIndex If this is a valid index, the voronoi sites will only be created within the volume of the indexed chunk. Otherwise,
+ the sites will be created within each of the root-level chunks. Default value is an invalid index.
+
+ \return returns the number of sites actually created (written to siteBuffer and siteChunkIndices). This may be less than the number of sites requested if site placement fails.
+ */
+ virtual uint32_t createVoronoiSitesInsideMesh
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ PxVec3* siteBuffer,
+ uint32_t* siteChunkIndices,
+ uint32_t siteCount,
+ uint32_t* randomSeed,
+ uint32_t* microgridSize,
+ BSPOpenMode::Enum meshMode,
+ nvidia::IProgressListener& progressListener,
+ uint32_t chunkIndex = 0xFFFFFFFF
+ ) = 0;
+
+ /**
+ Creates scatter mesh sites randomly distributed on the mesh.
+
+ \param meshIndices user-allocated array of size scatterMeshInstancesBufferSize which will be filled in by this function, giving the scatter mesh index used
+ \param relativeTransforms user-allocated array of size scatterMeshInstancesBufferSize which will be filled in by this function, giving the chunk-relative transform for each chunk instance
+ \param chunkMeshStarts user-allocated array which will be filled in with offsets into the meshIndices and relativeTransforms array.
+ For a chunk indexed by i, the corresponding range [chunkMeshStart[i], chunkMeshStart[i+1]-1] in meshIndices and relativeTransforms is used.
+ *NOTE*: chunkMeshStart array must be of at least size N+1, where N is the number of chunks in the base explicit hierarchical mesh.
+ \param scatterMeshInstancesBufferSize the size of meshIndices and relativeTransforms array.
+ \param scatterMeshInstancesBufferSize the size of meshIndices and relativeTransforms array.
+ \param hMesh the mesh in which to distribute sites
+ \param targetChunkCount how many chunks are in the array targetChunkIndices
+ \param targetChunkIndices an array of chunk indices which are candidates for scatter meshes. The elements in the array chunkIndices will come from this array
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param scatterMeshAssetCount the number of different scatter meshes (not instances). Should not exceed 255. If scatterMeshAssetCount > 255, only the first 255 will be used.
+ \param scatterMeshAssets an array of size scatterMeshAssetCount, of the render mesh assets which will be used for the scatter meshes
+ \param minCount an array of size scatterMeshAssetCount, giving the minimum number of instances to place for each mesh
+ \param maxCount an array of size scatterMeshAssetCount, giving the maximum number of instances to place for each mesh
+ \param minScales an array of size scatterMeshAssetCount, giving the minimum scale to apply to each scatter mesh
+ \param maxScales an array of size scatterMeshAssetCount, giving the maximum scale to apply to each scatter mesh
+ \param maxAngles an array of size scatterMeshAssetCount, giving a maximum deviation angle (in degrees) from the surface normal to apply to each scatter mesh
+
+ return value the number of instances placed in indices and relativeTransforms (will not exceed scatterMeshInstancesBufferSize)
+ */
+ virtual uint32_t createScatterMeshSites
+ (
+ uint8_t* meshIndices,
+ PxMat44* relativeTransforms,
+ uint32_t* chunkMeshStarts,
+ uint32_t scatterMeshInstancesBufferSize,
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ uint32_t targetChunkCount,
+ const uint16_t* targetChunkIndices,
+ uint32_t* randomSeed,
+ uint32_t scatterMeshAssetCount,
+ nvidia::RenderMeshAsset** scatterMeshAssets,
+ const uint32_t* minCount,
+ const uint32_t* maxCount,
+ const float* minScales,
+ const float* maxScales,
+ const float* maxAngles
+ ) = 0;
+
+ /**
+ Utility to visualize Voronoi cells for a given set of sites.
+
+ debugRender rendering object which will receive the drawing primitives associated with this cell visualization
+ sites an array of Voronoi cell sites, of length siteCount
+ siteCount the number of Voronoi cell sites (length of sites array)
+ cellColors an optional array of colors (see RenderDebug for format) for the cells. If NULL, the white (0xFFFFFFFF) color will be used.
+ If not NULL, this (of length cellColorCount) is used to color the cell graphics. The number cellColorCount need not match siteCount. If
+ cellColorCount is less than siteCount, the cell colors will cycle. That is, site N gets cellColor[N%cellColorCount].
+ cellColorCount the number of cell colors (the length of cellColors array)
+ bounds defines an axis-aligned bounding box which clips the visualization, since some cells extend to infinity
+ cellIndex if this is a valid index (cellIndex < siteCount), then only the cell corresponding to sites[cellIndex] will be drawn. Otherwise, all cells will be drawn.
+ */
+ virtual void visualizeVoronoiCells
+ (
+ nvidia::RenderDebugInterface& debugRender,
+ const PxVec3* sites,
+ uint32_t siteCount,
+ const uint32_t* cellColors,
+ uint32_t cellColorCount,
+ const PxBounds3& bounds,
+ uint32_t cellIndex = 0xFFFFFFFF
+ ) = 0;
+
+ /**
+ Builds a new ExplicitHierarchicalMesh from an array of triangles.
+
+ \param iHMesh the ExplicitHierarchicalMesh to build
+ \param meshTriangles pointer to array of ExplicitRenderTriangles which make up the mesh
+ \param meshTriangleCount the size of the meshTriangles array
+ \param submeshData pointer to array of ExplicitSubmeshData, describing the submeshes
+ \param submeshCount the size of the submeshData array
+ \param meshPartition if not NULL, an array of size meshPartitionCount, giving the end elements of contiguous subsets of meshTriangles.
+ If meshPartition is NULL, one partition is assumed.
+ When there is one partition, these triangles become the level 0 part.
+ When there is more than one partition, these triangles become level 1 parts, the behavior is determined by firstPartitionIsDepthZero (see below).
+ \param meshPartitionCount if meshPartition is not NULL, this is the size of the meshPartition array.
+ \param parentIndices if not NULL, the parent indices for each chunk (corresponding to a partition in the mesh partition).
+ \param parentIndexCount the size of the parentIndices array. This does not need to match meshPartitionCount. If a mesh partition has an index beyond the end of parentIndices,
+ then the parentIndex is considered to be 0. Therefore, if parentIndexCount = 0, all parents are 0 and so all chunks created will be depth 1. This will cause a
+ depth 0 chunk to be created that is the aggregate of the depth 1 chunks. If parentIndexCount > 0, then the depth-0 chunk must have a parentIndex of -1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = true, set parentIndices to the address of a int32_t containing the value -1,
+ and set parentIndexCount = 1.
+ To reproduce the effect of the old parameter 'firstPartitionIsDepthZero' = false, set parentIndexCount = 0.
+ Note: if parent indices are given, the first one must be -1, and *only* that index may be negative.
+ That is, there may be only one depth-0 mesh and it must be the first mesh.
+ */
+ virtual bool buildExplicitHierarchicalMesh
+ (
+ nvidia::ExplicitHierarchicalMesh& iHMesh,
+ const nvidia::ExplicitRenderTriangle* meshTriangles,
+ uint32_t meshTriangleCount,
+ const nvidia::ExplicitSubmeshData* submeshData,
+ uint32_t submeshCount,
+ uint32_t* meshPartition = NULL,
+ uint32_t meshPartitionCount = 0,
+ int32_t* parentIndices = NULL,
+ uint32_t parentIndexCount = 0
+ ) = 0;
+
+ /**
+ Set the tolerances used in CSG calculations with BSPs.
+
+ \param linearTolerance relative (to mesh size) tolerance used with angularTolerance to determine coplanarity. Default = 1.0e-4.
+ \param angularTolerance used with linearTolerance to determine coplanarity. Default = 1.0e-3
+ \param baseTolerance relative (to mesh size) tolerance used for spatial partitioning
+ \param clipTolerance relative (to mesh size) tolerance used when clipping triangles for CSG mesh building operations. Default = 1.0e-4.
+ \param cleaningTolerance relative (to mesh size) tolerance used when cleaning the out put mesh generated from the toMesh() function. Default = 1.0e-7.
+ */
+ virtual void setBSPTolerances
+ (
+ float linearTolerance,
+ float angularTolerance,
+ float baseTolerance,
+ float clipTolerance,
+ float cleaningTolerance
+ ) = 0;
+
+ /**
+ Set the parameters used in BSP building operations.
+
+ \param logAreaSigmaThreshold At each step in the tree building process, the surface with maximum triangle area is compared
+ to the other surface triangle areas. If the maximum area surface is far from the "typical" set of
+ surface areas, then that surface is chosen as the next splitting plane. Otherwise, a random
+ test set is chosen and a winner determined based upon the weightings below.
+ The value logAreaSigmaThreshold determines how "atypical" the maximum area surface must be to
+ be chosen in this manner.
+ Default value = 2.0.
+ \param testSetSize Larger values of testSetSize may find better BSP trees, but will take more time to create.
+ testSetSize = 0 is treated as infinity (all surfaces will be tested for each branch).
+ Default value = 10.
+ \param splitWeight How much to weigh the relative number of triangle splits when searching for a BSP surface.
+ Default value = 0.5.
+ \param imbalanceWeight How much to weigh the relative triangle imbalance when searching for a BSP surface.
+ Default value = 0.0.
+ */
+ virtual void setBSPBuildParameters
+ (
+ float logAreaSigmaThreshold,
+ uint32_t testSetSize,
+ float splitWeight,
+ float imbalanceWeight
+ ) = 0;
+
+
+ /**
+ Builds the root ExplicitHierarchicalMesh from an RenderMeshAsset.
+ Since an DestructibleAsset contains no hierarchy information, the input mesh must have only one part.
+
+ \param iHMesh the ExplicitHierarchicalMesh to build
+ \param renderMeshAsset input RenderMesh asset
+ \param maxRootDepth cap the root depth at this value. Re-fracturing of the mesh will occur at this depth. Default = UINT32_MAX
+ */
+ virtual bool buildExplicitHierarchicalMeshFromRenderMeshAsset(nvidia::ExplicitHierarchicalMesh& iHMesh, const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
+
+ /**
+ Builds the root ExplicitHierarchicalMesh from an DestructibleAsset.
+ Since an DestructibleAsset contains hierarchy information, the explicit mesh formed
+ will have this hierarchy structure.
+
+ \param iHMesh the ExplicitHierarchicalMesh to build
+ \param destructibleAsset input Destructible asset
+ \param maxRootDepth cap the root depth at this value. Re-fracturing of the mesh will occur at this depth. Default = UINT32_MAX
+ */
+ virtual bool buildExplicitHierarchicalMeshFromDestructibleAsset(nvidia::ExplicitHierarchicalMesh& iHMesh, const nvidia::DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
+
+ /**
+ Splits the mesh in chunk[0], forming a hierarchy of fractured meshes in chunks[1...]
+
+ \param hMesh the mesh to split
+ \param iHMeshCore if this mesh is not empty, chunk 0 will be used as an indestructible "core" of the fractured
+ mesh. That is, it will be subtracted from hMesh, and placed at level 1 of the hierarchy. The remainder
+ of hMesh will be split as usual, creating chunks at level 1 (and possibly deeper).
+ \param exportCoreMesh if true, a core mesh chunk will be created from iHMeshCore
+ \param coreMeshImprintSubmeshIndex if this is < 0, use the core mesh materials (was applyCoreMeshMaterialToNeighborChunks). Otherwise, use the given submesh
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the slicing surfaces (see FractureSliceDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity.
+ Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool createHierarchicallySplitMesh
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ nvidia::ExplicitHierarchicalMesh& iHMeshCore,
+ bool exportCoreMesh,
+ int32_t coreMeshImprintSubmeshIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureSliceDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t randomSeed,
+ nvidia::IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Chips the mesh in chunk[0], forming a hierarchy of fractured meshes in chunks[1...]
+
+ \param hMesh the mesh to split
+ \param meshProcessingParams describes generic mesh processing directives
+ \param desc describes the slicing surfaces (see FractureCutoutDesc)
+ \param iCutoutSet the cutout set to use for fracturing (see CutoutSet)
+ \param sliceDesc used if desc.chunkFracturingMethod = SliceFractureCutoutChunks
+ \param voronoiDesc used if desc.chunkFracturingMethod = VoronoiFractureCutoutChunks
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed seed for the random number generator, to ensure reproducibility.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity.
+ Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool createChippedMesh
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureCutoutDesc& desc,
+ const FractureTools::CutoutSet& iCutoutSet,
+ const FractureTools::FractureSliceDesc& sliceDesc,
+ const FractureTools::FractureVoronoiDesc& voronoiDesc,
+ const CollisionDesc& collisionDesc,
+ uint32_t randomSeed,
+ nvidia::IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Splits the chunk in chunk[chunkIndex], forming a hierarchy of fractured chunks using
+ slice-mode fracturing. The chunks will be rearranged so that they are in breadth-first order.
+
+ \param hMesh the ExplicitHierarchicalMesh to act upon
+ \param chunkIndex index of chunk to be split
+ \param meshProcessingParams used to create a BSP for this chunk
+ \param desc describes the slicing surfaces (see FractureSliceDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity.
+ Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool hierarchicallySplitChunk
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ uint32_t chunkIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureSliceDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t* randomSeed,
+ nvidia::IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Splits the chunk in chunk[chunkIndex], forming fractured chunks using
+ Voronoi decomposition fracturing. The chunks will be rearranged so that they are in breadth-first order.
+
+ \param hMesh the ExplicitHierarchicalMesh to act upon
+ \param chunkIndex index of chunk to be split
+ \param meshProcessingParams: describes generic mesh processing directives
+ \param desc describes the voronoi splitting parameters surfaces (see FractureVoronoiDesc)
+ \param collisionDesc convex hulls will be generated for each chunk using the method. See CollisionDesc.
+ \param randomSeed pointer to a seed for the random number generator, to ensure reproducibility. If NULL, the random number generator will not be re-seeded.
+ \param progressListener The user must instantiate an IProgressListener, so that this function may report progress of this operation
+ \param cancel if not NULL and *cancel is set to true, the root mesh will be restored to its original state, and the function will return at its earliest opportunity.
+ Meant to be set from another thread.
+
+ \return returns true if successful.
+ */
+ virtual bool voronoiSplitChunk
+ (
+ nvidia::ExplicitHierarchicalMesh& hMesh,
+ uint32_t chunkIndex,
+ const FractureTools::MeshProcessingParameters& meshProcessingParams,
+ const FractureTools::FractureVoronoiDesc& desc,
+ const CollisionDesc& collisionDesc,
+ uint32_t* randomSeed,
+ nvidia::IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ ) = 0;
+
+ /**
+ Builds a mesh used for slice fracturing, given the noise parameters and random seed. This function is mostly intended
+ for visualization - to give the user a "typical" slice surface used for fracturing.
+ */
+ virtual bool buildSliceMesh
+ (
+ nvidia::IntersectMesh& intersectMesh,
+ nvidia::ExplicitHierarchicalMesh& referenceMesh,
+ const PxPlane& slicePlane,
+ const FractureTools::NoiseParameters& noiseParameters,
+ uint32_t randomSeed
+ ) = 0;
+
+ /** Instantiates an ExplicitHierarchicalMesh */
+ virtual nvidia::ExplicitHierarchicalMesh* createExplicitHierarchicalMesh() = 0;
+
+ /** Instantiates an ExplicitHierarchicalMesh::ConvexHull */
+ virtual nvidia::ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull() = 0;
+
+};
+
+}} // namespaces
+
+
+PX_POP_PACK
+
+#endif // FRACTURE_TOOLS_API_H
diff --git a/APEX_1.4/include/destructible/FractureToolsStructs.h b/APEX_1.4/include/destructible/FractureToolsStructs.h
new file mode 100644
index 00000000..1bfecd9c
--- /dev/null
+++ b/APEX_1.4/include/destructible/FractureToolsStructs.h
@@ -0,0 +1,761 @@
+/*
+ * Copyright (c) 2008-2015, 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 FRACTURE_TOOLS_STRUCTS_H
+#define FRACTURE_TOOLS_STRUCTS_H
+
+#include "foundation/Px.h"
+#include "ExplicitHierarchicalMesh.h"
+
+PX_PUSH_PACK_DEFAULT
+
+namespace FractureTools
+{
+
+/**
+ These parameters are passed into the fracturing functions to guide mesh processing.
+*/
+struct MeshProcessingParameters
+{
+ /**
+ If this is true, separate mesh islands will be turned into separate chunks.
+ Default = false.
+ */
+ bool islandGeneration;
+
+ /**
+ If this is true, all T-junctions will be removed from the mesh.
+ Default = false.
+ */
+ bool removeTJunctions;
+
+ /**
+ The mesh is initially scaled to fit in a unit cube, then (if gridSize is not
+ zero), the vertices of the scaled mesh are snapped to a grid of size 1/gridSize.
+ A power of two is recommended.
+ Default = 65536.
+ */
+ unsigned microgridSize;
+
+ /**
+ Open mesh handling. Modes: Automatic, Closed, Open (see BSPOpenMode)
+ Closed mode assumes the mesh is closed and attempts to insert interior faces.
+ Open mode assumes the mesh is open and does not insert interior faces.
+ Automatic mode attempts to determine if the mesh is open or closed, and act accordingly.
+
+ Default is Automatic mode.
+ */
+ nvidia::BSPOpenMode::Enum meshMode;
+
+ /**
+ Debug output verbosity level. The higher the number, the more messages are output.
+ Default = 0.
+ */
+ int verbosity;
+
+ /** Constructor sets defaults */
+ MeshProcessingParameters()
+ {
+ setToDefault();
+ }
+
+ /** Set default values */
+ void setToDefault()
+ {
+ islandGeneration = false;
+ removeTJunctions = false;
+ microgridSize = 65536;
+ meshMode = nvidia::BSPOpenMode::Automatic;
+ verbosity = 0;
+ }
+};
+
+
+/**
+ Interface to a "cutout set," used with chippable fracturing. A cutout set is created from a bitmap. The
+ result is turned into cutouts which are applied to the mesh. For example, a bitmap which looks like a brick
+ pattern will generate a cutout for each "brick," forming the cutout set.
+
+ Each cutout is a 2D entity, meant to be projected onto various faces of a mesh. They are represented
+ by a set of 2D vertices, which form closed loops. More than one loop may represent a single cutout, if
+ the loops are forced to be convex. Otherwise, a cutout is represented by a single loop.
+*/
+class CutoutSet
+{
+public:
+ /** Returns the number of cutouts in the set. */
+ virtual uint32_t getCutoutCount() const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the number of vertices in the cutout.
+ */
+ virtual uint32_t getCutoutVertexCount(uint32_t cutoutIndex) const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the number of loops in this cutout.
+ */
+ virtual uint32_t getCutoutLoopCount(uint32_t cutoutIndex) const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the vertex indexed by vertexIndex. (Only the X and Y coordinates are used.)
+ */
+ virtual const physx::PxVec3& getCutoutVertex(uint32_t cutoutIndex, uint32_t vertexIndex) const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the number of vertices in the loop indexed by loopIndex.
+ */
+ virtual uint32_t getCutoutLoopSize(uint32_t coutoutIndex, uint32_t loopIndex) const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the vertex index of the vertex indexed by vertexNum, in the loop
+ indexed by loopIndex.
+ */
+ virtual uint32_t getCutoutLoopVertexIndex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
+
+ /**
+ Applies to the cutout indexed by cutoutIndex:
+ Returns the flags of the vertex indexed by vertexNum, in the loop
+ indexed by loopIndex.
+ */
+ virtual uint32_t getCutoutLoopVertexFlags(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
+
+ /**
+ Whether or not this cutout set is to be tiled.
+ */
+ virtual bool isPeriodic() const = 0;
+
+ /**
+ The dimensions of the fracture map used to create the cutout set.
+ */
+ virtual const physx::PxVec2& getDimensions() const = 0;
+
+ /** Serialization */
+ //virtual void serialize(physx::PxFileBuf& stream) const = 0;
+ //virtual void deserialize(physx::PxFileBuf& stream) = 0;
+
+ /** Releases all memory and deletes itself. */
+ virtual void release() = 0;
+
+protected:
+ /** Protected destructor. Use the release() method. */
+ virtual ~CutoutSet() {}
+};
+
+
+/**
+ NoiseParameters
+ These parameters are used to build a splitting surface.
+*/
+struct NoiseParameters
+{
+ /**
+ Size of the fluctuations, relative to mesh size
+ */
+ float amplitude;
+
+ /**
+ Noise frequencey relative to 1/(grid spacing). On scales much smaller than this, the function is smooth.
+ On scales much large, the function looks uncorrelated
+ */
+ float frequency;
+
+ /**
+ Suggested number of grid elements across the mesh. The actual number may vary depending
+ on the mesh's proportions.
+ */
+ int gridSize;
+
+ /**
+ Noise function to use. This parameter is currently unused.
+ Noise is generated by superposition of many fourier modes in random directions,
+ with frequencies randomly chosen in a band around the input frequency,
+ */
+ int type;
+
+ /** Constructor sets defaults */
+ NoiseParameters()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set default values:
+
+ amplitude = 0.0f;
+ frequency = 0.25f;
+ gridSize = 10;
+ type = 0;
+ */
+ void setToDefault()
+ {
+ amplitude = 0.0f;
+ frequency = 0.25f;
+ gridSize = 10;
+ type = 0;
+ }
+};
+
+
+/**
+ SliceParameters
+
+ The slicing parameters for X, Y, and Z slicing of a mesh.
+*/
+struct SliceParameters
+{
+ /**
+ Which axis order to slice the mesh.
+ This only matters if there is randomness in the slice surface.
+ */
+ enum Order
+ {
+ XYZ,
+ YZX,
+ ZXY,
+ ZYX,
+ YXZ,
+ XZY,
+ Through
+ };
+
+ /** The slicing order (see the Order enum) */
+ unsigned order;
+
+ /** How many times to slice along each axis */
+ unsigned splitsPerPass[3];
+
+ /**
+ Variation in slice position along each axis. This is a relative quantity.
+ linearVariation[axis] = 0 means the slicing offsets are evenly spaced across the mesh along the axis.
+ linearVariation[axis] = 1 means the slicing offsets are randomly chosen in a range of width 1/(splitsPerPass[axis]+1)
+ times the width of the mesh along the axis.
+ */
+ float linearVariation[3];
+
+ /**
+ Variation in the slice surface angle along each axis.
+ 0 variation means the slice surfaces are axis-aligned. Otherwise, the surface normal will be varied randomly,
+ with angle to the axis somewhere within the given variation (in radians).
+ */
+ float angularVariation[3];
+
+ /** The noise for each slicing direction */
+ NoiseParameters noise[3];
+
+ /** Constructor sets defaults */
+ SliceParameters()
+ {
+ setToDefault();
+ }
+
+ /** Sets all NoiseParameters to their defaults:
+ order = XYZ;
+ splitsPerPass[0] = splitsPerPass[1] = splitsPerPass[2] = 1;
+ linearVariation[0] = linearVariation[1] = linearVariation[2] = 0.1f;
+ angularVariation[0] = angularVariation[1] = angularVariation[2] = 20.0f*3.1415927f/180.0f;
+ noise[0].setToDefault();
+ noise[1].setToDefault();
+ noise[2].setToDefault();
+ */
+ void setToDefault()
+ {
+ order = XYZ;
+ splitsPerPass[0] = splitsPerPass[1] = splitsPerPass[2] = 1;
+ linearVariation[0] = linearVariation[1] = linearVariation[2] = 0.1f;
+ angularVariation[0] = angularVariation[1] = angularVariation[2] = 20.0f * 3.1415927f / 180.0f;
+ noise[0].setToDefault();
+ noise[1].setToDefault();
+ noise[2].setToDefault();
+ }
+};
+
+
+/**
+ FractureSliceDesc
+
+ Descriptor for slice-mode fracturing.
+*/
+struct FractureSliceDesc
+{
+ /** How many times to recurse the slicing process */
+ unsigned maxDepth;
+
+ /** Array of slice parameters; must be of length maxDepth */
+ SliceParameters* sliceParameters;
+
+ /**
+ If this is true, the targetProportions (see below) will be used.
+ */
+ bool useTargetProportions;
+
+ /**
+ If useTargetProportions is true, the splitsPerPass values will not necessarily be used.
+ Instead, the closest values will be chosen at each recursion of slicing, in order to make
+ the pieces match the target proportions as closely as possible.
+
+ Note: the more noise there is in the slicing surfaces, the less accurate these proportions will be.
+ */
+ float targetProportions[3];
+
+ /**
+ Smallest size allowed for chunks, as measured by their bounding box widths along the x, y, and z axes.
+ The sizes are interpreted as fractions of the unfractured mesh's bounding box width.
+ Chunks created by fracturing which are smaller than this limit will be removed. Note - this will leave holes at the given depth.
+ Default = (0,0,0), which disables this feature.
+ */
+ float minimumChunkSize[3];
+
+ /**
+ Material application descriptor used for each slice axis.
+ */
+ nvidia::FractureMaterialDesc materialDesc[3];
+
+ /**
+ If instanceChunks is true, corresponding chunks in different destructible actors will be instanced.
+ */
+ bool instanceChunks;
+
+ /**
+ If true, slice geometry and noise will be stored in a separate displacement offset buffer.
+ */
+ bool useDisplacementMaps;
+
+ /** Enum describing creation of displacement maps. */
+ enum NoiseMode
+ {
+ NoiseWavePlane = 0,
+ NoisePerlin2D,
+ NoisePerlin3D,
+
+ NoiseModeCount
+ };
+
+ /**
+ The noise mode. If displacement maps are enabled, NoisePerlin3D will be used.
+ */
+ unsigned noiseMode;
+
+ /** Constructor sets defaults */
+ FractureSliceDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Sets the default values:
+
+ maxDepth = 0;
+ sliceParameters = NULL;
+ useTargetProportions = false;
+ targetProportions[0..2] = 1.0f;
+ minimumChunkSize[0..2] = 0.0f;
+ materialDesc[0..2].setToDefault();
+ instanceChunks = false;
+ useDisplacementMaps = false;
+ noiseMode = NoiseWavePlane;
+ */
+ void setToDefault()
+ {
+ maxDepth = 0;
+ sliceParameters = NULL;
+ useTargetProportions = false;
+ for (int i = 0; i < 3; ++i)
+ {
+ targetProportions[i] = 1.0f;
+ minimumChunkSize[i] = 0.0f;
+ materialDesc[i].setToDefault();
+ }
+ instanceChunks = false;
+ useDisplacementMaps = false;
+ noiseMode = NoiseWavePlane;
+ }
+};
+
+
+/**
+ CutoutParameters
+
+ Parameters for a single cutout direction.
+*/
+struct CutoutParameters
+{
+ /**
+ The depth to apply cutout fracturing.
+ 0 has a special value; it means cut all the way through
+ */
+ float depth;
+
+ /**
+ Material application descriptor used for the cutout direction.
+ Note: The backface slice will use the U-direction and UV offset specified in each descriptor, however the cutout slices (surrounding
+ each cutout chunk) will ignore these fields (only using the UV scale).
+ */
+ nvidia::FractureMaterialDesc materialDesc;
+
+ /**
+ Describes the characteristics of the backface cutting surface (along the various cutout directions).
+ If the noise is 0, the cutting surface will be a plane. Otherwise, there will be some variation,
+ or roughness, to the surface.
+ */
+ NoiseParameters backfaceNoise;
+
+ /**
+ Describes the characteristics of the perimeter cutting surfaces (for the various cutout directions).
+ If the noise is 0, the cutting surface will smooth. Otherwise, there will be some variation,
+ or roughness, to the surface.
+
+ Note: this noise is applied only to the graphics of the cutout chunks. The chunks' collision volumes AND the chunks'
+ children (if fractured further) will NOT be affected by this noise.
+ */
+ NoiseParameters edgeNoise;
+
+ /** Constructor sets defaults */
+ CutoutParameters()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set default values:
+
+ depth = 1.0f;
+ backfaceNoise.setToDefault();
+ edgeNoise.setToDefault();
+ materialDesc.setToDefault();
+ */
+ void setToDefault()
+ {
+ depth = 1.0f;
+ backfaceNoise.setToDefault();
+ materialDesc.setToDefault();
+ edgeNoise.setToDefault();
+ }
+};
+
+
+/**
+ FractureCutoutDesc
+
+ Descriptor for cutout-mode (chippable) fracturing.
+*/
+struct FractureCutoutDesc
+{
+ /** Enum describing the directions to apply cutout fracturing. */
+ enum Directions
+ {
+ UserDefined = 0, // If no flags are set, the cutout direction is taken from userDefinedDirection
+
+ NegativeX = 1 << 0,
+ PositiveX = 1 << 1,
+ NegativeY = 1 << 2,
+ PositiveY = 1 << 3,
+ NegativeZ = 1 << 4,
+ PositiveZ = 1 << 5,
+
+ DirectionCount = 6
+ };
+
+ /** The directions to apply cutout fracturing. (See the Directions enum.) */
+ unsigned directions;
+
+ /**
+ The order in which to apply each cutout direction.
+ The direction in directionOrder[0] is applied first, in directionOrder[1], second, and so on.
+ */
+ unsigned directionOrder[DirectionCount];
+
+ /** Cutout parameters used for the various pre-defined cutout directions. */
+ CutoutParameters cutoutParameters[DirectionCount];
+
+ /**
+ The cutout direction if directions = 0. When this is used, it must be have non-zero length (it will be
+ normalized internally), and userUVMapping must be set (this may be done with AssetAuthoring::calculateCutoutUVMapping).
+ */
+ physx::PxVec3 userDefinedDirection;
+
+ /** The UV mapping used if directons = 0 (along with userDefinedDirection). */
+ physx::PxMat33 userUVMapping;
+
+ /** Cutout parameters used if user-defined (UV-based) cutout fracturing is selected by setting directions = 0 */
+ CutoutParameters userDefinedCutoutParameters;
+
+ /** Enum describing the instancing mode. */
+ enum InstancingMode
+ {
+ DoNotInstance,
+ InstanceCongruentChunks,
+ InstanceAllChunks,
+
+ InstanceModeCount
+ };
+
+ /**
+ The instancing mode.
+ */
+ unsigned instancingMode;
+
+ /**
+ If tileFractureMap is true, the map will be tiled across the destructible.
+ */
+ bool tileFractureMap;
+
+ /**
+ The U,V width of the fracture map when instancing chunks
+ */
+ physx::PxVec2 uvTileSize;
+
+ /**
+ If true, non-convex cutouts will be split into convex ones.
+ */
+ bool splitNonconvexRegions;
+
+ /**
+ Fracturing to apply to cutout chunks (if any), to break them down further.
+ Current options include none, slice fracturing, and voronoi fracturing.
+ */
+ enum CutoutChunkFracturingMethod
+ {
+ DoNotFractureCutoutChunks,
+ SliceFractureCutoutChunks,
+ VoronoiFractureCutoutChunks,
+
+ CutoutChunkFracturingMethodCount
+ };
+
+ /**
+ If true, slice-mode fracturing will be applied to each cutout piece.
+ The cutout function must be provided with a FractureSliceDesc as well to describe
+ the slice parameters. These parameters, however, must be interpreted from the
+ point of view of the cutout direction. That is, X and Y slice parameters will be
+ used to slice along the cutout faces. The Z slice parameters will be used to slice
+ into the cutout faces.
+ */
+ unsigned chunkFracturingMethod;
+
+ /**
+ If true, the backface and cutouts will be trimmed if (a) backface noise is non-zero or
+ (b) the collision hull is something other than the mesh convex hull ("Wrap Graphics Mesh").
+ Trimming is done by intersecting the face slice plane (without added noise) with the backface
+ and cutouts.
+ Default is true.
+ */
+ bool trimFaceCollisionHulls;
+
+ /** Scale to apply to the X coordinates of the cutout set (along the various cutout directions). */
+ float cutoutWidthScale[DirectionCount];
+
+ /** Scale to apply to the Y coordinates of the cutout set (along the various cutout directions). */
+ float cutoutHeightScale[DirectionCount];
+
+ /** Offset to apply to the X coordinates of the cutout set (along the various cutout directions). */
+ float cutoutWidthOffset[DirectionCount];
+
+ /** Offset to apply to the Y coordinates of the cutout set (along the various cutout directions). */
+ float cutoutHeightOffset[DirectionCount];
+
+ /** If true, the cutout map will be flipped in the X direction (along the various cutout directions). */
+ bool cutoutWidthInvert[DirectionCount];
+
+ /** If true, the cutout map will be flipped in the Y direction (along the various cutout directions). */
+ bool cutoutHeightInvert[DirectionCount];
+
+ /** The interpreted size of the cutout map in the X direction */
+ float cutoutSizeX;
+
+ /** The interpreted size of the cutout map in the Y direction */
+ float cutoutSizeY;
+
+ /**
+ Threshold angle to merge (smoothe) vertex normals around cutout, in degrees.
+ If the exterior angle between two facets of a cutout region no more than this, the vertex normals and tangents will be
+ averaged at the facet interface. A value of 0 effectively disables smoothing.
+ Default value = 60 degrees.
+ */
+ float facetNormalMergeThresholdAngle;
+
+ /** Constructor sets defaults */
+ FractureCutoutDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Set default values:
+
+ directions = 0;
+ directionOrder[0..5] = {NegativeX, .., PositiveZ};
+ cutoutParameters[0..5].setToDefault();
+ userDefinedDirection= physx::PxVec3(0.0f);
+ userUVMapping = physx::PxMat33(physx::PxIdentity);
+ userDefinedCutoutParameters.setToDefault();
+ instancingMode = DoNotInstance;
+ tileFractureMap = false;
+ uvTileSize = (0.0f,0.0f)
+ cutoutParameters[0..5].setToDefault();
+ cutoutWidthScale[0..5] = 1.0f;
+ cutoutHeightScale[0..5] = 1.0f;
+ cutoutWidthOffset[0..5] = 0.0f;
+ cutoutHeightOffset[0..5] = 0.0f;
+ cutoutWidthInvert[0..5] = false;
+ cutoutHeightInvert[0..5] = false;
+ cutoutSizeX = 1.0f;
+ cutoutSizeY = 1.0f;
+ facetNormalMergeThresholdAngle = 60.0f;
+ splitNonconvexRegions = false;
+ chunkFracturingMethod = DoNotFractureCutoutChunks;
+ trimFaceCollisionHulls = true;
+ */
+ void setToDefault()
+ {
+ directions = 0;
+ userDefinedDirection= physx::PxVec3(0.0f);
+ userUVMapping = physx::PxMat33(physx::PxIdentity);
+ userDefinedCutoutParameters.setToDefault();
+ instancingMode = DoNotInstance;
+ tileFractureMap = false;
+ uvTileSize = physx::PxVec2(0.0f);
+ for (uint32_t i = 0; i < DirectionCount; ++i)
+ {
+ directionOrder[i] = 1u << i;
+ cutoutParameters[i].setToDefault();
+ cutoutWidthScale[i] = 1.0f;
+ cutoutHeightScale[i] = 1.0f;
+ cutoutWidthOffset[i] = 0.0f;
+ cutoutHeightOffset[i] = 0.0f;
+ cutoutWidthInvert[i] = false;
+ cutoutHeightInvert[i] = false;
+ }
+ cutoutSizeX = 1.0f;
+ cutoutSizeY = 1.0f;
+ facetNormalMergeThresholdAngle = 60.0f;
+ splitNonconvexRegions = false;
+ chunkFracturingMethod = DoNotFractureCutoutChunks;
+ trimFaceCollisionHulls = true;
+ }
+};
+
+
+/**
+ FractureVoronoiDesc
+
+ Descriptor for Voronoi decomposition fracturing.
+*/
+struct FractureVoronoiDesc
+{
+ /**
+ Number of cell sites in the sites array. Must be positive.
+ */
+ unsigned siteCount;
+
+ /**
+ Array of cell sites. The length of this array is given by siteCount.
+ */
+ const physx::PxVec3* sites;
+
+ /**
+ Array of chunk indices to associate with each site. If this pointer is NULL, then all sites will be used to split
+ all chunks relevant to the splitting operation. Otherwise, the chunkIndices array must be of length siteCount.
+ */
+ const uint32_t* chunkIndices;
+
+ /**
+ Describes the characteristics of the interior surfaces.
+ If the noise is 0, the cutting surface will smooth. Otherwise, there will be some variation, or roughness, to the surface.
+
+ Note: this noise is applied only to the graphics of the chunks. The chunks' collision volumes AND the chunks'
+ children (if fractured further) will NOT be affected by this noise.
+ */
+ NoiseParameters faceNoise;
+
+ /**
+ If instanceChunks is true, corresponding chunks in different destructible actors will be instanced.
+ */
+ bool instanceChunks;
+
+ /**
+ If true, slice geometry and noise will be stored in a separate displacement offset buffer.
+ */
+ bool useDisplacementMaps;
+
+ /** Enum describing creation of displacement maps. */
+ enum NoiseMode
+ {
+ NoiseWavePlane = 0,
+ NoisePerlin2D,
+ NoisePerlin3D,
+
+ NoiseModeCount
+ };
+
+ /**
+ The noise mode. If displacement maps are enabled, NoisePerlin3D will be used.
+ */
+ unsigned noiseMode;
+
+ /**
+ Smallest size allowed for chunks, as measured by their bounding sphere diameters.
+ The sizes are interpreted as fractions of the unfractured mesh's bounding sphere diameter.
+ Chunks created by fracturing which are smaller than this limit will be removed. Note - this will leave holes at the given depth.
+ Default = 0, which disables this feature.
+ */
+ float minimumChunkSize;
+
+ /**
+ Material application descriptor used for each slice.
+ Note: the U-direction and UV offset in the descriptor will be ignored - UV mapping is done in arbitrary orientation and translation on each chunk face.
+ */
+ nvidia::FractureMaterialDesc materialDesc;
+
+
+ /** Constructor sets defaults */
+ FractureVoronoiDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ Sets the default values:
+
+ siteCount = 0;
+ sites = NULL;
+ chunkIndices = NULL;
+ faceNoise.setToDefault();
+ instanceChunks = false;
+ useDisplacementMaps = false;
+ noiseMode = NoiseWavePlane;
+ minimumChunkSize = 0.0f;
+ materialDesc.setToDefault();
+ */
+ void setToDefault()
+ {
+ siteCount = 0;
+ sites = NULL;
+ chunkIndices = NULL;
+ faceNoise.setToDefault();
+ instanceChunks = false;
+ useDisplacementMaps = false;
+ noiseMode = NoiseWavePlane;
+ minimumChunkSize = 0.0f;
+ materialDesc.setToDefault();
+ }
+};
+
+
+} // namespace FractureTools
+
+
+PX_POP_PACK
+
+#endif // FRACTURE_TOOLS_H
diff --git a/APEX_1.4/include/destructible/ModuleDestructible.h b/APEX_1.4/include/destructible/ModuleDestructible.h
new file mode 100644
index 00000000..863d2740
--- /dev/null
+++ b/APEX_1.4/include/destructible/ModuleDestructible.h
@@ -0,0 +1,880 @@
+/*
+ * Copyright (c) 2008-2015, 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 MODULE_DESTRUCTIBLE_H
+#define MODULE_DESTRUCTIBLE_H
+
+#include "foundation/Px.h"
+#include "foundation/PxBounds3.h"
+#include "Module.h"
+
+#ifndef APEX_RUNTIME_FRACTURE
+#define APEX_RUNTIME_FRACTURE 1
+#else
+#undef APEX_RUNTIME_FRACTURE
+#define APEX_RUNTIME_FRACTURE 0
+#endif
+
+#if PX_ANDROID
+#undef APEX_RUNTIME_FRACTURE
+#define APEX_RUNTIME_FRACTURE 0
+#endif
+
+namespace physx
+{
+class PxRigidActor;
+class PxRigidDynamic;
+class PxScene;
+}
+
+namespace nvidia
+{
+namespace apex
+{
+
+PX_PUSH_PACK_DEFAULT
+
+class DestructibleAsset;
+class DestructibleAssetAuthoring;
+class DestructibleActor;
+class DestructibleActorJoint;
+class DestructibleChunkDesc;
+class DestructibleActorDesc;
+class DestructibleActorJointDesc;
+
+/**
+ Flags returned by an UserChunkReport
+*/
+struct ApexChunkFlag
+{
+ /**
+ Enum of apex chunk flag
+ */
+ enum Enum
+ {
+ /** The chunk is dynamic */
+ DYNAMIC = 1 << 0,
+
+ /** The chunk has environmental support, so will remain kinematic until fractured */
+ EXTERNALLY_SUPPORTED = 1 << 1,
+
+ /** Only true if EXTERNALLY_SUPPORTED is true. In addition, this means that it gained support via static geometry overlap. */
+ WORLD_SUPPORTED = 1 << 2,
+
+ /** The chunk has been fractured */
+ FRACTURED = 1 << 3,
+
+ /** The chunk has been destroyed because the PxActor FIFO was full */
+ DESTROYED_FIFO_FULL = 1 << 4,
+
+ /** The chunk has been destroyed because it has exceeded the maximum debris lifetime */
+ DESTROYED_TIMED_OUT = 1 << 5,
+
+ /** The chunk has been destroyed because it has exceeded the maximum debris distance */
+ DESTROYED_EXCEEDED_MAX_DISTANCE = 1 << 6,
+
+ /** The destroyed chunk has generated crumble particles */
+ DESTROYED_CRUMBLED = 1 << 7,
+
+ /** The destroyed chunk has moved beyond the destructible actor's valid bounds. */
+ DESTROYED_LEFT_VALID_BOUNDS = 1 << 8,
+
+ /** The destroyed chunk has moved beyond the user-defined bounding box. */
+ DESTROYED_LEFT_USER_BOUNDS = 1 << 9,
+
+ /** The destroyed chunk has moved into the user-defined bounding box. */
+ DESTROYED_ENTERED_USER_BOUNDS = 1 << 10
+ };
+};
+
+/**
+ Per-chunk data returned in DamageEventReportData
+*/
+struct ChunkData
+{
+ /** The index of the chunk within the destructible asset */
+ uint32_t index;
+
+ /** The hierarchy depth of the chunk */
+ uint32_t depth;
+
+ /**
+ The chunk's axis-aligned bounding box, in world space.
+ */
+ PxBounds3 worldBounds;
+
+ /**
+ How much damage the chunk has taken
+ */
+ float damage;
+
+ /**
+ Several flags holding chunk information
+ \see ApexChunkFlag
+ */
+ uint32_t flags;
+};
+
+/**
+ Per-actor damage event data returned by an UserChunkReport
+*/
+struct DamageEventReportData
+{
+ /**
+ The DestructibleActor instance that these chunks belong to
+ */
+ DestructibleActor* destructible;
+
+ /**
+ Damage event hitDirection in world space.
+ */
+ PxVec3 hitDirection;
+
+ /**
+ The axis-aligned bounding box of all chunk fractures caused by this damage event,
+ which have flags that overlap the module's chunkReportBitMask (see ModuleDestructible::setChunkReportBitMask).
+ */
+ PxBounds3 worldBounds;
+
+ /**
+ Total number of fracture events caused by this damage event,
+ which have flags that overlap the module's chunkReportBitMask (see ModuleDestructible::setChunkReportBitMask).
+ */
+ uint32_t totalNumberOfFractureEvents;
+
+ /**
+ Min depth of chunk fracture events caused by this damage event,
+ which have flags that overlap the module's chunkReportBitMask (see ModuleDestructible::setChunkReportBitMask).
+ */
+ uint16_t minDepth;
+
+ /**
+ Max depth of chunk fracture events caused by this damage event,
+ which have flags that overlap the module's chunkReportBitMask (see ModuleDestructible::setChunkReportBitMask).
+ */
+ uint16_t maxDepth;
+
+ /**
+ Array of chunk fracture event data for all chunks above a size threshold, which have flags that overlap the
+ module's chunkReportBitMask (see ModuleDestructible::setChunkReportBitMask). Currently
+ the size cutoff is determined by the ModuleDestructible's chunkReportMaxFractureEventDepth (See
+ ModuleDestructible::setChunkReportMaxFractureEventDepth). All chunks up to that depth, but no deeper,
+ are reported in this list. The size of this array is given by fractureEventListSize. fractureEventList may
+ be NULL if fractureEventListSize = 0.
+ */
+ const ChunkData* fractureEventList;
+
+ /**
+ Size of the fractureEventList array. This may be less than totalNumberOfFractureEvents
+ if some of the fracture events involve chunks which do not meet the size criterion
+ described in the notes for the fractureEventList array.
+ */
+ uint32_t fractureEventListSize;
+
+ /**
+ Other PhysX actor that caused damage to DamageEventReportData.
+ */
+ physx::PxActor const* impactDamageActor;
+
+
+ /**
+ Impact damage position in world-space.
+ */
+ PxVec3 hitPosition;
+
+ /**
+ User data from applyDamage or applyRadiusDamage.
+ */
+ void* appliedDamageUserData;
+};
+
+
+/**
+ An event structure for an optional chunk event buffer. Contains a chunk index and an event field.
+
+ Note: currently the only chunk state event is for visibility changes, so the VisibilityChanged bit will always be set when this struct is used.
+*/
+struct DestructibleChunkEvent
+{
+ /**
+ Enum of event mask
+ */
+ enum EventMask
+ {
+ VisibilityChanged = (1 << 0),
+ ChunkVisible = (1 << 1)
+ };
+
+ uint16_t chunkIndex; ///< Chunk index
+ uint16_t event; ///< Event
+};
+
+
+/**
+ Chunk state event data pushed to the user, if the user requests it via ModuleDestructible::scheduleChunkStateEventCallback.
+*/
+struct ChunkStateEventData
+{
+ /**
+ The DestructibleActor instance that these chunks belong to
+ */
+ DestructibleActor* destructible;
+
+ /**
+ Array of chunk state event data collected since the last UserChunkReport::onStateChangeNotify call.
+ */
+ const DestructibleChunkEvent* stateEventList;
+
+ /**
+ Size of the stateEventList array
+ */
+ uint32_t stateEventListSize;
+};
+
+
+/**
+ UserChunkReport - API for a user-defined callback to get information about fractured or damaged chunks
+*/
+class UserChunkReport
+{
+public:
+ /**
+ User implementation of UserChunkReport must overload this function.
+ This function will get called when a chunk is fractured or destroyed.
+ See the definition of DamageEventReportData for the information provided
+ to the function.
+ */
+ virtual void onDamageNotify(const DamageEventReportData& damageEvent) = 0;
+
+ /**
+ User implementation of UserChunkReport must overload this function.
+ This function gets called when chunk visibility changes occur, if the user has selected
+ this option via ModuleDestructible::scheduleChunkStateEventCallback.
+ See the definition of ChunkStateEventData for the information provided
+ to the function.
+
+ *Please note* the user must also set the NxParameterized actor parameter 'createChunkEvents' to true,
+ on individual destructible actors, to receive state change events from that actor.
+ */
+ virtual void onStateChangeNotify(const ChunkStateEventData& visibilityEvent) = 0;
+
+ /**
+ Called when an DestructibleActor contains no visible chunks. If the user returns true,
+ APEX will release the destructible actor. If the user returns false, they should not
+ release the destructible actor from within the callback, and instead must wait until
+ the completion of Scene::fetchResults().
+
+ Default implementation returns false, which is the legacy behavior.
+
+ If this class (UserChunkReport) is not implemented, APEX will not destroy the DestructibleActor.
+ */
+ virtual bool releaseOnNoChunksVisible(const DestructibleActor* destructible) { PX_UNUSED(destructible); return false; }
+
+ /**
+ List of destructible actors that have just become awake (any associated PhysX actor has become awake).
+ **/
+ virtual void onDestructibleWake(DestructibleActor** destructibles, uint32_t count) = 0;
+
+ /**
+ List of destructible actors that have just gone to sleep (all associated PhysX actors have gone to sleep).
+ **/
+ virtual void onDestructibleSleep(DestructibleActor** destructibles, uint32_t count) = 0;
+
+protected:
+ virtual ~UserChunkReport() {}
+};
+
+
+/**
+ Particle buffer data returned with UserChunkParticleReport
+*/
+struct ChunkParticleReportData
+{
+ /** Position buffer. The length of this buffer is given by positionCount. */
+ const PxVec3* positions;
+
+ /** The array length of the positions buffer. */
+ uint32_t positionCount;
+
+ /**
+ Velocity buffer. The length of this buffer is given by velocityCount.
+ N.B.: The velocity buffer might not have the same length as the positions buffer.
+ It will be one of three lengths:
+ velocityCount = 0: There is no velocity data with these particles.
+ velocityCount = 1: All of the particle velocities are the same, given by *velocities.
+ velocityCount = positionCount: Each particle velocity is given.
+ */
+ const PxVec3* velocities;
+
+ /** The array length of the velocities buffer. (See the description above.)*/
+ uint32_t velocityCount;
+};
+
+/**
+ UserChunkParticleReport - API for a user-defined callback to get particle buffer data when a chunk crumbles or emits dust particles.
+ Note - only crumble emitters are implemented in 1.2.0
+*/
+class UserChunkParticleReport
+{
+public:
+ /**
+ User implementation of UserChunkParticleReport must overload this function.
+ This function will get called when an DestructibleActor generates crumble particle or
+ dust particle effect data. Crumble particles are generated whenever a chunk is destroyed completely and
+ the DestructibleActorFlag CRUMBLE_SMALLEST_CHUNKS is set. Dust line particles are
+ generated along chunk boundaries whenever they are fractured free from other chunks.
+
+ Note - only crumble emitters are implemented in 1.2.0
+ */
+ virtual void onParticleEmission(const ChunkParticleReportData& particleData) = 0;
+
+protected:
+ virtual ~UserChunkParticleReport() {}
+};
+
+
+/**
+ UserDestructiblePhysXActorReport - API for user-defined callbacks giving notification of PhysX actor creation and release from the
+ destruction module.
+*/
+class UserDestructiblePhysXActorReport
+{
+public:
+ /** Called immediately after a PxActor is created in the Destruction module. */
+ virtual void onPhysXActorCreate(const physx::PxActor& actor) = 0;
+
+ /** Called immediately before a PxActor is released in the Destruction module. */
+ virtual void onPhysXActorRelease(const physx::PxActor& actor) = 0;
+protected:
+ virtual ~UserDestructiblePhysXActorReport() {}
+};
+
+
+/**
+ Destructible module constants
+*/
+struct ModuleDestructibleConst
+{
+ /**
+ Enum for invalid chunk index (-1)
+ */
+ enum Enum
+ {
+ /**
+ When a function returns a chunk index, or takes a chunk index as a parameter, this
+ value indicates "no chunk."
+ */
+ INVALID_CHUNK_INDEX = -1
+ };
+};
+
+/**
+ Render mesh distinction, skinned vs. static
+*/
+struct DestructibleActorMeshType
+{
+ /**
+ Enum for destructible actor mesh type.
+ */
+ enum Enum
+ {
+ Skinned,
+ Static,
+ Count
+ };
+};
+
+/**
+ The core data of Damage Event. It is used for sync damage coloring.
+*/
+struct DamageEventCoreData
+{
+ int32_t chunkIndexInAsset; ///< Which chunk the damage is being applied to (non-range based damage)
+ PxVec3 position; ///< The position, in world space, where the damage event is originating from.
+ float damage; ///< The amount of damage
+ float radius; ///< The radius of the damage, if this is a range based damage event.
+};
+
+/**
+ Extended damage event data, used for impact damage reports
+*/
+struct ImpactDamageEventData : public DamageEventCoreData
+{
+ nvidia::DestructibleActor* destructible; ///< The destructible hit by the impacting actor
+ PxVec3 direction; ///< The position, in world space, from which the damage is applied
+ physx::PxActor const* impactDamageActor; ///< Other PhysX actor that caused damage
+};
+
+/**
+ UserImpactDamageReport - API for a user-defined callback to get a buffer of impact damage events
+*/
+class UserImpactDamageReport
+{
+public:
+ /**
+ User implementation of UserImpactDamageReport must overload this function.
+ If an instance of this object is passed to ModuleDestructible::setImpactDamageReportCallback,
+ this function will get called once during ApexScene::fetchResults, passing back an array of
+ ImpactDamageEventData reporting all impact damage events.
+ */
+ virtual void onImpactDamageNotify(const ImpactDamageEventData* buffer, uint32_t bufferSize) = 0;
+};
+
+/**
+ Sync-able Callback Class.
+*/
+template<typename DestructibleSyncHeader>
+class UserDestructibleSyncHandler
+{
+public:
+ /**
+ Called when write begins.
+ */
+ virtual void onWriteBegin(DestructibleSyncHeader *& bufferStart, uint32_t bufferSize) = 0;
+
+ /**
+ Called when write done.
+ */
+ virtual void onWriteDone(uint32_t headerCount) = 0;
+
+ /**
+ Called when pre-process read begins.
+ */
+ virtual void onPreProcessReadBegin(DestructibleSyncHeader *& bufferStart, uint32_t & bufferSize, bool & continuePointerSwizzling) = 0;
+
+ /**
+ Called when pre-process read done.
+ */
+ virtual void onPreProcessReadDone(uint32_t headerCount) = 0;
+
+ /**
+ Called when read begins.
+ */
+ virtual void onReadBegin(const DestructibleSyncHeader *& bufferStart) = 0;
+
+ /**
+ Called when read done.
+ */
+ virtual void onReadDone(const char * debugMessage) = 0;
+protected:
+ virtual ~UserDestructibleSyncHandler() {}
+};
+
+/*** Sync-able Damage Data ***/
+
+struct DamageEventUnit;
+/**
+ Damage event header.
+*/
+struct DamageEventHeader
+{
+ uint32_t userActorID; ///< User actor ID
+ uint32_t damageEventCount; ///< Damage event count
+ DamageEventUnit * damageEventBufferStart; ///< damage event buffer size
+ DamageEventHeader * next; ///< Pointer to next DamageEventHeader structure
+};
+
+/**
+ Damage event unit.
+*/
+struct DamageEventUnit
+{
+ uint32_t chunkIndex; ///< Chunk index
+ uint32_t damageEventFlags; ///< Damage event flags
+ float damage; ///< Damage value
+ float momentum; ///< Momentum
+ float radius; ///< Radius
+ PxVec3 position; ///< Position
+ PxVec3 direction; ///< Direction
+};
+
+/*** Sync-able Fracture Data ***/
+
+struct FractureEventUnit;
+
+/**
+ Fracture event header.
+*/
+struct FractureEventHeader
+{
+ uint32_t userActorID; ///< User actor ID
+ uint32_t fractureEventCount; ///< Fracture event count
+ FractureEventUnit * fractureEventBufferStart; ///< Fracture event buffer start
+ FractureEventHeader * next; ///< Pointer to next FractureEventHeader structure
+};
+
+/**
+ Fracture event unit.
+*/
+struct FractureEventUnit
+{
+ uint32_t chunkIndex; ///< Chunk index
+ uint32_t fractureEventFlags; ///< Fracture event flags
+ PxVec3 position; ///< Position
+ PxVec3 direction; ///< Direction
+ PxVec3 impulse; ///< Impulse
+};
+
+/*** Sync-able Transform Data ***/
+
+struct ChunkTransformUnit;
+
+/**
+ Chunk transform header.
+*/
+struct ChunkTransformHeader
+{
+ uint32_t userActorID; ///< User actor ID
+ uint32_t chunkTransformCount; ///< Chunk transform count
+ ChunkTransformUnit * chunkTransformBufferStart; ///< Chunk transform buffer start
+ ChunkTransformHeader * next; ///< Pointer to next ChunkTransformHeader structure
+};
+
+/**
+ Chunk transform unit.
+*/
+struct ChunkTransformUnit
+{
+ uint32_t chunkIndex; ///< Chunk index
+ PxVec3 chunkPosition; ///< Position
+ PxQuat chunkOrientation; ///< Chunk orientation
+};
+
+
+/**
+ Flags for DestructibleActor::raycast()
+*/
+struct DestructibleActorRaycastFlags
+{
+ /**
+ Enum of destructible actor raycast flags.
+ */
+ enum Enum
+ {
+ NoChunks = (0),
+ StaticChunks = (1 << 0),
+ DynamicChunks = (1 << 1),
+
+ AllChunks = StaticChunks | DynamicChunks,
+
+ SegmentIntersect = (1 << 2), ///< Do not consider intersect times > 1
+
+ ForceAccurateRaycastsOn = (1 << 3),
+ ForceAccurateRaycastsOff = (1 << 4),
+ };
+};
+
+
+/**
+ Enum to control when callbacks are fired.
+*/
+struct DestructibleCallbackSchedule
+{
+ /**
+ Enum of destructible callback schedule
+ */
+ enum Enum
+ {
+ Disabled = (0),
+ BeforeTick, ///< Called by the simulation thread
+ FetchResults, ///< Called by an application thread
+
+ Count
+ };
+};
+
+
+/**
+ Descriptor used to create the Destructible APEX module.
+*/
+class ModuleDestructible : public Module
+{
+public:
+ /** Object creation */
+
+ /**
+ Create an DestructibleActorJoint from the descriptor. (See DestructibleActorJoint and
+ DestructibleActorJointDesc.)
+ This module will own the DestructibleActorJoint, so that any DestructibleAsset created by it will
+ be released when this module is released. You may also call the DestructibleActorJoint's release()
+ method, as long as the DestructibleActorJoint is still valid in the scene. (See isDestructibleActorJointActive())
+ */
+ virtual DestructibleActorJoint* createDestructibleActorJoint(const DestructibleActorJointDesc& desc, Scene& scene) = 0;
+
+ /**
+ Query the module on the validity of a created DestructibleActorJoint.
+ A DestructibleActorJoint will no longer be valid when it is destroyed in the scene, in which case the module calls the DestructibleActorJoint's release().
+ Therefore, this DestructibleActorJoint should no longer be referenced if it is not valid.
+ */
+ virtual bool isDestructibleActorJointActive(const DestructibleActorJoint* candidateJoint, Scene& apexScene) const = 0;
+
+ /** LOD */
+
+ /**
+ The maximum number of allowed PxActors which represent dynamic groups of chunks. If a fracturing
+ event would cause more PxActors to be created, then some PxActors are released and the chunks they
+ represent destroyed. The PxActors released to make room for others depends on the priority mode.
+ If sorting by benefit (see setSortByBenefit), then chunks with the lowest LOD benefit are released
+ first. Otherwise, oldest chunks are released first.
+ */
+ virtual void setMaxDynamicChunkIslandCount(uint32_t maxCount) = 0;
+
+ /**
+ The maximum number of allowed visible chunks in the scene. If a fracturing
+ event would cause more chunks to be created, then PxActors are released to make room for the
+ created chunks. The priority for released PxActors is the same as described in
+ setMaxDynamicChunkIslandCount.
+ */
+ virtual void setMaxChunkCount(uint32_t maxCount) = 0;
+
+ /**
+ Instead of keeping the youngest PxActors, keep the greatest benefit PxActors if sortByBenefit is true.
+ By default, this module does not sort by benefit. That is, oldest PxActors are released first.
+ */
+ virtual void setSortByBenefit(bool sortByBenefit) = 0;
+
+ /**
+ Deprecated
+ */
+ virtual void setValidBoundsPadding(float pad) = 0;
+
+ /**
+ Effectively eliminates the deeper level (smaller) chunks from DestructibleAssets (see
+ DestructibleAsset). If maxChunkDepthOffset = 0, all chunks can be fractured. If maxChunkDepthOffset = 1,
+ the depest level (smallest) chunks are eliminated, etc. This prevents too many chunks from being
+ formed. In other words, the higher maxChunkDepthOffset, the lower the "level of detail."
+ */
+ virtual void setMaxChunkDepthOffset(uint32_t maxChunkDepthOffset) = 0;
+
+ /**
+ Every destructible asset defines a min and max lifetime, and maximum separation distance for its chunks.
+ Chunk islands are destroyed after this time or separation from their origins. This parameter sets the
+ lifetimes and max separations within their min-max ranges. The valid range is [0,1]. Default is 0.5.
+ */
+ virtual void setMaxChunkSeparationLOD(float separationLOD) = 0;
+
+
+ /** General */
+ /**
+ Sets the user chunk fracture/destroy callback. See UserChunkReport.
+ Set to NULL (the default) to disable. APEX does not take ownership of the report object.
+ */
+ virtual void setChunkReport(UserChunkReport* chunkReport) = 0;
+
+ /**
+ Sets the user impact damage report callback. See UserImpactDamageReport.
+ Set to NULL (the default) to disable. APEX does not take ownership of the report object.
+ */
+ virtual void setImpactDamageReportCallback(UserImpactDamageReport* impactDamageReport) = 0;
+
+ /**
+ Set a bit mask of flags (see ApexChunkFlag) for the fracture/destroy callback (See setChunkReport.)
+ Fracture events with flags that overlap this mask will contribute to the DamageEventReportData.
+ */
+ virtual void setChunkReportBitMask(uint32_t chunkReportBitMask) = 0;
+
+ /**
+ Sets the user callback to receive PhysX actor create/release notifications for destruction-associated PhysX actors.
+ Set to NULL (the default) to disable.
+ */
+ virtual void setDestructiblePhysXActorReport(UserDestructiblePhysXActorReport* destructiblePhysXActorReport) = 0;
+
+ /**
+ Set the maximum depth at which individual chunk fracture events will be reported in an DamageEventReportData's
+ fractureEventList through the UserChunkReport. Fracture events deeper than this will still contribute to the
+ DamageEventReportData's worldBounds and totalNumberOfFractureEvents.
+ */
+ virtual void setChunkReportMaxFractureEventDepth(uint32_t chunkReportMaxFractureEventDepth) = 0;
+
+ /**
+ Set whether or not the UserChunkReport::onStateChangeNotify interface will be used to deliver visibility
+ change data to the user.
+
+ Default = DestructibleCallbackSchedule::Disabled.
+ */
+ virtual void scheduleChunkStateEventCallback(DestructibleCallbackSchedule::Enum chunkStateEventCallbackSchedule) = 0;
+
+ /**
+ Sets the user chunk crumble particle buffer callback. See UserChunkParticleReport.
+ Set to NULL (the default) to disable. APEX does not take ownership of the report object.
+ */
+ virtual void setChunkCrumbleReport(UserChunkParticleReport* chunkCrumbleReport) = 0;
+
+ /**
+ Sets the user chunk dust particle buffer callback. See UserChunkParticleReport.
+ Set to NULL (the default) to disable. APEX does not take ownership of the report object.
+
+ Note - this is a placeholder API. The dust feature is disabled in 1.2.0.
+ */
+ virtual void setChunkDustReport(UserChunkParticleReport* chunkDustReport) = 0;
+
+ /**
+ PhysX SDK 3.X.
+ Allows the user to specify an alternative PhysX scene to use for world support calculations. If NULL (the default),
+ the PhysX scene associated with the Scene will be used.
+ */
+ virtual void setWorldSupportPhysXScene(Scene& apexScene, PxScene* physxScene) = 0;
+
+ /**
+ PhysX SDK 3.X.
+ Returns true iff the PxRigidActor was created by the Destructible module. If true, the user must NOT destroy the actor.
+ */
+ virtual bool owns(const PxRigidActor* actor) const = 0;
+
+#if APEX_RUNTIME_FRACTURE
+ /**
+ PhysX SDK 3.X.
+ Returns true iff the PxShape was created by the runtime fracture system.
+ */
+ virtual bool isRuntimeFractureShape(const PxShape& shape) const = 0;
+#endif
+
+ /**
+ PhysX SDK 3.X.
+ Given an PxShape, returns the DestructibleActor and chunkIndex which belong to it,
+ if the shape's PxActor is owned by the Destructible module (see the 'owns' function, above). Otherwise returns NULL.
+ Useful when a scene query such as a raycast returns a shape.
+ */
+ virtual DestructibleActor* getDestructibleAndChunk(const PxShape* shape, int32_t* chunkIndex = NULL) const = 0;
+
+ /**
+ Applies damage to all DestructibleActors within the given radius in the apex scene.
+ damage = the amount of damage at the damage point
+ momentum = the magnitude of the impulse to transfer to each chunk
+ position = the damage location
+ radius = distance from damage location at which chunks will be affected
+ falloff = whether or not to decrease damage with distance from the damage location. If true,
+ damage will decrease linearly from the full damage (at zero distance) to zero damage (at radius).
+ If false, full damage is applied to all chunks within the radius.
+ */
+ virtual void applyRadiusDamage(Scene& scene, float damage, float momentum,
+ const PxVec3& position, float radius, bool falloff) = 0;
+
+ /**
+ Lets the user throttle the number of SDK actor creates per frame (per scene) due to destruction, as this can be quite costly.
+ The default is 0xffffffff (unlimited).
+ */
+ virtual void setMaxActorCreatesPerFrame(uint32_t maxActorsPerFrame) = 0;
+
+ /**
+ Lets the user throttle the number of fractures processed per frame (per scene) due to destruction, as this can be quite costly.
+ The default is 0xffffffff (unlimited).
+ */
+ virtual void setMaxFracturesProcessedPerFrame(uint32_t maxFracturesProcessedPerFrame) = 0;
+
+ /**
+ Set the callback pointers from which APEX will use to return sync-able data.
+ */
+ virtual bool setSyncParams(UserDestructibleSyncHandler<DamageEventHeader> * userDamageEventHandler, UserDestructibleSyncHandler<FractureEventHeader> * userFractureEventHandler, UserDestructibleSyncHandler<ChunkTransformHeader> * userChunkMotionHandler) = 0;
+
+ /** The following functions control the use of legacy behavior. */
+
+ /**
+ By default, destruction damage application (either point or radius damage) now use the exact collision bounds
+ of the chunk to determine damage application. Before, bounding spheres were used on "leaf" chunks (deepest in the
+ fracture hierarchy) and only the bounding sphere center (effectively radius 0) was used on all chunks higher in the
+ hierarchy. This led to inconsistent behavior when damaging destructibles at various levels of detail.
+
+ If true is passed into this function, the legacy behavior is restored.
+ */
+ virtual void setUseLegacyChunkBoundsTesting(bool useLegacyChunkBoundsTesting) = 0;
+
+ /**
+ By default, the BehaviorGroup fields damageSpread.minimumRadius, damageSpread.radiusMultiplier, and
+ damageSpread.falloffExponent are used for point and radius damage. Impact damage still uses damageToRadius,
+ but this radius does not scale with the size of the destructible.
+
+ The old, deprecated behavior was to base damage spread upon the damageToRadius field of the BehaviorGroup used
+ by the chunk. Specifically, damage would spread throughout a damage radius calculated as
+ radius = damageToRadius * (damage / damageThreshold) * (size of destructible).
+
+ If true is passed into this function, the legacy behavior is restored.
+ */
+ virtual void setUseLegacyDamageRadiusSpread(bool useLegacyDamageRadiusSpread) = 0;
+
+ /**
+ Sets mass scaling properties in a given apex scene.
+
+ massScale and scaledMassExponent are used for scaling dynamic chunk masses.
+ The 'real' mass m of a chunk is calculated by the destructible actor's density multiplied by
+ the total volume of the chunk's (scaled) collision shapes. The mass used in
+ the simulation is massScale*pow(m/massScale,scaledMassExponent). Values less than 1 have the
+ effect of reducing the ratio of different masses. The closer scaledMassExponent is to zero, the
+ more the ratio will be 'flattened.' This helps PhysX converge when there is a very large number
+ of interacting rigid bodies (such as a pile of destructible chunks).
+
+ massScale valid range: (0,infinity). Default = 1.0.
+ scaledMassExponent valid range: [0,1]. Default = 0.5.
+
+ Returns true iff the parameters are valid and the apexScene is valid.
+ */
+ virtual bool setMassScaling(float massScale, float scaledMassExponent, Scene& apexScene) = 0;
+
+ /**
+ If a static PhysX actor is about to be removed, or has just been added, to the scene, then world support may change.
+ Use this function to notify the destruction module that it may need to reconsider world support in the given volumes.
+ This may be called multiple times, and the bounds list will accumulate. This list will be processed upon the next APEX
+ simulate call, and cleared.
+ */
+ virtual void invalidateBounds(const PxBounds3* bounds, uint32_t boundsCount, Scene& apexScene) = 0;
+
+ /**
+ When applyDamage, or damage from impact, is processed, a rayCast call is used internally to find a more accurate damage position.
+ This allows the user to specify the rayCast behavior. If no flags are set, no raycasting is done. Raycasting will be peformed against
+ static or dynamic chunks, or both, depending on the value of flags. The flags are defined by DestructibleActorRaycastFlags::Enum.
+
+ The default flag used is DestructibleActorRaycastFlags::StaticChunks, since static-only raycasts are faster than ones that include
+ dynamic chunks.
+
+ Note: only the flags DestructibleActorRaycastFlags::NoChunks, StaticChunks, and DynamicChunks are considered.
+ */
+ virtual void setDamageApplicationRaycastFlags(nvidia::DestructibleActorRaycastFlags::Enum flags, Scene& apexScene) = 0;
+
+ /**
+ In PhysX 3.x, scaling of collision shapes can be done in the shape, not the cooked hull data. As a consequence, each collision hull only needs to be cooked
+ once. By default, this hull is not scaled from the original data. But if the user desires, the hull can be scaled before cooking. That scale will be removed from
+ the DestructibleActor's scale before being applied to the shape using the hull. So ideally, this user-set cooking scale does nothing. Numerically, however,
+ it may have an effect, so we leave it as an option.
+
+ The input scale must be positive in all components. If not, the cooking scale will not be set, and the function returns false. Otherwise, the scale is set and
+ the function returns true.
+ */
+ virtual bool setChunkCollisionHullCookingScale(const PxVec3& scale) = 0;
+
+ /**
+ Retrieves the cooking scale used for PhysX3 collision hulls, which can be set by setChunkCollisionHullCookingScale.
+ */
+ virtual PxVec3 getChunkCollisionHullCookingScale() const = 0;
+
+ /**
+ \brief Get reference to FractureTools object.
+ */
+ virtual class FractureToolsAPI* getFractureTools() const = 0;
+
+protected:
+ virtual ~ModuleDestructible() {}
+};
+
+
+#if !defined(_USRDLL)
+/**
+* If this module is distributed as a static library, the user must call this
+* function before calling ApexSDK::createModule("Destructible")
+*/
+void instantiateModuleDestructible();
+#endif
+
+PX_POP_PACK
+
+}
+} // end namespace nvidia
+
+#endif // MODULE_DESTRUCTIBLE_H