From c19cf094a74bfc329ef58c5d664626d620c59ea1 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Thu, 27 May 2021 15:55:02 +0200 Subject: [PATCH] Backport the code to be able to display the region name of the file that holds the selected material. --- simgear/scene/material/mat.cxx | 8 ++++++-- simgear/scene/material/mat.hxx | 14 ++++++++++++-- simgear/scene/material/matlib.cxx | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index d2b1d9cc..7ed00bde 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -97,11 +97,13 @@ SGMaterial::SGMaterial( const SGReaderWriterOptions* options, const SGPropertyNode *props, SGPropertyNode *prop_root, AreaList *a, - SGSharedPtr c) + SGSharedPtr c, + const std::string& n) { init(); areas = a; condition = c; + region = n; read_properties( options, props, prop_root ); buildEffectProperties(options); } @@ -110,12 +112,14 @@ SGMaterial::SGMaterial( const osgDB::Options* options, const SGPropertyNode *props, SGPropertyNode *prop_root, AreaList *a, - SGSharedPtr c) + SGSharedPtr c, + const std::string& n) { osg::ref_ptr opt; opt = SGReaderWriterOptions::copyOrCreate(options); areas = a; condition = c; + region = n; init(); read_properties(opt.get(), props, prop_root); buildEffectProperties(opt.get()); diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index c48caf9b..e499735c 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -97,14 +97,16 @@ public: const SGPropertyNode *props, SGPropertyNode *prop_root, AreaList *a, - SGSharedPtr c); + SGSharedPtr c, + const std::string& n); SGMaterial(const simgear::SGReaderWriterOptions*, const SGPropertyNode *props, SGPropertyNode *prop_root, AreaList *a, - SGSharedPtr c); + SGSharedPtr c, + const std::string& n); /** * Destructor. @@ -123,6 +125,11 @@ public: simgear::Effect* get_one_effect(int texIndex); simgear::Effect* get_effect(); + /** + * Get the region Name. + */ + const std::string get_region_name() const { return region; } + /** * Get the Effect Name. */ @@ -487,6 +494,9 @@ private: SGVec4f ambient, diffuse, specular, emission; double shininess; + // region of this material + std::string region; + // effect for this material std::string effect; diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 3459d7e0..2ff1624e 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -128,12 +128,13 @@ bool SGMaterialLib::load( const SGPath &fg_root, const SGPath& mpath, // Now build all the materials for this set of areas and conditions + const std::string region = node->getStringValue("name"); const simgear::PropertyList materials = node->getChildren("material"); simgear::PropertyList::const_iterator materials_iter = materials.begin(); for (; materials_iter != materials.end(); materials_iter++) { const SGPropertyNode *node = materials_iter->get(); SGSharedPtr m = - new SGMaterial(options.get(), node, prop_root, arealist, condition); + new SGMaterial(options.get(), node, prop_root, arealist, condition, region); std::vectornames = node->getChildren("name"); for ( unsigned int j = 0; j < names.size(); j++ ) {