[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->setDataVariance(osg::Object::DYNAMIC);
	geometry->setVertexArray(buildVertices(count));
	geometry->setColorArray(buildColors(count), osg::Array::BIND_PER_VERTEX);
	geometry->addPrimitiveSet(buildElements(count));

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;
	geom->dirtyDisplayList();
	color.dirty();

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,
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71295#71295



-------------- 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