aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/destructible/include/DestructibleHelpers.h
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/DestructibleHelpers.h
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/DestructibleHelpers.h')
-rw-r--r--APEX_1.4/module/destructible/include/DestructibleHelpers.h79
1 files changed, 79 insertions, 0 deletions
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__