diff --git a/src/collision/CollisionDetection.cpp b/src/collision/CollisionDetection.cpp index c199859c..345c46bb 100644 --- a/src/collision/CollisionDetection.cpp +++ b/src/collision/CollisionDetection.cpp @@ -230,11 +230,11 @@ void CollisionDetection::computeMiddlePhase() { // Add all the narrow-phase info object reported by the callback into the // list of all the narrow-phase info object while (narrowPhaseInfo != nullptr) { - NarrowPhaseInfo* head = mNarrowPhaseInfoList; + NarrowPhaseInfo* next = narrowPhaseInfo->next; + narrowPhaseInfo->next = mNarrowPhaseInfoList; mNarrowPhaseInfoList = narrowPhaseInfo; - mNarrowPhaseInfoList->next = head; - narrowPhaseInfo = narrowPhaseInfo->next; + narrowPhaseInfo = next; } } // Concave vs Concave shape