[osg-users] what should I dirty when I change ColorArray on the fly?

Claudio Benghi claudio.benghi at gmail.com
Mon Oct 14 14:17:49 PDT 2019

Hello All,

I have implemented a colour change visitor along the lines of the class found at:

While debugging I note that the following code is executed, including the colorArrays->dirty(), but the colour in the render is not affected.

Could it depend from the way in which the colorArray is initialliy instantiated? 
Should I mark some state as Dynamic?


void XbimNodeColorVisitor::apply(osg::Geometry &curGeom)
  osg::Vec4Array *colorArrays = dynamic_cast<osg::Vec4Array *>(curGeom.getColorArray());
  if (colorArrays) {
    for (unsigned int i = 0; i < colorArrays->size(); i++) {
      osg::Vec4 *color = &colorArrays->operator [](i);
      color->set(m_color._v[0], m_color._v[1], m_color._v[2], m_color._v[3]);
  else {
    // code never enters this path


Thank you!


Read this topic online here:

More information about the osg-users mailing list