Fixed various physics bugs and added Physics Material to Inspector #249

Merged
direnbharwani merged 7 commits from SP3-2-Physics into main 2022-11-22 20:14:31 +08:00
1 changed files with 35 additions and 1 deletions
Showing only changes of commit dab51ee4cf - Show all commits

View File

@ -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<SHRigidBodyComponent>(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);
}
}
}