From: frohlich Date: Thu, 8 Jun 2006 05:54:23 +0000 (+0000) Subject: Preliminary material lookup hooks - still unoptimized. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e99c682637dcff8fbe8b680b77c431a8d99896f5;p=simgear.git Preliminary material lookup hooks - still unoptimized. --- diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 4fde41c9..d3bd72c5 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -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; +} + diff --git a/simgear/scene/material/matlib.hxx b/simgear/scene/material/matlib.hxx index 969b7298..269a3fa2 100644 --- a/simgear/scene/material/matlib.hxx +++ b/simgear/scene/material/matlib.hxx @@ -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 ); };