Backported from godot4: Fix NavigationMesh baking AABB Editor handling and visuals

Fixes handling and visuals for Navigation Mesh baking AABB in the Editor.
- smix8
This commit is contained in:
Relintai 2023-06-05 14:33:55 +02:00
parent b7892d6baf
commit cfa4384ad4
2 changed files with 16 additions and 3 deletions

View File

@ -31,8 +31,8 @@
#include "spatial_editor_gizmos.h"
#include "core/containers/list.h"
#include "core/containers/rb_map.h"
#include "core/containers/pool_vector.h"
#include "core/containers/rb_map.h"
#include "core/containers/rid.h"
#include "core/error/error_list.h"
#include "core/error/error_macros.h"
@ -3545,6 +3545,10 @@ NavigationMeshSpatialGizmoPlugin::NavigationMeshSpatialGizmoPlugin() {
create_material("navigation_edge_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled", Color(0.7, 0.7, 0.7)));
create_material("navigation_solid_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid", Color(0.5, 1, 1, 0.4)));
create_material("navigation_solid_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled", Color(0.7, 0.7, 0.7, 0.4)));
Color baking_aabb_material_color = Color(0.8, 0.5, 0.7);
baking_aabb_material_color.a = 0.1;
create_material("baking_aabb_material", baking_aabb_material_color);
}
bool NavigationMeshSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
@ -3573,6 +3577,15 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
return;
}
AABB baking_aabb = navmeshie->get_filter_baking_aabb();
if (!baking_aabb.has_no_volume()) {
Vector3 baking_aabb_offset = navmeshie->get_filter_baking_aabb_offset();
if (p_gizmo->is_selected()) {
Ref<Material> material = get_material("baking_aabb_material", p_gizmo);
p_gizmo->add_solid_box(material, baking_aabb.get_size(), baking_aabb.get_center() + baking_aabb_offset);
}
}
PoolVector<Vector3> vertices = navmeshie->get_vertices();
PoolVector<Vector3>::Read vr = vertices.read();
List<Face3> faces;

View File

@ -274,7 +274,7 @@ bool NavigationMesh::get_filter_walkable_low_height_spans() const {
void NavigationMesh::set_filter_baking_aabb(const AABB &p_aabb) {
filter_baking_aabb = p_aabb;
property_list_changed_notify();
emit_changed();
}
AABB NavigationMesh::get_filter_baking_aabb() const {
@ -283,7 +283,7 @@ AABB NavigationMesh::get_filter_baking_aabb() const {
void NavigationMesh::set_filter_baking_aabb_offset(const Vector3 &p_aabb_offset) {
filter_baking_aabb_offset = p_aabb_offset;
property_list_changed_notify();
emit_changed();
}
Vector3 NavigationMesh::get_filter_baking_aabb_offset() const {