Optimize physics simulation collisions pair cache
This commit is contained in:
@@ -556,6 +556,18 @@ public:
|
||||
SetCapacity(0, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the contents of collection with the other object without copy operation. Performs fast internal data exchange.
|
||||
/// </summary>
|
||||
/// <param name="other">The other collection.</param>
|
||||
void Swap(Dictionary& other)
|
||||
{
|
||||
::Swap(_elementsCount, other._elementsCount);
|
||||
::Swap(_deletedCount, other._deletedCount);
|
||||
::Swap(_size, other._size);
|
||||
_allocation.Swap(other._allocation);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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 <ThirdParty/PhysX/extensions/PxJoint.h>
|
||||
#include <ThirdParty/PhysX/PxShape.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -60,19 +60,7 @@ public:
|
||||
/// <summary>
|
||||
/// Clears the data.
|
||||
/// </summary>
|
||||
void Clear()
|
||||
{
|
||||
PrevCollisions = Collisions;
|
||||
Collisions.Clear();
|
||||
|
||||
NewCollisions.Clear();
|
||||
RemovedCollisions.Clear();
|
||||
|
||||
NewTriggerPairs.Clear();
|
||||
LostTriggerPairs.Clear();
|
||||
|
||||
BrokenJoints.Clear();
|
||||
}
|
||||
void Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Generates the new/old/removed collisions and a valid trigger pairs.
|
||||
|
||||
Reference in New Issue
Block a user