From edc482043034bb30517a2f96ca4f5997f1528963 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Mon, 14 Sep 2020 18:19:38 +0100 Subject: [PATCH] Fix RigidBodyBullet areasWhereIam element shift. --- modules/bullet/rigid_body_bullet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index f3e456fb97c..28fe09a7ea5 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -858,8 +858,8 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { } else { if (areasWhereIam[i]->get_spOv_priority() > p_area->get_spOv_priority()) { // The position was found, just shift all elements - for (int j = i; j < areaWhereIamCount; ++j) { - areasWhereIam.write[j + 1] = areasWhereIam[j]; + for (int j = areaWhereIamCount; j > i; j--) { + areasWhereIam.write[j] = areasWhereIam[j - 1]; } areasWhereIam.write[i] = p_area; break;