summaryrefslogtreecommitdiff
path: root/modules/gridmap
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gridmap')
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml136
-rw-r--r--modules/gridmap/grid_map.cpp48
-rw-r--r--modules/gridmap/grid_map.h8
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp2
4 files changed, 79 insertions, 115 deletions
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index a2c8e8eabf..c1dbe63628 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -17,119 +17,93 @@
</tutorials>
<methods>
<method name="clear">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Clear all cells.
</description>
</method>
<method name="clear_baked_meshes">
- <return type="void">
- </return>
+ <return type="void" />
<description>
</description>
</method>
<method name="get_bake_mesh_instance">
- <return type="RID">
- </return>
- <argument index="0" name="idx" type="int">
- </argument>
+ <return type="RID" />
+ <argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_bake_meshes">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
Returns an array of [ArrayMesh]es and [Transform3D] references of all bake meshes that exist within the current GridMap.
</description>
</method>
<method name="get_cell_item" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="position" type="Vector3i">
- </argument>
+ <return type="int" />
+ <argument index="0" name="position" type="Vector3i" />
<description>
The [MeshLibrary] item index located at the given grid coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.
</description>
</method>
<method name="get_cell_item_orientation" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="position" type="Vector3i">
- </argument>
+ <return type="int" />
+ <argument index="0" name="position" type="Vector3i" />
<description>
The orientation of the cell at the given grid coordinates. [code]-1[/code] is returned if the cell is empty.
</description>
</method>
- <method name="get_collision_layer_bit" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="bit" type="int">
- </argument>
+ <method name="get_collision_layer_value" qualifiers="const">
+ <return type="bool" />
+ <argument index="0" name="layer_number" type="int" />
<description>
- Returns an individual bit on the [member collision_layer].
+ Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [code]layer_number[/code] between 1 and 32.
</description>
</method>
- <method name="get_collision_mask_bit" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="bit" type="int">
- </argument>
+ <method name="get_collision_mask_value" qualifiers="const">
+ <return type="bool" />
+ <argument index="0" name="layer_number" type="int" />
<description>
- Returns an individual bit on the [member collision_mask].
+ Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [code]layer_number[/code] between 1 and 32.
</description>
</method>
<method name="get_meshes">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
Returns an array of [Transform3D] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space.
</description>
</method>
<method name="get_used_cells" qualifiers="const">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
</description>
</method>
<method name="make_baked_meshes">
- <return type="void">
- </return>
- <argument index="0" name="gen_lightmap_uv" type="bool" default="false">
- </argument>
- <argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1">
- </argument>
+ <return type="void" />
+ <argument index="0" name="gen_lightmap_uv" type="bool" default="false" />
+ <argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1" />
<description>
</description>
</method>
<method name="map_to_world" qualifiers="const">
- <return type="Vector3">
- </return>
- <argument index="0" name="map_position" type="Vector3i">
- </argument>
+ <return type="Vector3" />
+ <argument index="0" name="map_position" type="Vector3i" />
<description>
Returns the position of a grid cell in the GridMap's local coordinate space.
</description>
</method>
<method name="resource_changed">
- <return type="void">
- </return>
- <argument index="0" name="resource" type="Resource">
- </argument>
+ <return type="void" />
+ <argument index="0" name="resource" type="Resource" />
<description>
</description>
</method>
<method name="set_cell_item">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector3i">
- </argument>
- <argument index="1" name="item" type="int">
- </argument>
- <argument index="2" name="orientation" type="int" default="0">
- </argument>
+ <return type="void" />
+ <argument index="0" name="position" type="Vector3i" />
+ <argument index="1" name="item" type="int" />
+ <argument index="2" name="orientation" type="int" default="0" />
<description>
Sets the mesh index for the cell referenced by its grid coordinates.
A negative item index such as [constant INVALID_CELL_ITEM] will clear the cell.
@@ -137,46 +111,33 @@
</description>
</method>
<method name="set_clip">
- <return type="void">
- </return>
- <argument index="0" name="enabled" type="bool">
- </argument>
- <argument index="1" name="clipabove" type="bool" default="true">
- </argument>
- <argument index="2" name="floor" type="int" default="0">
- </argument>
- <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="0">
- </argument>
+ <return type="void" />
+ <argument index="0" name="enabled" type="bool" />
+ <argument index="1" name="clipabove" type="bool" default="true" />
+ <argument index="2" name="floor" type="int" default="0" />
+ <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="0" />
<description>
</description>
</method>
- <method name="set_collision_layer_bit">
- <return type="void">
- </return>
- <argument index="0" name="bit" type="int">
- </argument>
- <argument index="1" name="value" type="bool">
- </argument>
+ <method name="set_collision_layer_value">
+ <return type="void" />
+ <argument index="0" name="layer_number" type="int" />
+ <argument index="1" name="value" type="bool" />
<description>
- Sets an individual bit on the [member collision_layer].
+ Based on [code]value[/code], enables or disables the specified layer in the [member collision_layer], given a [code]layer_number[/code] between 1 and 32.
</description>
</method>
- <method name="set_collision_mask_bit">
- <return type="void">
- </return>
- <argument index="0" name="bit" type="int">
- </argument>
- <argument index="1" name="value" type="bool">
- </argument>
+ <method name="set_collision_mask_value">
+ <return type="void" />
+ <argument index="0" name="layer_number" type="int" />
+ <argument index="1" name="value" type="bool" />
<description>
- Sets an individual bit on the [member collision_mask].
+ Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [code]layer_number[/code] between 1 and 32.
</description>
</method>
<method name="world_to_map" qualifiers="const">
- <return type="Vector3i">
- </return>
- <argument index="0" name="world_position" type="Vector3">
- </argument>
+ <return type="Vector3i" />
+ <argument index="0" name="world_position" type="Vector3" />
<description>
Returns the coordinates of the grid cell containing the given point.
[code]pos[/code] should be in the GridMap's local coordinate space.
@@ -223,8 +184,7 @@
</members>
<signals>
<signal name="cell_size_changed">
- <argument index="0" name="cell_size" type="Vector3">
- </argument>
+ <argument index="0" name="cell_size" type="Vector3" />
<description>
Emitted when [member cell_size] changes.
</description>
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index fea513c820..8e8b6f14ad 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -151,36 +151,40 @@ uint32_t GridMap::get_collision_mask() const {
return collision_mask;
}
-void GridMap::set_collision_mask_bit(int p_bit, bool p_value) {
- ERR_FAIL_INDEX_MSG(p_bit, 32, "Collision mask bit must be between 0 and 31 inclusive.");
- uint32_t mask = get_collision_mask();
+void GridMap::set_collision_layer_value(int p_layer_number, bool p_value) {
+ ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive.");
+ ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive.");
+ uint32_t collision_layer = get_collision_layer();
if (p_value) {
- mask |= 1 << p_bit;
+ collision_layer |= 1 << (p_layer_number - 1);
} else {
- mask &= ~(1 << p_bit);
+ collision_layer &= ~(1 << (p_layer_number - 1));
}
- set_collision_mask(mask);
+ set_collision_layer(collision_layer);
}
-bool GridMap::get_collision_mask_bit(int p_bit) const {
- ERR_FAIL_INDEX_V_MSG(p_bit, 32, false, "Collision mask bit must be between 0 and 31 inclusive.");
- return get_collision_mask() & (1 << p_bit);
+bool GridMap::get_collision_layer_value(int p_layer_number) const {
+ ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive.");
+ ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive.");
+ return get_collision_layer() & (1 << (p_layer_number - 1));
}
-void GridMap::set_collision_layer_bit(int p_bit, bool p_value) {
- ERR_FAIL_INDEX_MSG(p_bit, 32, "Collision layer bit must be between 0 and 31 inclusive.");
- uint32_t layer = get_collision_layer();
+void GridMap::set_collision_mask_value(int p_layer_number, bool p_value) {
+ ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive.");
+ ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive.");
+ uint32_t mask = get_collision_mask();
if (p_value) {
- layer |= 1 << p_bit;
+ mask |= 1 << (p_layer_number - 1);
} else {
- layer &= ~(1 << p_bit);
+ mask &= ~(1 << (p_layer_number - 1));
}
- set_collision_layer(layer);
+ set_collision_mask(mask);
}
-bool GridMap::get_collision_layer_bit(int p_bit) const {
- ERR_FAIL_INDEX_V_MSG(p_bit, 32, false, "Collision layer bit must be between 0 and 31 inclusive.");
- return get_collision_layer() & (1 << p_bit);
+bool GridMap::get_collision_mask_value(int p_layer_number) const {
+ ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive.");
+ ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive.");
+ return get_collision_mask() & (1 << (p_layer_number - 1));
}
void GridMap::set_bake_navigation(bool p_bake_navigation) {
@@ -794,11 +798,11 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &GridMap::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &GridMap::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &GridMap::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &GridMap::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_value", "layer_number", "value"), &GridMap::set_collision_mask_value);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_value", "layer_number"), &GridMap::get_collision_mask_value);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &GridMap::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &GridMap::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_value", "layer_number", "value"), &GridMap::set_collision_layer_value);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_value", "layer_number"), &GridMap::get_collision_layer_value);
ClassDB::bind_method(D_METHOD("set_bake_navigation", "bake_navigation"), &GridMap::set_bake_navigation);
ClassDB::bind_method(D_METHOD("is_baking_navigation"), &GridMap::is_baking_navigation);
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 8cd82e1f4c..879489fc70 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -217,11 +217,11 @@ public:
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
- void set_collision_layer_bit(int p_bit, bool p_value);
- bool get_collision_layer_bit(int p_bit) const;
+ void set_collision_layer_value(int p_layer_number, bool p_value);
+ bool get_collision_layer_value(int p_layer_number) const;
- void set_collision_mask_bit(int p_bit, bool p_value);
- bool get_collision_mask_bit(int p_bit) const;
+ void set_collision_mask_value(int p_layer_number, bool p_value);
+ bool get_collision_mask_value(int p_layer_number) const;
void set_bake_navigation(bool p_bake_navigation);
bool is_baking_navigation();
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 989c2d295c..f101c43e89 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -675,7 +675,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
}
if (mb->get_button_index() == MOUSE_BUTTON_LEFT && input_action == INPUT_SELECT) {
- undo_redo->create_action("GridMap Selection");
+ undo_redo->create_action(TTR("GridMap Selection"));
undo_redo->add_do_method(this, "_set_selection", selection.active, selection.begin, selection.end);
undo_redo->add_undo_method(this, "_set_selection", last_selection.active, last_selection.begin, last_selection.end);
undo_redo->commit_action();