Fix RayCast{,2D}.clear_exceptions clears parent

This commit is contained in:
Haoyu Qiu 2022-02-08 16:22:10 +08:00
parent 5379237177
commit 74a4795fb1
2 changed files with 14 additions and 0 deletions

View file

@ -258,6 +258,13 @@ void RayCast2D::remove_exception(const Object *p_object) {
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_clip) {

View file

@ -256,6 +256,13 @@ void RayCast::remove_exception(const Object *p_object) {
void RayCast::clear_exceptions() {
exclude.clear();
if (exclude_parent_body && is_inside_tree()) {
CollisionObject *parent = Object::cast_to<CollisionObject>(get_parent());
if (parent) {
exclude.insert(parent->get_rid());
}
}
}
void RayCast::set_collide_with_areas(bool p_clip) {