Added sphere collider + serialization

This commit is contained in:
antopilo
2023-03-08 21:24:58 -05:00
parent d50b04be28
commit 0a6f7ad733
3 changed files with 34 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#include "src/Scene/Scene.h"
#include "src/Scene/Components/BoxCollider.h"
#include "src/Scene/Components/SphereCollider.h"
#include "src/Scene/Components/MeshCollider.h"
#include <src/Scene/Components/RigidbodyComponent.h>
#include "src/Scene/Entities/Entity.h"
@@ -35,6 +36,18 @@ namespace Nuake
Ref<Physics::Box> boxShape = CreateRef<Physics::Box>(boxComponent.Size);
rigidBody = CreateRef<Physics::RigidBody>(mass, transform.GetGlobalPosition(), boxShape, ent);
PhysicsManager::Get()->RegisterBody(rigidBody);
}
if (ent.HasComponent<SphereColliderComponent>())
{
float mass = rigidbody.Mass;
const auto& component = ent.GetComponent<SphereColliderComponent>();
auto shape = CreateRef<Physics::Sphere>(component.Radius);
rigidBody = CreateRef<Physics::RigidBody>(mass, transform.GetGlobalPosition(), shape, ent);
PhysicsManager::Get()->RegisterBody(rigidBody);
}
if (ent.HasComponent<SphereColliderComponent>())