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

2017-08-18 Thread Gianni Ambrosio
Hi,
just an update that can be useful for others.

As suggested I split the original huge geometry in chunks (1-3 vertices 
each works fine) and it works fine now.

Thanks again,
Gianni

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





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


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

2017-07-21 Thread Gianni Ambrosio
Thank you very much Robert,
I will do as you suggested.

Gianni

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





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


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

2017-07-21 Thread Robert Osfield
Hi Gianni,

On 21 July 2017 at 11:32, Gianni Ambrosio  wrote:

> I tried what Lionel suggested but in fact the geometry generation is much
> more slow now.
> Anyway, since I suspected that "dirtyDisplayList()" is the cause of the
> delay, I tried to remove that line but without it I cannot see the new
> color.
> Now, is "dirtyDisplayList()" really required for what I need or is there a
> different call should I use just to see the triangle with the updated color?
>

If you use display lists and you modify the osg::Geometry you need to call
dirtyDislplayList() to force OSG to recompile.

What you need to do is to break your dataset into smaller chunks, 10,000
vertices per osg::Geometry is a reasonable level of granularity.  Using
VertexBufferObjects rather than DisplayLists is also something you should
do.  Finally optimize the dataset so you don't have some many vertices by
making sure the triangle share vertices where possible - you'll need to use
osg::DrawElementsUInt/UShort to use indices.

Doing these above steps will resolve most of the problems you have been
presenting recently.  If want to handle big datasets these are the steps
you absolutely need to do.

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


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

2017-07-21 Thread Lionel Lagarde

If you use display lists, you have to tell OSG that it has to re-build it.

If you use vertex arrays, colors->dirty() should be enough.



On 21/07/2017 12:32, Gianni Ambrosio wrote:

Thanks Lionel and Robert for the quick reply.

I tried what Lionel suggested but in fact the geometry generation is much more 
slow now.
Anyway, since I suspected that "dirtyDisplayList()" is the cause of the delay, 
I tried to remove that line but without it I cannot see the new color.
Now, is "dirtyDisplayList()" really required for what I need or is there a 
different call should I use just to see the triangle with the updated color?

Thanks,
Gianni

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





___
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


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

2017-07-21 Thread Gianni Ambrosio
Thanks Lionel and Robert for the quick reply.

I tried what Lionel suggested but in fact the geometry generation is much more 
slow now.
Anyway, since I suspected that "dirtyDisplayList()" is the cause of the delay, 
I tried to remove that line but without it I cannot see the new color.
Now, is "dirtyDisplayList()" really required for what I need or is there a 
different call should I use just to see the triangle with the updated color?

Thanks,
Gianni

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





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


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

2017-07-21 Thread Lionel Lagarde
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(intersection.drawable.get());
osg::Vec4Array& color = 
dynamic_cast(*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