Merge pull request #79157 from smix8/navmesh_clear_4.x
Add `clear` function to NavigationMesh / NavigationPolygon
This commit is contained in:
commit
52078dc994
6 changed files with 34 additions and 0 deletions
|
@ -18,6 +18,12 @@
|
||||||
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="clear">
|
||||||
|
<return type="void" />
|
||||||
|
<description>
|
||||||
|
Clears the internal arrays for vertices and polygon indices.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="clear_polygons">
|
<method name="clear_polygons">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -69,6 +69,12 @@
|
||||||
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="clear">
|
||||||
|
<return type="void" />
|
||||||
|
<description>
|
||||||
|
Clears the internal arrays for vertices and polygon indices.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="clear_outlines">
|
<method name="clear_outlines">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -341,6 +341,11 @@ void NavigationMesh::clear_polygons() {
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavigationMesh::clear() {
|
||||||
|
polygons.clear();
|
||||||
|
vertices.clear();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
|
Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
|
||||||
if (debug_mesh.is_valid()) {
|
if (debug_mesh.is_valid()) {
|
||||||
|
@ -518,6 +523,8 @@ void NavigationMesh::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_set_polygons", "polygons"), &NavigationMesh::_set_polygons);
|
ClassDB::bind_method(D_METHOD("_set_polygons", "polygons"), &NavigationMesh::_set_polygons);
|
||||||
ClassDB::bind_method(D_METHOD("_get_polygons"), &NavigationMesh::_get_polygons);
|
ClassDB::bind_method(D_METHOD("_get_polygons"), &NavigationMesh::_get_polygons);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("clear"), &NavigationMesh::clear);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_vertices", "get_vertices");
|
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_vertices", "get_vertices");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_polygons", "_get_polygons");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_polygons", "_get_polygons");
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,8 @@ public:
|
||||||
Vector<int> get_polygon(int p_idx);
|
Vector<int> get_polygon(int p_idx);
|
||||||
void clear_polygons();
|
void clear_polygons();
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
Ref<ArrayMesh> get_debug_mesh();
|
Ref<ArrayMesh> get_debug_mesh();
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
|
@ -162,6 +162,15 @@ void NavigationPolygon::clear_polygons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavigationPolygon::clear() {
|
||||||
|
polygons.clear();
|
||||||
|
vertices.clear();
|
||||||
|
{
|
||||||
|
MutexLock lock(navigation_mesh_generation);
|
||||||
|
navigation_mesh.unref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ref<NavigationMesh> NavigationPolygon::get_navigation_mesh() {
|
Ref<NavigationMesh> NavigationPolygon::get_navigation_mesh() {
|
||||||
MutexLock lock(navigation_mesh_generation);
|
MutexLock lock(navigation_mesh_generation);
|
||||||
|
|
||||||
|
@ -360,6 +369,8 @@ void NavigationPolygon::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &NavigationPolygon::set_cell_size);
|
ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &NavigationPolygon::set_cell_size);
|
||||||
ClassDB::bind_method(D_METHOD("get_cell_size"), &NavigationPolygon::get_cell_size);
|
ClassDB::bind_method(D_METHOD("get_cell_size"), &NavigationPolygon::get_cell_size);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("clear"), &NavigationPolygon::clear);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_vertices", "get_vertices");
|
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_vertices", "get_vertices");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_polygons", "_get_polygons");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_polygons", "_get_polygons");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "outlines", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_outlines", "_get_outlines");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "outlines", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_outlines", "_get_outlines");
|
||||||
|
|
|
@ -92,6 +92,8 @@ public:
|
||||||
void set_cell_size(real_t p_cell_size);
|
void set_cell_size(real_t p_cell_size);
|
||||||
real_t get_cell_size() const;
|
real_t get_cell_size() const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
NavigationPolygon() {}
|
NavigationPolygon() {}
|
||||||
~NavigationPolygon() {}
|
~NavigationPolygon() {}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue