Added capsule collider component

This commit is contained in:
Antoine Pilote
2023-04-02 19:01:40 -04:00
parent 17849584e5
commit 80eadc2a5a
9 changed files with 144 additions and 46 deletions

View File

@@ -1,6 +1,7 @@
#include "PhysicsSystem.h"
#include "src/Scene/Scene.h"
#include "src/Scene/Components/BoxCollider.h"
#include "src/Scene/Components/CapsuleColliderComponent.h"
#include "src/Scene/Components/SphereCollider.h"
#include "src/Scene/Components/MeshCollider.h"
#include "src/Scene/Components/ModelComponent.h"
@@ -39,6 +40,17 @@ namespace Nuake
PhysicsManager::Get()->RegisterBody(rigidBody);
}
if (ent.HasComponent<CapsuleColliderComponent>())
{
auto& capsuleComponent = ent.GetComponent<CapsuleColliderComponent>();
float radius = capsuleComponent.Radius;
float height = capsuleComponent.Height;
auto capsuleShape = CreateRef<Physics::Capsule>(radius, height);
rigidBody = CreateRef<Physics::RigidBody>(rigidBodyComponent.Mass, transform.GetGlobalPosition(), transform.GetGlobalTransform(), capsuleShape, ent);
PhysicsManager::Get()->RegisterBody(rigidBody);
}
if (ent.HasComponent<SphereColliderComponent>())
{
float mass = rigidBodyComponent.Mass;