Add navigation layer bitmask helper functions
Adds helper functions to work with the navigation layer bitmask.
This commit is contained in:
parent
01efb93842
commit
55923ade68
@ -34,6 +34,13 @@
|
||||
Returns which index the agent is currently on in the navigation path's [PackedVector2Array].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_map" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
@ -76,6 +83,14 @@
|
||||
Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_layer_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_map">
|
||||
<return type="void" />
|
||||
<argument index="0" name="navigation_map" type="RID" />
|
||||
|
@ -34,6 +34,13 @@
|
||||
Returns which index the agent is currently on in the navigation path's [PackedVector3Array].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_map" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
@ -76,6 +83,14 @@
|
||||
Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_layer_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_map">
|
||||
<return type="void" />
|
||||
<argument index="0" name="navigation_map" type="RID" />
|
||||
|
@ -14,12 +14,27 @@
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_navigation_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_region_rid" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the [RID] of this region on the [NavigationServer2D]. Combined with [method NavigationServer2D.map_get_closest_point_owner] can be used to identify the [NavigationRegion2D] closest to a point on the merged navigation map.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_layer_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||
|
@ -21,12 +21,27 @@
|
||||
Bakes the [NavigationMesh]. If [code]on_thread[/code] is set to [code]true[/code] (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new [NavigationMesh]. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as HTML5 with threads disabled).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_region_rid" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the [RID] of this region on the [NavigationServer3D]. Combined with [method NavigationServer3D.map_get_closest_point_owner] can be used to identify the [NavigationRegion3D] closest to a point on the merged navigation map.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_layer_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||
|
@ -73,6 +73,13 @@
|
||||
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_navigation_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_used_cells" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
@ -133,6 +140,14 @@
|
||||
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="set_navigation_layer_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="layer_number" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="world_to_map" qualifiers="const">
|
||||
<return type="Vector3i" />
|
||||
<argument index="0" name="world_position" type="Vector3" />
|
||||
@ -177,7 +192,7 @@
|
||||
The assigned [MeshLibrary].
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
The navigation layers the GridMap generates its navigable regions in.
|
||||
A bitmask determining all navigation layers the GridMap generated navigation regions belong to. These navigation layers can be checked upon when requesting a path with [method NavigationServer3D.map_get_path].
|
||||
</member>
|
||||
<member name="physics_material" type="PhysicsMaterial" setter="set_physics_material" getter="get_physics_material">
|
||||
Overrides the default friction and bounce physics properties for the whole [GridMap].
|
||||
|
@ -231,10 +231,28 @@ void GridMap::set_navigation_layers(uint32_t p_navigation_layers) {
|
||||
_recreate_octant_data();
|
||||
}
|
||||
|
||||
uint32_t GridMap::get_navigation_layers() {
|
||||
uint32_t GridMap::get_navigation_layers() const {
|
||||
return navigation_layers;
|
||||
}
|
||||
|
||||
void GridMap::set_navigation_layer_value(int p_layer_number, bool p_value) {
|
||||
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
uint32_t _navigation_layers = get_navigation_layers();
|
||||
if (p_value) {
|
||||
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||
} else {
|
||||
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||
}
|
||||
set_navigation_layers(_navigation_layers);
|
||||
}
|
||||
|
||||
bool GridMap::get_navigation_layer_value(int p_layer_number) const {
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||
}
|
||||
|
||||
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
|
||||
if (!mesh_library.is_null()) {
|
||||
mesh_library->unregister_owner(this);
|
||||
@ -885,6 +903,9 @@ void GridMap::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "layers"), &GridMap::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &GridMap::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &GridMap::set_navigation_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &GridMap::get_navigation_layer_value);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library);
|
||||
|
||||
|
@ -239,7 +239,10 @@ public:
|
||||
bool is_baking_navigation();
|
||||
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers();
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_value(int p_layer_number) const;
|
||||
|
||||
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
||||
Ref<MeshLibrary> get_mesh_library() const;
|
||||
|
@ -64,6 +64,9 @@ void NavigationAgent2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationAgent2D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationAgent2D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent2D::set_navigation_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent2D::get_navigation_layer_value);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent2D::set_navigation_map);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent2D::get_navigation_map);
|
||||
|
||||
@ -219,6 +222,24 @@ uint32_t NavigationAgent2D::get_navigation_layers() const {
|
||||
return navigation_layers;
|
||||
}
|
||||
|
||||
void NavigationAgent2D::set_navigation_layer_value(int p_layer_number, bool p_value) {
|
||||
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
uint32_t _navigation_layers = get_navigation_layers();
|
||||
if (p_value) {
|
||||
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||
} else {
|
||||
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||
}
|
||||
set_navigation_layers(_navigation_layers);
|
||||
}
|
||||
|
||||
bool NavigationAgent2D::get_navigation_layer_value(int p_layer_number) const {
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||
}
|
||||
|
||||
void NavigationAgent2D::set_navigation_map(RID p_navigation_map) {
|
||||
map_override = p_navigation_map;
|
||||
NavigationServer2D::get_singleton()->agent_set_map(agent, map_override);
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_value(int p_layer_number) const;
|
||||
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
RID get_navigation_map() const;
|
||||
|
||||
|
@ -388,6 +388,24 @@ uint32_t NavigationRegion2D::get_navigation_layers() const {
|
||||
return NavigationServer2D::get_singleton()->region_get_navigation_layers(region);
|
||||
}
|
||||
|
||||
void NavigationRegion2D::set_navigation_layer_value(int p_layer_number, bool p_value) {
|
||||
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
uint32_t _navigation_layers = get_navigation_layers();
|
||||
if (p_value) {
|
||||
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||
} else {
|
||||
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||
}
|
||||
set_navigation_layers(_navigation_layers);
|
||||
}
|
||||
|
||||
bool NavigationRegion2D::get_navigation_layer_value(int p_layer_number) const {
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||
}
|
||||
|
||||
void NavigationRegion2D::set_enter_cost(real_t p_enter_cost) {
|
||||
ERR_FAIL_COND_MSG(p_enter_cost < 0.0, "The enter_cost must be positive.");
|
||||
enter_cost = MAX(p_enter_cost, 0.0);
|
||||
@ -562,6 +580,9 @@ void NavigationRegion2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationRegion2D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationRegion2D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationRegion2D::set_navigation_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationRegion2D::get_navigation_layer_value);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_region_rid"), &NavigationRegion2D::get_region_rid);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationRegion2D::set_enter_cost);
|
||||
|
@ -120,6 +120,9 @@ public:
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_value(int p_layer_number) const;
|
||||
|
||||
RID get_region_rid() const;
|
||||
|
||||
void set_enter_cost(real_t p_enter_cost);
|
||||
|
@ -68,6 +68,9 @@ void NavigationAgent3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationAgent3D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationAgent3D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent3D::set_navigation_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent3D::get_navigation_layer_value);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent3D::set_navigation_map);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent3D::get_navigation_map);
|
||||
|
||||
@ -226,6 +229,24 @@ uint32_t NavigationAgent3D::get_navigation_layers() const {
|
||||
return navigation_layers;
|
||||
}
|
||||
|
||||
void NavigationAgent3D::set_navigation_layer_value(int p_layer_number, bool p_value) {
|
||||
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
uint32_t _navigation_layers = get_navigation_layers();
|
||||
if (p_value) {
|
||||
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||
} else {
|
||||
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||
}
|
||||
set_navigation_layers(_navigation_layers);
|
||||
}
|
||||
|
||||
bool NavigationAgent3D::get_navigation_layer_value(int p_layer_number) const {
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||
}
|
||||
|
||||
void NavigationAgent3D::set_navigation_map(RID p_navigation_map) {
|
||||
map_override = p_navigation_map;
|
||||
NavigationServer3D::get_singleton()->agent_set_map(agent, map_override);
|
||||
|
@ -90,6 +90,9 @@ public:
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_value(int p_layer_number) const;
|
||||
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
RID get_navigation_map() const;
|
||||
|
||||
|
@ -73,6 +73,24 @@ uint32_t NavigationRegion3D::get_navigation_layers() const {
|
||||
return NavigationServer3D::get_singleton()->region_get_navigation_layers(region);
|
||||
}
|
||||
|
||||
void NavigationRegion3D::set_navigation_layer_value(int p_layer_number, bool p_value) {
|
||||
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
uint32_t _navigation_layers = get_navigation_layers();
|
||||
if (p_value) {
|
||||
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||
} else {
|
||||
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||
}
|
||||
set_navigation_layers(_navigation_layers);
|
||||
}
|
||||
|
||||
bool NavigationRegion3D::get_navigation_layer_value(int p_layer_number) const {
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||
}
|
||||
|
||||
void NavigationRegion3D::set_enter_cost(real_t p_enter_cost) {
|
||||
ERR_FAIL_COND_MSG(p_enter_cost < 0.0, "The enter_cost must be positive.");
|
||||
enter_cost = MAX(p_enter_cost, 0.0);
|
||||
@ -242,6 +260,9 @@ void NavigationRegion3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationRegion3D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationRegion3D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationRegion3D::set_navigation_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationRegion3D::get_navigation_layer_value);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_region_rid"), &NavigationRegion3D::get_region_rid);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationRegion3D::set_enter_cost);
|
||||
|
@ -60,6 +60,9 @@ public:
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_value(int p_layer_number) const;
|
||||
|
||||
RID get_region_rid() const;
|
||||
|
||||
void set_enter_cost(real_t p_enter_cost);
|
||||
|
Loading…
Reference in New Issue
Block a user