I don't know about the double frame but the default for geometries (drawables in fact) is to use OpenGL display lists (depending on the OSG compilation).

OpenGL display lists creation takes time. The dirtyDisplayList method forces OSG to re-create the OpenGL display list.


The solution is to force the geometry to use vertex arrays:

geometry->setUseDisplayLists(false);

On 21/07/2017 11:11, Gianni Ambrosio wrote:

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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to