]> git.mxchange.org Git - simgear.git/commitdiff
Preliminary material lookup hooks - still unoptimized.
authorfrohlich <frohlich>
Thu, 8 Jun 2006 05:54:23 +0000 (05:54 +0000)
committerfrohlich <frohlich>
Thu, 8 Jun 2006 05:54:23 +0000 (05:54 +0000)
simgear/scene/material/matlib.cxx
simgear/scene/material/matlib.hxx

index 4fde41c91a47e37963e818f9462504c9075829d7..d3bd72c5ee8090ce8caf538b0810b6190faf786f 100644 (file)
@@ -538,3 +538,36 @@ void SGMaterialLib::load_next_deferred() {
          return;
     }
 }
+
+bool SGMaterialLib::find( ssgSimpleState *state, string & material ) const
+{
+    bool found = false;
+    ssgSimpleState *state_mat;
+
+    material = "";
+
+    for( const_material_map_iterator iter = begin(); iter != end(); iter++ )
+    {
+        int nb_tex = (*iter).second->get_num();
+
+        // many textures per material
+        for( int i = 0; i < nb_tex; i++ )
+        {
+            // material state
+            state_mat = (*iter).second->get_state( i );
+
+            if( state_mat == state )
+            {
+                 material = (*iter).first.c_str();
+                found = true;
+                break;
+            }
+        }
+
+        if( found )
+            break;
+    }
+
+    return found;
+}
+
index 969b72987490033b00ee801f72252dda6a2dac3c..269a3fa2bf3116d51ba76c0ace74028f128455ed 100644 (file)
@@ -87,6 +87,8 @@ public:
     material_map_iterator end() { return matlib.end(); }
     const_material_map_iterator end() const { return matlib.end(); }
 
+    bool find( ssgSimpleState*, string & material ) const;
+
     // Destructor
     ~SGMaterialLib ( void );
 };