Collision 1/2

This commit is contained in:
Isuru Samarathunga
2025-09-29 03:36:31 +05:30
parent 3380eb993e
commit 5f112f7531
6 changed files with 210 additions and 3 deletions

View File

@ -23,6 +23,8 @@
namespace ia::iae
{
Vector<PhysicsComponent *> g_physicsComponents;
VOID Physics::Initialize()
{
}
@ -34,4 +36,27 @@ namespace ia::iae
VOID Physics::Update()
{
}
Handle Physics::RegisterComponent(IN PhysicsComponent *component)
{
g_physicsComponents.pushBack(component);
return g_physicsComponents.size() - 1;
}
BOOL Physics::CanMove(IN Handle handle, IN CONST PhysicsComponent::Collider &collider, IN glm::vec2 movement)
{
const auto comp = g_physicsComponents[handle];
const auto middle = comp->GetNode()->GetPosition() + movement + collider.Position + collider.Size / 2.0f;
for (const auto &t : g_physicsComponents)
{
if (t == comp)
continue;
for(const auto& tc: t->Colliders())
{
const auto tMiddle = t->GetNode()->GetPosition() + tc.Position + tc.Size / 2.0f;
}
}
return true;
}
} // namespace ia::iae