[osg-users] ViewerBase::frame() method slow after changing the color of a geometry

Gianni Ambrosio g.ambrosio+osg at gmail.com
Fri Jul 21 02:11:44 PDT 2017

Hi All,
I build a huge geometry (27 milion vertices, 9 milion triangles) as follows:

	osg::Geometry* geometry = new osg::Geometry;
	geometry->setColorArray(buildColors(count), osg::Array::BIND_PER_VERTEX);

On mouse event, after getting an intersection with the graphics, I do:

	osg::Geometry* geom = dynamic_cast<osg::Geometry*>(intersection.drawable.get());
	osg::Vec4Array& color = dynamic_cast<osg::Vec4Array&>(*geom->getColorArray());
	color[intersection.indexList[0]] = selectedColor;
	color[intersection.indexList[1]] = selectedColor;
	color[intersection.indexList[2]] = selectedColor;

The problem is that after these lines there is a delay of at least one second before seeing the triangle with the updated color on my 3D viewer.
Debugging OSG code I found that "ViewerBase::frame()" is called twice before seeing the new color. Moreover the first time "frame()" is called "renderingTraversals()" takes a lot.

I will debug the OSG code deeper but is there a way to prevent the delay I see in my application?
You can find the full example in attachment.

Thanks for your help,

Read this topic online here:

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: materials.cpp
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170721/52e20afd/attachment.asc>

More information about the osg-users mailing list