[osg-users] heightfield change height crashes
jean-sebastien.guay at cm-labs.com
Tue Nov 24 06:10:04 PST 2009
> i only have set ->setDataVariance(osg::Object::DYNAMIC); to the geode, now i also have set it to the shapeDrawable. Should i apply it only to the shapeDrawable or to both?
Data variance only has an effect on subclasses of osg::Drawable and on
osg::StateSet (at run time - it has an effect on other nodes for the
osg::Optimizer if you use that, but at run time it only effects
drawables and statesets).
> After this change it draws the first point of my setHeight() changes, any following setHeight() call doesnt paint anything? If i use ->dirtyDisplayList(); on the shapeDrawable directly after calling setHeight() crashes the application.
But you didn't answer the other question, do you call it in the update
phase? If you don't pay attention to when you call it, you might be
calling it during the cull phase while OSG is trying to draw your height
field, so one thread will be trying to draw it while another will be
trying to update it and it will crash.
For the changes in height to be visible, either you need to disable
display lists completely (setUseDisplayList(false)) or you need to dirty
the display list (dirtyDisplayList()). There's no getting around that,
if you don't do one of those two things then the old display list will
still be used and you won't see any changes you make using
setHeight()... Makes sense doesn't it?
For a relatively small height field, the general recommendation is that
if you're going to be changing the heights often (say more often than
once per second), you should disable display lists completely, or else
you'll be spending too much time updating them. But if you're going to
be changing the heights less often, then you should keep display lists
enabled and call dirtyDisplayList() (from the update phase! say in an
update callback on your geode).
But for large height fields, you should probably disable display lists
in any case, and perhaps even enable VBOs, if you're using a pretty
recent video card, it will be more efficient that way.
Anyways, try the different alternatives out and see for yourself.
Hope this helps,
Jean-Sebastien Guay jean-sebastien.guay at cm-labs.com
More information about the osg-users