diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index dc177744f..653e8f2b1 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1983,7 +1983,8 @@ void ColladaParser::ReadIndexData( Mesh* pMesh) } // small sanity check - if (primType != Prim_TriFans && primType != Prim_TriStrips) + if (primType != Prim_TriFans && primType != Prim_TriStrips && + primType != Prim_Lines) // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'. ai_assert(actualPrimitives == numPrimitives); // only when we're done reading all
tags (and thus know the final vertex count) can we commit the submesh
@@ -2091,9 +2092,15 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector element.");
- else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
+ if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
+ if (pPrimType == Prim_Lines) {
+ // HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
+ ReportWarning( "Expected different index count in element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
+ pNumPrimitives = (indices.size() / numOffsets) / 2;
+ } else
+ ThrowException( "Expected different index count in element.");
+
+ } else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
ThrowException( "Expected different index count in element.");
// find the data for all sources
@@ -2696,6 +2703,21 @@ AI_WONT_RETURN void ColladaParser::ThrowException( const std::string& pError) co
throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError));
}
+void ColladaParser::ReportWarning(const char* msg,...)
+{
+ ai_assert(NULL != msg);
+
+ va_list args;
+ va_start(args,msg);
+
+ char szBuffer[3000];
+ const int iLen = vsprintf(szBuffer,msg,args);
+ ai_assert(iLen > 0);
+
+ va_end(args);
+ DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
+}
+
// ------------------------------------------------------------------------------------------------
// Skips all data until the end node of the current element
void ColladaParser::SkipElement()
diff --git a/code/ColladaParser.h b/code/ColladaParser.h
index 553f9caf4..327d2d032 100644
--- a/code/ColladaParser.h
+++ b/code/ColladaParser.h
@@ -213,6 +213,7 @@ protected:
protected:
/** Aborts the file reading with an exception */
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
+ void ReportWarning(const char* msg,...);
/** Skips all data until the end node of the current element */
void SkipElement();