]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/matlib.cxx
Reduce compiler.h to almost nothing (but it's worth keeping around I think, for
[simgear.git] / simgear / scene / material / matlib.cxx
index ba8ef9abb0df6faee2accfb84d565d2cda964ffa..2d6fddb85db8261f4c70a2fd990f318e0820b53a 100644 (file)
 #  include <simgear_config.h>
 #endif
 
-#ifdef SG_MATH_EXCEPTION_CLASH
-#  include <math.h>
-#endif
-
 #ifdef HAVE_WINDOWS_H
 #  include <windows.h>
 #endif
@@ -44,7 +40,7 @@
 #include SG_GL_H
 
 #include <string.h>
-#include STL_STRING
+#include <string>
 
 #include <osg/AlphaFunc>
 #include <osg/BlendFunc>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
 #include <simgear/props/props_io.hxx>
+#include <simgear/props/condition.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 
 #include "mat.hxx"
 
 #include "matlib.hxx"
 
-SG_USING_NAMESPACE(std);
 SG_USING_STD(string);
 
 // Constructor
@@ -77,8 +73,9 @@ SGMaterialLib::SGMaterialLib ( void ) {
 }
 
 // Load a library of material properties
-bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season ) {
-
+bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season,
+        SGPropertyNode *prop_root )
+{
     SGPropertyNode materials;
 
     SG_LOG( SG_INPUT, SG_INFO, "Reading materials from " << mpath );
@@ -92,8 +89,18 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
 
     int nMaterials = materials.nChildren();
     for (int i = 0; i < nMaterials; i++) {
-        const SGPropertyNode * node = materials.getChild(i);
+        const SGPropertyNode *node = materials.getChild(i);
         if (!strcmp(node->getName(), "material")) {
+            const SGPropertyNode *conditionNode = node->getChild("condition");
+            if (conditionNode) {
+                SGSharedPtr<const SGCondition> condition = sgReadCondition(prop_root, conditionNode);
+                if (!condition->test()) {
+                    SG_LOG(SG_INPUT, SG_DEBUG, "Skipping material entry #"
+                        << i << " (condition false)");
+                    continue;
+                }
+            }
+
             SGSharedPtr<SGMaterial> m = new SGMaterial(fg_root, node, season);
 
             vector<SGPropertyNode_ptr>names = node->getChildren("name");