Fixed Collision & Trigger Messages not being cleared on deactivating objects

This commit is contained in:
Diren D Bharwani 2022-11-17 00:11:55 +08:00
parent a9f77d666c
commit 39a8ca131f
1 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@
// Project Headers // Project Headers
#include "Physics/PhysicsObject/SHPhysicsObject.h" #include "Physics/PhysicsObject/SHPhysicsObject.h"
#include "Physics/System/SHPhysicsSystem.h" #include "Physics/System/SHPhysicsSystem.h"
#include "Scene/SHSceneManager.h"
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
/* Local Helper Functions */ /* Local Helper Functions */
@ -80,10 +81,15 @@ namespace SHADE
{ {
for (auto eventIter = container.begin(); eventIter != container.end();) for (auto eventIter = container.begin(); eventIter != container.end();)
{ {
const bool CLEAR_EVENT = eventIter->GetCollisionState() == SHCollisionInfo::State::EXIT const SHCollisionInfo& C_INFO = *eventIter;
|| eventIter->GetCollisionState() == SHCollisionInfo::State::INVALID;
if (CLEAR_EVENT) const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT
|| C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
if (CLEAR_EVENT || INACTIVE_OBJECT)
eventIter = container.erase(eventIter); eventIter = container.erase(eventIter);
else else
++eventIter; ++eventIter;