From Vaclav Bilek, "The purpose of this change is to suppress "re-reading" of osg::ProxyNodes

( in OF external references) after the OF file is loaded. The change do
conditional
execution of already existing code.

I use this for optimized preprocessing of large databases what can not
be loaded
in one pass because of memory limits."
This commit is contained in:
Robert Osfield
2006-08-22 13:07:20 +00:00
parent c8a5dc86a2
commit 8aceb4eec6
2 changed files with 28 additions and 7 deletions

View File

@@ -152,6 +152,9 @@ class Document
bool getDoUnitsConversion() const { return _doUnitsConversion; }
void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; }
CoordUnits getDesiredUnits() const { return _desiredUnits; }
bool getKeepExternalReferences() const { return _keepExternalReferences; }
void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; }
protected:
@@ -162,6 +165,8 @@ class Document
bool _useTextureAlphaForTransparancyBinning;
bool _doUnitsConversion;
CoordUnits _desiredUnits;
bool _keepExternalReferences;
friend class Header;
bool _done;

View File

@@ -113,14 +113,27 @@ class FLTReaderWriter : public ReaderWriter
{
// add to local cache.
flt::Registry::instance()->addToLocalCache(fileName,rr.getNode());
bool keepExternalReferences = false;
if (options)
keepExternalReferences = (options->getOptionString().find("keepExternalReferences")!=std::string::npos);
// read externals.
if (rr.getNode())
if ( !keepExternalReferences )
{
nestedExternalsLevel++;
ReadExternalsVisitor visitor(local_opt.get());
rr.getNode()->accept(visitor);
nestedExternalsLevel--;
osg::notify(osg::DEBUG_INFO) << "keepExternalReferences not found, so externals will be re-readed"<<std::endl;
// read externals.
if (rr.getNode())
{
nestedExternalsLevel++;
ReadExternalsVisitor visitor(local_opt.get());
rr.getNode()->accept(visitor);
nestedExternalsLevel--;
}
}
else
{
osg::notify(osg::DEBUG_INFO) << "keepExternalReferences found, so externals will be left as ProxyNodes"<<std::endl;
}
}
@@ -145,6 +158,9 @@ class FLTReaderWriter : public ReaderWriter
if (options)
{
const char readerMsg[] = "flt reader option: ";
document.setKeepExternalReferences((options->getOptionString().find("keepExternalReferences")!=std::string::npos));
osg::notify(osg::DEBUG_INFO) << readerMsg << "keepExternalReferences=" << document.getKeepExternalReferences() << std::endl;
document.setPreserveFace((options->getOptionString().find("preserveFace")!=std::string::npos));
osg::notify(osg::DEBUG_INFO) << readerMsg << "preserveFace=" << document.getPreserveFace() << std::endl;
@@ -201,7 +217,7 @@ class FLTReaderWriter : public ReaderWriter
if (!document.getHeaderNode())
return ReadResult::ERROR_IN_READING_FILE;
if (!document.getPreserveFace())
{
osgUtil::Optimizer optimizer;