diff options
| author | Bryan Galdrikian <[email protected]> | 2018-01-22 14:04:16 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2018-01-22 14:04:16 -0800 |
| commit | 1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d (patch) | |
| tree | 5f8ca75a6b92c60fb5cf3b14282fc4cc1c127eb2 /sdk/extensions/authoring/include | |
| parent | Updating readme.md to show updated UE4 Blast integration branches (diff) | |
| download | blast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.tar.xz blast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.zip | |
Changes for 1.1.2 release candidate
See README.md, docs/release_notes.txt
Diffstat (limited to 'sdk/extensions/authoring/include')
5 files changed, 291 insertions, 21 deletions
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoring.h b/sdk/extensions/authoring/include/NvBlastExtAuthoring.h index dd49677..d3ca85c 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoring.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoring.h @@ -43,6 +43,7 @@ namespace Nv { class Mesh; class VoronoiSitesGenerator; + class CutoutSet; class FractureTool; class ConvexMeshBuilder; class BlastBondGenerator; @@ -71,6 +72,22 @@ NVBLAST_API Nv::Blast::Mesh* NvBlastExtAuthoringCreateMesh(const physx::PxVec3* const physx::PxVec2* uv, uint32_t verticesCount, const uint32_t* indices, uint32_t indicesCount); /** +Constructs mesh object from array of vertices, edges and facets. +User should call release() after usage. + +\param[in] vertices Array for Nv::Blast::Vertex +\param[in] edges Array for Nv::Blast::Edge +\param[in] facets Array for Nv::Blast::Facet +\param[in] verticesCount Number of vertices in mesh +\param[in] edgesCount Number of edges in mesh +\param[in] facetsCount Number of facets in mesh + +\return pointer to Nv::Blast::Mesh if it was created succefully otherwise return nullptr +*/ +NVBLAST_API Nv::Blast::Mesh* NvBlastExtAuthoringCreateMeshFromFacets(const void* vertices, const void* edges, const void* facets, + uint32_t verticesCount, uint32_t edgesCount, uint32_t facetsCount); + +/** Voronoi sites should not be generated outside of the fractured mesh, so VoronoiSitesGenerator should be supplied with fracture mesh. \param[in] mesh Fracture mesh @@ -80,6 +97,27 @@ should be supplied with fracture mesh. NVBLAST_API Nv::Blast::VoronoiSitesGenerator* NvBlastExtAuthoringCreateVoronoiSitesGenerator(Nv::Blast::Mesh* mesh, Nv::Blast::RandomGeneratorBase* rng); +/** Instantiates a blank CutoutSet */ +NVBLAST_API Nv::Blast::CutoutSet* NvBlastExtAuthoringCreateCutoutSet(); + +/** +Builds a cutout set (which must have been initially created by createCutoutSet()). +Uses a bitmap described by pixelBuffer, bufferWidth, and bufferHeight. Each pixel is represented +by one byte in the buffer. + +\param cutoutSet the CutoutSet to build +\param pixelBuffer pointer to be beginning of the pixel buffer +\param bufferWidth the width of the buffer in pixels +\param bufferHeight the height of the buffer in pixels +\param segmentationErrorThreshold Reduce the number of vertices on curve untill segmentation error is smaller then specified. By default set it to 0.001. +\param snapThreshold the pixel distance at which neighboring cutout vertices and segments may be fudged into alignment. By default set it to 1. +\param periodic whether or not to use periodic boundary conditions when creating cutouts from the map +\param expandGaps expand cutout regions to gaps or keep it as is + +*/ +NVBLAST_API void NvBlastExtAuthoringBuildCutoutSet(Nv::Blast::CutoutSet& cutoutSet, const uint8_t* pixelBuffer, + uint32_t bufferWidth, uint32_t bufferHeight, float segmentationErrorThreshold, float snapThreshold, bool periodic, bool expandGaps); + /** Create FractureTool object. \return Pointer to create FractureTool. User's code should release it after usage. @@ -145,6 +183,16 @@ Performs pending fractures and generates fractured asset, render and collision g NVBLAST_API Nv::Blast::AuthoringResult* NvBlastExtAuthoringProcessFracture(Nv::Blast::FractureTool& fTool, Nv::Blast::BlastBondGenerator& bondGenerator, Nv::Blast::ConvexMeshBuilder& collisionBuilder, const Nv::Blast::CollisionParams& collisionParam, int32_t defaultSupportDepth = -1); +/** +Updates graphics mesh only + +\param[in] fTool Fracture tool created by NvBlastExtAuthoringCreateFractureTool +\param[out] ares AuthoringResult object which contains chunks, for which rendermeshes will be updated (e.g. to tweak UVs). +*/ +NVBLAST_API void NvBlastExtUpdateGraphicsMesh(Nv::Blast::FractureTool& fTool, Nv::Blast::AuthoringResult& ares); + + + /** Creates MeshCleaner object @@ -173,7 +221,7 @@ descriptor arrays returned. The user must free this memory after use with NVBLAS \param[in] chunkHulls For each component, an array of CollisionHull* specifying the collision geometry for the chunks in that component. \param[in] componentCount The size of the components and relativeTransforms arrays. \param[out] newBondDescs Descriptors of type NvBlastExtAssetUtilsBondDesc for new bonds between components. - +\param[in] maxSeparation Maximal distance between chunks which can be connected by bond. \return the number of bonds in newBondDescs */ NVBLAST_API uint32_t NvBlastExtAuthoringFindAssetConnectingBonds @@ -185,7 +233,8 @@ NVBLAST_API uint32_t NvBlastExtAuthoringFindAssetConnectingBonds const uint32_t** convexHullOffsets, const Nv::Blast::CollisionHull*** chunkHulls, uint32_t componentCount, - NvBlastExtAssetUtilsBondDesc*& newBondDescs + NvBlastExtAssetUtilsBondDesc*& newBondDescs, + float maxSeparation = 0.0f ); #endif // ifndef NVBLASTAUTHORING_H diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h index 0151ed9..bd25098 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h @@ -56,10 +56,12 @@ struct PlaneChunkIndexer; Bond interface generation configuration EXACT - common surface will be searched AVERAGE - Inerface is approximated by projections or intersecitons with midplane + maxSeparation - for AVERAGE mode. Maximum distance between chunks and midplane used in decision whether create bond or chunks are too far from each other. */ struct BondGenerationConfig { enum BondGenMode { EXACT, AVERAGE }; + float maxSeparation; BondGenMode bondMode; }; @@ -164,7 +166,7 @@ public: \return Number of created bonds */ virtual int32_t bondsFromPrefractured(uint32_t meshCount, const uint32_t* convexHullOffset, const CollisionHull** chunkHulls, - const bool* chunkIsSupport, const uint32_t* meshGroups, NvBlastBondDesc*& resultBondDescs) = 0; + const bool* chunkIsSupport, const uint32_t* meshGroups, NvBlastBondDesc*& resultBondDescs, float maxSeparation) = 0; }; } // namespace Blast diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringCutout.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringCutout.h new file mode 100644 index 0000000..7a26393 --- /dev/null +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringCutout.h @@ -0,0 +1,106 @@ +// 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 NVBLASTAUTHORINGCUTOUT_H +#define NVBLASTAUTHORINGCUTOUT_H + +#include "NvBlastExtAuthoringTypes.h" + + +namespace Nv +{ +namespace Blast +{ + +/** +Interface to a "cutout set," used with chippable fracturing. A cutout set is created from a bitmap. The +result is turned into cutouts which are applied to the mesh. For example, a bitmap which looks like a brick +pattern will generate a cutout for each "brick," forming the cutout set. + +Each cutout is a 2D entity, meant to be projected onto various faces of a mesh. They are represented +by a set of 2D vertices, which form closed loops. More than one loop may represent a single cutout, if +the loops are forced to be convex. Otherwise, a cutout is represented by a single loop. +*/ +class CutoutSet +{ +public: + /** Returns the number of cutouts in the set. */ + virtual uint32_t getCutoutCount() const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the number of vertices in the cutout. + */ + virtual uint32_t getCutoutVertexCount(uint32_t cutoutIndex) const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the number of loops in this cutout. + */ + virtual uint32_t getCutoutLoopCount(uint32_t cutoutIndex) const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the vertex indexed by vertexIndex. (Only the X and Y coordinates are used.) + */ + virtual const physx::PxVec3& getCutoutVertex(uint32_t cutoutIndex, uint32_t vertexIndex) const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the number of vertices in the loop indexed by loopIndex. + */ + virtual uint32_t getCutoutLoopSize(uint32_t coutoutIndex, uint32_t loopIndex) const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the vertex index of the vertex indexed by vertexNum, in the loop + indexed by loopIndex. + */ + virtual uint32_t getCutoutLoopVertexIndex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0; + + /** + Applies to the cutout indexed by cutoutIndex: + Returns the flags of the vertex indexed by vertexNum, in the loop + indexed by loopIndex. + */ + virtual uint32_t getCutoutLoopVertexFlags(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0; + + /** + Whether or not this cutout set is to be tiled. + */ + virtual bool isPeriodic() const = 0; + + /** + The dimensions of the fracture map used to create the cutout set. + */ + virtual const physx::PxVec2& getDimensions() const = 0; + + /** Serialization */ + //virtual void serialize(physx::PxFileBuf& stream) const = 0; + //virtual void deserialize(physx::PxFileBuf& stream) = 0; + + /** Releases all memory and deletes itself. */ + virtual void release() = 0; + +protected: + /** Protected destructor. Use the release() method. */ + virtual ~CutoutSet() {} +}; + +} // namespace Blast +} // namespace Nv + + +#endif // idndef NVBLASTAUTHORINGCUTOUT_H diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h index 2c8eef4..e926005 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h @@ -39,6 +39,7 @@ namespace Blast class SpatialAccelerator; class Triangulator; class Mesh; +class CutoutSet; /* Chunk data, chunk with chunkId == 0 is always source mesh. @@ -49,53 +50,97 @@ struct ChunkInfo int32_t parent; int32_t chunkId; bool isLeaf; + bool isChanged; }; +/* + Noise fracturing configuration for chunks's faces +*/ +struct NoiseConfiguration +{ + /** + Noisy slicing configutaion: + + Amplitude of cutting surface noise. If it is 0 - noise is disabled. + */ + float amplitude = 0.f; + + /** + Frequencey of cutting surface noise. + */ + float frequency = 1.f; + + /** + Octave number in slicing surface noise. + */ + uint32_t octaveNumber = 1; + + /** + Cutting surface resolution. + */ + uint32_t surfaceResolution = 1; +}; /* Slicing fracturing configuration */ struct SlicingConfiguration { - /** + /** Number of slices in each direction */ int32_t x_slices = 1, y_slices = 1, z_slices = 1; - - /** + + /** Offset variation, value in [0, 1] */ float offset_variations = 0.f; - - /** + + /** Angle variation, value in [0, 1] */ float angle_variations = 0.f; + /* + Noise parameters for faces between sliced chunks + */ + NoiseConfiguration noise; +}; + +/** + Cutout fracturing configuration +*/ +struct CutoutConfiguration +{ /** - Noisy slicing configutaion: + Set of grouped convex loop patterns for cutout in normal direction. + Not required for PLANE_ONLY mode + */ + CutoutSet* cutoutSet = nullptr; - Amplitude of cutting surface noise. If it is 0 - noise is disabled. + /** + Transform for initial pattern position and orientation. + By default 2d pattern lies in XY plane (Y is up) the center of pattern is (0, 0) */ - float noiseAmplitude = 0.f; - + physx::PxTransform transform = physx::PxTransform(physx::PxIdentity); + /** - Frequencey of cutting surface noise. + Scale for pattern. Unscaled pattern has size (1, 1). + For negative scale pattern will be placed at the center of chunk and scaled with max distance between points of its AABB */ - float noiseFrequency = 1.f; + physx::PxVec2 scale = physx::PxVec2(-1, -1); /** - Octave number in slicing surface noise. + If relative transform is set - position will be displacement vector from chunk's center. Otherwise from global origin. */ - uint32_t noiseOctaveNumber = 1; + bool isRelativeTransform = true; /** - Cutting surface resolution. + Noise parameters for cutout surface, see NoiseConfiguration. */ - uint32_t surfaceResolution = 1; + NoiseConfiguration noise; }; - /** Class for voronoi sites generation inside supplied mesh. */ @@ -159,11 +204,13 @@ public: \param[in] center Center of sphere */ 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. */ virtual void setStencil(const Mesh* stencil) = 0; + /** Removes stencil mesh */ @@ -269,7 +316,33 @@ public: \return If 0, fracturing is successful. */ - virtual int32_t slicing(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0; + virtual int32_t slicing(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0; + + /** + Cut chunk with plane. + \param[in] chunkId Chunk to fracture + \param[in] normal Plane normal + \param[in] position Point on plane + \param[in] noise Noise configuration for plane-chunk intersection, see NoiseConfiguration. + \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly generated chunks will be at next depth level, source chunk will be parent for them. + Case replaceChunk == true && chunkId == 0 considered as wrong input parameters + \param[in] rnd User supplied random number generator + + \return If 0, fracturing is successful. + */ + virtual int32_t cut(uint32_t chunkId, const physx::PxVec3& normal, const physx::PxVec3& position, const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) = 0; + + /** + Cutout fracture for specified chunk. + \param[in] chunkId Chunk to fracture + \param[in] conf Cutout parameters, see CutoutConfiguration. + \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly generated chunks will be at next depth level, source chunk will be parent for them. + Case replaceChunk == true && chunkId == 0 considered as wrong input parameters + \param[in] rnd User supplied random number generator + + \return If 0, fracturing is successful. + */ + virtual int32_t cutout(uint32_t chunkId, CutoutConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0; /** @@ -277,6 +350,9 @@ public: */ virtual void finalizeFracturing() = 0; + /** + Returns overall number of chunks in fracture. + */ virtual uint32_t getChunkCount() const = 0; /** @@ -302,6 +378,15 @@ public: virtual uint32_t getBaseMesh(int32_t chunkIndex, Triangle*& output) = 0; /** + Update chunk base mesh + \note Doesn't allocates output array, Triangle* output should be preallocated by user + \param[in] chunkIndex Chunk index + \param[out] output Array of triangles to be filled + \return number of triangles in base mesh + */ + virtual uint32_t updateBaseMesh(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. @@ -330,7 +415,6 @@ public: */ 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. @@ -368,7 +452,28 @@ public: */ virtual bool deleteAllChildrenOfChunk(int32_t chunkId) = 0; + /** + Optimize chunk hierarhy for better runtime performance. + It tries to unite chunks to groups of some size in order to transform flat hierarchy (all chunks are children of single root) + to tree like hieracrhy with limited number of children for each chunk. + \param[in] maxAtLevel If number of children of some chunk less then maxAtLevel then it would be considered as already optimized and skipped. + \param[in] maxGroupSize Max number of children for processed chunks. + */ virtual void uniteChunks(uint32_t maxAtLevel, uint32_t maxGroupSize) = 0; + + /** + Rescale interior uv coordinates of given chunk to fit square of given size. + \param[in] side Size of square side + \param[in] chunkId Chunk ID for which UVs should be scaled. + */ + virtual void fitUvToRect(float side, uint32_t chunkId) = 0; + + /** + Rescale interior uv coordinates of all existing chunks to fit square of given size, relative sizes will be preserved. + \param[in] side Size of square side + */ + virtual void fitAllUvToRect(float side) = 0; + }; } // namespace Blast diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h index 512beca..b81ed25 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h @@ -90,6 +90,14 @@ struct Triangle { return ((b.p - a.p).cross(c.p - a.p)); } + inline Vertex& getVertex(uint32_t index) + { + return (&a)[index]; + } + inline const Vertex& getVertex(uint32_t index) const + { + return (&a)[index]; + } }; |