aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/destructible/include
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/module/destructible/include
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/module/destructible/include')
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleActorImpl.h975
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleActorJointImpl.h52
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleActorJointProxy.h77
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleActorProxy.h620
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleActorUtils.h401
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleAssetImpl.h916
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleAssetProxy.h923
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleHelpers.h79
-rw-r--r--APEX_1.4/module/destructible/include/DestructiblePreviewImpl.h104
-rw-r--r--APEX_1.4/module/destructible/include/DestructiblePreviewProxy.h123
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleRenderableImpl.h114
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleScene.h1249
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleStructure.h479
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleStructureStressSolver.h413
-rw-r--r--APEX_1.4/module/destructible/include/ModuleDestructibleImpl.h556
-rw-r--r--APEX_1.4/module/destructible/include/ModuleEventDefs.h61
-rw-r--r--APEX_1.4/module/destructible/include/ModulePerfScope.h18
-rw-r--r--APEX_1.4/module/destructible/include/autogen/CachedOverlaps.h245
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleActorChunks.h253
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleActorParam.h606
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleActorState.h445
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleAssetCollisionDataSet.h250
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleAssetParameters.h675
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleDebugRenderParams.h238
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructibleModuleParameters.h237
-rw-r--r--APEX_1.4/module/destructible/include/autogen/DestructiblePreviewParam.h244
-rw-r--r--APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStream.h238
-rw-r--r--APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStreamsAtScale.h238
-rw-r--r--APEX_1.4/module/destructible/include/autogen/ModuleDestructibleRegistration.h150
-rw-r--r--APEX_1.4/module/destructible/include/autogen/SurfaceTraceParameters.h248
-rw-r--r--APEX_1.4/module/destructible/include/autogen/SurfaceTraceSetParameters.h239
31 files changed, 11466 insertions, 0 deletions
diff --git a/APEX_1.4/module/destructible/include/DestructibleActorImpl.h b/APEX_1.4/module/destructible/include/DestructibleActorImpl.h
new file mode 100644
index 00000000..1b258347
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleActorImpl.h
@@ -0,0 +1,975 @@
+/*
+ * 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 __DESTRUCTIBLEACTOR_IMPL_H__
+#define __DESTRUCTIBLEACTOR_IMPL_H__
+
+#include "Apex.h"
+#include "ApexActor.h"
+#include "DestructibleAssetProxy.h"
+#include "DestructibleActorState.h"
+#include "DestructibleActor.h"
+#include "DestructibleStructure.h"
+#include "RenderMeshAssetIntl.h"
+#include "ResourceProviderIntl.h"
+#include "DestructibleRenderableImpl.h"
+#if APEX_RUNTIME_FRACTURE
+#include "SimScene.h"
+#include "../fracture/Actor.h"
+#endif
+
+namespace nvidia
+{
+namespace apex
+{
+class PhysXObjectDescIntl;
+class EmitterActor;
+}
+namespace destructible
+{
+
+class DestructibleScene;
+class DestructibleActorProxy;
+class DestructibleActorJointImpl;
+
+struct PhysXActorFlags
+{
+ enum Enum
+ {
+ DEPTH_PARAM_USER_FLAG_0 = 0,
+ DEPTH_PARAM_USER_FLAG_1,
+ DEPTH_PARAM_USER_FLAG_2,
+ DEPTH_PARAM_USER_FLAG_3,
+ CREATED_THIS_FRAME,
+ IS_SLEEPING // external sleep state tracking to be in sync with mAwakeActorCount that is updated in onWake/onSleep callbacks
+ };
+};
+
+PX_INLINE void PxBounds3Transform(PxBounds3& b, const PxMat44& tm)
+{
+ b = PxBounds3::basisExtent(tm.transform(b.getCenter()), PxMat33(tm.getBasis(0), tm.getBasis(1), tm.getBasis(2)), b.getExtents());
+}
+
+class DestructibleActorImpl : public ApexResource
+ , public ApexActorSource
+ , public ApexActor
+ , public NvParameterized::SerializationCallback
+{
+public:
+
+ friend class DestructibleActorProxy;
+ friend class DestructibleRenderableImpl;
+ friend class DestructibleScopedReadLock;
+ friend class DestructibleScopedWriteLock;
+
+ enum
+ {
+ InvalidID = 0xFFFFFFFF
+ };
+
+ enum Flag
+ {
+ Dynamic = (1 << 0)
+ };
+
+ enum InternalFlag
+ {
+ IslandMarker = (1 << 15)
+ };
+
+public:
+
+ void setState(NvParameterized::Interface* state);
+ const DestructibleActorState* getState() const { return mState; }
+ const DestructibleActorChunks* getChunks() const { return mChunks; }
+ DestructibleActorChunks* getChunks() { return mChunks; }
+ const DestructibleActorParam* getParams() const { return mParams; }
+ DestructibleActorParam* getParams() { return mParams; }
+ const DestructibleParameters& getDestructibleParameters() const { return mDestructibleParameters; }
+ DestructibleParameters& getDestructibleParameters() { return mDestructibleParameters; }
+ void setDestructibleParameters(const DestructibleParameters& destructibleParameters);
+ const DestructibleScene* getDestructibleScene() const { return mDestructibleScene; }
+ DestructibleScene* getDestructibleScene() { return mDestructibleScene; }
+ const DestructibleActor* getAPI() const { return mAPI; }
+ DestructibleActor* getAPI() { return mAPI; }
+
+ void incrementWakeCount(void);
+ void decrementWakeCount(void);
+ void removeActorAtIndex(uint32_t index);
+
+ void setPhysXScene(PxScene*);
+ PxScene* getPhysXScene() const;
+
+ void release();
+ void destroy();
+ void reset();
+
+ virtual void getLodRange(float& min, float& max, bool& intOnly) const;
+ virtual float getActiveLod() const;
+ virtual void forceLod(float lod);
+
+ void cacheModuleData() const;
+ void removeSelfFromStructure();
+ void removeSelfFromScene();
+ bool isInitiallyDynamic() const { return 0 != (getFlags() & (uint32_t)Dynamic); }
+ uint16_t getFlags() const { return mFlags; }
+ uint16_t getInternalFlags() const { return mInternalFlags; }
+ uint16_t& getInternalFlags() { return mInternalFlags; }
+ DestructibleStructure* getStructure() { return mStructure; }
+ const DestructibleStructure*getStructure() const { return mStructure; }
+ void setStructure(DestructibleStructure* s) { mStructure = s; }
+ DestructibleAssetImpl* getDestructibleAsset() { return mAsset; }
+ const DestructibleAssetImpl* getDestructibleAsset() const { return mAsset; }
+ uint32_t getID() const { return mID; }
+ uint32_t& getIDRef() { return mID; }
+ const PxBounds3& getOriginalBounds() const { return mOriginalBounds; }
+ uint32_t getFirstChunkIndex() const { return mFirstChunkIndex; }
+ void setFirstChunkIndex(uint32_t i) { mFirstChunkIndex = i; }
+ const EmitterActor* getCrumbleEmitter() const { return mCrumbleEmitter; }
+ EmitterActor* getCrumbleEmitter() { return mCrumbleEmitter; }
+ float getCrumbleParticleSpacing() const;
+ const EmitterActor* getDustEmitter() const { return mDustEmitter; }
+ EmitterActor* getDustEmitter() { return mDustEmitter; }
+ float getDustParticleSpacing() const;
+ const PxMat44& getInitialGlobalPose() const { return mTM; }
+ void setInitialGlobalPose(const PxMat44& pose);
+ const PxVec3& getScale() const { return mParams->scale; }
+ void setCrumbleEmitterEnabled(bool enabled) { mState->enableCrumbleEmitter = enabled; }
+ bool isCrumbleEmitterEnabled() const { return mState->enableCrumbleEmitter; }
+ void setDustEmitterEnabled(bool enabled) { mState->enableDustEmitter = enabled; }
+ bool isDustEmitterEnabled() const { return mState->enableDustEmitter; }
+ void setCrumbleEmitterName(const char*);
+ const char* getCrumbleEmitterName() const;
+ void setDustEmitterName(const char*);
+ const char* getDustEmitterName() const;
+
+ uint32_t getSupportDepth() const { return mParams->supportDepth; }
+ bool formExtendedStructures() const { return mParams->formExtendedStructures; }
+ bool performDetailedOverlapTestForExtendedStructures() const { return mParams->performDetailedOverlapTestForExtendedStructures; }
+ bool useAssetDefinedSupport() const { return mParams->useAssetDefinedSupport; }
+ bool useWorldSupport() const { return mParams->useWorldSupport; }
+ bool drawStaticChunksInSeparateMesh() const { return mParams->renderStaticChunksSeparately; }
+ bool keepVisibleBonesPacked() const { return mParams->keepVisibleBonesPacked; }
+ bool createChunkEvents() const { return mParams->createChunkEvents; }
+ bool keepPreviousFrameBoneBuffer() const { return mParams->keepPreviousFrameBoneBuffer; }
+ float getSleepVelocityFrameDecayConstant() const { return mParams->sleepVelocityFrameDecayConstant; }
+ bool useHardSleeping() const { return mParams->useHardSleeping; }
+ bool useStressSolver() const { return mParams->structureSettings.useStressSolver; }
+ float getStressSolverTimeDelay() const { return mParams->structureSettings.stressSolverTimeDelay; }
+ float getStressSolverMassThreshold() const { return mParams->structureSettings.stressSolverMassThreshold; }
+
+ void enableHardSleeping();
+ void disableHardSleeping(bool wake);
+ bool setChunkPhysXActorAwakeState(uint32_t chunkIndex, bool awake);
+ bool addForce(uint32_t chunkIndex, const PxVec3& force, physx::PxForceMode::Enum mode, const PxVec3* position = NULL, bool wakeup = true);
+
+ uint32_t getLOD() const { return mState->lod; }
+
+ uint32_t getRenderSubmeshCount()
+ {
+ return mAsset->getRenderMeshAsset()->getSubmeshCount();
+ }
+ uint32_t getAwakeActorCount() const { return mAwakeActorCount; }
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::Actor* getRTActor()
+ {
+ return mRTActor;
+ }
+#endif
+
+ void setGlobalPose(const PxMat44& pose);
+ void setGlobalPoseForStaticChunks(const PxMat44& pose);
+ bool getGlobalPoseForStaticChunks(PxMat44& pose) const;
+
+ void setChunkPose(uint32_t index, PxTransform worldPose);
+ void setLinearVelocity(const PxVec3& linearVelocity);
+ void setAngularVelocity(const PxVec3& angularVelocity);
+
+ void setDynamic(int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, bool immediate = false);
+ bool getDynamic(int32_t chunkIndex) const
+ {
+ PX_ASSERT(mAsset != NULL && mStructure != NULL && chunkIndex >= 0 && chunkIndex < (int32_t)mAsset->getChunkCount());
+ DestructibleStructure::Chunk& chunk = mStructure->chunks[mFirstChunkIndex + chunkIndex];
+ return (chunk.state & ChunkDynamic) != 0;
+ }
+
+ void getChunkVisibilities(uint8_t* visibilityArray, uint32_t visibilityArraySize) const;
+ void setChunkVisibility(uint16_t index, bool visibility);
+
+ // Chunk event buffer API
+ bool acquireChunkEventBuffer(const DestructibleChunkEvent*& buffer, uint32_t& bufferSize);
+ bool releaseChunkEventBuffer(bool clearBuffer = true);
+
+ // PhysX actor buffer API
+ bool acquirePhysXActorBuffer(physx::PxRigidDynamic**& buffer, uint32_t& bufferSize, uint32_t flags);
+ bool releasePhysXActorBuffer();
+
+ float getContactReportThreshold(const DestructibleStructure::Chunk& chunk) const
+ {
+ const DestructibleActorParamNS::BehaviorGroup_Type& behaviorGroup = getBehaviorGroup(chunk.indexInAsset);
+ return getContactReportThreshold(behaviorGroup);
+ }
+
+ float getContactReportThreshold(const DestructibleActorParamNS::BehaviorGroup_Type& behaviorGroup) const
+ {
+ float contactReportThreshold = PX_MAX_F32;
+ if (mDestructibleParameters.forceToDamage > 0)
+ {
+ const float maxEstimatedTimeStep = 0.1f;
+ const float thresholdFraction = 0.5f;
+ const float damageThreshold = behaviorGroup.damageThreshold;
+ contactReportThreshold = thresholdFraction * maxEstimatedTimeStep * damageThreshold / mDestructibleParameters.forceToDamage;
+ }
+
+ return contactReportThreshold;
+ }
+
+ float getAge(float elapsedTime) const { return elapsedTime - mStartTime; }
+
+ bool getUseLegacyChunkBoundsTesting() const;
+ bool getUseLegacyDamageRadiusSpread() const;
+
+ const IndexBank<uint16_t>& getStaticRoots() const { return mStaticRoots; }
+ IndexBank<uint16_t>& getStaticRoots() { return mStaticRoots; }
+
+ uint32_t getNumVisibleChunks() const { return mVisibleChunks.usedCount(); }
+ const uint16_t* getVisibleChunks() const { return mVisibleChunks.usedIndices(); }
+ bool initializedFromState() const { return mInitializedFromState; }
+
+ uint32_t getVisibleDynamicChunkShapeCount() const { return mVisibleDynamicChunkShapeCount; }
+ uint32_t getEssentialVisibleDynamicChunkShapeCount() const { return mEssentialVisibleDynamicChunkShapeCount; }
+
+ void increaseVisibleDynamicChunkShapeCount(const uint32_t number) { mVisibleDynamicChunkShapeCount += number; }
+ void increaseEssentialVisibleDynamicChunkShapeCount(const uint32_t number) { mEssentialVisibleDynamicChunkShapeCount += number; }
+
+ void initializeChunk(uint32_t index, DestructibleStructure::Chunk& chunk) const;
+ bool getInitialChunkDynamic(uint32_t index) const;
+ bool getInitialChunkVisible(uint32_t index) const;
+ bool getInitialChunkDestroyed(uint32_t index) const;
+ PxTransform getInitialChunkGlobalPose(uint32_t index) const;
+ PxTransform getInitialChunkLocalPose(uint32_t index) const;
+ PxVec3 getInitialChunkLinearVelocity(uint32_t index) const;
+ PxVec3 getInitialChunkAngularVelocity(uint32_t index) const;
+ PxTransform getChunkPose(uint32_t index) const;
+ PxTransform getChunkTransform(uint32_t index) const;
+ PxVec3 getChunkLinearVelocity(uint32_t index) const;
+ PxVec3 getChunkAngularVelocity(uint32_t index) const;
+ const PxRigidDynamic* getChunkActor(uint32_t index) const;
+ PxRigidDynamic* getChunkActor(uint32_t index);
+ uint32_t getChunkPhysXShapes(physx::PxShape**& shapes, uint32_t chunkIndex) const;
+ uint32_t getChunkCount() const { return getDestructibleAsset()->getChunkCount(); }
+ const DestructibleStructure::Chunk& getChunk(uint32_t index) const;
+
+ void setBenefit(float benefit) { mBenefit = benefit; }
+ float getBenefit() const { return mBenefit; }
+
+ float getChunkMass(uint32_t index) const
+ {
+ float volume = 0.0f;
+ for (uint32_t hullIndex = mAsset->getChunkHullIndexStart(index); hullIndex < mAsset->getChunkHullIndexStop(index); ++hullIndex)
+ {
+ volume += PxAbs(mAsset->chunkConvexHulls[hullIndex].mParams->volume);
+ }
+
+ // override actor descriptor if (behaviorGroup.density > 0)
+ const DestructibleActorParamNS::BehaviorGroup_Type& behaviorGroup = getBehaviorGroup(index);
+ float density = behaviorGroup.density;
+ if (density == 0)
+ {
+ density = physX3Template.data.density;
+ }
+ return volume * density * PxAbs(getScale().x * getScale().y * getScale().z);
+ }
+
+ const PxMat44 getChunkTM(uint32_t index) const
+ {
+ DestructibleActorMeshType::Enum typeN;
+ if (getDynamic((int32_t)index) || !drawStaticChunksInSeparateMesh())
+ {
+ typeN = DestructibleActorMeshType::Skinned;
+ }
+ else
+ {
+ typeN = DestructibleActorMeshType::Static;
+ index = 0; // Static rendering only has one transform
+ }
+ RenderMeshActor* rma = getRenderMeshActor(typeN);
+ if (rma != NULL)
+ {
+ return rma->getTM(mAsset->getPartIndex(index));
+ }
+ return PxMat44(PxIdentity);
+ }
+
+ int32_t getBehaviorGroupIndex(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mAsset->mParams->chunks.arraySizes[0]);
+ const DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mAsset->mParams->chunks.buf[chunkIndex];
+
+ return (int32_t)sourceChunk.behaviorGroupIndex;
+ }
+
+ uint32_t getChunkActorFlags(uint32_t chunkIndex) const;
+
+ const DestructibleActorParamNS::BehaviorGroup_Type& getBehaviorGroupImp(int8_t behaviorGroupIndex) const
+ {
+ if (behaviorGroupIndex == -1)
+ {
+ return mParams->defaultBehaviorGroup;
+ }
+ else
+ {
+ PX_ASSERT(behaviorGroupIndex < (uint16_t)mParams->behaviorGroups.arraySizes[0]);
+ return mParams->behaviorGroups.buf[behaviorGroupIndex];
+ }
+ }
+
+ const DestructibleActorParamNS::BehaviorGroup_Type& getBehaviorGroup(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mAsset->mParams->chunks.arraySizes[0]);
+ const DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mAsset->mParams->chunks.buf[chunkIndex];
+
+ return getBehaviorGroupImp(sourceChunk.behaviorGroupIndex);
+ }
+
+ const DestructibleActorParamNS::BehaviorGroup_Type& getRTFractureBehaviorGroup() const
+ {
+ return getBehaviorGroupImp(mAsset->mParams->RTFractureBehaviorGroup);
+ }
+
+ void setSkinnedOverrideMaterial(uint32_t index, const char* overrideMaterialName);
+ void setStaticOverrideMaterial(uint32_t index, const char* overrideMaterialName);
+ void setRuntimeFracturePattern(const char* fracturePatternName);
+
+ void updateRenderResources(bool rewriteBuffers, void* userRenderData);
+ void dispatchRenderResources(UserRenderer& renderer);
+
+ void applyDamage(float damage, float momentum, const PxVec3& position, const PxVec3& direction, int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, void* damageUserData = NULL);
+ void applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff, void* damageUserData = NULL);
+
+ void takeImpact(const PxVec3& force, const PxVec3& position, uint16_t chunkIndex, PxActor const* damageActor);
+ bool takesImpactDamageAtDepth(uint32_t depth)
+ {
+ if (depth < mDestructibleParameters.depthParametersCount)
+ {
+ if (mDestructibleParameters.depthParameters[depth].overrideImpactDamage())
+ {
+ return mDestructibleParameters.depthParameters[depth].overrideImpactDamageValue();
+ }
+ }
+ return (int32_t)depth <= mDestructibleParameters.impactDamageDefaultDepth;
+ }
+
+ bool isChunkSolitary(int32_t chunkIndex) const
+ {
+ PX_ASSERT(mAsset != NULL && mStructure != NULL && chunkIndex >= 0 && chunkIndex < (int32_t)mAsset->getChunkCount());
+ DestructibleStructure::Chunk& chunk = mStructure->chunks[mFirstChunkIndex + chunkIndex];
+ return mStructure->chunkIsSolitary( chunk );
+ }
+
+ bool isChunkDestroyed(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(mAsset != NULL && mStructure != NULL && chunkIndex < mAsset->getChunkCount());
+ DestructibleStructure::Chunk& chunk = mStructure->chunks[mFirstChunkIndex + chunkIndex];
+ return chunk.isDestroyed();
+ }
+
+ PxBounds3 getChunkLocalBounds(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(mAsset != NULL && mStructure != NULL && chunkIndex < mAsset->getChunkCount());
+
+ PxBounds3 localBounds = getDestructibleAsset()->getChunkShapeLocalBounds( chunkIndex );
+
+ PxVec3 boundsExtents = localBounds.getExtents();
+ PxVec3 scaledExtents( boundsExtents.x * getScale().x, boundsExtents.y * getScale().y, boundsExtents.z * getScale().z );
+
+ PxBounds3 scaledLocalBounds = PxBounds3::centerExtents( localBounds.getCenter(), scaledExtents );
+
+ return scaledLocalBounds;
+ }
+
+ PxBounds3 getChunkBounds(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(mAsset != NULL && mStructure != NULL && chunkIndex < mAsset->getChunkCount());
+
+ DestructibleStructure::Chunk& chunk = mStructure->chunks[mFirstChunkIndex + chunkIndex];
+ PxMat44 chunkGlobalPose = mStructure->getChunkGlobalPose( chunk );
+
+ PxBounds3 chunkBounds = getDestructibleAsset()->getChunkShapeLocalBounds( chunkIndex );
+
+ // Apply scaling.
+ chunkGlobalPose.scale( PxVec4(getScale(), 1.f) );
+
+ // Transform into actor local space.
+ PxBounds3Transform( chunkBounds, chunkGlobalPose );
+
+ return chunkBounds;
+ }
+
+ uint32_t getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const
+ {
+ return mStructure->getSupportDepthChunkIndices( OutChunkIndices, MaxOutIndices );
+ }
+
+ PxBounds3 getLocalBounds() const
+ {
+ PxBounds3 bounds = getDestructibleAsset()->getBounds();
+ PxVec3 scale = getScale();
+
+ bounds.minimum.x *= scale.x;
+ bounds.minimum.y *= scale.y;
+ bounds.minimum.z *= scale.z;
+
+ bounds.maximum.x *= scale.x;
+ bounds.maximum.y *= scale.y;
+ bounds.maximum.z *= scale.z;
+
+ return bounds;
+ }
+
+ float getLinearSize() const { return mLinearSize; }
+
+ void applyDamage_immediate(struct DamageEvent& damageEvent);
+ void applyRadiusDamage_immediate(struct DamageEvent& damageEvent);
+
+ int32_t rayCast(float& time, PxVec3& normal, const PxVec3& worldRayOrig, const PxVec3& worldRayDir, const DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) const
+ {
+ PX_ASSERT(worldRayOrig.isFinite() && worldRayDir.isFinite());
+
+ PxVec3 worldBoxCenter = worldRayOrig;
+ PxVec3 worldBoxExtents = PxVec3(0.0f, 0.0f, 0.0f);
+ PxMat33 worldBoxRT = PxMat33(PxIdentity);
+ int32_t chunk;
+ if (flags & DestructibleActorRaycastFlags::DynamicChunks)
+ {
+ chunk = pointOrOBBSweep(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRT, worldRayDir, flags, parentChunkIndex);
+ }
+ else
+ {
+ chunk = pointOrOBBSweepStatic(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRT, worldRayDir, flags, parentChunkIndex);
+ }
+#if APEX_RUNTIME_FRACTURE
+ if (mRTActor != NULL)
+ {
+ float rtTime = PX_MAX_F32;
+ // TODO: Refactor the runtime actor raycasting to use a more sensible approach
+ // (Perhaps we can re-use some of the existing pointOrOBBSweep code
+ if (mRTActor->rayCast(worldRayOrig, worldRayDir, rtTime) &&
+ (chunk == ModuleDestructibleConst::INVALID_CHUNK_INDEX || rtTime < time))
+ {
+ time = rtTime;
+ chunk = 0;
+ }
+ }
+#endif
+ return chunk;
+ }
+
+ int32_t obbSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRT, const PxVec3& worldDisplacement, DestructibleActorRaycastFlags::Enum flags) const
+ {
+ if (flags & DestructibleActorRaycastFlags::DynamicChunks)
+ {
+ return pointOrOBBSweep(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRT, worldDisplacement, flags, ModuleDestructibleConst::INVALID_CHUNK_INDEX);
+ }
+ else
+ {
+ return pointOrOBBSweepStatic(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRT, worldDisplacement, flags, ModuleDestructibleConst::INVALID_CHUNK_INDEX);
+ }
+ }
+
+ void setActorObjDescFlags(class PhysXObjectDescIntl* actorObjDesc, uint32_t depth) const;
+
+ void fillInstanceBuffers();
+ void setRenderTMs(bool processChunkPoseForSyncing = false);
+ void setRelativeTMs();
+
+ virtual bool recreateApexEmitter(DestructibleEmitterType::Enum type);
+ bool initCrumbleSystem(const char* crumbleEmitterName);
+ bool initDustSystem(const char* dustEmitterName);
+ bool initFracturePattern(const char* fracturePatternName);
+
+ virtual void preSerialize(void *userData = NULL);
+
+ virtual void setPreferredRenderVolume(RenderVolume* volume, DestructibleEmitterType::Enum type);
+ virtual EmitterActor* getApexEmitter(DestructibleEmitterType::Enum type);
+
+ void spawnParticles(class EmitterActor* emitter, UserChunkParticleReport* report, DestructibleStructure::Chunk& chunk, physx::Array<PxVec3>& positions, bool deriveVelocitiesFromChunk = false, const PxVec3* overrideVelocity = NULL);
+
+ void setDeleteFracturedChunks(bool inDeleteChunkMode);
+
+ bool useDamageColoring()
+ {
+ return mUseDamageColoring;
+ }
+
+ /**
+ Return ture means these core data of Damage Event should be saved for the damage coloring
+ */
+ bool applyDamageColoring(uint16_t indexInAsset, const PxVec3& position, float damage, float damageRadius);
+ bool applyDamageColoringRecursive(uint16_t indexInAsset, const PxVec3& position, float damage, float damageRadius);
+
+ void fillBehaviorGroupDesc(DestructibleBehaviorGroupDesc& behaviorGroupDesc, const DestructibleActorParamNS::BehaviorGroup_Type behaviorGroup) const;
+
+ /*** Public behavior group functions ***/
+ uint32_t getCustomBehaviorGroupCount() const
+ {
+ return (uint32_t)mParams->behaviorGroups.arraySizes[0];
+ }
+
+ bool getBehaviorGroup(DestructibleBehaviorGroupDesc& behaviorGroupDesc, int32_t index) const
+ {
+ if (index == -1)
+ {
+ fillBehaviorGroupDesc(behaviorGroupDesc, mParams->defaultBehaviorGroup);
+ return true;
+ }
+ if (index >= 0 && index < (int32_t)mParams->behaviorGroups.arraySizes[0])
+ {
+ fillBehaviorGroupDesc(behaviorGroupDesc, mParams->behaviorGroups.buf[index]);
+ return true;
+ }
+ return false;
+ }
+
+ /*** DestructibleHitChunk operations ***/
+ bool setHitChunkTrackingParams(bool flushHistory, bool startTracking, uint32_t trackingDepth, bool trackAllChunks = true);
+ bool getHitChunkHistory(const DestructibleHitChunk *& hitChunkContainer, uint32_t & hitChunkCount) const;
+ bool forceChunkHits(const DestructibleHitChunk * hitChunkContainer, uint32_t hitChunkCount, bool removeChunks = true, bool deferredEvent = false, PxVec3 damagePosition = PxVec3(0.0f), PxVec3 damageDirection = PxVec3(0.0f));
+ void evaluateForHitChunkList(const FractureEvent & fractureEvent);
+
+ struct CachedHitChunk : public DestructibleHitChunk
+ {
+ CachedHitChunk(uint32_t chunkIndex_, uint32_t hitChunkFlags_)
+ {
+#if defined WIN32
+ extern char enforce[sizeof(*this) == sizeof(DestructibleHitChunk)?1:-1];
+#endif // WIN32
+ DestructibleHitChunk::chunkIndex = chunkIndex_;
+ DestructibleHitChunk::hitChunkFlags = hitChunkFlags_;
+ }
+ ~CachedHitChunk() {}
+ private:
+ CachedHitChunk();
+ };
+
+ /*** Damage Coloring ***/
+ bool getDamageColoringHistory(const DamageEventCoreData *& damageEventCoreDataContainer, uint32_t & damageEventCoreDataCount) const;
+ bool forceDamageColoring(const DamageEventCoreData * damageEventCoreDataContainer, uint32_t damageEventCoreDataCount);
+ void collectDamageColoring(const int32_t indexInAsset, const PxVec3& position, const float damage, const float damageRadius);
+ void applyDamageColoring_immediate(const int32_t indexInAsset, const PxVec3& position, const float damage, const float damageRadius);
+
+ struct CachedDamageEventCoreData : public DamageEventCoreData
+ {
+ CachedDamageEventCoreData(int32_t chunkIndex_, PxVec3 position_, float damage_, float radius_)
+ {
+#if defined WIN32
+ extern char enforce[sizeof(*this) == sizeof(DamageEventCoreData)?1:-1];
+#endif // WIN32
+ DamageEventCoreData::chunkIndexInAsset = chunkIndex_;
+ DamageEventCoreData::position = position_;
+ DamageEventCoreData::damage = damage_;
+ DamageEventCoreData::radius = radius_;
+ }
+ ~CachedDamageEventCoreData() {}
+ private:
+ CachedDamageEventCoreData();
+ };
+
+private:
+ struct HitChunkParams
+ {
+ public:
+ HitChunkParams():cacheChunkHits(false),cacheAllChunks(false),trackingDepth(0)
+ {
+ manualFractureEventInstance.position = PxVec3(0.0f);
+ manualFractureEventInstance.impulse = PxVec3(0.0f);
+ manualFractureEventInstance.hitDirection = PxVec3(0.0f);
+ }
+ ~HitChunkParams() {}
+ bool cacheChunkHits;
+ bool cacheAllChunks;
+ uint32_t trackingDepth;
+ physx::Array<CachedHitChunk> hitChunkContainer;
+ FractureEvent manualFractureEventInstance;
+ } hitChunkParams;
+
+ /*** structure for damage coloring ***/
+ struct DamageColoringParams
+ {
+ physx::Array<CachedDamageEventCoreData> damageEventCoreDataContainer;
+ SyncDamageEventCoreDataParams damageEventCoreDataInstance;
+ } damageColoringParams;
+
+
+ /*** DestructibleActor::SyncParams ***/
+public:
+ bool setSyncParams(uint32_t userActorID, uint32_t actorSyncFlags, const DestructibleActorSyncState * actorSyncState, const DestructibleChunkSyncState * chunkSyncState);
+public:
+ class SyncParams
+ {
+ friend bool DestructibleActorImpl::setSyncParams(uint32_t, uint32_t, const DestructibleActorSyncState *, const DestructibleChunkSyncState *);
+ public:
+ SyncParams();
+ ~SyncParams();
+ uint32_t getUserActorID() const;
+ bool isSyncFlagSet(DestructibleActorSyncFlags::Enum flag) const;
+ const DestructibleActorSyncState * getActorSyncState() const;
+ const DestructibleChunkSyncState * getChunkSyncState() const;
+
+ void pushDamageBufferIndex(uint32_t index);
+ void pushFractureBufferIndex(uint32_t index);
+ void pushCachedChunkTransform(const CachedChunk & cachedChunk);
+
+ const physx::Array<uint32_t> & getDamageBufferIndices() const;
+ const physx::Array<uint32_t> & getFractureBufferIndices() const;
+ const physx::Array<CachedChunk> & getCachedChunkTransforms() const;
+
+ template<typename Unit> void clear();
+ template<typename Unit> uint32_t getCount() const;
+ private:
+ DECLARE_DISABLE_COPY_AND_ASSIGN(SyncParams);
+ void onReset();
+ uint32_t userActorID;
+ uint32_t actorSyncFlags;
+ bool useActorSyncState;
+ DestructibleActorSyncState actorSyncState;
+ bool useChunkSyncState;
+ DestructibleChunkSyncState chunkSyncState;
+
+ physx::Array<uint32_t> damageBufferIndices;
+ physx::Array<uint32_t> fractureBufferIndices;
+ physx::Array<CachedChunk> cachedChunkTransforms;
+ };
+
+ const DestructibleActorImpl::SyncParams & getSyncParams() const;
+ DestructibleActorImpl::SyncParams & getSyncParamsMutable();
+private:
+ SyncParams mSyncParams;
+
+private:
+ DestructibleActorImpl(DestructibleActor* _api, DestructibleAssetImpl& _asset, DestructibleScene& scene);
+ virtual ~DestructibleActorImpl();
+
+ void initialize(NvParameterized::Interface* stateOrParams);
+ void initializeFromState(NvParameterized::Interface* state);
+ void initializeFromParams(NvParameterized::Interface* params);
+ void initializeCommon(void);
+ void createRenderable(void);
+ void initializeActor(void);
+ void initializeRTActor(void);
+ void initializeEmitters(void);
+ void deinitialize(void);
+
+ void setDestructibleParameters(const DestructibleActorParamNS::DestructibleParameters_Type& destructibleParameters,
+ const DestructibleActorParamNS::DestructibleDepthParameters_DynamicArray1D_Type& destructibleDepthParameters);
+
+ int32_t pointOrOBBSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRT, const PxVec3& worldDisp,
+ DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex) const;
+
+ int32_t pointOrOBBSweepStatic(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRT, const PxVec3& pxWorldDisp,
+ DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex) const;
+
+ void wakeUp(void);
+ void putToSleep(void);
+
+ // Renderable support:
+public:
+ Renderable* getRenderable()
+ {
+ return static_cast<Renderable*>(mRenderable);
+ }
+ DestructibleRenderable* acquireRenderableReference();
+ RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const;
+
+private:
+
+ DestructibleActorState* mState; // Destructible asset state, contains data for serialization
+
+ // Cached parameters
+ DestructibleActorParam* mParams; // Destructible actor params, this is just a convenient reference to the params in mState
+ DestructibleActorChunks* mChunks; // Destructible actor chunks, this is just a convenient reference to the chunks in mState
+
+ // Read-write cached parameters (require writeback on preSerialization)
+ DestructibleParameters mDestructibleParameters;
+ PxMat44 mTM;
+ PxMat44 mRelTM; // Relative transform between the actor
+
+ // Derived parameters
+ IndexBank<uint16_t> mStaticRoots;
+ IndexBank<uint16_t> mVisibleChunks;
+ uint32_t mVisibleDynamicChunkShapeCount;
+ uint32_t mEssentialVisibleDynamicChunkShapeCount;
+ DestructibleScene* mDestructibleScene;
+ DestructibleActor* mAPI;
+ uint16_t mFlags;
+ uint16_t mInternalFlags; // Internal flags, currently indicates whether the actor has been marked as being part of an 'island' or not.
+ DestructibleStructure* mStructure; // The destructible structure that this actor is a member of. Multiple destructible actors can belong to a single destructible structure.
+ DestructibleAssetImpl* mAsset; // The asset associated with this actor.
+ uint32_t mID; // A unique 32 bit GUID given to this actor.
+ float mLinearSize;
+ PxBounds3 mOriginalBounds;
+ PxBounds3 mNonInstancedBounds; // Recording this separately, since instanced buffers get updated separately
+ PxBounds3 mInstancedBounds; // Recording this separately, since instanced buffers get updated separately
+ uint32_t mFirstChunkIndex; // This first chunk index used from the destructible structure
+ EmitterActor* mCrumbleEmitter; // The crumble emitter associated with this actor.
+ EmitterActor* mDustEmitter; // The dust emitter associated with this actor.
+ RenderVolume* mCrumbleRenderVolume; // The render volume to use for crumble effects.
+ RenderVolume* mDustRenderVolume; // The render volume to use for dust effects.
+ float mStartTime; // Time the actor became "alive."
+ float mBenefit;
+ bool mInitializedFromState; // Whether the actor was initialized from state
+ physx::Array<DestructibleChunkEvent> mChunkEventBuffer;
+ nvidia::Mutex mChunkEventBufferLock;
+
+ physx::Array<physx::PxRigidDynamic*> mPhysXActorBuffer;
+
+ nvidia::Mutex mPhysXActorBufferLock;
+
+ DestructibleRenderableImpl* mRenderable;
+
+ physx::Array< physx::Array<ColorRGBA> > mDamageColorArrays;
+ bool mUseDamageColoring;
+
+ uint32_t mDescOverrideSkinnedMaterialCount;
+ const char** mDescOverrideSkinnedMaterials;
+ uint32_t mDescOverrideStaticMaterialCount;
+ const char** mDescOverrideStaticMaterials;
+ bool mPhysXActorBufferAcquired;
+public:
+ bool mInDeleteChunkMode;
+
+ uint32_t mAwakeActorCount; // number of awake PxActors.
+ uint32_t mActiveFrames; // Bit representation of active frame history. Only used when mDestructibleScene->mUsingActiveTransforms == true
+
+ uint32_t mDamageEventReportIndex;
+
+#if USE_DESTRUCTIBLE_RWLOCK
+ shdfnd::ReadWriteLock* mLock;
+#endif
+
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::Actor* mRTActor;
+#endif
+
+ bool mWakeForEvent;
+
+ physx::Array<PxRigidDynamic*> mReferencingActors;
+
+public:
+ void referencedByActor(PxRigidDynamic* actor);
+ void unreferencedByActor(PxRigidDynamic* actor);
+
+ PxRigidDynamic** getReferencingActors(uint32_t& count)
+ {
+ count = mReferencingActors.size();
+ return count ? &mReferencingActors[0] : NULL;
+ }
+
+ void wakeForEvent();
+ void resetWakeForEvent();
+
+public:
+
+ PxConvexMesh* getConvexMesh(uint32_t hullIndex)
+ {
+ if (mAsset->mCollisionMeshes == NULL)
+ {
+ mAsset->mCollisionMeshes = mAsset->module->mCachedData->getConvexMeshesForScale(*mAsset, mAsset->module->getChunkCollisionHullCookingScale());
+ PX_ASSERT(mAsset->mCollisionMeshes != NULL);
+ if (mAsset->mCollisionMeshes == NULL)
+ {
+ return NULL;
+ }
+ }
+ return (*mAsset->mCollisionMeshes)[hullIndex];
+ }
+};
+
+
+struct DamageEvent : public DamageEventCoreData
+{
+ // Default constructor for a damage event.
+ DamageEvent() :
+ destructibleID((uint32_t)DestructibleActorImpl::InvalidID),
+ momentum(0.0f),
+ direction(PxVec3(0.0f, 0.0f, 1.0f)),
+ flags(0),
+ impactDamageActor(NULL),
+ appliedDamageUserData(NULL),
+ minDepth(0),
+ maxDepth(0),
+ processDepth(0)
+ {
+ DamageEventCoreData::chunkIndexInAsset = 0;
+ DamageEventCoreData::damage = 0.0f;
+ DamageEventCoreData::radius = 0.0f;
+ DamageEventCoreData::position = PxVec3(0.0f);
+
+ for (uint32_t i = 0; i <= MaxDepth; ++i)
+ {
+ cost[i] = benefit[i] = 0;
+ new(fractures + i) physx::Array<FractureEvent>();
+ }
+ }
+
+ // Copy constructor for a damage event.
+ DamageEvent(const DamageEvent& that)
+ {
+ destructibleID = that.destructibleID;
+ damage = that.damage;
+ momentum = that.momentum;
+ radius = that.radius;
+ position = that.position;
+ direction = that.direction;
+ chunkIndexInAsset = that.chunkIndexInAsset;
+ flags = that.flags;
+
+ minDepth = that.minDepth;
+ maxDepth = that.maxDepth;
+ processDepth = that.processDepth;
+
+ impactDamageActor = that.impactDamageActor;
+ appliedDamageUserData = that.appliedDamageUserData;
+
+ for (uint32_t i = 0; i < MaxDepth + 1; i++)
+ {
+ cost[i] = that.cost[i];
+ benefit[i] = that.benefit[i];
+ fractures[i] = that.fractures[i];
+ }
+ }
+
+ ~DamageEvent()
+ {
+ for (uint32_t i = MaxDepth + 1; i--;)
+ {
+ fractures[i].reset();
+ }
+ }
+
+ // Deep copy of one damage event to another.
+ DamageEvent& operator=(const DamageEvent& that)
+ {
+ if (this != &that)
+ {
+ destructibleID = that.destructibleID;
+ damage = that.damage;
+ momentum = that.momentum;
+ radius = that.radius;
+ position = that.position;
+ direction = that.direction;
+ chunkIndexInAsset = that.chunkIndexInAsset;
+ flags = that.flags;
+
+ minDepth = that.minDepth;
+ maxDepth = that.maxDepth;
+ processDepth = that.processDepth;
+
+ impactDamageActor = that.impactDamageActor;
+ appliedDamageUserData = that.appliedDamageUserData;
+
+ for (uint32_t i = 0; i < MaxDepth + 1; i++)
+ {
+ cost[i] = that.cost[i];
+ benefit[i] = that.benefit[i];
+ fractures[i] = that.fractures[i];
+ }
+ }
+ return *this;
+
+ }
+
+ enum Flag
+ {
+ UseRadius = (1U << 0), // Indicates whether or not to process the damage event as a radius based effect
+ HasFalloff = (1U << 1), // Indicates whether or not the damage amount (for radius damage) falls off with distance from the impact.
+ IsFromImpact = (1U << 2), // Indicates that this is an impact event, where damage is applied to specific chunk rather than radius based damage.
+ SyncDirect = (1U << 3), // Indicates whether this is a sync-ed damage event
+ DeleteChunkModeUnused = (1U << 30), // Indicates whether or not to delete the chunk instead of breaking it off. Propagates down to FractureEvent.
+
+ Invalid = (1U << 31) // Indicates that this event is invalid (can occur when a destructible is removed)
+ };
+
+ uint32_t destructibleID; // The ID of the destructible actor that is being damaged.
+ float momentum; // The inherited momentum of the damage event.
+ PxVec3 direction; // The direction of the damage event.
+ uint32_t flags; // Flags which indicate whether this damage event is radius based and if we use a fall off computation for the amount of damage.
+ physx::PxActor const* impactDamageActor;// Other PhysX actor that caused damage to ApexDamageEventReportData.
+
+ void* appliedDamageUserData; // User data from applyDamage or applyRadiusDamage.
+
+ enum
+ {
+ MaxDepth = 5
+ };
+
+ PX_INLINE uint32_t getMinDepth() const
+ {
+ return minDepth;
+ }
+ PX_INLINE uint32_t getMaxDepth() const
+ {
+ return maxDepth;
+ }
+ PX_INLINE uint32_t getProcessDepth() const
+ {
+ return processDepth;
+ }
+ PX_INLINE float getCost(uint32_t depth = 0xFFFFFFFF) const
+ {
+ return cost[depth <= MaxDepth ? depth : processDepth];
+ }
+ PX_INLINE float getBenefit(uint32_t depth = 0xFFFFFFFF) const
+ {
+ return benefit[depth <= MaxDepth ? depth : processDepth];
+ }
+ PX_INLINE bool isFromImpact(void) const
+ {
+ return flags & IsFromImpact ? true : false;
+ };
+
+ void resetFracturesInternal()
+ {
+ for(uint32_t index = DamageEvent::MaxDepth + 1; index--; )
+ {
+ fractures[index].reset();
+ }
+ }
+private:
+ uint32_t minDepth; // The minimum structure depth that this damage event can apply to.
+ uint32_t maxDepth; // The maximum structure depth that this damage event can apply to.
+ uint32_t processDepth; // The exact depth that the damage event applies to.
+ float cost[MaxDepth + 1]; // The LOD 'cost' at each depth for this damage event.
+ float benefit[MaxDepth + 1]; // The LOD 'benefit' at each depth for this damage event.
+ physx::Array<FractureEvent> fractures[MaxDepth + 1]; // The array of fracture events associated with this damage event.
+
+ friend class DestructibleScene;
+ friend class DestructibleActorImpl;
+};
+
+#if USE_DESTRUCTIBLE_RWLOCK
+class DestructibleScopedReadLock : public physx::ScopedReadLock
+{
+public:
+ DestructibleScopedReadLock(DestructibleActorImpl& destructible) : physx::ScopedReadLock(*destructible.mLock) {}
+};
+
+class DestructibleScopedWriteLock : public physx::ScopedWriteLock
+{
+public:
+ DestructibleScopedWriteLock(DestructibleActorImpl& destructible) : physx::ScopedWriteLock(*destructible.mLock) {}
+};
+#endif
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEACTOR_IMPL_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleActorJointImpl.h b/APEX_1.4/module/destructible/include/DestructibleActorJointImpl.h
new file mode 100644
index 00000000..e1abcee3
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleActorJointImpl.h
@@ -0,0 +1,52 @@
+/*
+ * 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_IMPL_H__
+#define __DESTRUCTIBLE_ACTOR_JOINT_IMPL_H__
+
+#include "Apex.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class DestructibleActorJointDesc;
+}
+namespace destructible
+{
+class DestructibleStructure;
+class DestructibleScene;
+
+class DestructibleActorJointImpl : public ApexResource
+{
+public:
+ DestructibleActorJointImpl(const DestructibleActorJointDesc& destructibleActorJointDesc, DestructibleScene& dscene);
+
+ virtual ~DestructibleActorJointImpl();
+
+ PxJoint* getJoint()
+ {
+ return joint;
+ }
+
+ bool updateJoint();
+
+protected:
+
+ PxJoint* joint;
+ DestructibleStructure* structure[2];
+ int32_t attachmentChunkIndex[2];
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLE_ACTOR_JOINT_IMPL_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleActorJointProxy.h b/APEX_1.4/module/destructible/include/DestructibleActorJointProxy.h
new file mode 100644
index 00000000..2ea9721a
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleActorJointProxy.h
@@ -0,0 +1,77 @@
+/*
+ * 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 __DESTRUCTIBLEACTORJOINT_PROXY_H__
+#define __DESTRUCTIBLEACTORJOINT_PROXY_H__
+
+#include "Apex.h"
+#include "DestructibleActorJoint.h"
+#include "DestructibleActorJointImpl.h"
+#include "PsUserAllocated.h"
+#include "ApexRWLockable.h"
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class DestructibleScene; // Forward declaration
+
+class DestructibleActorJointProxy : public DestructibleActorJoint, public ApexResourceInterface, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructibleActorJointImpl impl;
+
+#pragma warning(disable : 4355) // disable warning about this pointer in argument list
+ DestructibleActorJointProxy(const DestructibleActorJointDesc& destructibleActorJointDesc, DestructibleScene& dscene, ResourceList& list) :
+ impl(destructibleActorJointDesc, dscene)
+ {
+ list.add(*this);
+ };
+
+ ~DestructibleActorJointProxy()
+ {
+ };
+
+ // DestructibleActorJoint methods
+ virtual PxJoint* joint()
+ {
+ WRITE_ZONE();
+ return impl.getJoint();
+ }
+
+ virtual void release()
+ {
+ // impl.release();
+ delete this;
+ };
+
+ // ApexResourceInterface methods
+ virtual void setListIndex(ResourceList& list, uint32_t index)
+ {
+ impl.m_listIndex = index;
+ impl.m_list = &list;
+ }
+
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEACTORJOINT_PROXY_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleActorProxy.h b/APEX_1.4/module/destructible/include/DestructibleActorProxy.h
new file mode 100644
index 00000000..66aa7aa2
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleActorProxy.h
@@ -0,0 +1,620 @@
+/*
+ * 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 __DESTRUCTIBLEACTOR_PROXY_H__
+#define __DESTRUCTIBLEACTOR_PROXY_H__
+
+#include "Apex.h"
+#include "DestructibleActor.h"
+#include "DestructibleActorJointProxy.h"
+#include "DestructibleActorImpl.h"
+#include "DestructibleScene.h"
+#include "PsUserAllocated.h"
+#include "ApexActor.h"
+#if APEX_USE_PARTICLES
+#include "EmitterActor.h"
+#endif
+
+#include "ApexRWLockable.h"
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class DestructibleActorProxy : public DestructibleActor, public ApexResourceInterface, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructibleActorImpl impl;
+
+#pragma warning(disable : 4355) // disable warning about this pointer in argument list
+ DestructibleActorProxy(const NvParameterized::Interface& input, DestructibleAssetImpl& asset, ResourceList& list, DestructibleScene& scene)
+ : impl(this, asset, scene)
+ {
+ WRITE_ZONE();
+ NvParameterized::Interface* clonedInput = NULL;
+ input.clone(clonedInput);
+ list.add(*this); // Doing this before impl.initialize, since the render proxy created in that function wants a unique ID (only needs to be unique at any given time, can be recycled)
+ impl.initialize(clonedInput);
+ }
+
+ DestructibleActorProxy(NvParameterized::Interface* input, DestructibleAssetImpl& asset, ResourceList& list, DestructibleScene& scene)
+ : impl(this, asset, scene)
+ {
+ WRITE_ZONE();
+ impl.initialize(input);
+ list.add(*this);
+ }
+
+ ~DestructibleActorProxy()
+ {
+ }
+
+ virtual const DestructibleParameters& getDestructibleParameters() const
+ {
+ READ_ZONE();
+ return impl.getDestructibleParameters();
+ }
+
+ virtual void setDestructibleParameters(const DestructibleParameters& destructibleParameters)
+ {
+ WRITE_ZONE();
+ impl.setDestructibleParameters(destructibleParameters);
+ }
+
+ virtual const RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const
+ {
+ READ_ZONE();
+ return impl.getRenderMeshActor(type);
+ }
+
+ virtual PxMat44 getInitialGlobalPose() const
+ {
+ READ_ZONE();
+ return impl.getInitialGlobalPose();
+ }
+
+ virtual void setInitialGlobalPose(const PxMat44& pose)
+ {
+ WRITE_ZONE();
+ impl.setInitialGlobalPose(pose);
+ }
+
+ virtual PxVec3 getScale() const
+ {
+ READ_ZONE();
+ return impl.getScale();
+ }
+
+ virtual void applyDamage(float damage, float momentum, const PxVec3& position, const PxVec3& direction, int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, void* damageActorUserData = NULL)
+ {
+ WRITE_ZONE();
+ return impl.applyDamage(damage, momentum, position, direction, chunkIndex, damageActorUserData);
+ }
+
+ virtual void applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff, void* damageActorUserData = NULL)
+ {
+ WRITE_ZONE();
+ return impl.applyRadiusDamage(damage, momentum, position, radius, falloff, damageActorUserData);
+ }
+
+ virtual void getChunkVisibilities(uint8_t* visibilityArray, uint32_t visibilityArraySize) const
+ {
+ READ_ZONE();
+ impl.getChunkVisibilities(visibilityArray, visibilityArraySize);
+ }
+
+ virtual uint32_t getNumVisibleChunks() const
+ {
+ READ_ZONE();
+ return impl.getNumVisibleChunks();
+ }
+
+ virtual const uint16_t* getVisibleChunks() const
+ {
+ READ_ZONE();
+ return impl.getVisibleChunks();
+ }
+
+ virtual bool acquireChunkEventBuffer(const DestructibleChunkEvent*& buffer, uint32_t& bufferSize)
+ {
+ READ_ZONE();
+ return impl.acquireChunkEventBuffer(buffer, bufferSize);
+ }
+
+ virtual bool releaseChunkEventBuffer(bool clearBuffer = true)
+ {
+ READ_ZONE();
+ return impl.releaseChunkEventBuffer(clearBuffer);
+ }
+
+ virtual bool acquirePhysXActorBuffer(physx::PxRigidDynamic**& buffer, uint32_t& bufferSize, uint32_t flags = DestructiblePhysXActorQueryFlags::AllStates)
+ {
+ READ_ZONE();
+ return impl.acquirePhysXActorBuffer(buffer, bufferSize, flags);
+ }
+
+ virtual bool releasePhysXActorBuffer()
+ {
+ READ_ZONE();
+ return impl.releasePhysXActorBuffer();
+ }
+
+ virtual physx::PxRigidDynamic* getChunkPhysXActor(uint32_t index)
+ {
+ READ_ZONE();
+ physx::PxActor* actor = impl.getChunkActor(index);
+ PX_ASSERT(actor == NULL || actor->is<physx::PxRigidDynamic>());
+ return (physx::PxRigidDynamic*)actor;
+ }
+
+ virtual uint32_t getChunkPhysXShapes(physx::PxShape**& shapes, uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkPhysXShapes(shapes, chunkIndex);
+ }
+
+ virtual PxTransform getChunkPose(uint32_t index) const
+ {
+ READ_ZONE();
+ return impl.getChunkPose(index);
+ }
+
+ virtual PxTransform getChunkTransform(uint32_t index) const
+ {
+ READ_ZONE();
+ return impl.getChunkTransform(index);
+ }
+
+ virtual PxVec3 getChunkLinearVelocity(uint32_t index) const
+ {
+ READ_ZONE();
+ return impl.getChunkLinearVelocity(index);
+ }
+
+ virtual PxVec3 getChunkAngularVelocity(uint32_t index) const
+ {
+ READ_ZONE();
+ return impl.getChunkAngularVelocity(index);
+ }
+
+ virtual const PxMat44 getChunkTM(uint32_t index) const
+ {
+ READ_ZONE();
+ return impl.getChunkTM(index);
+ }
+
+ virtual int32_t getChunkBehaviorGroupIndex(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getBehaviorGroupIndex(chunkIndex);
+ }
+
+ virtual uint32_t getChunkActorFlags(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkActorFlags(chunkIndex);
+ }
+
+ virtual bool isChunkDestroyed(int32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.isChunkDestroyed((uint32_t)chunkIndex);
+ }
+
+ virtual void setSkinnedOverrideMaterial(uint32_t index, const char* overrideMaterialName)
+ {
+ WRITE_ZONE();
+ impl.setSkinnedOverrideMaterial(index, overrideMaterialName);
+ }
+
+ virtual void setStaticOverrideMaterial(uint32_t index, const char* overrideMaterialName)
+ {
+ WRITE_ZONE();
+ impl.setStaticOverrideMaterial(index, overrideMaterialName);
+ }
+
+ virtual void setRuntimeFractureOverridePattern(const char* overridePatternName)
+ {
+ WRITE_ZONE();
+ impl.setRuntimeFracturePattern(overridePatternName);
+ }
+
+ virtual bool isInitiallyDynamic() const
+ {
+ READ_ZONE();
+ return impl.isInitiallyDynamic();
+ }
+
+ virtual void setLinearVelocity(const PxVec3& linearVelocity)
+ {
+ WRITE_ZONE();
+ impl.setLinearVelocity(linearVelocity);
+ }
+
+ virtual void setGlobalPose(const PxMat44& pose)
+ {
+ WRITE_ZONE();
+ impl.setGlobalPose(pose);
+ }
+
+ virtual bool getGlobalPose(PxMat44& pose)
+ {
+ READ_ZONE();
+ return impl.getGlobalPoseForStaticChunks(pose);
+ }
+
+ virtual void setAngularVelocity(const PxVec3& angularVelocity)
+ {
+ WRITE_ZONE();
+ impl.setAngularVelocity(angularVelocity);
+ }
+
+ virtual void setDynamic(int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX)
+ {
+ WRITE_ZONE();
+ impl.setDynamic(chunkIndex);
+ }
+
+ virtual bool isDynamic(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ if (impl.getDestructibleAsset() != NULL && chunkIndex < impl.getDestructibleAsset()->getChunkCount())
+ {
+ return impl.getDynamic((int32_t)chunkIndex);
+ }
+ return false;
+ }
+
+ virtual void enableHardSleeping()
+ {
+ WRITE_ZONE();
+ impl.enableHardSleeping();
+ }
+
+ virtual void disableHardSleeping(bool wake = false)
+ {
+ WRITE_ZONE();
+ impl.disableHardSleeping(wake);
+ }
+
+ virtual bool isHardSleepingEnabled() const
+ {
+ READ_ZONE();
+ return impl.useHardSleeping();
+ }
+
+ virtual bool setChunkPhysXActorAwakeState(uint32_t chunkIndex, bool awake)
+ {
+ WRITE_ZONE();
+ return impl.setChunkPhysXActorAwakeState(chunkIndex, awake);
+ }
+
+ virtual bool addForce(uint32_t chunkIndex, const PxVec3& force, physx::PxForceMode::Enum mode, const PxVec3* position = NULL, bool wakeup = true)
+ {
+ WRITE_ZONE();
+ return impl.addForce(chunkIndex, force, mode, position, wakeup);
+ }
+
+ 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
+ {
+ READ_ZONE();
+ return impl.rayCast(time, normal, worldRayOrig, worldRayDir, flags, parentChunkIndex);
+ }
+
+ virtual int32_t obbSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRot, const PxVec3& worldDisplacement, DestructibleActorRaycastFlags::Enum flags) const
+ {
+ READ_ZONE();
+ return impl.obbSweep(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRot, worldDisplacement, flags);
+ }
+
+ virtual void cacheModuleData() const
+ {
+ READ_ZONE();
+ return impl.cacheModuleData();
+ }
+
+ virtual PxBounds3 getLocalBounds() const
+ {
+ READ_ZONE();
+ return impl.getLocalBounds();
+ }
+
+ virtual PxBounds3 getOriginalBounds() const
+ {
+ READ_ZONE();
+ return impl.getOriginalBounds();
+ }
+
+ virtual bool isChunkSolitary(int32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.isChunkSolitary( chunkIndex );
+ }
+
+ virtual PxBounds3 getChunkBounds(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkBounds( chunkIndex );
+ }
+
+ virtual PxBounds3 getChunkLocalBounds(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkLocalBounds( chunkIndex );
+ }
+
+ virtual uint32_t getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const
+ {
+ READ_ZONE();
+ return impl.getSupportDepthChunkIndices( OutChunkIndices, MaxOutIndices );
+ }
+
+ virtual uint32_t getSupportDepth() const
+ {
+ READ_ZONE();
+ return impl.getSupportDepth();
+ }
+
+ // Actor methods
+ virtual Asset* getOwner() const
+ {
+ READ_ZONE();
+ return impl.mAsset->getAsset();
+ }
+ virtual void release()
+ {
+ impl.release();
+ }
+ virtual void destroy()
+ {
+ impl.destroy();
+
+ delete this;
+ }
+
+ virtual DestructibleRenderable* acquireRenderableReference()
+ {
+ return impl.acquireRenderableReference();
+ }
+
+ // Renderable methods
+ virtual void updateRenderResources(bool rewriteBuffers, void* userRenderData)
+ {
+ URR_SCOPE;
+ impl.updateRenderResources(rewriteBuffers, userRenderData);
+ }
+
+ virtual void dispatchRenderResources(UserRenderer& api)
+ {
+ impl.dispatchRenderResources(api);
+ }
+
+ virtual void lockRenderResources()
+ {
+ Renderable* renderable = impl.getRenderable();
+ if (renderable != NULL)
+ {
+ renderable->lockRenderResources();
+ }
+ }
+
+ virtual void unlockRenderResources()
+ {
+ Renderable* renderable = impl.getRenderable();
+ if (renderable != NULL)
+ {
+ renderable->unlockRenderResources();
+ }
+ }
+
+ virtual PxBounds3 getBounds() const
+ {
+ READ_ZONE();
+ Renderable* renderable = const_cast<DestructibleActorImpl*>(&impl)->getRenderable();
+ if (renderable != NULL)
+ {
+ return renderable->getBounds();
+ }
+ return impl.getBounds();
+ }
+
+ virtual void setPhysX3Template(const PhysX3DescTemplate* desc)
+ {
+ WRITE_ZONE();
+ impl.setPhysX3Template(desc);
+ }
+
+ virtual bool getPhysX3Template(PhysX3DescTemplate& dest) const
+ {
+ READ_ZONE();
+ return impl.getPhysX3Template(dest);
+ }
+
+ PhysX3DescTemplate* createPhysX3DescTemplate() const
+ {
+ return impl.createPhysX3DescTemplate();
+ }
+
+ // ApexResourceInterface methods
+ virtual void setListIndex(ResourceList& list, uint32_t index)
+ {
+ WRITE_ZONE();
+ impl.m_listIndex = index;
+ impl.m_list = &list;
+ }
+ virtual uint32_t getListIndex() const
+ {
+ READ_ZONE();
+ return impl.m_listIndex;
+ }
+
+ virtual void getLodRange(float& min, float& max, bool& intOnly) const
+ {
+ READ_ZONE();
+ impl.getLodRange(min, max, intOnly);
+ }
+
+ virtual float getActiveLod() const
+ {
+ READ_ZONE();
+ return impl.getActiveLod();
+ }
+
+ virtual void forceLod(float lod)
+ {
+ WRITE_ZONE();
+ impl.forceLod(lod);
+ }
+
+ /**
+ \brief Selectively enables/disables debug visualization of a specific APEX actor. Default value it true.
+ */
+ virtual void setEnableDebugVisualization(bool state)
+ {
+ WRITE_ZONE();
+ impl.setEnableDebugVisualization(state);
+ }
+
+
+ virtual void setCrumbleEmitterState(bool enable)
+ {
+ WRITE_ZONE();
+ impl.setCrumbleEmitterEnabled(enable);
+ }
+
+ virtual void setDustEmitterState(bool enable)
+ {
+ WRITE_ZONE();
+ impl.setDustEmitterEnabled(enable);
+ }
+
+ /**
+ Sets a preferred render volume for a dust or crumble emitter
+ */
+ virtual void setPreferredRenderVolume(RenderVolume* volume, DestructibleEmitterType::Enum type)
+ {
+ WRITE_ZONE();
+ impl.setPreferredRenderVolume(volume, type);
+ }
+
+ virtual EmitterActor* getApexEmitter(DestructibleEmitterType::Enum type)
+ {
+ READ_ZONE();
+ return impl.getApexEmitter(type);
+ }
+
+ virtual bool recreateApexEmitter(DestructibleEmitterType::Enum type)
+ {
+ WRITE_ZONE();
+ return impl.recreateApexEmitter(type);
+ }
+
+ const NvParameterized::Interface* getNvParameterized(DestructibleParameterizedType::Enum type) const
+ {
+ READ_ZONE();
+ switch (type)
+ {
+ case DestructibleParameterizedType::State:
+ return (const NvParameterized::Interface*)impl.getState();
+ case DestructibleParameterizedType::Params:
+ return (const NvParameterized::Interface*)impl.getParams();
+ default:
+ return NULL;
+ }
+ }
+
+ void setNvParameterized(NvParameterized::Interface* params)
+ {
+ WRITE_ZONE();
+ impl.initialize(params);
+ }
+
+ const NvParameterized::Interface* getChunks() const
+ {
+ return (const NvParameterized::Interface*)impl.getChunks();
+ }
+
+ void setChunks(NvParameterized::Interface* chunks)
+ {
+ impl.initialize(chunks);
+ }
+
+ virtual bool setSyncParams(uint32_t userActorID, uint32_t actorSyncFlags, const DestructibleActorSyncState * actorSyncState, const DestructibleChunkSyncState * chunkSyncState)
+ {
+ WRITE_ZONE();
+ return impl.setSyncParams(userActorID, actorSyncFlags, actorSyncState, chunkSyncState);
+ }
+
+ virtual bool setHitChunkTrackingParams(bool flushHistory, bool startTracking, uint32_t trackingDepth, bool trackAllChunks)
+ {
+ WRITE_ZONE();
+ return impl.setHitChunkTrackingParams(flushHistory, startTracking, trackingDepth, trackAllChunks);
+ }
+
+ virtual bool getHitChunkHistory(const DestructibleHitChunk *& hitChunkContainer, uint32_t & hitChunkCount) const
+ {
+ READ_ZONE();
+ return impl.getHitChunkHistory(hitChunkContainer, hitChunkCount);
+ }
+
+ 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))
+ {
+ WRITE_ZONE();
+ return impl.forceChunkHits(hitChunkContainer, hitChunkCount, removeChunks, deferredEvent, damagePosition, damageDirection);
+ }
+
+ virtual bool getDamageColoringHistory(const DamageEventCoreData *& damageEventCoreDataContainer, uint32_t & damageEventCoreDataCount) const
+ {
+ READ_ZONE();
+ return impl.getDamageColoringHistory(damageEventCoreDataContainer, damageEventCoreDataCount);
+ }
+
+ virtual bool forceDamageColoring(const DamageEventCoreData * damageEventCoreDataContainer, uint32_t damageEventCoreDataCount)
+ {
+ WRITE_ZONE();
+ return impl.forceDamageColoring(damageEventCoreDataContainer, damageEventCoreDataCount);
+ }
+
+ virtual void setDeleteFracturedChunks(bool inDeleteChunkMode)
+ {
+ WRITE_ZONE();
+ impl.setDeleteFracturedChunks(inDeleteChunkMode);
+ }
+
+ virtual void takeImpact(const PxVec3& force, const PxVec3& position, uint16_t chunkIndex, PxActor const* damageImpactActor)
+ {
+ WRITE_ZONE();
+ impl.takeImpact(force, position, chunkIndex, damageImpactActor);
+ }
+
+ virtual uint32_t getCustomBehaviorGroupCount() const
+ {
+ READ_ZONE();
+ return impl.getCustomBehaviorGroupCount();
+ }
+
+ virtual bool getBehaviorGroup(DestructibleBehaviorGroupDesc& behaviorGroupDesc, int32_t index = -1) const
+ {
+ READ_ZONE();
+ return impl.getBehaviorGroup(behaviorGroupDesc, index);
+ }
+};
+
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEACTOR_PROXY_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleActorUtils.h b/APEX_1.4/module/destructible/include/DestructibleActorUtils.h
new file mode 100644
index 00000000..a8d2cf37
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleActorUtils.h
@@ -0,0 +1,401 @@
+/*
+ * 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 __DESTRUCTIBLEACTORUTILS_H__
+#define __DESTRUCTIBLEACTORUTILS_H__
+
+#include "ApexDefs.h"
+#include "DestructibleActorImpl.h"
+#include "PxPhysics.h"
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#ifdef _DEBUG
+#define VERIFY_PARAM(_A) PX_ASSERT((_A) == NvParameterized::ERROR_NONE)
+#else
+#define VERIFY_PARAM(_A) (_A)
+#endif
+
+
+enum AssignType {
+ AtoB,
+ BtoA,
+ Default = BtoA,
+ Inverse = AtoB
+};
+
+static const bool Serialize = true;
+static const bool Deserialize = false;
+
+///////////////////////////////////////////////////////////////////////////
+
+static const char* typeName(DestructibleParameterizedType::Enum e)
+{
+ const char* typeName = "";
+ switch (e)
+ {
+ case DestructibleParameterizedType::State:
+ typeName = DestructibleActorState::staticClassName();
+ break;
+ case DestructibleParameterizedType::Params:
+ typeName = DestructibleActorParam::staticClassName();
+ break;
+ default:
+ break;
+ }
+ return typeName;
+}
+
+PX_INLINE static bool isType(NvParameterized::Interface* i, DestructibleParameterizedType::Enum e)
+{
+ return nvidia::stricmp(i->className(), typeName(e)) == 0;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+template <typename T, typename FlagType>
+PX_INLINE void assignFlag(T& val, FlagType flag, bool setFlag)
+{
+ val = (T)(setFlag ? (val | (T)flag) : (val & ~(T)flag));
+}
+
+template <typename T, typename FlagType>
+PX_INLINE void assignFlag(bool& flagSet, const T& val, FlagType flag)
+{
+ flagSet = (val & flag) ? true : false;
+}
+
+template<typename T, typename FlagType>
+PX_INLINE void assignFlags(T& a, FlagType flag, bool& b, AssignType assignType)
+{
+ if (BtoA == assignType)
+ assignFlag(a, flag, b);
+ else
+ assignFlag(b, a, flag);
+}
+
+template<typename T, typename U>
+PX_INLINE void assign(T& a, U& b, AssignType assignType)
+{
+ if(AtoB == assignType)
+ b = static_cast<U>(a);
+ else
+ a = static_cast<T>(b);
+}
+
+template<typename T, typename U, typename T1, typename U1>
+PX_INLINE void assignPtr(T1& a, U1& b, AssignType assignType)
+{
+ if(AtoB == assignType)
+ b = (U)a;
+ else
+ a = (T)b;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+void assign(PhysX3DescTemplateImpl& descA,
+ DestructibleActorParamNS::P3ActorDescTemplate_Type& descB0,
+ DestructibleActorParamNS::P3BodyDescTemplate_Type& descB1,
+ DestructibleActorParamNS::P3ShapeDescTemplate_Type& descB2,
+ AssignType assignType = Default)
+{
+ // actor
+ assign(descA.dominanceGroup , descB0.dominanceGroup, assignType);
+ assign(descA.ownerClient , descB0.ownerClient, assignType);
+ assign(descA.clientBehaviorBits, descB0.clientBehaviorBits, assignType);
+
+ assignFlags(descA.actorFlags, physx::PxActorFlag::eVISUALIZATION, descB0.flags.eVISUALIZATION, assignType);
+ assignFlags(descA.actorFlags, physx::PxActorFlag::eDISABLE_GRAVITY, descB0.flags.eDISABLE_GRAVITY, assignType);
+ assignFlags(descA.actorFlags, physx::PxActorFlag::eSEND_SLEEP_NOTIFIES, descB0.flags.eSEND_SLEEP_NOTIFIES, assignType);
+
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eSOLVE_CONTACT, descB0.contactReportFlags.eSOLVE_CONTACT, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eMODIFY_CONTACTS, descB0.contactReportFlags.eMODIFY_CONTACTS, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_TOUCH_FOUND, descB0.contactReportFlags.eNOTIFY_TOUCH_FOUND, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_TOUCH_PERSISTS, descB0.contactReportFlags.eNOTIFY_TOUCH_PERSISTS, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_TOUCH_LOST, descB0.contactReportFlags.eNOTIFY_TOUCH_LOST, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_FOUND, descB0.contactReportFlags.eNOTIFY_THRESHOLD_FORCE_FOUND, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_PERSISTS, descB0.contactReportFlags.eNOTIFY_THRESHOLD_FORCE_PERSISTS, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST, descB0.contactReportFlags.eNOTIFY_THRESHOLD_FORCE_LOST, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eNOTIFY_CONTACT_POINTS, descB0.contactReportFlags.eNOTIFY_CONTACT_POINTS, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eDETECT_CCD_CONTACT, descB0.contactReportFlags.eDETECT_CCD_CONTACT, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eCONTACT_DEFAULT, descB0.contactReportFlags.eCONTACT_DEFAULT, assignType);
+ assignFlags(descA.contactReportFlags, physx::PxPairFlag::eTRIGGER_DEFAULT, descB0.contactReportFlags.eTRIGGER_DEFAULT, assignType);
+ assignPtr<void*,size_t>(descA.userData, descB0.userData, assignType);
+ assignPtr<const char*,size_t>(descA.name, descB0.name, assignType);
+
+ // body
+ assignFlags(descA.bodyFlags, PxRigidBodyFlag::eKINEMATIC, descB1.flags.eKINEMATIC, assignType);
+ assignFlags(descA.bodyFlags, PxRigidBodyFlag::eENABLE_CCD, descB1.flags.eENABLE_CCD, assignType);
+ assign(descA.density , descB1.density, assignType);
+ assign(descA.sleepThreshold , descB1.sleepThreshold, assignType);
+ assign(descA.wakeUpCounter , descB1.wakeUpCounter, assignType);
+ assign(descA.linearDamping , descB1.linearDamping, assignType);
+ assign(descA.angularDamping , descB1.angularDamping, assignType);
+ assign(descA.maxAngularVelocity , descB1.maxAngularVelocity, assignType);
+ assign(descA.solverIterationCount , descB1.solverIterationCount, assignType);
+ assign(descA.velocityIterationCount , descB1.velocityIterationCount, assignType);
+ assign(descA.contactReportThreshold , descB1.contactReportThreshold, assignType);
+ assign(descA.sleepLinearVelocity , descB1.sleepLinearVelocity, assignType);
+
+ // shape
+ assignFlags(descA.shapeFlags, PxShapeFlag::eSIMULATION_SHAPE, descB2.flags.eSIMULATION_SHAPE, assignType);
+ assignFlags(descA.shapeFlags, PxShapeFlag::eSCENE_QUERY_SHAPE, descB2.flags.eSCENE_QUERY_SHAPE, assignType);
+ assignFlags(descA.shapeFlags, PxShapeFlag::eTRIGGER_SHAPE, descB2.flags.eTRIGGER_SHAPE, assignType);
+ assignFlags(descA.shapeFlags, PxShapeFlag::eVISUALIZATION, descB2.flags.eVISUALIZATION, assignType);
+ assignFlags(descA.shapeFlags, PxShapeFlag::ePARTICLE_DRAIN, descB2.flags.ePARTICLE_DRAIN, assignType);
+
+ // TODO: Remove this from the NvParameterized destructible actor, shift it to the BODY descriptor?
+ //assignFlags(descA.shapeFlags, PxShapeFlag::eUSE_SWEPT_BOUNDS, descB2.flags.eUSE_SWEPT_BOUNDS, assignType);
+
+ assign(descA.simulationFilterData.word0 , descB2.simulationFilterData.word0, assignType);
+ assign(descA.simulationFilterData.word1 , descB2.simulationFilterData.word1, assignType);
+ assign(descA.simulationFilterData.word2 , descB2.simulationFilterData.word2, assignType);
+ assign(descA.simulationFilterData.word3 , descB2.simulationFilterData.word3, assignType);
+ assign(descA.queryFilterData.word0 , descB2.queryFilterData.word0, assignType);
+ assign(descA.queryFilterData.word1 , descB2.queryFilterData.word1, assignType);
+ assign(descA.queryFilterData.word2 , descB2.queryFilterData.word2, assignType);
+ assign(descA.queryFilterData.word3 , descB2.queryFilterData.word3, assignType);
+ assign(descA.contactOffset , descB2.contactOffset, assignType);
+ assign(descA.restOffset , descB2.restOffset, assignType);
+ assignPtr<void*,size_t>(descA.shapeUserData , descB2.userData, assignType);
+ assignPtr<const char*, size_t>(descA.shapeName, descB2.name, assignType);
+
+ if (BtoA == assignType)
+ {
+ PxMaterial* material = NULL;
+ if (descB2.material)
+ material = (PxMaterial*)descB2.material;
+ else
+ {
+ // Get the first material as a fallback
+ if (GetApexSDK()->getPhysXSDK()->getNbMaterials())
+ GetApexSDK()->getPhysXSDK()->getMaterials(&material, 1, 0);
+ }
+ if (NULL != material)
+ {
+ descA.materials.pushBack(material);
+ }
+ }
+ else
+ descB2.material = descA.materials.size() > 0 ? (size_t)descA.materials[0] : (uint64_t)0;
+}
+
+PX_INLINE void deserialize(PhysX3DescTemplateImpl& descA,
+ const DestructibleActorParamNS::P3ActorDescTemplate_Type& descB0,
+ const DestructibleActorParamNS::P3BodyDescTemplate_Type& descB1,
+ const DestructibleActorParamNS::P3ShapeDescTemplate_Type& descB2)
+{
+ assign(descA,
+ const_cast<DestructibleActorParamNS::P3ActorDescTemplate_Type&>(descB0),
+ const_cast<DestructibleActorParamNS::P3BodyDescTemplate_Type&>(descB1),
+ const_cast<DestructibleActorParamNS::P3ShapeDescTemplate_Type&>(descB2), BtoA);
+}
+
+PX_INLINE void serialize(const PhysX3DescTemplateImpl& descA,
+ DestructibleActorParamNS::P3ActorDescTemplate_Type& descB0,
+ DestructibleActorParamNS::P3BodyDescTemplate_Type& descB1,
+ DestructibleActorParamNS::P3ShapeDescTemplate_Type& descB2)
+{
+ assign(const_cast<PhysX3DescTemplateImpl&>(descA), descB0, descB1, descB2, AtoB);
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+PX_INLINE void assign(DestructibleDepthParameters& paramA,
+ DestructibleActorParamNS::DestructibleDepthParameters_Type& paramB,
+ AssignType assignType = Default)
+{
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE, paramB.OVERRIDE_IMPACT_DAMAGE, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE_VALUE, paramB.OVERRIDE_IMPACT_DAMAGE_VALUE, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::IGNORE_POSE_UPDATES, paramB.IGNORE_POSE_UPDATES, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::IGNORE_RAYCAST_CALLBACKS, paramB.IGNORE_RAYCAST_CALLBACKS, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::IGNORE_CONTACT_CALLBACKS, paramB.IGNORE_CONTACT_CALLBACKS, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::USER_FLAG_0, paramB.USER_FLAG_0, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::USER_FLAG_1, paramB.USER_FLAG_1, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::USER_FLAG_2, paramB.USER_FLAG_2, assignType);
+ assignFlags(paramA.flags, DestructibleDepthParametersFlag::USER_FLAG_3, paramB.USER_FLAG_3, assignType);
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+PX_INLINE void assign(DestructibleParameters& paramA,
+ DestructibleActorParamNS::DestructibleParameters_Type& paramB,
+ AssignType assignType = Default)
+{
+ assign(paramA.damageCap , paramB.damageCap, assignType);
+ assign(paramA.debrisDepth , paramB.debrisDepth, assignType);
+ assign(paramA.debrisLifetimeMax , paramB.debrisLifetimeMax, assignType);
+ assign(paramA.debrisLifetimeMin , paramB.debrisLifetimeMin, assignType);
+ assign(paramA.debrisMaxSeparationMax , paramB.debrisMaxSeparationMax, assignType);
+ assign(paramA.debrisMaxSeparationMin , paramB.debrisMaxSeparationMin, assignType);
+ assign(paramA.essentialDepth , paramB.essentialDepth, assignType);
+ assign(paramA.forceToDamage , paramB.forceToDamage, assignType);
+ assign(paramA.fractureImpulseScale , paramB.fractureImpulseScale, assignType);
+ assign(paramA.damageDepthLimit , paramB.damageDepthLimit, assignType);
+ assign(paramA.impactVelocityThreshold , paramB.impactVelocityThreshold, assignType);
+ assign(paramA.maxChunkSpeed , paramB.maxChunkSpeed, assignType);
+ assign(paramA.minimumFractureDepth , paramB.minimumFractureDepth, assignType);
+ assign(paramA.impactDamageDefaultDepth , paramB.impactDamageDefaultDepth, assignType);
+ assign(paramA.debrisDestructionProbability , paramB.debrisDestructionProbability, assignType);
+ assign(paramA.validBounds , paramB.validBounds, assignType);
+ assign(paramA.dynamicChunksDominanceGroup , paramB.dynamicChunkDominanceGroup, assignType);
+ assign(paramA.useDynamicChunksGroupsMask , paramB.dynamicChunksGroupsMask.useGroupsMask, assignType);
+ assign(paramA.dynamicChunksFilterData.word0 , paramB.dynamicChunksGroupsMask.bits0, assignType);
+ assign(paramA.dynamicChunksFilterData.word1 , paramB.dynamicChunksGroupsMask.bits1, assignType);
+ assign(paramA.dynamicChunksFilterData.word2 , paramB.dynamicChunksGroupsMask.bits2, assignType);
+ assign(paramA.dynamicChunksFilterData.word3 , paramB.dynamicChunksGroupsMask.bits3, assignType);
+ assign(paramA.supportStrength , paramB.supportStrength, assignType);
+ assign(paramA.legacyChunkBoundsTestSetting , paramB.legacyChunkBoundsTestSetting, assignType);
+ assign(paramA.legacyDamageRadiusSpreadSetting , paramB.legacyDamageRadiusSpreadSetting, assignType);
+
+ assignFlags(paramA.flags, DestructibleParametersFlag::ACCUMULATE_DAMAGE, paramB.flags.ACCUMULATE_DAMAGE, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::DEBRIS_TIMEOUT, paramB.flags.DEBRIS_TIMEOUT, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::DEBRIS_MAX_SEPARATION, paramB.flags.DEBRIS_MAX_SEPARATION, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::CRUMBLE_SMALLEST_CHUNKS, paramB.flags.CRUMBLE_SMALLEST_CHUNKS, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::ACCURATE_RAYCASTS, paramB.flags.ACCURATE_RAYCASTS, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::USE_VALID_BOUNDS, paramB.flags.USE_VALID_BOUNDS, assignType);
+ assignFlags(paramA.flags, DestructibleParametersFlag::CRUMBLE_VIA_RUNTIME_FRACTURE, paramB.flags.CRUMBLE_VIA_RUNTIME_FRACTURE, assignType);
+
+ // RT Fracture assign
+ assign(paramA.rtFractureParameters.sheetFracture, paramB.runtimeFracture.sheetFracture, assignType);
+ assign(paramA.rtFractureParameters.depthLimit, paramB.runtimeFracture.depthLimit, assignType);
+ assign(paramA.rtFractureParameters.destroyIfAtDepthLimit, paramB.runtimeFracture.destroyIfAtDepthLimit, assignType);
+ assign(paramA.rtFractureParameters.minConvexSize, paramB.runtimeFracture.minConvexSize, assignType);
+ assign(paramA.rtFractureParameters.impulseScale, paramB.runtimeFracture.impulseScale, assignType);
+ assign(paramA.rtFractureParameters.glass.numSectors, paramB.runtimeFracture.glass.numSectors, assignType);
+ assign(paramA.rtFractureParameters.glass.sectorRand, paramB.runtimeFracture.glass.sectorRand, assignType);
+ assign(paramA.rtFractureParameters.glass.firstSegmentSize, paramB.runtimeFracture.glass.firstSegmentSize, assignType);
+ assign(paramA.rtFractureParameters.glass.segmentScale, paramB.runtimeFracture.glass.segmentScale, assignType);
+ assign(paramA.rtFractureParameters.glass.segmentRand, paramB.runtimeFracture.glass.segmentRand, assignType);
+ assign(paramA.rtFractureParameters.attachment.posX, paramB.runtimeFracture.attachment.posX, assignType);
+ assign(paramA.rtFractureParameters.attachment.negX, paramB.runtimeFracture.attachment.negX, assignType);
+ assign(paramA.rtFractureParameters.attachment.posY, paramB.runtimeFracture.attachment.posY, assignType);
+ assign(paramA.rtFractureParameters.attachment.negY, paramB.runtimeFracture.attachment.negY, assignType);
+ assign(paramA.rtFractureParameters.attachment.posZ, paramB.runtimeFracture.attachment.posZ, assignType);
+ assign(paramA.rtFractureParameters.attachment.negZ, paramB.runtimeFracture.attachment.negZ, assignType);
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+template<typename A, typename B>
+PX_INLINE void deserialize(A& paramA, const B& paramB)
+{
+ assign(paramA, const_cast<B&>(paramB), BtoA);
+}
+
+template<typename A, typename B>
+PX_INLINE void serialize(const A& paramA, B& paramB)
+{
+ assign(const_cast<A&>(paramA), paramB, AtoB);
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+PX_INLINE void serialize(const DestructibleParameters& nxIn,
+ NvParameterized::Interface& nxOut)
+{
+ if (isType(&nxOut, DestructibleParameterizedType::Params))
+ {
+ DestructibleActorParam& nxOutParams = static_cast<DestructibleActorParam&>(nxOut);
+ NvParameterized::Handle handle(nxOutParams);
+ VERIFY_PARAM(nxOutParams.getParameterHandle("depthParameters", handle));
+ nxOutParams.resizeArray(handle, (int32_t)nxIn.depthParametersCount);
+
+ serialize(nxIn, nxOutParams.destructibleParameters);
+
+ PX_ASSERT(nxOutParams.depthParameters.arraySizes[0] == (int32_t)nxIn.depthParametersCount);
+ for (uint32_t i = 0; i < nxIn.depthParametersCount; ++i)
+ {
+ serialize(nxIn.depthParameters[i], nxOutParams.depthParameters.buf[i]);
+ }
+ }
+}
+
+PX_INLINE void deserialize(const DestructibleActorParamNS::DestructibleParameters_Type& nxIn,
+ const DestructibleActorParamNS::DestructibleDepthParameters_DynamicArray1D_Type& nxIn2,
+ DestructibleParameters& nxOut)
+{
+ deserialize(nxOut, const_cast<DestructibleActorParamNS::DestructibleParameters_Type&>(nxIn));
+ nxOut.depthParametersCount = (uint32_t)nxIn2.arraySizes[0];
+ for (uint32_t depth = 0; depth < nxOut.depthParametersCount; ++depth)
+ {
+ deserialize(nxOut.depthParameters[depth], nxIn2.buf[depth]);
+ }
+}
+
+PX_INLINE void serialize(const DestructibleActorImpl& actor,
+ const DestructibleStructure::Chunk* nxIn,
+ const uint32_t nxInCount,
+ DestructibleActorChunks& nxOut)
+{
+ if (nxInCount <= 0)
+ return;
+
+ NvParameterized::Handle handle(nxOut);
+ VERIFY_PARAM(nxOut.getParameterHandle("data", handle));
+ nxOut.resizeArray(handle, (int32_t)nxInCount);
+ PX_ASSERT((int32_t)nxInCount == nxOut.data.arraySizes[0]);
+
+ for (uint32_t i = 0; i < nxInCount; ++i)
+ {
+ nxOut.data.buf[i].state = nxIn[i].state;
+ nxOut.data.buf[i].flags = nxIn[i].flags;
+ nxOut.data.buf[i].islandID = nxIn[i].islandID;
+ nxOut.data.buf[i].damage = nxIn[i].damage;
+ nxOut.data.buf[i].localOffset = nxIn[i].localOffset;
+ nxOut.data.buf[i].localSphere = PxVec4(nxIn[i].localSphereCenter, nxIn[i].localSphereRadius);
+ nxOut.data.buf[i].shapesCount = (nxIn[i].isDestroyed() || !(nxIn[i].state & ChunkVisible)) ? 0 : nxIn[i].getShapeCount();
+
+ if (nxIn[i].visibleAncestorIndex != (int32_t)DestructibleStructure::InvalidChunkIndex)
+ nxOut.data.buf[i].visibleAncestorIndex = nxIn[i].visibleAncestorIndex - (int32_t)actor.getFirstChunkIndex();
+ else
+ nxOut.data.buf[i].visibleAncestorIndex = (int32_t)DestructibleStructure::InvalidChunkIndex;
+
+ if (!nxIn[i].isDestroyed())
+ {
+ // BRG - shouldn't this state be obtained from nxIn[i].state? In any case, must decouple this now since we have "dormant" kinematic chunks
+ // which are chunks that have been freed but turned kinematic for "hard" sleeping
+// const bool chunkDynamic = !actor.getChunkActor(i)->readBodyFlag(BF_KINEMATIC);
+// assignFlag(nxOut.data.buf[i].state, ChunkDynamic, chunkDynamic);
+
+ nxOut.data.buf[i].linearVelocity = actor.getChunkLinearVelocity(i);
+ nxOut.data.buf[i].angularVelocity = actor.getChunkAngularVelocity(i);
+ nxOut.data.buf[i].globalPose = actor.getChunkPose(i);
+ nxOut.data.buf[i].globalPose.q.normalize();
+ }
+ }
+}
+
+PX_INLINE void deserializeChunkData(const DestructibleActorChunksNS::Chunk_Type& nxIn, DestructibleStructure::Chunk& nxOut)
+{
+ nxOut.state = nxIn.state;
+ nxOut.flags = nxIn.flags;
+ nxOut.damage = nxIn.damage;
+ nxOut.localOffset = nxIn.localOffset;
+ nxOut.localSphereCenter = nxIn.localSphere.getXYZ();
+ nxOut.localSphereRadius = nxIn.localSphere.w;
+ nxOut.islandID = nxIn.islandID;
+ nxOut.clearShapes();
+ // Poses and velocities are restored later as chunks are actually created
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+}
+} // end namespace nvidia
+
+
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/DestructibleAssetImpl.h b/APEX_1.4/module/destructible/include/DestructibleAssetImpl.h
new file mode 100644
index 00000000..28267af4
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleAssetImpl.h
@@ -0,0 +1,916 @@
+/*
+ * 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_IMPL_H
+#define DESTRUCTIBLE_ASSET_IMPL_H
+
+#include "Apex.h"
+#include "PsArray.h"
+#include "ApexSDKHelpers.h"
+#include "DestructibleAsset.h"
+#include "ApexSharedUtils.h"
+#include "ApexAssetTracker.h"
+#include "DestructibleActorParam.h"
+#include "ApexUsingNamespace.h"
+#include "DestructibleAssetParameters.h"
+#include "MeshCookedCollisionStreamsAtScale.h"
+#include "MeshCookedCollisionStream.h"
+#include "DestructibleAssetCollisionDataSet.h"
+#include "CachedOverlaps.h"
+
+#include "PxConvexMesh.h"
+
+#include "authoring/Fracturing.h"
+
+#include "ApexActor.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class DestructiblePreview;
+}
+namespace destructible
+{
+class ModuleDestructibleImpl;
+
+
+/**
+ Descriptor used to create a Destructible actor.
+*/
+class DestructibleActorDesc : public ApexDesc
+{
+public:
+
+ /**
+ \brief Constructor sets to default.
+ */
+ PX_INLINE DestructibleActorDesc() : ApexDesc()
+ {
+ setToDefault();
+ }
+
+ /**
+ \brief Resets descriptor to default settings.
+ */
+ PX_INLINE void setToDefault()
+ {
+ ApexDesc::setToDefault();
+
+ physX3Template = NULL;
+ crumbleEmitterName = NULL;
+ dustEmitterName = NULL;
+ globalPose = PxMat44(PxIdentity);
+ scale = PxVec3(1.0f);
+ dynamic = false;
+ supportDepth = 0;
+ formExtendedStructures = false;
+ useAssetDefinedSupport = false;
+ useWorldSupport = false;
+ overrideSkinnedMaterials = NULL;
+ overrideSkinnedMaterialCount = 0;
+ overrideStaticMaterials = NULL;
+ overrideStaticMaterialCount = 0;
+ renderStaticChunksSeparately = true;
+ destructibleParameters.setToDefault();
+ }
+
+ /**
+ Returns true iff an object can be created using this descriptor.
+ */
+ PX_INLINE bool isValid() const
+ {
+ const float det = (globalPose.column0.getXYZ().cross(globalPose.column1.getXYZ())).dot(globalPose.column2.getXYZ());
+ if (!PxEquals(det, 1.0f, 0.001f))
+ {
+ APEX_DEBUG_WARNING("Mirror transformations are not allowed in the DestructibleActor descriptor.");
+ return false;
+ }
+
+ if (scale.x <= 0 || scale.y <= 0 || scale.z <= 0)
+ {
+ APEX_DEBUG_WARNING("Negative scales are not allowed in the DestructibleActor descriptor.");
+ return false;
+ }
+
+ if (physX3Template && !physX3Template->isValid() )
+ {
+ APEX_DEBUG_WARNING("Invalid physx3 descriptor template in the DestructibleActor descriptor.");
+ return false;
+ }
+
+ if (overrideSkinnedMaterialCount > 0 && overrideSkinnedMaterials == NULL)
+ {
+ APEX_DEBUG_WARNING("overrideSkinnedMaterials is NULL, but overrideSkinnedMaterialCount > 0.");
+ return false;
+ }
+
+ if (overrideStaticMaterialCount > 0 && overrideStaticMaterials == NULL)
+ {
+ APEX_DEBUG_WARNING("overrideStaticMaterials is NULL, but overrideStaticMaterialCount > 0.");
+ return false;
+ }
+
+ // Note - Not checking shapeDescTemplate, since meshData is not supplied
+
+ return ApexDesc::isValid();
+ }
+
+ PhysX3DescTemplateImpl* physX3Template;
+
+ /**
+ The name of the MeshParticleSystem to use for crumbling. This overrides the crumble system defined
+ in the DestructibleAsset if specified.
+ */
+ const char* crumbleEmitterName;
+
+ /**
+ The name of the MeshParticleSystem to use for fracture-line dust. This overrides the dust system defined
+ in the DestructibleAsset if specified.
+ */
+ const char* dustEmitterName;
+
+ /**
+ Initial global pose of undamaged destructible
+ */
+ PxMat44 globalPose;
+
+ /**
+ 3D scale
+ */
+ PxVec3 scale;
+
+ /**
+ Whether or not the destructible starts life as a dynamic actor
+ */
+ bool dynamic;
+
+ /**
+ 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;
+
+ /**
+ If 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.
+ */
+ bool formExtendedStructures;
+
+ /**
+ 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.
+ */
+ bool useAssetDefinedSupport;
+
+ /**
+ 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.
+ */
+ bool useWorldSupport;
+
+ /*
+ If true, static chunks will be renderered separately from dynamic chunks, as a single mesh (not using skinning).
+ This parameter is ignored if the 'dynamic' parameter is true.
+ Default value = false.
+ */
+ bool renderStaticChunksSeparately;
+
+ /**
+ Per-actor material names for the skinned mesh
+ */
+ const char** overrideSkinnedMaterials;
+
+ /**
+ Size of overrideSkinnedMaterials array
+ */
+ uint32_t overrideSkinnedMaterialCount;
+
+ /**
+ Per-actor material names for the static mesh
+ */
+ const char** overrideStaticMaterials;
+
+ /**
+ Size of overrideStaticMaterials array
+ */
+ uint32_t overrideStaticMaterialCount;
+
+ /**
+ Initial destructible parameters. These may be changed at runtime.
+ */
+ DestructibleParameters destructibleParameters;
+};
+
+
+/**
+ Set of sets of convex meshes [scale#][part#]
+*/
+class DestructibleConvexMeshContainer
+{
+public:
+ struct ConvexMeshSet : public UserAllocated
+ {
+ ConvexMeshSet() : mReferenceCount(0) {}
+
+ physx::Array<PxConvexMesh*> mSet;
+ uint32_t mReferenceCount;
+ };
+
+ ~DestructibleConvexMeshContainer() { reset(); }
+
+ uint32_t size() const
+ {
+ return mConvexMeshSets.size();
+ }
+
+ physx::Array<PxConvexMesh*>& operator [] (uint32_t i) const
+ {
+ return mConvexMeshSets[i]->mSet;
+ }
+
+ uint32_t getReferenceCount(uint32_t i) const
+ {
+ return mConvexMeshSets[i]->mReferenceCount;
+ }
+ void incReferenceCount(uint32_t i)
+ {
+ ++mConvexMeshSets[i]->mReferenceCount;
+ }
+ bool decReferenceCount(uint32_t i)
+ {
+ if (mConvexMeshSets[i]->mReferenceCount == 0)
+ return false;
+ --mConvexMeshSets[i]->mReferenceCount;
+ return true;
+ }
+
+ void resize(uint32_t newSize)
+ {
+ const uint32_t oldSize = size();
+ mConvexMeshSets.resize(newSize);
+ for (uint32_t i = oldSize; i < newSize; ++i)
+ {
+ mConvexMeshSets[i] = PX_NEW(ConvexMeshSet);
+ }
+ }
+
+ void reset(bool force = true)
+ {
+ for (uint32_t i = mConvexMeshSets.size(); i--;)
+ {
+ ConvexMeshSet* meshSet = mConvexMeshSets[i];
+ if (meshSet != NULL)
+ {
+ if (force)
+ {
+ PX_DELETE(meshSet);
+ mConvexMeshSets[i] = NULL;
+ }
+ else
+ {
+ if (meshSet->mReferenceCount == 0)
+ {
+ // Release the PhysX convex mesh pointers
+ for (uint32_t j=0; j<meshSet->mSet.size(); j++)
+ {
+ PxConvexMesh* convexMesh = meshSet->mSet[j];
+ if (convexMesh == NULL)
+ {
+ continue;
+ }
+ convexMesh->release();
+ }
+
+ meshSet->mSet.resize(0);
+ PX_DELETE(meshSet);
+ mConvexMeshSets.replaceWithLast(i);
+ }
+ }
+ }
+ }
+ if (force)
+ {
+ mConvexMeshSets.reset();
+ }
+ }
+
+private:
+ physx::Array<ConvexMeshSet*> mConvexMeshSets;
+};
+
+
+/**
+ Destructible asset collision data. Caches collision data for a DestructibleAsset at
+ various scales.
+*/
+
+#define kDefaultDestructibleAssetCollisionScaleTolerance (0.0001f)
+
+class DestructibleAssetCollision : public ApexResource
+{
+public:
+
+ struct Version
+ {
+ enum Enum
+ {
+ First = 0,
+ // New versions must be put here. There is no need to explicitly number them. The
+ // numbers above were put there to conform to the old DestructionToolStreamVersion enum.
+
+ Count,
+ Current = Count - 1
+ };
+ };
+
+ DestructibleAssetCollision();
+ DestructibleAssetCollision(NvParameterized::Interface* params);
+ ~DestructibleAssetCollision();
+
+ void setDestructibleAssetToCook(class DestructibleAssetImpl* asset);
+
+ bool addScale(const PxVec3& scale);
+
+ bool cookAll();
+
+ bool cookScale(const PxVec3& scale);
+
+ void resize(uint32_t hullCount);
+
+ const char* getAssetName() const
+ {
+ return mParams->assetName;
+ }
+ DestructibleAssetImpl* getAsset() { return mAsset; }
+ PxConvexMesh* getConvexMesh(uint32_t hullIndex, const PxVec3& scale);
+
+ PxFileBuf& deserialize(PxFileBuf& stream, const char* assetName);
+ PxFileBuf& serialize(PxFileBuf& stream) const;
+
+ bool platformAndVersionMatch() const;
+ void setPlatformAndVersion();
+
+ uint32_t memorySize() const;
+
+ MeshCookedCollisionStreamsAtScale* getCollisionAtScale(const PxVec3& scale);
+
+ physx::Array<PxConvexMesh*>* getConvexMeshesAtScale(const PxVec3& scale);
+
+ void clearUnreferencedSets();
+ // Spit out warnings to the error stream for any referenced sets
+ void reportReferencedSets();
+ bool incReferenceCount(int scaleIndex);
+ bool decReferenceCount(int scaleIndex);
+
+ void merge(DestructibleAssetCollision& collisionSet);
+
+ int32_t getScaleIndex(const PxVec3& scale, float tolerance) const;
+
+private:
+ DestructibleAssetCollisionDataSet* mParams;
+ bool mOwnsParams;
+
+ class DestructibleAssetImpl* mAsset;
+ DestructibleConvexMeshContainer mConvexMeshContainer;
+};
+
+#define OFFSET_FN(_classname, _membername) static uint32_t _membername##Offset() { return PX_OFFSET_OF(_classname, _membername); }
+
+class DestructibleAssetImpl : public ApexResource
+{
+public:
+
+ enum
+ {
+ InvalidChunkIndex = 0xFFFF
+ };
+
+ enum ChunkFlags
+ {
+ SupportChunk = (1 << 0),
+ UnfracturableChunk = (1 << 1),
+ DescendantUnfractureable = (1 << 2),
+ UndamageableChunk = (1 << 3),
+ UncrumbleableChunk = (1 << 4),
+#if APEX_RUNTIME_FRACTURE
+ RuntimeFracturableChunk = (1 << 5),
+#endif
+
+ Instanced = (1 << 8),
+ };
+
+ struct ChunkInstanceBufferDataElement
+ {
+ PxVec3 translation;
+ PxMat33 scaledRotation;
+ PxVec2 uvOffset;
+ PxVec3 localOffset;
+
+ OFFSET_FN(ChunkInstanceBufferDataElement, translation)
+ OFFSET_FN(ChunkInstanceBufferDataElement, scaledRotation)
+ OFFSET_FN(ChunkInstanceBufferDataElement, uvOffset)
+ OFFSET_FN(ChunkInstanceBufferDataElement, localOffset)
+ };
+
+ struct ScatterInstanceBufferDataElement
+ {
+ PxVec3 translation;
+ PxMat33 scaledRotation;
+ float alpha;
+
+ OFFSET_FN(ScatterInstanceBufferDataElement, translation)
+ OFFSET_FN(ScatterInstanceBufferDataElement, scaledRotation)
+ OFFSET_FN(ScatterInstanceBufferDataElement, alpha)
+ };
+
+ struct ScatterMeshInstanceInfo
+ {
+ ScatterMeshInstanceInfo()
+ : m_actor(NULL)
+ , m_instanceBuffer(NULL)
+ , m_IBSize(0)
+ {}
+
+ ~ScatterMeshInstanceInfo();
+
+ RenderMeshActor* m_actor;
+ UserRenderInstanceBuffer* m_instanceBuffer;
+ uint32_t m_IBSize;
+ physx::Array<ScatterInstanceBufferDataElement> m_instanceBufferData;
+ };
+
+ DestructibleAssetImpl(ModuleDestructibleImpl* module, DestructibleAsset* api, const char* name);
+ DestructibleAssetImpl(ModuleDestructibleImpl* module, DestructibleAsset* api, NvParameterized::Interface* params, const char* name);
+ ~DestructibleAssetImpl();
+
+ const NvParameterized::Interface* getAssetNvParameterized() const
+ {
+ return mParams;
+ }
+
+ DestructibleActor* createDestructibleActorFromDeserializedState(NvParameterized::Interface* params, Scene&);
+ DestructibleActor* createDestructibleActor(const NvParameterized::Interface& params, Scene&);
+ void releaseDestructibleActor(DestructibleActor& actor);
+
+ RenderMeshAsset* getRenderMeshAsset() const
+ {
+ return renderMeshAsset;
+ }
+ bool setRenderMeshAsset(RenderMeshAsset* newRenderMeshAsset);
+
+ bool setScatterMeshAssets(RenderMeshAsset** scatterMeshAssetArray, uint32_t scatterMeshAssetArraySize);
+
+ void createScatterMeshInstanceInfo();
+
+ UserRenderInstanceBufferDesc getScatterMeshInstanceBufferDesc();
+
+ uint32_t getScatterMeshAssetCount() const
+ {
+ return scatterMeshAssets.size();
+ }
+
+ virtual RenderMeshAsset* const * getScatterMeshAssets() const
+ {
+ return scatterMeshAssets.size() > 0 ? &scatterMeshAssets[0] : NULL;
+ }
+
+ RenderMeshAsset* getRuntimeRenderMeshAsset() const
+ {
+ return runtimeRenderMeshAsset;
+ }
+
+ uint32_t getInstancedChunkMeshCount() const
+ {
+ return m_instancedChunkMeshCount;
+ }
+
+ uint32_t getChunkCount() const
+ {
+ return (uint32_t)mParams->chunks.arraySizes[0];
+ }
+ uint32_t getDepthCount() const
+ {
+ return mParams->depthCount;
+ }
+ bool getScatterMeshAlwaysDrawFlag() const
+ {
+ return mParams->destructibleParameters.alwaysDrawScatterMesh;
+ }
+ uint32_t getChunkChildCount(uint32_t chunkIndex) const
+ {
+ if (chunkIndex >= (uint32_t)mParams->chunks.arraySizes[0])
+ {
+ return 0;
+ }
+ return (uint32_t)mParams->chunks.buf[chunkIndex].numChildren;
+ }
+ uint16_t getChunkDepth(uint32_t chunkIndex) const
+ {
+ if (chunkIndex >= (uint32_t)mParams->chunks.arraySizes[0])
+ {
+ return 0;
+ }
+ return mParams->chunks.buf[chunkIndex].depth;
+ }
+ int32_t getChunkChild(uint32_t chunkIndex, uint32_t childIndex) const
+ {
+ if (childIndex >= getChunkChildCount(chunkIndex))
+ {
+ return -1;
+ }
+ return int32_t(mParams->chunks.buf[chunkIndex].firstChildIndex + childIndex);
+ }
+ PxBounds3 getBounds() const
+ {
+ return mParams->bounds;
+ }
+ DestructibleParameters getParameters() const;
+ DestructibleInitParameters getInitParameters() const;
+ const char* getCrumbleEmitterName() const;
+ const char* getDustEmitterName() const;
+ const char* getFracturePatternName() const;
+ float getFractureImpulseScale() const
+ {
+ return mParams->destructibleParameters.fractureImpulseScale;
+ }
+ float getImpactVelocityThreshold() const
+ {
+ return mParams->destructibleParameters.impactVelocityThreshold;
+ }
+ void getStats(DestructibleAssetStats& stats) const;
+ void cacheChunkOverlapsUpToDepth(int32_t depth = -1);
+ float getNeighborPadding() const
+ {
+ return mParams->neighborPadding;
+ }
+
+ uint16_t getChunkParentIndex(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mParams->chunks.arraySizes[0]);
+ return mParams->chunks.buf[chunkIndex].parentIndex;
+ }
+
+ PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mParams->chunks.arraySizes[0]);
+ DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mParams->chunks.buf[chunkIndex];
+ return (sourceChunk.flags & DestructibleAssetImpl::Instanced) == 0 ? PxVec3(0.0f) : mParams->chunkInstanceInfo.buf[sourceChunk.meshPartIndex].chunkPositionOffset;
+ }
+
+ PxVec2 getChunkUVOffset(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mParams->chunks.arraySizes[0]);
+ DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mParams->chunks.buf[chunkIndex];
+ return (sourceChunk.flags & DestructibleAssetImpl::Instanced) == 0 ? PxVec2(0.0f) : mParams->chunkInstanceInfo.buf[sourceChunk.meshPartIndex].chunkUVOffset;
+ }
+
+ uint32_t getChunkFlags(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mParams->chunks.arraySizes[0]);
+ DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mParams->chunks.buf[chunkIndex];
+ uint32_t flags = 0;
+ if (sourceChunk.flags & DestructibleAssetImpl::SupportChunk)
+ {
+ flags |= DestructibleAsset::ChunkEnvironmentallySupported;
+ }
+ if (sourceChunk.flags & DestructibleAssetImpl::UnfracturableChunk)
+ {
+ flags |= DestructibleAsset::ChunkAndDescendentsDoNotFracture;
+ }
+ if (sourceChunk.flags & DestructibleAssetImpl::UndamageableChunk)
+ {
+ flags |= DestructibleAsset::ChunkDoesNotFracture;
+ }
+ if (sourceChunk.flags & DestructibleAssetImpl::UncrumbleableChunk)
+ {
+ flags |= DestructibleAsset::ChunkDoesNotCrumble;
+ }
+ if (sourceChunk.flags & DestructibleAssetImpl::Instanced)
+ {
+ flags |= DestructibleAsset::ChunkIsInstanced;
+ }
+#if APEX_RUNTIME_FRACTURE
+ if (sourceChunk.flags & DestructibleAssetImpl::RuntimeFracturableChunk)
+ {
+ flags |= DestructibleAsset::ChunkRuntimeFracture;
+ }
+#endif
+ return flags;
+ }
+
+ uint32_t getPartIndex(uint32_t chunkIndex) const
+ {
+ PX_ASSERT(chunkIndex < (uint16_t)mParams->chunks.arraySizes[0]);
+ DestructibleAssetParametersNS::Chunk_Type& sourceChunk = mParams->chunks.buf[chunkIndex];
+ return (sourceChunk.flags & DestructibleAssetImpl::Instanced) == 0 ? sourceChunk.meshPartIndex : mParams->chunkInstanceInfo.buf[sourceChunk.meshPartIndex].partIndex;
+ }
+
+ uint32_t getChunkHullIndexStart(uint32_t chunkIndex) const
+ {
+ return mParams->chunkConvexHullStartIndices.buf[getPartIndex(chunkIndex)];
+ }
+
+ uint32_t getChunkHullIndexStop(uint32_t chunkIndex) const
+ {
+ return mParams->chunkConvexHullStartIndices.buf[getPartIndex(chunkIndex)+1];
+ }
+
+ uint32_t getChunkHullCount(uint32_t chunkIndex) const
+ {
+ const uint32_t partIndex = getPartIndex(chunkIndex);
+ return mParams->chunkConvexHullStartIndices.buf[partIndex+1] - mParams->chunkConvexHullStartIndices.buf[partIndex];
+ }
+
+ uint32_t getPartHullIndexStart(uint32_t partIndex) const
+ {
+ return mParams->chunkConvexHullStartIndices.buf[partIndex];
+ }
+
+ uint32_t getPartHullIndexStop(uint32_t partIndex) const
+ {
+ return mParams->chunkConvexHullStartIndices.buf[partIndex+1];
+ }
+
+ NvParameterized::Interface** getConvexHullParameters(uint32_t hullIndex) const
+ {
+ return mParams->chunkConvexHulls.buf + hullIndex;
+ }
+
+ PxBounds3 getChunkActorLocalBounds(uint32_t chunkIndex) const
+ {
+ const uint32_t partIndex = getPartIndex(chunkIndex);
+ PxBounds3 bounds = renderMeshAsset->getBounds(partIndex);
+ const PxVec3 offset = getChunkPositionOffset(chunkIndex);
+ bounds.minimum += offset;
+ bounds.maximum += offset;
+ return bounds;
+ }
+
+ const PxBounds3& getChunkShapeLocalBounds(uint32_t chunkIndex) const
+ {
+ const uint32_t partIndex = getPartIndex(chunkIndex);
+ return renderMeshAsset->getBounds(partIndex);
+ }
+
+ void applyTransformation(const PxMat44& transformation, float scale);
+ void applyTransformation(const PxMat44& transformation);
+ bool setPlatformMaxDepth(PlatformTag platform, uint32_t maxDepth);
+ bool removePlatformMaxDepth(PlatformTag platform);
+
+ CachedOverlapsNS::IntPair_DynamicArray1D_Type* getOverlapsAtDepth(uint32_t depth, bool create = true) const;
+
+ void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false);
+ void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges);
+ void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty);
+
+ void traceSurfaceBoundary(physx::Array<PxVec3>& outPoints, uint16_t chunkIndex, const PxTransform& localToWorldRT, const PxVec3& scale,
+ float spacing, float jitter, float surfaceDistance, uint32_t maxPoints);
+
+ AuthObjTypeID getObjTypeID() const
+ {
+ return mAssetTypeID;
+ }
+ const char* getObjTypeName() const
+ {
+ return getClassName();
+ }
+ const char* getName() const
+ {
+ return mName.c_str();
+ }
+
+ void prepareForNewInstance();
+
+ void resetInstanceData();
+
+ // DestructibleAssetAuthoring methods
+ virtual bool prepareForPlatform(nvidia::apex::PlatformTag platform) const;
+
+ void setFractureImpulseScale(float scale)
+ {
+ mParams->destructibleParameters.fractureImpulseScale = scale;
+ }
+ void setImpactVelocityThreshold(float threshold)
+ {
+ mParams->destructibleParameters.impactVelocityThreshold = threshold;
+ }
+ void setChunkOverlapsCacheDepth(int32_t depth = -1);
+ void setParameters(const DestructibleParameters&);
+ void setInitParameters(const DestructibleInitParameters&);
+ void setCrumbleEmitterName(const char*);
+ void setDustEmitterName(const char*);
+ void setFracturePatternName(const char*);
+ void setNeighborPadding(float neighborPadding)
+ {
+ mParams->neighborPadding = neighborPadding;
+ }
+
+ uint32_t forceLoadAssets();
+ void initializeAssetNameTable();
+
+ void cleanup();
+ ModuleDestructibleImpl* getOwner()
+ {
+ return module;
+ }
+ DestructibleAsset* getAsset()
+ {
+ return mNxAssetApi;
+ }
+
+ static AuthObjTypeID getAssetTypeID()
+ {
+ return mAssetTypeID;
+ }
+
+ virtual NvParameterized::Interface* getDefaultActorDesc();
+ virtual NvParameterized::Interface* getDefaultAssetPreviewDesc();
+ virtual Actor* createApexActor(const NvParameterized::Interface& params, Scene& apexScene);
+
+ virtual AssetPreview* createApexAssetPreview(const ::NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/);
+
+ virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const;
+
+ uint32_t getActorTransformCount() const
+ {
+ return (uint32_t)mParams->actorTransforms.arraySizes[0];
+ }
+
+ const PxMat44* getActorTransforms() const
+ {
+ return mParams->actorTransforms.buf;
+ }
+
+ void appendActorTransforms(const PxMat44* transforms, uint32_t transformCount);
+
+ void clearActorTransforms();
+
+ bool rebuildCollisionGeometry(uint32_t partIndex, const DestructibleGeometryDesc& geometryDesc);
+
+
+ NvParameterized::Interface* acquireNvParameterizedInterface(void)
+ {
+ NvParameterized::Interface* ret = mParams;
+
+ // don't set mParams to NULL here, because it's read during the asset release
+ mOwnsParams = false;
+
+ return ret;
+ }
+
+protected:
+
+ void init();
+
+ void calculateChunkDepthStarts();
+ void calculateChunkOverlaps(physx::Array<IntPair>& overlaps, uint32_t depth) const;
+
+ void reduceAccordingToLOD();
+
+ void updateChunkInstanceRenderResources(bool rewriteBuffers, void* userRenderData);
+
+ static bool chunksInProximity(const DestructibleAssetImpl& asset0, uint16_t chunkIndex0, const PxTransform& tm0, const PxVec3& scale0,
+ const DestructibleAssetImpl& asset1, uint16_t chunkIndex1, const PxTransform& tm1, const PxVec3& scale1,
+ float padding);
+
+ bool chunkAndSphereInProximity(uint16_t chunkIndex, const PxTransform& chunkTM, const PxVec3& chunkScale,
+ const PxVec3& sphereWorldCenter, float sphereRadius, float padding, float* distance);
+
+ static DestructibleParameters getParameters(const DestructibleAssetParametersNS::DestructibleParameters_Type&,
+ const DestructibleAssetParametersNS::DestructibleDepthParameters_DynamicArray1D_Type*);
+ static void setParameters(const DestructibleParameters&, DestructibleAssetParametersNS::DestructibleParameters_Type&);
+
+ static AuthObjTypeID mAssetTypeID;
+ static const char* getClassName()
+ {
+ return DESTRUCTIBLE_AUTHORING_TYPE_NAME;
+ }
+ ApexSimpleString mName;
+
+ DestructibleAsset* mNxAssetApi;
+ ModuleDestructibleImpl* module;
+
+ DestructibleAssetParameters* mParams;
+ bool mOwnsParams;
+
+ // Has a parameterized internal representation
+ Array<ConvexHullImpl> chunkConvexHulls;
+
+ // Runtime / derived
+ int32_t chunkOverlapCacheDepth;
+ Array<ResID> mStaticMaterialIDs;
+
+ ApexAssetTracker mCrumbleAssetTracker;
+ ApexAssetTracker mDustAssetTracker;
+
+ RenderMeshAsset* renderMeshAsset;
+ RenderMeshAsset* runtimeRenderMeshAsset;
+
+ physx::Array<PxConvexMesh*>* mCollisionMeshes;
+
+ uint32_t mRuntimeCookedConvexCount;
+
+ Array<RenderMeshAsset*> scatterMeshAssets;
+
+ // Instanced chunks
+ uint16_t m_instancedChunkMeshCount;
+ physx::Array<RenderMeshActor*> m_instancedChunkRenderMeshActors; // One per render mesh actor per instanced chunk
+ physx::Array<uint16_t> m_instancedChunkActorVisiblePart;
+ physx::Array<uint16_t> m_instancedChunkActorMap; // from instanced chunk instanceInfo index to actor index
+ physx::Array<UserRenderInstanceBuffer*> m_chunkInstanceBuffers;
+ physx::Array< physx::Array< ChunkInstanceBufferDataElement > > m_chunkInstanceBufferData;
+
+ // Scatter meshes
+ physx::Array<ScatterMeshInstanceInfo> m_scatterMeshInstanceInfo; // One per scatter mesh asset
+
+ uint32_t m_currentInstanceBufferActorAllowance;
+ bool m_needsInstanceBufferDataResize;
+ bool m_needsInstanceBufferResize;
+ nvidia::Mutex m_chunkInstanceBufferDataLock;
+
+ bool m_needsScatterMeshInstanceInfoCreation;
+
+ int32_t m_instancingRepresentativeActorIndex; // -1 => means it's not set
+
+ ResourceList m_destructibleList;
+ ResourceList m_previewList;
+
+ friend class DestructibleStructure;
+ friend class DestructiblePreviewImpl;
+ friend class DestructibleActorImpl;
+ friend class DestructibleActorJointImpl;
+ friend class DestructibleScene;
+ friend class ModuleDestructibleImpl;
+ friend class DestructibleAssetCollision;
+ friend class DestructibleModuleCachedData;
+ friend class ApexDamageEventReportDataImpl;
+ friend class DestructibleRenderableImpl;
+
+ NvParameterized::Interface* mApexDestructibleActorParams;
+
+private:
+ struct PlatformKeyValuePair
+ {
+ PlatformKeyValuePair(nvidia::apex::PlatformTag k, uint32_t v): key(k), val(v) {}
+ ~PlatformKeyValuePair() {}
+ nvidia::apex::PlatformTag key;
+ uint32_t val;
+ private:
+ PlatformKeyValuePair();
+ };
+ Array<PlatformKeyValuePair> m_platformFractureDepthMap;
+ bool setDepthCount(uint32_t targetDepthCount) const;
+};
+
+#ifndef WITHOUT_APEX_AUTHORING
+
+void gatherPartMesh(physx::Array<PxVec3>& vertices, physx::Array<uint32_t>& indices, const RenderMeshAsset* renderMeshAsset, uint32_t partIndex);
+
+class DestructibleAssetAuthoringImpl : public DestructibleAssetImpl
+{
+public:
+
+ ExplicitHierarchicalMeshImpl hMesh;
+ ExplicitHierarchicalMeshImpl hMeshCore;
+ CutoutSetImpl cutoutSet;
+ IntersectMesh intersectMesh;
+
+ DestructibleAssetAuthoringImpl(ModuleDestructibleImpl* module, DestructibleAsset* api, const char* name) :
+ DestructibleAssetImpl(module, api, name) {}
+
+ DestructibleAssetAuthoringImpl(ModuleDestructibleImpl* module, DestructibleAsset* api, NvParameterized::Interface* params, const char* name) :
+ DestructibleAssetImpl(module, api, params, name) {}
+
+ void setToolString(const char* toolString);
+
+ void cookChunks(const DestructibleAssetCookingDesc&, bool cacheOverlaps, uint32_t* chunkIndexMapUser2Apex, uint32_t* chunkIndexMapApex2User, uint32_t chunkIndexMapCount);
+
+ void trimCollisionGeometry(const uint32_t* partIndices, uint32_t partIndexCount, float maxTrimFraction = 0.2f);
+
+ void serializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) const;
+ void deserializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding);
+
+private:
+ void trimCollisionGeometryInternal(const uint32_t* chunkIndices, uint32_t chunkIndexCount, const physx::Array<IntPair>& parentDepthOverlaps, uint32_t depth, float maxTrimFraction);
+};
+#endif
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_ASSET_IMPL_H
diff --git a/APEX_1.4/module/destructible/include/DestructibleAssetProxy.h b/APEX_1.4/module/destructible/include/DestructibleAssetProxy.h
new file mode 100644
index 00000000..d427a849
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleAssetProxy.h
@@ -0,0 +1,923 @@
+/*
+ * 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_PROXY_H
+#define DESTRUCTIBLE_ASSET_PROXY_H
+
+#include "ModuleDestructibleImpl.h"
+#include "DestructibleAsset.h"
+#include "DestructibleAssetImpl.h"
+#include "PsUserAllocated.h"
+#include "authoring/Fracturing.h"
+#include "ApexUsingNamespace.h"
+#include "ApexAuthorableObject.h"
+#include "ApexAssetAuthoring.h"
+
+#include "PsArray.h"
+#include "nvparameterized/NvParameterized.h"
+
+#include "ApexRWLockable.h"
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+#pragma warning(disable: 4355) // 'this' : used in base member initialization list
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class DestructibleAssetProxy : public DestructibleAsset, public ApexResourceInterface, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructibleAssetImpl impl;
+
+ DestructibleAssetProxy(ModuleDestructibleImpl* module, ResourceList& list, const char* name) :
+ impl(module, this, name)
+ {
+ list.add(*this);
+ }
+
+ DestructibleAssetProxy(ModuleDestructibleImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ impl(module, this, params, name)
+ {
+ list.add(*this);
+ }
+
+ ~DestructibleAssetProxy()
+ {
+ }
+
+ PxBounds3 getChunkActorLocalBounds(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkActorLocalBounds(chunkIndex);
+ }
+
+ const NvParameterized::Interface* getAssetNvParameterized() const
+ {
+ READ_ZONE();
+ return impl.getAssetNvParameterized();
+ }
+
+ /**
+ * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller.
+ */
+ virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void)
+ {
+ NvParameterized::Interface* ret = impl.acquireNvParameterizedInterface();
+ release();
+ return ret;
+ }
+
+ virtual void releaseDestructibleActor(DestructibleActor& actor)
+ {
+ WRITE_ZONE();
+ impl.releaseDestructibleActor(actor);
+ }
+ virtual DestructibleParameters getDestructibleParameters() const
+ {
+ return impl.getParameters();
+ }
+ virtual DestructibleInitParameters getDestructibleInitParameters() const
+ {
+ return impl.getInitParameters();
+ }
+ virtual uint32_t getChunkCount() const
+ {
+ return impl.getChunkCount();
+ }
+ virtual uint32_t getDepthCount() const
+ {
+ READ_ZONE();
+ return impl.getDepthCount();
+ }
+ virtual RenderMeshAsset* getRenderMeshAsset() const
+ {
+ READ_ZONE();
+ return impl.getRenderMeshAsset();
+ }
+ virtual bool setRenderMeshAsset(RenderMeshAsset* renderMeshAsset)
+ {
+ WRITE_ZONE();
+ return impl.setRenderMeshAsset(renderMeshAsset);
+ }
+ virtual uint32_t getScatterMeshAssetCount() const
+ {
+ READ_ZONE();
+ return impl.getScatterMeshAssetCount();
+ }
+ virtual RenderMeshAsset* const * getScatterMeshAssets() const
+ {
+ READ_ZONE();
+ return impl.getScatterMeshAssets();
+ }
+ virtual uint32_t getInstancedChunkMeshCount() const
+ {
+ READ_ZONE();
+ return impl.getInstancedChunkMeshCount();
+ }
+ virtual const char* getCrumbleEmitterName() const
+ {
+ READ_ZONE();
+ return impl.getCrumbleEmitterName();
+ }
+ virtual const char* getDustEmitterName() const
+ {
+ READ_ZONE();
+ return impl.getDustEmitterName();
+ }
+ virtual const char* getFracturePatternName() const
+ {
+ return impl.getFracturePatternName();
+ }
+ virtual void getStats(DestructibleAssetStats& stats) const
+ {
+ READ_ZONE();
+ impl.getStats(stats);
+ }
+
+ virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1)
+ {
+ WRITE_ZONE();
+ impl.cacheChunkOverlapsUpToDepth(depth);
+ }
+
+ virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false)
+ {
+ impl.clearChunkOverlaps(depth, keepCachedFlag);
+ }
+
+ virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges)
+ {
+ impl.addChunkOverlaps(supportGraphEdges, numSupportGraphEdges);
+ }
+
+ virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty)
+ {
+ impl.removeChunkOverlaps(supportGraphEdges, numSupportGraphEdges, keepCachedFlagIfEmpty);
+ }
+
+ virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) const
+ {
+ READ_ZONE();
+ CachedOverlapsNS::IntPair_DynamicArray1D_Type* pairArray = impl.getOverlapsAtDepth(depth, false);
+ return uint32_t(pairArray != NULL ? pairArray->arraySizes[0] : 0);
+ }
+
+ virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) const
+ {
+ READ_ZONE();
+ CachedOverlapsNS::IntPair_DynamicArray1D_Type* pairArray = impl.getOverlapsAtDepth(depth, false);
+ PX_ASSERT(sizeof(IntPair) == pairArray->elementSize);
+ return pairArray != NULL ? (const IntPair*)pairArray->buf : NULL;
+ }
+
+ NvParameterized::Interface* getDefaultActorDesc()
+ {
+ return impl.getDefaultActorDesc();
+ }
+
+ NvParameterized::Interface* getDefaultAssetPreviewDesc()
+ {
+ return impl.getDefaultAssetPreviewDesc();
+ }
+
+ virtual Actor* createApexActor(const NvParameterized::Interface& parms, Scene& apexScene)
+ {
+ return impl.createApexActor(parms, apexScene);
+ }
+
+ virtual DestructibleActor* createDestructibleActorFromDeserializedState(NvParameterized::Interface* parms, Scene& apexScene)
+ {
+ WRITE_ZONE();
+ return impl.createDestructibleActorFromDeserializedState(parms, apexScene);
+ }
+
+ virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& params, AssetPreviewScene* /*previewScene*/)
+ {
+ return impl.createApexAssetPreview(params, NULL);
+ }
+
+ virtual bool isValidForActorCreation(const ::NvParameterized::Interface& parms, Scene& apexScene) const
+ {
+ return impl.isValidForActorCreation(parms, apexScene);
+ }
+
+ virtual bool isDirty() const
+ {
+ return false;
+ }
+
+ virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkPositionOffset(chunkIndex);
+ }
+
+ virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkUVOffset(chunkIndex);
+ }
+
+ virtual uint32_t getChunkFlags(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkFlags(chunkIndex);
+ }
+
+ virtual uint16_t getChunkDepth(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getChunkDepth(chunkIndex);
+ }
+
+ virtual int32_t getChunkParentIndex(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ const uint16_t chunkParentIndex = impl.getChunkParentIndex(chunkIndex);
+ return chunkParentIndex != DestructibleAssetImpl::InvalidChunkIndex ? (int32_t)chunkParentIndex : -1;
+ }
+
+ virtual uint32_t getPartIndex(uint32_t chunkIndex) const
+ {
+ READ_ZONE();
+ return impl.getPartIndex(chunkIndex);
+ }
+
+ virtual uint32_t getPartConvexHullCount(const uint32_t partIndex) const
+ {
+ READ_ZONE();
+ return impl.getPartHullIndexStop(partIndex) - impl.getPartHullIndexStart(partIndex);
+ }
+
+ virtual NvParameterized::Interface** getPartConvexHullArray(const uint32_t partIndex) const
+ {
+ READ_ZONE();
+ return impl.getConvexHullParameters(impl.getPartHullIndexStart(partIndex));
+ }
+
+ uint32_t getActorTransformCount() const
+ {
+ READ_ZONE();
+ return impl.getActorTransformCount();
+ }
+ const PxMat44* getActorTransforms() const
+ {
+ READ_ZONE();
+ return impl.getActorTransforms();
+ }
+
+ void applyTransformation(const PxMat44& transformation, float scale)
+ {
+ WRITE_ZONE();
+ impl.applyTransformation(transformation, scale);
+ }
+ void applyTransformation(const PxMat44& transformation)
+ {
+ WRITE_ZONE();
+ impl.applyTransformation(transformation);
+ }
+
+ virtual bool rebuildCollisionGeometry(uint32_t partIndex, const DestructibleGeometryDesc& geometryDesc)
+ {
+ WRITE_ZONE();
+ return impl.rebuildCollisionGeometry(partIndex, geometryDesc);
+ }
+
+ // ApexInterface methods
+ virtual void release()
+ {
+ WRITE_ZONE();
+ impl.getOwner()->mSdk->releaseAsset(*this);
+ }
+ virtual void destroy()
+ {
+ impl.cleanup();
+ delete this;
+ }
+
+ // Asset methods
+ virtual const char* getName() const
+ {
+ READ_ZONE();
+ return impl.getName();
+ }
+ static const char* getClassName()
+ {
+ return DESTRUCTIBLE_AUTHORING_TYPE_NAME;
+ }
+ virtual AuthObjTypeID getObjTypeID() const
+ {
+ return impl.getObjTypeID();
+ }
+ virtual const char* getObjTypeName() const
+ {
+ return impl.getObjTypeName();
+ }
+ virtual uint32_t forceLoadAssets()
+ {
+ return impl.forceLoadAssets();
+ }
+
+ // ApexResourceInterface methods
+ virtual void setListIndex(ResourceList& list, uint32_t index)
+ {
+ impl.m_listIndex = index;
+ impl.m_list = &list;
+ }
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+
+ friend class DestructibleActorImpl;
+};
+
+#ifndef WITHOUT_APEX_AUTHORING
+class DestructibleAssetAuthoringProxy : public DestructibleAssetAuthoring, public ApexResourceInterface, public ApexAssetAuthoring, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructibleAssetAuthoringImpl impl;
+
+ DestructibleAssetAuthoringProxy(ModuleDestructibleImpl* module, ResourceList& list) :
+ impl(module, NULL, "DestructibleAuthoring")
+ {
+ list.add(*this);
+ }
+
+ DestructibleAssetAuthoringProxy(ModuleDestructibleImpl* module, ResourceList& list, const char* name) :
+ impl(module, NULL, name)
+ {
+ list.add(*this);
+ }
+
+ DestructibleAssetAuthoringProxy(ModuleDestructibleImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ impl(module, NULL, params, name)
+ {
+ list.add(*this);
+ }
+
+ virtual ~DestructibleAssetAuthoringProxy()
+ {
+ }
+
+ // DestructibleAssetAuthoring methods
+
+ virtual ExplicitHierarchicalMesh& getExplicitHierarchicalMesh()
+ {
+ return impl.hMesh;
+ }
+
+ virtual ExplicitHierarchicalMesh& getCoreExplicitHierarchicalMesh()
+ {
+ return impl.hMeshCore;
+ }
+
+ virtual CutoutSet& getCutoutSet()
+ {
+ return impl.cutoutSet;
+ }
+
+ virtual uint32_t partitionMeshByIslands
+ (
+ nvidia::ExplicitRenderTriangle* mesh,
+ uint32_t meshTriangleCount,
+ uint32_t* meshPartition,
+ uint32_t meshPartitionMaxCount,
+ float padding
+ )
+ {
+ return ::FractureTools::partitionMeshByIslands(mesh, meshTriangleCount, meshPartition, meshPartitionMaxCount, padding);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::buildExplicitHierarchicalMesh(impl.hMesh, meshTriangles, meshTriangleCount, submeshData, submeshCount, meshPartition, meshPartitionCount, parentIndices, parentIndexCount);
+ }
+
+ virtual bool importRenderMeshAssetToRootMesh(const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX)
+ {
+ return ::FractureTools::buildExplicitHierarchicalMeshFromRenderMeshAsset(impl.hMesh, renderMeshAsset, maxRootDepth);
+ }
+
+ virtual bool importDestructibleAssetToRootMesh(const DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX)
+ {
+ return ::FractureTools::buildExplicitHierarchicalMeshFromDestructibleAsset(impl.hMesh, destructibleAsset, maxRootDepth);
+ }
+
+ virtual bool setCoreMesh
+ (
+ const ExplicitRenderTriangle* meshTriangles,
+ uint32_t meshTriangleCount,
+ const ExplicitSubmeshData* submeshData,
+ uint32_t submeshCount,
+ uint32_t* meshPartition = NULL,
+ uint32_t meshPartitionCount = 0
+ )
+ {
+ return ::FractureTools::buildExplicitHierarchicalMesh(impl.hMeshCore, meshTriangles, meshTriangleCount, submeshData, submeshCount, meshPartition, meshPartitionCount);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::buildExplicitHierarchicalMesh(hMesh, meshTriangles, meshTriangleCount, submeshData, submeshCount, meshPartition, meshPartitionCount, parentIndices, parentIndexCount);
+ }
+
+ virtual bool createHierarchicallySplitMesh
+ (
+ const MeshProcessingParameters& meshProcessingParams,
+ const FractureSliceDesc& desc,
+ const CollisionDesc& collisionDesc,
+ bool exportCoreMesh,
+ int32_t coreMeshImprintSubmeshIndex,
+ uint32_t randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ )
+ {
+ return ::FractureTools::createHierarchicallySplitMesh(impl.hMesh, impl.hMeshCore, exportCoreMesh, coreMeshImprintSubmeshIndex,
+ meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createVoronoiSplitMesh(impl.hMesh, impl.hMeshCore, exportCoreMesh, coreMeshImprintSubmeshIndex,
+ meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::hierarchicallySplitChunk(impl.hMesh, chunkIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::voronoiSplitChunk(impl.hMesh, chunkIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ virtual bool createChippedMesh
+ (
+ const MeshProcessingParameters& meshProcessingParams,
+ const FractureCutoutDesc& desc,
+ const CutoutSet& iCutoutSet,
+ const FractureSliceDesc& sliceDesc,
+ const FractureVoronoiDesc& voronoiDesc,
+ const CollisionDesc& collisionDesc,
+ uint32_t randomSeed,
+ IProgressListener& progressListener,
+ volatile bool* cancel = NULL
+ )
+ {
+ return ::FractureTools::createChippedMesh(impl.hMesh, meshProcessingParams, desc, iCutoutSet, sliceDesc, voronoiDesc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ virtual void buildCutoutSet
+ (
+ const uint8_t* pixelBuffer,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight,
+ float snapThreshold,
+ bool periodic
+ )
+ {
+ ::FractureTools::buildCutoutSet(impl.cutoutSet, pixelBuffer, bufferWidth, bufferHeight, snapThreshold, periodic);
+ }
+
+ virtual bool calculateCutoutUVMapping(PxMat33& mapping, const nvidia::ExplicitRenderTriangle& triangle)
+ {
+ return ::FractureTools::calculateCutoutUVMapping(triangle, mapping);
+ }
+
+ virtual bool calculateCutoutUVMapping(PxMat33& mapping, const PxVec3& targetDirection)
+ {
+ return ::FractureTools::calculateCutoutUVMapping(impl.hMesh, targetDirection, mapping);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createVoronoiSitesInsideMesh(impl.hMesh, siteBuffer, siteChunkIndices, siteCount, randomSeed, microgridSize, meshMode, progressListener, chunkIndex);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createScatterMeshSites(meshIndices, relativeTransforms, chunkMeshStarts, scatterMeshInstancesBufferSize, impl.hMesh, targetChunkCount, targetChunkIndices,
+ randomSeed, scatterMeshAssetCount, scatterMeshAssets, minCount, maxCount, minScales, maxScales, maxAngles);
+ }
+
+ 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
+ )
+ {
+ ::FractureTools::visualizeVoronoiCells(debugRender, sites, siteCount, cellColors, cellColorCount, bounds, cellIndex);
+ }
+
+ virtual void setBSPTolerances
+ (
+ float linearTolerance,
+ float angularTolerance,
+ float baseTolerance,
+ float clipTolerance,
+ float cleaningTolerance
+ )
+ {
+ ::FractureTools::setBSPTolerances(linearTolerance, angularTolerance, baseTolerance, clipTolerance, cleaningTolerance);
+ }
+
+ virtual void setBSPBuildParameters
+ (
+ float logAreaSigmaThreshold,
+ uint32_t testSetSize,
+ float splitWeight,
+ float imbalanceWeight
+ )
+ {
+ ::FractureTools::setBSPBuildParameters(logAreaSigmaThreshold, testSetSize, splitWeight, imbalanceWeight);
+ }
+
+ virtual ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull()
+ {
+ return ::FractureTools::createExplicitHierarchicalMeshConvexHull();
+ }
+
+ virtual uint32_t buildSliceMesh(const ExplicitRenderTriangle*& mesh, const ::FractureTools::NoiseParameters& noiseParameters, const PxPlane& slicePlane, uint32_t randomSeed)
+ {
+ if( ::FractureTools::buildSliceMesh(impl.intersectMesh, impl.hMesh, slicePlane, noiseParameters, randomSeed) )
+ {
+ mesh = impl.intersectMesh.m_triangles.begin();
+ return impl.intersectMesh.m_triangles.size();
+ }
+
+ mesh = NULL;
+ return 0;
+ }
+
+ virtual void setChunkOverlapsCacheDepth(int32_t depth = -1)
+ {
+ impl.setChunkOverlapsCacheDepth(depth);
+ }
+ virtual RenderMeshAsset* getRenderMeshAsset() const
+ {
+ return impl.getRenderMeshAsset();
+ }
+ virtual bool setRenderMeshAsset(RenderMeshAsset* renderMeshAsset)
+ {
+ return impl.setRenderMeshAsset(renderMeshAsset);
+ }
+ virtual bool setScatterMeshAssets(RenderMeshAsset** scatterMeshAssetArray, uint32_t scatterMeshAssetArraySize)
+ {
+ return impl.setScatterMeshAssets(scatterMeshAssetArray, scatterMeshAssetArraySize);
+ }
+ virtual uint32_t getScatterMeshAssetCount() const
+ {
+ return impl.getScatterMeshAssetCount();
+ }
+ virtual RenderMeshAsset* const * getScatterMeshAssets() const
+ {
+ return impl.getScatterMeshAssets();
+ }
+ virtual uint32_t getInstancedChunkMeshCount() const
+ {
+ return impl.getInstancedChunkMeshCount();
+ }
+ virtual void setDestructibleParameters(const DestructibleParameters& parameters)
+ {
+ impl.setParameters(parameters);
+ }
+ virtual DestructibleParameters getDestructibleParameters() const
+ {
+ READ_ZONE();
+ return impl.getParameters();
+ }
+ virtual void setDestructibleInitParameters(const DestructibleInitParameters& parameters)
+ {
+ impl.setInitParameters(parameters);
+ }
+ virtual DestructibleInitParameters getDestructibleInitParameters() const
+ {
+ READ_ZONE();
+ return impl.getInitParameters();
+ }
+ virtual void setCrumbleEmitterName(const char* name)
+ {
+ impl.setCrumbleEmitterName(name);
+ }
+ virtual void setDustEmitterName(const char* name)
+ {
+ impl.setDustEmitterName(name);
+ }
+ virtual void setFracturePatternName(const char* name)
+ {
+ impl.setFracturePatternName(name);
+ }
+ virtual void cookChunks(const DestructibleAssetCookingDesc& cookingDesc, bool cacheOverlaps, uint32_t* chunkIndexMapUser2Apex, uint32_t* chunkIndexMapApex2User, uint32_t chunkIndexMapCount)
+ {
+ impl.cookChunks(cookingDesc, cacheOverlaps, chunkIndexMapApex2User, chunkIndexMapUser2Apex, chunkIndexMapCount);
+ }
+ virtual void serializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) const
+ {
+ impl.serializeFractureToolState(stream, embedding);
+ }
+ virtual void deserializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding)
+ {
+ impl.deserializeFractureToolState(stream, embedding);
+ }
+ virtual uint32_t getChunkCount() const
+ {
+ READ_ZONE();
+ return impl.getChunkCount();
+ }
+ virtual uint32_t getDepthCount() const
+ {
+ return impl.getDepthCount();
+ }
+ virtual uint32_t getChunkChildCount(uint32_t chunkIndex) const
+ {
+ return impl.getChunkChildCount(chunkIndex);
+ }
+ virtual int32_t getChunkChild(uint32_t chunkIndex, uint32_t childIndex) const
+ {
+ return impl.getChunkChild(chunkIndex, childIndex);
+ }
+ virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const
+ {
+ return impl.getChunkPositionOffset(chunkIndex);
+ }
+ virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const
+ {
+ return impl.getChunkUVOffset(chunkIndex);
+ }
+ virtual uint32_t getPartIndex(uint32_t chunkIndex) const
+ {
+ return impl.getPartIndex(chunkIndex);
+ }
+ virtual void trimCollisionGeometry(const uint32_t* partIndices, uint32_t partIndexCount, float maxTrimFraction = 0.2f)
+ {
+ impl.trimCollisionGeometry(partIndices, partIndexCount, maxTrimFraction);
+ }
+ virtual float getImpactVelocityThreshold() const
+ {
+ return impl.getImpactVelocityThreshold();
+ }
+ void setImpactVelocityThreshold(float threshold)
+ {
+ impl.setImpactVelocityThreshold(threshold);
+ }
+ virtual float getFractureImpulseScale() const
+ {
+ return impl.getFractureImpulseScale();
+ }
+ void setFractureImpulseScale(float scale)
+ {
+ impl.setFractureImpulseScale(scale);
+ }
+ virtual void getStats(DestructibleAssetStats& stats) const
+ {
+ impl.getStats(stats);
+ }
+
+ virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1)
+ {
+ impl.cacheChunkOverlapsUpToDepth(depth);
+ }
+
+ virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false)
+ {
+ impl.clearChunkOverlaps(depth, keepCachedFlag);
+ }
+
+ virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges)
+ {
+ impl.addChunkOverlaps(supportGraphEdges, numSupportGraphEdges);
+ }
+
+ virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty)
+ {
+ impl.removeChunkOverlaps(supportGraphEdges, numSupportGraphEdges, keepCachedFlagIfEmpty);
+ }
+
+ virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth)
+ {
+ CachedOverlapsNS::IntPair_DynamicArray1D_Type* pairArray = impl.getOverlapsAtDepth(depth, false);
+ return uint32_t(pairArray != NULL ? pairArray->arraySizes[0] : 0);
+ }
+
+ virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth)
+ {
+ CachedOverlapsNS::IntPair_DynamicArray1D_Type* pairArray = impl.getOverlapsAtDepth(depth, false);
+ PX_ASSERT(sizeof(IntPair) == pairArray->elementSize);
+ return pairArray != NULL ? (const IntPair*)pairArray->buf : NULL;
+ }
+ virtual void setNeighborPadding(float neighborPadding)
+ {
+ impl.setNeighborPadding(neighborPadding);
+ }
+ virtual float getNeighborPadding() const
+ {
+ return impl.getNeighborPadding();
+ }
+ void applyTransformation(const PxMat44& transformation, float scale)
+ {
+ impl.applyTransformation(transformation, scale);
+ }
+ void applyTransformation(const PxMat44& transformation)
+ {
+ impl.applyTransformation(transformation);
+ }
+
+ bool setPlatformMaxDepth(PlatformTag platform, uint32_t maxDepth)
+ {
+ return impl.setPlatformMaxDepth(platform, maxDepth);
+ }
+
+ bool removePlatformMaxDepth(PlatformTag platform)
+ {
+ return impl.removePlatformMaxDepth(platform);
+ }
+
+ // AssetAuthoring methods
+
+ const char* getName(void) const
+ {
+ return impl.getName();
+ }
+
+ const char* getObjTypeName() const
+ {
+ return impl.getObjTypeName();
+ }
+
+ virtual bool prepareForPlatform(nvidia::apex::PlatformTag platformTag)
+ {
+ return impl.prepareForPlatform(platformTag);
+ }
+
+ void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist)
+ {
+ ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist);
+ }
+
+ void setToolString(const char* toolString)
+ {
+ impl.setToolString(toolString);
+ }
+
+ uint32_t getActorTransformCount() const
+ {
+ return impl.getActorTransformCount();
+ }
+
+ const PxMat44* getActorTransforms() const
+ {
+ return impl.getActorTransforms();
+ }
+
+ void appendActorTransforms(const PxMat44* transforms, uint32_t transformCount)
+ {
+ impl.appendActorTransforms(transforms, transformCount);
+ }
+
+ void clearActorTransforms()
+ {
+ impl.clearActorTransforms();
+ }
+
+ NvParameterized::Interface* getNvParameterized() const
+ {
+ return (NvParameterized::Interface*)impl.getAssetNvParameterized();
+ }
+
+ /**
+ * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller.
+ */
+ virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void)
+ {
+ NvParameterized::Interface* ret = impl.acquireNvParameterizedInterface();
+ release();
+ return ret;
+ }
+
+
+ // ApexResourceInterface methods
+ virtual void setListIndex(ResourceList& list, uint32_t index)
+ {
+ impl.m_listIndex = index;
+ impl.m_list = &list;
+ }
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+
+ // ApexInterface methods
+ virtual void release()
+ {
+ impl.getOwner()->mSdk->releaseAssetAuthoring(*this);
+ }
+ virtual void destroy()
+ {
+ impl.cleanup();
+ delete this;
+ }
+};
+#endif
+
+}
+} // end namespace nvidia
+
+#endif // DESTRUCTIBLE_ASSET_PROXY_H
diff --git a/APEX_1.4/module/destructible/include/DestructibleHelpers.h b/APEX_1.4/module/destructible/include/DestructibleHelpers.h
new file mode 100644
index 00000000..e44755fd
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleHelpers.h
@@ -0,0 +1,79 @@
+/*
+ * 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 __DESTRUCTIBLEHELPERS_H__
+#define __DESTRUCTIBLEHELPERS_H__
+
+#include "Apex.h"
+#include "ApexSDKHelpers.h"
+#include "PsUserAllocated.h"
+#include "PsMemoryBuffer.h"
+
+#include "DestructibleAsset.h"
+#include "NxPhysicsSDK.h"
+
+/*
+ For managing mesh cooking at various scales
+ */
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class ConvexHullAtScale
+{
+public:
+ ConvexHullAtScale() : scale(1), convexMesh(NULL) {}
+ ConvexHullAtScale(const PxVec3& inScale) : scale(inScale), convexMesh(NULL) {}
+
+ PxVec3 scale;
+ PxConvexMesh* convexMesh;
+ physx::Array<uint8_t> cookedHullData;
+};
+
+class MultiScaledConvexHull : public UserAllocated
+{
+public:
+ ConvexHullAtScale* getConvexHullAtScale(const PxVec3& scale, float tolerance = 0.0001f)
+ {
+ // Find mesh at scale. If not found, create one.
+ for (uint32_t index = 0; index < meshes.size(); ++index)
+ {
+ if (PxVec3equals(meshes[index].scale, scale, tolerance))
+ {
+ return &meshes[index];
+ }
+ }
+ meshes.insert();
+ return new(&meshes.back()) ConvexHullAtScale(scale);
+ }
+
+ void releaseConvexMeshes()
+ {
+ for (uint32_t index = 0; index < meshes.size(); ++index)
+ {
+ if (meshes[index].convexMesh != NULL)
+ {
+ GetApexSDK()->getPhysXSDK()->releaseConvexMesh(*meshes[index].convexMesh);
+ meshes[index].convexMesh = NULL;
+ }
+ }
+ }
+
+ Array<ConvexHullAtScale> meshes;
+};
+
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEHELPERS_H__
diff --git a/APEX_1.4/module/destructible/include/DestructiblePreviewImpl.h b/APEX_1.4/module/destructible/include/DestructiblePreviewImpl.h
new file mode 100644
index 00000000..359dbb96
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructiblePreviewImpl.h
@@ -0,0 +1,104 @@
+/*
+ * 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_IMPL_H__
+#define __DESTRUCTIBLE_PREVIEW_IMPL_H__
+
+#include "Apex.h"
+#include "ApexPreview.h"
+#include "RenderMesh.h"
+#include "DestructiblePreview.h"
+
+namespace nvidia
+{
+namespace destructible
+{
+class DestructiblePreviewImpl : public ApexResource, public ApexPreview
+{
+public:
+
+ DestructibleAssetImpl* m_asset;
+ DestructiblePreview* m_api;
+
+ uint32_t m_chunkDepth;
+ float m_explodeAmount;
+
+ RenderMeshActor* m_renderMeshActors[DestructibleActorMeshType::Count]; // Indexed by DestructibleActorMeshType::Enum
+
+ physx::Array<RenderMeshActor*> m_instancedChunkRenderMeshActors; // One per render mesh actor per instanced chunk
+ physx::Array<uint16_t> m_instancedActorVisiblePart;
+
+ physx::Array<uint16_t> m_instancedChunkActorMap; // from instanced chunk instanceInfo index to actor index
+
+ physx::Array<UserRenderInstanceBuffer*> m_chunkInstanceBuffers;
+ physx::Array< physx::Array< DestructibleAssetImpl::ChunkInstanceBufferDataElement > > m_chunkInstanceBufferData;
+
+ bool m_drawUnexpandedChunksStatically;
+
+ void* m_userData;
+
+ void setExplodeView(uint32_t depth, float explode);
+
+ void updateRenderResources(bool rewriteBuffers, void* userRenderData);
+
+ RenderMeshActor* getRenderMeshActor() const
+ {
+ return m_renderMeshActors[(!m_drawUnexpandedChunksStatically || m_explodeAmount != 0.0f) ? DestructibleActorMeshType::Skinned : DestructibleActorMeshType::Static];
+ }
+
+ void updateRenderResources(void* userRenderData);
+ void dispatchRenderResources(UserRenderer& renderer);
+
+ // ApexPreview methods
+ void setPose(const PxMat44& pose);
+ Renderable* getRenderable()
+ {
+ return DYNAMIC_CAST(Renderable*)(m_api);
+ }
+ void release();
+ void destroy();
+
+ DestructiblePreviewImpl(DestructiblePreview* _api, DestructibleAssetImpl& _asset, const NvParameterized::Interface* params);
+ virtual ~DestructiblePreviewImpl();
+
+protected:
+ void setChunkVisibility(uint16_t index, bool visibility)
+ {
+ PX_ASSERT((int32_t)index < m_asset->mParams->chunks.arraySizes[0]);
+ if (visibility)
+ {
+ mVisibleChunks.use(index);
+ }
+ else
+ {
+ mVisibleChunks.free(index);
+ }
+ DestructibleAssetParametersNS::Chunk_Type& sourceChunk = m_asset->mParams->chunks.buf[index];
+ if ((sourceChunk.flags & DestructibleAssetImpl::Instanced) == 0)
+ {
+ // Not instanced - need to choose the static or dynamic mesh, and set visibility for the render mesh actor
+ const DestructibleActorMeshType::Enum typeN = (m_explodeAmount != 0.0f || !m_drawUnexpandedChunksStatically) ?
+ DestructibleActorMeshType::Skinned : DestructibleActorMeshType::Static;
+ m_renderMeshActors[typeN]->setVisibility(visibility, sourceChunk.meshPartIndex);
+ }
+ }
+
+
+ void setInstancedChunkCount(uint32_t count);
+
+ IndexBank<uint16_t> mVisibleChunks;
+ uint16_t m_instancedChunkCount;
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEACTOR_H__
diff --git a/APEX_1.4/module/destructible/include/DestructiblePreviewProxy.h b/APEX_1.4/module/destructible/include/DestructiblePreviewProxy.h
new file mode 100644
index 00000000..2a7429fb
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructiblePreviewProxy.h
@@ -0,0 +1,123 @@
+/*
+ * 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 __DESTRUCTIBLEPREVIEW_PROXY_H__
+#define __DESTRUCTIBLEPREVIEW_PROXY_H__
+
+#include "Apex.h"
+#include "DestructiblePreview.h"
+#include "DestructiblePreviewImpl.h"
+#include "PsUserAllocated.h"
+#include "ApexRWLockable.h"
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class DestructiblePreviewProxy : public DestructiblePreview, public ApexResourceInterface, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructiblePreviewImpl impl;
+
+#pragma warning(disable : 4355) // disable warning about this pointer in argument list
+ DestructiblePreviewProxy(DestructibleAssetImpl& asset, ResourceList& list, const NvParameterized::Interface* params)
+ : impl(this, asset, params)
+ {
+ list.add(*this);
+ }
+
+ virtual ~DestructiblePreviewProxy()
+ {
+ }
+
+ // AssetPreview methods
+ virtual void setPose(const PxMat44& pose)
+ {
+ WRITE_ZONE();
+ impl.setPose(pose);
+ }
+
+ virtual const PxMat44 getPose() const
+ {
+ READ_ZONE();
+ return impl.getPose();
+ }
+
+ // DestructiblePreview methods
+
+ virtual const RenderMeshActor* getRenderMeshActor() const
+ {
+ READ_ZONE();
+ return const_cast<const RenderMeshActor*>(impl.getRenderMeshActor());
+ }
+
+ virtual void setExplodeView(uint32_t depth, float explode)
+ {
+ WRITE_ZONE();
+ return impl.setExplodeView(depth, explode);
+ }
+
+ // ApexInterface methods
+ virtual void release()
+ {
+ WRITE_ZONE();
+ impl.release();
+ delete this;
+ }
+ virtual void destroy()
+ {
+ impl.destroy();
+ }
+
+ // Renderable methods
+ virtual void updateRenderResources(bool rewriteBuffers, void* userRenderData)
+ {
+ URR_SCOPE;
+ impl.updateRenderResources(rewriteBuffers, userRenderData);
+ }
+ virtual void dispatchRenderResources(UserRenderer& api)
+ {
+ impl.dispatchRenderResources(api);
+ }
+ virtual PxBounds3 getBounds() const
+ {
+ return impl.getBounds();
+ }
+ virtual void lockRenderResources()
+ {
+ impl.ApexRenderable::renderDataLock();
+ }
+ virtual void unlockRenderResources()
+ {
+ impl.ApexRenderable::renderDataUnLock();
+ }
+
+ // ApexResourceInterface methods
+ virtual void setListIndex(ResourceList& list, uint32_t index)
+ {
+ impl.m_listIndex = index;
+ impl.m_list = &list;
+ }
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLEPREVIEW_PROXY_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleRenderableImpl.h b/APEX_1.4/module/destructible/include/DestructibleRenderableImpl.h
new file mode 100644
index 00000000..4ca7bf68
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleRenderableImpl.h
@@ -0,0 +1,114 @@
+/*
+ * 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_IMPL_H__
+#define __DESTRUCTIBLE_RENDERABLE_IMPL_H__
+
+#include "Apex.h"
+#include "DestructibleActor.h"
+#include "DestructibleRenderable.h"
+#include "ApexRWLockable.h"
+#include "ApexActor.h"
+#if APEX_RUNTIME_FRACTURE
+#include "../fracture/Renderable.h"
+#endif
+
+#include "ReadCheck.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class RenderMeshActor;
+}
+
+namespace destructible
+{
+
+class DestructibleActorImpl;
+
+class DestructibleRenderableImpl : public DestructibleRenderable, public ApexRenderable, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ DestructibleRenderableImpl(RenderMeshActor* renderMeshActors[DestructibleActorMeshType::Count], DestructibleAssetImpl* asset, int32_t listIndex);
+ ~DestructibleRenderableImpl();
+
+ // Begin DestructibleRenderable methods
+ virtual RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const
+ {
+ READ_ZONE();
+ return (uint32_t)type < DestructibleActorMeshType::Count ? mRenderMeshActors[type] : NULL;
+ }
+
+ virtual void release();
+ // End DestructibleRenderable methods
+
+ // Begin Renderable methods
+ virtual void updateRenderResources(bool rewriteBuffers, void* userRenderData);
+
+ virtual void dispatchRenderResources(UserRenderer& api);
+
+ virtual PxBounds3 getBounds() const
+ {
+ PxBounds3 bounds = ApexRenderable::getBounds();
+#if APEX_RUNTIME_FRACTURE
+ bounds.include(mRTrenderable.getBounds());
+#endif
+ return bounds;
+ }
+
+ virtual void lockRenderResources()
+ {
+ ApexRenderable::renderDataLock();
+ }
+
+ virtual void unlockRenderResources()
+ {
+ ApexRenderable::renderDataUnLock();
+ }
+ // End Renderable methods
+
+ // Begin DestructibleRenderable methods
+ // Returns this if successful, NULL otherwise
+ DestructibleRenderableImpl* incrementReferenceCount();
+
+ int32_t getReferenceCount()
+ {
+ return mRefCount;
+ }
+
+ void setBounds(const PxBounds3& bounds)
+ {
+ mRenderBounds = bounds;
+ }
+ // End DestructibleRenderable methods
+
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::Renderable& getRTrenderable() { return mRTrenderable; }
+#endif
+
+private:
+
+ RenderMeshActor* mRenderMeshActors[DestructibleActorMeshType::Count]; // Indexed by DestructibleActorMeshType::Enum
+ DestructibleAssetImpl* mAsset;
+ int32_t mListIndex;
+ volatile int32_t mRefCount;
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::Renderable mRTrenderable;
+#endif
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLE_RENDERABLE_IMPL_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleScene.h b/APEX_1.4/module/destructible/include/DestructibleScene.h
new file mode 100644
index 00000000..69eb83d2
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleScene.h
@@ -0,0 +1,1249 @@
+/*
+ * 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_SCENE_H__
+#define __DESTRUCTIBLE_SCENE_H__
+
+#include "Apex.h"
+#include "SceneIntl.h"
+#include "ModuleIntl.h"
+#include "DestructibleActorImpl.h"
+#include "DestructibleAssetImpl.h"
+#include "DestructibleStructure.h"
+#include "ModuleDestructibleImpl.h"
+#include "PsHashMap.h"
+#include "PsHashSet.h"
+
+#include <PxSimulationEventCallback.h>
+#include <PxContactModifyCallback.h>
+
+#include "DestructibleActorJoint.h"
+
+#include "RenderDebugInterface.h"
+
+#include "DebugRenderParams.h"
+#include "DestructibleDebugRenderParams.h"
+
+#include "PsTime.h"
+#include "PsMutex.h"
+#include "ApexContext.h"
+
+#include "PxTaskManager.h"
+#include "PxTask.h"
+
+#if APEX_RUNTIME_FRACTURE
+#include "SimScene.h"
+#endif
+
+#include "ModulePerfScope.h"
+
+// We currently have to copy into the contact buffer because the native contact
+// stream is compressed within PhysX. If we need to optimize we could use a
+// contact iterator like what's found in PxContactPair::extractContacts()
+#define USE_EXTRACT_CONTACTS 1
+#define PAIR_POINT_ALLOCS 0
+
+#ifndef PX_VERIFY
+#ifndef NDEBUG
+#define PX_VERIFY(f) PX_ASSERT(f)
+#else // NDEBUG
+#define PX_VERIFY(f) ((void)(f))
+#endif
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+static const int32_t MAX_SHAPE_COUNT = 256;
+
+class ModuleDestructibleImpl;
+class DestructibleScene;
+class DestructibleActorProxy;
+class DestructibleBeforeTick;
+
+struct IndexedReal
+{
+ float value;
+ uint32_t index;
+
+ PX_INLINE bool operator > (IndexedReal& i)
+ {
+ return value > i.value;
+ }
+};
+
+
+class DestructibleContactModify : public PxContactModifyCallback
+{
+public:
+ DestructibleContactModify() : destructibleScene(NULL) {}
+
+ void onContactModify(physx::PxContactModifyPair* const pairs, uint32_t count);
+
+ DestructibleScene* destructibleScene;
+};
+
+class DestructibleUserNotify : public PxSimulationEventCallback
+{
+public:
+ DestructibleUserNotify(ModuleDestructibleImpl& module, DestructibleScene* destructibleScene);
+
+private:
+ virtual void onConstraintBreak(physx::PxConstraintInfo* constraints, uint32_t count);
+ virtual void onWake(PxActor** actors, uint32_t count);
+ virtual void onSleep(PxActor** actors, uint32_t count);
+ virtual void onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, uint32_t nbPairs);
+ virtual void onTrigger(physx::PxTriggerPair* pairs, uint32_t count);
+ virtual void onAdvance(const PxRigidBody*const* bodyBuffer, const PxTransform* poseBuffer, const PxU32 count);
+
+ void operator=(const DestructibleUserNotify&) {}
+
+private:
+ ModuleDestructibleImpl& mModule;
+ DestructibleScene* mDestructibleScene;
+#if USE_EXTRACT_CONTACTS
+ physx::Array<uint8_t> mPairPointBuffer;
+#endif
+};
+
+
+class ApexDamageEventReportDataImpl : public DamageEventReportData
+{
+public:
+ ApexDamageEventReportDataImpl()
+ {
+ clear();
+ }
+
+ ApexDamageEventReportDataImpl(const ApexDamageEventReportDataImpl& other)
+ {
+ *this = other;
+ }
+
+ ApexDamageEventReportDataImpl& operator = (const ApexDamageEventReportDataImpl& other)
+ {
+ m_destructible = other.m_destructible;
+ m_fractureEvents = other.m_fractureEvents;
+ m_chunkReportBitMask = other.m_chunkReportBitMask;
+ m_chunkReportMaxFractureEventDepth = other.m_chunkReportMaxFractureEventDepth;
+ destructible = other.destructible;
+ hitDirection = other.hitDirection;
+ worldBounds = other.worldBounds;
+ totalNumberOfFractureEvents = other.totalNumberOfFractureEvents;
+ minDepth = other.minDepth;
+ maxDepth = other.maxDepth;
+ fractureEventList = m_fractureEvents.size() > 0 ? &m_fractureEvents[0] : NULL;
+ fractureEventListSize = m_fractureEvents.size();
+ impactDamageActor = other.impactDamageActor;
+ appliedDamageUserData = other.appliedDamageUserData;
+ hitPosition = other.hitPosition;
+ return *this;
+ }
+
+ void setDestructible(DestructibleActorImpl* inDestructible);
+
+ uint32_t addFractureEvent(const DestructibleStructure::Chunk& chunk, uint32_t flags);
+
+ ChunkData& getFractureEvent(uint32_t index)
+ {
+ return m_fractureEvents[index];
+ }
+
+ void clearChunkReports();
+
+private:
+ void clear()
+ {
+ m_destructible = NULL;
+ m_fractureEvents.reset();
+ m_chunkReportBitMask = 0xffffffff;
+ m_chunkReportMaxFractureEventDepth = 0xffffffff;
+ destructible = NULL;
+ hitDirection = PxVec3(0.0f);
+ worldBounds.setEmpty();
+ totalNumberOfFractureEvents = 0;
+ minDepth = 0xffff;
+ maxDepth = 0;
+ fractureEventList = NULL;
+ fractureEventListSize = 0;
+ impactDamageActor = NULL;
+ appliedDamageUserData = NULL;
+ hitPosition = PxVec3(0.0f);
+ }
+
+ DestructibleActorImpl* m_destructible;
+ physx::Array<ChunkData> m_fractureEvents;
+ uint32_t m_chunkReportBitMask;
+ uint32_t m_chunkReportMaxFractureEventDepth;
+};
+
+struct ActorFIFOEntry
+{
+ enum Flag
+ {
+ IsDebris = 1 << 0,
+ ForceLODRemove = 1 << 1,
+
+ MassUpdateNeeded = 1 << 8,
+ };
+
+ ActorFIFOEntry() : actor(NULL), origin(0.0f), age(0.0f), benefitCache(PX_MAX_F32), maxSpeed(0.0f), averagedLinearVelocity(0.0f), averagedAngularVelocity(0.0f), unscaledMass(0.0f), flags(0) {}
+ ActorFIFOEntry(PxRigidDynamic* inActor, float inUnscaledMass, uint32_t inFlags) : actor(inActor), age(0.0f), benefitCache(PX_MAX_F32), maxSpeed(0.0f),
+ averagedLinearVelocity(0.0f), averagedAngularVelocity(0.0f), unscaledMass(inUnscaledMass), flags(inFlags)
+ {
+ SCOPED_PHYSX_LOCK_READ(actor->getScene());
+ origin = (actor->getGlobalPose() * actor->getCMassLocalPose()).p;
+ }
+
+ PxRigidDynamic* actor;
+ PxVec3 origin;
+ float age;
+ float benefitCache; //for LOD
+ float maxSpeed;
+ PxVec3 averagedLinearVelocity;
+ PxVec3 averagedAngularVelocity;
+ float unscaledMass;
+ uint32_t flags;
+};
+
+struct DormantActorEntry
+{
+ DormantActorEntry() : actor(NULL), unscaledMass(0.0f), flags(0) {}
+ DormantActorEntry(PxRigidDynamic* inActor, float inUnscaledMass, uint32_t inFlags) : actor(inActor), unscaledMass(inUnscaledMass), flags(inFlags) {}
+
+ PxRigidDynamic* actor;
+ float unscaledMass;
+ uint32_t flags;
+};
+
+struct ChunkBenefitCoefs
+{
+ ChunkBenefitCoefs() : perChunkInitialBenefit(1.0f), benefitDecayTimeConstant(1.0f), benefitPerPercentScreenArea(1.0f) {}
+
+ float perChunkInitialBenefit;
+ float benefitDecayTimeConstant;
+ float benefitPerPercentScreenArea;
+};
+
+struct ChunkCostCoefs
+{
+ ChunkCostCoefs() : perChunkCost(1.0f) {}
+
+ float perChunkCost;
+};
+
+
+/* Class which manages DestructibleActors and DestructibleStructures
+ * associate with a single Scene
+ */
+
+class DestructibleScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource
+{
+public:
+ DestructibleScene(ModuleDestructibleImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list);
+ ~DestructibleScene();
+
+ /* ModuleSceneIntl */
+ virtual void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps);
+ virtual void setTaskDependencies();
+ virtual void tasked_beforeTick(float elapsedTime);
+ virtual void fetchResults();
+
+ virtual void setModulePhysXScene(PxScene* s);
+ virtual PxScene* getModulePhysXScene() const
+ {
+ return mPhysXScene;
+ }
+ virtual void release()
+ {
+ mModule->releaseModuleSceneIntl(*this);
+ }
+ virtual void visualize();
+
+ virtual Module* getModule()
+ {
+ return mModule;
+ }
+
+ ModuleDestructibleImpl* getModuleDestructible() const
+ {
+ return mModule;
+ }
+
+ SceneIntl* getApexScene()
+ {
+ return mApexScene;
+ }
+
+ void initModuleSettings();
+
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::SimScene* getDestructibleRTScene(bool create = true);
+#endif
+
+ enum StatsDataEnum
+ {
+ VisibleDestructibleChunkCount,
+ DynamicDestructibleChunkIslandCount,
+ NumberOfShapes,
+ NumberOfAwakeShapes,
+ RbThroughput,
+
+ // insert new items before this line
+ NumberOfStats // The number of stats
+ };
+
+ virtual SceneStats* getStats();
+
+ /* ApexResourceInterface */
+ uint32_t getListIndex() const
+ {
+ return m_listIndex;
+ }
+ void setListIndex(ResourceList& list, uint32_t index)
+ {
+ m_listIndex = index;
+ m_list = &list;
+ }
+
+ /* DestructibleScene methods */
+
+ void applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff);
+
+ bool isActorCreationRateExceeded();
+ bool isFractureBufferProcessRateExceeded();
+
+ void addToAwakeList(DestructibleActorImpl& actor);
+ void removeFromAwakeList(DestructibleActorImpl& actor);
+
+ enum
+ {
+ InvalidReportID = 0xFFFFFFFF
+ };
+
+private:
+
+ void addActorsToScene();
+ physx::Array<physx::PxActor*> mActorsToAdd;
+ HashMap<physx::PxActor*, uint32_t> mActorsToAddIndexMap;
+
+ void addForceToAddActorsMap(physx::PxActor* actor, const ActorForceAtPosition& force);
+ HashMap<physx::PxActor*, ActorForceAtPosition> mForcesToAddToActorsMap;
+
+ ModuleDestructibleImpl* mModule;
+ SceneIntl* mApexScene;
+ PxScene* mPhysXScene;
+ DestructibleContactModify mContactModify;
+
+ ResourceList mDestructibleActorJointList;
+ DestructibleBeforeTick* mBeforeTickTask;
+
+ DestructibleUserNotify mUserNotify;
+ SceneStats mModuleSceneStats;
+ float mElapsedTime;
+
+ physx::Array<DestructibleActorImpl*> mInstancedActors;
+
+#if APEX_RUNTIME_FRACTURE
+ ::nvidia::fracture::SimScene* mRTScene;
+#endif
+
+ // These values are set per-scene by the destruction module
+ float mMassScale;
+ float mMassScaleInv;
+ float mScaledMassExponent;
+ float mScaledMassExponentInv;
+
+ int mPreviousVisibleDestructibleChunkCount; // Must keep previous value because of our goofy cumulative-only stats system
+ int mPreviousDynamicDestructibleChunkIslandCount; // Must keep previous value because of our goofy cumulative-only stats system
+
+public:
+ void destroy();
+ void reset();
+ DestructibleActorJoint* createDestructibleActorJoint(const DestructibleActorJointDesc& destructibleActorJointDesc);
+ DestructibleActor* getDestructibleAndChunk(const PxShape* shape, int32_t* chunkIndex) const;
+
+ bool insertDestructibleActor(DestructibleActor* destructible);
+
+ bool removeStructure(DestructibleStructure* structure, bool immediate = true);
+ void addActor(PhysXObjectDescIntl& desc, PxRigidDynamic& actor, float unscaledMass, bool isDebris);
+ bool destroyActorChunks(PxRigidDynamic& actor, uint32_t chunkFlag);
+ void capDynamicActorCount();
+ void removeReferencesToActor(DestructibleActorImpl& actor);
+
+ void addInstancedActor(DestructibleActorImpl* actor)
+ {
+ mInstancedActors.pushBack(actor);
+ }
+
+ void releasePhysXActor(PxRigidDynamic& actor);
+
+ void resetEmitterActors();
+
+ PxRigidDynamic* createRoot(DestructibleStructure::Chunk& chunk, const PxTransform& pose, bool dynamic, PxTransform* relTM = NULL, bool fromInitialData = false);
+ bool appendShapes(DestructibleStructure::Chunk& chunk, bool dynamic, PxTransform* relTM = NULL, PxRigidDynamic* actor = NULL);
+
+ void setWorldSupportPhysXScene(PxScene* physxScene)
+ {
+ m_worldSupportPhysXScene = physxScene;
+ }
+
+ bool testWorldOverlap(const ConvexHullImpl& convexHull, const PxTransform& tm, const PxVec3& scale, float padding, const physx::PxFilterData* groupsMask = NULL);
+
+ DestructibleStructure* getChunkStructure(DestructibleStructure::Chunk& chunk) const
+ {
+ return mDestructibles.direct(chunk.destructibleID)->getStructure();
+ }
+
+ DestructibleStructure::Chunk* getChunk(const PxShape* shape) const
+ {
+ // TODO: this fires all the time with PhysX3
+ //PX_ASSERT(mModule->owns((PxActor*)&shape->getActor()));
+ const PxRigidActor* actor = shape->getActor();
+
+ if (!mModule->owns(actor))
+ {
+ return NULL;
+ }
+
+ const PhysXObjectDesc* shapeDesc = mModule->mSdk->getPhysXObjectInfo(shape);
+ if (shapeDesc == NULL)
+ {
+ return NULL;
+ }
+
+ return (DestructibleStructure::Chunk*)shapeDesc->userData;
+ }
+
+ const DestructibleActorImpl* getChunkActor(const DestructibleStructure::Chunk& chunk) const
+ {
+ return mDestructibles.direct(chunk.destructibleID);
+ }
+
+ PX_INLINE void createChunkReportDataForFractureEvent(const FractureEvent& fractureEvent, DestructibleActorImpl* destructible, DestructibleStructure::Chunk& chunk)
+ {
+ PX_UNUSED(fractureEvent); // Keeping this parameter assuming we'll merge in a later change which requires fractureEvent
+ PX_ASSERT(destructible != NULL && destructible->mDamageEventReportIndex < mDamageEventReportData.size());
+ if (destructible != NULL && destructible->mDamageEventReportIndex < mDamageEventReportData.size())
+ {
+ ApexDamageEventReportDataImpl& damageReportData = mDamageEventReportData[destructible->mDamageEventReportIndex];
+ const uint32_t fractureEventIndex = damageReportData.addFractureEvent(chunk, ApexChunkFlag::FRACTURED);
+ mFractureEventCount++;
+ chunk.reportID = mChunkReportHandles.size();
+ IntPair& handle = mChunkReportHandles.insert();
+ handle.set((int32_t)destructible->mDamageEventReportIndex, (int32_t)fractureEventIndex);
+ }
+ }
+
+ PX_INLINE ChunkData* getChunkReportData(DestructibleStructure::Chunk& chunk, uint32_t flags);
+
+ PX_INLINE PxRigidDynamic* chunkIntact(DestructibleStructure::Chunk& chunk);
+
+ bool scheduleChunkShapesForDelete(DestructibleStructure::Chunk& chunk);
+ bool schedulePxActorForDelete(PhysXObjectDescIntl& actorDesc);
+
+ PX_INLINE void calculatePotentialCostAndBenefit(float& cost, float& benefit, physx::Array<uint8_t*>& trail, physx::Array<uint8_t>& undo, const FractureEvent& fractureEvent) const;
+
+ template <class ChunkOpClass>
+ void forSubtree(DestructibleStructure::Chunk& chunk, ChunkOpClass chunkOp, bool skipRoot = false);
+
+ bool setMassScaling(float massScale, float scaledMassExponent);
+
+ void invalidateBounds(const PxBounds3* bounds, uint32_t boundsCount);
+
+ void setDamageApplicationRaycastFlags(nvidia::DestructibleActorRaycastFlags::Enum flags);
+
+ nvidia::DestructibleActorRaycastFlags::Enum getDamageApplicationRaycastFlags() const { return (nvidia::DestructibleActorRaycastFlags::Enum)m_damageApplicationRaycastFlags; }
+
+ PX_INLINE float scaleMass(float mass)
+ {
+ if (PxAbs(mScaledMassExponent - 0.5f) < 1e-7)
+ {
+ return mMassScale * PxSqrt(mass * mMassScaleInv);
+ }
+ return mMassScale * PxPow(mass * mMassScaleInv, mScaledMassExponent);
+ }
+
+ PX_INLINE float unscaleMass(float scaledMass)
+ {
+ if (PxAbs(mScaledMassExponentInv - 2.f) < 1e-7)
+ {
+ float tmp = scaledMass * mMassScaleInv;
+ return mMassScale * tmp * tmp;
+ }
+ return mMassScale * PxPow(scaledMass * mMassScaleInv, mScaledMassExponentInv);
+ }
+
+ void updateActorPose(DestructibleActorImpl* actor, UserChunkMotionHandler* callback)
+ {
+ const bool processChunkPoseForSyncing = ((NULL != callback) && ( actor->getSyncParams().isSyncFlagSet(DestructibleActorSyncFlags::CopyChunkTransform) ||
+ actor->getSyncParams().isSyncFlagSet(DestructibleActorSyncFlags::ReadChunkTransform)));
+ actor->setRenderTMs(processChunkPoseForSyncing);
+ }
+
+ bool setRenderLockMode(RenderLockMode::Enum renderLockMode)
+ {
+ if ((int)renderLockMode < 0 || (int)renderLockMode > RenderLockMode::PER_MODULE_SCENE_RENDER_LOCK)
+ {
+ return false;
+ }
+
+ mRenderLockMode = renderLockMode;
+
+ return true;
+ }
+
+ RenderLockMode::Enum getRenderLockMode() const
+ {
+ return mRenderLockMode;
+ }
+
+ bool lockModuleSceneRenderLock()
+ {
+ return mRenderDataLock.lock();
+ }
+
+ bool unlockModuleSceneRenderLock()
+ {
+ return mRenderDataLock.unlock();
+ }
+
+ bool lockRenderResources()
+ {
+ switch (getRenderLockMode())
+ {
+ case RenderLockMode::PER_ACTOR_RENDER_LOCK:
+ renderLockAllActors();
+ return true;
+ case RenderLockMode::PER_MODULE_SCENE_RENDER_LOCK:
+ return lockModuleSceneRenderLock();
+ case RenderLockMode::NO_RENDER_LOCK:
+ break;
+ }
+ return true;
+ }
+
+ bool unlockRenderResources()
+ {
+ switch (getRenderLockMode())
+ {
+ case RenderLockMode::PER_ACTOR_RENDER_LOCK:
+ renderUnLockAllActors();
+ return true;
+ case RenderLockMode::PER_MODULE_SCENE_RENDER_LOCK:
+ return unlockModuleSceneRenderLock();
+ case RenderLockMode::NO_RENDER_LOCK:
+ break;
+ }
+ return true;
+ }
+
+ physx::Array<ApexDamageEventReportDataImpl> mDamageEventReportData;
+ physx::Array<IntPair> mChunkReportHandles; // i0 = m_damageEventReportData index, i1 = ApexDamageEventReportDataImpl::m_fractureEvents
+
+ physx::Array<ImpactDamageEventData> mImpactDamageEventData; // Impact damage notify
+
+ physx::Array<DestructibleActorImpl*> mActorsWithChunkStateEvents; // Filled when module->m_chunkStateEventCallbackSchedule is not DestructibleCallbackSchedule::Disabled
+
+ void setStructureSupportRebuild(DestructibleStructure* structure, bool rebuild);
+ void setStructureUpdate(DestructibleStructure* structure, bool update);
+ void setStressSolverTick(DestructibleStructure* structure, bool update);
+
+ // FIFO
+ physx::Array<ActorFIFOEntry> mActorFIFO;
+ physx::Array<IndexedReal> mActorBenefitSortArray;
+ uint32_t mDynamicActorFIFONum; // Tracks the valid entries in actorFIFO;
+ uint32_t mTotalChunkCount; // Tracks the chunks;
+
+ uint32_t mNumFracturesProcessedThisFrame;
+ uint32_t mNumActorsCreatedThisFrame;
+
+ uint32_t mFractureEventCount;
+
+ // DestructibleActors with scene-global IDs
+ Bank<DestructibleActorImpl*, uint32_t> mDestructibles;
+
+ // Structure container
+ Bank<DestructibleStructure*, uint32_t> mStructures;
+ physx::Array<DestructibleStructure*> mStructureKillList;
+ Bank<DestructibleStructure*, uint32_t> mStructureUpdateList;
+ Bank<DestructibleStructure*, uint32_t> mStructureSupportRebuildList;
+ Bank<DestructibleStructure*, uint32_t> mStressSolverTickList;
+
+ // For delayed release of PxRigidDynamics
+ physx::Array<PxRigidDynamic*> mActorKillList;
+ ResourceList mApexActorKillList;
+
+ // Damage queue
+ RingBuffer<DamageEvent> mDamageBuffer[2]; // Double-buffering
+ uint32_t mDamageBufferWriteIndex;
+
+ // Fracture queue
+ RingBuffer<FractureEvent> mFractureBuffer;
+
+ // Destroy queue
+ physx::Array<IntPair> mChunkKillList;
+
+ // Destructibles on death row
+ physx::Array<DestructibleActor*> destructibleActorKillList;
+
+ // Bank of dormant (kinematic dynamic) actors
+ Bank<DormantActorEntry, uint32_t> mDormantActors;
+
+ // list of awake destructible actor IDs (mDestructibles bank)
+ IndexBank<uint32_t> mAwakeActors;
+ bool mUsingActiveTransforms;
+
+ // Wake/sleep event actors
+ physx::Array<DestructibleActor*> mOnWakeActors;
+ physx::Array<DestructibleActor*> mOnSleepActors;
+
+ physx::Array<physx::PxClientID> mSceneClientIDs;
+
+ // Scene to use for world support calculations if NULL, mPhysXScene is used
+ physx::PxScene* m_worldSupportPhysXScene;
+
+ physx::Array<PxBounds3> m_invalidBounds;
+
+ uint32_t m_damageApplicationRaycastFlags;
+
+ RenderDebugInterface* mDebugRender; //debug renderer created and owned by the owning ApexScene and passed down. Not owned.
+
+ DebugRenderParams* mDebugRenderParams;
+ DestructibleDebugRenderParams* mDestructibleDebugRenderParams;
+
+ physx::Array<physx::PxOverlapHit> mOverlapHits;
+
+ RenderLockMode::Enum mRenderLockMode;
+
+ AtomicLock mRenderDataLock;
+
+ // Access to the double-buffered damage events
+ RingBuffer<DamageEvent>& getDamageWriteBuffer()
+ {
+ return mDamageBuffer[mDamageBufferWriteIndex];
+ }
+ RingBuffer<DamageEvent>& getDamageReadBuffer()
+ {
+ return mDamageBuffer[mDamageBufferWriteIndex^1];
+ }
+ void swapDamageBuffers()
+ {
+ mDamageBufferWriteIndex ^= 1;
+ }
+
+ class CollectVisibleChunks
+ {
+ physx::Array<DestructibleStructure::Chunk*>& chunkArray;
+
+ public:
+
+ CollectVisibleChunks(physx::Array<DestructibleStructure::Chunk*>& inChunkArray) :
+ chunkArray(inChunkArray) {}
+
+ bool execute(DestructibleStructure* structure, DestructibleStructure::Chunk& chunk)
+ {
+ PX_UNUSED(structure);
+ if ((chunk.state & ChunkVisible) != 0)
+ {
+ chunkArray.pushBack(&chunk);
+ return false;
+ }
+ return true;
+ }
+ private:
+ CollectVisibleChunks& operator=(const CollectVisibleChunks&);
+ };
+
+ class VisibleChunkSetDescendents
+ {
+ uint32_t visibleChunkIndex;
+ uint8_t raiseStateFlags;
+
+ public:
+ VisibleChunkSetDescendents(uint32_t chunkIndex, bool makeDynamic)
+ : visibleChunkIndex(chunkIndex)
+ , raiseStateFlags(makeDynamic ? (uint8_t)ChunkDynamic : (uint8_t)0)
+ {
+ }
+ bool execute(DestructibleStructure* structure, DestructibleStructure::Chunk& chunk)
+ {
+ PX_UNUSED(structure);
+ chunk.clearShapes();
+ chunk.state |= raiseStateFlags; // setting dynamic flag, but these chunks are descendents of a visible chunk and therefore invisible. No need to update visible dynamic chunk shape counts
+ chunk.visibleAncestorIndex = (int32_t)visibleChunkIndex;
+ return true;
+ }
+ };
+
+ class ChunkClearDescendents
+ {
+ int32_t rootChunkIndex;
+
+ public:
+ ChunkClearDescendents(int32_t chunkIndex) : rootChunkIndex(chunkIndex) {}
+
+ bool execute(DestructibleStructure* structure, DestructibleStructure::Chunk& chunk)
+ {
+ PX_UNUSED(structure);
+ if (chunk.visibleAncestorIndex == rootChunkIndex)
+ {
+ chunk.clearShapes();
+ chunk.visibleAncestorIndex = DestructibleStructure::InvalidChunkIndex;
+ }
+ return true;
+ }
+ };
+
+ class ChunkLoadState
+ {
+ public:
+ ChunkLoadState(DestructibleScene& scene) : mScene(scene) { }
+ bool execute(DestructibleStructure* structure, DestructibleStructure::Chunk& chunk);
+ private:
+ ChunkLoadState& operator=(const ChunkLoadState&);
+ DestructibleScene& mScene;
+ };
+
+private:
+ void createModuleStats();
+ void destroyModuleStats();
+ void setStatValue(int32_t index, StatValue dataVal);
+ static PX_INLINE float ticksToMilliseconds(uint64_t t0, uint64_t t1)
+ {
+ // this is a copy of ApexScene::tickToMilliseconds. Unfortunately can't easily use the other
+ static const CounterFrequencyToTensOfNanos freq = nvidia::Time::getBootCounterFrequency();
+ static const double freqMultiplier = (double)freq.mNumerator/(double)freq.mDenominator * 0.00001; // convert from 10nanoseconds to milliseconds
+
+ float ret = (float)((double)(t1 - t0) * freqMultiplier);
+ return ret;
+ }
+
+ friend class DestructibleActorImpl;
+ friend class DestructibleActorProxy;
+ friend class DestructibleActorJointImpl;
+ friend class DestructibleStructure;
+ friend class DestructibleContactReport;
+ friend class DestructibleContactModify;
+ friend class OverlapSphereShapesReport;
+ friend class ModuleDestructibleImpl;
+ friend class ApexDamageEventReportDataImpl;
+ friend class DestructibleUserNotify;
+
+ /*
+ <--- Destructible Sync-ables Memory Layout --->
+
+ all actor data => buffer (consists of)
+ per actor data => segment (consists of)
+ 1) header
+ 1.1) userActorID
+ 1.2) _X_unit count, pointer to _X_buffer start
+ 1.3) _Y_unit count, pointer to _Y_buffer start
+ 1.4) pointer to next header. NULL if last
+ 2) _X_buffer
+ 2.1) made up of '_X_count' of '_X_unit'
+ 3) _Y_buffer (if used)
+ 3.1) made up of '_Y_count' of '_Y_unit'
+
+ |-------------|----------|---------------|----------|---------------|------|-----------|-----------|-----------------
+ | userActorID | _X_count | _X_buffer_ptr | _Y_count | _Y_buffer_ptr | next | _X_buffer | _Y_buffer | userActorID ...
+ |-------------|----------|---------------|----------|---------------|------|-----------|-----------|-----------------
+
+ <------------------------------------------------------ buffer ------------------------------------------------------...
+ <-------------------------------------------- segment -------------------------------------------->
+ <--------------------------------- header --------------------------------->
+ <-----------> uniform buffer
+ <-----------> uniform buffer
+
+
+ <--- Destructible Sync-ables Function Call Flow --->
+
+ 1) write
+ onProcessWriteData()
+ loadDataForWrite()
+ interceptLoad()
+ processWriteBuffer()
+ getBufferSizeRequired()
+ getSegmentSizeRequired()
+ callback.onWriteBegin()
+ writeUserBuffer()
+ writeUserSegment()
+ writeUserUniformBuffer()
+ interpret()
+ interceptEdit()
+ callback.onWriteDone()
+ unloadDataForWrite()
+
+ ___buffer full___
+ a) after generateFractureProfilesInDamageBuffer()
+ before fillFractureBufferFromDamage()
+ b) before processFractureBuffer()
+ c) after fetchResults()
+ actor->setRenderTMs()
+
+ 2) read
+ onPreProcessReadData()
+ processReadBuffer()
+ callback.onPreProcessReadBegin()
+ writeUserBufferPointers()
+ callback.onPreProcessReadDone()
+ callback.onReadBegin()
+ loadDataForRead()
+
+ ___begin read___
+ a) generateFractureProfilesInDamageBuffer()
+ interpret()
+ interceptEdit()
+ fillFractureBufferFromDamage()
+ b) processFractureBuffer()
+ interpret()
+ interceptEdit()
+ c) fetchResults()
+ actor->setRenderTMs()
+ ___end read___
+
+ onPostProcessReadData()
+ unloadDataForRead()
+ callback.onReadDone()
+ */
+
+ /*** DestructibleScene::SyncParams ***/
+public:
+ class SyncParams
+ {
+ public:
+ struct UserDamageEvent;
+ struct UserFractureEvent;
+ explicit SyncParams(const ModuleDestructibleImpl::SyncParams & moduleParams);
+ ~SyncParams();
+ public:
+ bool setSyncActor(uint32_t entryIndex, DestructibleActorImpl * entry, DestructibleActorImpl *& erasedEntry);
+ private:
+ DestructibleActorImpl * getSyncActor(uint32_t entryIndex) const;
+ uint32_t getUserActorID(uint32_t destructibleID) const;
+
+ public: //read and write - public APIs
+ void onPreProcessReadData(UserDamageEventHandler & callback, const physx::Array<UserDamageEvent> *& userSource);
+ void onPreProcessReadData(UserFractureEventHandler & callback, const physx::Array<UserFractureEvent> *& userSource);
+ void onPreProcessReadData(UserChunkMotionHandler & callback);
+
+ DamageEvent & interpret(const UserDamageEvent & userDamageEvent);
+ FractureEvent & interpret(const UserFractureEvent & userFractureEvent);
+ void interceptEdit(DamageEvent & damageEvent, const DestructibleActorImpl::SyncParams & actorParams) const;
+ void interceptEdit(FractureEvent & fractureEvent, const DestructibleActorImpl::SyncParams & actorParams) const;
+
+ void onPostProcessReadData(UserDamageEventHandler & callback);
+ void onPostProcessReadData(UserFractureEventHandler & callback);
+ void onPostProcessReadData(UserChunkMotionHandler & callback);
+
+ void onProcessWriteData(UserDamageEventHandler & callback, const RingBuffer<DamageEvent> & localSource);
+ void onProcessWriteData(UserFractureEventHandler & callback, const RingBuffer<FractureEvent> & localSource);
+ void onProcessWriteData(UserChunkMotionHandler & callback);
+
+ private: //read - helper functions
+ void loadDataForRead(const DamageEventHeader * bufferStart, const physx::Array<UserDamageEvent> *& userSource);
+ void loadDataForRead(const FractureEventHeader * bufferStart, const physx::Array<UserFractureEvent> *& userSource);
+ void loadDataForRead(const ChunkTransformHeader * bufferStart);
+
+ bool unloadDataForRead(const UserDamageEventHandler & dummy);
+ bool unloadDataForRead(const UserFractureEventHandler & dummy);
+ bool unloadDataForRead(const UserChunkMotionHandler & dummy);
+
+ template<typename Callback, typename Header, typename Unit> const Header * processReadBuffer(Callback & callback) const;
+ template<typename Header, typename Unit> int32_t writeUserBufferPointers(Header * bufferStart, uint32_t bufferSize) const;
+ template<typename Callback> void postProcessReadData(Callback & callback);
+
+ private: //write - helper functions
+ uint32_t loadDataForWrite(const RingBuffer<DamageEvent> & localSource);
+ uint32_t loadDataForWrite(const RingBuffer<FractureEvent> & localSource);
+ uint32_t loadDataForWrite(const UserChunkMotionHandler & dummy);
+
+ void unloadDataForWrite(const UserDamageEventHandler & dummy);
+ void unloadDataForWrite(const UserFractureEventHandler & dummy);
+ void unloadDataForWrite(const UserChunkMotionHandler & dummy);
+
+ template<typename Callback, typename Header, typename Unit> uint32_t processWriteBuffer(Callback & callback);
+ template<typename Header, typename Unit> uint32_t getBufferSizeRequired() const;
+ template<typename Header, typename Unit> uint32_t getSegmentSizeRequired(const DestructibleActorImpl::SyncParams & actorParams) const;
+ template<typename Header, typename Unit> uint32_t writeUserBuffer(Header * bufferStart, uint32_t & headerCount);
+ template<typename Header, typename Unit> uint32_t writeUserSegment(Header * header, bool isLast, const DestructibleActorImpl::SyncParams & actorParams);
+ template<typename Unit> uint32_t writeUserUniformBuffer(Unit * bufferStart, const DestructibleActorImpl::SyncParams & actorParams);
+
+ bool interceptLoad(const DamageEvent & damageEvent, const DestructibleActorImpl & syncActor) const;
+ bool interceptLoad(const FractureEvent & fractureEvent, const DestructibleActorImpl & syncActor) const;
+ DamageEventUnit * interpret(const DamageEvent & damageEvent);
+ FractureEventUnit * interpret(const FractureEvent & fractureEvent);
+ void interceptEdit(DamageEventUnit & nxApexDamageEventUnit, const DestructibleActorImpl::SyncParams & actorParams) const;
+ void interceptEdit(FractureEventUnit & nxApexFractureEventUnit, const DestructibleActorImpl::SyncParams & actorParams) const;
+
+ private: //read and write - template helper functions
+ template<typename Item> uint32_t getUniformBufferCount(const DamageEventHeader & header) const;
+ template<typename Item> uint32_t getUniformBufferCount(const FractureEventHeader & header) const;
+ template<typename Item> uint32_t getUniformBufferCount(const ChunkTransformHeader & header) const;
+
+ template<typename Item> uint32_t & getUniformBufferCountMutable(DamageEventHeader & header) const;
+ template<typename Item> uint32_t & getUniformBufferCountMutable(FractureEventHeader & header) const;
+ template<typename Item> uint32_t & getUniformBufferCountMutable(ChunkTransformHeader & header) const;
+
+ template<typename Item> Item * getUniformBufferStart(const DamageEventHeader & header) const;
+ template<typename Item> Item * getUniformBufferStart(const FractureEventHeader & header) const;
+ template<typename Item> Item * getUniformBufferStart(const ChunkTransformHeader & header) const;
+
+ template<typename Item> Item *& getUniformBufferStartMutable(DamageEventHeader & header) const;
+ template<typename Item> Item *& getUniformBufferStartMutable(FractureEventHeader & header) const;
+ template<typename Item> Item *& getUniformBufferStartMutable(ChunkTransformHeader & header) const;
+
+#if 1
+ public:
+ bool ditchStaleBuffers;
+ bool lockSyncParams;
+#endif // lionel: TODO...if necessary
+
+ private:
+ SyncParams();
+ DECLARE_DISABLE_COPY_AND_ASSIGN(SyncParams);
+ const ModuleDestructibleImpl::SyncParams & moduleParams;
+ mutable physx::Array<uint32_t> segmentSizeChecker;
+ const RingBuffer<DamageEvent> * damageEventWriteSource;
+ DamageEventUnit damageEventUserInstance;
+ physx::Array<UserDamageEvent> damageEventReadSource;
+ DamageEvent damageEventImplInstance;
+ const RingBuffer<FractureEvent> * fractureEventWriteSource;
+ FractureEventUnit fractureEventUserInstance;
+ physx::Array<UserFractureEvent> fractureEventReadSource;
+ FractureEvent fractureEventImplInstance;
+ physx::Array<DestructibleStructure::Chunk*> chunksWithUserControlledChunk;
+
+ class SyncActorRecord
+ {
+ friend bool DestructibleScene::SyncParams::setSyncActor(uint32_t, DestructibleActorImpl *, DestructibleActorImpl *&);
+ public:
+ SyncActorRecord();
+ ~SyncActorRecord();
+ const physx::Array<uint32_t> & getIndexContainer() const;
+ const physx::Array<DestructibleActorImpl*> & getActorContainer() const;
+ private:
+ DECLARE_DISABLE_COPY_AND_ASSIGN(SyncActorRecord);
+ void onRebuild(const uint32_t & newCount);
+ physx::Array<uint32_t> indexContainer;
+ physx::Array<DestructibleActorImpl*> actorContainer;
+ private:
+ bool assertActorContainerOk() const;
+ } syncActorRecord;
+
+ struct ActorEventPair
+ {
+ public:
+ const DestructibleActorImpl * actorAlias;
+ protected:
+ union
+ {
+ public:
+ const DamageEventUnit * userDamageEvent;
+ const FractureEventUnit * userFractureEvent;
+ };
+ ActorEventPair(const DestructibleActorImpl * actorAlias, const DamageEventUnit * userDamageEvent);
+ ActorEventPair(const DestructibleActorImpl * actorAlias, const FractureEventUnit * userFractureEvent);
+ ~ActorEventPair();
+ private:
+ ActorEventPair();
+ };
+
+ public:
+ struct UserDamageEvent : public ActorEventPair
+ {
+ public:
+ UserDamageEvent(const DestructibleActorImpl * actorAlias, const DamageEventUnit * userDamageEvent);
+ ~UserDamageEvent();
+ const DamageEventUnit * get() const;
+ private:
+ UserDamageEvent();
+ };
+
+ struct UserFractureEvent : public ActorEventPair
+ {
+ public:
+ UserFractureEvent(const DestructibleActorImpl * actorAlias, const FractureEventUnit * userFractureEvent);
+ ~UserFractureEvent();
+ const FractureEventUnit * get() const;
+ private:
+ UserFractureEvent();
+ };
+
+ public:
+ bool assertUserDamageEventOk(const DamageEvent & damageEvent, const DestructibleScene & scene) const;
+ bool assertUserFractureEventOk(const FractureEvent & fractureEvent, const DestructibleScene & scene) const;
+ private:
+ bool assertCachedChunkContainerOk(const DestructibleActorImpl::SyncParams & actorParams) const;
+ bool assertControlledChunkContainerOk() const;
+ private:
+ static const char * errorMissingUserActorID;
+ static const char * errorMissingFlagReadDamageEvents;
+ static const char * errorMissingFlagReadFractureEvents;
+ static const char * errorMissingFlagReadChunkMotion;
+ static const char * errorOutOfBoundsActorChunkIndex;
+ static const char * errorOutOfBoundsStructureChunkIndex;
+ static const char * errorOverrunBuffer;
+ };
+
+ const DestructibleScene::SyncParams & getSyncParams() const;
+ DestructibleScene::SyncParams & getSyncParamsMutable();
+private:
+ SyncParams mSyncParams;
+
+ //these methods participate in the sync process
+private:
+ void processEventBuffers();
+ void generateFractureProfilesInDamageBuffer(nvidia::RingBuffer<DamageEvent> & userDamageBuffer, const physx::Array<SyncParams::UserDamageEvent> * userSource = NULL);
+ void calculateDamageBufferCostProfiles(nvidia::RingBuffer<DamageEvent> & subjectDamageBuffer);
+ void fillFractureBufferFromDamage(nvidia::RingBuffer<DamageEvent> * userDamageBuffer = NULL);
+ void processFractureBuffer();
+ void processFractureBuffer(const physx::Array<SyncParams::UserFractureEvent> * userSource);
+ void processDamageColoringBuffer();
+
+private:
+ RingBuffer<FractureEvent> mDeprioritisedFractureBuffer;
+ RingBuffer<FractureEvent> mDeferredFractureBuffer;
+ RingBuffer<SyncDamageEventCoreDataParams> mSyncDamageEventCoreDataBuffer;
+};
+
+template <class ChunkOpClass>
+PX_INLINE void DestructibleScene::forSubtree(DestructibleStructure::Chunk& chunk, ChunkOpClass chunkOp, bool skipRoot)
+{
+ uint16_t indexInAsset = chunk.indexInAsset;
+ DestructibleStructure::Chunk* pProcessChunk = &chunk;
+ physx::Array<uint16_t> stack;
+
+ DestructibleActorImpl* destructible = mDestructibles.direct(chunk.destructibleID);
+ const DestructibleAssetParametersNS::Chunk_Type* sourceChunks = destructible->getDestructibleAsset()->mParams->chunks.buf;
+ const uint32_t firstChunkIndex = destructible->getFirstChunkIndex();
+
+ for (;;)
+ {
+ bool recurse = skipRoot ? true : chunkOp.execute(destructible->getStructure(), *pProcessChunk);
+ skipRoot = false;
+ const DestructibleAssetParametersNS::Chunk_Type& source = sourceChunks[indexInAsset];
+ if (recurse && source.numChildren)
+ {
+ for (indexInAsset = uint16_t(source.firstChildIndex + source.numChildren); --indexInAsset > source.firstChildIndex;)
+ {
+ stack.pushBack(indexInAsset);
+ }
+ }
+ else
+ {
+ if (stack.size() == 0)
+ {
+ return;
+ }
+ indexInAsset = stack.back();
+ stack.popBack();
+ }
+ pProcessChunk = destructible->getStructure()->chunks.begin() + (firstChunkIndex + indexInAsset);
+ }
+}
+
+PX_INLINE ChunkData* DestructibleScene::getChunkReportData(DestructibleStructure::Chunk& chunk, uint32_t flags)
+{
+ if (!mModule->m_chunkReport)
+ {
+ return NULL; // don't give out data if we won't be reporting it
+ }
+
+ if (chunk.reportID == InvalidReportID)
+ {
+ // No chunk report data. Create.
+ const uint32_t damageEventIndex = mDamageEventReportData.size();
+ ApexDamageEventReportDataImpl& damageReportData = mDamageEventReportData.insert();
+ damageReportData.setDestructible(mDestructibles.direct(chunk.destructibleID));
+ const uint32_t fractureEventIndex = damageReportData.addFractureEvent(chunk, flags);
+ chunk.reportID = mChunkReportHandles.size();
+ IntPair& handle = mChunkReportHandles.insert();
+ handle.set((int32_t)damageEventIndex, (int32_t)fractureEventIndex);
+ }
+
+ PX_ASSERT(chunk.reportID < mChunkReportHandles.size());
+ if (chunk.reportID < mChunkReportHandles.size())
+ {
+ IntPair& handle = mChunkReportHandles[chunk.reportID];
+ PX_ASSERT((uint32_t)handle.i0 < mDamageEventReportData.size());
+ if ((uint32_t)handle.i0 < mDamageEventReportData.size() && (uint32_t)handle.i1 != 0xFFFFFFFF)
+ {
+ return &mDamageEventReportData[(uint32_t)handle.i0].getFractureEvent((uint32_t)handle.i1);
+ }
+ }
+
+ return NULL;
+}
+
+PX_INLINE PxRigidDynamic* DestructibleScene::chunkIntact(DestructibleStructure::Chunk& chunk)
+{
+ DestructibleStructure::Chunk* child = &chunk;
+ DestructibleActorImpl* destructible = mDestructibles.direct(chunk.destructibleID);
+
+ if (!chunk.isDestroyed())
+ {
+ return destructible->getStructure()->getChunkActor(chunk);
+ }
+
+ if ((chunk.flags & ChunkMissingChild) != 0)
+ {
+ return NULL;
+ }
+
+ DestructibleAssetImpl* asset = destructible->getDestructibleAsset();
+ do
+ {
+ DestructibleAssetParametersNS::Chunk_Type& source = asset->mParams->chunks.buf[child->indexInAsset];
+ PX_ASSERT(source.numChildren > 0);
+ child = &destructible->getStructure()->chunks[destructible->getFirstChunkIndex() + source.firstChildIndex];
+
+ if (!child->isDestroyed())
+ {
+ return destructible->getStructure()->getChunkActor(chunk);
+ }
+ }
+ while ((child->flags & ChunkMissingChild) == 0);
+
+ return NULL;
+}
+
+PX_INLINE void cacheChunkTempState(DestructibleStructure::Chunk& chunk, physx::Array<uint8_t*>& trail, physx::Array<uint8_t>& undo)
+{
+ // ChunkTemp0 = chunk state has been cached
+ // ChunkTemp1 = chunk exists
+ // ChunkTemp2 = chunk is visible
+ // ChunkTemp3 = chunk is dynamic
+
+ undo.pushBack((uint8_t)(chunk.state & (uint8_t)ChunkTempMask));
+
+ if ((chunk.state & ChunkTemp0) == 0)
+ {
+ chunk.state |= ChunkTemp0;
+ if (!chunk.isDestroyed())
+ {
+ chunk.state |= ChunkTemp1;
+ if (chunk.state & ChunkVisible)
+ {
+ chunk.state |= ChunkTemp2;
+ }
+ if (chunk.state & ChunkDynamic)
+ {
+ chunk.state |= ChunkTemp3;
+ }
+ }
+ trail.pushBack(&chunk.state);
+ }
+}
+
+PX_INLINE void DestructibleScene::calculatePotentialCostAndBenefit(float& cost, float& benefit, physx::Array<uint8_t*>& trail, physx::Array<uint8_t>& undo, const FractureEvent& fractureEvent) const
+{
+ cost = 0.0f;
+ benefit = 0.0f;
+
+ DestructibleActorImpl* destructible = mDestructibles.direct(fractureEvent.destructibleID);
+ if (destructible == NULL)
+ {
+ return;
+ }
+
+ DestructibleStructure* structure = destructible->getStructure();
+ if (structure == NULL)
+ {
+ return;
+ }
+
+ DestructibleStructure::Chunk* chunk = structure->chunks.begin() + fractureEvent.chunkIndexInAsset + destructible->getFirstChunkIndex();
+
+ // ChunkTemp0 = chunk state has been cached
+ // ChunkTemp1 = chunk exists
+ // ChunkTemp2 = chunk is visible
+ // ChunkTemp3 = chunk is dynamic
+
+ cacheChunkTempState(*chunk, trail, undo);
+
+ if ((chunk->state & ChunkTemp1) == 0)
+ {
+ return;
+ }
+
+ if ((chunk->state & ChunkTemp3) != 0) // If the chunk is dynamic, we're done... no extra cost or benefit, and it's disconnected from its parent
+ {
+ return;
+ }
+
+ const uint32_t chunkIndexInAsset = fractureEvent.chunkIndexInAsset;
+ const uint32_t chunkShapeCount = destructible->getDestructibleAsset()->getChunkHullCount(chunkIndexInAsset);
+
+ cost += chunkShapeCount;
+ benefit += destructible->getBenefit()*(float)chunkShapeCount/(float)PxMax<uint32_t>(destructible->getVisibleDynamicChunkShapeCount(), 1);
+
+ chunk->state |= ChunkTemp3; // Mark it as dynamic
+
+ if ((chunk->state & ChunkTemp2) != 0)
+ {
+ return; // It was visible already, so we just made it dynamic. It will have no parent and iits siblings will already be accounted for, if they exist.
+ }
+
+ chunk->state |= ChunkTemp2; // Mark it as visible
+
+ for (;;)
+ {
+ // Climb the hierarchy
+ DestructibleAssetParametersNS::Chunk_Type& source = destructible->getDestructibleAsset()->mParams->chunks.buf[chunk->indexInAsset];
+ if (source.parentIndex == DestructibleAssetImpl::InvalidChunkIndex)
+ {
+ break;
+ }
+ chunk = structure->chunks.begin() + (source.parentIndex + destructible->getFirstChunkIndex());
+ cacheChunkTempState(*chunk, trail, undo);
+ if ((chunk->state & ChunkTemp1) == 0)
+ {
+ break; // Parent doesn't exist
+ }
+
+ // Make children visible
+ DestructibleAssetParametersNS::Chunk_Type& parentSource = destructible->getDestructibleAsset()->mParams->chunks.buf[chunk->indexInAsset];
+ const uint32_t firstChildIndex = parentSource.firstChildIndex + destructible->getFirstChunkIndex();
+ const uint32_t endChildIndex = firstChildIndex + parentSource.numChildren;
+ for (uint32_t childIndex = firstChildIndex; childIndex < endChildIndex; ++childIndex)
+ {
+ DestructibleStructure::Chunk& child = structure->chunks[childIndex];
+ cacheChunkTempState(child, trail, undo);
+ if ((child.state & ChunkTemp1) == 0)
+ {
+ continue; // Child doesn't exist, skip
+ }
+ child.state |= ChunkTemp2; // Make it visible
+ if ((chunk->state & ChunkTemp3) != 0 || (child.flags & ChunkBelowSupportDepth) != 0)
+ {
+ // Add cost and benefit for children
+ const uint32_t childndexInAsset = childIndex - destructible->getFirstChunkIndex();
+ const uint32_t childShapeCount = destructible->getDestructibleAsset()->getChunkHullCount(childndexInAsset);
+
+ cost += childShapeCount;
+ benefit += destructible->getBenefit()*(float)childShapeCount/(float)PxMax<uint32_t>(destructible->getVisibleDynamicChunkShapeCount(), 1);
+
+ // Parent is dynamic (so its children will be too), or the child is below the support depth, so make it dynamic
+ child.state |= ChunkTemp3;
+ }
+ }
+
+ chunk->state &= ~(uint8_t)(ChunkTemp1 | ChunkTemp2 | ChunkTemp3); // The parent will cease to exist
+ }
+}
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLE_SCENE_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleStructure.h b/APEX_1.4/module/destructible/include/DestructibleStructure.h
new file mode 100644
index 00000000..493d7e91
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleStructure.h
@@ -0,0 +1,479 @@
+/*
+ * 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 __DESTRUCTIBLESTRUCTURE_H__
+#define __DESTRUCTIBLESTRUCTURE_H__
+
+#include "Apex.h"
+#include "DestructibleAssetProxy.h"
+
+#include "ScopedPhysXLock.h"
+
+#include "PsMutex.h"
+#include "PxShape.h"
+#include "PxRigidActor.h"
+#include <PxRigidDynamic.h>
+#include <PxRigidBodyExt.h>
+#include <PxShapeExt.h>
+
+#ifndef USE_CHUNK_RWLOCK
+#define USE_CHUNK_RWLOCK 0
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class ModuleDestructibleImpl;
+class DestructibleScene;
+typedef class DestructibleStructureStressSolver StressSolver;
+
+#define ENFORCE(condition) extern char unusableName[(condition)?1:-1]
+#define GET_OFFSET(Class, Member) uint64_t(&(static_cast<Class*>(0)->Member))
+struct CachedChunk : public ChunkTransformUnit
+{
+ CachedChunk(uint32_t chunkIndex_, PxMat44 chunkPose_)
+ {
+ chunkIndex = chunkIndex_;
+ chunkPosition = chunkPose_.getPosition();
+ chunkOrientation = PxQuat(PxMat33(chunkPose_.column0.getXYZ(), chunkPose_.column1.getXYZ(), chunkPose_.column2.getXYZ()));
+#if defined WIN32
+ ENFORCE(GET_OFFSET(CachedChunk, chunkIndex) == GET_OFFSET(ChunkTransformUnit, chunkIndex));
+ ENFORCE(GET_OFFSET(CachedChunk, chunkPosition) == GET_OFFSET(ChunkTransformUnit, chunkPosition));
+ ENFORCE(GET_OFFSET(CachedChunk, chunkOrientation) == GET_OFFSET(ChunkTransformUnit, chunkOrientation));
+ ENFORCE(static_cast<uint64_t>(sizeof(*this)) == static_cast<uint64_t>(sizeof(ChunkTransformUnit)));
+#endif // WIN32
+ }
+ ~CachedChunk() {}
+private:
+ CachedChunk();
+};
+typedef CachedChunk ControlledChunk;
+#undef GET_OFFSET
+#undef ENFORCE
+
+struct SyncDamageEventCoreDataParams : public DamageEventCoreData
+{
+ SyncDamageEventCoreDataParams()
+ :
+ destructibleID(0xFFFFFFFF)
+ {
+ DamageEventCoreData::chunkIndexInAsset = 0;
+ DamageEventCoreData::damage = 0.0f;
+ DamageEventCoreData::radius = 0.0f;
+ DamageEventCoreData::position = PxVec3(0.0f);
+ }
+
+ uint32_t destructibleID; // The ID of the destructible actor that is being damaged.
+};
+
+struct FractureEvent
+{
+ FractureEvent() : chunkIndexInAsset(0xFFFFFFFF), destructibleID(0xFFFFFFFF), flags(0), impactDamageActor(NULL), appliedDamageUserData(NULL), deletionWeight(0.0f), damageFraction(1.0f) {}
+
+ enum Flag
+ {
+ DamageFromImpact = (1U << 0),
+ CrumbleChunk = (1U << 1),
+ DeleteChunk = (1U << 2),
+
+ SyncDirect = (1U << 24), // fracture event is directly sync-ed
+ SyncDerived = (1U << 25), // fracture event is a derivative of a sync-ed damage event
+ Manual = (1U << 26), // fracture event is manually invoked by the user
+ Snap = (1U << 27), // fracture event is generated from the destructible stress solver
+ Forced = (1U << 28),
+ Silent = (1U << 29),
+ Virtual = (1U << 30),
+
+ Invalid = (1U << 31)
+ };
+
+ PxVec3 position; // The position of a single fracture event.
+ uint32_t chunkIndexInAsset; // The chunk index which is being fractured.
+ PxVec3 impulse; // The impulse vector to apply for this fracture event.
+ uint32_t destructibleID; // The ID of the destructible actor that is being damaged.
+ uint32_t flags; // Bit flags describing behavior of this fracture event.
+ PxVec3 hitDirection; // The direction vector this damage being applied to this fracture event.
+ physx::PxActor const* impactDamageActor; // Other PhysX actor that caused damage to ApexDamageEventReportData.
+
+ void* appliedDamageUserData; // User data from applyDamage or applyRadiusDamage.
+ float deletionWeight; // A weighting factor for probabilistic deletion
+ float damageFraction; // Calculated from damage spread functions, it's good to store this for later use (e.g. impulse scaling)
+};
+
+enum ChunkState
+{
+ ChunkVisible = 0x01,
+ ChunkDynamic = 0x02,
+ //ChunkControlled = 0x04, // chunk behavior is not locally-determined //unused
+
+ ChunkTemp0 = 0x10, // chunk state has been cached
+ ChunkTemp1 = 0x20, // chunk exists
+ ChunkTemp2 = 0x40, // chunk is visible
+ ChunkTemp3 = 0x80, // chunk is dynamic
+ ChunkTempMask = 0xF0,
+};
+
+enum ChunkFlag
+{
+ ChunkCrumbled = 0x01,
+ ChunkBelowSupportDepth = 0x02,
+ ChunkExternallySupported = 0x04,
+ ChunkWorldSupported = 0x08,
+ ChunkMissingChild = 0x20,
+ ChunkRuntime = 0x80,
+ //ChunkGraphical = 0x80, // chunk has no attached PxShape //unused
+};
+
+/* A struct for adding forces to actors after they are added to the scene */
+struct ActorForceAtPosition
+{
+ ActorForceAtPosition() : force(0.0f), pos(0.0f), mode(physx::PxForceMode::eFORCE), wakeup(true), usePosition(true) {}
+
+ ActorForceAtPosition(const PxVec3& _force, const PxVec3& _pos, physx::PxForceMode::Enum _mode, bool _wakeup, bool _usePosition)
+ : force(_force)
+ , pos(_pos)
+ , mode(_mode)
+ , wakeup(_wakeup)
+ , usePosition(_usePosition)
+ {}
+
+ PxVec3 force;
+ PxVec3 pos;
+ physx::PxForceMode::Enum mode;
+ bool wakeup;
+ bool usePosition;
+};
+
+
+class DestructibleStructure : public UserAllocated
+{
+public:
+
+ enum
+ {
+ InvalidID = 0xFFFFFFFF,
+ InvalidChunkIndex = 0xFFFFFFFF
+ };
+
+ struct Chunk
+ {
+ uint32_t destructibleID; // The GUID of the destructible actor this chunk is associated with.
+ uint32_t reportID; // A GUID to report state about this chunk
+ uint16_t indexInAsset; // The index into the master asset for this destructible
+ uint8_t state; // bit flags controlling the current 'state' of this chunk.
+ uint8_t flags; // Overall Chunk flags
+ float damage; // How damaged this chunk is.
+ PxVec3 localSphereCenter; // A local bounding sphere for this chunk (center).
+ float localSphereRadius; // A local bounding sphere for this chunk (radius).
+ const ControlledChunk * controlledChunk; // Chunk data given by user
+#if USE_CHUNK_RWLOCK
+ shdfnd::ReadWriteLock* lock;
+#endif
+
+ PxVec3 localOffset; // If this chunk is instanced, this may be non-zero. It needs to be stored somewhere in case we use
+ // the transform of a parent chunk which has a different offset. Actually, this can all be looked up
+ // through a chain of indirection, but I'm storing it here for efficiency.
+ int32_t visibleAncestorIndex; // Index (in structure) of this chunks' visible ancestor, if any. If none exists, it's InvalidChunkIndex.
+
+ uint32_t islandID; // The GUID of the actor associated with the chunk. Used for island reconstruction.
+
+ private:
+ physx::Array<PxShape*> shapes; // The rigid body shapes for this chunk.
+
+ public:
+
+ Chunk() {}
+ Chunk(const Chunk& other)
+ {
+ *this = other;
+ }
+
+ Chunk& operator = (const Chunk& other)
+ {
+ destructibleID = other.destructibleID;
+ reportID = other.reportID;
+ indexInAsset = other.indexInAsset;
+ state = other.state;
+ flags = other.flags;
+ damage = other.damage;
+ localSphereCenter = other.localSphereCenter;
+ localSphereRadius = other.localSphereRadius;
+ controlledChunk = other.controlledChunk;
+#if USE_CHUNK_RWLOCK
+#error USE_CONTROL_RWLOCK non-zero, but lock is not supported in assignment operator and copy constructor
+#endif
+ localOffset = other.localOffset;
+ visibleAncestorIndex = other.visibleAncestorIndex;
+ islandID = other.islandID;
+ shapes = physx::Array<PxShape*>(other.shapes);
+ return *this;
+ }
+
+ uint32_t getShapeCount() const
+ {
+ return shapes.size();
+ }
+
+ const PxShape* getShape(uint32_t shapeIndex) const
+ {
+ return shapeIndex < shapes.size() ? shapes[shapeIndex] : NULL;
+ }
+
+ PxShape* getShape(uint32_t shapeIndex)
+ {
+ return shapeIndex < shapes.size() ? shapes[shapeIndex] : NULL;
+ }
+
+ bool isFirstShape(const PxShape* shape) const
+ {
+ return shapes.size() ? shapes[0] == shape : false;
+ }
+
+ void setShapes(PxShape* const* newShapes, uint32_t shapeCount)
+ {
+ shapes.resize(shapeCount);
+ for (uint32_t i = 0; i < shapeCount; ++i)
+ {
+ shapes[i] = newShapes[i];
+ }
+ visibleAncestorIndex = InvalidChunkIndex;
+ }
+
+ void clearShapes()
+ {
+ shapes.reset();
+ visibleAncestorIndex = InvalidChunkIndex;
+ }
+
+ bool isDestroyed() const
+ {
+ return shapes.empty() && visibleAncestorIndex == (int32_t)InvalidChunkIndex;
+ }
+
+ friend class DestructibleStructure;
+ };
+
+#if USE_CHUNK_RWLOCK
+ class ChunkScopedReadLock : public physx::ScopedReadLock
+ {
+ public:
+ ChunkScopedReadLock(Chunk& chunk) : physx::ScopedReadLock(*chunk.lock) {}
+ };
+
+ class ChunkScopedWriteLock : public physx::ScopedWriteLock
+ {
+ public:
+ ChunkScopedWriteLock(Chunk& chunk) : physx::ScopedWriteLock(*chunk.lock) {}
+ };
+#endif
+
+ DestructibleScene* dscene; // The scene that this destructible structure belongs to
+ Array<DestructibleActorImpl*> destructibles; // The array of destructible actors associated with this destructible structure
+ Array<Chunk> chunks; // The array of chunks associated with this structure.
+ Array<uint32_t> supportDepthChunks; //
+ Array<uint32_t> overlaps;
+ Array<uint32_t> firstOverlapIndices; // Size = chunks.size()+1, firstOverlapsIndices[chunks.size()] = overlaps.size()
+ uint32_t ID; // The unique GUID associated with this destructible structure
+ uint32_t supportDepthChunksNotExternallySupportedCount;
+ bool supportInvalid;
+ PxRigidDynamic* actorForStaticChunks;
+ StressSolver * stressSolver;
+
+ typedef HashMap<PxRigidDynamic*, uint32_t> ActorToIslandMap;
+ typedef HashMap<uint32_t, PxRigidDynamic*> IslandToActorMap;
+ // As internal, cache-type containers, these structures do not affect external state
+ mutable ActorToIslandMap actorToIsland;
+ mutable IslandToActorMap islandToActor;
+
+ DestructibleStructure(DestructibleScene* inScene, uint32_t inID);
+ ~DestructibleStructure();
+
+ bool addActors(const physx::Array<class DestructibleActorImpl*>& destructiblesToAdd);
+ bool removeActor(DestructibleActorImpl* destructibleToRemove);
+ void setSupportInvalid(bool supportIsInvalid);
+
+ void updateIslands();
+ void tickStressSolver(float deltaTime);
+ void visualizeSupport(RenderDebugInterface* debugRender);
+
+ uint32_t damageChunk(Chunk& chunk, const PxVec3& position, const PxVec3& direction, bool fromImpact, float damage, float damageRadius,
+ physx::Array<FractureEvent> outputs[], uint32_t& possibleDeleteChunks, float& totalDeleteChunkRelativeDamage,
+ uint32_t& maxDepth, uint32_t depth, uint16_t stopDepth, float padding);
+ void fractureChunk(const FractureEvent& fractureEvent);
+#if APEX_RUNTIME_FRACTURE
+ void runtimeFractureChunk(const FractureEvent& fractureEvent, Chunk& chunk);
+#endif
+ void crumbleChunk(const FractureEvent& fractureEvent, Chunk& chunk, const PxVec3* impulse = NULL); // Add an impulse - used when actor is static
+ void addDust(Chunk& chunk);
+ void removeChunk(Chunk& chunk);
+ void separateUnsupportedIslands();
+ void createDynamicIsland(const physx::Array<uint32_t>& indices);
+ void calculateExternalSupportChunks();
+ void buildSupportGraph();
+ void invalidateBounds(const PxBounds3* bounds, uint32_t boundsCount);
+ void postBuildSupportGraph();
+ void evaluateForHitChunkList(const physx::Array<uint32_t> & chunkIndices) const;
+
+ PxMat44 getActorForStaticChunksPose()
+ {
+ if (NULL != actorForStaticChunks)
+ {
+ SCOPED_PHYSX_LOCK_READ(actorForStaticChunks->getScene());
+ return PxMat44(actorForStaticChunks->getGlobalPose());
+ }
+ else
+ {
+ return PxMat44(PxIdentity);
+ }
+ }
+
+ physx::Array<PxShape*>& getChunkShapes(Chunk& chunk)
+ {
+ return (chunk.visibleAncestorIndex == (int32_t)InvalidChunkIndex) ? chunk.shapes : chunks[(uint32_t)chunk.visibleAncestorIndex].shapes;
+ }
+
+ const physx::Array<PxShape*>& getChunkShapes(const Chunk& chunk) const
+ {
+ return (chunk.visibleAncestorIndex == (int32_t)InvalidChunkIndex) ? chunk.shapes : chunks[(uint32_t)chunk.visibleAncestorIndex].shapes;
+ }
+
+ PxRigidDynamic* getChunkActor(Chunk& chunk);
+
+ const PxRigidDynamic* getChunkActor(const Chunk& chunk) const;
+
+ bool chunkIsSolitary(Chunk& chunk)
+ {
+ PxRigidDynamic* actor = getChunkActor(chunk);
+ SCOPED_PHYSX_LOCK_READ(actor->getScene());
+ return (actor == NULL) ? false : (getChunkShapes(chunk).size() == actor->getNbShapes());
+ }
+
+ Chunk* getRootChunk(Chunk& chunk)
+ {
+ if (chunk.isDestroyed())
+ {
+ return NULL;
+ }
+ return chunk.visibleAncestorIndex == (int32_t)InvalidChunkIndex ? &chunk : &chunks[(uint32_t)chunk.visibleAncestorIndex];
+ }
+
+ PxTransform getChunkLocalPose(const Chunk& chunk) const;
+
+ void setChunkGlobalPose(Chunk& chunk, PxTransform pose)
+ {
+ physx::Array<PxShape*>& shapes = getChunkShapes(chunk);
+ PX_ASSERT(!shapes.empty());
+
+ for (uint32_t i = 0; i < shapes.size(); ++i)
+ {
+ const PxTransform shapeLocalPose = shapes[i]->getLocalPose();
+ const PxTransform inverseShapeLocalPose = shapeLocalPose.getInverse();
+ PxTransform newGlobalPose = pose * inverseShapeLocalPose;
+
+ shapes[i]->getActor()->setGlobalPose(newGlobalPose);
+ }
+ }
+
+ PxTransform getChunkActorPose(const Chunk& chunk) const;
+
+ PxTransform getChunkGlobalPose(const Chunk& chunk) const
+ {
+ return getChunkActorPose(chunk) * getChunkLocalPose(chunk);
+ }
+
+ PxTransform getChunkLocalTransform(const Chunk& chunk) const
+ {
+ const physx::Array<PxShape*>* shapes;
+ PxVec3 offset;
+ if (chunk.visibleAncestorIndex == (int32_t)InvalidChunkIndex)
+ {
+ shapes = &chunk.shapes;
+ offset = PxVec3(0.0f);
+ }
+ else
+ {
+ shapes = &chunks[(uint32_t)chunk.visibleAncestorIndex].shapes;
+ offset = chunk.localOffset - chunks[(uint32_t)chunk.visibleAncestorIndex].localOffset;
+ }
+
+ PX_ASSERT(!shapes->empty());
+ PxTransform transform;
+ if (!shapes->empty() && NULL != (*shapes)[0])
+ {
+ transform = (*shapes)[0]->getLocalPose();
+ }
+ else
+ {
+ transform = PxTransform(PxVec3(0, 0, 0), PxQuat(0, 0, 0, 1));
+ }
+ transform.p += offset;
+ return transform;
+ }
+
+ PxTransform getChunkActorTransform(const Chunk& chunk) const
+ {
+ const physx::Array<PxShape*>& shapes = getChunkShapes(chunk);
+ PX_ASSERT(!shapes.empty());
+ if (!shapes.empty() && NULL != shapes[0])
+ {
+ // All shapes should have the same actor
+ SCOPED_PHYSX_LOCK_READ(shapes[0]->getActor()->getScene());
+ return shapes[0]->getActor()->getGlobalPose();
+ }
+ else
+ {
+ return PxTransform(PxVec3(0, 0, 0), PxQuat(0, 0, 0, 1));
+ }
+ }
+
+ PxTransform getChunkGlobalTransform(const Chunk& chunk) const
+ {
+ return getChunkActorTransform(chunk).transform(getChunkLocalTransform(chunk));
+ }
+
+ void addChunkImpluseForceAtPos(Chunk& chunk, const PxVec3& impulse, const PxVec3& position, bool wakeup = true);
+
+ PxVec3 getChunkWorldCentroid(const Chunk& chunk) const
+ {
+ return getChunkGlobalPose(chunk).transform(chunk.localSphereCenter);
+ }
+
+ // This version saves a little time on consoles (saving a recalcualtion of the chunk global pose
+ PX_INLINE PxVec3 getChunkWorldCentroid(const Chunk& chunk, const PxTransform& chuckGlobalPose)
+ {
+ return chuckGlobalPose.transform(chunk.localSphereCenter);
+ }
+
+ uint32_t newPxActorIslandReference(Chunk& chunk, PxRigidDynamic& nxActor);
+ void removePxActorIslandReferences(PxRigidDynamic& nxActor) const;
+
+ uint32_t getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const
+ {
+ PX_ASSERT( supportDepthChunksNotExternallySupportedCount <= supportDepthChunks.size() );
+
+ uint32_t chunkNum = 0;
+ for ( ; chunkNum < supportDepthChunksNotExternallySupportedCount && chunkNum < MaxOutIndices; ++chunkNum )
+ {
+ uint32_t chunkIndex = supportDepthChunks[chunkNum];
+ Chunk const& chunk = chunks[chunkIndex];
+ OutChunkIndices[chunkNum] = chunk.indexInAsset;
+ }
+
+ return chunkNum;
+ }
+};
+
+}
+} // end namespace nvidia
+
+#endif // __DESTRUCTIBLESTRUCTURE_H__
diff --git a/APEX_1.4/module/destructible/include/DestructibleStructureStressSolver.h b/APEX_1.4/module/destructible/include/DestructibleStructureStressSolver.h
new file mode 100644
index 00000000..cf1b5ab8
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/DestructibleStructureStressSolver.h
@@ -0,0 +1,413 @@
+/*
+ * 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_STRUCTURE_STRESS_SOLVER_H
+#define DESTRUCTIBLE_STRUCTURE_STRESS_SOLVER_H
+
+#include "PsUserAllocated.h"
+#include "ApexUsingNamespace.h"
+#include "PsArray.h"
+
+
+#include "DestructibleScene.h"
+#include "Scene.h"
+#include "ApexDefs.h"
+#include <PxPhysics.h>
+#include "cooking/PxCooking.h"
+
+#include <PxScene.h>
+#include "extensions/PxExtensionsAPI.h"
+#include "extensions/PxDefaultCpuDispatcher.h"
+#include "extensions/PxDefaultSimulationFilterShader.h"
+#include <PxFiltering.h>
+#include <PxMaterial.h>
+#include <PxFixedJoint.h>
+#include <PxConstraint.h>
+
+namespace nvidia
+{
+namespace destructible
+{
+
+class DestructibleStructure;
+class DestructibleActorImpl;
+struct ActorChunkPair;
+struct FractureEvent;
+
+// a helper class for managing states using an array
+template<class T, typename F, unsigned int N>
+class ArraySet
+{
+public:
+ explicit ArraySet(T v)
+ {
+ PX_COMPILE_TIME_ASSERT(N > 0);
+#if defined(PX_PS4)
+ typedef char PxCompileTimeAssert_Dummy2[(N * sizeof(T) == sizeof(*this)) ? 1 : -1] __attribute__((unused));
+#else
+ typedef char PxCompileTimeAssert_Dummy2[(N * sizeof(T) == sizeof(*this)) ? 1 : -1];
+#endif
+ ::memset(static_cast<void*>(&t[0]), v, N * sizeof(T));
+ }
+ ~ArraySet()
+ {
+ }
+ void set(unsigned int i, F f)
+ {
+ PX_ASSERT(i < N);
+ PX_ASSERT(!isSet(i, f));
+ t[i] |= f;
+ }
+ void unset(unsigned int i, F f)
+ {
+ PX_ASSERT(i < N);
+ PX_ASSERT(isSet(i, f));
+ t[i] &= ~f;
+ }
+ bool isSet(unsigned int i, F f) const
+ {
+ PX_ASSERT(i < N);
+ return (0 != (f & t[i]));
+ }
+ void reset(T v)
+ {
+ ::memset(static_cast<void*>(&t[0]), v, N * sizeof(T));
+ }
+ const T (&get() const) [N]
+ {
+ return t;
+ }
+ const T * getPtr() const
+ {
+ return &t[0];
+ }
+private:
+ T t[N];
+}; // class ArraySet
+
+// Int-To-Type idiom
+template<unsigned int I>
+struct Int2Type
+{
+ enum
+ {
+ Value = I,
+ };
+}; // struct Int2Type
+
+// a type container used to identify the different ways of evaluating stresses on the structure
+struct StressEvaluationType
+{
+ enum Enum
+ {
+ EvaluateByCount = 0,
+ EvaluateByMoment,
+ };
+}; // struct StressEvaluationType
+
+// a helper data structure used for recording bit values
+struct StructureScratchBuffer
+{
+public:
+ StructureScratchBuffer(uint8_t * const bufferStart, uint32_t bufferCount);
+ ~StructureScratchBuffer();
+
+ bool isOccupied(uint32_t index) const;
+ void setOccupied(uint32_t index);
+
+private:
+ StructureScratchBuffer();
+ StructureScratchBuffer& operator=(const StructureScratchBuffer&);
+
+ enum ByteState
+ {
+ ByteEmpty = 0x00,
+ ByteExist = 0xFF,
+ };
+
+ uint8_t * const bufferStart;
+ const uint32_t bufferCount;
+}; // struct StructureScratchBuffer
+
+// a data structure used to collect and hold potential new island data
+struct PeninsulaData
+{
+public:
+ PeninsulaData();
+ PeninsulaData(uint8_t peninsulaState, uint32_t chunkCount);
+ PeninsulaData(uint8_t peninsulaState, uint32_t chunkCount, float aggregateMass, PxVec3 geometricCenter);
+ ~PeninsulaData();
+ enum PeninsulaFlag
+ {
+ PeninsulaEncounteredExternalSupport = (1 << 0),
+ PeninsulaEncounteredAnotherWeakLink = (1 << 1),
+ PeninsulaInvalidMaxFlag = (1 << 2),
+ };
+
+ bool isValid() const;
+ void resetData();
+ void setFlag(PeninsulaData::PeninsulaFlag peninsulaFlag);
+ void setLinkedChunkData(const ActorChunkPair & actorChunkPair, Int2Type<StressEvaluationType::EvaluateByCount>);
+ void setLinkedChunkData(const ActorChunkPair & actorChunkPair, Int2Type<StressEvaluationType::EvaluateByMoment>);
+ void setRootLinkedChunkIndex(uint32_t linkedChunkIndex);
+ void assimilate(const PeninsulaData & that, Int2Type<StressEvaluationType::EvaluateByCount>);
+ void assimilate(const PeninsulaData & that, Int2Type<StressEvaluationType::EvaluateByMoment>);
+ bool hasFlag(PeninsulaData::PeninsulaFlag peninsulaFlag) const;
+ uint32_t getDataChunkCount() const;
+ float getDataAggregateMass() const;
+ const PxVec3 & getDataGeometricCenter() const;
+ uint32_t getRootLinkedChunkIndex() const;
+private:
+ const PeninsulaData operator+ (const PeninsulaData &);
+ PeninsulaData & operator+= (const PeninsulaData &);
+
+ uint32_t rootLinkedChunkIndex;
+ uint8_t peninsulaState;
+ uint32_t chunkCount;
+ float aggregateMass;
+ PxVec3 geometricCenter;
+}; // struct PeninsulaData
+
+// a data structure used to hold minimally required fracture data
+struct FractureEventProxy : public UserAllocated
+{
+public:
+ uint32_t rootLinkedChunkIndex;
+ uint32_t chunkIndexInAsset;
+ uint32_t destructibleId;
+ uint32_t fractureEventProxyFlags;
+ PxVec3 rootLinkedChunkPosition;
+ PxVec3 impulse;
+}; // struct FractureEventProxy
+
+// a data structure with a 1-N convertible relationship with fracture event(s)
+struct SnapEvent : public UserAllocated
+{
+public:
+ static SnapEvent* instantiate(FractureEventProxy * fractureEventProxyBufferStart, uint32_t fractureEventProxyBufferCount, float tickSecondsToSnap);
+
+ void onDestroy();
+ bool isRipeAfterUpdatingTime(float deltaTime);
+ bool isExpired() const;
+ uint32_t getFractureEventProxyCount() const;
+ const FractureEventProxy& getFractureEventProxy(uint32_t index) const;
+
+private:
+ SnapEvent(FractureEventProxy* fractureEventProxyBufferStart, uint32_t fractureEventProxyBufferCount, float tickSecondsToSnap);
+ SnapEvent& operator=(const SnapEvent&);
+
+ ~SnapEvent();
+ SnapEvent();
+
+ FractureEventProxy* fractureEventProxyBufferStart;
+ const uint32_t fractureEventProxyBufferCount;
+ float tickSecondsRemainingToSnap;
+}; // struct SnapEvent
+
+// a solver with a 1-1 or 0-1 relationship with a destructible structure
+class DestructibleStructureStressSolver : public UserAllocated
+{
+public:
+ explicit DestructibleStructureStressSolver(const DestructibleStructure & bindedStructureAlias, float strength);
+
+ ~DestructibleStructureStressSolver();
+
+ void onTick(float deltaTime);
+ void onUpdate(uint32_t linkedChunkIndex);
+ void onResolve();
+private:
+ DestructibleStructureStressSolver();
+ DestructibleStructureStressSolver(const DestructibleStructureStressSolver &);
+ DestructibleStructureStressSolver & operator= (const DestructibleStructureStressSolver &);
+ enum StructureLinkFlag
+ {
+ LinkedChunkExist = (1 << 0),
+ LinkedChunkBroken = (1 << 1),
+ LinkedChunkStrained = (1 << 2),
+ LinkedChunkInvalidMaxFlag = (1 << 3),
+ };
+ enum LinkTestParameters
+ {
+ LowerLimitActivationCount = 2,
+ UpperLimitActivationCount = 3,
+ };
+ enum LinkTraverseParameters
+ {
+ PathTraversalCount = 2,
+ };
+ static const StressEvaluationType::Enum StressEvaluationEnum = StressEvaluationType::EvaluateByMoment;
+
+ void processLinkedChunkIndicesForEvaluation(physx::Array<uint32_t> & linkedChunkIndicesForEvaluation);
+ void evaluateForPotentialIslands(const physx::Array<uint32_t> & linkedChunkIndicesForEvaluation);
+ bool passLinkCountTest(uint32_t linkedChunkIndex, physx::Array<uint32_t> & unbrokenAdjacentLinkedChunkIndices) const;
+ bool passLinkAdjacencyTest(const physx::Array<uint32_t> & unbrokenAdjacentLinkedChunkIndices, uint32_t (&linkedChunkIndicesForTraversal)[2]) const;
+ void evaluateForPotentialPeninsulas(uint32_t rootLinkedChunkIndex, const uint32_t (&linkedChunkIndicesForTraversal)[2]);
+ PeninsulaData traverseLink(uint32_t linkedChunkIndex, StructureScratchBuffer & traverseRecord) const;
+ void evaluatePeninsulas(const PeninsulaData (&peninsulasForEvaluation)[2]);
+ SnapEvent * interpret(const PeninsulaData & peninsulaData, Int2Type<StressEvaluationType::EvaluateByCount>) const;
+ SnapEvent * interpret(const PeninsulaData & peninsulaData, Int2Type<StressEvaluationType::EvaluateByMoment>) const;
+ const FractureEvent & interpret(const FractureEventProxy & fractureEventProxy) const;
+
+ bool isLinkedChunkBroken(uint32_t linkedChunkIndex) const;
+ void setLinkedChunkBroken(uint32_t linkedChunkIndex);
+ bool isLinkedChunkStrained(uint32_t linkedChunkIndex) const;
+ void setLinkedChunkStrained(uint32_t linkedChunkIndex);
+ void getUnbrokenAdjacentLinkedChunkIndices(uint32_t linkedChunkIndex, physx::Array<uint32_t> & unbrokenAdjacentLinkedChunkIndices) const;
+ bool areUnbrokenLinkedChunksAdjacent(uint32_t linkedChunkIndex, uint32_t linkedChunkIndexSubject) const;
+ ActorChunkPair getActorChunkPair(uint32_t chunkIndexInStructure) const;
+ StructureScratchBuffer acquireScratchBuffer() const;
+ void relinquishScratchBuffer() const;
+ DestructibleStructure & getBindedStructureMutable();
+ bool assertLinkedChunkIndexOk(uint32_t linkedChunkIndex) const;
+ bool assertLinkedChunkIndicesForEvaluationOk(const physx::Array<uint32_t> & linkedChunkIndicesForEvaluation) const;
+
+ const DestructibleStructure & bindedStructureAlias;
+ uint32_t structureLinkCount;
+ uint8_t * structureLinkCondition;
+ uint8_t * scratchBuffer;
+ mutable bool scratchBufferLocked;
+ float userTimeDelay;
+ float userMassThreshold;
+ physx::Array<uint32_t> recentlyBrokenLinkedChunkIndices;
+ physx::Array<uint32_t> strainedLinkedChunkIndices;
+ physx::Array<SnapEvent*> snapEventContainer;
+
+ //Shadow scene to simulate a set of linked rigidbodies
+ public :
+ struct LinkedJoint
+ {
+ uint32_t actor1Index;
+ uint32_t actor2Index;
+ physx::PxFixedJoint * joint;
+ bool isDestroyed;
+ };
+
+ struct ShadowActor
+ {
+ physx::PxRigidDynamic* actor;
+ float currentForce;
+ float maxInitialForce;
+ bool isDestroyed;
+ };
+private:
+ //The basic assumption is that the initialize structure is valid, so we should know the maximum force for each link through initializing, and use it to calculate the threshold.
+ //So initializingMaxForce is to judge if it is initializing or something breaks the initializing.
+ bool initializingMaxForce;
+
+ // The isNoChunkWarmingUpdate is the variable that fewer chunks updating during the warming, in this case, just quit warming.
+ bool isNoChunkWarmingUpdate;
+
+ // The isSimulating symbol indicates if the shadowScene is simulating.
+ bool isSimulating;
+
+ uint32_t continuousNoUpdationCount;
+ physx::Array<ShadowActor> shadowActors;
+
+ //Hash the global chunk index to the support chunk's index
+ physx::Array<uint32_t> globalHashedtoSupportChunks;
+
+ //initialWarmingKillList caches the chunks breaking during the warming stage, after warming is done, all chunks in this list will be removed from shadow scene.
+ physx::Array<uint32_t> initialWarmingKillList;
+
+ //islandKillList caches the chunks removed by the reason of new island generation, all supported chunks will be removed from the shadow scene at once.
+ physx::Array<uint32_t> islandKillList;
+
+ //forces[i] are the current force for supported chunk i in the scene.
+ physx::Array<float> forces;
+
+ //linked joints are constructed as a network for chunk breaking prediction.
+ physx::Array<LinkedJoint> linkedJoint;
+
+ //The SDK is usde to create the shadow scene
+ physx::PxPhysics * newSceneSDK;
+
+ //The shadow scene is used to construct linked joints which are used for chunk breaking prediction
+ physx::PxScene* shadowScene;
+
+ //Size of the supported chunk in the real scene.
+ uint32_t supportChunkSize;
+
+ //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;
+
+ //currentWarmingFrame increases by 1 in the warming stage.
+ uint32_t currentWarmingFrame;
+
+ //initialWarmFrames is used with currentWarmingFrame. If currentWarmingFrame is larger than initialWarmFrames, the warming will stop.
+ uint32_t initialWarmFrames;
+
+ //If no fracturing during one activCycle, just turn the mode to sleep.
+ uint32_t activeCycle;
+
+ //It is used with the activeCycle,
+ uint32_t currentActiveSimulationFrame;
+
+ //If any chunks break isActiveWakedUp is set to true indicates that the stress solver will wake up.
+ bool isActiveWakedUp;
+
+ bool isSleep;
+public :
+ // The isPhysxBasedSim is the variable that uses by the customer if they want to choose the physics based simulation mode.
+ bool isPhysxBasedSim;
+
+ // The isCustomEnablesSimulating symbol is used by the user if the they would like to stop the shadowScene simulating after creating the shadow scene.
+ bool isCustomEnablesSimulating;
+
+ //Functions:
+ uint32_t predictBreakChunk(float deltaTime, float supportStrength_);
+ //create the shadow scene
+ void createShadowScene(uint32_t initialWarmFrames_,uint32_t actCycle, float supStrength);
+ //calculate current maximum force
+ void calculateMaxForce(uint32_t& index, float supportStrength_);
+
+ //If new island genereates, remove the chunks in the island
+ void removeChunkFromIsland(uint32_t index);
+ //Break specific chunk
+ void breakChunks(uint32_t index);
+ //Entry to use physx based stress solver
+ void physcsBasedStressSolverTick();
+ void removeChunkFromShadowScene(bool localIndex, uint32_t index);
+ void resetSupportStrength(float supportStrength_);
+ void resetActiveCycle(uint32_t actCycle);
+ void resetInitialWarmFrames(uint32_t iniWarmFrames);
+ void enablePhyStressSolver(float strength);
+ // The stress solver will stop simulating after calling disablePhyStressSolver;
+ void disablePhyStressSolver();
+ void removePhysStressSolver();
+}; // class DestructibleStructureStressSolver
+
+} // namespace destructible
+} // namespace nvidia
+
+#endif // DESTRUCTIBLE_STRUCTURE_STRESS_SOLVER_H
+
+#if 0
+/*
+issues and improvements:
+1) performance - traverseLink() may generate a stack that is too deep - explore ways to return out earlier.
+ 1.1) tried to return out earlier by returning when we hit a strained link, but this will not work for some composite cases
+ 1.2) basic assumption that a strained link will go on and find an externally supported chunk may be true initially,
+ but this condition needs to be verified again subsequently.
+ 1.3) tried to evaluate past strained links for evaluation runs that contain recently broken links that used to be strained,
+ this seemed promising initially, but under an uncommon, yet possible scenario, an unsupported peninsula could be instantly
+ generated by breaking links, without the intermediate stage of it being strained. Thus, this method was abandoned.
+2) performance - do less traversing by assimilating previously-traversed peninsula data
+ 2.1) while this will not lessen the stack generated, performance could be improved if somehow we can cache peninsula information
+ for an evaluation run. We can reliably reuse this peninsula information instead traversing past it again. Using the flag
+ PeninsulaEncounteredAnotherWeakLink could be useful for this purpose. Doing this may require significant refactoring.
+3) realism - widen criteria for qualifying weak links
+ 3.1) we can improve passLinkCountTest() and passLinkAdjacencyTest() to qualify more links for peninsula assessment. For example,
+ we can try extending it to assess 4 links as well, and also possibly to assess 3 traversal paths.
+4) realism - make better use of physical data to create better break-offs
+ 4.1) we can try and make a peninsula break off in a better direction, such as about the pivot (the weak link), instead of it
+ dropping down vertically.
+*/
+#endif // notes
diff --git a/APEX_1.4/module/destructible/include/ModuleDestructibleImpl.h b/APEX_1.4/module/destructible/include/ModuleDestructibleImpl.h
new file mode 100644
index 00000000..24131733
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/ModuleDestructibleImpl.h
@@ -0,0 +1,556 @@
+/*
+ * 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_IMPL_H__
+#define __MODULE_DESTRUCTIBLE_IMPL_H__
+
+#include "Apex.h"
+#include "ApexSDKIntl.h"
+#include "ModuleIntl.h"
+#include "ModuleBase.h"
+
+#include "FractureTools.h"
+
+#include "ModuleDestructible.h"
+
+#include "DestructibleActorJoint.h"
+#include "DestructibleAssetImpl.h"
+#include "PsMutex.h"
+#include "ApexAuthorableObject.h"
+
+#include "ApexSDKCachedDataImpl.h"
+#include "ApexRWLockable.h"
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+#include "ApexRand.h"
+
+#include "ModuleDestructibleRegistration.h"
+#ifndef USE_DESTRUCTIBLE_RWLOCK
+#define USE_DESTRUCTIBLE_RWLOCK 0
+#endif
+
+#define DECLARE_DISABLE_COPY_AND_ASSIGN(Class) private: Class(const Class &); Class & operator = (const Class &);
+
+namespace nvidia
+{
+namespace destructible
+{
+
+/*** SyncParams ***/
+typedef UserDestructibleSyncHandler<DamageEventHeader> UserDamageEventHandler;
+typedef UserDestructibleSyncHandler<FractureEventHeader> UserFractureEventHandler;
+typedef UserDestructibleSyncHandler<ChunkTransformHeader> UserChunkMotionHandler;
+
+class DestructibleActorImpl;
+class DestructibleScene;
+
+class DestructibleModuleCachedData : public ModuleCachedDataIntl, public UserAllocated
+{
+public:
+ DestructibleModuleCachedData(AuthObjTypeID moduleID);
+ virtual ~DestructibleModuleCachedData();
+
+ virtual AuthObjTypeID getModuleID() const
+ {
+ return mModuleID;
+ }
+
+ virtual NvParameterized::Interface* getCachedDataForAssetAtScale(Asset& asset, const PxVec3& scale);
+ virtual PxFileBuf& serialize(PxFileBuf& stream) const;
+ virtual PxFileBuf& deserialize(PxFileBuf& stream);
+ virtual void clear(bool force = true);
+
+ void clearAssetCollisionSet(const DestructibleAssetImpl& asset);
+ physx::Array<PxConvexMesh*>* getConvexMeshesForActor(const DestructibleActorImpl& destructible); // increments ref counts
+ void releaseReferencesToConvexMeshesForActor(const DestructibleActorImpl& destructible); // decrements ref counts
+
+ // The DestructibleActor::cacheModuleData() method needs to avoid incrementing the ref count
+ physx::Array<PxConvexMesh*>* getConvexMeshesForScale(const DestructibleAssetImpl& asset, const PxVec3& scale, bool incRef = true);
+
+ DestructibleAssetCollision* getAssetCollisionSet(const DestructibleAssetImpl& asset);
+
+ virtual PxFileBuf& serializeSingleAsset(Asset& asset, PxFileBuf& stream);
+ virtual PxFileBuf& deserializeSingleAsset(Asset& asset, PxFileBuf& stream);
+private:
+ DestructibleAssetCollision* findAssetCollisionSet(const char* name);
+
+ struct Version
+ {
+ enum Enum
+ {
+ First = 0,
+
+ Count,
+ Current = Count - 1
+ };
+ };
+
+ AuthObjTypeID mModuleID;
+ physx::Array<DestructibleAssetCollision*> mAssetCollisionSets;
+};
+
+class ModuleDestructibleImpl : public ModuleDestructible, public ModuleIntl, public ModuleBase, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ModuleDestructibleImpl(ApexSDKIntl* sdk);
+ ~ModuleDestructibleImpl();
+
+ void destroy();
+
+ // base class methods
+ void init(NvParameterized::Interface& desc);
+ NvParameterized::Interface* getDefaultModuleDesc();
+ void release()
+ {
+ ModuleBase::release();
+ }
+ const char* getName() const
+ {
+ READ_ZONE();
+ return ModuleBase::getName();
+ }
+ bool isInitialized()
+ {
+ return m_isInitialized;
+ }
+
+ bool setRenderLockMode(RenderLockMode::Enum, Scene&);
+
+ RenderLockMode::Enum getRenderLockMode(const Scene&) const;
+
+ bool lockModuleSceneRenderLock(Scene&);
+
+ bool unlockModuleSceneRenderLock(Scene&);
+
+ void setIntValue(uint32_t parameterIndex, uint32_t value);
+ ModuleSceneIntl* createInternalModuleScene(SceneIntl&, RenderDebugInterface*);
+ void releaseModuleSceneIntl(ModuleSceneIntl&);
+ uint32_t forceLoadAssets();
+ AuthObjTypeID getModuleID() const;
+ RenderableIterator* createRenderableIterator(const Scene&);
+
+ DestructibleActorJoint* createDestructibleActorJoint(const DestructibleActorJointDesc&, Scene&);
+ bool isDestructibleActorJointActive(const DestructibleActorJoint*, Scene&) const;
+
+ void setMaxDynamicChunkIslandCount(uint32_t maxCount);
+ void setMaxChunkCount(uint32_t maxCount);
+
+ void setSortByBenefit(bool sortByBenefit);
+ void setMaxChunkDepthOffset(uint32_t offset);
+ void setMaxChunkSeparationLOD(float separationLOD);
+
+ void setChunkReport(UserChunkReport* chunkReport);
+ void setImpactDamageReportCallback(UserImpactDamageReport* impactDamageReport);
+ void setChunkReportBitMask(uint32_t chunkReportBitMask);
+ void setDestructiblePhysXActorReport(UserDestructiblePhysXActorReport* destructiblePhysXActorReport);
+ void setChunkReportMaxFractureEventDepth(uint32_t chunkReportMaxFractureEventDepth);
+ void scheduleChunkStateEventCallback(DestructibleCallbackSchedule::Enum chunkStateEventCallbackSchedule);
+ void setChunkCrumbleReport(UserChunkParticleReport* chunkCrumbleReport);
+ void setChunkDustReport(UserChunkParticleReport* chunkDustReport);
+ void setWorldSupportPhysXScene(Scene& apexScene, PxScene* physxScene);
+
+ bool owns(const PxRigidActor* actor) const;
+#if APEX_RUNTIME_FRACTURE
+ bool isRuntimeFractureShape(const PxShape& shape) const;
+#endif
+
+ DestructibleActor* getDestructibleAndChunk(const PxShape* shape, int32_t* chunkIndex) const;
+
+ void applyRadiusDamage(Scene& scene, float damage, float momentum,
+ const PxVec3& position, float radius, bool falloff);
+
+ void setMaxActorCreatesPerFrame(uint32_t maxActorsPerFrame);
+ void setMaxFracturesProcessedPerFrame(uint32_t maxActorsPerFrame);
+ void setValidBoundsPadding(float);
+
+#if 0 // dead code
+ void releaseBufferedConvexMeshes();
+#endif
+
+ ModuleCachedDataIntl* getModuleDataCache()
+ {
+ return mCachedData;
+ }
+
+ PX_INLINE NvParameterized::Interface* getApexDestructiblePreviewParams(void) const
+ {
+ return mApexDestructiblePreviewParams;
+ }
+
+ void setUseLegacyChunkBoundsTesting(bool useLegacyChunkBoundsTesting);
+ bool getUseLegacyChunkBoundsTesting() const
+ {
+ return mUseLegacyChunkBoundsTesting;
+ }
+
+ void setUseLegacyDamageRadiusSpread(bool useLegacyDamageRadiusSpread);
+ bool getUseLegacyDamageRadiusSpread() const
+ {
+ return mUseLegacyDamageRadiusSpread;
+ }
+
+ bool setMassScaling(float massScale, float scaledMassExponent, Scene& apexScene);
+
+ void invalidateBounds(const PxBounds3* bounds, uint32_t boundsCount, Scene& apexScene);
+
+ void setDamageApplicationRaycastFlags(nvidia::DestructibleActorRaycastFlags::Enum flags, Scene& apexScene);
+
+ bool setChunkCollisionHullCookingScale(const PxVec3& scale);
+
+ PxVec3 getChunkCollisionHullCookingScale() const { READ_ZONE(); return mChunkCollisionHullCookingScale; }
+
+ virtual class FractureToolsAPI* getFractureTools() const
+ {
+ READ_ZONE();
+#ifdef WITHOUT_APEX_AUTHORING
+ APEX_DEBUG_WARNING("FractureTools are not available in release builds.");
+#endif
+ return (FractureToolsAPI*)mFractureTools;
+ }
+
+ DestructibleModuleParameters* getModuleParameters()
+ {
+ return mModuleParams;
+ }
+
+#if 0 // dead code
+ physx::Array<PxConvexMesh*> convexMeshKillList;
+#endif
+
+private:
+ // Private interface, used by Destructible* classes
+
+ DestructibleScene* getDestructibleScene(const Scene& apexScene) const;
+
+ bool m_isInitialized;
+
+ // Max chunk depth offset (for LOD) - effectively reduces the max chunk depth in all destructibles by this number
+ uint32_t m_maxChunkDepthOffset;
+ // Where in the assets' min-max range to place the lifetime and max. separation
+ float m_maxChunkSeparationLOD;
+ float m_validBoundsPadding;
+ uint32_t m_maxFracturesProcessedPerFrame;
+ uint32_t m_maxActorsCreateablePerFrame;
+ uint32_t m_dynamicActorFIFOMax;
+ uint32_t m_chunkFIFOMax;
+ bool m_sortByBenefit;
+ UserChunkReport* m_chunkReport;
+ UserImpactDamageReport* m_impactDamageReport;
+ uint32_t m_chunkReportBitMask;
+ UserDestructiblePhysXActorReport* m_destructiblePhysXActorReport;
+ uint32_t m_chunkReportMaxFractureEventDepth;
+ DestructibleCallbackSchedule::Enum m_chunkStateEventCallbackSchedule;
+ UserChunkParticleReport* m_chunkCrumbleReport;
+ UserChunkParticleReport* m_chunkDustReport;
+
+ float m_massScale;
+ float m_scaledMassExponent;
+
+ ResourceList m_destructibleSceneList;
+
+ ResourceList mAuthorableObjects;
+
+ NvParameterized::Interface* mApexDestructiblePreviewParams;
+ DestructibleModuleParameters* mModuleParams;
+
+ DestructibleModuleCachedData* mCachedData;
+
+ nvidia::QDSRand mRandom;
+
+ bool mUseLegacyChunkBoundsTesting;
+ bool mUseLegacyDamageRadiusSpread;
+
+ PxVec3 mChunkCollisionHullCookingScale;
+
+ class FractureTools* mFractureTools;
+
+ /*** ModuleDestructibleImpl::SyncParams ***/
+public:
+ bool setSyncParams(UserDamageEventHandler * userDamageEventHandler, UserFractureEventHandler * userFractureEventHandler, UserChunkMotionHandler * userChunkMotionHandler);
+public:
+ class SyncParams
+ {
+ friend bool ModuleDestructibleImpl::setSyncParams(UserDamageEventHandler *, UserFractureEventHandler *, UserChunkMotionHandler *);
+ public:
+ SyncParams();
+ ~SyncParams();
+ UserDamageEventHandler * getUserDamageEventHandler() const;
+ UserFractureEventHandler * getUserFractureEventHandler() const;
+ UserChunkMotionHandler * getUserChunkMotionHandler() const;
+ template<typename T> uint32_t getSize() const;
+ private:
+ DECLARE_DISABLE_COPY_AND_ASSIGN(SyncParams);
+ UserDamageEventHandler * userDamageEventHandler;
+ UserFractureEventHandler * userFractureEventHandler;
+ UserChunkMotionHandler * userChunkMotionHandler;
+ };
+ const ModuleDestructibleImpl::SyncParams & getSyncParams() const;
+private:
+ SyncParams mSyncParams;
+
+private:
+ friend class DestructibleActorImpl;
+ friend class DestructibleActorJointImpl;
+ friend class DestructibleAssetImpl;
+ friend class DestructibleStructure;
+ friend class DestructibleScene;
+ friend class DestructibleContactReport;
+ friend class DestructibleContactModify;
+ friend class ApexDamageEventReportDataImpl;
+ friend struct DestructibleNXActorCreator;
+};
+
+
+
+#ifndef WITHOUT_APEX_AUTHORING
+// API for FractureTools from our shared/internal code
+class FractureTools : public nvidia::apex::FractureToolsAPI, public UserAllocated
+{
+public:
+ virtual ~FractureTools() {};
+
+ virtual ::FractureTools::CutoutSet* createCutoutSet()
+ {
+ return ::FractureTools::createCutoutSet();
+ }
+
+ virtual void buildCutoutSet(::FractureTools::CutoutSet& cutoutSet, const uint8_t* pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight, float snapThreshold, bool periodic)
+ {
+ return ::FractureTools::buildCutoutSet(cutoutSet, pixelBuffer, bufferWidth, bufferHeight, snapThreshold, periodic);
+ }
+
+ virtual bool calculateCutoutUVMapping(const nvidia::ExplicitRenderTriangle& triangle, PxMat33& theMapping)
+ {
+ return ::FractureTools::calculateCutoutUVMapping(triangle, theMapping);
+ }
+
+ virtual bool calculateCutoutUVMapping(nvidia::ExplicitHierarchicalMesh& hMesh, const PxVec3& targetDirection, PxMat33& theMapping)
+ {
+ return ::FractureTools::calculateCutoutUVMapping(hMesh, targetDirection, theMapping);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createVoronoiSplitMesh(hMesh, iHMeshCore, exportCoreMesh, coreMeshImprintSubmeshIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createVoronoiSitesInsideMesh(hMesh, siteBuffer, siteChunkIndices, siteCount, randomSeed, microgridSize, meshMode, progressListener, chunkIndex);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createScatterMeshSites(meshIndices, relativeTransforms, chunkMeshStarts, scatterMeshInstancesBufferSize, hMesh, targetChunkCount,
+ targetChunkIndices, randomSeed, scatterMeshAssetCount, scatterMeshAssets, minCount, maxCount, minScales, maxScales, maxAngles);
+ }
+
+ 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
+ )
+ {
+ ::FractureTools::visualizeVoronoiCells(debugRender, sites, siteCount, cellColors, cellColorCount, bounds, cellIndex);
+ }
+
+ 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
+
+ )
+ {
+ return ::FractureTools::buildExplicitHierarchicalMesh(iHMesh, meshTriangles, meshTriangleCount, submeshData, submeshCount, meshPartition, meshPartitionCount, parentIndices, parentIndexCount);
+ }
+
+ virtual void setBSPTolerances
+ (
+ float linearTolerance,
+ float angularTolerance,
+ float baseTolerance,
+ float clipTolerance,
+ float cleaningTolerance
+ )
+ {
+ ::FractureTools::setBSPTolerances(linearTolerance, angularTolerance, baseTolerance, clipTolerance, cleaningTolerance);
+ }
+
+ virtual void setBSPBuildParameters
+ (
+ float logAreaSigmaThreshold,
+ uint32_t testSetSize,
+ float splitWeight,
+ float imbalanceWeight
+ )
+ {
+ ::FractureTools::setBSPBuildParameters(logAreaSigmaThreshold, testSetSize, splitWeight, imbalanceWeight);
+ }
+
+ virtual bool buildExplicitHierarchicalMeshFromRenderMeshAsset(nvidia::ExplicitHierarchicalMesh& iHMesh, const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX)
+ {
+ return ::FractureTools::buildExplicitHierarchicalMeshFromRenderMeshAsset(iHMesh, renderMeshAsset, maxRootDepth);
+ }
+
+ virtual bool buildExplicitHierarchicalMeshFromDestructibleAsset(nvidia::ExplicitHierarchicalMesh& iHMesh, const nvidia::DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX)
+ {
+ return ::FractureTools::buildExplicitHierarchicalMeshFromDestructibleAsset(iHMesh, destructibleAsset, maxRootDepth);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createHierarchicallySplitMesh(hMesh, iHMeshCore, exportCoreMesh, coreMeshImprintSubmeshIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::createChippedMesh(hMesh, meshProcessingParams, desc, iCutoutSet, sliceDesc, voronoiDesc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::hierarchicallySplitChunk(hMesh, chunkIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ 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
+ )
+ {
+ return ::FractureTools::voronoiSplitChunk(hMesh, chunkIndex, meshProcessingParams, desc, collisionDesc, randomSeed, progressListener, cancel);
+ }
+
+ virtual bool buildSliceMesh
+ (
+ IntersectMesh& intersectMesh,
+ nvidia::ExplicitHierarchicalMesh& referenceMesh,
+ const PxPlane& slicePlane,
+ const ::FractureTools::NoiseParameters& noiseParameters,
+ uint32_t randomSeed
+ )
+ {
+ return ::FractureTools::buildSliceMesh(intersectMesh, referenceMesh, slicePlane, noiseParameters, randomSeed);
+ }
+
+ virtual nvidia::ExplicitHierarchicalMesh* createExplicitHierarchicalMesh()
+ {
+ return ::FractureTools::createExplicitHierarchicalMesh();
+ }
+
+ virtual nvidia::ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull()
+ {
+ return ::FractureTools::createExplicitHierarchicalMeshConvexHull();
+ }
+};
+#endif
+
+
+
+}
+} // end namespace nvidia
+
+
+#endif // __MODULE_DESTRUCTIBLE_IMPL_H__
diff --git a/APEX_1.4/module/destructible/include/ModuleEventDefs.h b/APEX_1.4/module/destructible/include/ModuleEventDefs.h
new file mode 100644
index 00000000..933cdde0
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/ModuleEventDefs.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+
+// This file is used to define a list of AgPerfMon events.
+//
+// This file is included exclusively by AgPerfMonEventSrcAPI.h
+// and by AgPerfMonEventSrcAPI.cpp, for the purpose of building
+// an enumeration (enum xx) and an array of strings ()
+// that contain the list of events.
+//
+// This file should only contain event definitions, using the
+// DEFINE_EVENT macro. E.g.:
+//
+// DEFINE_EVENT(sample_name_1)
+// DEFINE_EVENT(sample_name_2)
+// DEFINE_EVENT(sample_name_3)
+
+DEFINE_EVENT(DestructibleFetchResults)
+DEFINE_EVENT(DestructibleUpdateRenderResources)
+DEFINE_EVENT(DestructibleDispatchRenderResources)
+DEFINE_EVENT(DestructibleSeparateUnsupportedIslands)
+DEFINE_EVENT(DestructibleCreateDynamicIsland)
+DEFINE_EVENT(DestructibleCookChunkCollisionMeshes)
+DEFINE_EVENT(DestructibleAddActors)
+DEFINE_EVENT(DestructibleCreateRoot)
+DEFINE_EVENT(DestructibleAppendShape)
+DEFINE_EVENT(DestructibleStructureTick)
+DEFINE_EVENT(DestructiblePhysBasedStressSolver)
+DEFINE_EVENT(DestructiblePhysBasedStressSolverInitial)
+DEFINE_EVENT(DestructiblePhysBasedStressSolverCalculateForce)
+DEFINE_EVENT(DestructiblePhysBasedStressSolverRemoveChunk)
+DEFINE_EVENT(DestructibleStructureBoundsCalculateOverlaps)
+DEFINE_EVENT(DestructibleStructureDetailedOverlapTest)
+DEFINE_EVENT(DestructibleCreateActor)
+DEFINE_EVENT(DestructibleCacheChunkCookedCollisionMeshes)
+DEFINE_EVENT(DestructibleFractureChunk)
+DEFINE_EVENT(DestructibleChunkReport)
+DEFINE_EVENT(DestructibleRayCastFindVisibleChunk)
+DEFINE_EVENT(DestructibleRayCastFindDeepestChunk)
+DEFINE_EVENT(DestructibleRayCastProcessChunk)
+DEFINE_EVENT(DestructibleRemoveChunksForBudget)
+DEFINE_EVENT(DestructibleProcessFractureBuffer)
+DEFINE_EVENT(DestructibleKillStructures)
+DEFINE_EVENT(DestructibleOnContactConstraint)
+DEFINE_EVENT(DestructibleOnContactNotify)
+DEFINE_EVENT(DestructibleBeforeTickLockRenderables)
+DEFINE_EVENT(DestructibleUpdateRenderMeshBonePoses)
+DEFINE_EVENT(DestructibleStructureBuildSupportGraph)
+DEFINE_EVENT(DestructibleSimulate)
+DEFINE_EVENT(DestructibleCalcStaticChunkBenefit)
+DEFINE_EVENT(DestructibleGatherNonessentialChunks)
+DEFINE_EVENT(DestructibleCalculateBenefit)
+DEFINE_EVENT(DestructibleGetChunkGlobalPose)
diff --git a/APEX_1.4/module/destructible/include/ModulePerfScope.h b/APEX_1.4/module/destructible/include/ModulePerfScope.h
new file mode 100644
index 00000000..fd53d00e
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/ModulePerfScope.h
@@ -0,0 +1,18 @@
+/*
+ * 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_PERF_SCOPE_H___
+#define __MODULE_PERF_SCOPE_H___
+
+#define MODULE_NAMESPACE destructible
+#include "ModuleProfileCommon.h"
+
+#endif \ No newline at end of file
diff --git a/APEX_1.4/module/destructible/include/autogen/CachedOverlaps.h b/APEX_1.4/module/destructible/include/autogen/CachedOverlaps.h
new file mode 100644
index 00000000..e1c34060
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/CachedOverlaps.h
@@ -0,0 +1,245 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_CachedOverlaps_h
+#define HEADER_CachedOverlaps_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace CachedOverlapsNS
+{
+
+struct IntPair_Type;
+
+struct IntPair_DynamicArray1D_Type
+{
+ IntPair_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct IntPair_Type
+{
+ int32_t i0;
+ int32_t i1;
+};
+
+struct ParametersStruct
+{
+
+ bool isCached;
+ IntPair_DynamicArray1D_Type overlaps;
+
+};
+
+static const uint32_t checksum[] = { 0x42ce64a0, 0x9634fff2, 0x6f308fbe, 0xf3ce7bcd, };
+
+} // namespace CachedOverlapsNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class CachedOverlaps : public NvParameterized::NvParameters, public CachedOverlapsNS::ParametersStruct
+{
+public:
+ CachedOverlaps(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~CachedOverlaps();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("CachedOverlaps");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)1;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(CachedOverlapsNS::checksum);
+ return CachedOverlapsNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const CachedOverlapsNS::ParametersStruct& parameters(void) const
+ {
+ CachedOverlaps* tmpThis = const_cast<CachedOverlaps*>(this);
+ return *(static_cast<CachedOverlapsNS::ParametersStruct*>(tmpThis));
+ }
+
+ CachedOverlapsNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<CachedOverlapsNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class CachedOverlapsFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ CachedOverlaps::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(CachedOverlaps), CachedOverlaps::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, CachedOverlaps::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class CachedOverlaps");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(CachedOverlaps)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, CachedOverlaps)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, CachedOverlaps::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, CachedOverlaps::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class CachedOverlaps");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of CachedOverlaps here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (CachedOverlaps*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (CachedOverlaps::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (CachedOverlaps::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (CachedOverlaps::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (CachedOverlaps::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleActorChunks.h b/APEX_1.4/module/destructible/include/autogen/DestructibleActorChunks.h
new file mode 100644
index 00000000..893224e9
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleActorChunks.h
@@ -0,0 +1,253 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleActorChunks_h
+#define HEADER_DestructibleActorChunks_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleActorChunksNS
+{
+
+struct Chunk_Type;
+
+struct Chunk_DynamicArray1D_Type
+{
+ Chunk_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct Chunk_Type
+{
+ uint8_t state;
+ uint8_t flags;
+ uint32_t islandID;
+ float damage;
+ physx::PxVec4 localSphere;
+ physx::PxVec3 localOffset;
+ int32_t visibleAncestorIndex;
+ uint32_t shapesCount;
+ physx::PxTransform globalPose;
+ physx::PxVec3 linearVelocity;
+ physx::PxVec3 angularVelocity;
+};
+
+struct ParametersStruct
+{
+
+ Chunk_DynamicArray1D_Type data;
+
+};
+
+static const uint32_t checksum[] = { 0x1f4e04ad, 0x95dc5558, 0x4dae15a1, 0x46caf98e, };
+
+} // namespace DestructibleActorChunksNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleActorChunks : public NvParameterized::NvParameters, public DestructibleActorChunksNS::ParametersStruct
+{
+public:
+ DestructibleActorChunks(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleActorChunks();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleActorChunks");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleActorChunksNS::checksum);
+ return DestructibleActorChunksNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleActorChunksNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleActorChunks* tmpThis = const_cast<DestructibleActorChunks*>(this);
+ return *(static_cast<DestructibleActorChunksNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleActorChunksNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleActorChunksNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleActorChunksFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleActorChunks::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleActorChunks), DestructibleActorChunks::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleActorChunks::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorChunks");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleActorChunks)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleActorChunks)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleActorChunks::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleActorChunks::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorChunks");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleActorChunks here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleActorChunks*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleActorChunks::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleActorChunks::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleActorChunks::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleActorChunks::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleActorParam.h b/APEX_1.4/module/destructible/include/autogen/DestructibleActorParam.h
new file mode 100644
index 00000000..9fb50b5c
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleActorParam.h
@@ -0,0 +1,606 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleActorParam_h
+#define HEADER_DestructibleActorParam_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleActorParamNS
+{
+
+struct GroupsMask_Type;
+struct ShapeDescFlags_Type;
+struct ShapeDescTemplate_Type;
+struct ContactPairFlag_Type;
+struct ActorDescFlags_Type;
+struct ActorDescTemplate_Type;
+struct BodyDescFlags_Type;
+struct BodyDescTemplate_Type;
+struct DestructibleDepthParameters_Type;
+struct DestructibleParametersFlag_Type;
+struct FractureGlass_Type;
+struct FractureVoronoi_Type;
+struct FractureAttachment_Type;
+struct RuntimeFracture_Type;
+struct DestructibleParameters_Type;
+struct DamageSpreadFunction_Type;
+struct P3FilterData_Type;
+struct P3ShapeFlags_Type;
+struct P3PairFlag_Type;
+struct P3ShapeDescTemplate_Type;
+struct P3ActorFlags_Type;
+struct P3ActorDescTemplate_Type;
+struct P3BodyDescFlags_Type;
+struct P3BodyDescTemplate_Type;
+struct StructureSettings_Type;
+struct BehaviorGroup_Type;
+
+struct STRING_DynamicArray1D_Type
+{
+ NvParameterized::DummyStringStruct* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct DestructibleDepthParameters_DynamicArray1D_Type
+{
+ DestructibleDepthParameters_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct BehaviorGroup_DynamicArray1D_Type
+{
+ BehaviorGroup_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct DestructibleDepthParameters_Type
+{
+ bool OVERRIDE_IMPACT_DAMAGE;
+ bool OVERRIDE_IMPACT_DAMAGE_VALUE;
+ bool IGNORE_POSE_UPDATES;
+ bool IGNORE_RAYCAST_CALLBACKS;
+ bool IGNORE_CONTACT_CALLBACKS;
+ bool USER_FLAG_0;
+ bool USER_FLAG_1;
+ bool USER_FLAG_2;
+ bool USER_FLAG_3;
+};
+struct P3BodyDescFlags_Type
+{
+ bool eKINEMATIC;
+ bool eENABLE_CCD;
+};
+struct GroupsMask_Type
+{
+ bool useGroupsMask;
+ uint32_t bits0;
+ uint32_t bits1;
+ uint32_t bits2;
+ uint32_t bits3;
+};
+struct DestructibleParametersFlag_Type
+{
+ bool ACCUMULATE_DAMAGE;
+ bool DEBRIS_TIMEOUT;
+ bool DEBRIS_MAX_SEPARATION;
+ bool CRUMBLE_SMALLEST_CHUNKS;
+ bool ACCURATE_RAYCASTS;
+ bool USE_VALID_BOUNDS;
+ bool CRUMBLE_VIA_RUNTIME_FRACTURE;
+};
+struct ShapeDescFlags_Type
+{
+ bool NX_TRIGGER_ON_ENTER;
+ bool NX_TRIGGER_ON_LEAVE;
+ bool NX_TRIGGER_ON_STAY;
+ bool NX_SF_VISUALIZATION;
+ bool NX_SF_DISABLE_COLLISION;
+ bool NX_SF_FEATURE_INDICES;
+ bool NX_SF_DISABLE_RAYCASTING;
+ bool NX_SF_POINT_CONTACT_FORCE;
+ bool NX_SF_FLUID_DRAIN;
+ bool NX_SF_FLUID_DISABLE_COLLISION;
+ bool NX_SF_FLUID_TWOWAY;
+ bool NX_SF_DISABLE_RESPONSE;
+ bool NX_SF_DYNAMIC_DYNAMIC_CCD;
+ bool NX_SF_DISABLE_SCENE_QUERIES;
+ bool NX_SF_CLOTH_DRAIN;
+ bool NX_SF_CLOTH_DISABLE_COLLISION;
+ bool NX_SF_CLOTH_TWOWAY;
+ bool NX_SF_SOFTBODY_DRAIN;
+ bool NX_SF_SOFTBODY_DISABLE_COLLISION;
+ bool NX_SF_SOFTBODY_TWOWAY;
+};
+struct ShapeDescTemplate_Type
+{
+ ShapeDescFlags_Type flags;
+ uint16_t collisionGroup;
+ GroupsMask_Type groupsMask;
+ uint16_t materialIndex;
+ float density;
+ float skinWidth;
+ uint64_t userData;
+ uint64_t name;
+};
+struct P3FilterData_Type
+{
+ uint32_t word0;
+ uint32_t word1;
+ uint32_t word2;
+ uint32_t word3;
+};
+struct StructureSettings_Type
+{
+ bool useStressSolver;
+ float stressSolverTimeDelay;
+ float stressSolverMassThreshold;
+};
+struct FractureGlass_Type
+{
+ uint32_t numSectors;
+ float sectorRand;
+ float firstSegmentSize;
+ float segmentScale;
+ float segmentRand;
+};
+struct DamageSpreadFunction_Type
+{
+ float minimumRadius;
+ float radiusMultiplier;
+ float falloffExponent;
+};
+struct FractureVoronoi_Type
+{
+ physx::PxVec3 dimensions;
+ uint32_t numCells;
+ float biasExp;
+ float maxDist;
+};
+struct BehaviorGroup_Type
+{
+ NvParameterized::DummyStringStruct name;
+ float damageThreshold;
+ float damageToRadius;
+ DamageSpreadFunction_Type damageSpread;
+ DamageSpreadFunction_Type damageColorSpread;
+ physx::PxVec4 damageColorChange;
+ float materialStrength;
+ float density;
+ float fadeOut;
+ float maxDepenetrationVelocity;
+ GroupsMask_Type groupsMask;
+ uint64_t userData;
+};
+struct P3ShapeFlags_Type
+{
+ bool eSIMULATION_SHAPE;
+ bool eSCENE_QUERY_SHAPE;
+ bool eTRIGGER_SHAPE;
+ bool eVISUALIZATION;
+ bool ePARTICLE_DRAIN;
+ bool eDEFORMABLE_DRAIN;
+};
+struct P3ShapeDescTemplate_Type
+{
+ P3ShapeFlags_Type flags;
+ P3FilterData_Type simulationFilterData;
+ P3FilterData_Type queryFilterData;
+ uint64_t material;
+ float contactOffset;
+ float restOffset;
+ uint64_t userData;
+ uint64_t name;
+};
+struct P3ActorFlags_Type
+{
+ bool eVISUALIZATION;
+ bool eDISABLE_GRAVITY;
+ bool eSEND_SLEEP_NOTIFIES;
+};
+struct P3BodyDescTemplate_Type
+{
+ float density;
+ P3BodyDescFlags_Type flags;
+ float sleepThreshold;
+ float wakeUpCounter;
+ float linearDamping;
+ float angularDamping;
+ float maxAngularVelocity;
+ uint32_t solverIterationCount;
+ uint32_t velocityIterationCount;
+ float contactReportThreshold;
+ float sleepLinearVelocity;
+};
+struct ContactPairFlag_Type
+{
+ bool NX_IGNORE_PAIR;
+ bool NX_NOTIFY_ON_START_TOUCH;
+ bool NX_NOTIFY_ON_END_TOUCH;
+ bool NX_NOTIFY_ON_TOUCH;
+ bool NX_NOTIFY_ON_IMPACT;
+ bool NX_NOTIFY_ON_ROLL;
+ bool NX_NOTIFY_ON_SLIDE;
+ bool NX_NOTIFY_FORCES;
+ bool NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_CONTACT_MODIFICATION;
+};
+struct BodyDescFlags_Type
+{
+ bool NX_BF_DISABLE_GRAVITY;
+ bool NX_BF_FILTER_SLEEP_VEL;
+ bool NX_BF_ENERGY_SLEEP_TEST;
+ bool NX_BF_VISUALIZATION;
+};
+struct BodyDescTemplate_Type
+{
+ BodyDescFlags_Type flags;
+ float wakeUpCounter;
+ float linearDamping;
+ float angularDamping;
+ float maxAngularVelocity;
+ float CCDMotionThreshold;
+ float sleepLinearVelocity;
+ float sleepAngularVelocity;
+ uint32_t solverIterationCount;
+ float sleepEnergyThreshold;
+ float sleepDamping;
+ float contactReportThreshold;
+};
+struct FractureAttachment_Type
+{
+ bool posX;
+ bool negX;
+ bool posY;
+ bool negY;
+ bool posZ;
+ bool negZ;
+};
+struct RuntimeFracture_Type
+{
+ const char* RuntimeFractureType;
+ bool sheetFracture;
+ uint32_t depthLimit;
+ bool destroyIfAtDepthLimit;
+ float minConvexSize;
+ float impulseScale;
+ FractureGlass_Type glass;
+ FractureVoronoi_Type voronoi;
+ FractureAttachment_Type attachment;
+};
+struct DestructibleParameters_Type
+{
+ float damageCap;
+ float forceToDamage;
+ float impactVelocityThreshold;
+ uint32_t minimumFractureDepth;
+ int32_t impactDamageDefaultDepth;
+ int32_t debrisDepth;
+ uint32_t essentialDepth;
+ float debrisLifetimeMin;
+ float debrisLifetimeMax;
+ float debrisMaxSeparationMin;
+ float debrisMaxSeparationMax;
+ float debrisDestructionProbability;
+ physx::PxBounds3 validBounds;
+ float maxChunkSpeed;
+ DestructibleParametersFlag_Type flags;
+ float fractureImpulseScale;
+ uint16_t damageDepthLimit;
+ uint16_t dynamicChunkDominanceGroup;
+ GroupsMask_Type dynamicChunksGroupsMask;
+ RuntimeFracture_Type runtimeFracture;
+ float supportStrength;
+ int8_t legacyChunkBoundsTestSetting;
+ int8_t legacyDamageRadiusSpreadSetting;
+ bool alwaysDrawScatterMesh;
+};
+struct ActorDescFlags_Type
+{
+ bool NX_AF_DISABLE_COLLISION;
+ bool NX_AF_DISABLE_RESPONSE;
+ bool NX_AF_LOCK_COM;
+ bool NX_AF_FLUID_DISABLE_COLLISION;
+ bool NX_AF_CONTACT_MODIFICATION;
+ bool NX_AF_FORCE_CONE_FRICTION;
+ bool NX_AF_USER_ACTOR_PAIR_FILTERING;
+};
+struct ActorDescTemplate_Type
+{
+ ActorDescFlags_Type flags;
+ float density;
+ uint16_t actorCollisionGroup;
+ uint16_t dominanceGroup;
+ ContactPairFlag_Type contactReportFlags;
+ uint16_t forceFieldMaterial;
+ uint64_t userData;
+ uint64_t name;
+ uint64_t compartment;
+};
+struct P3PairFlag_Type
+{
+ bool eSOLVE_CONTACT;
+ bool eMODIFY_CONTACTS;
+ bool eNOTIFY_TOUCH_FOUND;
+ bool eNOTIFY_TOUCH_PERSISTS;
+ bool eNOTIFY_TOUCH_LOST;
+ bool eNOTIFY_THRESHOLD_FORCE_FOUND;
+ bool eNOTIFY_THRESHOLD_FORCE_PERSISTS;
+ bool eNOTIFY_THRESHOLD_FORCE_LOST;
+ bool eNOTIFY_CONTACT_POINTS;
+ bool eNOTIFY_CONTACT_FORCES;
+ bool eNOTIFY_CONTACT_FORCE_PER_POINT;
+ bool eNOTIFY_CONTACT_FEATURE_INDICES_PER_POINT;
+ bool eDETECT_CCD_CONTACT;
+ bool eCONTACT_DEFAULT;
+ bool eTRIGGER_DEFAULT;
+};
+struct P3ActorDescTemplate_Type
+{
+ P3ActorFlags_Type flags;
+ uint8_t dominanceGroup;
+ uint8_t ownerClient;
+ uint32_t clientBehaviorBits;
+ P3PairFlag_Type contactReportFlags;
+ uint64_t userData;
+ uint64_t name;
+};
+
+struct ParametersStruct
+{
+
+ NvParameterized::DummyStringStruct crumbleEmitterName;
+ float crumbleParticleSpacing;
+ NvParameterized::DummyStringStruct dustEmitterName;
+ float dustParticleSpacing;
+ physx::PxTransform globalPose;
+ physx::PxVec3 scale;
+ bool dynamic;
+ uint32_t supportDepth;
+ bool formExtendedStructures;
+ bool performDetailedOverlapTestForExtendedStructures;
+ bool keepPreviousFrameBoneBuffer;
+ bool doNotCreateRenderable;
+ bool useAssetDefinedSupport;
+ bool useWorldSupport;
+ bool renderStaticChunksSeparately;
+ bool keepVisibleBonesPacked;
+ bool createChunkEvents;
+ STRING_DynamicArray1D_Type overrideSkinnedMaterialNames;
+ STRING_DynamicArray1D_Type overrideStaticMaterialNames;
+ float sleepVelocityFrameDecayConstant;
+ bool useHardSleeping;
+ DestructibleParameters_Type destructibleParameters;
+ DestructibleDepthParameters_DynamicArray1D_Type depthParameters;
+ ShapeDescTemplate_Type shapeDescTemplate;
+ ActorDescTemplate_Type actorDescTemplate;
+ BodyDescTemplate_Type bodyDescTemplate;
+ P3ShapeDescTemplate_Type p3ShapeDescTemplate;
+ P3ActorDescTemplate_Type p3ActorDescTemplate;
+ P3BodyDescTemplate_Type p3BodyDescTemplate;
+ StructureSettings_Type structureSettings;
+ BehaviorGroup_Type defaultBehaviorGroup;
+ BehaviorGroup_DynamicArray1D_Type behaviorGroups;
+ bool deleteChunksLeavingUserDefinedBB;
+ bool deleteChunksEnteringUserDefinedBB;
+
+};
+
+static const uint32_t checksum[] = { 0x2f148a8b, 0x0ef80948, 0x34293f31, 0x363a5ff0, };
+
+} // namespace DestructibleActorParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleActorParam : public NvParameterized::NvParameters, public DestructibleActorParamNS::ParametersStruct
+{
+public:
+ DestructibleActorParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleActorParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleActorParam");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)32;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleActorParamNS::checksum);
+ return DestructibleActorParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleActorParamNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleActorParam* tmpThis = const_cast<DestructibleActorParam*>(this);
+ return *(static_cast<DestructibleActorParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleActorParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleActorParamNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleActorParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleActorParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleActorParam), DestructibleActorParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleActorParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleActorParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleActorParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleActorParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleActorParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleActorParam here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleActorParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleActorParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleActorParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleActorParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleActorParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleActorState.h b/APEX_1.4/module/destructible/include/autogen/DestructibleActorState.h
new file mode 100644
index 00000000..066a881f
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleActorState.h
@@ -0,0 +1,445 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleActorState_h
+#define HEADER_DestructibleActorState_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleActorStateNS
+{
+
+struct GroupsMask_Type;
+struct ShapeDescFlags_Type;
+struct ShapeDescTemplate_Type;
+struct ContactPairFlag_Type;
+struct ActorDescFlags_Type;
+struct ActorDescTemplate_Type;
+struct BodyDescFlags_Type;
+struct BodyDescTemplate_Type;
+struct DestructibleDepthParameters_Type;
+struct DestructibleParametersFlag_Type;
+struct FractureGlass_Type;
+struct FractureVoronoi_Type;
+struct FractureAttachment_Type;
+struct RuntimeFracture_Type;
+struct DestructibleParameters_Type;
+struct DamageSpreadFunction_Type;
+
+struct DestructibleDepthParameters_Type
+{
+ bool OVERRIDE_IMPACT_DAMAGE;
+ bool OVERRIDE_IMPACT_DAMAGE_VALUE;
+ bool IGNORE_POSE_UPDATES;
+ bool IGNORE_RAYCAST_CALLBACKS;
+ bool IGNORE_CONTACT_CALLBACKS;
+ bool USER_FLAG_0;
+ bool USER_FLAG_1;
+ bool USER_FLAG_2;
+ bool USER_FLAG_3;
+};
+struct GroupsMask_Type
+{
+ bool useGroupsMask;
+ uint32_t bits0;
+ uint32_t bits1;
+ uint32_t bits2;
+ uint32_t bits3;
+};
+struct DestructibleParametersFlag_Type
+{
+ bool ACCUMULATE_DAMAGE;
+ bool DEBRIS_TIMEOUT;
+ bool DEBRIS_MAX_SEPARATION;
+ bool CRUMBLE_SMALLEST_CHUNKS;
+ bool ACCURATE_RAYCASTS;
+ bool USE_VALID_BOUNDS;
+ bool CRUMBLE_VIA_RUNTIME_FRACTURE;
+};
+struct ShapeDescFlags_Type
+{
+ bool NX_TRIGGER_ON_ENTER;
+ bool NX_TRIGGER_ON_LEAVE;
+ bool NX_TRIGGER_ON_STAY;
+ bool NX_SF_VISUALIZATION;
+ bool NX_SF_DISABLE_COLLISION;
+ bool NX_SF_FEATURE_INDICES;
+ bool NX_SF_DISABLE_RAYCASTING;
+ bool NX_SF_POINT_CONTACT_FORCE;
+ bool NX_SF_FLUID_DRAIN;
+ bool NX_SF_FLUID_DISABLE_COLLISION;
+ bool NX_SF_FLUID_TWOWAY;
+ bool NX_SF_DISABLE_RESPONSE;
+ bool NX_SF_DYNAMIC_DYNAMIC_CCD;
+ bool NX_SF_DISABLE_SCENE_QUERIES;
+ bool NX_SF_CLOTH_DRAIN;
+ bool NX_SF_CLOTH_DISABLE_COLLISION;
+ bool NX_SF_CLOTH_TWOWAY;
+ bool NX_SF_SOFTBODY_DRAIN;
+ bool NX_SF_SOFTBODY_DISABLE_COLLISION;
+ bool NX_SF_SOFTBODY_TWOWAY;
+};
+struct ShapeDescTemplate_Type
+{
+ ShapeDescFlags_Type flags;
+ uint16_t collisionGroup;
+ GroupsMask_Type groupsMask;
+ uint16_t materialIndex;
+ float density;
+ float skinWidth;
+ uint64_t userData;
+ uint64_t name;
+};
+struct FractureGlass_Type
+{
+ uint32_t numSectors;
+ float sectorRand;
+ float firstSegmentSize;
+ float segmentScale;
+ float segmentRand;
+};
+struct DamageSpreadFunction_Type
+{
+ float minimumRadius;
+ float radiusMultiplier;
+ float falloffExponent;
+};
+struct FractureVoronoi_Type
+{
+ physx::PxVec3 dimensions;
+ uint32_t numCells;
+ float biasExp;
+ float maxDist;
+};
+struct ContactPairFlag_Type
+{
+ bool NX_IGNORE_PAIR;
+ bool NX_NOTIFY_ON_START_TOUCH;
+ bool NX_NOTIFY_ON_END_TOUCH;
+ bool NX_NOTIFY_ON_TOUCH;
+ bool NX_NOTIFY_ON_IMPACT;
+ bool NX_NOTIFY_ON_ROLL;
+ bool NX_NOTIFY_ON_SLIDE;
+ bool NX_NOTIFY_FORCES;
+ bool NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_CONTACT_MODIFICATION;
+};
+struct BodyDescFlags_Type
+{
+ bool NX_BF_DISABLE_GRAVITY;
+ bool NX_BF_FILTER_SLEEP_VEL;
+ bool NX_BF_ENERGY_SLEEP_TEST;
+ bool NX_BF_VISUALIZATION;
+};
+struct BodyDescTemplate_Type
+{
+ BodyDescFlags_Type flags;
+ float wakeUpCounter;
+ float linearDamping;
+ float angularDamping;
+ float maxAngularVelocity;
+ float CCDMotionThreshold;
+ float sleepLinearVelocity;
+ float sleepAngularVelocity;
+ uint32_t solverIterationCount;
+ float sleepEnergyThreshold;
+ float sleepDamping;
+ float contactReportThreshold;
+};
+struct FractureAttachment_Type
+{
+ bool posX;
+ bool negX;
+ bool posY;
+ bool negY;
+ bool posZ;
+ bool negZ;
+};
+struct RuntimeFracture_Type
+{
+ const char* RuntimeFractureType;
+ bool sheetFracture;
+ uint32_t depthLimit;
+ bool destroyIfAtDepthLimit;
+ float minConvexSize;
+ float impulseScale;
+ FractureGlass_Type glass;
+ FractureVoronoi_Type voronoi;
+ FractureAttachment_Type attachment;
+};
+struct DestructibleParameters_Type
+{
+ float damageCap;
+ float forceToDamage;
+ float impactVelocityThreshold;
+ uint32_t minimumFractureDepth;
+ int32_t impactDamageDefaultDepth;
+ int32_t debrisDepth;
+ uint32_t essentialDepth;
+ float debrisLifetimeMin;
+ float debrisLifetimeMax;
+ float debrisMaxSeparationMin;
+ float debrisMaxSeparationMax;
+ float debrisDestructionProbability;
+ physx::PxBounds3 validBounds;
+ float maxChunkSpeed;
+ DestructibleParametersFlag_Type flags;
+ float fractureImpulseScale;
+ uint16_t damageDepthLimit;
+ uint16_t dynamicChunkDominanceGroup;
+ GroupsMask_Type dynamicChunksGroupsMask;
+ RuntimeFracture_Type runtimeFracture;
+ float supportStrength;
+ int8_t legacyChunkBoundsTestSetting;
+ int8_t legacyDamageRadiusSpreadSetting;
+ bool alwaysDrawScatterMesh;
+};
+struct ActorDescFlags_Type
+{
+ bool NX_AF_DISABLE_COLLISION;
+ bool NX_AF_DISABLE_RESPONSE;
+ bool NX_AF_LOCK_COM;
+ bool NX_AF_FLUID_DISABLE_COLLISION;
+ bool NX_AF_CONTACT_MODIFICATION;
+ bool NX_AF_FORCE_CONE_FRICTION;
+ bool NX_AF_USER_ACTOR_PAIR_FILTERING;
+};
+struct ActorDescTemplate_Type
+{
+ ActorDescFlags_Type flags;
+ float density;
+ uint16_t actorCollisionGroup;
+ uint16_t dominanceGroup;
+ ContactPairFlag_Type contactReportFlags;
+ uint16_t forceFieldMaterial;
+ uint64_t userData;
+ uint64_t name;
+ uint64_t compartment;
+};
+
+struct ParametersStruct
+{
+
+ bool enableCrumbleEmitter;
+ bool enableDustEmitter;
+ uint32_t lod;
+ bool forceLod;
+ DestructibleParameters_Type destructibleParameters;
+ uint64_t userData;
+ NvParameterized::Interface* actorParameters;
+ NvParameterized::Interface* actorChunks;
+
+};
+
+static const uint32_t checksum[] = { 0xc6984ee8, 0x0dae2202, 0x4f638ad1, 0x24536329, };
+
+} // namespace DestructibleActorStateNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleActorState : public NvParameterized::NvParameters, public DestructibleActorStateNS::ParametersStruct
+{
+public:
+ DestructibleActorState(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleActorState();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleActorState");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)4;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleActorStateNS::checksum);
+ return DestructibleActorStateNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleActorStateNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleActorState* tmpThis = const_cast<DestructibleActorState*>(this);
+ return *(static_cast<DestructibleActorStateNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleActorStateNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleActorStateNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleActorStateFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleActorState::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleActorState), DestructibleActorState::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleActorState::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorState");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleActorState)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleActorState)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleActorState::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleActorState::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleActorState");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleActorState here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleActorState*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleActorState::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleActorState::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleActorState::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleActorState::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleAssetCollisionDataSet.h b/APEX_1.4/module/destructible/include/autogen/DestructibleAssetCollisionDataSet.h
new file mode 100644
index 00000000..ea14b856
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleAssetCollisionDataSet.h
@@ -0,0 +1,250 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleAssetCollisionDataSet_h
+#define HEADER_DestructibleAssetCollisionDataSet_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleAssetCollisionDataSetNS
+{
+
+
+struct VEC3_DynamicArray1D_Type
+{
+ physx::PxVec3* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct REF_DynamicArray1D_Type
+{
+ NvParameterized::Interface** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ NvParameterized::DummyStringStruct assetName;
+ uint32_t cookingPlatform;
+ uint32_t cookingVersionNum;
+ VEC3_DynamicArray1D_Type scales;
+ REF_DynamicArray1D_Type meshCookedCollisionStreamsAtScale;
+
+};
+
+static const uint32_t checksum[] = { 0x716db49d, 0xccc81ef4, 0x85f3752e, 0x9cf18dc6, };
+
+} // namespace DestructibleAssetCollisionDataSetNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleAssetCollisionDataSet : public NvParameterized::NvParameters, public DestructibleAssetCollisionDataSetNS::ParametersStruct
+{
+public:
+ DestructibleAssetCollisionDataSet(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleAssetCollisionDataSet();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleAssetCollisionDataSet");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleAssetCollisionDataSetNS::checksum);
+ return DestructibleAssetCollisionDataSetNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleAssetCollisionDataSetNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleAssetCollisionDataSet* tmpThis = const_cast<DestructibleAssetCollisionDataSet*>(this);
+ return *(static_cast<DestructibleAssetCollisionDataSetNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleAssetCollisionDataSetNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleAssetCollisionDataSetNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleAssetCollisionDataSetFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleAssetCollisionDataSet::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleAssetCollisionDataSet), DestructibleAssetCollisionDataSet::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleAssetCollisionDataSet::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleAssetCollisionDataSet");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleAssetCollisionDataSet)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleAssetCollisionDataSet)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleAssetCollisionDataSet::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleAssetCollisionDataSet::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleAssetCollisionDataSet");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleAssetCollisionDataSet here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleAssetCollisionDataSet*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleAssetCollisionDataSet::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleAssetCollisionDataSet::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleAssetCollisionDataSet::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleAssetCollisionDataSet::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleAssetParameters.h b/APEX_1.4/module/destructible/include/autogen/DestructibleAssetParameters.h
new file mode 100644
index 00000000..5dfd8d79
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleAssetParameters.h
@@ -0,0 +1,675 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleAssetParameters_h
+#define HEADER_DestructibleAssetParameters_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleAssetParametersNS
+{
+
+struct GroupsMask_Type;
+struct ShapeDescFlags_Type;
+struct ShapeDescTemplate_Type;
+struct ContactPairFlag_Type;
+struct ActorDescFlags_Type;
+struct ActorDescTemplate_Type;
+struct BodyDescFlags_Type;
+struct BodyDescTemplate_Type;
+struct DestructibleDepthParameters_Type;
+struct DestructibleParametersFlag_Type;
+struct FractureGlass_Type;
+struct FractureVoronoi_Type;
+struct FractureAttachment_Type;
+struct RuntimeFracture_Type;
+struct DestructibleParameters_Type;
+struct DamageSpreadFunction_Type;
+struct BufferFormat_Type;
+struct U8x2_Type;
+struct U8x3_Type;
+struct U8x4_Type;
+struct U16x2_Type;
+struct U16x3_Type;
+struct U16x4_Type;
+struct U32x2_Type;
+struct U32x3_Type;
+struct U32x4_Type;
+struct F32x2_Type;
+struct F32x3_Type;
+struct F32x4_Type;
+struct Plane_Type;
+struct BehaviorGroup_Type;
+struct Chunk_Type;
+struct InstanceInfo_Type;
+
+struct BehaviorGroup_DynamicArray1D_Type
+{
+ BehaviorGroup_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct Chunk_DynamicArray1D_Type
+{
+ Chunk_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct REF_DynamicArray1D_Type
+{
+ NvParameterized::Interface** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct DestructibleDepthParameters_DynamicArray1D_Type
+{
+ DestructibleDepthParameters_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct InstanceInfo_DynamicArray1D_Type
+{
+ InstanceInfo_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct STRING_DynamicArray1D_Type
+{
+ NvParameterized::DummyStringStruct* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct MAT44_DynamicArray1D_Type
+{
+ physx::PxMat44* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U8_DynamicArray1D_Type
+{
+ uint8_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct F32x3_Type
+{
+ float x;
+ float y;
+ float z;
+};
+struct U32x2_Type
+{
+ uint32_t x;
+ uint32_t y;
+};
+struct DestructibleParametersFlag_Type
+{
+ bool ACCUMULATE_DAMAGE;
+ bool DEBRIS_TIMEOUT;
+ bool DEBRIS_MAX_SEPARATION;
+ bool CRUMBLE_SMALLEST_CHUNKS;
+ bool ACCURATE_RAYCASTS;
+ bool USE_VALID_BOUNDS;
+ bool CRUMBLE_VIA_RUNTIME_FRACTURE;
+};
+struct U32x4_Type
+{
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
+ uint32_t w;
+};
+struct ShapeDescFlags_Type
+{
+ bool NX_TRIGGER_ON_ENTER;
+ bool NX_TRIGGER_ON_LEAVE;
+ bool NX_TRIGGER_ON_STAY;
+ bool NX_SF_VISUALIZATION;
+ bool NX_SF_DISABLE_COLLISION;
+ bool NX_SF_FEATURE_INDICES;
+ bool NX_SF_DISABLE_RAYCASTING;
+ bool NX_SF_POINT_CONTACT_FORCE;
+ bool NX_SF_FLUID_DRAIN;
+ bool NX_SF_FLUID_DISABLE_COLLISION;
+ bool NX_SF_FLUID_TWOWAY;
+ bool NX_SF_DISABLE_RESPONSE;
+ bool NX_SF_DYNAMIC_DYNAMIC_CCD;
+ bool NX_SF_DISABLE_SCENE_QUERIES;
+ bool NX_SF_CLOTH_DRAIN;
+ bool NX_SF_CLOTH_DISABLE_COLLISION;
+ bool NX_SF_CLOTH_TWOWAY;
+ bool NX_SF_SOFTBODY_DRAIN;
+ bool NX_SF_SOFTBODY_DISABLE_COLLISION;
+ bool NX_SF_SOFTBODY_TWOWAY;
+};
+struct F32x2_Type
+{
+ float x;
+ float y;
+};
+struct InstanceInfo_Type
+{
+ uint16_t partIndex;
+ physx::PxVec3 chunkPositionOffset;
+ physx::PxVec2 chunkUVOffset;
+};
+struct Plane_Type
+{
+ physx::PxVec3 normal;
+ float d;
+};
+struct U16x2_Type
+{
+ uint16_t x;
+ uint16_t y;
+};
+struct U8x2_Type
+{
+ uint8_t x;
+ uint8_t y;
+};
+struct DamageSpreadFunction_Type
+{
+ float minimumRadius;
+ float radiusMultiplier;
+ float falloffExponent;
+};
+struct FractureVoronoi_Type
+{
+ physx::PxVec3 dimensions;
+ uint32_t numCells;
+ float biasExp;
+ float maxDist;
+};
+struct U8x3_Type
+{
+ uint8_t x;
+ uint8_t y;
+ uint8_t z;
+};
+struct ContactPairFlag_Type
+{
+ bool NX_IGNORE_PAIR;
+ bool NX_NOTIFY_ON_START_TOUCH;
+ bool NX_NOTIFY_ON_END_TOUCH;
+ bool NX_NOTIFY_ON_TOUCH;
+ bool NX_NOTIFY_ON_IMPACT;
+ bool NX_NOTIFY_ON_ROLL;
+ bool NX_NOTIFY_ON_SLIDE;
+ bool NX_NOTIFY_FORCES;
+ bool NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD;
+ bool NX_NOTIFY_CONTACT_MODIFICATION;
+};
+struct BodyDescFlags_Type
+{
+ bool NX_BF_DISABLE_GRAVITY;
+ bool NX_BF_FILTER_SLEEP_VEL;
+ bool NX_BF_ENERGY_SLEEP_TEST;
+ bool NX_BF_VISUALIZATION;
+};
+struct BufferFormat_Type
+{
+ NvParameterized::DummyStringStruct name;
+ int32_t semantic;
+ uint32_t id;
+ uint32_t format;
+ uint32_t access;
+ bool serialize;
+};
+struct FractureAttachment_Type
+{
+ bool posX;
+ bool negX;
+ bool posY;
+ bool negY;
+ bool posZ;
+ bool negZ;
+};
+struct Chunk_Type
+{
+ uint16_t depth;
+ uint16_t parentIndex;
+ uint16_t firstChildIndex;
+ uint16_t numChildren;
+ uint16_t meshPartIndex;
+ uint16_t flags;
+ physx::PxVec3 surfaceNormal;
+ int8_t behaviorGroupIndex;
+ uint16_t firstScatterMesh;
+ uint16_t scatterMeshCount;
+};
+struct DestructibleDepthParameters_Type
+{
+ bool OVERRIDE_IMPACT_DAMAGE;
+ bool OVERRIDE_IMPACT_DAMAGE_VALUE;
+ bool IGNORE_POSE_UPDATES;
+ bool IGNORE_RAYCAST_CALLBACKS;
+ bool IGNORE_CONTACT_CALLBACKS;
+ bool USER_FLAG_0;
+ bool USER_FLAG_1;
+ bool USER_FLAG_2;
+ bool USER_FLAG_3;
+};
+struct U16x4_Type
+{
+ uint16_t x;
+ uint16_t y;
+ uint16_t z;
+ uint16_t w;
+};
+struct GroupsMask_Type
+{
+ bool useGroupsMask;
+ uint32_t bits0;
+ uint32_t bits1;
+ uint32_t bits2;
+ uint32_t bits3;
+};
+struct ShapeDescTemplate_Type
+{
+ ShapeDescFlags_Type flags;
+ uint16_t collisionGroup;
+ GroupsMask_Type groupsMask;
+ uint16_t materialIndex;
+ float density;
+ float skinWidth;
+ uint64_t userData;
+ uint64_t name;
+};
+struct BodyDescTemplate_Type
+{
+ BodyDescFlags_Type flags;
+ float wakeUpCounter;
+ float linearDamping;
+ float angularDamping;
+ float maxAngularVelocity;
+ float CCDMotionThreshold;
+ float sleepLinearVelocity;
+ float sleepAngularVelocity;
+ uint32_t solverIterationCount;
+ float sleepEnergyThreshold;
+ float sleepDamping;
+ float contactReportThreshold;
+};
+struct U32x3_Type
+{
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
+};
+struct U16x3_Type
+{
+ uint16_t x;
+ uint16_t y;
+ uint16_t z;
+};
+struct F32x4_Type
+{
+ PX_ALIGN(16, float x);
+ float y;
+ float z;
+ float w;
+};
+struct FractureGlass_Type
+{
+ uint32_t numSectors;
+ float sectorRand;
+ float firstSegmentSize;
+ float segmentScale;
+ float segmentRand;
+};
+struct RuntimeFracture_Type
+{
+ const char* RuntimeFractureType;
+ bool sheetFracture;
+ uint32_t depthLimit;
+ bool destroyIfAtDepthLimit;
+ float minConvexSize;
+ float impulseScale;
+ FractureGlass_Type glass;
+ FractureVoronoi_Type voronoi;
+ FractureAttachment_Type attachment;
+};
+struct DestructibleParameters_Type
+{
+ float damageCap;
+ float forceToDamage;
+ float impactVelocityThreshold;
+ uint32_t minimumFractureDepth;
+ int32_t impactDamageDefaultDepth;
+ int32_t debrisDepth;
+ uint32_t essentialDepth;
+ float debrisLifetimeMin;
+ float debrisLifetimeMax;
+ float debrisMaxSeparationMin;
+ float debrisMaxSeparationMax;
+ float debrisDestructionProbability;
+ physx::PxBounds3 validBounds;
+ float maxChunkSpeed;
+ DestructibleParametersFlag_Type flags;
+ float fractureImpulseScale;
+ uint16_t damageDepthLimit;
+ uint16_t dynamicChunkDominanceGroup;
+ GroupsMask_Type dynamicChunksGroupsMask;
+ RuntimeFracture_Type runtimeFracture;
+ float supportStrength;
+ int8_t legacyChunkBoundsTestSetting;
+ int8_t legacyDamageRadiusSpreadSetting;
+ bool alwaysDrawScatterMesh;
+};
+struct BehaviorGroup_Type
+{
+ NvParameterized::DummyStringStruct name;
+ float damageThreshold;
+ float damageToRadius;
+ DamageSpreadFunction_Type damageSpread;
+ DamageSpreadFunction_Type damageColorSpread;
+ physx::PxVec4 damageColorChange;
+ float materialStrength;
+ float density;
+ float fadeOut;
+ float maxDepenetrationVelocity;
+ uint64_t userData;
+};
+struct U8x4_Type
+{
+ uint8_t x;
+ uint8_t y;
+ uint8_t z;
+ uint8_t w;
+};
+struct ActorDescFlags_Type
+{
+ bool NX_AF_DISABLE_COLLISION;
+ bool NX_AF_DISABLE_RESPONSE;
+ bool NX_AF_LOCK_COM;
+ bool NX_AF_FLUID_DISABLE_COLLISION;
+ bool NX_AF_CONTACT_MODIFICATION;
+ bool NX_AF_FORCE_CONE_FRICTION;
+ bool NX_AF_USER_ACTOR_PAIR_FILTERING;
+};
+struct ActorDescTemplate_Type
+{
+ ActorDescFlags_Type flags;
+ float density;
+ uint16_t actorCollisionGroup;
+ uint16_t dominanceGroup;
+ ContactPairFlag_Type contactReportFlags;
+ uint16_t forceFieldMaterial;
+ uint64_t userData;
+ uint64_t name;
+ uint64_t compartment;
+};
+
+struct ParametersStruct
+{
+
+ NvParameterized::DummyStringStruct comments;
+ uint32_t depthCount;
+ uint32_t originalDepthCount;
+ physx::PxBounds3 bounds;
+ BehaviorGroup_Type defaultBehaviorGroup;
+ BehaviorGroup_DynamicArray1D_Type behaviorGroups;
+ int8_t RTFractureBehaviorGroup;
+ Chunk_DynamicArray1D_Type chunks;
+ REF_DynamicArray1D_Type chunkConvexHulls;
+ U32_DynamicArray1D_Type chunkConvexHullStartIndices;
+ DestructibleParameters_Type destructibleParameters;
+ DestructibleDepthParameters_DynamicArray1D_Type depthParameters;
+ NvParameterized::DummyStringStruct crumbleEmitterName;
+ NvParameterized::DummyStringStruct dustEmitterName;
+ NvParameterized::Interface* collisionData;
+ NvParameterized::Interface* renderMeshAsset;
+ uint32_t initialDestructibleActorAllowanceForInstancing;
+ InstanceInfo_DynamicArray1D_Type chunkInstanceInfo;
+ STRING_DynamicArray1D_Type staticMaterialNames;
+ float neighborPadding;
+ REF_DynamicArray1D_Type overlapsAtDepth;
+ U32_DynamicArray1D_Type firstChunkAtDepth;
+ uint32_t supportDepth;
+ bool formExtendedStructures;
+ bool useAssetDefinedSupport;
+ bool useWorldSupport;
+ MAT44_DynamicArray1D_Type actorTransforms;
+ REF_DynamicArray1D_Type scatterMeshAssets;
+ U8_DynamicArray1D_Type scatterMeshIndices;
+ MAT44_DynamicArray1D_Type scatterMeshTransforms;
+
+};
+
+static const uint32_t checksum[] = { 0xb0082230, 0x839469d7, 0xd24a9c81, 0xc8df3469, };
+
+} // namespace DestructibleAssetParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleAssetParameters : public NvParameterized::NvParameters, public DestructibleAssetParametersNS::ParametersStruct
+{
+public:
+ DestructibleAssetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleAssetParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleAssetParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)26;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleAssetParametersNS::checksum);
+ return DestructibleAssetParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleAssetParametersNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleAssetParameters* tmpThis = const_cast<DestructibleAssetParameters*>(this);
+ return *(static_cast<DestructibleAssetParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleAssetParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleAssetParametersNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleAssetParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleAssetParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleAssetParameters), DestructibleAssetParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleAssetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleAssetParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleAssetParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleAssetParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleAssetParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleAssetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleAssetParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleAssetParameters here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleAssetParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleAssetParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleAssetParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleAssetParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleAssetParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleDebugRenderParams.h b/APEX_1.4/module/destructible/include/autogen/DestructibleDebugRenderParams.h
new file mode 100644
index 00000000..be004876
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleDebugRenderParams.h
@@ -0,0 +1,238 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleDebugRenderParams_h
+#define HEADER_DestructibleDebugRenderParams_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleDebugRenderParamsNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ bool VISUALIZE_DESTRUCTIBLE_ACTOR;
+ float VISUALIZE_DESTRUCTIBLE_BOUNDS;
+ float VISUALIZE_DESTRUCTIBLE_SUPPORT;
+ bool VISUALIZE_DESTRUCTIBLE_ACTOR_POSE;
+ float THRESHOLD_DISTANCE_DESTRUCTIBLE_ACTOR_POSE;
+ bool VISUALIZE_DESTRUCTIBLE_ACTOR_NAME;
+ float THRESHOLD_DISTANCE_DESTRUCTIBLE_ACTOR_NAME;
+ bool VISUALIZE_DESTRUCTIBLE_FRAGMENT_POSE;
+ float THRESHOLD_DISTANCE_DESTRUCTIBLE_FRAGMENT_POSE;
+
+};
+
+static const uint32_t checksum[] = { 0xf9b70cc9, 0xc8a5ed52, 0x51f40e6a, 0x14b18d85, };
+
+} // namespace DestructibleDebugRenderParamsNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleDebugRenderParams : public NvParameterized::NvParameters, public DestructibleDebugRenderParamsNS::ParametersStruct
+{
+public:
+ DestructibleDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleDebugRenderParams();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleDebugRenderParams");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleDebugRenderParamsNS::checksum);
+ return DestructibleDebugRenderParamsNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleDebugRenderParamsNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleDebugRenderParams* tmpThis = const_cast<DestructibleDebugRenderParams*>(this);
+ return *(static_cast<DestructibleDebugRenderParamsNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleDebugRenderParamsNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleDebugRenderParamsNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleDebugRenderParamsFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleDebugRenderParams::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleDebugRenderParams), DestructibleDebugRenderParams::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleDebugRenderParams");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleDebugRenderParams)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleDebugRenderParams)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleDebugRenderParams::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleDebugRenderParams");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleDebugRenderParams here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleDebugRenderParams*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleDebugRenderParams::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleDebugRenderParams::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleDebugRenderParams::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleDebugRenderParams::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructibleModuleParameters.h b/APEX_1.4/module/destructible/include/autogen/DestructibleModuleParameters.h
new file mode 100644
index 00000000..2c4cb1c6
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructibleModuleParameters.h
@@ -0,0 +1,237 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructibleModuleParameters_h
+#define HEADER_DestructibleModuleParameters_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructibleModuleParametersNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ uint32_t maxDynamicChunkIslandCount;
+ bool sortFIFOByBenefit;
+ float validBoundsPadding;
+ float maxChunkSeparationLOD;
+ uint32_t maxActorCreatesPerFrame;
+ uint32_t maxChunkDepthOffset;
+ float massScale;
+ float scaledMassExponent;
+
+};
+
+static const uint32_t checksum[] = { 0xea4f5a53, 0x75a1901c, 0xd7138e07, 0xef8c1364, };
+
+} // namespace DestructibleModuleParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructibleModuleParameters : public NvParameterized::NvParameters, public DestructibleModuleParametersNS::ParametersStruct
+{
+public:
+ DestructibleModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructibleModuleParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructibleModuleParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)3;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructibleModuleParametersNS::checksum);
+ return DestructibleModuleParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructibleModuleParametersNS::ParametersStruct& parameters(void) const
+ {
+ DestructibleModuleParameters* tmpThis = const_cast<DestructibleModuleParameters*>(this);
+ return *(static_cast<DestructibleModuleParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructibleModuleParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructibleModuleParametersNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructibleModuleParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructibleModuleParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructibleModuleParameters), DestructibleModuleParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructibleModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleModuleParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructibleModuleParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructibleModuleParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructibleModuleParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructibleModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructibleModuleParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructibleModuleParameters here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructibleModuleParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructibleModuleParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructibleModuleParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructibleModuleParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructibleModuleParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/DestructiblePreviewParam.h b/APEX_1.4/module/destructible/include/autogen/DestructiblePreviewParam.h
new file mode 100644
index 00000000..c1f32df8
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/DestructiblePreviewParam.h
@@ -0,0 +1,244 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_DestructiblePreviewParam_h
+#define HEADER_DestructiblePreviewParam_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace DestructiblePreviewParamNS
+{
+
+
+struct STRING_DynamicArray1D_Type
+{
+ NvParameterized::DummyStringStruct* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ physx::PxMat44 globalPose;
+ uint32_t chunkDepth;
+ float explodeAmount;
+ bool renderUnexplodedChunksStatically;
+ STRING_DynamicArray1D_Type overrideSkinnedMaterialNames;
+ STRING_DynamicArray1D_Type overrideStaticMaterialNames;
+ uint64_t userData;
+
+};
+
+static const uint32_t checksum[] = { 0x3637da2c, 0x7fa3add1, 0xf223f0ff, 0x3a06c4b3, };
+
+} // namespace DestructiblePreviewParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class DestructiblePreviewParam : public NvParameterized::NvParameters, public DestructiblePreviewParamNS::ParametersStruct
+{
+public:
+ DestructiblePreviewParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~DestructiblePreviewParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("DestructiblePreviewParam");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(DestructiblePreviewParamNS::checksum);
+ return DestructiblePreviewParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const DestructiblePreviewParamNS::ParametersStruct& parameters(void) const
+ {
+ DestructiblePreviewParam* tmpThis = const_cast<DestructiblePreviewParam*>(this);
+ return *(static_cast<DestructiblePreviewParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ DestructiblePreviewParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<DestructiblePreviewParamNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class DestructiblePreviewParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ DestructiblePreviewParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(DestructiblePreviewParam), DestructiblePreviewParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, DestructiblePreviewParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructiblePreviewParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(DestructiblePreviewParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, DestructiblePreviewParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, DestructiblePreviewParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, DestructiblePreviewParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class DestructiblePreviewParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of DestructiblePreviewParam here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (DestructiblePreviewParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (DestructiblePreviewParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (DestructiblePreviewParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (DestructiblePreviewParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (DestructiblePreviewParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStream.h b/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStream.h
new file mode 100644
index 00000000..9cdb5088
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStream.h
@@ -0,0 +1,238 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_MeshCookedCollisionStream_h
+#define HEADER_MeshCookedCollisionStream_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace MeshCookedCollisionStreamNS
+{
+
+
+struct U8_DynamicArray1D_Type
+{
+ uint8_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ U8_DynamicArray1D_Type bytes;
+
+};
+
+static const uint32_t checksum[] = { 0x10ac85d4, 0x690961af, 0x1dfeb2cb, 0x4494e6fa, };
+
+} // namespace MeshCookedCollisionStreamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class MeshCookedCollisionStream : public NvParameterized::NvParameters, public MeshCookedCollisionStreamNS::ParametersStruct
+{
+public:
+ MeshCookedCollisionStream(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~MeshCookedCollisionStream();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("MeshCookedCollisionStream");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(MeshCookedCollisionStreamNS::checksum);
+ return MeshCookedCollisionStreamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const MeshCookedCollisionStreamNS::ParametersStruct& parameters(void) const
+ {
+ MeshCookedCollisionStream* tmpThis = const_cast<MeshCookedCollisionStream*>(this);
+ return *(static_cast<MeshCookedCollisionStreamNS::ParametersStruct*>(tmpThis));
+ }
+
+ MeshCookedCollisionStreamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<MeshCookedCollisionStreamNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class MeshCookedCollisionStreamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ MeshCookedCollisionStream::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(MeshCookedCollisionStream), MeshCookedCollisionStream::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, MeshCookedCollisionStream::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class MeshCookedCollisionStream");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(MeshCookedCollisionStream)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, MeshCookedCollisionStream)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, MeshCookedCollisionStream::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, MeshCookedCollisionStream::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class MeshCookedCollisionStream");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of MeshCookedCollisionStream here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (MeshCookedCollisionStream*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (MeshCookedCollisionStream::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (MeshCookedCollisionStream::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (MeshCookedCollisionStream::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (MeshCookedCollisionStream::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStreamsAtScale.h b/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStreamsAtScale.h
new file mode 100644
index 00000000..3f2565c8
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/MeshCookedCollisionStreamsAtScale.h
@@ -0,0 +1,238 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_MeshCookedCollisionStreamsAtScale_h
+#define HEADER_MeshCookedCollisionStreamsAtScale_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace MeshCookedCollisionStreamsAtScaleNS
+{
+
+
+struct REF_DynamicArray1D_Type
+{
+ NvParameterized::Interface** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ REF_DynamicArray1D_Type meshCookedCollisionStreams;
+
+};
+
+static const uint32_t checksum[] = { 0xf356e0c1, 0xf4812209, 0x4cf28347, 0xc18b1923, };
+
+} // namespace MeshCookedCollisionStreamsAtScaleNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class MeshCookedCollisionStreamsAtScale : public NvParameterized::NvParameters, public MeshCookedCollisionStreamsAtScaleNS::ParametersStruct
+{
+public:
+ MeshCookedCollisionStreamsAtScale(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~MeshCookedCollisionStreamsAtScale();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("MeshCookedCollisionStreamsAtScale");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(MeshCookedCollisionStreamsAtScaleNS::checksum);
+ return MeshCookedCollisionStreamsAtScaleNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const MeshCookedCollisionStreamsAtScaleNS::ParametersStruct& parameters(void) const
+ {
+ MeshCookedCollisionStreamsAtScale* tmpThis = const_cast<MeshCookedCollisionStreamsAtScale*>(this);
+ return *(static_cast<MeshCookedCollisionStreamsAtScaleNS::ParametersStruct*>(tmpThis));
+ }
+
+ MeshCookedCollisionStreamsAtScaleNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<MeshCookedCollisionStreamsAtScaleNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class MeshCookedCollisionStreamsAtScaleFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ MeshCookedCollisionStreamsAtScale::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(MeshCookedCollisionStreamsAtScale), MeshCookedCollisionStreamsAtScale::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, MeshCookedCollisionStreamsAtScale::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class MeshCookedCollisionStreamsAtScale");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(MeshCookedCollisionStreamsAtScale)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, MeshCookedCollisionStreamsAtScale)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, MeshCookedCollisionStreamsAtScale::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, MeshCookedCollisionStreamsAtScale::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class MeshCookedCollisionStreamsAtScale");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of MeshCookedCollisionStreamsAtScale here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (MeshCookedCollisionStreamsAtScale*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (MeshCookedCollisionStreamsAtScale::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (MeshCookedCollisionStreamsAtScale::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (MeshCookedCollisionStreamsAtScale::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (MeshCookedCollisionStreamsAtScale::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/ModuleDestructibleRegistration.h b/APEX_1.4/module/destructible/include/autogen/ModuleDestructibleRegistration.h
new file mode 100644
index 00000000..05c9e353
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/ModuleDestructibleRegistration.h
@@ -0,0 +1,150 @@
+/*
+ * 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_MODULEDESTRUCTIBLEREGISTRATIONH_H
+#define MODULE_MODULEDESTRUCTIBLEREGISTRATIONH_H
+
+#include "PsAllocator.h"
+#include "NvRegistrationsForTraitsBase.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "PxAssert.h"
+#include <stdint.h>
+
+// INCLUDE GENERATED FACTORIES
+#include "DestructibleActorParam.h"
+#include "DestructibleActorChunks.h"
+#include "DestructibleActorState.h"
+#include "SurfaceTraceParameters.h"
+#include "SurfaceTraceSetParameters.h"
+#include "CachedOverlaps.h"
+#include "MeshCookedCollisionStream.h"
+#include "MeshCookedCollisionStreamsAtScale.h"
+#include "DestructibleAssetCollisionDataSet.h"
+#include "DestructibleAssetParameters.h"
+#include "DestructiblePreviewParam.h"
+#include "DestructibleDebugRenderParams.h"
+#include "DestructibleModuleParameters.h"
+
+
+// INCLUDE GENERATED CONVERSION
+
+
+namespace nvidia {
+namespace destructible {
+
+
+class ModuleDestructibleRegistration : public NvParameterized::RegistrationsForTraitsBase
+{
+public:
+ static void invokeRegistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleDestructibleRegistration().registerAll(*parameterizedTraits);
+ }
+ }
+
+ static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleDestructibleRegistration().unregisterAll(*parameterizedTraits);
+ }
+ }
+
+ void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits)
+ {
+ ::NvParameterized::Factory* factoriesToRegister[] = {
+// REGISTER GENERATED FACTORIES
+ new nvidia::destructible::DestructibleActorParamFactory(),
+ new nvidia::destructible::DestructibleActorChunksFactory(),
+ new nvidia::destructible::DestructibleActorStateFactory(),
+ new nvidia::destructible::SurfaceTraceParametersFactory(),
+ new nvidia::destructible::SurfaceTraceSetParametersFactory(),
+ new nvidia::destructible::CachedOverlapsFactory(),
+ new nvidia::destructible::MeshCookedCollisionStreamFactory(),
+ new nvidia::destructible::MeshCookedCollisionStreamsAtScaleFactory(),
+ new nvidia::destructible::DestructibleAssetCollisionDataSetFactory(),
+ new nvidia::destructible::DestructibleAssetParametersFactory(),
+ new nvidia::destructible::DestructiblePreviewParamFactory(),
+ new nvidia::destructible::DestructibleDebugRenderParamsFactory(),
+ new nvidia::destructible::DestructibleModuleParametersFactory(),
+
+ };
+
+ for (size_t i = 0; i < sizeof(factoriesToRegister)/sizeof(factoriesToRegister[0]); ++i)
+ {
+ parameterizedTraits.registerFactory(*factoriesToRegister[i]);
+ }
+ }
+
+ virtual void registerAvailableConverters(NvParameterized::Traits& parameterizedTraits)
+ {
+// REGISTER GENERATED CONVERSION
+PX_UNUSED(parameterizedTraits);
+
+ }
+
+ void unregisterAvailableFactories(NvParameterized::Traits& parameterizedTraits)
+ {
+ struct FactoryDesc
+ {
+ const char* name;
+ uint32_t version;
+ };
+
+ ::NvParameterized::Factory* factoriesToUnregister[] = {
+// UNREGISTER GENERATED FACTORIES
+ new nvidia::destructible::DestructibleActorParamFactory(),
+ new nvidia::destructible::DestructibleActorChunksFactory(),
+ new nvidia::destructible::DestructibleActorStateFactory(),
+ new nvidia::destructible::SurfaceTraceParametersFactory(),
+ new nvidia::destructible::SurfaceTraceSetParametersFactory(),
+ new nvidia::destructible::CachedOverlapsFactory(),
+ new nvidia::destructible::MeshCookedCollisionStreamFactory(),
+ new nvidia::destructible::MeshCookedCollisionStreamsAtScaleFactory(),
+ new nvidia::destructible::DestructibleAssetCollisionDataSetFactory(),
+ new nvidia::destructible::DestructibleAssetParametersFactory(),
+ new nvidia::destructible::DestructiblePreviewParamFactory(),
+ new nvidia::destructible::DestructibleDebugRenderParamsFactory(),
+ new nvidia::destructible::DestructibleModuleParametersFactory(),
+
+ };
+
+ for (size_t i = 0; i < sizeof(factoriesToUnregister)/sizeof(factoriesToUnregister[0]); ++i)
+ {
+ ::NvParameterized::Factory* removedFactory = parameterizedTraits.removeFactory(factoriesToUnregister[i]->getClassName(), factoriesToUnregister[i]->getVersion());
+ if (!removedFactory)
+ {
+ PX_ASSERT_WITH_MESSAGE(0, "Factory can not be removed!");
+ }
+ else
+ {
+ removedFactory->freeParameterDefinitionTable(&parameterizedTraits);
+ delete removedFactory;
+ delete factoriesToUnregister[i];
+ }
+ }
+ }
+
+ virtual void unregisterAvailableConverters(NvParameterized::Traits& parameterizedTraits)
+ {
+// UNREGISTER GENERATED CONVERSION
+PX_UNUSED(parameterizedTraits);
+
+ }
+
+};
+
+
+}
+} //nvidia::destructible
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/SurfaceTraceParameters.h b/APEX_1.4/module/destructible/include/autogen/SurfaceTraceParameters.h
new file mode 100644
index 00000000..82219197
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/SurfaceTraceParameters.h
@@ -0,0 +1,248 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_SurfaceTraceParameters_h
+#define HEADER_SurfaceTraceParameters_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace SurfaceTraceParametersNS
+{
+
+
+struct U8_DynamicArray1D_Type
+{
+ uint8_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ U8_DynamicArray1D_Type submeshIndices;
+ U32_DynamicArray1D_Type vertexIndices;
+ physx::PxVec3 defaultNormal;
+
+};
+
+static const uint32_t checksum[] = { 0x97a690a9, 0x7c950c3a, 0x7e771c34, 0x41bed788, };
+
+} // namespace SurfaceTraceParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class SurfaceTraceParameters : public NvParameterized::NvParameters, public SurfaceTraceParametersNS::ParametersStruct
+{
+public:
+ SurfaceTraceParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~SurfaceTraceParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("SurfaceTraceParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(SurfaceTraceParametersNS::checksum);
+ return SurfaceTraceParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const SurfaceTraceParametersNS::ParametersStruct& parameters(void) const
+ {
+ SurfaceTraceParameters* tmpThis = const_cast<SurfaceTraceParameters*>(this);
+ return *(static_cast<SurfaceTraceParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ SurfaceTraceParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<SurfaceTraceParametersNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class SurfaceTraceParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ SurfaceTraceParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(SurfaceTraceParameters), SurfaceTraceParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, SurfaceTraceParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SurfaceTraceParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(SurfaceTraceParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, SurfaceTraceParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, SurfaceTraceParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, SurfaceTraceParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SurfaceTraceParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of SurfaceTraceParameters here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (SurfaceTraceParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (SurfaceTraceParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (SurfaceTraceParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (SurfaceTraceParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (SurfaceTraceParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/destructible/include/autogen/SurfaceTraceSetParameters.h b/APEX_1.4/module/destructible/include/autogen/SurfaceTraceSetParameters.h
new file mode 100644
index 00000000..3bf77c6d
--- /dev/null
+++ b/APEX_1.4/module/destructible/include/autogen/SurfaceTraceSetParameters.h
@@ -0,0 +1,239 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#ifndef HEADER_SurfaceTraceSetParameters_h
+#define HEADER_SurfaceTraceSetParameters_h
+
+#include "NvParametersTypes.h"
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "NvParameters.h"
+#include "NvTraitsInternal.h"
+#endif
+
+namespace nvidia
+{
+namespace destructible
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace SurfaceTraceSetParametersNS
+{
+
+
+struct REF_DynamicArray1D_Type
+{
+ NvParameterized::Interface** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ REF_DynamicArray1D_Type traces;
+ physx::PxVec3 positionOffset;
+
+};
+
+static const uint32_t checksum[] = { 0x7825b62c, 0x9ed33f77, 0x7851a472, 0xb4319f34, };
+
+} // namespace SurfaceTraceSetParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class SurfaceTraceSetParameters : public NvParameterized::NvParameters, public SurfaceTraceSetParametersNS::ParametersStruct
+{
+public:
+ SurfaceTraceSetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~SurfaceTraceSetParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("SurfaceTraceSetParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)2;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(SurfaceTraceSetParametersNS::checksum);
+ return SurfaceTraceSetParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const SurfaceTraceSetParametersNS::ParametersStruct& parameters(void) const
+ {
+ SurfaceTraceSetParameters* tmpThis = const_cast<SurfaceTraceSetParameters*>(this);
+ return *(static_cast<SurfaceTraceSetParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ SurfaceTraceSetParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<SurfaceTraceSetParametersNS::ParametersStruct*>(this));
+ }
+
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const;
+ virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle);
+
+ void initDefaults(void);
+
+protected:
+
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void);
+ virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const;
+
+
+ virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const;
+
+private:
+
+ void buildTree(void);
+ void initDynamicArrays(void);
+ void initStrings(void);
+ void initReferences(void);
+ void freeDynamicArrays(void);
+ void freeStrings(void);
+ void freeReferences(void);
+
+ static bool mBuiltFlag;
+ static NvParameterized::MutexType mBuiltFlagMutex;
+};
+
+class SurfaceTraceSetParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ SurfaceTraceSetParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(SurfaceTraceSetParameters), SurfaceTraceSetParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, SurfaceTraceSetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SurfaceTraceSetParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(SurfaceTraceSetParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, SurfaceTraceSetParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, SurfaceTraceSetParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, SurfaceTraceSetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SurfaceTraceSetParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of SurfaceTraceSetParameters here
+ // but it may call default constructors of members and spoil the data
+ NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount);
+
+ // Init vtable (everything else is already initialized)
+ *(const char**)bufObj = vptr;
+
+ return (SurfaceTraceSetParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (SurfaceTraceSetParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (SurfaceTraceSetParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (SurfaceTraceSetParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (SurfaceTraceSetParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace destructible
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif