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."
This commit is contained in:
Robert Osfield 2010-06-28 08:27:30 +00:00
parent 9d9a36f6af
commit e0d8e0a5c7

View File

@ -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 );
}