Implemented a custom physics engine #316

Merged
direnbharwani merged 95 commits from SHPhysics into main 2023-01-23 15:55:45 +08:00
2 changed files with 8 additions and 1 deletions
Showing only changes of commit 27c7a17397 - Show all commits

View File

@ -17,6 +17,7 @@
#include "Events/SHEvent.h"
#include "Math/SHMathHelpers.h"
#include "Physics/SHPhysicsEvents.h"
#include "Physics/Dynamics/SHRigidBody.h"
namespace SHADE
@ -277,6 +278,9 @@ namespace SHADE
SHEventManager::BroadcastEvent<SHPhysicsColliderAddedEvent>(EVENT_DATA, SH_PHYSICS_COLLIDER_ADDED_EVENT);
if (rigidBody)
rigidBody->ComputeMassData();
return static_cast<int>(shapes.size());
}
@ -316,6 +320,9 @@ namespace SHADE
// Broadcast Event for removing a shape
SHEventManager::BroadcastEvent<SHPhysicsColliderRemovedEvent>(EVENT_DATA, SH_PHYSICS_COLLIDER_REMOVED_EVENT);
if (rigidBody)
rigidBody->ComputeMassData();
SHLOG_INFO_D("Removing Collision Shape {} from Entity {}", index, entityID)
}

View File

@ -598,7 +598,7 @@ namespace SHADE
const SHMatrix ROTATION = SHMatrix::Rotate(motionState.orientation);
// Compute world inertia
worldInvInertia = ROTATION * localInvInertia * SHMatrix::Transpose(ROTATION);
worldInvInertia = SHMatrix::Transpose(ROTATION) * localInvInertia * ROTATION;
// Compute world centroid
worldCentroid = (ROTATION * localCentroid) + motionState.position;