From 48362761aae8765d96932d09ac2ff76cbda2a5b6 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Thu, 22 Feb 2024 21:20:10 -0500 Subject: [PATCH] Fixup some of the drawing stuff and set a specific color for them --- src/engine/EngineContext.cpp | 4 ++-- src/engine/debug/drawers.cpp | 25 ++++++++++++--------- src/engine/debug/tracy_colors.hpp | 11 +++++++++ src/engine/systems/EntityRendererSystem.cpp | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 src/engine/debug/tracy_colors.hpp diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index fdb39e3..25a65db 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -470,9 +470,9 @@ namespace fgl::engine m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; - for ( int x = 0; x < 1; ++x ) + for ( int x = 0; x < 32; ++x ) { - for ( int y = 0; y < 1; ++y ) + for ( int y = 0; y < 32; ++y ) { auto sponza = GameObject::createGameObject(); sponza.model = model; diff --git a/src/engine/debug/drawers.cpp b/src/engine/debug/drawers.cpp index af317b1..ff35410 100644 --- a/src/engine/debug/drawers.cpp +++ b/src/engine/debug/drawers.cpp @@ -8,6 +8,7 @@ #include "engine/model/BoundingBox.hpp" #include "engine/primitives/Line.hpp" #include "engine/primitives/Vector.hpp" +#include "tracy_colors.hpp" namespace fgl::engine::debug { @@ -19,7 +20,7 @@ namespace fgl::engine::debug Coordinate< CoordinateSpace::Screen > toScreenSpace( Coordinate< CoordinateSpace::World > world_point, const Camera& camera ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const ImVec2 window_size { windowSize() }; const Coordinate< CoordinateSpace::Screen > screen_point { glm::projectZO( @@ -58,7 +59,7 @@ namespace fgl::engine::debug { void drawBoundingBox( const BoundingBox< CoordinateSpace::World >& box, Camera& camera, const glm::vec3 color ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); for ( const auto [ p1, p2 ] : box.lines() ) { drawLine( p1, p2, camera, color ); @@ -72,7 +73,7 @@ namespace fgl::engine::debug void drawLine( const Line< CoordinateSpace::World > line, const Camera& camera, const glm::vec3 color ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const Coordinate< CoordinateSpace::Screen > start_screen { toScreenSpace( line.start, camera ) }; const Coordinate< CoordinateSpace::Screen > end_screen { toScreenSpace( line.end, camera ) }; @@ -90,13 +91,14 @@ namespace fgl::engine::debug const Camera& camera, const glm::vec3 color ) { + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); drawLine( { start, end }, camera, color ); } void drawPointText( const Coordinate< CoordinateSpace::World > point, const Camera& camera, const glm::vec3 color ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const glm::vec3 screen_point { toScreenSpace( point, camera ) }; if ( !inView( screen_point ) ) return; @@ -123,7 +125,7 @@ namespace fgl::engine::debug void drawPointLabel( const Coordinate< CoordinateSpace::World > point, const std::string label, const Camera& camera ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const glm::vec3 screen_point { toScreenSpace( point, camera ) }; if ( !inView( screen_point ) ) return; @@ -137,7 +139,7 @@ namespace fgl::engine::debug const std::string label, const glm::vec3 color ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const auto screen_point { toScreenSpace( point, camera ) }; if ( !inView( screen_point ) ) return; @@ -153,7 +155,7 @@ namespace fgl::engine::debug const bool value, const glm::vec2 offset ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const auto screen_point { toScreenSpace( point, camera ) }; const auto color { value ? glm::vec3( 0.0f, 1.0f, 0.0f ) : glm::vec3( 1.0f, 0.0f, 0.0f ) }; @@ -168,6 +170,7 @@ namespace fgl::engine::debug const std::string label, const glm::vec3 color ) { + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); drawLine( point, point + glm::normalize( vector ), camera, color ); drawPoint( point + glm::normalize( vector ), camera, label, color ); drawPointLabel( point, label, camera ); @@ -195,6 +198,7 @@ namespace fgl::engine::debug void drawFrustum( const Frustum< CoordinateSpace::World >& frustum, const Camera& camera, const WorldCoordinate point ) { + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); drawPlane( frustum.near, point, camera, "near" ); drawPlane( frustum.far, point, camera, "far" ); drawPlane( frustum.top, point, camera, "top" ); @@ -205,6 +209,7 @@ namespace fgl::engine::debug void drawFrustum( const Camera& camera ) { + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const Frustum frustum { camera.getFrustumBounds() }; drawFrustum( frustum, camera, camera.getFrustumPosition() ); } @@ -216,7 +221,7 @@ namespace fgl::engine::debug const std::string label, const glm::vec3 color ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const auto normal { plane.direction() }; assert( point != constants::DEFAULT_VEC3 ); @@ -232,7 +237,7 @@ namespace fgl::engine::debug void drawText( const glm::vec2 position, const std::string& text, const glm::vec3 color, const glm::vec2 offset ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); ImGui::GetForegroundDrawList() ->AddText( glmToImgui( position + offset ), ImColor( color.x, color.y, color.z ), text.c_str() ); } @@ -240,7 +245,7 @@ namespace fgl::engine::debug void drawBoolAlpha( const glm::vec2 screen_point, const Camera& camera, const bool value, const glm::vec2 offset ) { - ZoneScoped; + ZoneScopedC( TRACY_DRAWER_FUNC_COLOR ); const auto color { value ? glm::vec3( 0.0f, 1.0f, 0.0f ) : glm::vec3( 1.0f, 0.0f, 0.0f ) }; drawText( glm::vec2( screen_point.x, screen_point.y + offset.y ), value ? "true" : "false", color ); } diff --git a/src/engine/debug/tracy_colors.hpp b/src/engine/debug/tracy_colors.hpp new file mode 100644 index 0000000..97d50e2 --- /dev/null +++ b/src/engine/debug/tracy_colors.hpp @@ -0,0 +1,11 @@ +// +// Created by kj16609 on 2/22/24. +// + +#pragma once + +namespace fgl::engine +{ + constexpr int TRACY_DRAWER_FUNC_COLOR { 0x00FF00 }; + +} diff --git a/src/engine/systems/EntityRendererSystem.cpp b/src/engine/systems/EntityRendererSystem.cpp index f20274f..0e255f1 100644 --- a/src/engine/systems/EntityRendererSystem.cpp +++ b/src/engine/systems/EntityRendererSystem.cpp @@ -101,7 +101,7 @@ namespace fgl::engine debug::world::drawBoundingBox( model_bounding_box, info.camera ); - //if ( !model_bounding_box.isInFrustum( info.camera_frustum ) ) continue; + if ( !model_bounding_box.isInFrustum( info.camera_frustum ) ) continue; for ( const auto& primitive : obj.model->m_primitives ) {