From ae41ae32119f8c8105d154f1c96326632cd92fd4 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Feb 2019 21:43:45 +0100 Subject: [PATCH] closes https://github.com/assimp/assimp/issues/305': fix viewer --- code/FBXConverter.cpp | 3 +-- code/FBXImporter.cpp | 13 ++++++++----- tools/assimp_view/assimp_view.cpp | 23 ++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index d88a3cacd..1bfc90b6d 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1291,8 +1291,7 @@ namespace Assimp { unsigned int cursor = 0, in_cursor = 0; itf = faces.begin(); - for (MatIndexArray::const_iterator it = mindices.begin(), - end = mindices.end(); it != end; ++it, ++itf) + for (MatIndexArray::const_iterator it = mindices.begin(), end = mindices.end(); it != end; ++it, ++itf) { const unsigned int pcount = *itf; if ((*it) != index) { diff --git a/code/FBXImporter.cpp b/code/FBXImporter.cpp index 72f8eea8e..2cc8bffc2 100644 --- a/code/FBXImporter.cpp +++ b/code/FBXImporter.cpp @@ -60,11 +60,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include namespace Assimp { - template<> const char* LogFunctions::Prefix() - { - static auto prefix = "FBX: "; - return prefix; - } + +template<> +const char* LogFunctions::Prefix() { + static auto prefix = "FBX: "; + return prefix; +} + } using namespace Assimp; @@ -72,6 +74,7 @@ using namespace Assimp::Formatter; using namespace Assimp::FBX; namespace { + static const aiImporterDesc desc = { "Autodesk FBX Importer", "", diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 355287e0d..1bcdce967 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -508,19 +508,28 @@ int CreateAssetData() unsigned int nidx; switch (mesh->mPrimitiveTypes) { case aiPrimitiveType_POINT: - nidx = 1;break; + nidx = 1; + break; case aiPrimitiveType_LINE: - nidx = 2;break; + nidx = 2; + break; case aiPrimitiveType_TRIANGLE: - nidx = 3;break; - default: ai_assert(false); + nidx = 3; + break; + default: + ai_assert(false); + break; }; + unsigned int numIndices = mesh->mNumFaces * 3; + if (0 == numIndices && nidx == 1) { + numIndices = mesh->mNumVertices; + } // check whether we can use 16 bit indices - if (mesh->mNumFaces * 3 >= 65536) { + if (numIndices >= 65536) { // create 32 bit index buffer if(FAILED( g_piDevice->CreateIndexBuffer( 4 * - mesh->mNumFaces * nidx, + numIndices, D3DUSAGE_WRITEONLY | dwUsage, D3DFMT_INDEX32, D3DPOOL_DEFAULT, @@ -546,7 +555,7 @@ int CreateAssetData() else { // create 16 bit index buffer if(FAILED( g_piDevice->CreateIndexBuffer( 2 * - mesh->mNumFaces * nidx, + numIndices, D3DUSAGE_WRITEONLY | dwUsage, D3DFMT_INDEX16, D3DPOOL_DEFAULT,