Debug: red bounding boxes when colliding
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
void Systems::CollisionSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::CollisionSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
if (parent != 0)
|
/*if (parent != 0)
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
auto transform = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
||||||
auto parentTransform = m_World->GetComponent<Components::Transform>(parent, "Transform");
|
auto parentTransform = m_World->GetComponent<Components::Transform>(parent, "Transform");
|
||||||
@@ -11,8 +11,14 @@ void Systems::CollisionSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
transform->Position[0] += parentTransform->Position[0];
|
transform->Position[0] += parentTransform->Position[0];
|
||||||
transform->Position[1] += parentTransform->Position[1];
|
transform->Position[1] += parentTransform->Position[1];
|
||||||
transform->Position[2] += parentTransform->Position[2];
|
transform->Position[2] += parentTransform->Position[2];
|
||||||
}
|
}*/
|
||||||
LOG_INFO("Updating entity %i with parent %i", entity, parent);
|
|
||||||
|
auto collisionComponent = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||||
|
if (!collisionComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Clear old collisions
|
||||||
|
collisionComponent->CollidingEntities.clear();
|
||||||
|
|
||||||
auto entities = m_World->GetEntities();
|
auto entities = m_World->GetEntities();
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||||
if(collision->CollidingEntities.size() != 0)
|
if(collision->CollidingEntities.size() > 0) {
|
||||||
int c = 1; // lol
|
// DO STUFF
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,12 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
|
|
||||||
// Debug draw bounds
|
// Debug draw bounds
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||||
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
||||||
if (bounds != nullptr) {
|
if (bounds != nullptr) {
|
||||||
glm::vec3 origin = transformComponent->Position + (transformComponent->Scale * bounds->Origin);
|
glm::vec3 origin = transformComponent->Position + (transformComponent->Scale * bounds->Origin);
|
||||||
glm::vec3 volumeVector = transformComponent->Scale * bounds->VolumeVector;
|
glm::vec3 volumeVector = transformComponent->Scale * bounds->VolumeVector;
|
||||||
m_Renderer->AddAABBToDraw(origin, volumeVector, true);
|
m_Renderer->AddAABBToDraw(origin, volumeVector, (collision != nullptr && collision->CollidingEntities.size() > 0));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
#include "Components/Camera.h"
|
#include "Components/Camera.h"
|
||||||
#include "Components/Bounds.h"
|
#include "Components/Bounds.h"
|
||||||
|
#include "Components/Collision.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
|
|||||||
Reference in New Issue
Block a user