From adde89e8b1c66b4f4814c3b47a5d347ff576428b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 Sep 2017 14:53:17 -0300 Subject: -Added an optimization so physics shapes are configured later, speeds up grid map loading and editing --- modules/gridmap/grid_map.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules/gridmap/grid_map.cpp') diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1b932f040e..ced1c3ca12 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -396,8 +396,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Map > > multimesh_items; - print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size())); - for (Set::Element *E = g.cells.front(); E; E = E->next()) { ERR_CONTINUE(!cell_map.has(E->get())); @@ -464,7 +462,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { //update multimeshes for (Map > >::Element *E = multimesh_items.front(); E; E = E->next()) { - print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size())); Octant::MultimeshInstance mmi; RID mm = VS::get_singleton()->multimesh_create(); -- cgit v1.2.3 From f43a0ef3270737d2b526480ecb0f1337ece9e041 Mon Sep 17 00:00:00 2001 From: David Saltares Date: Mon, 4 Sep 2017 21:52:44 +0100 Subject: Setting visibility on GridMap now works. Closes #907. Basically, `GridMap` wasn't reacting to the `NOTIFICATION_VISIBILITY_CHANGED` event. This reacts to such events and walks over the set of `Octants` and all of their `MultiMeshInstances` to set their visibility on the `VisualServer`. --- modules/gridmap/grid_map.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/gridmap/grid_map.cpp') diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1b932f040e..1b7a9e4061 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -655,6 +655,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::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()); + } } } @@ -720,6 +738,7 @@ void GridMap::_update_octants_callback() { to_delete.pop_back(); } + _update_visibility(); awaiting_update = false; } -- cgit v1.2.3