]> git.mxchange.org Git - simgear.git/commitdiff
Refactor mat.hxx header.
authorJames Turner <zakalawe@mac.com>
Wed, 22 Aug 2012 18:02:46 +0000 (19:02 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 22 Aug 2012 18:02:46 +0000 (19:02 +0100)
Avoid many includes in mat.hxx, so ground testing code (e.g., Yasim) doesn't end up pulling in many OSG and scene classes.

simgear/scene/material/mat.cxx
simgear/scene/material/mat.hxx
simgear/scene/tgdb/ReaderWriterSTG.cxx
simgear/scene/tgdb/SGModelBin.hxx
simgear/scene/tgdb/SGOceanTile.cxx
simgear/scene/tgdb/SGTexturedTriangleBin.hxx
simgear/scene/tgdb/apt_signs.cxx
simgear/scene/tgdb/obj.cxx

index 7f70c63328ebcc55bef883c330617528f4f13cda..5f252918008214cf3014e28cf00b24a9200ea746 100644 (file)
 #include <simgear/props/props_io.hxx>
 #include <simgear/props/vectorPropTemplates.hxx>
 #include <simgear/scene/model/model.hxx>
+#include <simgear/scene/material/matmodel.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
+#include <simgear/props/condition.hxx>
+#include <simgear/scene/util/SGSceneFeatures.hxx>
+#include <simgear/scene/tgdb/SGTexturedTriangleBin.hxx>
 
 #include "Effect.hxx"
 #include "Technique.hxx"
@@ -448,7 +452,7 @@ Effect* SGMaterial::get_effect(int i)
     return _status[i].effect.get();
 }
 
-Effect* SGMaterial::get_effect(SGTexturedTriangleBin triangleBin)
+Effect* SGMaterial::get_effect(const SGTexturedTriangleBin& triangleBin)
 {
     if (_status.size() == 0) {
         SG_LOG( SG_GENERAL, SG_WARN, "No effect available.");
@@ -465,7 +469,7 @@ Effect* SGMaterial::get_effect()
 }
 
 
-osg::Texture2D* SGMaterial::get_object_mask(SGTexturedTriangleBin triangleBin)
+osg::Texture2D* SGMaterial::get_object_mask(const SGTexturedTriangleBin& triangleBin)
 {
     if (_status.size() == 0) {
         SG_LOG( SG_GENERAL, SG_WARN, "No mask available.");
@@ -541,6 +545,15 @@ SGMaterialGlyph* SGMaterial::get_glyph (const string& name) const
     return it->second;
 }
 
+bool SGMaterial::valid() const
+{ 
+  if (condition) {
+    return condition->test();       
+  } else {
+    return true;
+  }
+}
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // SGMaterialGlyph.
index 57b6c24cd1c21720de3809c28c9f07b0b25d3b53..3a4afe87e10b76b66df127d45931f8439a3d32be 100644 (file)
 #ifndef _SG_MAT_HXX
 #define _SG_MAT_HXX
 
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
 #include <simgear/compiler.h>
 
 #include <string>      // Standard C++ string library
@@ -37,7 +33,6 @@
 #include <map>
 
 #include "Effect.hxx"
-#include <simgear/scene/tgdb/SGTexturedTriangleBin.hxx>
 
 #include <osg/ref_ptr>
 #include <osg/Texture2D>
@@ -47,21 +42,21 @@ namespace osg
 class StateSet;
 }
 
-#include <simgear/scene/util/SGReaderWriterOptions.hxx>
-#include <simgear/props/props.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
-#include <simgear/scene/util/SGSceneFeatures.hxx>
-#include <simgear/props/condition.hxx>
-
-#include "matmodel.hxx"
+#include <simgear/math/SGMath.hxx>
 
 namespace simgear
 {
 class Effect;
 void reload_shaders();
+class SGReaderWriterOptions;
 }
 
+class SGMatModelGroup;
+class SGCondition;
+class SGPropertyNode;
 class SGMaterialGlyph;
+class SGTexturedTriangleBin;
 
 /**
  * A material in the scene graph.
@@ -109,13 +104,13 @@ public:
   /**
    * Get the textured state.
    */
-  simgear::Effect* get_effect(SGTexturedTriangleBin triangleBin);
+  simgear::Effect* get_effect(const SGTexturedTriangleBin& triangleBin);
   simgear::Effect* get_effect();
 
   /**
    * Get the textured state.
    */
-  osg::Texture2D* get_object_mask(SGTexturedTriangleBin triangleBin);
+  osg::Texture2D* get_object_mask(const SGTexturedTriangleBin& triangleBin);
 
 
   /**
@@ -311,13 +306,7 @@ public:
    * Evaluate whether this material is valid given the current global
    * property state.
    */
-   bool valid() { 
-     if (condition) {
-       return condition->test();       
-     } else {
-       return true;
-     }
-   }
+     bool valid() const;
 
   /**
    * Return pointer to glyph class, or 0 if it doesn't exist.
index 386a3f6aed680a51fe017ccc3954ee6e04d02fc7..8e5913d800aadeb2a6399a409b99ab8ded606c18 100644 (file)
@@ -39,6 +39,7 @@
 #include <simgear/misc/sgstream.hxx>
 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
 #include <simgear/scene/material/mat.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/tgdb/apt_signs.hxx>
index 914b52a6928b5a235ba74b6356a18a07bf1e2058..5c973faa773b54797fbd6a536579f176594a0ce2 100644 (file)
 #ifndef SG_MAT_MODEL_BIN_HXX
 #define SG_MAT_MODEL_BIN_HXX
 
-#include <math.h>
+#include <vector>
+#include <simgear/math/SGMath.hxx>
 
+// forward decls  
+class SGMatModel;
+   
 class SGMatModelBin {
 public:
   struct MatModel {
index cac90c191d72928916fe5751f666cd41ebc4f8a3..3679b57cad07c887d956145a7a52e02bc4ef425c 100644 (file)
@@ -41,7 +41,7 @@
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/material/mat.hxx>
 #include <simgear/scene/material/matlib.hxx>
-
+#include <simgear/scene/util/OsgMath.hxx>
 #include <simgear/scene/util/VectorArrayAdapter.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
 
index 9404e437ef4a567e1bfef4f9e9f17491768424b9..f87fc180e87ce758e1b463aeae469048960ad497 100644 (file)
@@ -361,7 +361,8 @@ public:
   osg::Geometry* buildGeometry() const
   { return buildGeometry(getTriangles()); }
   
-  int getTextureIndex() {
+  int getTextureIndex() const
+  {
     if (empty() || getNumTriangles() == 0)
       return 0;
 
index 1bc15f37f3e97ca66aa11d0172d1d38776e9c6df..019d9f32b5f2e2a2d761e1fef36db8362d18ada3 100644 (file)
@@ -39,6 +39,7 @@
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/material/mat.hxx>
 #include <simgear/scene/material/matlib.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
 
 #include "apt_signs.hxx"
 
index f8a2be17320047f7ed9e456dc88e1ca61693930a..113c5c6c4a47c4db4ae092b8226bafbe127ef96a 100644 (file)
 #include <simgear/scene/material/Effect.hxx>
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/material/mat.hxx>
+#include <simgear/scene/material/matmodel.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/model/SGOffsetTransform.hxx>
 #include <simgear/scene/util/SGUpdateVisitor.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
 #include <simgear/scene/util/QuadTreeBuilder.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
 #include "SGTexturedTriangleBin.hxx"
 #include "SGLightBin.hxx"