From 4921114c7d12bf6c66b82282d8fcbb9c005e91b4 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sat, 25 Aug 2012 19:53:46 +0200 Subject: [PATCH] - fbx: better error reporting reading property tables. --- code/FBXAnimation.cpp | 10 +++++++--- code/FBXDocument.cpp | 9 ++++----- code/FBXDocument.h | 7 +++++++ code/FBXDocumentUtil.cpp | 7 +++++-- code/FBXDocumentUtil.h | 3 ++- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/code/FBXAnimation.cpp b/code/FBXAnimation.cpp index 3054373d8..5d3b60458 100644 --- a/code/FBXAnimation.cpp +++ b/code/FBXAnimation.cpp @@ -103,7 +103,7 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons , target() { const Scope& sc = GetRequiredScope(element); - props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc); + props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc,false); { // resolve attached animation curves @@ -179,7 +179,9 @@ AnimationLayer::AnimationLayer(uint64_t id, const Element& element, const std::s : Object(id, element, name) { const Scope& sc = GetRequiredScope(element); - props = GetPropertyTable(doc,"AnimationLayer.FbxAnimLayer",element,sc); + + // note: the props table here bears little importance and is usually absent + props = GetPropertyTable(doc,"AnimationLayer.FbxAnimLayer",element,sc, true); // resolve attached animation nodes const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurveNode"); @@ -219,7 +221,9 @@ AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::s : Object(id, element, name) { const Scope& sc = GetRequiredScope(element); - props = GetPropertyTable(doc,"AnimationStack.FbxAnimStack",element,sc); + + // note: we don't currently use any of these properties so we shouldn't bother if it is missing + props = GetPropertyTable(doc,"AnimationStack.FbxAnimStack",element,sc, true); // resolve attached animation layers const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer"); diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index 88da0e4f4..28e06619f 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -318,14 +318,13 @@ void Document::ReadGlobalSettings() DOMError("no GlobalSettings dictionary found"); } - const Element* Properties70 = (*ehead->Compound())["Properties70"]; - if(!Properties70) { + boost::shared_ptr props = GetPropertyTable(*this, "", *ehead, *ehead->Compound(), true); + + if(!props) { DOMError("GlobalSettings dictionary contains no property table"); } - globals.reset(new FileGlobalSettings(*this, boost::make_shared( - *Properties70,boost::shared_ptr(static_cast(NULL)) - ))); + globals.reset(new FileGlobalSettings(*this, props)); } diff --git a/code/FBXDocument.h b/code/FBXDocument.h index 7fcc3b066..67ef4f94c 100644 --- a/code/FBXDocument.h +++ b/code/FBXDocument.h @@ -915,6 +915,13 @@ public: public: + fbx_simple_property(LocalStart, uint64_t, 0L); + fbx_simple_property(LocalStop, uint64_t, 0L); + fbx_simple_property(ReferenceStart, uint64_t, 0L); + fbx_simple_property(ReferenceStop, uint64_t, 0L); + + + const PropertyTable& Props() const { ai_assert(props.get()); return *props.get(); diff --git a/code/FBXDocumentUtil.cpp b/code/FBXDocumentUtil.cpp index 6c388f62c..5efbcb2b7 100644 --- a/code/FBXDocumentUtil.cpp +++ b/code/FBXDocumentUtil.cpp @@ -99,7 +99,8 @@ void DOMWarning(const std::string& message, const Element* element /*= NULL*/) boost::shared_ptr GetPropertyTable(const Document& doc, const std::string& templateName, const Element &element, - const Scope& sc) + const Scope& sc, + bool no_warn /*= false*/) { const Element* const Properties70 = sc["Properties70"]; boost::shared_ptr templateProps = boost::shared_ptr( @@ -113,7 +114,9 @@ boost::shared_ptr GetPropertyTable(const Document& doc, } if(!Properties70) { - DOMWarning("material property table (Properties70) not found",&element); + if(!no_warn) { + DOMWarning("property table (Properties70) not found",&element); + } if(templateProps) { return templateProps; } diff --git a/code/FBXDocumentUtil.h b/code/FBXDocumentUtil.h index 530bd9b2f..7ff71937c 100644 --- a/code/FBXDocumentUtil.h +++ b/code/FBXDocumentUtil.h @@ -62,7 +62,8 @@ void DOMWarning(const std::string& message, const Element* element = NULL); boost::shared_ptr GetPropertyTable(const Document& doc, const std::string& templateName, const Element &element, - const Scope& sc); + const Scope& sc, + bool no_warn = false); // ------------------------------------------------------------------------------------------------