From abf42402f875a34db964c70d0b51109a2bb3f248 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 14 Jun 2022 11:43:34 +0200 Subject: [PATCH] Update OccluderInstance3D warnings on project setting changes This ensures the node configuration warning is always up-to-date, even when the Use Occlusion Culling project setting is changed while a scene with an OccluderInstance3D is being edited. --- scene/3d/occluder_instance_3d.cpp | 18 ++++++++++++++++++ scene/3d/occluder_instance_3d.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 66d0a8c4e21..03817977fb5 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -467,6 +467,11 @@ void OccluderInstance3D::_occluder_changed() { update_configuration_warnings(); } +void OccluderInstance3D::_project_settings_changed() { + // Use Occlusion Culling project setting affects node configuration warnings. + update_configuration_warnings(); +} + Ref OccluderInstance3D::get_occluder() const { return occluder; } @@ -719,6 +724,19 @@ Ref OccluderInstance3D::_get_editable_3d_polygon_resource() const { return occluder; } +void OccluderInstance3D::_notification(int p_what) { +#ifdef TOOLS_ENABLED + switch (p_what) { + case NOTIFICATION_READY: { + if (Engine::get_singleton()->is_editor_hint()) { + // Use Occlusion Culling project setting affects node configuration warnings. + EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &OccluderInstance3D::_project_settings_changed)); + } + } break; + } +#endif +} + void OccluderInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bake_mask", "mask"), &OccluderInstance3D::set_bake_mask); ClassDB::bind_method(D_METHOD("get_bake_mask"), &OccluderInstance3D::get_bake_mask); diff --git a/scene/3d/occluder_instance_3d.h b/scene/3d/occluder_instance_3d.h index ed6610074e5..9f5711a4732 100644 --- a/scene/3d/occluder_instance_3d.h +++ b/scene/3d/occluder_instance_3d.h @@ -169,6 +169,7 @@ private: float bake_simplification_dist = 0.1f; void _occluder_changed(); + void _project_settings_changed(); static bool _bake_material_check(Ref p_material); static void _bake_surface(const Transform3D &p_transform, Array p_surface_arrays, Ref p_material, float p_simplification_dist, PackedVector3Array &r_vertices, PackedInt32Array &r_indices); @@ -178,6 +179,7 @@ private: Ref _get_editable_3d_polygon_resource() const; protected: + void _notification(int p_what); static void _bind_methods(); public: