From e9cd13f1206a50c3050188755053700e09365c3a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 30 Nov 2010 14:36:37 +0000 Subject: [PATCH] Fixed the readObject method so it could handle reading from a file contains any valid type of osg::Object --- src/osgPlugins/osg/ReaderWriterOSG2.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/osg/ReaderWriterOSG2.cpp b/src/osgPlugins/osg/ReaderWriterOSG2.cpp index 1618e8efe..41eb55cc8 100644 --- a/src/osgPlugins/osg/ReaderWriterOSG2.cpp +++ b/src/osgPlugins/osg/ReaderWriterOSG2.cpp @@ -148,7 +148,7 @@ public: std::ios::openmode mode = std::ios::in; Options* local_opt = prepareReading( result, fileName, mode, options ); if ( !result.success() ) return result; - + osgDB::ifstream istream( fileName.c_str(), mode ); return readObject( istream, local_opt ); } @@ -157,14 +157,17 @@ public: { osg::ref_ptr ii = readInputIterator(fin, options); if ( !ii ) return ReadResult::FILE_NOT_HANDLED; - + InputStream is( options ); - if ( is.start(ii.get())!=InputStream::READ_OBJECT ) + + osgDB::InputStream::ReadType readType = is.start(ii.get()); + if ( readType==InputStream::READ_UNKNOWN ) { CATCH_EXCEPTION(is); return ReadResult::FILE_NOT_HANDLED; } is.decompress(); CATCH_EXCEPTION(is); + osg::Object* obj = is.readObject(); CATCH_EXCEPTION(is); return obj; }