mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Expose is_baking method in navigation servers and region nodes.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user