summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAndreas Haas <Hinsbart@users.noreply.github.com>2017-10-05 19:23:04 +0200
committerGitHub <noreply@github.com>2017-10-05 19:23:04 +0200
commitb9b9a9f86ee4f0905629259d3e63e6d97e7b3e3b (patch)
tree779c517397838325d6c17af6feb449e9c5d34fab /modules
parentb759d1416f574e5b642413edd623b04f2a1d20ad (diff)
parent16bf0f08ed1357fc29b8e2507491ad9652ffbcd9 (diff)
Merge pull request #11858 from J08nY/feature/gridmap-used-cells
Add GridMap::get_used_cells. Fixes #11857.
Diffstat (limited to 'modules')
-rw-r--r--modules/gridmap/grid_map.cpp15
-rw-r--r--modules/gridmap/grid_map.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 4f7545a11d..4e8b67e4e8 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -769,6 +769,8 @@ 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_meshes"), &GridMap::get_meshes);
BIND_CONSTANT(INVALID_CELL_ITEM);
@@ -807,6 +809,19 @@ float GridMap::get_cell_scale() const {
return cell_scale;
}
+Array GridMap::get_used_cells() const {
+
+ Array a;
+ a.resize(cell_map.size());
+ int i = 0;
+ for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
+ Vector3 p(E->key().x, E->key().y, E->key().z);
+ a[i++] = p;
+ }
+
+ return a;
+}
+
Array GridMap::get_meshes() {
if (theme.is_null())
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index eb1b215696..296956ff5d 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -223,6 +223,8 @@ public:
void set_cell_scale(float p_scale);
float get_cell_scale() const;
+ Array get_used_cells() const;
+
Array get_meshes();
void clear();