summaryrefslogtreecommitdiff
path: root/modules/gridmap/grid_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gridmap/grid_map.cpp')
-rw-r--r--modules/gridmap/grid_map.cpp42
1 files changed, 16 insertions, 26 deletions
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 6df7835855..02fe4d93de 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -703,8 +703,8 @@ void GridMap::_notification(int p_what) {
RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
-
} break;
+
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform3D new_xform = get_global_transform();
if (new_xform == last_transform) {
@@ -721,6 +721,7 @@ void GridMap::_notification(int p_what) {
RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
} break;
+
case NOTIFICATION_EXIT_WORLD: {
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
_octant_exit_world(E.key);
@@ -732,8 +733,8 @@ void GridMap::_notification(int p_what) {
for (int i = 0; i < baked_meshes.size(); i++) {
RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
}
-
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
_update_visibility();
} break;
@@ -873,11 +874,10 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_center_z", "enable"), &GridMap::set_center_z);
ClassDB::bind_method(D_METHOD("get_center_z"), &GridMap::get_center_z);
- ClassDB::bind_method(D_METHOD("set_clip", "enabled", "clipabove", "floor", "axis"), &GridMap::set_clip, DEFVAL(true), DEFVAL(0), DEFVAL(Vector3::AXIS_X));
-
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells);
+ ClassDB::bind_method(D_METHOD("get_used_cells_by_item", "item"), &GridMap::get_used_cells_by_item);
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
ClassDB::bind_method(D_METHOD("get_bake_meshes"), &GridMap::get_bake_meshes);
@@ -907,28 +907,6 @@ void GridMap::_bind_methods() {
ADD_SIGNAL(MethodInfo("cell_size_changed", PropertyInfo(Variant::VECTOR3, "cell_size")));
}
-void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::Axis p_axis) {
- if (!p_enabled && !clip) {
- return;
- }
- if (clip && p_enabled && clip_floor == p_floor && p_clip_above == clip_above && p_axis == clip_axis) {
- return;
- }
-
- clip = p_enabled;
- clip_floor = p_floor;
- clip_axis = p_axis;
- clip_above = p_clip_above;
-
- //make it all update
- for (KeyValue<OctantKey, Octant *> &E : octant_map) {
- Octant *g = E.value;
- g->dirty = true;
- }
- awaiting_update = true;
- _update_octants_callback();
-}
-
void GridMap::set_cell_scale(float p_scale) {
cell_scale = p_scale;
_recreate_octant_data();
@@ -950,6 +928,18 @@ Array GridMap::get_used_cells() const {
return a;
}
+Array GridMap::get_used_cells_by_item(int p_item) const {
+ Array a;
+ for (const KeyValue<IndexKey, Cell> &E : cell_map) {
+ if (E.value.item == p_item) {
+ Vector3 p(E.key.x, E.key.y, E.key.z);
+ a.push_back(p);
+ }
+ }
+
+ return a;
+}
+
Array GridMap::get_meshes() const {
if (mesh_library.is_null()) {
return Array();