From 46fe57fb8de917e442d281940a7a7d5de334ff8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20de=20l=27Hamaide?= Date: Wed, 12 Nov 2014 22:31:19 +0100 Subject: [PATCH] UniformFactory: fix Rembrandt light --- simgear/scene/material/Effect.cxx | 5 +++-- simgear/scene/material/Effect.hxx | 4 ++++ simgear/scene/material/makeEffect.cxx | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index e36af698..6f36c072 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -105,7 +105,7 @@ private: SGMutex _mutex; - typedef boost::tuple UniformCacheKey; + typedef boost::tuple UniformCacheKey; typedef boost::tuple, SGPropertyChangeListener*> UniformCacheValue; std::map > uniformCache; @@ -145,7 +145,7 @@ ref_ptr UniformFactoryImpl::getUniform( Effect * effect, } } - UniformCacheKey key = boost::make_tuple(name, uniformType, val); + UniformCacheKey key = boost::make_tuple(name, uniformType, val, effect->getName()); ref_ptr uniform = uniformCache[key]; if (uniform.valid()) { @@ -1107,6 +1107,7 @@ InstallAttributeBuilder installUniform("uniform"); // Not sure what to do with "name". At one point I wanted to use it to // order the passes, but I do support render bin and stuff too... +// Clément de l'Hamaide 10/2014: "name" is now used in the UniformCacheKey struct NameBuilder : public PassAttributeBuilder { diff --git a/simgear/scene/material/Effect.hxx b/simgear/scene/material/Effect.hxx index 8ad98307..50ac5fb7 100644 --- a/simgear/scene/material/Effect.hxx +++ b/simgear/scene/material/Effect.hxx @@ -99,6 +99,9 @@ public: { void doUpdate(osg::Node* node, osg::NodeVisitor* nv); }; + + std::string getName(){return _name;} + void setName(std::string name){_name = name;} protected: ~Effect(); // Support for a cache of effects that inherit from this one, so @@ -137,6 +140,7 @@ protected: friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques, const SGReaderWriterOptions* options); bool _isRealized; + std::string _name; }; // Automatic support for boost hash function size_t hash_value(const Effect::Key&); diff --git a/simgear/scene/material/makeEffect.cxx b/simgear/scene/material/makeEffect.cxx index 4abdd4a2..628d7143 100644 --- a/simgear/scene/material/makeEffect.cxx +++ b/simgear/scene/material/makeEffect.cxx @@ -187,6 +187,10 @@ Effect* makeEffect(SGPropertyNode* prop, } } ref_ptr effect; + if(!prop->hasChild("name")){ + setValue(prop->getChild("name", 0, true), "noname"); + } + SGPropertyNode_ptr nameProp = prop->getChild("name"); // Merge with the parent effect, if any SGPropertyNode_ptr inheritProp = prop->getChild("inherits-from"); Effect* parent = 0; @@ -214,6 +218,7 @@ Effect* makeEffect(SGPropertyNode* prop, } if (!effect.valid()) { effect = new Effect; + effect->setName(nameProp->getStringValue()); effect->root = new SGPropertyNode; mergePropertyTrees(effect->root, prop, parent->root); effect->parametersProp = effect->root->getChild("parameters"); @@ -237,6 +242,7 @@ Effect* makeEffect(SGPropertyNode* prop, } } else { effect = new Effect; + effect->setName(nameProp->getStringValue()); effect->root = prop; effect->parametersProp = effect->root->getChild("parameters"); } -- 2.39.5