From f617e766b19ad7476bc613dbab4342f6a56cb47e Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sat, 21 Jul 2012 23:08:48 +0200 Subject: [PATCH] - fbx: add "strict" import mode (only accept 2012,2013 files). --- code/FBXDocument.cpp | 11 +++++++++-- code/FBXImportSettings.h | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index d6375a9c4..d29d525a7 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -494,9 +494,9 @@ const Object* LazyObject::Get(bool dieOnError) flags &= ~BEING_CONSTRUCTED; flags |= FAILED_TO_CONSTRUCT; - //if(dieOnError) { + if(dieOnError || doc.Settings().strictMode) { throw; - //} + } // note: the error message is already formatted, so raw logging is ok if(!DefaultLogger::isNullLogger()) { @@ -587,6 +587,13 @@ void Document::ReadHeader() const Scope& shead = *ehead->Compound(); fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0)); + if(Settings().strictMode) { + if(fbxVersion < 7200 || fbxVersion > 7300) { + DOMError("unsupported format version, supported are only FBX 2012 and FBX 2013"\ + " in ASCII format (turn off strict mode to try anyhow) "); + } + } + const Element* const ecreator = shead["Creator"]; if(ecreator) { creator = ParseTokenAsString(GetRequiredToken(*ecreator,0)); diff --git a/code/FBXImportSettings.h b/code/FBXImportSettings.h index dd36af417..794e2183d 100644 --- a/code/FBXImportSettings.h +++ b/code/FBXImportSettings.h @@ -57,7 +57,17 @@ struct ImportSettings , readCameras(true) , readLights(true) , readAnimations(true) + , strictMode(true) {} + + + /** enable strict mode: + * - only accept fbx 2012, 2013 files + * - on the slightest error, give up. + * + * Basically, strict mode means that the fbx file will actually + * be validated. Strict mode is off by default. */ + bool strictMode; /** specifies whether all geometry layers are read and scanned for * usable data channels. The FBX spec indicates that many readers