瀏覽代碼

Merge pull request #42061 from madmiraal/fix-41743

Fix Bullet prioritised list of Areas a RigidBody is a member of element shift.
Rémi Verschelde 5 年之前
父節點
當前提交
3a8a0bc5d3
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      modules/bullet/rigid_body_bullet.cpp

+ 2 - 2
modules/bullet/rigid_body_bullet.cpp

@@ -849,8 +849,8 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) {
 		} else {
 		} else {
 			if (areasWhereIam[i]->get_spOv_priority() > p_area->get_spOv_priority()) {
 			if (areasWhereIam[i]->get_spOv_priority() > p_area->get_spOv_priority()) {
 				// The position was found, just shift all elements
 				// The position was found, just shift all elements
-				for (int j = i; j < areaWhereIamCount; ++j) {
-					areasWhereIam[j + 1] = areasWhereIam[j];
+				for (int j = areaWhereIamCount; j > i; j--) {
+					areasWhereIam[j] = areasWhereIam[j - 1];
 				}
 				}
 				areasWhereIam[i] = p_area;
 				areasWhereIam[i] = p_area;
 				break;
 				break;