2
0
Эх сурвалжийг харах

- fbx: better error reporting reading property tables.

Alexander Gessler 13 жил өмнө
parent
commit
4921114c7d

+ 7 - 3
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<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)
 {
 	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<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer");

+ 4 - 5
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<const PropertyTable> props = GetPropertyTable(*this, "", *ehead, *ehead->Compound(), true);
+
+	if(!props) {
 		DOMError("GlobalSettings dictionary contains no property table");
 	}
 
-	globals.reset(new FileGlobalSettings(*this, boost::make_shared<const PropertyTable>(
-		*Properties70,boost::shared_ptr<const PropertyTable>(static_cast<const PropertyTable*>(NULL))
-	)));
+	globals.reset(new FileGlobalSettings(*this, props));
 }
 
 

+ 7 - 0
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();

+ 5 - 2
code/FBXDocumentUtil.cpp

@@ -99,7 +99,8 @@ void DOMWarning(const std::string& message, const Element* element /*= NULL*/)
 boost::shared_ptr<const PropertyTable> 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<const PropertyTable> templateProps = boost::shared_ptr<const PropertyTable>(
@@ -113,7 +114,9 @@ boost::shared_ptr<const PropertyTable> 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;
 		}

+ 2 - 1
code/FBXDocumentUtil.h

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