diff options
author | Jasuse <61157367+Jasuse@users.noreply.github.com> | 2022-11-08 15:26:08 +0300 |
---|---|---|
committer | Jasuse <61157367+Jasuse@users.noreply.github.com> | 2022-11-24 22:31:35 +0300 |
commit | 749bdad23cdf798f1efb39c082ef0752928357d7 (patch) | |
tree | b2a1b4418c874ffcc8c9784466e8bb6e6953b8d8 /scene | |
parent | a16d3625c3b2e82c88cb29e897523aa53f78ec7c (diff) |
Fixing debug shape update of ShapeCast3D
fixed update conditiion at set_shape
added "changed" notification to update on shape changing
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/shape_cast_3d.cpp | 15 | ||||
-rw-r--r-- | scene/3d/shape_cast_3d.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/scene/3d/shape_cast_3d.cpp b/scene/3d/shape_cast_3d.cpp index 267139c7d0..54e1921ace 100644 --- a/scene/3d/shape_cast_3d.cpp +++ b/scene/3d/shape_cast_3d.cpp @@ -30,6 +30,7 @@ #include "shape_cast_3d.h" +#include "core/core_string_names.h" #include "collision_object_3d.h" #include "mesh_instance_3d.h" #include "scene/resources/concave_polygon_shape_3d.h" @@ -318,25 +319,35 @@ void ShapeCast3D::resource_changed(Ref<Resource> p_res) { update_gizmos(); } +void ShapeCast3D::_shape_changed() { + update_gizmos(); + bool is_editor = Engine::get_singleton()->is_editor_hint(); + if (is_inside_tree() && (is_editor || get_tree()->is_debugging_collisions_hint())) { + _update_debug_shape(); + } +} + void ShapeCast3D::set_shape(const Ref<Shape3D> &p_shape) { if (p_shape == shape) { return; } if (!shape.is_null()) { + shape->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast3D::_shape_changed)); shape->unregister_owner(this); } shape = p_shape; if (!shape.is_null()) { shape->register_owner(this); + shape->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast3D::_shape_changed)); } if (p_shape.is_valid()) { shape_rid = shape->get_rid(); } - if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) { + bool is_editor = Engine::get_singleton()->is_editor_hint(); + if (is_inside_tree() && (is_editor || get_tree()->is_debugging_collisions_hint())) { _update_debug_shape(); } - update_gizmos(); update_configuration_warnings(); } diff --git a/scene/3d/shape_cast_3d.h b/scene/3d/shape_cast_3d.h index abe10c9b24..2929679269 100644 --- a/scene/3d/shape_cast_3d.h +++ b/scene/3d/shape_cast_3d.h @@ -77,6 +77,7 @@ class ShapeCast3D : public Node3D { protected: void _notification(int p_what); void _update_shapecast_state(); + void _shape_changed(); static void _bind_methods(); public: |