- fbx: better error reporting reading property tables.

pull/14/head
Alexander Gessler 2012-08-25 19:53:46 +02:00
parent c9facf16fa
commit 4921114c7d
5 changed files with 25 additions and 11 deletions

View File

@ -103,7 +103,7 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
, target() , target()
{ {
const Scope& sc = GetRequiredScope(element); const Scope& sc = GetRequiredScope(element);
props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc); props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc,false);
{ {
// resolve attached animation curves // resolve attached animation curves
@ -179,7 +179,9 @@ AnimationLayer::AnimationLayer(uint64_t id, const Element& element, const std::s
: Object(id, element, name) : Object(id, element, name)
{ {
const Scope& sc = GetRequiredScope(element); 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 // resolve attached animation nodes
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurveNode"); const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurveNode");
@ -219,7 +221,9 @@ AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::s
: Object(id, element, name) : Object(id, element, name)
{ {
const Scope& sc = GetRequiredScope(element); 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 // resolve attached animation layers
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer"); const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer");

View File

@ -318,14 +318,13 @@ void Document::ReadGlobalSettings()
DOMError("no GlobalSettings dictionary found"); DOMError("no GlobalSettings dictionary found");
} }
const Element* Properties70 = (*ehead->Compound())["Properties70"]; boost::shared_ptr<const PropertyTable> props = GetPropertyTable(*this, "", *ehead, *ehead->Compound(), true);
if(!Properties70) {
if(!props) {
DOMError("GlobalSettings dictionary contains no property table"); DOMError("GlobalSettings dictionary contains no property table");
} }
globals.reset(new FileGlobalSettings(*this, boost::make_shared<const PropertyTable>( globals.reset(new FileGlobalSettings(*this, props));
*Properties70,boost::shared_ptr<const PropertyTable>(static_cast<const PropertyTable*>(NULL))
)));
} }

View File

@ -915,6 +915,13 @@ public:
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 { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();

View File

@ -99,7 +99,8 @@ void DOMWarning(const std::string& message, const Element* element /*= NULL*/)
boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc, boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
const std::string& templateName, const std::string& templateName,
const Element &element, const Element &element,
const Scope& sc) const Scope& sc,
bool no_warn /*= false*/)
{ {
const Element* const Properties70 = sc["Properties70"]; const Element* const Properties70 = sc["Properties70"];
boost::shared_ptr<const PropertyTable> templateProps = boost::shared_ptr<const PropertyTable>( boost::shared_ptr<const PropertyTable> templateProps = boost::shared_ptr<const PropertyTable>(
@ -113,7 +114,9 @@ boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
} }
if(!Properties70) { if(!Properties70) {
DOMWarning("material property table (Properties70) not found",&element); if(!no_warn) {
DOMWarning("property table (Properties70) not found",&element);
}
if(templateProps) { if(templateProps) {
return templateProps; return templateProps;
} }

View File

@ -62,7 +62,8 @@ void DOMWarning(const std::string& message, const Element* element = NULL);
boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc, boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
const std::string& templateName, const std::string& templateName,
const Element &element, const Element &element,
const Scope& sc); const Scope& sc,
bool no_warn = false);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------