diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-09-06 11:49:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 11:49:35 +0200 |
commit | 6efd777faeb11b42c41d8eccf29274defb20acd9 (patch) | |
tree | 19637641e75944d56afd316ed4f8f0f1454aed26 /modules/gridmap | |
parent | 7e2d03bd146a15a7f034ef42b2101987d978a6df (diff) | |
parent | f43a0ef3270737d2b526480ecb0f1337ece9e041 (diff) |
Merge pull request #10976 from saltares/issue-907
Fixes setting visibility on GridMap, issue #907
Diffstat (limited to 'modules/gridmap')
-rw-r--r-- | modules/gridmap/grid_map.cpp | 19 | ||||
-rw-r--r-- | modules/gridmap/grid_map.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index ced1c3ca12..4f7545a11d 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -652,6 +652,24 @@ void GridMap::_notification(int p_what) { //_update_area_instances(); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + _update_visibility(); + } break; + } +} + +void GridMap::_update_visibility() { + if (!is_inside_tree()) + return; + + _change_notify("visible"); + + for (Map<OctantKey, Octant *>::Element *e = octant_map.front(); e; e = e->next()) { + Octant *octant = e->value(); + for (int i = 0; i < octant->multimesh_instances.size(); i++) { + Octant::MultimeshInstance &mi = octant->multimesh_instances[i]; + VS::get_singleton()->instance_set_visible(mi.instance, is_visible()); + } } } @@ -717,6 +735,7 @@ void GridMap::_update_octants_callback() { to_delete.pop_back(); } + _update_visibility(); awaiting_update = false; } diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 9e1d250680..eb1b215696 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -190,6 +190,7 @@ protected: void _get_property_list(List<PropertyInfo> *p_list) const; void _notification(int p_what); + void _update_visibility(); static void _bind_methods(); public: |