Skip to content

Commit

Permalink
Expose is_baking method in navigation servers and region nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Feb 5, 2024
1 parent 4b6ad34 commit c2cfc0d
Show file tree
Hide file tree
Showing 24 changed files with 137 additions and 12 deletions.
6 changes: 6 additions & 0 deletions doc/classes/NavigationRegion2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
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="is_baking" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] when the [NavigationPolygon] is being baked on a background thread.
</description>
</method>
<method name="set_avoidance_layer_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/NavigationRegion3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
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="is_baking" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] when the [NavigationMesh] is being baked on a background thread.
</description>
</method>
<method name="set_navigation_layer_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
Expand Down
7 changes: 7 additions & 0 deletions doc/classes/NavigationServer2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
</description>
</method>
<method name="is_baking_navigation_polygon" qualifiers="const">
<return type="bool" />
<param index="0" name="navigation_polygon" type="NavigationPolygon" />
<description>
Returns [code]true[/code] when the provided navigation polygon is being baked on a background thread.
</description>
</method>
<method name="link_create">
<return type="RID" />
<description>
Expand Down
7 changes: 7 additions & 0 deletions doc/classes/NavigationServer3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@
Returns information about the current state of the NavigationServer. See [enum ProcessInfo] for a list of available states.
</description>
</method>
<method name="is_baking_navigation_mesh" qualifiers="const">
<return type="bool" />
<param index="0" name="navigation_mesh" type="NavigationMesh" />
<description>
Returns [code]true[/code] when the provided navigation mesh is being baked on a background thread.
</description>
</method>
<method name="link_create">
<return type="RID" />
<description>
Expand Down
4 changes: 4 additions & 0 deletions modules/navigation/godot_navigation_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,10 @@ void GodotNavigationServer::bake_from_source_geometry_data_async(const Ref<Navig
#endif // _3D_DISABLED
}

bool GodotNavigationServer::is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const {
return NavMeshGenerator3D::get_singleton()->is_baking(p_navigation_mesh);
}

COMMAND_1(free, RID, p_object) {
if (map_owner.owns(p_object)) {
NavMap *map = map_owner.get_or_null(p_object);
Expand Down
1 change: 1 addition & 0 deletions modules/navigation/godot_navigation_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class GodotNavigationServer : public NavigationServer3D {
virtual void parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override;
virtual void bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) override;
virtual void bake_from_source_geometry_data_async(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) override;
virtual bool is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const override;

COMMAND_1(free, RID, p_object);

Expand Down
4 changes: 4 additions & 0 deletions modules/navigation/godot_navigation_server_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ void GodotNavigationServer2D::bake_from_source_geometry_data_async(const Ref<Nav
#endif // CLIPPER2_ENABLED
}

bool GodotNavigationServer2D::is_baking_navigation_polygon(Ref<NavigationPolygon> p_navigation_polygon) const {
return NavMeshGenerator2D::get_singleton()->is_baking(p_navigation_polygon);
}

GodotNavigationServer2D::GodotNavigationServer2D() {}

GodotNavigationServer2D::~GodotNavigationServer2D() {}
Expand Down
1 change: 1 addition & 0 deletions modules/navigation/godot_navigation_server_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class GodotNavigationServer2D : public NavigationServer2D {
virtual void parse_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override;
virtual void bake_from_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) override;
virtual void bake_from_source_geometry_data_async(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) override;
virtual bool is_baking_navigation_polygon(Ref<NavigationPolygon> p_navigation_polygon) const override;
};

#endif // GODOT_NAVIGATION_SERVER_2D_H
17 changes: 11 additions & 6 deletions modules/navigation/nav_mesh_generator_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ void NavMeshGenerator2D::bake_from_source_geometry_data(Ref<NavigationPolygon> p
return;
}

baking_navmesh_mutex.lock();
if (baking_navmeshes.has(p_navigation_mesh)) {
baking_navmesh_mutex.unlock();
if (is_baking(p_navigation_mesh)) {
ERR_FAIL_MSG("NavigationPolygon is already baking. Wait for current bake to finish.");
}
baking_navmesh_mutex.lock();
baking_navmeshes.insert(p_navigation_mesh);
baking_navmesh_mutex.unlock();

Expand Down Expand Up @@ -193,11 +192,10 @@ void NavMeshGenerator2D::bake_from_source_geometry_data_async(Ref<NavigationPoly
return;
}

baking_navmesh_mutex.lock();
if (baking_navmeshes.has(p_navigation_mesh)) {
baking_navmesh_mutex.unlock();
if (is_baking(p_navigation_mesh)) {
ERR_FAIL_MSG("NavigationPolygon is already baking. Wait for current bake to finish.");
}
baking_navmesh_mutex.lock();
baking_navmeshes.insert(p_navigation_mesh);
baking_navmesh_mutex.unlock();

Expand All @@ -212,6 +210,13 @@ void NavMeshGenerator2D::bake_from_source_geometry_data_async(Ref<NavigationPoly
generator_task_mutex.unlock();
}

bool NavMeshGenerator2D::is_baking(Ref<NavigationPolygon> p_navigation_polygon) {
baking_navmesh_mutex.lock();
bool baking = baking_navmeshes.has(p_navigation_polygon);
baking_navmesh_mutex.unlock();
return baking;
}

void NavMeshGenerator2D::generator_thread_bake(void *p_arg) {
NavMeshGeneratorTask2D *generator_task = static_cast<NavMeshGeneratorTask2D *>(p_arg);

Expand Down
1 change: 1 addition & 0 deletions modules/navigation/nav_mesh_generator_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class NavMeshGenerator2D : public Object {
static void parse_source_geometry_data(Ref<NavigationPolygon> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable());
static void bake_from_source_geometry_data(Ref<NavigationPolygon> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, const Callable &p_callback = Callable());
static void bake_from_source_geometry_data_async(Ref<NavigationPolygon> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, const Callable &p_callback = Callable());
static bool is_baking(Ref<NavigationPolygon> p_navigation_polygon);

NavMeshGenerator2D();
~NavMeshGenerator2D();
Expand Down
17 changes: 11 additions & 6 deletions modules/navigation/nav_mesh_generator_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ void NavMeshGenerator3D::bake_from_source_geometry_data(Ref<NavigationMesh> p_na
return;
}

baking_navmesh_mutex.lock();
if (baking_navmeshes.has(p_navigation_mesh)) {
baking_navmesh_mutex.unlock();
if (is_baking(p_navigation_mesh)) {
ERR_FAIL_MSG("NavigationMesh is already baking. Wait for current bake to finish.");
}
baking_navmesh_mutex.lock();
baking_navmeshes.insert(p_navigation_mesh);
baking_navmesh_mutex.unlock();

Expand Down Expand Up @@ -208,12 +207,11 @@ void NavMeshGenerator3D::bake_from_source_geometry_data_async(Ref<NavigationMesh
return;
}

baking_navmesh_mutex.lock();
if (baking_navmeshes.has(p_navigation_mesh)) {
baking_navmesh_mutex.unlock();
if (is_baking(p_navigation_mesh)) {
ERR_FAIL_MSG("NavigationMesh is already baking. Wait for current bake to finish.");
return;
}
baking_navmesh_mutex.lock();
baking_navmeshes.insert(p_navigation_mesh);
baking_navmesh_mutex.unlock();

Expand All @@ -228,6 +226,13 @@ void NavMeshGenerator3D::bake_from_source_geometry_data_async(Ref<NavigationMesh
generator_task_mutex.unlock();
}

bool NavMeshGenerator3D::is_baking(Ref<NavigationMesh> p_navigation_mesh) {
baking_navmesh_mutex.lock();
bool baking = baking_navmeshes.has(p_navigation_mesh);
baking_navmesh_mutex.unlock();
return baking;
}

void NavMeshGenerator3D::generator_thread_bake(void *p_arg) {
NavMeshGeneratorTask3D *generator_task = static_cast<NavMeshGeneratorTask3D *>(p_arg);

Expand Down
1 change: 1 addition & 0 deletions modules/navigation/nav_mesh_generator_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class NavMeshGenerator3D : public Object {
static void parse_source_geometry_data(Ref<NavigationMesh> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable());
static void bake_from_source_geometry_data(Ref<NavigationMesh> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, const Callable &p_callback = Callable());
static void bake_from_source_geometry_data_async(Ref<NavigationMesh> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, const Callable &p_callback = Callable());
static bool is_baking(Ref<NavigationMesh> p_navigation_mesh);

NavMeshGenerator3D();
~NavMeshGenerator3D();
Expand Down
5 changes: 5 additions & 0 deletions scene/2d/navigation_region_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ void NavigationRegion2D::_bake_finished(Ref<NavigationPolygon> p_navigation_poly
emit_signal(SNAME("bake_finished"));
}

bool NavigationRegion2D::is_baking() const {
return NavigationServer2D::get_singleton()->is_baking_navigation_polygon(navigation_polygon);
}

void NavigationRegion2D::_navigation_polygon_changed() {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
queue_redraw();
Expand Down Expand Up @@ -320,6 +324,7 @@ void NavigationRegion2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_travel_cost"), &NavigationRegion2D::get_travel_cost);

ClassDB::bind_method(D_METHOD("bake_navigation_polygon", "on_thread"), &NavigationRegion2D::bake_navigation_polygon, DEFVAL(true));
ClassDB::bind_method(D_METHOD("is_baking"), &NavigationRegion2D::is_baking);

ClassDB::bind_method(D_METHOD("_navigation_polygon_changed"), &NavigationRegion2D::_navigation_polygon_changed);

Expand Down
1 change: 1 addition & 0 deletions scene/2d/navigation_region_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class NavigationRegion2D : public Node2D {

void bake_navigation_polygon(bool p_on_thread);
void _bake_finished(Ref<NavigationPolygon> p_navigation_polygon);
bool is_baking() const;

NavigationRegion2D();
~NavigationRegion2D();
Expand Down
5 changes: 5 additions & 0 deletions scene/3d/navigation_region_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_navigation_mesh) {
emit_signal(SNAME("bake_finished"));
}

bool NavigationRegion3D::is_baking() const {
return NavigationServer3D::get_singleton()->is_baking_navigation_mesh(navigation_mesh);
}

PackedStringArray NavigationRegion3D::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();

Expand Down Expand Up @@ -308,6 +312,7 @@ void NavigationRegion3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_travel_cost"), &NavigationRegion3D::get_travel_cost);

ClassDB::bind_method(D_METHOD("bake_navigation_mesh", "on_thread"), &NavigationRegion3D::bake_navigation_mesh, DEFVAL(true));
ClassDB::bind_method(D_METHOD("is_baking"), &NavigationRegion3D::is_baking);

ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navigation_mesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
Expand Down
1 change: 1 addition & 0 deletions scene/3d/navigation_region_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class NavigationRegion3D : public Node3D {
/// sets the new navigation mesh and emits a signal
void bake_navigation_mesh(bool p_on_thread);
void _bake_finished(Ref<NavigationMesh> p_navigation_mesh);
bool is_baking() const;

PackedStringArray get_configuration_warnings() const override;

Expand Down
1 change: 1 addition & 0 deletions servers/navigation_server_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ void NavigationServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("parse_source_geometry_data", "navigation_polygon", "source_geometry_data", "root_node", "callback"), &NavigationServer2D::parse_source_geometry_data, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data", "navigation_polygon", "source_geometry_data", "callback"), &NavigationServer2D::bake_from_source_geometry_data, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data_async", "navigation_polygon", "source_geometry_data", "callback"), &NavigationServer2D::bake_from_source_geometry_data_async, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("is_baking_navigation_polygon", "navigation_polygon"), &NavigationServer2D::is_baking_navigation_polygon);

ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer2D::free);

Expand Down
1 change: 1 addition & 0 deletions servers/navigation_server_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ class NavigationServer2D : public Object {
virtual void parse_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) = 0;
virtual void bake_from_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) = 0;
virtual void bake_from_source_geometry_data_async(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) = 0;
virtual bool is_baking_navigation_polygon(Ref<NavigationPolygon> p_navigation_polygon) const = 0;

NavigationServer2D();
~NavigationServer2D() override;
Expand Down
1 change: 1 addition & 0 deletions servers/navigation_server_2d_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class NavigationServer2DDummy : public NavigationServer2D {
void parse_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override {}
void bake_from_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) override {}
void bake_from_source_geometry_data_async(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, const Callable &p_callback = Callable()) override {}
bool is_baking_navigation_polygon(Ref<NavigationPolygon> p_navigation_polygon) const override { return false; }

void set_debug_enabled(bool p_enabled) {}
bool get_debug_enabled() const { return false; }
Expand Down
1 change: 1 addition & 0 deletions servers/navigation_server_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void NavigationServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("parse_source_geometry_data", "navigation_mesh", "source_geometry_data", "root_node", "callback"), &NavigationServer3D::parse_source_geometry_data, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data", "navigation_mesh", "source_geometry_data", "callback"), &NavigationServer3D::bake_from_source_geometry_data, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data_async", "navigation_mesh", "source_geometry_data", "callback"), &NavigationServer3D::bake_from_source_geometry_data_async, DEFVAL(Callable()));
ClassDB::bind_method(D_METHOD("is_baking_navigation_mesh", "navigation_mesh"), &NavigationServer3D::is_baking_navigation_mesh);

ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer3D::free);

Expand Down
1 change: 1 addition & 0 deletions servers/navigation_server_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class NavigationServer3D : public Object {
virtual void parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) = 0;
virtual void bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) = 0;
virtual void bake_from_source_geometry_data_async(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) = 0;
virtual bool is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const = 0;

NavigationServer3D();
~NavigationServer3D() override;
Expand Down
2 changes: 2 additions & 0 deletions servers/navigation_server_3d_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class NavigationServer3DDummy : public NavigationServer3D {
void parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override {}
void bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) override {}
void bake_from_source_geometry_data_async(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) override {}
bool is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const override { return false; }

void free(RID p_object) override {}
void set_active(bool p_active) override {}
void process(real_t delta_time) override {}
Expand Down
40 changes: 40 additions & 0 deletions tests/scene/test_navigation_region_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
#ifndef TEST_NAVIGATION_REGION_3D_H
#define TEST_NAVIGATION_REGION_3D_H

#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/main/window.h"
#include "scene/resources/primitive_meshes.h"

#include "tests/test_macros.h"

Expand All @@ -44,6 +46,44 @@ TEST_SUITE("[Navigation]") {
CHECK(region_node->get_region_rid().is_valid());
memdelete(region_node);
}

TEST_CASE("[SceneTree][NavigationRegion3D] Region should bake successfully from valid geometry") {
Node3D *node_3d = memnew(Node3D);
SceneTree::get_singleton()->get_root()->add_child(node_3d);
Ref<NavigationMesh> navigation_mesh = memnew(NavigationMesh);
NavigationRegion3D *navigation_region = memnew(NavigationRegion3D);
navigation_region->set_navigation_mesh(navigation_mesh);
node_3d->add_child(navigation_region);
Ref<PlaneMesh> plane_mesh = memnew(PlaneMesh);
plane_mesh->set_size(Size2(10.0, 10.0));
MeshInstance3D *mesh_instance = memnew(MeshInstance3D);
mesh_instance->set_mesh(plane_mesh);
navigation_region->add_child(mesh_instance);

CHECK_FALSE(navigation_region->is_baking());
CHECK_EQ(navigation_mesh->get_polygon_count(), 0);
CHECK_EQ(navigation_mesh->get_vertices().size(), 0);

SUBCASE("Synchronous bake should have immediate effects") {
navigation_region->bake_navigation_mesh(false);
CHECK_FALSE(navigation_region->is_baking());
CHECK_NE(navigation_mesh->get_polygon_count(), 0);
CHECK_NE(navigation_mesh->get_vertices().size(), 0);
}

// Race condition is present in the below subcase, but baking should take many
// orders of magnitude longer than basic checks on the main thread, so it's fine.
SUBCASE("Asynchronous bake should not be immediate") {
navigation_region->bake_navigation_mesh(true);
CHECK(navigation_region->is_baking());
CHECK_EQ(navigation_mesh->get_polygon_count(), 0);
CHECK_EQ(navigation_mesh->get_vertices().size(), 0);
}

memdelete(mesh_instance);
memdelete(navigation_region);
memdelete(node_3d);
}
}

} //namespace TestNavigationRegion3D
Expand Down
Loading

0 comments on commit c2cfc0d

Please sign in to comment.