Thanks Mathias, your fix looks good, now merged and submitted to snv/trunk. Cheers, Robert.
On Wed, Sep 15, 2010 at 5:20 PM, Mathias Fiedler <[email protected]> wrote: > Hi Wang Rui, hi Robert, > > i found an issue with the serializer writing shared arrays. At > OutputStream::writeArray(), if the currently latest array is shared the full > array content will be written. > The following code snippet will reproduce this issue: > > > Code: > > osg::Vec2 vec(0.f, 0.f); > osg::Array* sharedArray = new osg::Vec2Array(1, & vec); > > // create 2 geometries sharing same array > osg::Geometry* geom0 = new osg::Geometry; > osg::Geometry* geom1 = new osg::Geometry; > geom0->setVertexArray(sharedArray); > geom1->setVertexArray(sharedArray); > > osg::ref_ptr<osg::Geode> geode = new osg::Geode; > geode->addDrawable(geom0); > geode->addDrawable(geom1); > > std::stringstream buffer; > > // write node > osg::ref_ptr<osgDB::Options> options = new osgDB::Options("Ascii"); > osgDB::ReaderWriter* rw = > osgDB::Registry::instance()->getReaderWriterForExtension("osgt"); > osgDB::ReaderWriter::WriteResult wr = rw->writeNode(*geode, buffer, > options.get()); > > // print result; array will be written twice with full content, though with > same ID > std::cout << buffer.str() << std::endl; > > // trying to read back node will print warnings about unmatched properties > osgDB::ReaderWriter::ReadResult rr = rw->readNode(buffer, options.get()); > > > > > To fix this i made a change in OutputStream::writeArray(). > I think the same issue applies to OutputStream::writeObject(). So i made the > same change there. > > I only tested it for graphs with shared arrays. > > Thank you! > > Cheers, > Mathias > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=31641#31641 > > > > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
