Some cleanup
This commit is contained in:
@@ -112,4 +112,8 @@ namespace fgl::engine::memory
|
||||
BufferSuballocation( buffer.allocate( size ) )
|
||||
{}
|
||||
|
||||
} // namespace fgl::engine
|
||||
BufferSuballocation::BufferSuballocation( Buffer& buffer, std::size_t t_size, std::size_t t_align ) :
|
||||
BufferSuballocation( buffer.allocate( t_size, t_align ) )
|
||||
{}
|
||||
|
||||
} // namespace fgl::engine::memory
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace fgl::engine::memory
|
||||
|
||||
void flush( vk::DeviceSize beg, vk::DeviceSize end );
|
||||
|
||||
explicit BufferSuballocation( Buffer& buffer, std::size_t t_size, std::size_t t_align );
|
||||
|
||||
public:
|
||||
|
||||
using value_type = void;
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace fgl::engine
|
||||
HostSingleT( HostSingleT&& ) = delete;
|
||||
HostSingleT& operator=( const HostSingleT& ) = delete;
|
||||
|
||||
HostSingleT( memory::Buffer& buffer ) :
|
||||
memory::BufferSuballocation( buffer.allocate( sizeof( T ), alignof( T ) ) )
|
||||
{}
|
||||
HostSingleT( memory::Buffer& buffer ) : memory::BufferSuballocation( buffer, sizeof( T ), alignof( T ) ) {}
|
||||
|
||||
HostSingleT& operator=( T& t )
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
inline static std::unique_ptr< CameraRenderer > camera_renderer;
|
||||
|
||||
Matrix< MatrixType::WorldToScreen > Camera::getProjectionViewMatrix() const
|
||||
{
|
||||
assert( projection_matrix != constants::MAT4_IDENTITY );
|
||||
@@ -76,13 +78,13 @@ namespace fgl::engine
|
||||
}
|
||||
|
||||
updateInfo( frame_info.frame_idx );
|
||||
m_renderer->pass( frame_info, *m_swapchain );
|
||||
camera_renderer->pass( frame_info, *m_swapchain );
|
||||
frame_info.camera = nullptr;
|
||||
}
|
||||
|
||||
vk::raii::RenderPass& Camera::getRenderpass()
|
||||
{
|
||||
return m_renderer->getRenderpass();
|
||||
return camera_renderer->getRenderpass();
|
||||
}
|
||||
|
||||
CameraSwapchain& Camera::getSwapchain() const
|
||||
@@ -119,7 +121,7 @@ namespace fgl::engine
|
||||
void Camera::remakeSwapchain( vk::Extent2D extent )
|
||||
{
|
||||
this->setPerspectiveProjection( m_fov_y, aspectRatio(), constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
m_swapchain = std::make_shared< CameraSwapchain >( m_renderer->getRenderpass(), extent );
|
||||
m_swapchain = std::make_shared< CameraSwapchain >( camera_renderer->getRenderpass(), extent );
|
||||
}
|
||||
|
||||
void Camera::setName( const std::string_view str )
|
||||
@@ -299,15 +301,15 @@ namespace fgl::engine
|
||||
|
||||
void Camera::initCameraRenderer()
|
||||
{
|
||||
assert( !m_renderer );
|
||||
m_renderer = std::make_unique< CameraRenderer >();
|
||||
assert( !camera_renderer );
|
||||
camera_renderer = std::make_unique< CameraRenderer >();
|
||||
}
|
||||
|
||||
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 >( camera_renderer->getRenderpass(), m_target_extent ) ),
|
||||
name()
|
||||
{
|
||||
this->setPerspectiveProjection( m_fov_y, aspectRatio(), constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "CameraRenderer.hpp"
|
||||
#include "engine/buffers/HostSingleT.hpp"
|
||||
#include "engine/buffers/UniqueFrameSuballocation.hpp"
|
||||
#include "engine/descriptors/DescriptorSet.hpp"
|
||||
#include "engine/primitives/Frustum.hpp"
|
||||
#include "engine/primitives/Rotation.hpp"
|
||||
#include "engine/primitives/TransformComponent.hpp"
|
||||
#include "engine/rendering/types.hpp"
|
||||
|
||||
namespace vk::raii
|
||||
@@ -43,7 +43,9 @@ namespace fgl::engine
|
||||
class Camera
|
||||
{
|
||||
inline static CameraIDX camera_counter { 0 };
|
||||
CameraIDX camera_idx { camera_counter++ };
|
||||
|
||||
// Const is acceptable, Since this value should never change. EVER
|
||||
const CameraIDX camera_idx { camera_counter++ };
|
||||
|
||||
Matrix< MatrixType::CameraToScreen > projection_matrix { 1.0f };
|
||||
|
||||
@@ -66,7 +68,6 @@ namespace fgl::engine
|
||||
// Camera info is expected at binding 0
|
||||
std::vector< descriptors::DescriptorSet > m_camera_info_descriptors {};
|
||||
|
||||
inline static std::unique_ptr< CameraRenderer > m_renderer;
|
||||
std::shared_ptr< CameraSwapchain > m_swapchain;
|
||||
|
||||
std::string name;
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
|
||||
struct CameraInfo
|
||||
{
|
||||
glm::mat4 projection { 1.0f };
|
||||
|
||||
@@ -55,4 +55,7 @@ namespace fgl::engine
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
CameraManager::~CameraManager()
|
||||
{}
|
||||
} // namespace fgl::engine
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "engine/buffers/Buffer.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -26,6 +27,8 @@ namespace fgl::engine
|
||||
|
||||
public:
|
||||
|
||||
~CameraManager();
|
||||
|
||||
static CameraManager& getInstance();
|
||||
|
||||
std::vector< std::weak_ptr< Camera > >& getCameras();
|
||||
|
||||
@@ -37,4 +37,9 @@ namespace fgl::engine
|
||||
return INVALID_TEXTURE_ID;
|
||||
}
|
||||
|
||||
OrientedBoundingBox< CoordinateSpace::World > Primitive::getWorldBounds() const
|
||||
{
|
||||
return m_transform->mat() * m_bounding_box;
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace fgl::engine
|
||||
|
||||
TextureID getAlbedoTextureID() const;
|
||||
TextureID getNormalTextureID() const;
|
||||
OrientedBoundingBox< CoordinateSpace::World > getWorldBounds() const;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace fgl::engine
|
||||
const auto mat_idx { prim.material };
|
||||
if ( mat_idx == -1 )
|
||||
{
|
||||
//There is no matrial for this
|
||||
//There is no material for this
|
||||
throw std::runtime_error( "No material for primitive. One was expected" );
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace fgl::engine
|
||||
return { itter->second };
|
||||
};
|
||||
|
||||
std::string str;
|
||||
std::string str {};
|
||||
|
||||
std::size_t counter { 0 };
|
||||
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace fgl::engine
|
||||
static_assert(
|
||||
CType == CoordinateSpace::World, "pointInside can only be called on World coordinate Frustums" );
|
||||
|
||||
//Ensure the point we are not trying to test a NaN point
|
||||
assert( coord.x != std::numeric_limits< decltype( coord.x ) >::quiet_NaN() );
|
||||
assert( coord.y != std::numeric_limits< decltype( coord.y ) >::quiet_NaN() );
|
||||
assert( coord.z != std::numeric_limits< decltype( coord.z ) >::quiet_NaN() );
|
||||
|
||||
//TODO: This is a biased approach.
|
||||
// Approaches for non-biased:
|
||||
// We can either make this non-biased by using a projection from distance shot down the FORWARD vector
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace fgl::engine
|
||||
{
|
||||
if ( !primitive.ready() ) continue;
|
||||
|
||||
// Does this primitive pass the bounds check
|
||||
if ( !frustum.intersects( primitive.getWorldBounds() ) ) continue;
|
||||
|
||||
//assert( primitive.m_texture );
|
||||
const ModelMatrixInfo matrix_info { .model_matrix = obj.getTransform().mat4(),
|
||||
.albedo_id = primitive.getAlbedoTextureID(),
|
||||
|
||||
@@ -83,7 +83,6 @@ namespace fgl::engine
|
||||
{
|
||||
assert( std::holds_alternative< OctTreeNodeLeaf >( m_node_data ) );
|
||||
OctTreeNodeLeaf& leaf { std::get< OctTreeNodeLeaf >( m_node_data ) };
|
||||
leafs.reserve( LEAF_RESERVE_SIZE );
|
||||
leafs.emplace_back( &leaf );
|
||||
|
||||
//debug::world::drawBoundingBox( m_bounds );
|
||||
@@ -200,6 +199,7 @@ namespace fgl::engine
|
||||
{
|
||||
auto& objects { std::get< OctTreeNodeLeaf >( m_node_data ) };
|
||||
assert( objects.capacity() == MAX_NODES_IN_LEAF );
|
||||
// If the amount of nodes is about to exceed the number of leafs, Then split the nodes
|
||||
if ( objects.size() + 1 > MAX_NODES_IN_LEAF )
|
||||
{
|
||||
split();
|
||||
@@ -313,7 +313,7 @@ namespace fgl::engine
|
||||
if ( std::holds_alternative< OctTreeNodeLeaf >( m_node_data ) )
|
||||
{
|
||||
auto& leaf { std::get< OctTreeNodeLeaf >( m_node_data ) };
|
||||
//No point in us giving back an empy leaf
|
||||
//No point in us giving back an empty leaf
|
||||
if ( leaf.size() > 0 ) objects.emplace_back( &leaf );
|
||||
}
|
||||
else
|
||||
|
||||
31
src/shaders/viewinfo
Normal file
31
src/shaders/viewinfo
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef FGL_SHADER
|
||||
#define mat4 glm::mat4
|
||||
#define mat3 glm::mat3
|
||||
|
||||
#define vec4 glm::vec4
|
||||
#define vec3 glm::vec3
|
||||
#endif
|
||||
|
||||
#ifdef FGL_ENGINE
|
||||
namespace fgl::engine
|
||||
{
|
||||
#endif
|
||||
|
||||
struct ViewInfo {
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifdef FGL_ENGINE
|
||||
} // namespace fgl::engine
|
||||
#endif
|
||||
|
||||
#define SHADER_LAYOUT(set_idx, binding_idx) \
|
||||
layout (set = set_idx, binding = binding_idx)
|
||||
|
||||
#define UNIFORM uniform
|
||||
|
||||
SHADER_LAYOUT(1, 0) UNIFORM CAMERA_INFO ubo;
|
||||
Reference in New Issue
Block a user