]> git.mxchange.org Git - simgear.git/commitdiff
Various code massaging.
authorcurt <curt>
Thu, 15 May 2003 21:35:31 +0000 (21:35 +0000)
committercurt <curt>
Thu, 15 May 2003 21:35:31 +0000 (21:35 +0000)
simgear/scene/model/Makefile.am
simgear/scene/model/loader.cxx [deleted file]
simgear/scene/model/loader.hxx [deleted file]
simgear/scene/model/location.cxx
simgear/scene/model/model.cxx
simgear/scene/model/modellib.cxx [new file with mode: 0644]
simgear/scene/model/modellib.hxx [new file with mode: 0644]
simgear/scene/model/placement.cxx

index 360d6c605f32d6d1970dcd44e2445bf77b9be2cf..3734733b38b54f4ea0a0ff0541091b40933d84e3 100644 (file)
@@ -6,16 +6,16 @@ noinst_HEADERS =
 
 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)
diff --git a/simgear/scene/model/loader.cxx b/simgear/scene/model/loader.cxx
deleted file mode 100644 (file)
index bf833fc..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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
diff --git a/simgear/scene/model/loader.hxx b/simgear/scene/model/loader.hxx
deleted file mode 100644 (file)
index cd2da07..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#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
index 57c2975e1ab528a91e234657ce81dbf9ce6bf620..5ae03aed805205d1b14a2a879c488f6ed3c9073a 100644 (file)
@@ -35,9 +35,6 @@
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/vector.hxx>
 
-// #include <Scenery/scenery.hxx>
-// #include "globals.hxx"
-
 #include "location.hxx"
 
 
index b6394fb75bae4a952d3676cc16d8c92ed737a74c..425d558d99f0e2832c50e7d9781856dace2be517 100644 (file)
@@ -21,7 +21,8 @@
 #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"
 
diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx
new file mode 100644 (file)
index 0000000..3d3edd1
--- /dev/null
@@ -0,0 +1,85 @@
+// 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
diff --git a/simgear/scene/model/modellib.hxx b/simgear/scene/model/modellib.hxx
new file mode 100644 (file)
index 0000000..deed1e6
--- /dev/null
@@ -0,0 +1,45 @@
+// 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
index b408062b941bde91f1ccfdb3249a7940c0429ae3..cbee20f560d7ff7bc45f8c6be5c84af5a6d8b910 100644 (file)
@@ -17,7 +17,7 @@
 #include <plib/ssg.h>
 #include <plib/ul.h>
 
-#include <simgear/scene/model/location.hxx>
+#include "location.hxx"
 
 #include "placement.hxx"