diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h
index 1cbeb711f..ab3e986d4 100644
--- a/Source/Engine/Core/Collections/Dictionary.h
+++ b/Source/Engine/Core/Collections/Dictionary.h
@@ -556,6 +556,18 @@ public:
SetCapacity(0, false);
}
+ ///
+ /// Swaps the contents of collection with the other object without copy operation. Performs fast internal data exchange.
+ ///
+ /// The other collection.
+ void Swap(Dictionary& other)
+ {
+ ::Swap(_elementsCount, other._elementsCount);
+ ::Swap(_deletedCount, other._deletedCount);
+ ::Swap(_size, other._size);
+ _allocation.Swap(other._allocation);
+ }
+
public:
///
diff --git a/Source/Engine/Physics/SimulationEventCallback.cpp b/Source/Engine/Physics/SimulationEventCallback.cpp
index 6b2cfe18d..27c8aa785 100644
--- a/Source/Engine/Physics/SimulationEventCallback.cpp
+++ b/Source/Engine/Physics/SimulationEventCallback.cpp
@@ -2,11 +2,9 @@
#include "SimulationEventCallback.h"
#include "Utilities.h"
-#include "FlaxEngine.Gen.h"
#include "Colliders/Collider.h"
#include "Joints/Joint.h"
#include "Actors/RigidBody.h"
-#include "Engine/Core/Log.h"
#include
#include
@@ -39,6 +37,20 @@ namespace
}
}
+void SimulationEventCallback::Clear()
+{
+ PrevCollisions.Swap(Collisions);
+ Collisions.Clear();
+
+ NewCollisions.Clear();
+ RemovedCollisions.Clear();
+
+ NewTriggerPairs.Clear();
+ LostTriggerPairs.Clear();
+
+ BrokenJoints.Clear();
+}
+
void SimulationEventCallback::CollectResults()
{
// Generate new collisions
diff --git a/Source/Engine/Physics/SimulationEventCallback.h b/Source/Engine/Physics/SimulationEventCallback.h
index 00f610717..c2705d255 100644
--- a/Source/Engine/Physics/SimulationEventCallback.h
+++ b/Source/Engine/Physics/SimulationEventCallback.h
@@ -60,19 +60,7 @@ public:
///
/// Clears the data.
///
- void Clear()
- {
- PrevCollisions = Collisions;
- Collisions.Clear();
-
- NewCollisions.Clear();
- RemovedCollisions.Clear();
-
- NewTriggerPairs.Clear();
- LostTriggerPairs.Clear();
-
- BrokenJoints.Clear();
- }
+ void Clear();
///
/// Generates the new/old/removed collisions and a valid trigger pairs.