UniformFactory: fix Rembrandt light
This commit is contained in:
@@ -105,7 +105,7 @@ private:
|
|||||||
|
|
||||||
SGMutex _mutex;
|
SGMutex _mutex;
|
||||||
|
|
||||||
typedef boost::tuple<std::string, Uniform::Type, std::string> UniformCacheKey;
|
typedef boost::tuple<std::string, Uniform::Type, std::string, std::string> UniformCacheKey;
|
||||||
typedef boost::tuple<ref_ptr<Uniform>, SGPropertyChangeListener*> UniformCacheValue;
|
typedef boost::tuple<ref_ptr<Uniform>, SGPropertyChangeListener*> UniformCacheValue;
|
||||||
std::map<UniformCacheKey,ref_ptr<Uniform> > uniformCache;
|
std::map<UniformCacheKey,ref_ptr<Uniform> > uniformCache;
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ ref_ptr<Uniform> 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> uniform = uniformCache[key];
|
ref_ptr<Uniform> uniform = uniformCache[key];
|
||||||
|
|
||||||
if (uniform.valid()) {
|
if (uniform.valid()) {
|
||||||
@@ -1107,6 +1107,7 @@ InstallAttributeBuilder<UniformBuilder> installUniform("uniform");
|
|||||||
|
|
||||||
// Not sure what to do with "name". At one point I wanted to use it to
|
// 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...
|
// 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
|
struct NameBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ public:
|
|||||||
{
|
{
|
||||||
void doUpdate(osg::Node* node, osg::NodeVisitor* nv);
|
void doUpdate(osg::Node* node, osg::NodeVisitor* nv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string getName(){return _name;}
|
||||||
|
void setName(std::string name){_name = name;}
|
||||||
protected:
|
protected:
|
||||||
~Effect();
|
~Effect();
|
||||||
// Support for a cache of effects that inherit from this one, so
|
// Support for a cache of effects that inherit from this one, so
|
||||||
@@ -137,6 +140,7 @@ protected:
|
|||||||
friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
|
friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
|
||||||
const SGReaderWriterOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
bool _isRealized;
|
bool _isRealized;
|
||||||
|
std::string _name;
|
||||||
};
|
};
|
||||||
// Automatic support for boost hash function
|
// Automatic support for boost hash function
|
||||||
size_t hash_value(const Effect::Key&);
|
size_t hash_value(const Effect::Key&);
|
||||||
|
|||||||
@@ -187,6 +187,10 @@ Effect* makeEffect(SGPropertyNode* prop,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref_ptr<Effect> effect;
|
ref_ptr<Effect> 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
|
// Merge with the parent effect, if any
|
||||||
SGPropertyNode_ptr inheritProp = prop->getChild("inherits-from");
|
SGPropertyNode_ptr inheritProp = prop->getChild("inherits-from");
|
||||||
Effect* parent = 0;
|
Effect* parent = 0;
|
||||||
@@ -214,6 +218,7 @@ Effect* makeEffect(SGPropertyNode* prop,
|
|||||||
}
|
}
|
||||||
if (!effect.valid()) {
|
if (!effect.valid()) {
|
||||||
effect = new Effect;
|
effect = new Effect;
|
||||||
|
effect->setName(nameProp->getStringValue());
|
||||||
effect->root = new SGPropertyNode;
|
effect->root = new SGPropertyNode;
|
||||||
mergePropertyTrees(effect->root, prop, parent->root);
|
mergePropertyTrees(effect->root, prop, parent->root);
|
||||||
effect->parametersProp = effect->root->getChild("parameters");
|
effect->parametersProp = effect->root->getChild("parameters");
|
||||||
@@ -237,6 +242,7 @@ Effect* makeEffect(SGPropertyNode* prop,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
effect = new Effect;
|
effect = new Effect;
|
||||||
|
effect->setName(nameProp->getStringValue());
|
||||||
effect->root = prop;
|
effect->root = prop;
|
||||||
effect->parametersProp = effect->root->getChild("parameters");
|
effect->parametersProp = effect->root->getChild("parameters");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user