]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/EffectBuilder.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / material / EffectBuilder.hxx
index a464071f717b27712e75679a9dadf4d75e1bd6af..06b8ba9f4ab32b054bb9f45583fb16a3c1333e37 100644 (file)
@@ -31,7 +31,6 @@
 #include <boost/multi_index/member.hpp>
 #include <boost/multi_index/ordered_index.hpp>
 
-#include <simgear/math/SGMath.hxx>
 #include <simgear/props/AtomicChangeListener.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
@@ -58,16 +57,16 @@ class EffectBuilder : public SGReferenced
 {
 public:
     virtual ~EffectBuilder() {}
-    virtual T* build(Effect* effect, const SGPropertyNode*,
+    virtual T* build(Effect* effect, Pass* pass, const SGPropertyNode*,
                      const SGReaderWriterOptions* options) = 0;
-    static T* buildFromType(Effect* effect, const std::string& type,
+    static T* buildFromType(Effect* effect, Pass* pass, const std::string& type,
                             const SGPropertyNode*props,
                             const SGReaderWriterOptions* options)
     {
         BuilderMap& builderMap = getMap();
         typename BuilderMap::iterator iter = builderMap.find(type);
         if (iter != builderMap.end())
-            return iter->second->build(effect, props, options);
+            return iter->second->build(effect, pass, props, options);
         else
             return 0;
     }
@@ -168,7 +167,7 @@ EffectPropertyMap<T>::EffectPropertyMap(const EffectNameValue<T> (&attrs)[N])
 template<typename T>
 struct SimplePropertyMap
 {
-    typedef std::map<string, T> map_type;
+    typedef std::map<std::string, T> map_type;
     map_type _map;
     template<int N>
     SimplePropertyMap(const EffectNameValue<T> (&attrs)[N])
@@ -196,10 +195,10 @@ void findAttr(const effect::EffectPropertyMap<T>& pMap,
 {
     using namespace effect;
     typename EffectPropertyMap<T>::BMap::iterator itr
-        = pMap._map.get<from>().find(name);
+        = pMap._map.template get<from>().find(name);
     if (itr == pMap._map.end()) {
-        throw effect::BuilderException(string("findAttr: could not find attribute ")
-                               string(name));
+        throw effect::BuilderException(std::string("findAttr: could not find attribute ")
+                                       + std::string(name));
     } else {
         result = itr->second;
     }
@@ -234,7 +233,7 @@ const T* findAttr(const effect::EffectPropertyMap<T>& pMap,
 {
     using namespace effect;
     typename EffectPropertyMap<T>::BMap::iterator itr
-        = pMap._map.get<from>().find(name);
+        = pMap._map.template get<from>().find(name);
     if (itr == pMap._map.end())
         return 0;
     else 
@@ -268,8 +267,8 @@ std::string findName(const effect::EffectPropertyMap<T>& pMap, T value)
     using namespace effect;
     std::string result;
     typename EffectPropertyMap<T>::BMap::template index_iterator<to>::type itr
-        = pMap._map.get<to>().find(value);
-    if (itr != pMap._map.get<to>().end())
+        = pMap._map.template get<to>().find(value);
+    if (itr != pMap._map.template get<to>().end())
         result = itr->first;
     return result;
 }
@@ -317,7 +316,7 @@ getVectorProperties(const SGPropertyNode* prop,
     PropertyList useProps = prop->getChildren("use");
     if (useProps.size() == 1) {
         string parentName = useProps[0]->getStringValue();
-        if (parentName.size() == 0 || parentName[0] != '/')
+        if (parentName.empty() || parentName[0] != '/')
             parentName = options->getPropertyNode()->getPath() + "/" + parentName;
         if (parentName[parentName.size() - 1] != '/')
             parentName.append("/");
@@ -332,7 +331,7 @@ getVectorProperties(const SGPropertyNode* prop,
              itr != end;
              ++itr) {
             string childName = (*itr)->getStringValue();
-            if (childName.size() == 0 || childName[0] != '/')
+            if (childName.empty() || childName[0] != '/')
                 result.push_back(parentName + childName);
             else
                 result.push_back(childName);
@@ -374,7 +373,7 @@ public:
 template<typename T>
 struct InstallAttributeBuilder
 {
-    InstallAttributeBuilder(const string& name)
+    InstallAttributeBuilder(const std::string& name)
     {
         PassAttributeBuilder::PassAttrMapSingleton::instance()
             ->passAttrMap.insert(make_pair(name, new T));
@@ -615,10 +614,10 @@ initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
     const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
     if (!valProp)
         return;
-    setDynamicVariance(obj);
     if (valProp->nChildren() == 0) {
         setter(obj, valProp->getValue<OSGParamType>());
     } else {
+        setDynamicVariance(obj);
         std::string propName = getGlobalProperty(valProp, options);
         ScalarChangeListener<OSGParamType, ObjType, F>* listener
             = new ScalarChangeListener<OSGParamType, ObjType, F>(obj, setter,
@@ -668,10 +667,10 @@ initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
     const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
     if (!valProp)
         return;
-    setDynamicVariance(obj);
     if (valProp->nChildren() == 0) { // Has <use>?
         setter(obj, Bridge<OSGParamType>::get(valProp->getValue<sg_type>()));
     } else {
+        setDynamicVariance(obj);
         std::vector<std::string> paramNames
             = getVectorProperties(valProp, options,numComponents, nameItr);
         if (paramNames.empty())