Merge branch 'master' into ios-build-script

pull/2045/head
Kim Kulling 2018-07-10 11:28:54 +02:00 committed by GitHub
commit c58aef4b4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 19 deletions

View File

@ -143,7 +143,8 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
const char** tokens, const char** tokens,
unsigned int numTokens, unsigned int numTokens,
unsigned int searchBytes /* = 200 */, unsigned int searchBytes /* = 200 */,
bool tokensSol /* false */) bool tokensSol /* false */,
bool noAlphaBeforeTokens /* false */)
{ {
ai_assert( nullptr != tokens ); ai_assert( nullptr != tokens );
ai_assert( 0 != numTokens ); ai_assert( 0 != numTokens );
@ -193,6 +194,11 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
if( !r ) { if( !r ) {
continue; continue;
} }
// We need to make sure that we didn't accidentially identify the end of another token as our token,
// e.g. in a previous version the "gltf " present in some gltf files was detected as "f "
if (noAlphaBeforeTokens && (r != buffer && isalpha(r[-1]))) {
continue;
}
// We got a match, either we don't care where it is, or it happens to // We got a match, either we don't care where it is, or it happens to
// be in the beginning of the file / line // be in the beginning of the file / line
if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') {

View File

@ -100,7 +100,7 @@ bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler ,
} else { } else {
// Check file Header // Check file Header
static const char *pTokens[] = { "mtllib", "usemtl", "v ", "vt ", "vn ", "o ", "g ", "s ", "f " }; static const char *pTokens[] = { "mtllib", "usemtl", "v ", "vt ", "vn ", "o ", "g ", "s ", "f " };
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9 ); return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9, 200, false, true );
} }
} }

View File

@ -164,9 +164,6 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS) #if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
out.push_back( new OptimizeGraphProcess()); out.push_back( new OptimizeGraphProcess());
#endif #endif
#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
out.push_back( new FindDegeneratesProcess());
#endif
#ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS #ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
out.push_back( new ComputeUVMappingProcess()); out.push_back( new ComputeUVMappingProcess());
#endif #endif
@ -179,6 +176,12 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS) #if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS)
out.push_back( new TriangulateProcess()); out.push_back( new TriangulateProcess());
#endif #endif
#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
//find degenerates should run after triangulation (to sort out small
//generated triangles) but before sort by p types (in case there are lines
//and points generated and inserted into a mesh)
out.push_back( new FindDegeneratesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS) #if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS)
out.push_back( new SortByPTypeProcess()); out.push_back( new SortByPTypeProcess());
#endif #endif

View File

@ -487,21 +487,22 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
for(aiFace* f = last_face; f != curOut; ) { for(aiFace* f = last_face; f != curOut; ) {
unsigned int* i = f->mIndices; unsigned int* i = f->mIndices;
// drop dumb 0-area triangles // drop dumb 0-area triangles - deactivated for now:
if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) { //FindDegenerates post processing step can do the same thing
ASSIMP_LOG_DEBUG("Dropping triangle with area 0"); //if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) {
--curOut; // ASSIMP_LOG_DEBUG("Dropping triangle with area 0");
// --curOut;
delete[] f->mIndices; // delete[] f->mIndices;
f->mIndices = NULL; // f->mIndices = nullptr;
for(aiFace* ff = f; ff != curOut; ++ff) { // for(aiFace* ff = f; ff != curOut; ++ff) {
ff->mNumIndices = (ff+1)->mNumIndices; // ff->mNumIndices = (ff+1)->mNumIndices;
ff->mIndices = (ff+1)->mIndices; // ff->mIndices = (ff+1)->mIndices;
(ff+1)->mIndices = NULL; // (ff+1)->mIndices = nullptr;
} // }
continue; // continue;
} //}
i[0] = idx[i[0]]; i[0] = idx[i[0]];
i[1] = idx[i[1]]; i[1] = idx[i[1]];

View File

@ -244,7 +244,8 @@ public: // static utilities
const char** tokens, const char** tokens,
unsigned int numTokens, unsigned int numTokens,
unsigned int searchBytes = 200, unsigned int searchBytes = 200,
bool tokensSol = false); bool tokensSol = false,
bool noAlphaBeforeTokens = false);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Check whether a file has a specific file extension /** @brief Check whether a file has a specific file extension