Provide SGReaderWriterOptions::copyOrCreate(const osgDB::Options*).
This functions tries to preserve the database options as much as possible and guarantees to return a non zero options pointer.
This commit is contained in:
parent
11fd888ed8
commit
1473eabc7c
@ -21,6 +21,7 @@
|
||||
#define SGREADERWRITEROPTIONS_HXX 1
|
||||
|
||||
#include <osgDB/Options>
|
||||
#include <osgDB/Registry>
|
||||
#include <simgear/scene/model/modellib.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
@ -92,6 +93,17 @@ public:
|
||||
void setInstantiateEffects(bool instantiateEffects)
|
||||
{ _instantiateEffects = instantiateEffects; }
|
||||
|
||||
static SGReaderWriterOptions* copyOrCreate(const osgDB::Options* options)
|
||||
{
|
||||
if (!options)
|
||||
options = osgDB::Registry::instance()->getOptions();
|
||||
if (!options)
|
||||
return new SGReaderWriterOptions;
|
||||
if (!dynamic_cast<const SGReaderWriterOptions*>(options))
|
||||
return new SGReaderWriterOptions(*options);
|
||||
return new SGReaderWriterOptions(*static_cast<const SGReaderWriterOptions*>(options));
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~SGReaderWriterOptions() {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user