# 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
pull/1/head
aramis_acg 2011-04-22 17:11:54 +00:00
parent ea3372f232
commit 07dd50c975
1 changed files with 9 additions and 7 deletions

View File

@ -420,8 +420,13 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh)
for (unsigned int a = 0; a < job;++a) { for (unsigned int a = 0; a < job;++a) {
const aiFace& f = mesh->mFaces[processed+a]; const aiFace& f = mesh->mFaces[processed+a];
hash = SuperFastHash((const char*)&f.mNumIndices,sizeof(unsigned int),hash); uint32_t tmp = f.mNumIndices;
hash = SuperFastHash((const char*) f.mIndices,f.mNumIndices*sizeof(unsigned int),hash); 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); len += Write<unsigned int>(hash);
} }
@ -432,12 +437,9 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh)
for (unsigned int i = 0; i < mesh->mNumFaces;++i) { for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
const aiFace& f = mesh->mFaces[i]; const aiFace& f = mesh->mFaces[i];
if (f.mNumIndices >= (1u<<16)) { BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
printf("The assbin format doesn't support polygons with more than 65536 vertices");
return -1;
}
len += Write<uint16_t>(f.mNumIndices); len += Write<uint16_t>(f.mNumIndices);
for (unsigned int a = 0; a < f.mNumIndices;++a) { for (unsigned int a = 0; a < f.mNumIndices;++a) {
if (mesh->mNumVertices < (1u<<16)) { if (mesh->mNumVertices < (1u<<16)) {
len += Write<uint16_t>(f.mIndices[a]); len += Write<uint16_t>(f.mIndices[a]);