aboutsummaryrefslogtreecommitdiff
path: root/sdk/extensions/authoring/include
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /sdk/extensions/authoring/include
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'sdk/extensions/authoring/include')
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoring.h119
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h151
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h103
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h276
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h179
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringMeshCleaner.h71
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h179
7 files changed, 658 insertions, 420 deletions
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoring.h b/sdk/extensions/authoring/include/NvBlastExtAuthoring.h
new file mode 100644
index 0000000..ce21c65
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoring.h
@@ -0,0 +1,119 @@
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef NVBLASTAUTHORING_H
+#define NVBLASTAUTHORING_H
+
+#include "NvBlastExtAuthoringTypes.h"
+
+namespace physx
+{
+ class PxCooking;
+ class PxPhysicsInsertionCallback;
+}
+
+namespace Nv
+{
+ namespace Blast
+ {
+ class Mesh;
+ class VoronoiSitesGenerator;
+ class FractureTool;
+ class ConvexMeshBuilder;
+ class BlastBondGenerator;
+ class MeshCleaner;
+ }
+}
+
+/**
+Constructs mesh object from array of triangles.
+User should call release() after usage.
+
+\param[in] positions Array for vertex positions, 3 * verticesCount floats will be read
+\param[in] normals Array for vertex normals, 3 * verticesCount floats will be read
+\param[in] uv Array for vertex uv coordinates, 2 * verticesCount floats will be read
+\param[in] verticesCount Number of vertices in mesh
+\param[in] indices Array of vertex indices. Indices contain vertex index triplets which form a mesh triangle.
+\param[in] indicesCount Indices count (should be equal to numberOfTriangles * 3)
+
+\return pointer to Nv::Blast::Mesh if it was created succefully otherwise return nullptr
+*/
+NVBLAST_API Nv::Blast::Mesh* NvBlastExtAuthoringCreateMesh(const physx::PxVec3* positions, const physx::PxVec3* normals,
+ const physx::PxVec2* uv, uint32_t verticesCount, const uint32_t* indices, uint32_t indicesCount);
+
+/**
+Voronoi sites should not be generated outside of the fractured mesh, so VoronoiSitesGenerator
+should be supplied with fracture mesh.
+\param[in] mesh Fracture mesh
+\param[in] rnd User supplied random value generator.
+\return Pointer to VoronoiSitesGenerator. User's code should release it after usage.
+*/
+NVBLAST_API Nv::Blast::VoronoiSitesGenerator* NvBlastExtAuthoringCreateVoronoiSitesGenerator(Nv::Blast::Mesh* mesh,
+ Nv::Blast::RandomGeneratorBase* rng);
+
+/**
+Create FractureTool object.
+\return Pointer to create FractureTool. User's code should release it after usage.
+*/
+NVBLAST_API Nv::Blast::FractureTool* NvBlastExtAuthoringCreateFractureTool();
+
+/**
+Create BlastBondGenerator
+\return Pointer to created BlastBondGenerator. User's code should release it after usage.
+*/
+NVBLAST_API Nv::Blast::BlastBondGenerator* NvBlastExtAuthoringCreateBondGenerator(physx::PxCooking* cooking,
+ physx::PxPhysicsInsertionCallback* insertionCallback);
+
+/**
+Create ConvexMeshBuilder
+\return Pointer to created ConvexMeshBuilder. User's code should release it after usage.
+*/
+NVBLAST_API Nv::Blast::ConvexMeshBuilder* NvBlastExtAuthoringCreateConvexMeshBuilder(physx::PxCooking* cooking,
+ physx::PxPhysicsInsertionCallback* insertionCallback);
+
+/**
+Performs pending fractures and generates fractured asset, render and collision geometry
+
+\param[in] fTool Fracture tool created by NvBlastExtAuthoringCreateFractureTool
+\param[in] bondGenerator Bond generator created by NvBlastExtAuthoringCreateBondGenerator
+\param[in] collisionBuilder Collision builder created by NvBlastExtAuthoringCreateConvexMeshBuilder
+\param[in] defaultSupportDepth All new chunks will be marked as support if its depth equal to defaultSupportDepth.
+ By default leaves (chunks without children) marked as support.
+\return Authoring result
+*/
+NVBLAST_API Nv::Blast::AuthoringResult* NvBlastExtAuthoringProcessFracture(Nv::Blast::FractureTool& fTool,
+ Nv::Blast::BlastBondGenerator& bondGenerator, Nv::Blast::ConvexMeshBuilder& collisionBuilder, int32_t defaultSupportDepth = -1);
+
+
+/**
+ Creates MeshCleaner object
+ \return pointer to Nv::Blast::Mesh if it was created succefully otherwise return nullptr
+*/
+NVBLAST_API Nv::Blast::MeshCleaner* NvBlastExtAuthoringCreateMeshCleaner();
+
+#endif // ifndef NVBLASTAUTHORING_H
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h
index 68767eb..4f5d0e6 100644
--- a/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h
@@ -1,35 +1,54 @@
-/*
-* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// 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) 2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTEXTAUTHORINGBONDGENERATOR_H
#define NVBLASTEXTAUTHORINGBONDGENERATOR_H
#include "NvBlastExtAuthoringTypes.h"
-#include "NvBlastExtAuthoringFractureTool.h"
-#include "NvBlastTypes.h"
-#include "../cooking/PxCooking.h"
-#include <PxPlane.h>
-#include <NvBlastExtAuthoringCollisionBuilder.h>
+
+namespace physx
+{
+class PxPlane;
+class PxCooking;
+class PxPhysicsInsertionCallback;
+}
+
struct NvBlastBondDesc;
struct NvBlastChunkDesc;
struct NvBlastBond;
-using namespace physx;
-
-
namespace Nv
{
namespace Blast
{
// Forward declarations
+class FractureTool;
class TriangleProcessor;
struct PlaneChunkIndexer;
@@ -61,73 +80,75 @@ struct PlaneChunkIndexer
class BlastBondGenerator
{
public:
-
- BlastBondGenerator(physx::PxCooking* cooking, physx::PxPhysicsInsertionCallback* insertionCallback) : mPxCooking(cooking), mPxInsertionCallback(insertionCallback){};
+ virtual ~BlastBondGenerator() {}
+
+ /**
+ Release BlastBondGenerator memory
+ */
+ virtual void release() = 0;
/**
This method based on marking triangles during fracture process, so can be used only with internally fractured meshes.
- \param[in] tool FractureTool which contains chunks representation, tool->finalizeFracturing() should be called before.
- \param[in] chunkIsSupport Array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
- \param[out] resultBondDescs Array of created bond descriptors.
- \param[out] resultChunkDescriptors Array of created chunk descriptors.
- \return 0 if success
+ \note User should call NVBLAST_FREE for resultBondDescs when it not needed anymore
+ \param[in] tool FractureTool which contains chunks representation, tool->finalizeFracturing() should be called before.
+ \param[in] chunkIsSupport Pointer to array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
+ \param[out] resultBondDescs Pointer to array of created bond descriptors.
+ \param[out] resultChunkDescriptors Pointer to array of created chunk descriptors.
+ \return Number of created bonds
*/
- int32_t buildDescFromInternalFracture(FractureTool* tool, const std::vector<bool>& chunkIsSupport, std::vector<NvBlastBondDesc>& resultBondDescs, std::vector<NvBlastChunkDesc>& resultChunkDescriptors);
+ virtual int32_t buildDescFromInternalFracture(FractureTool* tool, const bool* chunkIsSupport,
+ NvBlastBondDesc*& resultBondDescs, NvBlastChunkDesc*& resultChunkDescriptors) = 0;
/**
Creates bond description between two meshes
- \param[in] meshA Array of triangles of mesh A.
- \param[in] meshB Array of triangles of mesh B.
- \param[out] resultBond Result bond description.
- \param[in] conf Bond creation mode.
- \return 0 if success
+ \param[in] meshACount Number of triangles in mesh A
+ \param[in] meshA Pointer to array of triangles of mesh A.
+ \param[in] meshBCount Number of triangles in mesh B
+ \param[in] meshB Pointer to array of triangles of mesh B.
+ \param[out] resultBond Result bond description.
+ \param[in] conf Bond creation mode.
+ \return 0 if success
*/
- int32_t createBondBetweenMeshes(const std::vector<Triangle>& meshA, const std::vector<Triangle>& meshB, NvBlastBond& resultBond, BondGenerationConfig conf = BondGenerationConfig());
+ virtual int32_t createBondBetweenMeshes(uint32_t meshACount, const Triangle* meshA, uint32_t meshBCount, const Triangle* meshB,
+ NvBlastBond& resultBond, BondGenerationConfig conf = BondGenerationConfig()) = 0;
/**
Creates bond description between number of meshes
- \param[in] geometry Array of arrays of triangles for each chunk.
- \param[out] resultBond Array of result bonds.
- \param[in] overlaps Array of pairs - indexes of chunks, for which bond should be created.
- \param[in] cfg Bond creation mode.
- \return 0 if success
+ \note User should call NVBLAST_FREE for resultBondDescs when it not needed anymore
+ \param[in] meshCount Number of meshes
+ \param[in] geometryOffset Pointer to array of triangle offsets for each mesh.
+ Containts meshCount + 1 element, last one is total number of triangles in geometry
+ \param[in] geometry Pointer to array of triangles.
+ Triangles from geometryOffset[i] to geometryOffset[i+1] correspond to i-th mesh.
+ \param[in] overlapsCount Number of overlaps
+ \param[in] overlaps Pointer to array of pairs - indexes of chunks, for which bond should be created.
+ \param[out] resultBond Pointer to array of result bonds.
+ \param[in] cfg Bond creation mode.
+ \return Number of created bonds
*/
- int32_t createBondBetweenMeshes(const std::vector<std::vector<Triangle> >& geometry, std::vector<NvBlastBondDesc>& resultBond, const std::vector<std::pair<uint32_t, uint32_t> >& overlaps, BondGenerationConfig cfg);
+ virtual int32_t createBondBetweenMeshes(uint32_t meshCount, const uint32_t* geometryOffset, const Triangle* geometry,
+ uint32_t overlapsCount, const uint32_t* overlapsA, const uint32_t* overlapsB,
+ NvBlastBondDesc*& resultBond, BondGenerationConfig cfg) = 0;
/**
Creates bond description for prefractured meshes, when there is no info about which chunks should be connected with bond.
- \param[in] geometry Array of arrays of triangles for each chunk.
- \param[in] chunkIsSupport Array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
- \param[out] resultBondDescs Array of result bonds.
- \param[in] conf Bond creation mode.
- \return 0 if success
+ \note User should call NVBLAST_FREE for resultBondDescs when it not needed anymore
+ \param[in] meshCount Number of meshes
+ \param[in] geometryOffset Pointer to array of triangle offsets for each mesh.
+ Containts meshCount + 1 element, last one is total number of triangles in geometry
+ \param[in] geometry Pointer to array of triangles.
+ Triangles from geometryOffset[i] to geometryOffset[i+1] correspond to i-th mesh.
+ \param[in] chunkIsSupport Pointer to array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
+ \param[out] resultBondDescs Pointer to array of result bonds.
+ \param[in] conf Bond creation mode.
+ \return Number of created bonds
*/
- int32_t bondsFromPrefractured(const std::vector<std::vector<Triangle>>& geometry, const std::vector<bool>& chunkIsSupport, std::vector<NvBlastBondDesc>& resultBondDescs, BondGenerationConfig conf = BondGenerationConfig());
+ virtual int32_t bondsFromPrefractured(uint32_t meshCount, const uint32_t* geometryOffset, const Triangle* geometry,
+ const bool*& chunkIsSupport, NvBlastBondDesc*& resultBondDescs,
+ BondGenerationConfig conf = BondGenerationConfig()) = 0;
-private:
- float processWithMidplanes(TriangleProcessor* trProcessor, const std::vector<physx::PxVec3>& chunk1Points, const std::vector<physx::PxVec3>& chunk2Points,
- const std::vector<physx::PxVec3>& hull1p,const std::vector<physx::PxVec3>& hull2p, physx::PxVec3& normal, physx::PxVec3& centroid);
-
- int32_t createFullBondListAveraged(const std::vector<std::vector<Triangle>>& chunksGeometry, const std::vector<bool>& supportFlags, std::vector<NvBlastBondDesc>& mResultBondDescs, BondGenerationConfig conf);
- int32_t createFullBondListExact(const std::vector<std::vector<Triangle>>& chunksGeometry, const std::vector<bool>& supportFlags, std::vector<NvBlastBondDesc>& mResultBondDescs, BondGenerationConfig conf);
- int32_t createFullBondListExactInternal(const std::vector<std::vector<Triangle>>& chunksGeometry, std::vector < PlaneChunkIndexer >& planeTriangleMapping , std::vector<NvBlastBondDesc>& mResultBondDescs);
- int32_t createBondForcedInternal(const std::vector<PxVec3>& hull0, const std::vector<PxVec3>& hull1,const CollisionHull& cHull0, const CollisionHull& cHull1,PxBounds3 bound0, PxBounds3 bound1, NvBlastBond& resultBond, float overlapping);
-
- void buildGeometryCache(const std::vector<std::vector<Triangle> >& geometry);
- void resetGeometryCache();
-
- physx::PxCooking* mPxCooking;
- physx::PxPhysicsInsertionCallback* mPxInsertionCallback;
-
-
- std::vector<std::vector<Triangle> > mGeometryCache;
-
- std::vector<PlaneChunkIndexer> mPlaneCache;
- std::vector<CollisionHull> mCHullCache;
- std::vector<std::vector<physx::PxVec3> > mHullsPointsCache;
- std::vector<physx::PxBounds3 > mBoundsCache;
};
} // namespace Blast
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h
index b3e143a..1e851bb 100644
--- a/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h
@@ -1,26 +1,42 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTEXTAUTHORINGCOLLISIONBUILDER_H
#define NVBLASTEXTAUTHORINGCOLLISIONBUILDER_H
#include "NvBlastTypes.h"
-#include <vector>
-#include <PxVec3.h>
namespace physx
{
- class PxCooking;
- class PxPhysicsInsertionCallback;
- class PxVec3;
- class PxConvexMesh;
+class PxCooking;
+class PxPhysicsInsertionCallback;
+class PxVec3;
+class PxConvexMesh;
}
@@ -29,32 +45,7 @@ namespace Nv
namespace Blast
{
-/**
- Collision hull geometry format.
-*/
-struct CollisionHull
-{
- /**
- Collision hull polygon format.
- */
- struct HullPolygon
- {
- // Polygon base plane
- float mPlane[4];
- // Number vertices in polygon
- uint16_t mNbVerts;
- // First index in CollisionHull.indices array for this polygon
- uint16_t mIndexBase;
- };
- ///**
-
- CollisionHull(){};
-
- std::vector<physx::PxVec3> points;
- std::vector<uint32_t> indices;
- std::vector<HullPolygon> polygonData;
-};
-
+struct CollisionHull;
/**
ConvexMeshBuilder provides routine to build collision hulls from array of vertices.
@@ -64,35 +55,38 @@ struct CollisionHull
class ConvexMeshBuilder
{
public:
+ virtual ~ConvexMeshBuilder() {}
/**
- Constructor should be provided with PxCoocking and PxPhysicsInsertionCallback objects.
+ Release ConvexMeshBuilder memory
*/
- ConvexMeshBuilder(physx::PxCooking* cooking, physx::PxPhysicsInsertionCallback* insertionCallback) : mInsertionCallback(insertionCallback), mCooking(cooking) {}
+ virtual void release() = 0;
/**
Method creates CollisionHull from provided array of vertices.
+ \param[in] verticesCount Number of vertices
\param[in] vertexData Vertex array of some object, for which collision geometry should be built
\param[out] output Reference on CollisionHull object in which generated geometry should be saved
*/
- void buildCollisionGeometry(const std::vector<physx::PxVec3>& vertexData, CollisionHull& output);
+ virtual CollisionHull* buildCollisionGeometry(uint32_t verticesCount, const physx::PxVec3* vertexData) = 0;
/**
Method creates PxConvexMesh from provided array of vertices.
- \param[in] vertexData Vertex array of some object, for which collision geometry should be built
+ \param[in] verticesCount Number of vertices
+ \param[in] vertexData Vertex array of some object, for which collision geometry should be built
\return pointer to the PxConvexMesh object if it was built successfully, 'nullptr' otherwise.
*/
- physx::PxConvexMesh* buildConvexMesh(std::vector<physx::PxVec3>& vertexData);
+ virtual physx::PxConvexMesh* buildConvexMesh(uint32_t verticesCount, const physx::PxVec3* vertexData) = 0;
/**
Method creates PxConvexMesh from provided ConvexHull geometry
- \param[in] hull ConvexHull geometry
+ \param[in] hull ConvexHull geometry
\return pointer to the PxConvexMesh object if it was built successfully, 'nullptr' otherwise.
*/
- physx::PxConvexMesh* buildConvexMesh(CollisionHull& hull);
+ virtual physx::PxConvexMesh* buildConvexMesh(const CollisionHull& hull) = 0;
/**
@@ -102,18 +96,13 @@ public:
This method trims all intersecting parts of collision geometry.
As a drawback, trimming collision geometry can lead to penetrating render meshes during simulation.
-
- \param[in] in ConvexHull geometry which should be clipped.
- \param[in] chunkDepth Array of depth levels of convex hulls corresponding chunks.
+ \param[in] chunksCount Number of chunks
+ \param[in,out] in ConvexHull geometry which should be clipped.
+ \param[in] chunkDepth Array of depth levels of convex hulls corresponding chunks.
*/
-
- void trimCollisionGeometry(std::vector<CollisionHull>& in, const std::vector<uint32_t>& chunkDepth);
-
+ virtual void trimCollisionGeometry(uint32_t chunksCount, CollisionHull** in, const uint32_t* chunkDepth) = 0;
-private:
- physx::PxPhysicsInsertionCallback* mInsertionCallback;
- physx::PxCooking* mCooking;
};
} // namespace Blast
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h
index 528ffbc..82959ac 100644
--- a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h
@@ -1,19 +1,35 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTAUTHORINGFRACTURETOOL_H
#define NVBLASTAUTHORINGFRACTURETOOL_H
-#include "NvBlastExtAuthoringMesh.h"
-#include "NvBlastTypes.h"
-
+#include "NvBlastExtAuthoringTypes.h"
namespace Nv
{
@@ -21,8 +37,8 @@ namespace Blast
{
class SpatialAccelerator;
-class ChunkPostProcessor;
-
+class Triangulator;
+class Mesh;
/*
Chunk data, chunk with chunkId == 0 is always source mesh.
@@ -38,119 +54,83 @@ struct ChunkInfo
/*
Slicing fracturing configuration
-
-
- default:
- x_slices = 1;
- y_slices = 1;
- z_slices = 1;
-
- offset_variations = 0.f;
- angle_variations = 0.f;
- noiseAmplitude = 0.f;
- noiseFrequency = 1.f;
- noiseOctaveNumber = 1;
- surfaceResolution = 1;
*/
struct SlicingConfiguration
{
/**
Number of slices in each direction
*/
- int32_t x_slices, y_slices, z_slices;
+ int32_t x_slices = 1, y_slices = 1, z_slices = 1;
/**
Offset variation, value in [0, 1]
*/
- float offset_variations;
+ float offset_variations = 0.f;
+
/**
Angle variation, value in [0, 1]
*/
- float angle_variations;
-
+ float angle_variations = 0.f;
/**
Noisy slicing configutaion:
Amplitude of cutting surface noise. If it is 0 - noise is disabled.
*/
- float noiseAmplitude;
+ float noiseAmplitude = 0.f;
+
/**
Frequencey of cutting surface noise.
*/
- float noiseFrequency;
+ float noiseFrequency = 1.f;
+
/**
Octave number in slicing surface noise.
*/
- uint32_t noiseOctaveNumber;
- /**
- Cutting surface resolution.
- */
- int32_t surfaceResolution;
-
+ uint32_t noiseOctaveNumber = 1;
- SlicingConfiguration()
- {
- reset();
- }
/**
- Set default params.
+ Cutting surface resolution.
*/
- void reset()
- {
- x_slices = 1;
- y_slices = 1;
- z_slices = 1;
-
- offset_variations = 0.f;
- angle_variations = 0.f;
- noiseAmplitude = 0.f;
- noiseFrequency = 1.f;
- noiseOctaveNumber = 1;
- surfaceResolution = 1;
- }
-
+ int32_t surfaceResolution = 1;
};
-
/**
Class for voronoi sites generation inside supplied mesh.
*/
class VoronoiSitesGenerator
{
public:
-
- /**
- Voronoi sites should not be generated outside of the fractured mesh, so VoronoiSitesGenerator
- should be supplied with fracture mesh.
- \param[in] mesh Fracture mesh
- \param[in] rnd User supplied random value generator.
- \return
+ virtual ~VoronoiSitesGenerator() {}
+
+ /**
+ Release VoronoiSitesGenerator memory
*/
- VoronoiSitesGenerator(Mesh* mesh, RandomGeneratorBase* rnd);
- ~VoronoiSitesGenerator();
+ virtual void release() = 0;
/**
Set base fracture mesh
*/
- void setBaseMesh(Mesh* m);
+ virtual void setBaseMesh(const Mesh* mesh) = 0;
/**
- Returns reference on vector of generated voronoi sites.
+ Access to generated voronoi sites.
+ \param[out] Pointer to generated voronoi sites
+ \return Count of generated voronoi sites.
*/
- std::vector<physx::PxVec3>& getVoronoiSites();
+ virtual uint32_t getVoronoiSites(const physx::PxVec3*& sites) = 0;
/**
Add site in particular point
\param[in] site Site coordinates
*/
- void addSite(const physx::PxVec3& site);
+ virtual void addSite(const physx::PxVec3& site) = 0;
/**
Uniformly generate sites inside the mesh
\param[in] numberOfSites Number of generated sites
*/
- void uniformlyGenerateSitesInMesh(const uint32_t numberOfSites);
+ virtual void uniformlyGenerateSitesInMesh(uint32_t numberOfSites) = 0;
/**
Generate sites in clustered fashion
@@ -158,7 +138,7 @@ public:
\param[in] sitesPerCluster Number of sites in each cluster
\param[in] clusterRadius Voronoi cells cluster radius
*/
- void clusteredSitesGeneration(const uint32_t numberOfClusters, const uint32_t sitesPerCluster, float clusterRadius);
+ virtual void clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) = 0;
/**
Radial pattern of sites generation
@@ -170,7 +150,7 @@ public:
\param[in] angleOffset Angle offset at each radial step
\param[in] variability Randomness of sites distribution
*/
- void radialPattern(const physx::PxVec3& center, const physx::PxVec3& normal, float radius, int32_t angularSteps, int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f);
+ virtual void radialPattern(const physx::PxVec3& center, const physx::PxVec3& normal, float radius, int32_t angularSteps, int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f) = 0;
/**
Generate sites inside sphere
@@ -178,16 +158,16 @@ public:
\param[in] radius Radius of sphere
\param[in] center Center of sphere
*/
- void generateInSphere(const uint32_t count, const float radius, const physx::PxVec3& center);
+ virtual void generateInSphere(const uint32_t count, const float radius, const physx::PxVec3& center) = 0;
/**
Set stencil mesh. With stencil mesh sites are generated only inside both of fracture and stencil meshes.
\param[in] stencil Stencil mesh.
*/
- void setStencil(Mesh* stencil);
+ virtual void setStencil(const Mesh* stencil) = 0;
/**
Removes stencil mesh
*/
- void clearStencil();
+ virtual void clearStencil() = 0;
/**
Deletes sites inside supplied sphere
@@ -195,18 +175,9 @@ public:
\param[in] center Center of sphere
\param[in] eraserProbability Probability of removing some particular site
*/
- void deleteInSphere(const float radius, const physx::PxVec3& center, const float eraserProbability = 1);
-
-private:
- std::vector<physx::PxVec3> mGeneratedSites;
- Mesh* mMesh;
- Mesh* mStencil;
- RandomGeneratorBase* mRnd;
- SpatialAccelerator* mAccelerator;
+ virtual void deleteInSphere(const float radius, const physx::PxVec3& center, const float eraserProbability = 1) = 0;
};
-
-
/**
FractureTool class provides methods to fracture provided mesh and generate Blast asset data
*/
@@ -214,44 +185,34 @@ class FractureTool
{
public:
+ virtual ~FractureTool() {}
/**
- FractureTool can log asset creation info if logCallback is provided.
+ Release FractureTool memory
*/
- FractureTool(NvBlastLog logCallback = nullptr)
- {
- mPlaneIndexerOffset = 1;
- mChunkIdCounter = 0;
- mRemoveIslands = false;
- mLoggingCallback = logCallback;
- }
-
- ~FractureTool()
- {
- reset();
- }
+ virtual void release() = 0;
/**
Reset FractureTool state.
*/
- void reset();
+ virtual void reset() = 0;
/**
Set input mesh wich will be fractured, FractureTool will be reseted.
*/
- void setSourceMesh(Mesh* mesh);
+ virtual void setSourceMesh(const Mesh* mesh) = 0;
/**
- Get chunk mesh in polygonal representation
+ Get chunk mesh in polygonal representation. User's code should release it after usage.
*/
- Mesh getChunkMesh(int32_t chunkId);
+ virtual Mesh* createChunkMesh(int32_t chunkId) = 0;
/**
Input mesh is scaled and transformed internally to fit unit cube centered in origin.
Method provides offset vector and scale parameter;
*/
- void getTransformation(physx::PxVec3& offset, float& scale);
+ virtual void getTransformation(physx::PxVec3& offset, float& scale) = 0;
/**
@@ -262,7 +223,7 @@ public:
Case replaceChunk == true && chunkId == 0 considered as wrong input parameters
\return If 0, fracturing is successful.
*/
- int32_t voronoiFracturing(uint32_t chunkId, const std::vector<physx::PxVec3>& cellPoints, bool replaceChunk);
+ virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, bool replaceChunk) = 0;
/**
Fractures specified chunk with voronoi method. Cells can be scaled along x,y,z axes.
@@ -274,7 +235,7 @@ public:
Case replaceChunk == true && chunkId == 0 considered as wrong input parameters
\return If 0, fracturing is successful.
*/
- int32_t voronoiFracturing(uint32_t chunkId, const std::vector<physx::PxVec3>& cellPoints, const physx::PxVec3& scale, bool replaceChunk);
+ virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, bool replaceChunk) = 0;
/**
@@ -287,37 +248,20 @@ public:
\return If 0, fracturing is successful.
*/
- int32_t slicing(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd);
+ virtual int32_t slicing(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
/**
Creates resulting fractured mesh geometry from intermediate format
*/
- void finalizeFracturing();
+ virtual void finalizeFracturing() = 0;
- /**
- Get chunk information
- */
- const std::vector<ChunkInfo>& getChunkList();
-
+ virtual uint32_t getChunkCount() const = 0;
/**
- Tesselate interior surfaces
- \param[in] averageEdgeLength - Average length of edge on internal surface.
- */
- void tesselate(float averageEdgeLength);
-
- /**
- Apply noise to interior surfaces. Must be called only after tesselation!
- \param[in] amplitude Amplitude of noise
- \param[in] frequency Frequency of noise
- \param[in] octaves Number of noise octaves
- \param[in] falloff - damping of noise around of external surface
- \param[in] relaxIterations - number of smoothing iterations before applying noise
- \param[in] relaxFactor - amount of smoothing before applying noise.
- \param[in] seed Random seed value
+ Get chunk information
*/
- void applyNoise(float amplitude, float frequency, int32_t octaves, float falloff, int32_t relaxIterations, float relaxFactor, int32_t seed = 0);
+ virtual const ChunkInfo& getChunkInfo(int32_t chunkIndex) = 0;
/**
Get percentage of mesh overlap.
@@ -326,110 +270,78 @@ public:
\param[in] meshB Mesh B
\return mesh overlap percentage
*/
- static float getMeshOverlap(Mesh& meshA, Mesh& meshB);
+ virtual float getMeshOverlap(const Mesh& meshA, const Mesh& meshB) = 0;
/**
Get chunk base mesh
\param[in] chunkIndex Chunk index
\param[out] output Array of triangles to be filled
+ \return number of triangles in base mesh
*/
- void getBaseMesh(int32_t chunkIndex, std::vector<Triangle>& output);
-
- /**
- Get chunk mesh with noise
- \param[in] chunkIndex Chunk index
- \param[out] output Array of triangles to be filled
- */
- void getNoisedMesh(int32_t chunkIndex, std::vector<Triangle>& output);
-
+ virtual uint32_t getBaseMesh(int32_t chunkIndex, Triangle*& output) = 0;
/**
Return index of chunk with specified chunkId
\param[in] chunkId Chunk ID
\return Chunk index in internal buffer, if not exist -1 is returned.
*/
- int32_t getChunkIndex(int32_t chunkId);
+ virtual int32_t getChunkIndex(int32_t chunkId) = 0;
/**
Return id of chunk with specified index.
\param[in] chunkIndex Chunk index
\return Chunk id or -1 if there is no such chunk.
*/
- int32_t getChunkId(int32_t chunkIndex);
+ virtual int32_t getChunkId(int32_t chunkIndex) = 0;
/**
Return depth level of the given chunk
\param[in] chunkId Chunk ID
\return Chunk depth or -1 if there is no such chunk.
*/
- int32_t getChunkDepth(int32_t chunkId);
+ virtual int32_t getChunkDepth(int32_t chunkId) = 0;
/**
Return array of chunks IDs with given depth.
- \param[in] depth Chunk depth
- \return Array of chunk IDs
+ \param[in] depth Chunk depth
+ \param[out] Pointer to array of chunk IDs
+ \return Number of chunks in array
*/
- std::vector<int32_t> getChunksIdAtDepth(uint32_t depth);
+ virtual uint32_t getChunksIdAtDepth(uint32_t depth, int32_t*& chunkIds) = 0;
/**
Get result geometry without noise as vertex and index buffers, where index buffers contain series of triplets
which represent triangles.
\param[out] vertexBuffer Array of vertices to be filled
- \param[out] indexBuffer Array of arrays of indices to be filled
+ \param[out] indexBuffer Array of indices to be filled
+ \param[out] indexBufferOffsets Array of offsets in indexBuffer for each base mesh.
+ Contains getChunkCount() + 1 elements. Last one is indexBuffer size
+ \return Number of vertices in vertexBuffer
*/
- void getBufferedBaseMeshes(std::vector<Vertex>& vertexBuffer, std::vector<std::vector<uint32_t> >& indexBuffer);
-
- /**
- Get result geometry after tesselation and application of noise as vertex and index buffers, where index buffers contain series of triplets
- which represent triangles.
- \param[out] vertexBuffer Array of vertices to be filled
- \param[out] indexBuffer Array of arrays of indices to be filled
- */
- void getBufferedNoiseMeshes(std::vector<Vertex>& vertexBuffer, std::vector<std::vector<uint32_t> >& indexBuffer);
+ virtual uint32_t getBufferedBaseMeshes(Vertex*& vertexBuffer, uint32_t*& indexBuffer, uint32_t*& indexBufferOffsets) = 0;
/**
Set automatic islands removing. May cause instabilities.
\param[in] isRemoveIslands Flag whether remove or not islands.
*/
- void setRemoveIslands(bool isRemoveIslands);
+ virtual void setRemoveIslands(bool isRemoveIslands) = 0;
/**
Try find islands and remove them on some specifical chunk. If chunk has childs, island removing can lead to wrong results! Apply it before further chunk splitting.
\param[in] chunkId Chunk ID which should be checked for islands
\return Number of found islands is returned
*/
- int32_t islandDetectionAndRemoving(int32_t chunkId);
-
-private:
- void eraseChunk(int32_t chunkId);
- bool isAncestorForChunk(int32_t ancestorId, int32_t chunkId);
- void deleteAllChildsOfChunk(int32_t chunkId);
- int32_t slicingNoisy(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd);
+ virtual int32_t islandDetectionAndRemoving(int32_t chunkId) = 0;
-protected:
/**
- Mesh scaled to unite-cube and translated to the origin
+ Check if input mesh contains open edges. Open edges can lead to wrong fracturing results.
+ \return true if mesh contains open edges
*/
- float mScaleFactor;
- physx::PxVec3 mOffset;
-
- /* Chunk mesh wrappers */
- std::vector<ChunkPostProcessor*> mChunkPostprocessors;
-
-
-
- int32_t mPlaneIndexerOffset;
- int32_t mChunkIdCounter;
- std::vector<ChunkInfo> mChunkData;
-
- bool mRemoveIslands;
-
- NvBlastLog mLoggingCallback;
+ virtual bool isMeshContainOpenEdges(const Mesh* input) = 0;
};
} // namespace Blast
} // namespace Nv
-
#endif // ifndef NVBLASTAUTHORINGFRACTURETOOL_H
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h
index 2b1806a..039da52 100644
--- a/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h
@@ -1,19 +1,35 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTAUTHORINGMESH_H
#define NVBLASTAUTHORINGMESH_H
#include "NvBlastExtAuthoringTypes.h"
-#include <vector>
-
namespace Nv
{
@@ -26,147 +42,106 @@ namespace Blast
class Mesh
{
public:
+ virtual ~Mesh() {}
/**
- Constructs mesh object from array of triangles.
- \param[in] position Array of vertex positions
- \param[in] normals Array of vertex normals
- \param[in] uv Array of vertex uv coordinates
- \param[in] verticesCount Vertices count
- \param[in] indices Array of vertex indices. Indices contain vertex index triplets which form a mesh triangle.
- \param[in] indicesCount Indices count (should be equal to numberOfTriangles * 3)
+ Release Mesh memory
*/
- Mesh(physx::PxVec3* position, physx::PxVec3* normals, physx::PxVec2* uv, uint32_t verticesCount, uint32_t* indices, uint32_t indicesCount);
+ virtual void release() = 0;
/**
- Constructs mesh object from array of facets.
- \param[in] vertices Array of vertices
- \param[in] edges Array of edges
- \param[in] facets Array of facets
- \param[in] posCount Vertices count
- \param[in] edgesCount Edges count
- \param[in] facetsCount Facets count
+ Return true if mesh is valid
*/
- Mesh(Vertex* vertices, Edge* edges, Facet* facets, uint32_t posCount, uint32_t edgesCount, uint32_t facetsCount);
+ virtual bool isValid() const = 0;
- ~Mesh();
+ /**
+ Return writable pointer on vertices array
+ */
+ virtual Vertex* getVerticesWritable() = 0;
/**
- Return true if mesh is valid
+ Return pointer on vertices array
+ */
+ virtual const Vertex* getVertices() const = 0;
+
+
+ /**
+ Return writable pointer on edges array
*/
- bool isValid();
+ virtual Edge* getEdgesWritable() = 0;
/**
- Return pointer on vertices array
+ Return pointer on edges array
*/
- Vertex* getVertices();
+ virtual const Edge* getEdges() const = 0;
/**
- Return pointer on edges array
+ Return writable pointer on facets array
*/
- Edge* getEdges();
+ virtual Facet* getFacetsBufferWritable() = 0;
/**
- Return pointer on facets array
+ Return pointer on facets array
*/
- Facet* getFacetsBuffer();
+ virtual const Facet* getFacetsBuffer() const = 0;
/**
+ Return writable pointer on specified facet
+ */
+ virtual Facet* getFacetWritable(int32_t facet) = 0;
+ /**
Return pointer on specified facet
*/
- Facet* getFacet(int32_t facet);
+ virtual const Facet* getFacet(int32_t facet) const = 0;
/**
Return edges count
*/
- uint32_t getEdgesCount();
+ virtual uint32_t getEdgesCount() const = 0;
/**
Return vertices count
*/
- uint32_t getVerticesCount();
+ virtual uint32_t getVerticesCount() const = 0;
/**
Return facet count
*/
- uint32_t getFacetCount();
+ virtual uint32_t getFacetCount() const = 0;
/**
Return reference on mesh bounding box.
*/
- physx::PxBounds3& getBoundingBox();
+ virtual const physx::PxBounds3& getBoundingBox() const = 0;
+
+ /**
+ Return writable reference on mesh bounding box.
+ */
+ virtual physx::PxBounds3& getBoundingBoxWritable() = 0;
+
+
+ /**
+ Set per-facet material id.
+ */
+ virtual void setMaterialId(int32_t* materialIds) = 0;
+
+ /**
+ Set per-facet smoothing group.
+ */
+ virtual void setSmoothingGroup(int32_t* smoothingGroup) = 0;
/**
Recalculate bounding box
*/
- void recalculateBoundingBox();
+ virtual void recalculateBoundingBox() = 0;
/**
Compute mesh volume. Can be used only for triangulated meshes.
Return mesh volume. If mesh is not triangulated return 0.
*/
- float getMeshVolume();
-
-private:
- std::vector<Vertex> mVertices;
- std::vector<Edge> mEdges;
- std::vector<Facet> mFacets;
- physx::PxBounds3 mBounds;
+ virtual float getMeshVolume() = 0;
};
-
-/**
- Helper functions
-*/
-
-/**
- Set cutting box at some particular position.
- \param[in] point Cutting face center
- \param[in] normal Cutting face normal
- \param[in] mesh Cutting box mesh
- \param[in] size Cutting box size
- \param[in] id Cutting box ID
-*/
-void setCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, Mesh* mesh, float size, int32_t id);
-/**
- Create cutting box at some particular position.
- \param[in] point Cutting face center
- \param[in] normal Cutting face normal
- \param[in] size Cutting box size
- \param[in] id Cutting box ID
-*/
-Mesh* getCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, float size, int32_t id);
-
-/**
- Create box at some particular position.
- \param[in] point Cutting face center
- \param[in] size Cutting box size
-*/
-Mesh* getBigBox(const physx::PxVec3& point, float size);
-
-/**
- Create slicing box with noisy cutting surface.
- \param[in] point Cutting face center
- \param[in] normal Cutting face normal
- \param[in] size Cutting box size
- \param[in] jaggedPlaneSize Noisy surface size
- \param[in] resolution Noisy surface resolution
- \param[in] id Cutting box ID
- \param[in] amplitude Noise amplitude
- \param[in] frequency Noise frequency
- \param[in] octaves Noise octaves
- \param[in] seed Random generator seed, used for noise generation.
-*/
-Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed);
-
-
-/**
- Inverses normals of cutting box and sets indices.
- \param[in] mesh Cutting box mesh
- \param[in] id Cutting box ID
-*/
-void inverseNormalAndSetIndices(Mesh* mesh, int32_t id);
-
} // namespace Blast
} // namespace Nv
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringMeshCleaner.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringMeshCleaner.h
new file mode 100644
index 0000000..b352e80
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringMeshCleaner.h
@@ -0,0 +1,71 @@
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef NVBLASTEXTAUTHORINGMESHCLEANER_H
+#define NVBLASTEXTAUTHORINGMESHCLEANER_H
+
+#include "NvBlastExtAuthoringTypes.h"
+
+/**
+ FractureTool has requirements to input meshes to fracture them successfully:
+ 1) Mesh should be closed (watertight)
+ 2) There should not be self-intersections and open-edges.
+*/
+
+/**
+ Mesh cleaner input is closed mesh with self-intersections and open-edges (only in the interior).
+ It tries to track outer hull to make input mesh solid and meet requierements of FractureTool. If mesh contained some internal cavities they will be removed.
+*/
+
+namespace Nv
+{
+namespace Blast
+{
+
+class Mesh;
+
+class MeshCleaner
+{
+public:
+ virtual ~MeshCleaner() {}
+
+ /**
+ Tries to remove self intersections and open edges in interior of mesh.
+ \param[in] mesh Mesh to be cleaned.
+ \return Cleaned mesh or nullptr if failed.
+ */
+ virtual Mesh* cleanMesh(const Mesh* mesh) = 0;
+
+ virtual void release() = 0;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+#endif // ifndef NVBLASTEXTAUTHORINGMESHCLEANER_H \ No newline at end of file
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h
index de28866..13865f7 100644
--- a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// 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) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTAUTHORINGTYPES_H
#define NVBLASTAUTHORINGTYPES_H
@@ -14,7 +32,6 @@
#include <PxVec3.h>
#include <PxVec2.h>
#include <PxBounds3.h>
-#include <algorithm>
#include "NvBlastTypes.h"
#define NOT_VALID_VERTEX INT32_MAX
@@ -51,6 +68,13 @@ struct Vertex
physx::PxVec2 uv[1]; // UV-coordinates array, currently supported only one UV coordinate.
};
+
+// Interior material ID
+#define MATERIAL_INTERIOR 1000
+#define SMOOTHING_GROUP_INTERIOR 1000
+
+
+
/**
Mesh triangle representation
*/
@@ -59,7 +83,9 @@ struct Triangle
Triangle() {};
Triangle(Vertex a, Vertex b, Vertex c) : a(a), b(b), c(c) {};
Vertex a, b, c;
- int32_t userInfo;
+ int32_t userData;
+ int32_t materialId;
+ int32_t smoothingGroup; // NOT SUPPORTED ATM.
physx::PxVec3 getNormal()
{
return ((b.p - a.p).cross(c.p - a.p));
@@ -91,10 +117,28 @@ struct TriangleIndexed
return (a == ea || a == eb || a == ec) && (b == ea || b == eb || b == ec);
}
+ Triangle convertToTriangle(Vertex* vertices)
+ {
+ Triangle tr;
+ tr.a = vertices[ea];
+ tr.b = vertices[eb];
+ tr.c = vertices[ec];
+
+ tr.userData = userData;
+ tr.materialId = materialId;
+ tr.smoothingGroup = smoothingGroup;
+ return tr;
+ }
+
uint32_t ea, eb, ec;
- int32_t userInfo;
+ int32_t materialId;
+ int32_t smoothingGroup;
+ int32_t userData;
};
+
+
+
/**
Mesh facet representation
*/
@@ -103,11 +147,14 @@ struct Facet
int32_t firstEdgeNumber;
uint32_t edgesCount;
int32_t userData;
- Facet(int32_t fEdge = 0, uint32_t eCount = 0, int32_t userData = 0) : firstEdgeNumber(fEdge), edgesCount(eCount), userData(userData) {}
+ int32_t materialId;
+ int32_t smoothingGroup;
+
+ Facet(int32_t fEdge = 0, uint32_t eCount = 0, int32_t materialId = 0, int32_t userData = 0, int32_t smoothingGroup = 0) : firstEdgeNumber(fEdge), edgesCount(eCount), materialId(materialId), userData(userData), smoothingGroup(smoothingGroup) {}
};
/**
-Abstract base class for user-defined random value generator.
+ Abstract base class for user-defined random value generator.
*/
class RandomGeneratorBase
{
@@ -119,6 +166,110 @@ public:
virtual ~RandomGeneratorBase() {};
};
+/**
+ Collision hull geometry format.
+*/
+struct CollisionHull
+{
+ /**
+ Collision hull polygon format.
+ */
+ struct HullPolygon
+ {
+ // Polygon base plane
+ float mPlane[4];
+ // Number vertices in polygon
+ uint16_t mNbVerts;
+ // First index in CollisionHull.indices array for this polygon
+ uint16_t mIndexBase;
+ };
+ ///**
+
+ uint32_t pointsCount;
+ uint32_t indicesCount;
+ uint32_t polygonDataCount;
+ physx::PxVec3* points;
+ uint32_t* indices;
+ HullPolygon* polygonData;
+
+ virtual ~CollisionHull() {}
+
+ virtual void release() = 0;
+};
+
+/**
+ Authoring results. Which contains NvBlastAsset, render and collision meshes
+*/
+struct AuthoringResult
+{
+ uint32_t chunkCount; //Number of chunks in Blast asset
+
+ uint32_t bondCount; //Number of bonds in Blast asset
+
+ NvBlastAsset* asset; //Blast asset
+
+ /**
+ assetToFractureChunkIdMap used for getting internal FractureChunkId with FractureTool::getChunkId.
+ FractureChunkId = FractureTool.getChunkId(aResult.assetToFractureChunkIdMap(AssetChunkId);
+ */
+ uint32_t* assetToFractureChunkIdMap;
+
+ /**
+ Offsets for render mesh geometry. Contains chunkCount + 1 element.
+ First triangle for i-th chunk: aResult.geometry[aResult.geometryOffset[i]]
+ aResult.geometryOffset[chunkCount+1] is total number of triangles in geometry
+ */
+ uint32_t* geometryOffset;
+
+ Triangle* geometry; //Raw array of Triangle for all chunks
+
+ NvBlastChunkDesc* chunkDescs; //Array of chunk descriptors. Contains chunkCount elements
+
+ NvBlastBondDesc* bondDescs; //Array of bond descriptors. Contains bondCount elements
+
+ /**
+ Collision hull offsets. Contains chunkCount + 1 element.
+ First collision hull for i-th chunk: aResult.collisionHull[aResult.collisionHullOffset[i]]
+ aResult.collisionHullOffset[chunkCount+1] is total number of collision hulls in collisionHull
+ */
+ uint32_t* collisionHullOffset;
+
+ CollisionHull** collisionHull; //Raw array of pointers to collision hull for all chunks.
+
+ /**
+ Array of chunk physics parameters. Contains chunkCount elements
+ */
+ struct ExtPxChunk* physicsChunks;
+
+ /**
+ Array of phisics subchunks (convex mesh) descriptors.
+ Use collisionHullOffset for accessing elements.
+ */
+ struct ExtPxSubchunk* physicsSubchunks;
+
+ /**
+ Array of material names.
+ */
+ char** materialNames;
+ /**
+ Size of array of material names.
+ */
+
+ uint32_t materialCount;
+
+ //// Member functions ////
+ virtual ~AuthoringResult() {}
+
+ /**
+ Free collision hulls data
+ */
+ virtual void releaseCollisionHulls() = 0;
+
+ /**
+ Free all data and AuthoringResult
+ */
+ virtual void release() = 0;
+};
} // namespace Blast