diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-02-08 16:31:07 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-02-08 16:31:07 +0800 |
commit | bbcd9c5b9781fdbebd2e03a6bf054d387d3df24c (patch) | |
tree | 156584f06c5a84a2086d37b42f33ba6786d3a452 | |
parent | 0154ce2c8d66528d617e10b139640fd4c4405c6b (diff) |
Fix RayCast{2,3}D.clear_exceptions clears parent
-rw-r--r-- | scene/2d/ray_cast_2d.cpp | 7 | ||||
-rw-r--r-- | scene/3d/ray_cast_3d.cpp | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 9521667854..51b3e676f9 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -279,6 +279,13 @@ void RayCast2D::remove_exception(const CollisionObject2D *p_node) { void RayCast2D::clear_exceptions() { exclude.clear(); + + if (exclude_parent_body && is_inside_tree()) { + CollisionObject2D *parent = Object::cast_to<CollisionObject2D>(get_parent()); + if (parent) { + exclude.insert(parent->get_rid()); + } + } } void RayCast2D::set_collide_with_areas(bool p_enabled) { diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index b71c54dcf9..b251aa38ba 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -259,6 +259,13 @@ void RayCast3D::remove_exception(const CollisionObject3D *p_node) { void RayCast3D::clear_exceptions() { exclude.clear(); + + if (exclude_parent_body && is_inside_tree()) { + CollisionObject3D *parent = Object::cast_to<CollisionObject3D>(get_parent()); + if (parent) { + exclude.insert(parent->get_rid()); + } + } } void RayCast3D::set_collide_with_areas(bool p_enabled) { |