Optimize physics simulation collisions pair cache
This commit is contained in:
@@ -556,6 +556,18 @@ public:
|
|||||||
SetCapacity(0, false);
|
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:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
#include "SimulationEventCallback.h"
|
#include "SimulationEventCallback.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "FlaxEngine.Gen.h"
|
|
||||||
#include "Colliders/Collider.h"
|
#include "Colliders/Collider.h"
|
||||||
#include "Joints/Joint.h"
|
#include "Joints/Joint.h"
|
||||||
#include "Actors/RigidBody.h"
|
#include "Actors/RigidBody.h"
|
||||||
#include "Engine/Core/Log.h"
|
|
||||||
#include <ThirdParty/PhysX/extensions/PxJoint.h>
|
#include <ThirdParty/PhysX/extensions/PxJoint.h>
|
||||||
#include <ThirdParty/PhysX/PxShape.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()
|
void SimulationEventCallback::CollectResults()
|
||||||
{
|
{
|
||||||
// Generate new collisions
|
// Generate new collisions
|
||||||
|
|||||||
@@ -60,19 +60,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears the data.
|
/// Clears the data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Clear()
|
void Clear();
|
||||||
{
|
|
||||||
PrevCollisions = Collisions;
|
|
||||||
Collisions.Clear();
|
|
||||||
|
|
||||||
NewCollisions.Clear();
|
|
||||||
RemovedCollisions.Clear();
|
|
||||||
|
|
||||||
NewTriggerPairs.Clear();
|
|
||||||
LostTriggerPairs.Clear();
|
|
||||||
|
|
||||||
BrokenJoints.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates the new/old/removed collisions and a valid trigger pairs.
|
/// Generates the new/old/removed collisions and a valid trigger pairs.
|
||||||
|
|||||||
Reference in New Issue
Block a user