From Andreas Ekstrand, "Attached is a modified ReaderWriterDAE.cpp which creates the one and

only DAE instance when it's first needed instead of in the constructor.
This fixes the problem with osgdb_dae.dll not being loaded due to
unwanted ordering of global initialization.

This fix and the previous fix of the COLLADA plugin might be unnecessary
with the latest COLLADA DOM, but since many of us will probably still
use the older version of the DOM, I guess it's better this way.
"
This commit is contained in:
Robert Osfield
2006-10-02 11:38:25 +00:00
parent 0c8d909800
commit 9dd487e6c8

View File

@@ -29,9 +29,8 @@
class ReaderWriterDAE : public osgDB::ReaderWriter
{
public:
ReaderWriterDAE()
ReaderWriterDAE() : dae_(NULL)
{
dae_ = new DAE();
}
~ReaderWriterDAE()
@@ -74,6 +73,9 @@ ReaderWriterDAE::readNode(const std::string& fname,
osg::notify(osg::INFO) << "ReaderWriterDAE( \"" << fileName << "\" )" << std::endl;
if (dae_ == NULL)
const_cast<ReaderWriterDAE *>(this)->dae_ = new DAE();
osgdae::daeReader daeReader(dae_);
std::string fileURI( osgDB::convertFileNameToUnixStyle(fileName) );
if ( ! daeReader.convert( fileURI ) )
@@ -117,6 +119,9 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
}
}
if (dae_ == NULL)
const_cast<ReaderWriterDAE *>(this)->dae_ = new DAE();
osgdae::daeWriter daeWriter(dae_, fname, usePolygon );
daeWriter.setRootNode( node );
const_cast<osg::Node*>(&node)->accept( daeWriter );