- fbx: add "strict" import mode (only accept 2012,2013 files).

pull/14/head
Alexander Gessler 2012-07-21 23:08:48 +02:00
parent b7456307dd
commit f617e766b1
2 changed files with 19 additions and 2 deletions

View File

@ -494,9 +494,9 @@ const Object* LazyObject::Get(bool dieOnError)
flags &= ~BEING_CONSTRUCTED; flags &= ~BEING_CONSTRUCTED;
flags |= FAILED_TO_CONSTRUCT; flags |= FAILED_TO_CONSTRUCT;
//if(dieOnError) { if(dieOnError || doc.Settings().strictMode) {
throw; throw;
//} }
// note: the error message is already formatted, so raw logging is ok // note: the error message is already formatted, so raw logging is ok
if(!DefaultLogger::isNullLogger()) { if(!DefaultLogger::isNullLogger()) {
@ -587,6 +587,13 @@ void Document::ReadHeader()
const Scope& shead = *ehead->Compound(); const Scope& shead = *ehead->Compound();
fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0)); 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"]; const Element* const ecreator = shead["Creator"];
if(ecreator) { if(ecreator) {
creator = ParseTokenAsString(GetRequiredToken(*ecreator,0)); creator = ParseTokenAsString(GetRequiredToken(*ecreator,0));

View File

@ -57,8 +57,18 @@ struct ImportSettings
, readCameras(true) , readCameras(true)
, readLights(true) , readLights(true)
, readAnimations(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 /** specifies whether all geometry layers are read and scanned for
* usable data channels. The FBX spec indicates that many readers * usable data channels. The FBX spec indicates that many readers
* will only read the first channel and that this is in some way * will only read the first channel and that this is in some way