draws bounding box + contours

This commit is contained in:
arthur.jamet
2021-06-14 13:59:05 +02:00
parent a3236ffba6
commit a36ab11b6d
2 changed files with 21 additions and 4 deletions
+17 -4
View File
@@ -11,8 +11,8 @@
#include <Model/Model.hpp>
#include "Drawables/ADrawable3D.hpp"
#include "Component/Shaders/ShaderComponent.hpp"
#include <Drawables/3D/Cube.hpp>
#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<CollisionComponent>();
//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();
}
+4
View File
@@ -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