Cleanup a bunch of warnings

This commit is contained in:
2024-08-04 12:22:30 -04:00
parent 849a1283cf
commit b631c20c95
17 changed files with 86 additions and 135 deletions

View File

@@ -222,9 +222,7 @@ namespace fgl::engine
EngineContext::~EngineContext()
{
#if TITOR_EDITOR
gui::cleanupImGui();
#endif
cleanupImGui();
}
bool EngineContext::good()

View File

@@ -51,8 +51,8 @@ namespace fgl::engine
GuiSystem m_gui_system { Device::getInstance(), m_renderer.getSwapChainRenderPass() };
// Temp function
std::function< void( FrameInfo& ) > renderGui;
std::function< void() > cleanupImGui;
std::function< void( FrameInfo& ) > renderGui { []( [[maybe_unused]] FrameInfo& ) noexcept {} };
std::function< void() > cleanupImGui { []() noexcept {} };
// Memory pool for shader uniforms.
memory::Buffer m_ubo_buffer_pool;

View File

@@ -44,11 +44,4 @@
std::unreachable()
#else
#define FGL_UNREACHABLE() std::unreachable()
#endif
#ifndef FGL_TESTS
#define FGL_TESTED_ASSERT( ... ) FGL_ASSERT( __VA_ARGS__ );
#else
#include <catch2/src/catch2/catch_test_macros.hpp>
#define FGL_TESTED_ASSERT( ... ) REQUIRE( __VA_ARGS__ );
#endif
#endif

View File

@@ -84,11 +84,11 @@ namespace fgl::engine
if ( pitch_change > std::numeric_limits< float >::epsilon()
|| pitch_change < -std::numeric_limits< float >::epsilon() )
pitch_rotation.pitch() += static_cast< float >( dt * pitch_change );
pitch_rotation.pitch() += dt * pitch_change;
if ( yaw_change > std::numeric_limits< float >::epsilon()
|| yaw_change < -std::numeric_limits< float >::epsilon() )
yaw_rotation.yaw() += static_cast< float >( dt * yaw_change );
yaw_rotation.yaw() += dt * yaw_change;
target.getTransform().rotation = yaw_rotation * original_rotation * pitch_rotation;
}

View File

@@ -12,7 +12,6 @@
#include "CameraInfo.hpp"
#include "CameraRenderer.hpp"
#include "CameraSwapchain.hpp"
#include "engine/logging/formatters/glm_formatters.hpp"
namespace fgl::engine
{
@@ -305,9 +304,11 @@ namespace fgl::engine
}
Camera::Camera( const vk::Extent2D extent, memory::Buffer& buffer ) :
m_transform(),
m_target_extent( extent ),
m_camera_frame_info( buffer, SwapChain::MAX_FRAMES_IN_FLIGHT ),
m_swapchain( std::make_shared< CameraSwapchain >( m_renderer->getRenderpass(), m_target_extent ) )
m_swapchain( std::make_shared< CameraSwapchain >( m_renderer->getRenderpass(), m_target_extent ) ),
name()
{
this->setPerspectiveProjection( m_fov_y, aspectRatio(), constants::NEAR_PLANE, constants::FAR_PLANE );
this->setView( WorldCoordinate( constants::CENTER ), Rotation( 0.0f, 0.0f, 0.0f ) );

View File

@@ -1,5 +0,0 @@
//
// Created by kj16609 on 8/2/24.
//
#include "glm_formatters.hpp"

View File

@@ -1,38 +0,0 @@
//
// Created by kj16609 on 8/2/24.
//
#pragma once
#include <glm/glm.hpp>
#include <format>
template <>
struct std::formatter< glm::mat4 >
{
constexpr format_parse_context::iterator parse( std::format_parse_context& ctx ) { return ctx.begin(); }
format_context::iterator format( const glm::mat4& mat4, format_context& ctx ) const
{
return std::format_to(
ctx.out(),
"mat4:\n\t[{}, {}, {}, {}]\n\t[{}, {}, {}, {}]\n\t[{}, {}, {}, {}]\n\t[{}, {}, {}, {}]",
mat4[ 0 ][ 0 ],
mat4[ 0 ][ 1 ],
mat4[ 0 ][ 2 ],
mat4[ 0 ][ 3 ],
mat4[ 1 ][ 0 ],
mat4[ 1 ][ 1 ],
mat4[ 1 ][ 2 ],
mat4[ 1 ][ 3 ],
mat4[ 2 ][ 0 ],
mat4[ 2 ][ 1 ],
mat4[ 2 ][ 2 ],
mat4[ 2 ][ 3 ],
mat4[ 3 ][ 0 ],
mat4[ 3 ][ 1 ],
mat4[ 3 ][ 2 ],
mat4[ 3 ][ 3 ] );
}
};

View File

@@ -8,6 +8,7 @@
#include "engine/primitives/boxes/AxisAlignedBoundingBox.hpp"
#include "engine/primitives/boxes/AxisAlignedBoundingCube.hpp"
#include "engine/primitives/boxes/OrientedBoundingBox.hpp"
#include "lines/InfiniteLine.hpp"
namespace fgl::engine
{
@@ -141,21 +142,47 @@ namespace fgl::engine
}
template < CoordinateSpace CType >
FGL_FORCE_INLINE Vector Frustum< CType >::forwardVec() const
FGL_FORCE_INLINE inline NormalVector Frustum< CType >::forwardVec() const
{
return near.direction();
return near.getDirection();
}
template < CoordinateSpace CType >
FGL_FORCE_INLINE Vector Frustum< CType >::upVec() const
FGL_FORCE_INLINE inline NormalVector Frustum< CType >::upVec() const
{
return glm::cross( forwardVec(), left.direction() );
return NormalVector( glm::cross( forwardVec().vec(), left.getDirection().vec() ) );
}
template < CoordinateSpace CType >
FGL_FORCE_INLINE Vector Frustum< CType >::rightVec() const
FGL_FORCE_INLINE inline NormalVector Frustum< CType >::rightVec() const
{
return glm::cross( forwardVec(), upVec() );
return NormalVector( glm::cross( forwardVec().vec(), upVec().vec() ) );
}
template < CoordinateSpace CType >
std::array< Coordinate< CType >, 4 * 2 > Frustum< CType >::points() const
{
const NormalVector pv0 { glm::cross( top.getDirection().vec(), left.getDirection().vec() ) };
const NormalVector pv1 { glm::cross( top.getDirection().vec(), right.getDirection().vec() ) };
const NormalVector pv2 { glm::cross( bottom.getDirection().vec(), left.getDirection().vec() ) };
const NormalVector pv3 { glm::cross( bottom.getDirection().vec(), right.getDirection().vec() ) };
const auto l0 { InfiniteLine< CoordinateSpace::World >( m_position, pv0 ) };
const auto l1 { InfiniteLine< CoordinateSpace::World >( m_position, pv1 ) };
const auto l2 { InfiniteLine< CoordinateSpace::World >( m_position, pv2 ) };
const auto l3 { InfiniteLine< CoordinateSpace::World >( m_position, pv3 ) };
const auto p0 { l0.intersection( far ) };
const auto p1 { l1.intersection( far ) };
const auto p2 { l2.intersection( far ) };
const auto p3 { l3.intersection( far ) };
const auto p4 { l0.intersection( near ) };
const auto p5 { l1.intersection( near ) };
const auto p6 { l2.intersection( near ) };
const auto p7 { l3.intersection( near ) };
return { { p0, p1, p2, p3, p4, p5, p6, p7 } };
}
template <>
@@ -358,4 +385,6 @@ namespace fgl::engine
return coordinate;
}
template struct Frustum< CoordinateSpace::World >;
} // namespace fgl::engine

View File

@@ -6,10 +6,9 @@
#include <ostream>
#include "engine/primitives/lines/InfiniteLine.hpp"
#include "engine/primitives/planes/OriginDistancePlane.hpp"
#include "engine/primitives/planes/PointPlane.hpp"
#include "engine/primitives/points/Coordinate.hpp"
#include "vectors/Vector.hpp"
namespace fgl::engine
{
@@ -57,9 +56,9 @@ namespace fgl::engine
m_position( position )
{}
FGL_FORCE_INLINE Vector forwardVec() const;
FGL_FORCE_INLINE Vector upVec() const;
FGL_FORCE_INLINE Vector rightVec() const;
FGL_FORCE_INLINE NormalVector forwardVec() const;
FGL_FORCE_INLINE NormalVector upVec() const;
FGL_FORCE_INLINE NormalVector rightVec() const;
Coordinate< CType > getPosition() const { return m_position; }
@@ -93,36 +92,7 @@ namespace fgl::engine
template < typename T >
Coordinate< CType > intersection( const T& t ) const;
std::array< Coordinate< CType >, 4 * 2 > points() const
{
const Vector pv0 { glm::cross( top.getDirection().vec(), left.getDirection().vec() ) };
const Vector pv1 { glm::cross( top.getDirection().vec(), right.getDirection().vec() ) };
const Vector pv2 { glm::cross( bottom.getDirection().vec(), left.getDirection().vec() ) };
const Vector pv3 { glm::cross( bottom.getDirection().vec(), right.getDirection().vec() ) };
const auto l0 { InfiniteLine< CoordinateSpace::World >( m_position, pv0 ) };
const auto l1 { InfiniteLine< CoordinateSpace::World >( m_position, pv1 ) };
const auto l2 { InfiniteLine< CoordinateSpace::World >( m_position, pv2 ) };
const auto l3 { InfiniteLine< CoordinateSpace::World >( m_position, pv3 ) };
const auto p0 { l0.intersection( far ) };
const auto p1 { l1.intersection( far ) };
const auto p2 { l2.intersection( far ) };
const auto p3 { l3.intersection( far ) };
const auto p4 { l0.intersection( near ) };
const auto p5 { l1.intersection( near ) };
const auto p6 { l2.intersection( near ) };
const auto p7 { l3.intersection( near ) };
return { { p0, p1, p2, p3, p4, p5, p6, p7 } };
}
bool operator==( const Frustum< CType >& other ) const
{
return near == other.near && far == other.far && top == other.top && bottom == other.bottom
&& right == other.right && left == other.left;
}
std::array< Coordinate< CType >, 4 * 2 > points() const;
};
#ifdef EXPOSE_FRUSTUM_INTERNALS

View File

@@ -39,7 +39,7 @@ namespace fgl::engine
InfiniteLine operator-() const { return InfiniteLine( m_start, -m_direction ); }
inline InfiniteLine flip() const { return -( *this ); }
InfiniteLine flip() const { return -( *this ); }
template < typename T >
requires is_plane< T >

View File

@@ -2,7 +2,10 @@
// Created by kj16609 on 2/28/24.
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <glm/ext/matrix_transform.hpp>
#pragma GCC diagnostic pop
#include "RotationMatrix.hpp"
#include "engine/primitives/vectors/NormalVector.hpp"

View File

@@ -40,37 +40,37 @@ namespace fgl::engine
explicit Coordinate( const float value ) : glm::vec3( value ) {}
explicit Coordinate( const Vector vector );
explicit Coordinate( Vector vector );
inline float& up() { return z; }
float& up() { return z; }
inline float up() const { return z; }
float up() const { return z; }
inline float& right() { return x; }
float& right() { return x; }
inline float right() const { return x; }
float right() const { return x; }
inline float& forward() { return y; }
float& forward() { return y; }
inline float forward() const { return y; }
float forward() const { return y; }
inline glm::vec3& vec() { return static_cast< glm::vec3& >( *this ); }
glm::vec3& vec() { return static_cast< glm::vec3& >( *this ); }
inline const glm::vec3& vec() const { return static_cast< const glm::vec3& >( *this ); }
const glm::vec3& vec() const { return static_cast< const glm::vec3& >( *this ); }
Coordinate operator+( const Vector other ) const;
Coordinate operator-( const Vector other ) const;
Coordinate& operator+=( const Vector other );
Coordinate& operator-=( const Vector other );
Coordinate operator+( Vector other ) const;
Coordinate operator-( Vector other ) const;
Coordinate& operator+=( Vector other );
Coordinate& operator-=( Vector other );
Coordinate operator+( const NormalVector other ) const;
Coordinate operator-( const NormalVector other ) const;
Coordinate operator+( NormalVector other ) const;
Coordinate operator-( NormalVector other ) const;
Coordinate operator+( const Coordinate other ) const;
Coordinate operator-( const Coordinate other ) const;
Coordinate operator+( Coordinate other ) const;
Coordinate operator-( Coordinate other ) const;
Coordinate operator+( const glm::vec3 other ) const;
Coordinate operator-( const glm::vec3 other ) const;
Coordinate operator+( glm::vec3 other ) const;
Coordinate operator-( glm::vec3 other ) const;
Coordinate& operator=( const Coordinate& other ) = default;
Coordinate& operator=( Coordinate&& other ) = default;
@@ -87,14 +87,13 @@ namespace fgl::engine
static_assert( sizeof( glm::vec3 ) == sizeof( ModelCoordinate ) );
template < CoordinateSpace CType >
inline double distance( const Coordinate< CType >& p1, const Coordinate< CType >& p2 )
double distance( const Coordinate< CType >& p1, const Coordinate< CType >& p2 )
{
return length( p1.vec() - p2.vec() );
}
template < engine::CoordinateSpace CType >
inline engine::Coordinate< CType >
midpoint( const engine::Coordinate< CType > left, const engine::Coordinate< CType > right )
template < CoordinateSpace CType >
Coordinate< CType > midpoint( const Coordinate< CType > left, const Coordinate< CType > right )
{
const auto x { ( left.vec().x + right.vec().x ) / 2.0f };
const auto y { ( left.vec().y + right.vec().y ) / 2.0f };

View File

@@ -9,7 +9,7 @@
namespace fgl::engine
{
constexpr NormalVector::NormalVector( const glm::vec3 vector ) : glm::vec3( glm::normalize( vector ) )
NormalVector::NormalVector( const glm::vec3 vector ) : glm::vec3( glm::normalize( vector ) )
{}
NormalVector::NormalVector( const fgl::engine::Vector vector ) : NormalVector( vector.vec() )

View File

@@ -27,18 +27,18 @@ namespace fgl::engine
public:
const glm::vec3& vec() const { return static_cast< const glm::vec3& >( *this ); }
glm::vec3& vec() { return static_cast< glm::vec3& >( *this ); }
//TODO: Make my own normalize function to bypass the fact glm::normalize can't be constexpr
NormalVector() : glm::vec3( glm::normalize( glm::vec3( 1.0f ) ) ) {}
NormalVector( const NormalVector& other ) = default;
NormalVector( const Vector vec );
explicit NormalVector( const Vector vec );
explicit constexpr NormalVector( const glm::vec3 vec );
explicit NormalVector( const glm::vec3 vec );
const glm::vec3& vec() const { return static_cast< const glm::vec3& >( *this ); }
glm::vec3& vec() { return static_cast< glm::vec3& >( *this ); }
Vector operator*( const float scalar ) const;

View File

@@ -243,7 +243,7 @@ namespace fgl::engine::rendering
}
info.setSubpasses( subpass_descriptions );
info.setSubpassCount( subpass_descriptions.size() );
// info.setSubpassCount( subpass_descriptions.size() );
info.setDependencies( subpass_dependencies );
info.setAttachments( m_attachment_descriptions );

View File

@@ -159,7 +159,8 @@ namespace fgl::engine
throw std::runtime_error( "failed to present swap chain image!" );
}
m_current_frame_index = ( m_current_frame_index + 1 ) % MAX_FRAMES_IN_FLIGHT;
m_current_frame_index = static_cast<
FrameIndex >( ( m_current_frame_index + static_cast< FrameIndex >( 1 ) ) % MAX_FRAMES_IN_FLIGHT );
return vk::Result::eSuccess;
}

View File

@@ -62,7 +62,7 @@ namespace fgl::engine
void EntityRendererSystem::pass( FrameInfo& info )
{
ZoneScopedN( "Entity pass" );
auto& command_buffer { setupSystem( info ) };
[[maybe_unused]] auto& command_buffer { setupSystem( info ) };
TracyVkZone( info.tracy_ctx, *command_buffer, "Render entities" );
texturelessPass( info );