Sfoglia il codice sorgente

# 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
aramis_acg 14 anni fa
parent
commit
07dd50c975
1 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 9 7
      tools/assimp_cmd/WriteDumb.cpp

+ 9 - 7
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<const char*>(&tmp),sizeof tmp,hash);
+				for (unsigned int i = 0; i < f.mNumIndices; ++i) {
+					BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff);
+					tmp = static_cast<uint32_t>( f.mIndices[i] );
+					hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
+				}
 			}
 			len += Write<unsigned int>(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<uint16_t>(f.mNumIndices);
+
 			for (unsigned int a = 0; a < f.mNumIndices;++a) {
 				if (mesh->mNumVertices < (1u<<16)) {
 					len += Write<uint16_t>(f.mIndices[a]);