Layer loading question

classic Classic list List threaded Threaded
3 messages Options
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Layer loading question

This post was updated on .
Hello,

We've successfully created a system such that there can be a shared osgEarth::MapNode that can be shared via multiple viewers simultaneously. We can do the following:

1. Add Image Layers (like the earth.tif)
2. Add DTED from GDAL library output
3. Add CADRG files

When we spawn a new viewer, it has a camera with a name. Each layer gets a cullCallback installed on it such that it will check the user value during traversal to determine if the node it corresponds to should be traversed or not. Essentisally we just have something like this:

//Assume we have an osgViewer::Viewer with an osg::Camera with a unique name/ id
...
osgEarth::ImageLayer* layer = new osgEarth::ImageLayer(originalLayer.options());
layer->addCullCallback(new layerCullCallback(layer, mapNode));
foreach(std::string cameraName, cameraNameVector){
    layer->setUserValue(cameraName, true);
}
layer->setUserValue(camera->getName(), false);

We use the boolean value to reference whether or not the layer is culled or not for the camera name. So essentially if we had 3 cameras, there will be one original copy that the mapNode's Map engine does not contain, but then we do a deep copy from the options of that original layer and add it to the map per camera after installing our callback. This gives us the intended result of each viewer having it's own view of a set of layers. So we can do stuff like set brightness and contrast on a per viewer basis.

This is all great and dandy, but we noticed that in our osg::EventHandler that we installed on our viewer, if we try to page in a bunch of color, hillshade, and vrt layers for displaying the visual information from the GDAL output it looks okay. However, whenever we page in a new tile based on our camera's focal point (we change every time the focal point crosses the border of 1x1 latitude/longitude tile) we call startUpdate() on the MapNode's Map, do our stuff like adding/removing what we need and then call endUpdate(). Sometimes, based on the StatsHandler, the Database pager looks like the requests stall if I don't touch anything or have focus on the osgVewer::Viewer window.

My question, sorry this is a bit long, is then, does the RexTerrainEngine not process when the viewer is not detecting user events from like mouse move / clicking events or something in order to assume the request is a lower priority or something? Because if I used two viewers, they will update very slowly for just doing even a single Lat/Lon tile. When it pages in the tiles it seems to partially load / stall the database pager. If I move my camera a tiny bit around or just move my mouse around it seems to load finally, if I do it on the original viewer that began the request. Is there a way I can always force the data base pager to process events or should it be doing that on its own already?

- Blanky

Edit: I have verified that this happens if I call beginUpdate in two handlers. Do I need a mutex?

Edit2: Mutexes fixed it for the projected maps, but regular wgs-84 spherical maps seem to ignore the begin update call. Is there something under the hood different with the RexEngine when managing a projected vs 3D map?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Layer loading question

Hello Blanky,

Sharing a scene graph across multiple osgViewer::Viewer instances is a recipe for trouble. Have you considered using CompositeViewer instead?

That said, your issue may be down to unsync'd FrameStamps across the multiple viewers. Since the Pager relies on framestamps to work properly that might be confusing it.

But I'm just guessing.
https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg19107.html
Glenn Waldron / Pelican Mapping
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Re: Layer loading question

I realized it's due to the .vrt files. We don't add ElevationLayers with the color and hillshade on projected maps, but do on the 3d maps. This causes a full rebuild regardless of the begin and end updates. We're on osgEarth 2.10. Did 3.0 deal at all with how ElevationLayers are handled, such that it won't fully remcompile the tiles? Also we've been having pretty good success with the multille viewers looking at the scene actually. Nothing seems to print opengl errors and the frame rates aren't bad so long as the map isn't too cluttered with moving nodes.