On Wed, Sep 17, 2008 at 3:23 AM, Csaba Halász <csaba.hal...@gmail.com> wrote:
>
> I have
> made a sample patch for the emission property. However it only seems
> to work for me and not anybody else. Hopefully somebody can come up
> with a proper fix.
Okay, here is another attempt. Please test and comment.
Also, all the live() and dirty() values could be precalculated. They
are not going to change, are they? But first let's fix the bug,
cosmetics later.
--
Csaba/Jester
Index: simgear/scene/model/SGMaterialAnimation.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/model/SGMaterialAnimation.cxx,v
retrieving revision 1.9
diff -u -r1.9 SGMaterialAnimation.cxx
--- simgear/scene/model/SGMaterialAnimation.cxx 21 Dec 2008 15:01:11 -0000 1.9
+++ simgear/scene/model/SGMaterialAnimation.cxx 13 Jan 2009 03:48:09 -0000
@@ -259,7 +259,8 @@
configNode/*->getChild("shininess")*/, modelRoot),
_transparency("alpha", "alpha-prop",
configNode->getChild("transparency"), modelRoot),
- _texturePathList(texturePathList)
+ _texturePathList(texturePathList),
+ _prevState(false)
{
const SGPropertyNode* node;
@@ -309,22 +310,22 @@
= stateSet->getAttribute(osg::StateAttribute::MATERIAL);
osg::Material* material = dynamic_cast<osg::Material*>(stateAttribute);
if (material) {
- if (_ambient.live())
+ if (_ambient.live() || (!_prevState && _ambient.dirty()))
material->setAmbient(osg::Material::FRONT_AND_BACK,
_ambient.rgbaVec4());
- if (_diffuse.live())
+ if (_diffuse.live() || (!_prevState && _diffuse.dirty()))
material->setDiffuse(osg::Material::FRONT_AND_BACK,
_diffuse.rgbaVec4());
- if (_specular.live())
+ if (_specular.live() || (!_prevState && _specular.dirty()))
material->setSpecular(osg::Material::FRONT_AND_BACK,
_specular.rgbaVec4());
- if (_emission.live())
+ if (_emission.live() || (!_prevState && _emission.dirty()))
material->setEmission(osg::Material::FRONT_AND_BACK,
_emission.rgbaVec4());
- if (_shininess.live())
+ if (_shininess.live() || (!_prevState && _shininess.dirty()))
material->setShininess(osg::Material::FRONT_AND_BACK,
_shininess.getValue());
- if (_transparency.live()) {
+ if (_transparency.live() || (!_prevState && _transparency.dirty())) {
float alpha = _transparency.getValue();
material->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
if (alpha < 1.0f) {
@@ -335,6 +336,9 @@
}
}
}
+ _prevState = true;
+ } else {
+ _prevState = false;
}
traverse(node, nv);
}
@@ -350,6 +354,7 @@
PropSpec _shininess;
PropSpec _transparency;
osgDB::FilePathList _texturePathList;
+ bool _prevState;
};
} // namespace
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel