commit
d09fefe9b4
|
@ -14,6 +14,7 @@
|
||||||
#include "SHCollisionListener.h"
|
#include "SHCollisionListener.h"
|
||||||
|
|
||||||
// Project Headers
|
// Project Headers
|
||||||
|
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||||
#include "Physics/PhysicsObject/SHPhysicsObject.h"
|
#include "Physics/PhysicsObject/SHPhysicsObject.h"
|
||||||
#include "Physics/System/SHPhysicsSystem.h"
|
#include "Physics/System/SHPhysicsSystem.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
|
@ -83,13 +84,11 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
const SHCollisionInfo& C_INFO = *eventIter;
|
const SHCollisionInfo& C_INFO = *eventIter;
|
||||||
|
|
||||||
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT
|
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT || C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
|
||||||
|| C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
|
const bool INVALID_ENTITY = !SHEntityManager::IsValidEID(C_INFO.GetEntityA()) || !SHEntityManager::IsValidEID(C_INFO.GetEntityB());
|
||||||
|
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA()) || !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
|
||||||
|
|
||||||
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|
if (CLEAR_EVENT || INVALID_ENTITY || INACTIVE_OBJECT)
|
||||||
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
|
|
||||||
|
|
||||||
if (CLEAR_EVENT || INACTIVE_OBJECT)
|
|
||||||
eventIter = container.erase(eventIter);
|
eventIter = container.erase(eventIter);
|
||||||
else
|
else
|
||||||
++eventIter;
|
++eventIter;
|
||||||
|
|
|
@ -380,6 +380,11 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* physicsObject = system->GetPhysicsObject(GetEID());
|
auto* physicsObject = system->GetPhysicsObject(GetEID());
|
||||||
|
if (!physicsObject)
|
||||||
|
{
|
||||||
|
SHLOGV_ERROR("Unable to retrieve physics object of Entity {}", GetEID())
|
||||||
|
return;
|
||||||
|
}
|
||||||
physicsObject->GetRigidBody()->setLinearVelocity(newLinearVelocity);
|
physicsObject->GetRigidBody()->setLinearVelocity(newLinearVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +399,11 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* physicsObject = system->GetPhysicsObject(GetEID());
|
auto* physicsObject = system->GetPhysicsObject(GetEID());
|
||||||
|
if (!physicsObject)
|
||||||
|
{
|
||||||
|
SHLOGV_ERROR("Unable to retrieve physics object of Entity {}", GetEID())
|
||||||
|
return;
|
||||||
|
}
|
||||||
physicsObject->GetRigidBody()->setAngularVelocity(newAngularVelocity);
|
physicsObject->GetRigidBody()->setAngularVelocity(newAngularVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,14 @@ namespace SHADE
|
||||||
objectManager.AddRigidBody(EID);
|
objectManager.AddRigidBody(EID);
|
||||||
|
|
||||||
if (SHComponentManager::HasComponent<SHColliderComponent>(EID))
|
if (SHComponentManager::HasComponent<SHColliderComponent>(EID))
|
||||||
|
{
|
||||||
objectManager.AddCollider(EID);
|
objectManager.AddCollider(EID);
|
||||||
|
|
||||||
|
auto* COLLIDER = SHComponentManager::GetComponent<SHColliderComponent>(EID);
|
||||||
|
for (size_t i = 0; i < COLLIDER->GetCollisionShapes().size(); ++i)
|
||||||
|
objectManager.AddCollisionShape(EID, i);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -156,6 +163,8 @@ namespace SHADE
|
||||||
// Destroy an existing world
|
// Destroy an existing world
|
||||||
if (worldState.world != nullptr)
|
if (worldState.world != nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
objectManager.RemoveAllObjects();
|
objectManager.RemoveAllObjects();
|
||||||
objectManager.SetWorld(nullptr);
|
objectManager.SetWorld(nullptr);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace SHADE
|
||||||
auto phySystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
auto phySystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
||||||
if (phySystem)
|
if (phySystem)
|
||||||
{
|
{
|
||||||
return phySystem->GetFixedUpdateRate();
|
return 1.0 / phySystem->GetFixedUpdateRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SHLOGV_WARNING("Failed to get fixed delta time. 0.0 returned instead.");
|
SHLOGV_WARNING("Failed to get fixed delta time. 0.0 returned instead.");
|
||||||
|
|
|
@ -140,9 +140,10 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
const double FIXED_DT = physicsSystem->fixedDT;
|
const double FIXED_DT = physicsSystem->fixedDT;
|
||||||
//to be remove =======================================================
|
// HACK: Clamp DT here to prevent a ridiculous amount of updates. This limits updates from large dt to 2.
|
||||||
|
// HACK: This should be done by the FRC and not here for predictable behaviour.
|
||||||
|
|
||||||
dt = std::clamp(dt, 0.0, 1.0 / 30.0);
|
dt = std::clamp(dt, 0.0, 1.0 / 30.0);
|
||||||
//to be remove =======================================================
|
|
||||||
accumulatedTime += dt;
|
accumulatedTime += dt;
|
||||||
|
|
||||||
//testFunction();
|
//testFunction();
|
||||||
|
@ -394,13 +395,13 @@ void testFunction()
|
||||||
if (rb)
|
if (rb)
|
||||||
{
|
{
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::W))
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::W))
|
||||||
rb->AddForce(-SHVec3::UnitZ * forceModifier);
|
rb->AddForce(SHVec3::UnitZ * forceModifier);
|
||||||
|
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A))
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A))
|
||||||
rb->AddForce(-SHVec3::UnitX * forceModifier);
|
rb->AddForce(-SHVec3::UnitX * forceModifier);
|
||||||
|
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::S))
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::S))
|
||||||
rb->AddForce(SHVec3::UnitZ * forceModifier);
|
rb->AddForce(-SHVec3::UnitZ * forceModifier);
|
||||||
|
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::D))
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::D))
|
||||||
rb->AddForce(SHVec3::UnitX * forceModifier);
|
rb->AddForce(SHVec3::UnitX * forceModifier);
|
||||||
|
|
Loading…
Reference in New Issue