From 07dd50c975f511304d7ab50714c18d4b45f0aee0 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Fri, 22 Apr 2011 17:11:54 +0000 Subject: [PATCH] # fix a critical portability problem in the mini dump writer code (it still depends on the endianess, but no longer on integer size). git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@963 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- tools/assimp_cmd/WriteDumb.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index a7b898c93..d6ddf2e43 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -420,8 +420,13 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh) for (unsigned int a = 0; a < job;++a) { const aiFace& f = mesh->mFaces[processed+a]; - hash = SuperFastHash((const char*)&f.mNumIndices,sizeof(unsigned int),hash); - hash = SuperFastHash((const char*) f.mIndices,f.mNumIndices*sizeof(unsigned int),hash); + uint32_t tmp = f.mNumIndices; + hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); + for (unsigned int i = 0; i < f.mNumIndices; ++i) { + BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff); + tmp = static_cast( f.mIndices[i] ); + hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); + } } len += Write(hash); } @@ -432,12 +437,9 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh) for (unsigned int i = 0; i < mesh->mNumFaces;++i) { const aiFace& f = mesh->mFaces[i]; - if (f.mNumIndices >= (1u<<16)) { - printf("The assbin format doesn't support polygons with more than 65536 vertices"); - return -1; - } - + BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); len += Write(f.mNumIndices); + for (unsigned int a = 0; a < f.mNumIndices;++a) { if (mesh->mNumVertices < (1u<<16)) { len += Write(f.mIndices[a]);