include_HEADERS = \
animation.hxx \
- loader.hxx \
location.hxx \
model.hxx \
+ modellib.hxx \
placement.hxx
libsgmodel_a_SOURCES = \
animation.cxx \
- loader.cxx \
location.cxx \
model.cxx \
+ modellib.cxx \
placement.cxx
INCLUDES = -I$(top_srcdir)
+++ /dev/null
-// loader.cxx - implement SSG model and texture loaders.
-
-#include <simgear/compiler.h>
-#include <simgear/props/props.hxx>
-
-#include "loader.hxx"
-#include "model.hxx"
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of SGssgLoader.
-////////////////////////////////////////////////////////////////////////
-
-SGssgLoader::SGssgLoader ()
-{
- // no op
-}
-
-SGssgLoader::~SGssgLoader ()
-{
- std::map<string, ssgBase *>::iterator it = _table.begin();
- while (it != _table.end()) {
- it->second->deRef();
- _table.erase(it);
- }
-}
-
-void
-SGssgLoader::flush ()
-{
- std::map<string, ssgBase *>::iterator it = _table.begin();
- while (it != _table.end()) {
- ssgBase * item = it->second;
- // If there is only one reference, it's
- // ours; no one else is using the item.
- if (item->getRef() == 1) {
- item->deRef();
- _table.erase(it);
- }
- it++;
- }
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of SGModelLoader.
-////////////////////////////////////////////////////////////////////////
-
-SGModelLoader::SGModelLoader ()
-{
-}
-
-SGModelLoader::~SGModelLoader ()
-{
-}
-
-ssgEntity *
-SGModelLoader::load_model( const string &fg_root,
- const string &path,
- SGPropertyNode *prop_root,
- double sim_time_sec )
-{
- // FIXME: normalize path to
- // avoid duplicates.
- std::map<string, ssgBase *>::iterator it = _table.find(path);
- if (it == _table.end()) {
- _table[path] = sgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
- it = _table.find(path);
- it->second->ref(); // add one reference to keep it around
- }
- return (ssgEntity *)it->second;
-}
-
-
-// end of loader.cxx
+++ /dev/null
-#ifndef __MODEL_LOADER_HXX
-#define __MODEL_LOADER_HXX 1
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/compiler.h> // for SG_USING_STD
-
-#include <map>
-#include STL_STRING
-
-#include <plib/ssg.h>
-
-#include <simgear/props/props.hxx>
-
-SG_USING_STD(map);
-SG_USING_STD(string);
-
-
-/**
- * Base class for loading and managing SSG things.
- */
-class SGssgLoader
-{
-public:
- SGssgLoader ();
- virtual ~SGssgLoader ();
- virtual void flush ();
-protected:
- std::map<string,ssgBase *> _table;
-};
-
-
-/**
- * Class for loading and managing models with XML wrappers.
- */
-class SGModelLoader : public SGssgLoader
-{
-public:
- SGModelLoader ();
- virtual ~SGModelLoader ();
-
- virtual ssgEntity *load_model( const string &fg_root,
- const string &path,
- SGPropertyNode *prop_root,
- double sim_time_sec );
-};
-
-
-#endif
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/vector.hxx>
-// #include <Scenery/scenery.hxx>
-// #include "globals.hxx"
-
#include "location.hxx"
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
-#include <simgear/scene/model/animation.hxx>
+
+#include "animation.hxx"
#include "model.hxx"
--- /dev/null
+// modellib.cxx - implement an SSG model library.
+
+#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
+
+#include "model.hxx"
+
+#include "modellib.hxx"
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of SGModelLib.
+////////////////////////////////////////////////////////////////////////
+
+SGModelLib::SGModelLib ()
+{
+}
+
+SGModelLib::~SGModelLib ()
+{
+ map<string, ssgBase *>::iterator it = _table.begin();
+ while (it != _table.end()) {
+ it->second->deRef();
+ _table.erase(it);
+ }
+}
+
+void
+SGModelLib::flush1()
+{
+ // This routine is disabled because I believe I see multiple
+ // problems with it.
+ //
+ // 1. It blindly deletes all managed models that aren't used
+ // elsewhere. Is this what we really want???? In the one
+ // FlightGear case that calls this method, this clearly is not the
+ // intention. I believe it makes more sense to simply leave items
+ // in the lbrary, even if they are not currently used, they will be
+ // there already when/if we want to use them later.
+ //
+ // 2. This routine only does a deRef() on the model. This doesn't actually
+ // delete the ssg tree so there is a memory leak.
+
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "WARNGING: a disabled/broken routine has been called. This should be fixed!" );
+
+ return;
+
+ map<string, ssgBase *>::iterator it = _table.begin();
+ while (it != _table.end()) {
+ ssgBase *item = it->second;
+ // If there is only one reference, it's
+ // ours; no one else is using the item.
+ if (item->getRef() == 1) {
+ item->deRef();
+ _table.erase(it);
+ }
+ it++;
+ }
+}
+
+
+ssgEntity *
+SGModelLib::load_model( const string &fg_root,
+ const string &path,
+ SGPropertyNode *prop_root,
+ double sim_time_sec )
+{
+ // FIXME: normalize path to
+ // avoid duplicates.
+ map<string, ssgBase *>::iterator it = _table.find(path);
+ if (it == _table.end()) {
+ ssgEntity *model = sgLoad3DModel( fg_root, path, prop_root,
+ sim_time_sec );
+ model->ref();
+ _table[path] = model; // add one reference to keep it around
+ return model;
+ } else {
+ return (ssgEntity *)it->second;
+ }
+}
+
+
+// end of modellib.cxx
--- /dev/null
+// modellib.cxx - implement an SSG model library.
+
+#ifndef _SG_MODEL_LIB_HXX
+#define _SG_MODEL_LIB_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/compiler.h> // for SG_USING_STD
+
+#include <map>
+#include STL_STRING
+
+#include <plib/ssg.h>
+
+#include <simgear/props/props.hxx>
+
+SG_USING_STD(map);
+SG_USING_STD(string);
+
+
+/**
+ * Class for loading and managing models with XML wrappers.
+ */
+class SGModelLib
+{
+
+public:
+
+ SGModelLib ();
+ virtual ~SGModelLib ();
+ virtual void flush1();
+
+ virtual ssgEntity *load_model( const string &fg_root,
+ const string &path,
+ SGPropertyNode *prop_root,
+ double sim_time_sec );
+protected:
+
+ map<string,ssgBase *> _table;
+};
+
+
+#endif // _SG_MODEL_LIB_HXX
#include <plib/ssg.h>
#include <plib/ul.h>
-#include <simgear/scene/model/location.hxx>
+#include "location.hxx"
#include "placement.hxx"