[osg-users] Error loading OSGBs with external textures in 3.4.0
Chris Kuliukas
chris at kuliukas.com
Thu Oct 1 02:00:25 PDT 2015
Hi,
After upgrading to 3.4.0 we suddenly found a visual model that used to load but no longer would, and would crash osgviewer when loading the particular model by itself.
After much head scratching and running the current and previous version in the debugger we narrowed the issue down to osgDB\InputStream.cpp in osg::Image* InputStream::readImage(bool readFromExternal)
Code:
if (loadedFromCache)
{
// we don't want to overwrite the properties of the image in the cache as this could cause theading problems if the object is currently being used
// so we read the properties from the file into a dummy object and discard the changes.
osg::ref_ptr<osg::Object> temp_obj = readObjectFields("osg::Object", id, _dummyReadObject.get() );
_identifierMap[id] = image;
}
else
{
//image = static_cast<osg::Image*>( readObjectFields("osg::Object", id, image.get()) ); // Previous line
image = static_cast<osg::Image*>( readObjectFields(className, id, image.get()) ); // Line which works as before
if ( image.valid() )
{
image->setFileName( name );
image->setWriteHint( (osg::Image::WriteHint)writeHint );
}
}
It looks like what's going on is for some reason it couldn't save this particular image to the binary, so there was no inline data to extract. This means the image object is NULL if there's no inline data, and when it gets down the bottom and does readObjectFields("osg::Object" it doesn't read the right binary data, so the InputStream gets lost and it can't read any further.
In a previous version 3.2.1 this piece of code looked like:
Code:
image = static_cast<osg::Image*>( readObjectFields(className, id, image.get()) );
if ( image.valid() )
{
image->setFileName( name );
image->setWriteHint( (osg::Image::WriteHint)writeHint );
}
So I'm guessing some cacheing addition / thread safety addition introduced some issue.
What I'm wondering is whether this is a proper fix, if not what is the proper fix, and if so can it please get included asap?
Attached is the .osgb file which caused the issue, if you want to recreate it.
Cheers,
Chris
------------------------
http://www.hrwallingford.com/facilities/ship-simulation-centre (http://www.hrwallingford.com/facilities/ship-simulation-centre)
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65274#65274
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LNG7_Green.zip
Type: application/x-zip-compressed
Size: 537862 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151001/a6a83c63/attachment-0002.bin>
More information about the osg-users
mailing list