Fixup some of the drawing stuff and set a specific color for them

This commit is contained in:
2024-02-22 21:20:10 -05:00
parent 47bbeb0b32
commit 48362761aa
4 changed files with 29 additions and 13 deletions

View File

@@ -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;

View File

@@ -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 );
}

View File

@@ -0,0 +1,11 @@
//
// Created by kj16609 on 2/22/24.
//
#pragma once
namespace fgl::engine
{
constexpr int TRACY_DRAWER_FUNC_COLOR { 0x00FF00 };
}

View File

@@ -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 )
{