Skip to content

Commit

Permalink
Setting visibility on GridMap now works. Closes godotengine#907.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
dsaltares committed Sep 5, 2017
1 parent 29db531 commit f43a0ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/gridmap/grid_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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());
}
}
}

Expand Down Expand Up @@ -720,6 +738,7 @@ void GridMap::_update_octants_callback() {
to_delete.pop_back();
}

_update_visibility();
awaiting_update = false;
}

Expand Down
1 change: 1 addition & 0 deletions modules/gridmap/grid_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class GridMap : public Spatial {
void _get_property_list(List<PropertyInfo> *p_list) const;

void _notification(int p_what);
void _update_visibility();
static void _bind_methods();

public:
Expand Down

0 comments on commit f43a0ef

Please sign in to comment.