]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/EffectBuilder.cxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / material / EffectBuilder.cxx
index 34f14ac84aed8f862dd0bc7591121465377e16c2..446659426523bc0c08b9deaebcfdca047c2b7e06 100644 (file)
@@ -2,13 +2,14 @@
 #  include <simgear_config.h>
 #endif
 
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 
-#include <simgear/math/SGMath.hxx>
-
 #include "EffectBuilder.hxx"
 #include "Effect.hxx"
 
+using std::string;
+
 namespace simgear
 {
 
@@ -41,13 +42,29 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
         return getEffectPropertyNode(effect, child);
 }
 
-string getGlobalProperty(const SGPropertyNode* prop)
+string getGlobalProperty(const SGPropertyNode* prop,
+                         const SGReaderWriterOptions* options)
 {
     if (!prop)
         return string();
     const SGPropertyNode* useProp = prop->getChild("use");
     if (!useProp)
         return string();
+    string propName = useProp->getStringValue();
+    SGPropertyNode_ptr propRoot;
+    if (propName[0] == '/') {
+        return propName;
+    } else if ((propRoot = options->getPropertyNode())) {
+        string result = propRoot->getPath();
+        result.append("/");
+        result.append(propName);
+        return result;
+    } else {
+        throw effect::
+            BuilderException("No property root to use with relative name "
+                             + propName);
+    }
+        
     return useProp->getStringValue();
 }
 
@@ -85,4 +102,14 @@ namespace effect
 {
 const char* colorFields[] = {"red", "green", "blue", "alpha"};
 }
+  
+PassAttributeBuilder::~PassAttributeBuilder()
+{
 }
+  
+} // of namespace simgear
+
+
+
+
+