From dab51ee4cf6b128a4b5bdfd2a070c1c95360d635 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Tue, 22 Nov 2022 20:00:58 +0800 Subject: [PATCH] Readded testing function in physics routines for future use --- .../System/SHPhysicsSystemRoutines.cpp | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp index 8ddbbcc9..45f236f3 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp @@ -21,6 +21,13 @@ #include "Input/SHInputManager.h" +/*-------------------------------------------------------------------------------------*/ +/* Local Functions */ +/*-------------------------------------------------------------------------------------*/ + +void testFunction(); + +///////////////////////////////////////////////////////////////////////////////////////// namespace SHADE { @@ -135,7 +142,7 @@ namespace SHADE const double FIXED_DT = physicsSystem->fixedDT; accumulatedTime += dt; - testFunction(); + //testFunction(); int count = 0; while (accumulatedTime > FIXED_DT) @@ -359,5 +366,32 @@ namespace SHADE } } // namespace SHADE +///////////////////////////////////////////////////////////////////////////////////////// +void testFunction() +{ + using namespace SHADE; + // Test movement + const float forceModifier = 25.0f; + EntityID eid = 65538; + + if (SHEntityManager::IsValidEID(eid)) + { + auto* rb = SHComponentManager::GetComponent_s(eid); + if (rb) + { + if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::W)) + rb->AddForce(-SHVec3::UnitZ * forceModifier); + + if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A)) + rb->AddForce(-SHVec3::UnitX * forceModifier); + + if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::S)) + rb->AddForce(SHVec3::UnitZ * forceModifier); + + if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::D)) + rb->AddForce(SHVec3::UnitX * forceModifier); + } + } +}