Merge pull request #13392 from cbscribe/kcc_raycast_fix

Fix RayCast2D 'Exclude Parent' to include Area2D
This commit is contained in:
Rémi Verschelde 2017-11-29 16:12:51 +01:00 committed by GitHub
commit 9725f33ac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,11 +120,11 @@ void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) {
if (!is_inside_tree())
return;
if (Object::cast_to<PhysicsBody2D>(get_parent())) {
if (Object::cast_to<CollisionObject2D>(get_parent())) {
if (exclude_parent_body)
exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
exclude.insert(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
else
exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
exclude.erase(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
}
}
@ -144,11 +144,11 @@ void RayCast2D::_notification(int p_what) {
else
set_physics_process(false);
if (Object::cast_to<PhysicsBody2D>(get_parent())) {
if (Object::cast_to<CollisionObject2D>(get_parent())) {
if (exclude_parent_body)
exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
exclude.insert(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
else
exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
exclude.erase(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
}
} break;
case NOTIFICATION_EXIT_TREE: {