From: James Turner Date: Wed, 22 Aug 2012 18:02:46 +0000 (+0100) Subject: Refactor mat.hxx header. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e99064ca18fc30e3b9a38e040df6f16c0cfaa67a;p=simgear.git Refactor mat.hxx header. Avoid many includes in mat.hxx, so ground testing code (e.g., Yasim) doesn't end up pulling in many OSG and scene classes. --- diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 7f70c633..5f252918 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -54,8 +54,12 @@ #include #include #include +#include #include #include +#include +#include +#include #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; + } +} + //////////////////////////////////////////////////////////////////////// // SGMaterialGlyph. diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 57b6c24c..3a4afe87 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -26,10 +26,6 @@ #ifndef _SG_MAT_HXX #define _SG_MAT_HXX -#ifndef __cplusplus -# error This library requires C++ -#endif - #include #include // Standard C++ string library @@ -37,7 +33,6 @@ #include #include "Effect.hxx" -#include #include #include @@ -47,21 +42,21 @@ namespace osg class StateSet; } -#include -#include #include -#include -#include - -#include "matmodel.hxx" +#include 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. diff --git a/simgear/scene/tgdb/ReaderWriterSTG.cxx b/simgear/scene/tgdb/ReaderWriterSTG.cxx index 386a3f6a..8e5913d8 100644 --- a/simgear/scene/tgdb/ReaderWriterSTG.cxx +++ b/simgear/scene/tgdb/ReaderWriterSTG.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/simgear/scene/tgdb/SGModelBin.hxx b/simgear/scene/tgdb/SGModelBin.hxx index 914b52a6..5c973faa 100644 --- a/simgear/scene/tgdb/SGModelBin.hxx +++ b/simgear/scene/tgdb/SGModelBin.hxx @@ -22,8 +22,12 @@ #ifndef SG_MAT_MODEL_BIN_HXX #define SG_MAT_MODEL_BIN_HXX -#include +#include +#include +// forward decls +class SGMatModel; + class SGMatModelBin { public: struct MatModel { diff --git a/simgear/scene/tgdb/SGOceanTile.cxx b/simgear/scene/tgdb/SGOceanTile.cxx index cac90c19..3679b57c 100644 --- a/simgear/scene/tgdb/SGOceanTile.cxx +++ b/simgear/scene/tgdb/SGOceanTile.cxx @@ -41,7 +41,7 @@ #include #include #include - +#include #include #include diff --git a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx index 9404e437..f87fc180 100644 --- a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx +++ b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx @@ -361,7 +361,8 @@ public: osg::Geometry* buildGeometry() const { return buildGeometry(getTriangles()); } - int getTextureIndex() { + int getTextureIndex() const + { if (empty() || getNumTriangles() == 0) return 0; diff --git a/simgear/scene/tgdb/apt_signs.cxx b/simgear/scene/tgdb/apt_signs.cxx index 1bc15f37..019d9f32 100644 --- a/simgear/scene/tgdb/apt_signs.cxx +++ b/simgear/scene/tgdb/apt_signs.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include "apt_signs.hxx" diff --git a/simgear/scene/tgdb/obj.cxx b/simgear/scene/tgdb/obj.cxx index f8a2be17..113c5c6c 100644 --- a/simgear/scene/tgdb/obj.cxx +++ b/simgear/scene/tgdb/obj.cxx @@ -52,11 +52,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "SGTexturedTriangleBin.hxx" #include "SGLightBin.hxx"