More major cleanup
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <concepts>
|
||||
#include <numeric>
|
||||
|
||||
template < typename T, std::uint64_t max_count = 100 >
|
||||
@@ -18,7 +17,7 @@ class Average
|
||||
|
||||
consteval std::uint64_t count() const { return max_count; }
|
||||
|
||||
void FGL_FLATTEN push( const T t )
|
||||
FGL_FLATTEN void push( const T t )
|
||||
{
|
||||
std::call_once( flag, [ this, t ]() { std::fill( data.begin(), data.end(), t ); } );
|
||||
std::shift_right( data.begin(), data.end(), 1 );
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace fgl::engine
|
||||
//TODO: Figure out frustum culling for orthographic projection. (If we even wanna use it)
|
||||
}
|
||||
|
||||
void FGL_FLATTEN_HOT Camera::setPerspectiveProjection( float fovy, float aspect, float near, float far )
|
||||
FGL_FLATTEN_HOT void Camera::setPerspectiveProjection( float fovy, float aspect, float near, float far )
|
||||
{
|
||||
projection_matrix = Matrix< MatrixType::CameraToScreen >( glm::perspectiveLH_ZO( fovy, aspect, near, far ) );
|
||||
|
||||
base_frustum = createFrustum( aspect, fovy, near, far );
|
||||
}
|
||||
|
||||
void FGL_FLATTEN_HOT Camera::setView( WorldCoordinate pos, const Rotation rotation, const ViewMode mode )
|
||||
FGL_FLATTEN_HOT void Camera::setView( WorldCoordinate pos, const Rotation rotation, const ViewMode mode )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
@@ -66,17 +66,11 @@ namespace fgl::engine
|
||||
|
||||
void Camera::updateFrustum()
|
||||
{
|
||||
if ( update_frustums ) [[likely]]
|
||||
{
|
||||
last_frustum_pos = getPosition();
|
||||
last_frustum_pos = getPosition();
|
||||
|
||||
const Matrix< MatrixType::ModelToWorld > translation_matrix { frustumTranslationMatrix() };
|
||||
const Matrix< MatrixType::ModelToWorld > translation_matrix { frustumTranslationMatrix() };
|
||||
|
||||
frustum = translation_matrix * base_frustum;
|
||||
return;
|
||||
}
|
||||
else [[unlikely]]
|
||||
return;
|
||||
frustum = translation_matrix * base_frustum;
|
||||
}
|
||||
|
||||
Frustum< CoordinateSpace::Model >
|
||||
|
||||
@@ -14,35 +14,23 @@
|
||||
#define FGL_DELETE_ALL_Ro5( ClassName ) \
|
||||
FGL_DELETE_DEFAULT_CTOR( ClassName ) FGL_DELETE_COPY( ClassName ) FGL_DELETE_MOVE( ClassName )
|
||||
|
||||
#ifndef FGL_FORCE_NOTHING
|
||||
//#define FGL_FLATTEN __attribute__( ( flatten ) )
|
||||
#define FGL_FLATTEN [[gnu::flatten]]
|
||||
#define FGL_ARTIFICIAL [[gnu::artificial]]
|
||||
#define FGL_HOT [[gnu::hot]]
|
||||
#define FGL_COLD [[gnu::cold]]
|
||||
#define FGL_FLATTEN_HOT FGL_FLATTEN FGL_HOT
|
||||
#define FGL_FORCE_INLINE [[gnu::always_inline]]
|
||||
#define FGL_FORCE_INLINE_FLATTEN FGL_FLATTEN FGL_FORCE_INLINE
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define FGL_FLATTEN __attribute__( ( flatten ) )
|
||||
#define FGL_FLATTEN_HOT __attribute__( ( flatten, hot ) )
|
||||
#define FGL_ARTIFICIAL __attribute__( ( artificial ) )
|
||||
#define FGL_HOT __attribute__( ( hot ) )
|
||||
#define FGL_COLD __attribute__( ( cold ) )
|
||||
#define FGL_FORCE_INLINE __attribute__( ( always_inline ) )
|
||||
#define FGL_FORCE_INLINE_FLATTEN __attribute__( ( always_inline, flatten ) )
|
||||
#define FGL_ASSUME( ... ) __attribute__( ( assume( __VA_ARGS__ ) ) )
|
||||
#define FGL_ASSUME( ... ) [[gnu::assume( __VA_ARGS__ )]]
|
||||
|
||||
#define FGL_ALIGN( bytesize ) __attribute__( ( alligned( bitsize ) ) )
|
||||
#define FGL_ALIGN( bytesize ) [[gnu::alligned( bitsize )]]
|
||||
|
||||
#define FGL_FUNC_CLEANUP( func ) __attribute__( ( cleanup( func ) ) )
|
||||
#define FGL_FUNC_CLEANUP( func ) [[gnu::cleanup( func )]]
|
||||
|
||||
//! Warns if the variable is used as a string (strlen)
|
||||
#define FGL_NONSTRING_DATA __attribute__( ( nonstring ) )
|
||||
#define FGL_NONSTRING_DATA [[gnu::nonstring]]
|
||||
|
||||
//! Warns if the structure field is not alligned with a set number of bytes
|
||||
#define FGL_STRICT_ALIGNMENT( bytesize ) __attribute__( ( warn_if_not_aligned( bytesize ) ) )
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define FGL_FLATTEN
|
||||
#define FGL_FLATTEN_HOT
|
||||
#define FGL_FORCE_INLINE
|
||||
#define FGL_FORCE_INLINE_FLATTEN
|
||||
|
||||
#endif
|
||||
#define FGL_STRICT_ALIGNMENT( bytesize ) [[gnu::warn_if_not_aligned( bytesize )]]
|
||||
@@ -31,7 +31,7 @@ namespace fgl::engine
|
||||
auto& scale { this->m_transform.scale };
|
||||
gui::dragFloat3( "Scale", scale );
|
||||
|
||||
for ( const GameObjectComponentBase* component : components )
|
||||
for ( [[maybe_unused]] const GameObjectComponentBase* component : components )
|
||||
{
|
||||
//TODO: Draw components
|
||||
}
|
||||
|
||||
@@ -100,8 +100,6 @@ namespace fgl::engine
|
||||
std::shared_ptr< Model > m_model { nullptr };
|
||||
std::string name {};
|
||||
|
||||
private:
|
||||
|
||||
GameObject( GameObjectID obj_id ) : m_id( obj_id ) {}
|
||||
|
||||
FGL_DELETE_DEFAULT_CTOR( GameObject );
|
||||
@@ -153,10 +151,10 @@ namespace fgl::engine
|
||||
//Misc
|
||||
static GameObject createGameObject();
|
||||
|
||||
inline GameObjectID getId() const { return m_id; }
|
||||
GameObjectID getId() const { return m_id; }
|
||||
|
||||
//! Returns the name of the game object. If no name is set then the name of the model is used.
|
||||
inline std::string& getName()
|
||||
std::string& getName()
|
||||
{
|
||||
if ( name.empty() && m_model )
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace fgl::engine
|
||||
|
||||
GLFWwindow* window() const { return m_window; }
|
||||
|
||||
Window( const int w, const int h, std::string window_name );
|
||||
Window( int w, int h, std::string window_name );
|
||||
Window() = delete;
|
||||
Window( const Window& other ) = delete;
|
||||
Window( Window&& other ) = delete;
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
// In order to monitor memory we need to overload the new and delete operators
|
||||
|
||||
#ifndef TRACY_ENABLE
|
||||
#define TRACY_ENABLE 0
|
||||
#endif
|
||||
|
||||
#if TRACY_ENABLE
|
||||
|
||||
void* operator new( std::size_t count )
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_vulkan.h>
|
||||
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -90,7 +91,6 @@ namespace fgl::engine::gui
|
||||
//ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ImGui DockBuilder is still very much not ready for use.
|
||||
void prepareDock()
|
||||
@@ -176,7 +176,7 @@ namespace fgl::engine::gui
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void drawEntityInfo( FrameInfo& info )
|
||||
void drawEntityInfo( [[maybe_unused]] FrameInfo& info )
|
||||
{
|
||||
ZoneScoped;
|
||||
ImGui::Begin( "Entity info" );
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace fgl::engine::gui
|
||||
{
|
||||
default:
|
||||
[[fallthrough]];
|
||||
case filesystem::BINARY:
|
||||
[[fallthrough]];
|
||||
case filesystem::UNKNOWN:
|
||||
spdlog::warn( "Unknown filetype dropped into rendering view acceptor" );
|
||||
break;
|
||||
|
||||
@@ -55,11 +55,9 @@ namespace fgl::engine
|
||||
m_position( position )
|
||||
{}
|
||||
|
||||
Vector FGL_FORCE_INLINE forwardVec() const;
|
||||
|
||||
Vector FGL_FORCE_INLINE upVec() const;
|
||||
|
||||
Vector FGL_FORCE_INLINE rightVec() const;
|
||||
FGL_FORCE_INLINE Vector forwardVec() const;
|
||||
FGL_FORCE_INLINE Vector upVec() const;
|
||||
FGL_FORCE_INLINE Vector rightVec() const;
|
||||
|
||||
Coordinate< CType > getPosition() const { return m_position; }
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "engine/math/taitBryanMatrix.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
@@ -19,7 +21,7 @@ namespace fgl::engine
|
||||
const glm::vec3 rot_cos { glm::cos( rotation ) };
|
||||
const glm::vec3 rot_sin { glm::sin( rotation ) };
|
||||
|
||||
auto extractFloats = []( const glm::vec3& vec ) -> std::tuple< const float&, const float&, const float >
|
||||
auto extractFloats = []( const glm::vec3& vec ) -> std::tuple< const float&, const float&, const float& >
|
||||
{ return std::make_tuple( vec.x, vec.y, vec.z ); };
|
||||
|
||||
const auto& [ cp, cr, cy ] = extractFloats( rot_cos );
|
||||
|
||||
@@ -43,14 +43,14 @@ namespace fgl::engine
|
||||
|
||||
template < typename T >
|
||||
requires is_plane< T >
|
||||
bool FGL_FLATTEN intersects( const T plane ) const
|
||||
FGL_FLATTEN bool intersects( const T plane ) const
|
||||
{
|
||||
return !std::isnan( glm::dot( plane.getDirection(), getDirection() ) );
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
requires is_plane< T >
|
||||
Coordinate< CType > FGL_FLATTEN intersection( const T plane ) const
|
||||
FGL_FLATTEN Coordinate< CType > intersection( const T plane ) const
|
||||
{
|
||||
return Coordinate< CType >( planeIntersection( plane.getDirection().vec(), plane.distance() ) );
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace fgl::engine
|
||||
|
||||
template < typename T >
|
||||
requires is_plane< T >
|
||||
bool FGL_FLATTEN intersects( const T plane ) const
|
||||
FGL_FLATTEN bool intersects( const T plane ) const
|
||||
{
|
||||
return plane.isForward( start ) != plane.isForward( end );
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace fgl::engine
|
||||
|
||||
template < typename T >
|
||||
requires is_plane< T >
|
||||
Coordinate< CType > FGL_FLATTEN intersection( const T plane ) const
|
||||
FGL_FLATTEN Coordinate< CType > intersection( const T plane ) const
|
||||
{
|
||||
return Coordinate< CType >( planeIntersection( plane.getDirection().vec(), plane.distance() ) );
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace fgl::engine
|
||||
|
||||
float distanceFrom( const Coordinate< CType > coord ) const;
|
||||
|
||||
bool FGL_FORCE_INLINE_FLATTEN isForward( const Coordinate< CType > coord ) const
|
||||
FGL_FORCE_INLINE_FLATTEN bool isForward( const Coordinate< CType > coord ) const
|
||||
{
|
||||
return distanceFrom( coord ) > 0.0f;
|
||||
}
|
||||
|
||||
bool FGL_FORCE_INLINE_FLATTEN isBehind( const Coordinate< CType > coord ) const { return !isForward( coord ); }
|
||||
FGL_FORCE_INLINE_FLATTEN bool isBehind( const Coordinate< CType > coord ) const { return !isForward( coord ); }
|
||||
|
||||
//! Returns a normalized Vector
|
||||
NormalVector direction() const { return m_direction; }
|
||||
|
||||
@@ -26,15 +26,15 @@ namespace fgl::engine
|
||||
|
||||
PointPlane();
|
||||
|
||||
PointPlane( const Coordinate< CType > pos, const Vector vec );
|
||||
PointPlane( Coordinate< CType > pos, Vector vec );
|
||||
|
||||
PointPlane( const Coordinate< CType > pos, const NormalVector vec );
|
||||
PointPlane( Coordinate< CType > pos, NormalVector vec );
|
||||
|
||||
NormalVector FGL_FORCE_INLINE getDirection() const { return vector; }
|
||||
FGL_FORCE_INLINE NormalVector getDirection() const { return vector; }
|
||||
|
||||
float distance() const;
|
||||
|
||||
Coordinate< CType > FGL_FORCE_INLINE getPosition() const { return coordinate; }
|
||||
FGL_FORCE_INLINE Coordinate< CType > getPosition() const { return coordinate; }
|
||||
|
||||
float distanceFrom( const Coordinate< CType > coord ) const;
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ namespace fgl::engine
|
||||
|
||||
//Coordinate has an operator for vector that's much easier to define. So we just invert the order and use that one.
|
||||
template < CoordinateSpace CType >
|
||||
Vector FGL_FLATTEN operator+( const Coordinate< CType > coord )
|
||||
FGL_FLATTEN Vector operator+( const Coordinate< CType > coord )
|
||||
{
|
||||
return coord + *this;
|
||||
}
|
||||
|
||||
template < CoordinateSpace CType >
|
||||
Vector FGL_FLATTEN operator-( const Coordinate< CType > coord )
|
||||
FGL_FLATTEN Vector operator-( const Coordinate< CType > coord )
|
||||
{
|
||||
return coord - *this;
|
||||
}
|
||||
|
||||
@@ -101,9 +101,7 @@ namespace fgl::engine
|
||||
public:
|
||||
|
||||
// Not copyable or movable
|
||||
FGL_DELETE_DEFAULT_CTOR( Device )
|
||||
FGL_DELETE_COPY( Device )
|
||||
FGL_DELETE_MOVE( Device )
|
||||
FGL_DELETE_ALL_Ro5( Device );
|
||||
|
||||
vk::CommandPool getCommandPool() { return m_commandPool; }
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
#include <bitset>
|
||||
#include <functional>
|
||||
|
||||
#include "engine/GameObject.hpp"
|
||||
#include "engine/primitives/boxes/AxisAlignedBoundingCube.hpp"
|
||||
@@ -59,7 +58,7 @@ namespace fgl::engine
|
||||
public:
|
||||
|
||||
OctTreeNode() = delete;
|
||||
OctTreeNode( const WorldCoordinate center, float span = ROOT_SPAN, OctTreeNode* parent = nullptr );
|
||||
OctTreeNode( WorldCoordinate center, float span = ROOT_SPAN, OctTreeNode* parent = nullptr );
|
||||
|
||||
OctTreeNode( const OctTreeNode& other ) = delete;
|
||||
OctTreeNode( OctTreeNode&& other ) = delete;
|
||||
@@ -70,10 +69,10 @@ namespace fgl::engine
|
||||
private:
|
||||
|
||||
//! Returns the node of a given ID (Searches down)
|
||||
OctTreeNode* findID( const GameObject::GameObjectID id );
|
||||
OctTreeNode* findID( GameObject::GameObjectID id );
|
||||
|
||||
//! Returns true if the node contains a given ID
|
||||
inline bool contains( const GameObject::GameObjectID id ) { return findID( id ) != nullptr; }
|
||||
bool contains( const GameObject::GameObjectID id ) { return findID( id ) != nullptr; }
|
||||
|
||||
//! Splits a node. Does nothing if node is not a leaf.
|
||||
void split( int depth = 1 );
|
||||
@@ -83,9 +82,9 @@ namespace fgl::engine
|
||||
//! returns true if this node should contain the given object
|
||||
bool canContain( const GameObject& obj );
|
||||
|
||||
GameObject extract( const GameObject::GameObjectID id );
|
||||
GameObject extract( GameObject::GameObjectID id );
|
||||
|
||||
inline GameObject extract( const GameObject& obj ) { return this->extract( obj.getId() ); }
|
||||
GameObject extract( const GameObject& obj ) { return this->extract( obj.getId() ); }
|
||||
|
||||
bool isInFrustum( const Frustum< CoordinateSpace::World >& frustum ) const;
|
||||
|
||||
@@ -95,13 +94,13 @@ namespace fgl::engine
|
||||
&& std::get< OctTreeNodeLeaf >( m_node_data ).empty();
|
||||
}
|
||||
|
||||
auto getGameObjectItter( const GameObject::GameObjectID id );
|
||||
auto getGameObjectItter( GameObject::GameObjectID id );
|
||||
|
||||
void getAllLeafs( std::vector< OctTreeNodeLeaf* >& out_leafs );
|
||||
void getAllLeafsInFrustum(
|
||||
const Frustum< CoordinateSpace::World >& frustum, std::vector< OctTreeNodeLeaf* >& out_leafs );
|
||||
|
||||
bool contains( const WorldCoordinate coord ) const;
|
||||
bool contains( WorldCoordinate coord ) const;
|
||||
|
||||
OctTreeNode& operator[]( const WorldCoordinate coord );
|
||||
|
||||
@@ -114,7 +113,7 @@ namespace fgl::engine
|
||||
|
||||
constexpr static std::size_t LEAF_RESERVE_SIZE { 1024 };
|
||||
|
||||
[[nodiscard]] inline std::vector< OctTreeNodeLeaf* > getAllLeafs()
|
||||
[[nodiscard]] std::vector< OctTreeNodeLeaf* > getAllLeafs()
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector< OctTreeNodeLeaf* > leafs {};
|
||||
@@ -123,8 +122,8 @@ namespace fgl::engine
|
||||
return leafs;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline std::vector< OctTreeNodeLeaf* > getAllLeafsInFrustum( const Frustum<
|
||||
CoordinateSpace::World >& frustum )
|
||||
[[nodiscard]] std::vector< OctTreeNodeLeaf* > getAllLeafsInFrustum( const Frustum< CoordinateSpace::World >&
|
||||
frustum )
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector< OctTreeNodeLeaf* > leafs {};
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "engine/GameObject.hpp"
|
||||
#include <vector>
|
||||
|
||||
#include "engine/GameObject.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -27,13 +28,13 @@ namespace fgl::engine
|
||||
Scale m_node_bounds { std::numeric_limits< float >::infinity() };
|
||||
std::variant< QuadTreeNodeArray, QuadTreeNodeLeaf > m_node_data { QuadTreeNodeLeaf() };
|
||||
|
||||
bool contains( const WorldCoordinate coord ) const;
|
||||
bool contains( WorldCoordinate coord ) const;
|
||||
|
||||
public:
|
||||
|
||||
QuadTreeNode& operator[]( const WorldCoordinate pos );
|
||||
QuadTreeNode& operator[]( WorldCoordinate pos );
|
||||
|
||||
void split( const int depth = 1 );
|
||||
void split( int depth = 1 );
|
||||
|
||||
void addGameObject( GameObject&& obj );
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace fgl::engine
|
||||
{
|
||||
|
||||
template < typename T, typename... Ts >
|
||||
inline void hashCombine( std::size_t& seed, const T& v, const Ts&... ts )
|
||||
void hashCombine( std::size_t& seed, const T& v, const Ts&... ts )
|
||||
{
|
||||
std::hash< T > hasher;
|
||||
seed ^= hasher( v ) + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 );
|
||||
|
||||
Reference in New Issue
Block a user