From e0d8e0a5c7c394771558c99c9b8e410a5a654208 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 28 Jun 2010 08:27:30 +0000 Subject: [PATCH] From Wang Rui, "A solution for serialziers to call static functions at the end of reading/writing is to use a user serializer. The serialziers/osgManipulator/Draggers.cpp uses a DefaultGeometry serializer to run setupDefaultGeometry() once the reading process is finished, and this can also be applied to load the TerrainTileCallback. I've attached the modified serializer/osgTerrain/TerrainTile.cpp for tracing and solving current problem." --- .../serializers/osgTerrain/TerrainTile.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/osgWrappers/serializers/osgTerrain/TerrainTile.cpp b/src/osgWrappers/serializers/osgTerrain/TerrainTile.cpp index 9aef51d16..f60785a96 100644 --- a/src/osgWrappers/serializers/osgTerrain/TerrainTile.cpp +++ b/src/osgWrappers/serializers/osgTerrain/TerrainTile.cpp @@ -60,6 +60,20 @@ static bool writeColorLayers( osgDB::OutputStream& os, const osgTerrain::Terrain return true; } +// TileLoadedCallback +static bool checkTileLoadedCallback( const osgTerrain::TerrainTile& tile ) +{ return true; } + +static bool readTileLoadedCallback( osgDB::InputStream& is, osgTerrain::TerrainTile& tile ) +{ + if ( osgTerrain::TerrainTile::getTileLoadedCallback().valid() ) + osgTerrain::TerrainTile::getTileLoadedCallback()->loaded( &terrainTile, is.getOptions() ); + return true; +} + +static bool writeTileLoadedCallback( osgDB::OutputStream& os, const osgTerrain::TerrainTile& tile ) +{ return true; } + REGISTER_OBJECT_WRAPPER( osgTerrain_TerrainTile, new osgTerrain::TerrainTile, osgTerrain::TerrainTile, @@ -78,4 +92,6 @@ REGISTER_OBJECT_WRAPPER( osgTerrain_TerrainTile, ADD_ENUM_VALUE( ENABLE_BLENDING ); ADD_ENUM_VALUE( ENABLE_BLENDING_WHEN_ALPHA_PRESENT ); END_ENUM_SERIALIZER(); // BlendingPolicy + + ADD_USER_SERIALIZER( TileLoadedCallback ); }