Transfer editor specific code to a separate binary
This commit is contained in:
@@ -99,9 +99,8 @@ endforeach ()
|
||||
add_custom_target(shaders ALL DEPENDS ${SPV_SHADERS})
|
||||
add_custom_target(assets ALL DEPENDS ${OUT_ASSETS})
|
||||
|
||||
add_dependencies(${PROJECT_NAME} shaders)
|
||||
add_dependencies(${PROJECT_NAME} assets)
|
||||
|
||||
add_dependencies(TitorEditor shaders)
|
||||
add_dependencies(TitorEditor assets)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_SOURCE_DIR}/compile_commands.json
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
add_subdirectory(vma)
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(objectloaders)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(editor)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
add_executable(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${FGL_FLAGS}")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Tracy::TracyClient FGLEngine)
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 11/27/23.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "engine/EngineContext.hpp"
|
||||
#include "engine/logging/logging.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
fgl::engine::log::set_level( spdlog::level::debug );
|
||||
|
||||
fgl::engine::EngineContext engine_ctx {};
|
||||
|
||||
engine_ctx.run();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
15
src/editor/CMakeLists.txt
Normal file
15
src/editor/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
target_compile_definitions(FGLEngine PUBLIC VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.hpp"
|
||||
)
|
||||
|
||||
add_executable(TitorEditor ${SOURCE_FILES})
|
||||
target_link_libraries(TitorEditor PRIVATE FGLEngine)
|
||||
target_include_directories(TitorEditor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
target_compile_definitions(TitorEditor PUBLIC IDHAN_EDITOR)
|
||||
11
src/editor/src/components/GameComponent.cpp
Normal file
11
src/editor/src/components/GameComponent.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by kj16609 on 8/2/24.
|
||||
//
|
||||
|
||||
#include "engine/gameobjects/GameObject.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +1,13 @@
|
||||
//
|
||||
// Created by kj16609 on 7/8/24.
|
||||
// Created by kj16609 on 8/2/24.
|
||||
//
|
||||
|
||||
#include "ModelComponent.hpp"
|
||||
#include "engine/gameobjects/components/ModelComponent.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#include "gui/safe_include.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
void ModelComponent::drawImGui()
|
||||
{
|
||||
if ( ImGui::CollapsingHeader( "Model Component", ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_DefaultOpen ) )
|
||||
@@ -20,5 +15,4 @@ namespace fgl::engine
|
||||
ImGui::Text( "MODEL COMPONENT WOOOOOO" );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "engine/assets/stores.hpp"
|
||||
#include "engine/filesystem/scanner/FileScanner.hpp"
|
||||
#include "engine/gui/safe_include.hpp"
|
||||
#include "engine/filesystem/types.hpp"
|
||||
#include "engine/image/ImageView.hpp"
|
||||
#include "engine/logging/logging.hpp"
|
||||
#include "engine/texture/Texture.hpp"
|
||||
#include "types.hpp"
|
||||
#include "safe_include.hpp"
|
||||
|
||||
namespace fgl::engine::filesystem
|
||||
{
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "scanner/FileScanner.hpp"
|
||||
#include "../../../engine/filesystem/scanner/FileScanner.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -4,15 +4,11 @@
|
||||
|
||||
#include "engine/camera/Camera.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#include <cassert>
|
||||
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "preview.hpp"
|
||||
#include "safe_include.hpp"
|
||||
|
||||
namespace fgl::engine::gui
|
||||
{
|
||||
@@ -10,17 +10,19 @@
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_vulkan.h>
|
||||
|
||||
#include <imgui_internal.h> // Included for DockBuilder since it's not exposed yet
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "FileBrowser.hpp"
|
||||
#include "engine/debug/DEBUG_NAMES.hpp"
|
||||
#include "engine/descriptors/DescriptorPool.hpp"
|
||||
#include "engine/filesystem/FileBrowser.hpp"
|
||||
#include "engine/model/Model.hpp"
|
||||
#include "engine/rendering/Device.hpp"
|
||||
#include "engine/rendering/Renderer.hpp"
|
||||
#include "engine/tree/octtree/OctTreeNode.hpp"
|
||||
#include "gui_window_names.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "safe_include.hpp"
|
||||
|
||||
namespace fgl::engine::gui
|
||||
@@ -203,12 +205,40 @@ namespace fgl::engine::gui
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void drawObject( GameObject& game_object )
|
||||
{
|
||||
ImGui::InputText( "Name", &( game_object.getName() ) );
|
||||
|
||||
// Transform - Position
|
||||
dragFloat3( "Position", game_object.getTransform().translation.vec() );
|
||||
|
||||
dragFloat3Rot( "Rotation", game_object.getRotation() );
|
||||
|
||||
dragFloat3( "Scale", game_object.getScale() );
|
||||
}
|
||||
|
||||
void drawComponents( const GameObject& game_object )
|
||||
{
|
||||
for ( ComponentEditorInterface* component : game_object.getComponents() )
|
||||
{
|
||||
ImGui::Separator();
|
||||
component->drawImGui();
|
||||
}
|
||||
}
|
||||
|
||||
void drawEntityInfo( [[maybe_unused]] FrameInfo& info )
|
||||
{
|
||||
ZoneScoped;
|
||||
ImGui::Begin( ENTITY_INFO_NAME );
|
||||
|
||||
if ( selected_object ) selected_object->drawImGui();
|
||||
if ( !selected_object )
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
drawObject( *selected_object );
|
||||
drawComponents( *selected_object );
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
namespace fgl::engine
|
||||
{
|
||||
constexpr std::string_view GUI_DOCKSPACE_NAME { "MainWindowDockspace" };
|
||||
constexpr std::string_view CAMERA_EDITOR_NAME { "Scene" };
|
||||
constexpr std::string_view FILE_PICKER_NAME { "File Browser" };
|
||||
constexpr std::string_view OBJECT_TREE_VIEW_NAME { "Object List" };
|
||||
constexpr std::string_view ENTITY_INFO_NAME { "Entiy Info" };
|
||||
@@ -4,16 +4,6 @@
|
||||
|
||||
#include "preview.hpp"
|
||||
|
||||
// clang-format off
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <imgui.h>
|
||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||
#pragma GCC diagnostic pop
|
||||
// clang-format on
|
||||
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "engine/camera/Camera.hpp"
|
||||
#include "engine/camera/CameraSwapchain.hpp"
|
||||
@@ -24,6 +14,7 @@
|
||||
#include "engine/model/builders/SceneBuilder.hpp"
|
||||
#include "engine/rendering/SwapChain.hpp"
|
||||
#include "engine/tree/octtree/OctTreeNode.hpp"
|
||||
#include "safe_include.hpp"
|
||||
|
||||
namespace fgl::engine::gui
|
||||
{
|
||||
@@ -140,7 +131,7 @@ namespace fgl::engine::gui
|
||||
[[maybe_unused]] const FrameIndex frame_index,
|
||||
std::uint_fast8_t& current )
|
||||
{
|
||||
static constexpr char* const options[] = { "Composite", "Albedo", "Normal", "Position" };
|
||||
static constexpr std::string_view options[] = { "Composite", "Albedo", "Normal", "Position" };
|
||||
if ( ImGui::BeginMenuBar() )
|
||||
{
|
||||
if ( ImGui::BeginMenu( "Output" ) )
|
||||
@@ -38,4 +38,18 @@ namespace ImGui
|
||||
return ::ImGui::Begin( name.data(), p_open, flags );
|
||||
}
|
||||
|
||||
// IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated.
|
||||
FGL_FORCE_INLINE inline bool MenuItem(
|
||||
const std::string_view label, const char* shortcut = NULL, bool selected = false, bool enabled = true )
|
||||
{
|
||||
return ::ImGui::MenuItem( label.data(), shortcut, selected, enabled );
|
||||
}
|
||||
|
||||
// IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
FGL_FORCE_INLINE inline bool
|
||||
MenuItem( const std::string_view label, const char* shortcut, bool* selected, bool enabled = true )
|
||||
{
|
||||
return ::ImGui::MenuItem( label.data(), shortcut, selected, enabled );
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
56
src/editor/src/main.cpp
Normal file
56
src/editor/src/main.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Created by kj16609 on 7/30/24.
|
||||
//
|
||||
#include <cstdlib>
|
||||
|
||||
#include "engine/EngineContext.hpp"
|
||||
#include "engine/camera/CameraManager.hpp"
|
||||
#include "engine/gameobjects/components/CameraComponent.hpp"
|
||||
#include "gui/core.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace fgl::engine;
|
||||
|
||||
log::set_level( spdlog::level::debug );
|
||||
|
||||
EngineContext engine_ctx {};
|
||||
|
||||
// We start by hooking into the imgui rendering.
|
||||
engine_ctx.hookInitImGui( gui::initGui );
|
||||
engine_ctx.hookCleanupImGui( gui::cleanupImGui );
|
||||
engine_ctx.TEMPhookGuiRender( gui::drawMainGUI );
|
||||
|
||||
// Now we need to create the camera for the editor.
|
||||
CameraManager& camera_manager { CameraManager::getInstance() };
|
||||
|
||||
auto& editor_camera { camera_manager.getPrimary() };
|
||||
|
||||
editor_camera->setPerspectiveProjection(
|
||||
glm::radians( 90.0f ), engine_ctx.getWindowAspectRatio(), constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
|
||||
//! Will be true until the window says it wants to close.
|
||||
while ( engine_ctx.good() )
|
||||
{
|
||||
engine_ctx.tickDeltaTime();
|
||||
|
||||
engine_ctx.handleTransfers();
|
||||
|
||||
// Process input
|
||||
engine_ctx.processInput();
|
||||
|
||||
// Here we can decide if we want to tick fully or not.
|
||||
|
||||
// Simulate step
|
||||
engine_ctx.tickSimulation();
|
||||
|
||||
// Update the viewer camera
|
||||
|
||||
// Render step
|
||||
engine_ctx.renderFrame();
|
||||
}
|
||||
|
||||
engine_ctx.run();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -12,87 +12,149 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "KeyboardMovementController.hpp"
|
||||
#include "assets/stores.hpp"
|
||||
#include "buffers/HostSingleT.hpp"
|
||||
#include "camera/Camera.hpp"
|
||||
#include "camera/CameraManager.hpp"
|
||||
#include "engine/Average.hpp"
|
||||
#include "engine/assets/TransferManager.hpp"
|
||||
#include "engine/buffers/UniqueFrameSuballocation.hpp"
|
||||
#include "engine/debug/drawers.hpp"
|
||||
#include "engine/literals/size.hpp"
|
||||
#include "engine/model/prebuilt/terrainModel.hpp"
|
||||
#include "gui/core.hpp"
|
||||
#include "model/builders/SceneBuilder.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
constexpr float MAX_DELTA_TIME { 0.5 };
|
||||
|
||||
EngineContext::EngineContext()
|
||||
EngineContext::EngineContext() :
|
||||
m_ubo_buffer_pool( 512_KiB, vk::BufferUsageFlagBits::eUniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||
m_matrix_info_pool(
|
||||
512_KiB,
|
||||
vk::BufferUsageFlagBits::eVertexBuffer,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||
m_draw_parameter_pool(
|
||||
16_KiB,
|
||||
vk::BufferUsageFlagBits::eIndirectBuffer,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||
m_delta_time_ms( 0.0 )
|
||||
{
|
||||
ZoneScoped;
|
||||
using namespace fgl::literals::size_literals;
|
||||
|
||||
memory::TransferManager::createInstance( device, 512_MiB );
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
initImGui();
|
||||
#endif
|
||||
loadGameObjects();
|
||||
memory::TransferManager::createInstance( device, 128_MiB );
|
||||
}
|
||||
|
||||
static Average< float, 60 * 15 > rolling_ms_average;
|
||||
|
||||
void EngineContext::processInput()
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void EngineContext::tickDeltaTime()
|
||||
{
|
||||
// Get delta time
|
||||
const auto now { std::chrono::high_resolution_clock::now() };
|
||||
const std::chrono::duration< double, std::micro > time_diff { last_tick - now };
|
||||
last_tick = now;
|
||||
|
||||
m_delta_time_ms = time_diff.count() * 1000.0f;
|
||||
}
|
||||
|
||||
void EngineContext::tickSimulation()
|
||||
{
|
||||
// TODO: This is where we'll start doing physics stuff.
|
||||
// The first step here should be culling things that aren't needed to be ticked.
|
||||
// Perhaps implementing a tick system that doesn't care about the refresh rate might be good?
|
||||
// That way we can still tick consistantly without actually needing to render anything.
|
||||
}
|
||||
|
||||
void EngineContext::renderCameras( FrameInfo frame_info )
|
||||
{
|
||||
auto& camera_manager { CameraManager::getInstance() };
|
||||
for ( auto& current_camera_ptr : camera_manager.getCameras() )
|
||||
{
|
||||
if ( current_camera_ptr.expired() ) continue;
|
||||
|
||||
auto sh_camera { current_camera_ptr.lock() };
|
||||
|
||||
Camera& current_camera { *sh_camera };
|
||||
|
||||
current_camera.pass( frame_info );
|
||||
}
|
||||
}
|
||||
|
||||
void EngineContext::renderFrame()
|
||||
{
|
||||
if ( auto& command_buffer = m_renderer.beginFrame(); *command_buffer )
|
||||
{
|
||||
ZoneScopedN( "Render" );
|
||||
const FrameIndex frame_index { m_renderer.getFrameIndex() };
|
||||
const PresentIndex present_idx { m_renderer.getPresentIndex() };
|
||||
|
||||
auto& camera_manager { CameraManager::getInstance() };
|
||||
|
||||
FrameInfo frame_info { frame_index,
|
||||
present_idx,
|
||||
m_delta_time_ms,
|
||||
command_buffer,
|
||||
nullptr, // Camera
|
||||
camera_manager.getCameras(),
|
||||
// global_descriptor_sets[ frame_index ],
|
||||
m_game_objects_root,
|
||||
m_renderer.getCurrentTracyCTX(),
|
||||
m_matrix_info_pool,
|
||||
m_draw_parameter_pool,
|
||||
*this->m_vertex_buffer,
|
||||
*this->m_index_buffer,
|
||||
m_renderer.getSwapChain().getInputDescriptor( present_idx ),
|
||||
this->m_renderer.getSwapChain() };
|
||||
|
||||
TracyVkCollect( frame_info.tracy_ctx, *command_buffer );
|
||||
|
||||
//TODO: Setup semaphores to make this pass not always required.
|
||||
memory::TransferManager::getInstance().recordOwnershipTransferDst( command_buffer );
|
||||
|
||||
//TODO: Add some way of 'activating' cameras. We don't need to render cameras that aren't active.
|
||||
renderCameras( frame_info );
|
||||
|
||||
m_renderer.clearInputImage( command_buffer );
|
||||
|
||||
//primary_camera
|
||||
// .copyOutput( command_buffer, frame_index, m_renderer.getSwapChain().getInputImage( present_idx ) );
|
||||
|
||||
m_renderer.beginSwapchainRendererPass( command_buffer );
|
||||
|
||||
m_gui_system.pass( frame_info );
|
||||
|
||||
// TODO: Implement some way we can record extra things into the command buffer during this stage.
|
||||
// We'll probably just use multiple command buffers and allow the caller to pass some in with flags on where to put them
|
||||
renderGui( frame_info );
|
||||
|
||||
m_renderer.endSwapchainRendererPass( command_buffer );
|
||||
|
||||
m_renderer.endFrame();
|
||||
|
||||
memory::TransferManager::getInstance().dump();
|
||||
|
||||
FrameMark;
|
||||
}
|
||||
}
|
||||
|
||||
Window& EngineContext::getWindow()
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
float EngineContext::getWindowAspectRatio()
|
||||
{
|
||||
return m_renderer.getAspectRatio();
|
||||
}
|
||||
|
||||
void EngineContext::run()
|
||||
{
|
||||
TracyCZoneN( TRACY_PrepareEngine, "Inital Run", true );
|
||||
std::cout << "Starting main loop run" << std::endl;
|
||||
memory::Buffer global_ubo_buffer { 512_KiB,
|
||||
vk::BufferUsageFlagBits::eUniformBuffer,
|
||||
vk::MemoryPropertyFlagBits::eHostVisible }; // 512 KB
|
||||
|
||||
//Camera prep
|
||||
|
||||
CameraManager camera_manager {};
|
||||
|
||||
PerFrameSuballocation< HostSingleT< PointLight > > point_lights { global_ubo_buffer,
|
||||
SwapChain::MAX_FRAMES_IN_FLIGHT };
|
||||
|
||||
std::shared_ptr< Texture > debug_tex {
|
||||
getTextureStore().load( "assets/textures/DebugTexture.png", vk::Format::eR8G8B8A8Unorm )
|
||||
};
|
||||
|
||||
constexpr std::uint32_t matrix_default_size { 64_MiB };
|
||||
constexpr std::uint32_t draw_parameter_default_size { 64_MiB };
|
||||
|
||||
std::vector< memory::Buffer > matrix_info_buffers {};
|
||||
|
||||
std::vector< memory::Buffer > draw_parameter_buffers {};
|
||||
|
||||
// std::vector< descriptors::DescriptorSet > global_descriptor_sets {};
|
||||
|
||||
for ( int i = 0; i < SwapChain::MAX_FRAMES_IN_FLIGHT; ++i )
|
||||
{
|
||||
matrix_info_buffers.emplace_back(
|
||||
matrix_default_size,
|
||||
vk::BufferUsageFlagBits::eVertexBuffer,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible );
|
||||
|
||||
draw_parameter_buffers.emplace_back(
|
||||
draw_parameter_default_size,
|
||||
vk::BufferUsageFlagBits::eIndirectBuffer,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible );
|
||||
|
||||
// global_descriptor_sets.emplace_back( GlobalDescriptorSet::createLayout() );
|
||||
}
|
||||
|
||||
// for ( std::uint8_t i = 0; i < SwapChain::MAX_FRAMES_IN_FLIGHT; ++i )
|
||||
// {
|
||||
// global_descriptor_sets[ i ].setMaxIDX( 2 );
|
||||
// global_descriptor_sets[ i ].bindUniformBuffer( 2, point_lights[ i ] );
|
||||
// global_descriptor_sets[ i ].update();
|
||||
// }
|
||||
|
||||
auto viewer { GameObject::createGameObject() };
|
||||
|
||||
@@ -104,26 +166,11 @@ namespace fgl::engine
|
||||
|
||||
auto previous_frame_start { std::chrono::high_resolution_clock::now() };
|
||||
|
||||
//camera.setOrthographicProjection( -aspect, aspect, -1, 1, -1, 1 );
|
||||
const float aspect { m_renderer.getAspectRatio() };
|
||||
|
||||
auto& editor_camera { camera_manager.getPrimary() };
|
||||
// auto secondary_camera { camera_manager.createCamera( { 1920, 1080 } ) };
|
||||
|
||||
editor_camera
|
||||
.setPerspectiveProjection( glm::radians( 90.0f ), aspect, constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
// secondary_camera
|
||||
// ->setPerspectiveProjection( glm::radians( 90.0f ), aspect, constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
|
||||
const auto old_aspect_ratio { m_renderer.getAspectRatio() };
|
||||
|
||||
camera_controller.moveInPlaneXZ( m_window.window(), 0.0, viewer );
|
||||
editor_camera.setView( viewer.getPosition(), viewer.getRotation() );
|
||||
// secondary_camera->setView( viewer.getPosition(), viewer.getRotation() );
|
||||
|
||||
TracyCZoneEnd( TRACY_PrepareEngine );
|
||||
|
||||
while ( !m_window.shouldClose() )
|
||||
while ( good() )
|
||||
{
|
||||
memory::TransferManager::getInstance().submitNow();
|
||||
|
||||
@@ -132,88 +179,14 @@ namespace fgl::engine
|
||||
|
||||
const auto new_time { std::chrono::high_resolution_clock::now() };
|
||||
|
||||
{
|
||||
//Calculate time change from previous frame and add to accumulator
|
||||
const auto time_diff { new_time - previous_frame_start };
|
||||
rolling_ms_average.push(
|
||||
static_cast< float >( std::chrono::duration_cast< std::chrono::microseconds >( time_diff ).count() )
|
||||
/ 1000.0f );
|
||||
previous_frame_start = new_time;
|
||||
}
|
||||
|
||||
auto delta_time { std::chrono::duration< float >( new_time - current_time ).count() };
|
||||
|
||||
current_time = new_time;
|
||||
delta_time = glm::min( delta_time, MAX_DELTA_TIME );
|
||||
|
||||
if ( old_aspect_ratio != m_renderer.getAspectRatio() )
|
||||
{
|
||||
editor_camera.setPerspectiveProjection(
|
||||
glm::radians( 90.0f ), m_renderer.getAspectRatio(), constants::NEAR_PLANE, constants::FAR_PLANE );
|
||||
}
|
||||
|
||||
camera_controller.moveInPlaneXZ( m_window.window(), delta_time, viewer );
|
||||
editor_camera.setView( viewer.getPosition(), viewer.getRotation() );
|
||||
|
||||
if ( auto& command_buffer = m_renderer.beginFrame(); *command_buffer )
|
||||
{
|
||||
ZoneScopedN( "Render" );
|
||||
const FrameIndex frame_index { m_renderer.getFrameIndex() };
|
||||
const PresentIndex present_idx { m_renderer.getPresentIndex() };
|
||||
|
||||
FrameInfo frame_info { frame_index,
|
||||
present_idx,
|
||||
delta_time,
|
||||
command_buffer,
|
||||
{ nullptr, viewer.getTransform() },
|
||||
camera_manager.getCameras(),
|
||||
// global_descriptor_sets[ frame_index ],
|
||||
m_game_objects_root,
|
||||
m_renderer.getCurrentTracyCTX(),
|
||||
matrix_info_buffers[ frame_index ],
|
||||
draw_parameter_buffers[ frame_index ],
|
||||
*this->m_vertex_buffer,
|
||||
*this->m_index_buffer,
|
||||
m_renderer.getSwapChain().getInputDescriptor( present_idx ),
|
||||
this->m_renderer.getSwapChain() };
|
||||
|
||||
#if TRACY_ENABLE
|
||||
//auto& tracy_ctx { frame_info.tracy_ctx };
|
||||
#endif
|
||||
|
||||
TracyVkCollect( frame_info.tracy_ctx, *command_buffer );
|
||||
|
||||
//TODO: Setup semaphores to make this pass not always required.
|
||||
memory::TransferManager::getInstance().recordOwnershipTransferDst( command_buffer );
|
||||
|
||||
for ( auto& current_camera_ptr : camera_manager.getCameras() )
|
||||
{
|
||||
if ( current_camera_ptr.expired() ) continue;
|
||||
|
||||
auto sh_camera { current_camera_ptr.lock() };
|
||||
|
||||
Camera& current_camera { *sh_camera };
|
||||
|
||||
current_camera.pass( frame_info );
|
||||
}
|
||||
|
||||
m_renderer.clearInputImage( command_buffer );
|
||||
|
||||
//primary_camera
|
||||
// .copyOutput( command_buffer, frame_index, m_renderer.getSwapChain().getInputImage( present_idx ) );
|
||||
|
||||
m_renderer.beginSwapchainRendererPass( command_buffer );
|
||||
|
||||
m_gui_system.pass( frame_info );
|
||||
|
||||
m_renderer.endSwapchainRendererPass( command_buffer );
|
||||
|
||||
m_renderer.endFrame();
|
||||
|
||||
memory::TransferManager::getInstance().dump();
|
||||
|
||||
FrameMark;
|
||||
}
|
||||
renderFrame();
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
std::this_thread::sleep_for( 13ms );
|
||||
@@ -247,18 +220,21 @@ namespace fgl::engine
|
||||
log::info( "Finished loading game object" );
|
||||
}
|
||||
|
||||
void EngineContext::initImGui()
|
||||
{
|
||||
#if ENABLE_IMGUI
|
||||
gui::initGui( m_window, m_renderer );
|
||||
#endif
|
||||
}
|
||||
|
||||
EngineContext::~EngineContext()
|
||||
{
|
||||
#if ENABLE_IMGUI
|
||||
#if EXPOSE_IMGUI_FUNCS
|
||||
gui::cleanupImGui();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool EngineContext::good()
|
||||
{
|
||||
return !m_window.shouldClose();
|
||||
}
|
||||
|
||||
void EngineContext::handleTransfers()
|
||||
{
|
||||
memory::TransferManager::getInstance().submitNow();
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
class CameraManager;
|
||||
class GameObject;
|
||||
|
||||
using namespace fgl::literals::size_literals;
|
||||
|
||||
@@ -48,18 +50,64 @@ namespace fgl::engine
|
||||
// SubPass 0
|
||||
GuiSystem m_gui_system { Device::getInstance(), m_renderer.getSwapChainRenderPass() };
|
||||
|
||||
// Temp function
|
||||
std::function< void( FrameInfo& ) > renderGui;
|
||||
std::function< void() > cleanupImGui;
|
||||
|
||||
// Memory pool for shader uniforms.
|
||||
memory::Buffer m_ubo_buffer_pool;
|
||||
|
||||
// Memory pool for matrix info and draw parameters
|
||||
memory::Buffer m_matrix_info_pool;
|
||||
memory::Buffer m_draw_parameter_pool;
|
||||
|
||||
std::chrono::time_point< std::chrono::high_resolution_clock > last_tick {
|
||||
std::chrono::high_resolution_clock::now()
|
||||
};
|
||||
double m_delta_time_ms;
|
||||
|
||||
void loadGameObjects();
|
||||
|
||||
void initImGui();
|
||||
#ifdef IDHAN_EDITOR
|
||||
|
||||
public:
|
||||
|
||||
#endif
|
||||
|
||||
FGL_FORCE_INLINE_FLATTEN void hookInitImGui( const std::function< void( Window&, Renderer& ) >& func )
|
||||
{
|
||||
func( m_window, m_renderer );
|
||||
}
|
||||
|
||||
FGL_FORCE_INLINE_FLATTEN void hookCleanupImGui( const std::function< void() >& func ) { cleanupImGui = func; }
|
||||
|
||||
void TEMPhookGuiRender( const std::function< void( FrameInfo& ) >& func ) { renderGui = func; }
|
||||
|
||||
public:
|
||||
|
||||
EngineContext();
|
||||
~EngineContext();
|
||||
|
||||
bool good();
|
||||
|
||||
//! Performs and pending memory transfers
|
||||
void handleTransfers();
|
||||
|
||||
EngineContext( EngineContext&& other ) = delete;
|
||||
EngineContext( const EngineContext& other ) = delete;
|
||||
EngineContext& operator=( const EngineContext& other ) = delete;
|
||||
|
||||
void processInput();
|
||||
|
||||
void tickDeltaTime();
|
||||
void tickSimulation();
|
||||
void renderCameras( FrameInfo frame_info );
|
||||
|
||||
void renderFrame();
|
||||
|
||||
Window& getWindow();
|
||||
float getWindowAspectRatio();
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
descriptors::DescriptorSet& FrameInfo::getGBufferDescriptor()
|
||||
descriptors::DescriptorSet& FrameInfo::getGBufferDescriptor() const
|
||||
{
|
||||
return camera_data.camera->getSwapchain().getGBufferDescriptor( frame_idx );
|
||||
return camera->getSwapchain().getGBufferDescriptor( frame_idx );
|
||||
}
|
||||
|
||||
descriptors::DescriptorSet& FrameInfo::getCameraDescriptor()
|
||||
descriptors::DescriptorSet& FrameInfo::getCameraDescriptor() const
|
||||
{
|
||||
return camera_data.camera->getDescriptor( frame_idx );
|
||||
return camera->getDescriptor( frame_idx );
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -71,15 +71,11 @@ namespace fgl::engine
|
||||
{
|
||||
FrameIndex frame_idx;
|
||||
PresentIndex present_idx;
|
||||
float frame_time;
|
||||
double frame_time_ms;
|
||||
|
||||
vk::raii::CommandBuffer& command_buffer;
|
||||
|
||||
struct
|
||||
{
|
||||
Camera* camera { nullptr };
|
||||
TransformComponent& camera_transform;
|
||||
} camera_data;
|
||||
Camera* camera { nullptr };
|
||||
|
||||
std::vector< std::weak_ptr< Camera > >& m_camera_list;
|
||||
|
||||
@@ -96,8 +92,8 @@ namespace fgl::engine
|
||||
|
||||
descriptors::DescriptorSet& gui_input_descriptor;
|
||||
|
||||
descriptors::DescriptorSet& getGBufferDescriptor();
|
||||
descriptors::DescriptorSet& getCameraDescriptor();
|
||||
descriptors::DescriptorSet& getGBufferDescriptor() const;
|
||||
descriptors::DescriptorSet& getCameraDescriptor() const;
|
||||
|
||||
SwapChain& swap_chain;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
//
|
||||
|
||||
#include "Buffer.hpp"
|
||||
|
||||
#include "BufferSuballocationHandle.hpp"
|
||||
#include "align.hpp"
|
||||
#include "engine/buffers/exceptions.hpp"
|
||||
|
||||
@@ -60,11 +60,11 @@ namespace fgl::engine
|
||||
|
||||
void Camera::pass( FrameInfo& frame_info )
|
||||
{
|
||||
assert( frame_info.camera_data.camera == nullptr );
|
||||
frame_info.camera_data.camera = this;
|
||||
assert( frame_info.camera == nullptr );
|
||||
frame_info.camera = this;
|
||||
updateInfo( frame_info.frame_idx );
|
||||
m_renderer->pass( frame_info, *m_swapchain );
|
||||
frame_info.camera_data.camera = nullptr;
|
||||
frame_info.camera = nullptr;
|
||||
}
|
||||
|
||||
vk::raii::RenderPass& Camera::getRenderpass()
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "CameraManager.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "engine/debug/DEBUG_NAMES.hpp"
|
||||
#include "engine/debug/drawers.hpp"
|
||||
#include "engine/gui/gui_window_names.hpp"
|
||||
#include "engine/literals/size.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
@@ -14,21 +14,33 @@ namespace fgl::engine
|
||||
|
||||
using namespace fgl::literals::size_literals;
|
||||
|
||||
inline static std::unique_ptr< CameraManager > camera_manager_instance;
|
||||
|
||||
CameraManager& CameraManager::getInstance()
|
||||
{
|
||||
if ( !camera_manager_instance )
|
||||
{
|
||||
camera_manager_instance = std::unique_ptr< CameraManager >( new CameraManager() );
|
||||
}
|
||||
|
||||
return *camera_manager_instance;
|
||||
}
|
||||
|
||||
std::vector< std::weak_ptr< Camera > >& CameraManager::getCameras()
|
||||
{
|
||||
return cameras;
|
||||
}
|
||||
|
||||
Camera& CameraManager::getPrimary()
|
||||
std::shared_ptr< Camera >& CameraManager::getPrimary()
|
||||
{
|
||||
return *m_primary_camera;
|
||||
return m_primary_camera;
|
||||
}
|
||||
|
||||
CameraManager::CameraManager() :
|
||||
m_data_buffer( 4_KiB, vk::BufferUsageFlagBits::eUniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible )
|
||||
{
|
||||
Camera::initCameraRenderer();
|
||||
debug::setDebugDrawingCamera( getPrimary() );
|
||||
debug::setDebugDrawingCamera( *getPrimary() );
|
||||
|
||||
m_primary_camera = createCamera( { 1920, 1080 } );
|
||||
m_primary_camera->setName( CAMERA_EDITOR_NAME );
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "engine/buffers/UniqueFrameSuballocation.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -23,13 +22,15 @@ namespace fgl::engine
|
||||
|
||||
std::vector< std::weak_ptr< Camera > > cameras {};
|
||||
|
||||
CameraManager();
|
||||
|
||||
public:
|
||||
|
||||
static CameraManager& getInstance();
|
||||
|
||||
std::vector< std::weak_ptr< Camera > >& getCameras();
|
||||
|
||||
Camera& getPrimary();
|
||||
|
||||
CameraManager();
|
||||
std::shared_ptr< Camera >& getPrimary();
|
||||
|
||||
std::shared_ptr< Camera > createCamera( vk::Extent2D extent );
|
||||
};
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 6/25/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FULL_DEBUG_BARRIER( buffer ) \
|
||||
{ \
|
||||
vk::MemoryBarrier memory_barrier {}; \
|
||||
memory_barrier.srcAccessMask = vk::AccessFlagBits::eMemoryWrite | vk::AccessFlagBits::eMemoryRead; \
|
||||
memory_barrier.dstAccessMask = vk::AccessFlagBits::eMemoryWrite | vk::AccessFlagBits::eMemoryRead; \
|
||||
std::vector< vk::MemoryBarrier > barriers { memory_barrier }; \
|
||||
\
|
||||
buffer.pipelineBarrier( \
|
||||
vk::PipelineStageFlagBits::eAllCommands, \
|
||||
vk::PipelineStageFlagBits::eAllCommands, \
|
||||
vk::DependencyFlagBits::eByRegion, \
|
||||
barriers, \
|
||||
{}, \
|
||||
{} ); \
|
||||
}
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
#include "GameObject.hpp"
|
||||
|
||||
#include "engine/gui/helpers.hpp"
|
||||
#include "engine/gui/safe_include.hpp"
|
||||
#include "engine/model/Model.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -17,6 +13,7 @@ namespace fgl::engine
|
||||
return GameObject( current_id++ );
|
||||
}
|
||||
|
||||
/*
|
||||
void GameObject::drawImGui()
|
||||
{
|
||||
ImGui::InputText( "Name", &( this->getName() ) );
|
||||
@@ -37,5 +34,6 @@ namespace fgl::engine
|
||||
component->drawImGui();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
struct Scale;
|
||||
template < CoordinateSpace CType >
|
||||
struct OrientedBoundingBox;
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace fgl::engine
|
||||
GameObjectFlagType object_flags { GameObjectFlagMask::MASK_DEFAULT };
|
||||
TransformComponent m_transform {};
|
||||
|
||||
std::vector< GameObjectComponentBase* > components {};
|
||||
std::vector< GameObjectComponentPtr > components {};
|
||||
|
||||
std::string name {};
|
||||
|
||||
@@ -64,13 +65,15 @@ namespace fgl::engine
|
||||
components.emplace_back( ptr.release() );
|
||||
}
|
||||
|
||||
Scale& getScale() { return m_transform.scale; }
|
||||
|
||||
GameObject( GameObject&& other ) = default;
|
||||
|
||||
template < typename T >
|
||||
requires is_component< T >
|
||||
bool hasComponent() const
|
||||
{
|
||||
for ( const GameObjectComponentBase* comp : components )
|
||||
for ( const GameObjectComponentPtr comp : components )
|
||||
{
|
||||
if ( comp->id() == T::ID ) return true;
|
||||
}
|
||||
@@ -84,7 +87,7 @@ namespace fgl::engine
|
||||
{
|
||||
std::vector< const T* > temp {};
|
||||
|
||||
for ( const GameObjectComponentBase* comp : components )
|
||||
for ( const ComponentEngineInterface* comp : components )
|
||||
{
|
||||
if ( comp->id() == T::ID ) temp.emplace_back( static_cast< const T* >( comp ) );
|
||||
}
|
||||
@@ -98,7 +101,7 @@ namespace fgl::engine
|
||||
{
|
||||
std::vector< T* > temp {};
|
||||
|
||||
for ( GameObjectComponentBase* comp : components )
|
||||
for ( ComponentEngineInterface* comp : components )
|
||||
{
|
||||
if ( comp->id() == T::ID ) temp.emplace_back( comp );
|
||||
}
|
||||
@@ -106,6 +109,10 @@ namespace fgl::engine
|
||||
return temp;
|
||||
}
|
||||
|
||||
std::vector< GameObjectComponentPtr >& getComponents() { return components; }
|
||||
|
||||
const std::vector< GameObjectComponentPtr >& getComponents() const { return components; }
|
||||
|
||||
//Flags
|
||||
GameObjectFlagType flags() const { return object_flags; }
|
||||
|
||||
@@ -120,7 +127,9 @@ namespace fgl::engine
|
||||
|
||||
const WorldCoordinate& getPosition() const { return m_transform.translation; }
|
||||
|
||||
const Rotation& getRotation() const { return m_transform.rotation; }
|
||||
// const Rotation& getRotation() const { return m_transform.rotation; }
|
||||
|
||||
Rotation& getRotation() { return m_transform.rotation; }
|
||||
|
||||
//Misc
|
||||
static GameObject createGameObject();
|
||||
@@ -130,7 +139,7 @@ namespace fgl::engine
|
||||
//! Returns the name of the game object. If no name is set then the name of the model is used.
|
||||
std::string& getName() { return name; }
|
||||
|
||||
void drawImGui();
|
||||
// void drawImGui();
|
||||
};
|
||||
|
||||
// static_assert( offsetof( GameObject, hot_limter ) < 64, "Hot limit reached" );
|
||||
|
||||
27
src/engine/gameobjects/components/CameraComponent.hpp
Normal file
27
src/engine/gameobjects/components/CameraComponent.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by kj16609 on 8/2/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "GameObjectComponent.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
class Camera;
|
||||
|
||||
class CameraComponent final : public GameObjectComponent< 2 >
|
||||
{
|
||||
std::shared_ptr< Camera > m_camera;
|
||||
|
||||
public:
|
||||
|
||||
CameraComponent() = delete;
|
||||
CameraComponent( std::shared_ptr< Camera >& camera );
|
||||
~CameraComponent();
|
||||
};
|
||||
|
||||
static_assert( is_component< CameraComponent > );
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by kj16609 on 7/7/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef IDHAN_EDITOR
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
struct ComponentEditorInterface
|
||||
{
|
||||
#ifdef IDHAN_EDITOR
|
||||
virtual void drawImGui() = 0;
|
||||
virtual std::string_view name() const = 0;
|
||||
#endif
|
||||
virtual ~ComponentEditorInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by kj16609 on 7/7/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "ComponentEditorInterface.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
struct ComponentEngineInterface
|
||||
{
|
||||
using ComponentID = std::uint16_t;
|
||||
virtual ComponentID id() const = 0;
|
||||
|
||||
virtual ~ComponentEngineInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 7/7/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
struct ComponentImGuiInterface
|
||||
{
|
||||
virtual void drawImGui() = 0;
|
||||
virtual ~ComponentImGuiInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -4,26 +4,33 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ComponentImGuiInterface.hpp"
|
||||
#include "GameObjectComponentBase.hpp"
|
||||
#include "ComponentEngineInterface.hpp"
|
||||
#include "engine/primitives/TransformComponent.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
using ComponentTransform = TransformComponent;
|
||||
|
||||
template < GameObjectComponentBase::ComponentID T_ID >
|
||||
struct GameObjectComponentBase : public ComponentEditorInterface, public ComponentEngineInterface
|
||||
{};
|
||||
|
||||
using GameObjectComponentPtr = GameObjectComponentBase*;
|
||||
|
||||
template < ComponentEngineInterface::ComponentID T_ID >
|
||||
struct GameObjectComponent : public GameObjectComponentBase
|
||||
{
|
||||
constexpr static ComponentID ID { T_ID };
|
||||
ComponentTransform m_transform;
|
||||
|
||||
virtual ComponentID id() const override final { return ID; }
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
concept is_component = requires( T t ) {
|
||||
std::is_base_of_v< T, GameObjectComponentBase >;
|
||||
std::is_base_of_v< T, ComponentEngineInterface >;
|
||||
{
|
||||
t.ID
|
||||
} -> std::same_as< const GameObjectComponentBase::ComponentID& >;
|
||||
} -> std::same_as< const ComponentEngineInterface::ComponentID& >;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -1,22 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 7/7/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
struct GameObjectComponentBase : public ComponentImGuiInterface
|
||||
{
|
||||
using ComponentID = std::uint8_t;
|
||||
virtual ComponentID id() const = 0;
|
||||
virtual std::string_view name() const = 0;
|
||||
|
||||
virtual ~GameObjectComponentBase() override = default;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "GameObjectComponent.hpp"
|
||||
#include "engine/primitives/TransformComponent.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -16,12 +15,12 @@ namespace fgl::engine
|
||||
class ModelComponent final : public GameObjectComponent< 1 >
|
||||
{
|
||||
std::shared_ptr< Model > m_model;
|
||||
TransformComponent m_model_transform {};
|
||||
|
||||
public:
|
||||
|
||||
ModelComponent( std::shared_ptr< Model >&& model ) : m_model( std::forward< decltype( m_model ) >( model ) ) {}
|
||||
|
||||
#ifdef IDHAN_EDITOR
|
||||
void drawImGui() override;
|
||||
|
||||
std::string_view name() const override
|
||||
@@ -29,11 +28,10 @@ namespace fgl::engine
|
||||
//TODO: Get name of component
|
||||
return "TEST NAME";
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual ~ModelComponent() override {}
|
||||
|
||||
void setModel( const std::filesystem::path path );
|
||||
|
||||
Model* operator->() { return m_model.get(); }
|
||||
|
||||
const Model* operator->() const { return m_model.get(); }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Rotation.hpp"
|
||||
#include "Scale.hpp"
|
||||
#include "engine/primitives/points/Coordinate.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
@@ -16,7 +17,7 @@ namespace fgl::engine
|
||||
struct TransformComponent
|
||||
{
|
||||
WorldCoordinate translation { constants::WORLD_CENTER };
|
||||
glm::vec3 scale { 1.0f, 1.0f, 1.0f };
|
||||
Scale scale { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
Rotation rotation { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace fgl::engine
|
||||
std::vector< vk::raii::CommandBuffer > m_command_buffer {};
|
||||
std::vector< vk::raii::CommandBuffer > m_gui_command_buffer {};
|
||||
|
||||
std::optional< TracyVkCtx > m_tracy_ctx { std::nullopt };
|
||||
TracyVkCtx m_tracy_ctx { nullptr };
|
||||
|
||||
PresentIndex current_present_index { std::numeric_limits< PresentIndex >::max() };
|
||||
FrameIndex current_frame_idx { 0 };
|
||||
@@ -62,15 +62,7 @@ namespace fgl::engine
|
||||
|
||||
vk::raii::CommandBuffer& getCurrentGuiCommandBuffer() { return m_gui_command_buffer[ current_frame_idx ]; }
|
||||
|
||||
TracyVkCtx getCurrentTracyCTX() const
|
||||
{
|
||||
#if TRACY_ENABLE
|
||||
assert( m_tracy_ctx.has_value() );
|
||||
return m_tracy_ctx.value();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
TracyVkCtx getCurrentTracyCTX() const { return m_tracy_ctx; }
|
||||
|
||||
vk::raii::RenderPass& getSwapChainRenderPass() const { return m_swapchain->getRenderPass(); }
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace fgl::engine
|
||||
{
|
||||
ZoneScopedN( "Culling pass" );
|
||||
|
||||
const auto frustum { info.camera_data.camera->getFrustumBounds() };
|
||||
const auto frustum { info.camera->getFrustumBounds() };
|
||||
|
||||
if ( !enable_culling )
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace fgl::engine
|
||||
|
||||
//Get all commands for drawing anything without a texture
|
||||
auto [ draw_commands, model_matricies ] = getDrawCallsFromTree(
|
||||
info.game_objects, info.camera_data.camera->getFrustumBounds(), IS_VISIBLE | IS_ENTITY, IS_TEXTURELESS );
|
||||
info.game_objects, info.camera->getFrustumBounds(), IS_VISIBLE | IS_ENTITY, IS_TEXTURELESS );
|
||||
|
||||
//TODO: Filter Textureless models (#6)
|
||||
|
||||
@@ -127,8 +127,8 @@ namespace fgl::engine
|
||||
m_textured_pipeline
|
||||
->bindDescriptor( command_buffer, TextureDescriptorSet::m_set_idx, Texture::getTextureDescriptorSet() );
|
||||
|
||||
auto [ draw_commands, model_matricies ] = getDrawCallsFromTree(
|
||||
info.game_objects, info.camera_data.camera->getFrustumBounds(), IS_VISIBLE | IS_ENTITY );
|
||||
auto [ draw_commands, model_matricies ] =
|
||||
getDrawCallsFromTree( info.game_objects, info.camera->getFrustumBounds(), IS_VISIBLE | IS_ENTITY );
|
||||
|
||||
if ( draw_commands.empty() ) return;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "GuiSystem.hpp"
|
||||
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "engine/gui/core.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -40,7 +39,7 @@ namespace fgl::engine
|
||||
command_buffer.draw( 3, 1, 0, 0 );
|
||||
|
||||
//Handle GUI
|
||||
gui::drawMainGUI( info );
|
||||
// gui::drawMainGUI( info );
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
Reference in New Issue
Block a user