diff options
| author | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
| commit | 1e887d827e65a084a0ad0ba933c61a8330aeee07 (patch) | |
| tree | 1e2aab418dadd37f5dc0aae4d8b00e81d909fd24 /sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h | |
| parent | Removing ArtistTools and CurveEditor projects (diff) | |
| download | blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.tar.xz blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.zip | |
Candidate 1.1 release.
* SampleAssetViewer now unconditionally loads the commandline-defined asset.
* Better error handling in AuthoringTool (stderr and user error handler).
* More consistent commandline switches in AuthoringTool and ApexImporter (--ll, --tx, --px flags).
* NvBlastExtAuthoring
** Mesh cleaner, tries to remove self intersections and open edges in the interior of a mesh.
** Ability to set interior material to existing (external) material, or a new material id.
** Material ID remapping API.
** Rotation of voronoi cells used for fracturing.
* Fixed smoothing groups in FBX exporter code.
* Impulse passing from parent to child chunks fixed.
* Reading unskinned fbx meshes correctly.
* Collision hull generation from fbx meshes fixed.
* Win32/64 PerfTest crash fix.
Diffstat (limited to 'sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h')
| -rw-r--r-- | sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h | 94 |
1 files changed, 87 insertions, 7 deletions
diff --git a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h index b7c81aa..db928f4 100644 --- a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h +++ b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h @@ -44,6 +44,87 @@ class Mesh; class FbxFileReader : public IFbxFileReader { + struct CollisionHullImpl : public Nv::Blast::CollisionHull + { + void release() override + { + delete this; + } + + //copy from existing + CollisionHullImpl(const CollisionHullImpl& other) : CollisionHullImpl() + { + copyFrom(other); + } + + CollisionHullImpl() + { + pointsCount = 0; + indicesCount = 0; + polygonDataCount = 0; + points = nullptr; + indices = nullptr; + polygonData = nullptr; + } + + CollisionHullImpl(CollisionHullImpl&& other) + { + operator=(std::move(other)); + } + + CollisionHullImpl& operator=(const CollisionHullImpl& other) + { + if (&other != this) + { + release(); + copyFrom(other); + } + return *this; + } + + CollisionHullImpl& operator=(CollisionHullImpl&& other) + { + if (&other != this) + { + pointsCount = other.pointsCount; + indicesCount = other.indicesCount; + polygonDataCount = other.polygonDataCount; + points = other.points; + indices = other.indices; + polygonData = other.polygonData; + + other.pointsCount = 0; + other.indicesCount = 0; + other.polygonDataCount = 0; + other.points = nullptr; + other.indices = nullptr; + other.polygonData = nullptr; + } + return *this; + } + + virtual ~CollisionHullImpl() + { + delete[] points; + delete[] indices; + delete[] polygonData; + } + private: + + void copyFrom(const CollisionHullImpl& other) + { + pointsCount = other.pointsCount; + indicesCount = other.indicesCount; + polygonDataCount = other.polygonDataCount; + points = new physx::PxVec3[pointsCount]; + indices = new uint32_t[indicesCount]; + polygonData = new Nv::Blast::CollisionHull::HullPolygon[polygonDataCount]; + memcpy(points, other.points, sizeof(points[0]) * pointsCount); + memcpy(indices, other.indices, sizeof(indices[0]) * indicesCount); + memcpy(polygonData, other.polygonData, sizeof(polygonData[0]) * polygonDataCount); + } + }; + public: FbxFileReader(); ~FbxFileReader() = default; @@ -60,7 +141,7 @@ public: return mVertexPositions.size(); } - virtual uint32_t getIdicesCount() const override + virtual uint32_t getIndicesCount() const override { return mIndices.size(); } @@ -73,7 +154,7 @@ public: /** Retrieve collision geometry if it exist */ - virtual uint32_t getCollision(uint32_t*& hullsOffset, Nv::Blast::CollisionHull** hulls) override; + virtual uint32_t getCollision(uint32_t*& hullsOffset, Nv::Blast::CollisionHull**& hulls) override; virtual uint32_t getBoneInfluences(uint32_t*& out) override; @@ -109,7 +190,7 @@ public: /** Get material name. */ - char* getMaterialName(int32_t id) override; + const char* getMaterialName(int32_t id) override; int32_t getMaterialCount() override; @@ -117,9 +198,10 @@ public: private: uint32_t mMeshCount; + uint32_t mChunkCount; std::vector<uint32_t> mHullsOffset; - std::vector<Nv::Blast::CollisionHull*> mHulls; - std::vector<uint32_t> mVertexToParentBoneMap; + std::vector<CollisionHullImpl> mHulls; + std::vector<uint32_t> mVertexToContainingChunkMap; std::multimap<uint32_t, FbxNode*> mCollisionNodes; std::vector<physx::PxVec3> mVertexPositions; std::vector<physx::PxVec3> mVertexNormals; @@ -128,8 +210,6 @@ private: std::vector<int32_t> mSmoothingGroups; std::vector<int32_t> mMaterialIds; std::vector<std::string> mMaterialNames; - - uint32_t mBoneCount; FbxAMatrix getTransformForNode(FbxNode* node); void getFbxMeshes(FbxDisplayLayer* collisionDisplayLayer, FbxNode* node, std::vector<FbxNode*>& meshNodes); |