浏览代码

Fix NavigationMesh baking AABB Editor handling and visuals

Fixes handling and visuals for Navigation Mesh baking AABB in the Editor.
smix8 2 年之前
父节点
当前提交
7caf08ec75
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 14 0
      editor/plugins/node_3d_editor_gizmos.cpp
  2. 2 2
      scene/resources/navigation_mesh.cpp

+ 14 - 0
editor/plugins/node_3d_editor_gizmos.cpp

@@ -4876,6 +4876,10 @@ NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() {
 	create_material("face_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color(), false, false, true);
 	create_material("face_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color(), false, false, true);
 	create_material("edge_material", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_color());
 	create_material("edge_material", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_color());
 	create_material("edge_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_disabled_color());
 	create_material("edge_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_disabled_color());
+
+	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 NavigationRegion3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
 bool NavigationRegion3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
@@ -4899,6 +4903,16 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
 		return;
 		return;
 	}
 	}
 
 
+	AABB baking_aabb = navigationmesh->get_filter_baking_aabb();
+	if (baking_aabb.has_volume()) {
+		Vector3 baking_aabb_offset = navigationmesh->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);
+		}
+	}
+
 	Vector<Vector3> vertices = navigationmesh->get_vertices();
 	Vector<Vector3> vertices = navigationmesh->get_vertices();
 	const Vector3 *vr = vertices.ptr();
 	const Vector3 *vr = vertices.ptr();
 	List<Face3> faces;
 	List<Face3> faces;

+ 2 - 2
scene/resources/navigation_mesh.cpp

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