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.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 6df7835855..4b72c71a5a 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -878,6 +878,7 @@ void GridMap::_bind_methods() {
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);
@@ -950,6 +951,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();