From 06f888d38c568a8ace4391b9ba3f8ff32e49c180 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sun, 1 May 2016 22:35:21 +0100 Subject: [PATCH] Display random objects independently of buildings Fix bug reported by Thorsten RENK on the mailing list that random objects were only being displayed if random objects were also present for the tile. Also fix crash if none of the random object models were found. --- simgear/scene/material/matmodel.cxx | 2 ++ simgear/scene/tgdb/SGTileDetailsCallback.hxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/simgear/scene/material/matmodel.cxx b/simgear/scene/material/matmodel.cxx index 41d004da..84dd9237 100644 --- a/simgear/scene/material/matmodel.cxx +++ b/simgear/scene/material/matmodel.cxx @@ -130,6 +130,8 @@ SGMatModel::load_models( SGPropertyNode *prop_root ) } else { SG_LOG(SG_INPUT, SG_ALERT, "Failed to load object " << _paths[i]); + // Ensure the vector contains something, otherwise get_random_model below fails + _models.push_back(new osg::Node()); } } } diff --git a/simgear/scene/tgdb/SGTileDetailsCallback.hxx b/simgear/scene/tgdb/SGTileDetailsCallback.hxx index 465be137..1cd9139b 100644 --- a/simgear/scene/tgdb/SGTileDetailsCallback.hxx +++ b/simgear/scene/tgdb/SGTileDetailsCallback.hxx @@ -387,7 +387,7 @@ public: float cos_zero_density_angle = mat->get_cos_object_zero_density_slope_angle(); float cos_max_density_angle = mat->get_cos_object_max_density_slope_angle(); - if (building_coverage == 0) + if ((building_coverage == 0) && (group_count ==0)) continue; SGBuildingBin* bin = NULL;