From a36ab11b6d38e94321d9e9e7af3b56715712b379 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Mon, 14 Jun 2021 13:59:05 +0200 Subject: [PATCH] draws bounding box + contours --- sources/System/Renderer/RenderSystem.cpp | 21 +++++++++++++++++---- sources/System/Renderer/RenderSystem.hpp | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sources/System/Renderer/RenderSystem.cpp b/sources/System/Renderer/RenderSystem.cpp index d901b115..b6a6e735 100644 --- a/sources/System/Renderer/RenderSystem.cpp +++ b/sources/System/Renderer/RenderSystem.cpp @@ -11,8 +11,8 @@ #include #include "Drawables/ADrawable3D.hpp" #include "Component/Shaders/ShaderComponent.hpp" - - +#include +#include "Models/Vector3.hpp" #include "Component/Collision/CollisionComponent.hpp" namespace BBM @@ -26,6 +26,19 @@ namespace BBM this->_window.setFPS(this->FPS); } + void RenderSystem::drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const + { + auto *dimsComponent = entity.tryGetComponent(); + + //draws hitbox + if (dimsComponent) { + RAY::Drawables::Drawables3D::Cube boundingBox(posComponent.position, dimsComponent->bound, WHITE); + boundingBox.drawWiresOn(this->_window); + } + //draws models contours + drawable.drawable->drawWiresOn(this->_window); + } + void RenderSystem::onSelfUpdate() { this->_camera.update(); @@ -39,9 +52,9 @@ namespace BBM if (modelShader) modelShader->model->setShader(modelShader->getShader()); drawable.drawable->setPosition(pos.position); - drawable.drawable->drawOn(this->_window); if (this->_debugMode) - drawable.drawable->drawWiresOn(this->_window); + this->drawBoundingBox(entity, pos, drawable); + drawable.drawable->drawOn(this->_window); if (modelShader) modelShader->model->resetShader(); } diff --git a/sources/System/Renderer/RenderSystem.hpp b/sources/System/Renderer/RenderSystem.hpp index e790a741..bff17267 100644 --- a/sources/System/Renderer/RenderSystem.hpp +++ b/sources/System/Renderer/RenderSystem.hpp @@ -6,6 +6,7 @@ #include "Component/Renderer/CameraComponent.hpp" #include "Component/Position/PositionComponent.hpp" +#include "Component/Renderer/Drawable3DComponent.hpp" #include "System/System.hpp" #include "Camera/Camera2D.hpp" #include "Window.hpp" @@ -39,6 +40,9 @@ namespace BBM //! @param debug true if debug mode should be enabled void setDebug(bool debug); + //! @param entity entity to draw bounding box of + void drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const; + //! @brief ctor RenderSystem(WAL::Wal &wal, RAY::Window &window, bool debugMode = false); //! @brief Default copy ctor