From aec48186c64adb1b16ac436b40f5b923ba5de072 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Wed, 14 Aug 2024 16:01:44 -0400 Subject: [PATCH] Some component and rendering cleanup --- src/editor/src/components/ModelComponent.cpp | 30 ++++++-- src/editor/src/gui/core.cpp | 28 +------- src/editor/src/gui/core.hpp | 5 ++ src/editor/src/gui/drawGameObject.cpp | 46 +++++++++++++ src/engine/EngineContext.hpp | 4 -- src/engine/FrameInfo.cpp | 2 +- src/engine/FrameInfo.hpp | 2 +- src/engine/buffers/Buffer.cpp | 2 +- src/engine/buffers/BufferSuballocation.hpp | 2 +- src/engine/camera/CameraRenderer.cpp | 2 +- src/engine/camera/CameraSwapchain.hpp | 2 +- src/engine/concepts/is_attachment.hpp | 2 +- .../concepts/is_descriptor_set_collection.hpp | 6 +- src/engine/descriptors/DescriptorPool.cpp | 13 ++-- src/engine/descriptors/DescriptorPool.hpp | 4 +- .../descriptors/DescriptorSetLayout.hpp | 2 +- .../gameobjects/components/ModelComponent.hpp | 18 +---- src/engine/gameobjects/components/drawers.cpp | 69 +++++++++++++++++++ src/engine/gameobjects/components/drawers.hpp | 13 ++++ .../interface/ComponentEditorInterface.cpp | 12 ++++ .../interface/ComponentEditorInterface.hpp | 4 -- .../interface/GameObjectComponent.cpp | 33 +++++++++ .../interface/GameObjectComponent.hpp | 16 ++++- src/engine/image/ImageHandle.hpp | 2 +- src/engine/image/Sampler.cpp | 2 +- src/engine/model/Model.cpp | 11 +-- src/engine/model/Model.hpp | 8 ++- src/engine/model/Primitive.hpp | 2 + src/engine/model/builders/SceneBuilder.cpp | 3 +- src/engine/rendering/QueuePool.cpp | 2 +- src/engine/rendering/Renderer.cpp | 1 - src/engine/rendering/Renderer.hpp | 1 - src/engine/rendering/SwapChain.cpp | 5 +- src/engine/rendering/SwapChain.hpp | 4 +- src/engine/rendering/{ => devices}/Device.cpp | 2 +- src/engine/rendering/{ => devices}/Device.hpp | 4 +- .../{ => devices}/PhysicalDevice.cpp | 4 +- .../{ => devices}/PhysicalDevice.hpp | 2 +- .../rendering/{ => pipelines}/Attachment.hpp | 6 +- .../pipelines}/Pipeline.cpp | 2 +- .../pipelines}/Pipeline.hpp | 2 +- .../pipelines}/PipelineConfigInfo.cpp | 3 +- .../pipelines}/PipelineConfigInfo.hpp | 2 +- .../pipelines}/PipelineT.hpp | 6 +- .../pipelines}/Shader.cpp | 4 +- .../pipelines}/Shader.hpp | 2 +- .../pipelines}/shaders/Compiler.cpp | 0 .../pipelines}/shaders/Compiler.hpp | 0 .../rendering/{ => renderpass}/RenderPass.cpp | 2 +- .../rendering/{ => renderpass}/RenderPass.hpp | 0 .../rendering/{ => renderpass}/Subpass.hpp | 2 +- src/engine/systems/CompositionSystem.hpp | 4 +- src/engine/systems/EntityRendererSystem.hpp | 2 +- src/engine/systems/GuiSystem.hpp | 4 +- src/engine/systems/LineDrawer.hpp | 2 +- src/engine/systems/TerrainSystem.hpp | 2 +- .../modelRendering/StandardPipeline.hpp | 4 +- .../modelRendering/TexturedPipeline.hpp | 4 +- 58 files changed, 297 insertions(+), 126 deletions(-) create mode 100644 src/editor/src/gui/drawGameObject.cpp create mode 100644 src/engine/gameobjects/components/drawers.cpp create mode 100644 src/engine/gameobjects/components/drawers.hpp create mode 100644 src/engine/gameobjects/components/interface/ComponentEditorInterface.cpp create mode 100644 src/engine/gameobjects/components/interface/GameObjectComponent.cpp rename src/engine/rendering/{ => devices}/Device.cpp (99%) rename src/engine/rendering/{ => devices}/Device.hpp (97%) rename src/engine/rendering/{ => devices}/PhysicalDevice.cpp (97%) rename src/engine/rendering/{ => devices}/PhysicalDevice.hpp (95%) rename src/engine/rendering/{ => pipelines}/Attachment.hpp (98%) rename src/engine/{pipeline => rendering/pipelines}/Pipeline.cpp (98%) rename src/engine/{pipeline => rendering/pipelines}/Pipeline.hpp (96%) rename src/engine/{pipeline => rendering/pipelines}/PipelineConfigInfo.cpp (99%) rename src/engine/{pipeline => rendering/pipelines}/PipelineConfigInfo.hpp (98%) rename src/engine/{pipeline => rendering/pipelines}/PipelineT.hpp (96%) rename src/engine/{pipeline => rendering/pipelines}/Shader.cpp (95%) rename src/engine/{pipeline => rendering/pipelines}/Shader.hpp (98%) rename src/engine/{ => rendering/pipelines}/shaders/Compiler.cpp (100%) rename src/engine/{ => rendering/pipelines}/shaders/Compiler.hpp (100%) rename src/engine/rendering/{ => renderpass}/RenderPass.cpp (99%) rename src/engine/rendering/{ => renderpass}/RenderPass.hpp (100%) rename src/engine/rendering/{ => renderpass}/Subpass.hpp (99%) diff --git a/src/editor/src/components/ModelComponent.cpp b/src/editor/src/components/ModelComponent.cpp index 5c8be14..c56fe13 100644 --- a/src/editor/src/components/ModelComponent.cpp +++ b/src/editor/src/components/ModelComponent.cpp @@ -4,15 +4,37 @@ #include "engine/gameobjects/components/ModelComponent.hpp" +#include "engine/gameobjects/components/drawers.hpp" +#include "engine/model/Model.hpp" #include "gui/safe_include.hpp" namespace fgl::engine { + +#ifdef TITOR_EDITOR void ModelComponent::drawImGui() { - if ( ImGui::CollapsingHeader( "Model Component", ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_DefaultOpen ) ) - { - ImGui::Text( "MODEL COMPONENT WOOOOOO" ); - } + drawComponentTransform( m_transform ); + + ImGui::Text( "MODEL COMPONENT WOOOOOO" ); + } + + std::string_view ModelComponent::name() const + { + if ( m_model ) + return m_model->getName(); + else + return "Empty Model"; + } +#endif + + Model* ModelComponent::operator->() + { + return m_model.get(); + } + + const Model* ModelComponent::operator->() const + { + return m_model.get(); } } // namespace fgl::engine diff --git a/src/editor/src/gui/core.cpp b/src/editor/src/gui/core.cpp index ade39f6..a0bb398 100644 --- a/src/editor/src/gui/core.cpp +++ b/src/editor/src/gui/core.cpp @@ -18,11 +18,9 @@ #include "engine/debug/DEBUG_NAMES.hpp" #include "engine/descriptors/DescriptorPool.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 @@ -207,30 +205,6 @@ namespace fgl::engine::gui ImGui::End(); } - void drawObject( GameObject& game_object ) - { - static std::string name_input_temp { "" }; - name_input_temp = game_object.getName(); - ImGui::InputText( "Name", &name_input_temp ); - if ( game_object.getName() != name_input_temp ) game_object.setName( name_input_temp ); - - // 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; @@ -243,7 +217,7 @@ namespace fgl::engine::gui } drawObject( *selected_object ); - drawComponents( *selected_object ); + drawComponentsList( *selected_object ); ImGui::End(); } diff --git a/src/editor/src/gui/core.hpp b/src/editor/src/gui/core.hpp index a14cecc..50c9ae5 100644 --- a/src/editor/src/gui/core.hpp +++ b/src/editor/src/gui/core.hpp @@ -6,6 +6,7 @@ namespace fgl::engine { + class GameObject; class Device; class Renderer; class Window; @@ -23,6 +24,10 @@ namespace fgl::engine::gui void drawEntityInfo( FrameInfo& ); void drawFilesystemGUI( FrameInfo& info ); + void drawObject( GameObject& game_object ); + void drawComponentsList( GameObject& game_object ); + void drawSelectedComponent(); + void drawCameraOutputs( FrameInfo& info ); void drawStats( const FrameInfo& info ); diff --git a/src/editor/src/gui/drawGameObject.cpp b/src/editor/src/gui/drawGameObject.cpp new file mode 100644 index 0000000..87654a5 --- /dev/null +++ b/src/editor/src/gui/drawGameObject.cpp @@ -0,0 +1,46 @@ +// +// Created by kj16609 on 8/13/24. +// + +#include "engine/gameobjects/GameObject.hpp" +#include "gui/helpers.hpp" + +namespace fgl::engine::gui +{ + void drawObject( GameObject& game_object ) + { + static std::string name_input_temp { "" }; + name_input_temp = game_object.getName(); + ImGui::InputText( "Name", &name_input_temp ); + if ( game_object.getName() != name_input_temp ) game_object.setName( name_input_temp ); + + // Transform - Position + dragFloat3( "Position", game_object.getTransform().translation.vec() ); + + dragFloat3Rot( "Rotation", game_object.getRotation() ); + + dragFloat3( "Scale", game_object.getScale() ); + } + + static GameObjectComponentPtr selected_component { nullptr }; + + void drawComponentsList( GameObject& game_object ) + { + ImGui::SeparatorText( "Components" ); + + for ( GameObjectComponentPtr component : game_object.getComponents() ) + { + component->drawNode( selected_component ); + } + + if ( selected_component ) + { + ImGui::SeparatorText( "Selected Component" ); + + ImGui::PushID( ImGui::GetID( "ComponentEditor" ) ); + selected_component->drawImGui(); + ImGui::PopID(); + } + } + +} // namespace fgl::engine::gui \ No newline at end of file diff --git a/src/engine/EngineContext.hpp b/src/engine/EngineContext.hpp index 0af89b9..893eddf 100644 --- a/src/engine/EngineContext.hpp +++ b/src/engine/EngineContext.hpp @@ -67,12 +67,8 @@ namespace fgl::engine void loadGameObjects(); -#ifdef TITOR_EDITOR - public: -#endif - FGL_FORCE_INLINE_FLATTEN void hookInitImGui( const std::function< void( Window&, Renderer& ) >& func ) { func( m_window, m_renderer ); diff --git a/src/engine/FrameInfo.cpp b/src/engine/FrameInfo.cpp index ba709e6..329a576 100644 --- a/src/engine/FrameInfo.cpp +++ b/src/engine/FrameInfo.cpp @@ -6,7 +6,7 @@ #include "camera/Camera.hpp" #include "camera/CameraSwapchain.hpp" -#include "pipeline/Pipeline.hpp" +#include "rendering/pipelines/Pipeline.hpp" namespace fgl::engine { diff --git a/src/engine/FrameInfo.hpp b/src/engine/FrameInfo.hpp index 240fd6e..9cc6eee 100644 --- a/src/engine/FrameInfo.hpp +++ b/src/engine/FrameInfo.hpp @@ -12,8 +12,8 @@ #include "descriptors/Descriptor.hpp" #include "descriptors/DescriptorSetLayout.hpp" -#include "pipeline/Pipeline.hpp" #include "primitives/Frustum.hpp" +#include "rendering/pipelines/Pipeline.hpp" #include "rendering/types.hpp" #define MAX_LIGHTS 10 diff --git a/src/engine/buffers/Buffer.cpp b/src/engine/buffers/Buffer.cpp index edffb36..6aa3dde 100644 --- a/src/engine/buffers/Buffer.cpp +++ b/src/engine/buffers/Buffer.cpp @@ -8,7 +8,7 @@ #include "align.hpp" #include "engine/buffers/exceptions.hpp" #include "engine/literals/size.hpp" -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::memory { diff --git a/src/engine/buffers/BufferSuballocation.hpp b/src/engine/buffers/BufferSuballocation.hpp index 0bf233f..0a08391 100644 --- a/src/engine/buffers/BufferSuballocation.hpp +++ b/src/engine/buffers/BufferSuballocation.hpp @@ -5,7 +5,7 @@ #pragma once #include "BufferSuballocationHandle.hpp" -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::memory { diff --git a/src/engine/camera/CameraRenderer.cpp b/src/engine/camera/CameraRenderer.cpp index ec67908..f785ade 100644 --- a/src/engine/camera/CameraRenderer.cpp +++ b/src/engine/camera/CameraRenderer.cpp @@ -5,7 +5,7 @@ #include "CameraRenderer.hpp" #include "CameraSwapchain.hpp" -#include "engine/rendering/RenderPass.hpp" +#include "engine/rendering/renderpass/RenderPass.hpp" namespace fgl::engine { diff --git a/src/engine/camera/CameraSwapchain.hpp b/src/engine/camera/CameraSwapchain.hpp index 1bc3b59..0a65f03 100644 --- a/src/engine/camera/CameraSwapchain.hpp +++ b/src/engine/camera/CameraSwapchain.hpp @@ -4,8 +4,8 @@ #pragma once +#include "../rendering/pipelines/Attachment.hpp" #include "engine/descriptors/DescriptorSet.hpp" -#include "engine/rendering/Attachment.hpp" #include "engine/rendering/SwapChain.hpp" namespace fgl::engine diff --git a/src/engine/concepts/is_attachment.hpp b/src/engine/concepts/is_attachment.hpp index bdf6095..e307d6a 100644 --- a/src/engine/concepts/is_attachment.hpp +++ b/src/engine/concepts/is_attachment.hpp @@ -6,7 +6,7 @@ #include -#include "engine/rendering/Attachment.hpp" +#include "../rendering/pipelines/Attachment.hpp" namespace fgl::engine { diff --git a/src/engine/concepts/is_descriptor_set_collection.hpp b/src/engine/concepts/is_descriptor_set_collection.hpp index 7b5f115..58b2107 100644 --- a/src/engine/concepts/is_descriptor_set_collection.hpp +++ b/src/engine/concepts/is_descriptor_set_collection.hpp @@ -4,10 +4,12 @@ #pragma once +#include +#include + namespace fgl::engine { - template < typename T > concept is_descriptor_set_collection = requires( T t ) { typename T::DescriptorSetTuple; @@ -16,4 +18,4 @@ namespace fgl::engine } -> std::same_as< const std::uint64_t& >; }; -} \ No newline at end of file +} // namespace fgl::engine \ No newline at end of file diff --git a/src/engine/descriptors/DescriptorPool.cpp b/src/engine/descriptors/DescriptorPool.cpp index c0914bd..6998b41 100644 --- a/src/engine/descriptors/DescriptorPool.cpp +++ b/src/engine/descriptors/DescriptorPool.cpp @@ -4,12 +4,12 @@ #include "DescriptorPool.hpp" -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::descriptors { - vk::raii::DescriptorPool createPool( Device& device, std::uint32_t set_count ) + vk::raii::DescriptorPool createPool( std::uint32_t set_count ) { std::vector< vk::DescriptorPoolSize > pool_sizes {}; for ( auto& [ type, ratio ] : descriptor_allocation_ratios ) @@ -24,11 +24,10 @@ namespace fgl::engine::descriptors pool_info.setFlags( vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet | vk::DescriptorPoolCreateFlagBits::eUpdateAfterBind ); - return device->createDescriptorPool( pool_info ); + return Device::getInstance()->createDescriptorPool( pool_info ); } - DescriptorPool::DescriptorPool( Device& device, std::uint32_t set_count ) : - m_pool( createPool( device, set_count ) ) + DescriptorPool::DescriptorPool( std::uint32_t set_count ) : m_pool( createPool( set_count ) ) {} [[nodiscard]] vk::raii::DescriptorSet DescriptorPool::allocateSet( vk::raii::DescriptorSetLayout& layout ) @@ -48,10 +47,10 @@ namespace fgl::engine::descriptors static DescriptorPool* s_pool { nullptr }; - DescriptorPool& DescriptorPool::init( Device& device ) + DescriptorPool& DescriptorPool::init() { assert( !s_pool && "Descriptor pool already initialized" ); - s_pool = new DescriptorPool( device, 1000 ); + s_pool = new DescriptorPool( 1000 ); return *s_pool; } diff --git a/src/engine/descriptors/DescriptorPool.hpp b/src/engine/descriptors/DescriptorPool.hpp index 04f83d4..2334f0c 100644 --- a/src/engine/descriptors/DescriptorPool.hpp +++ b/src/engine/descriptors/DescriptorPool.hpp @@ -25,7 +25,7 @@ namespace fgl::engine::descriptors { vk::raii::DescriptorPool m_pool; - DescriptorPool( Device& device, std::uint32_t set_count ); + DescriptorPool( std::uint32_t set_count ); public: @@ -38,7 +38,7 @@ namespace fgl::engine::descriptors VkDescriptorPool operator*() { return *m_pool; } - static DescriptorPool& init( Device& device ); + static DescriptorPool& init(); [[nodiscard]] static DescriptorPool& getInstance(); [[nodiscard]] vk::raii::DescriptorSet allocateSet( vk::raii::DescriptorSetLayout& layout ); diff --git a/src/engine/descriptors/DescriptorSetLayout.hpp b/src/engine/descriptors/DescriptorSetLayout.hpp index f529ae4..fdd6093 100644 --- a/src/engine/descriptors/DescriptorSetLayout.hpp +++ b/src/engine/descriptors/DescriptorSetLayout.hpp @@ -9,7 +9,7 @@ #include "engine/concepts/is_descriptor.hpp" #include "engine/concepts/is_descriptor_set.hpp" #include "engine/concepts/is_empty_descriptor_set.hpp" -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::descriptors { diff --git a/src/engine/gameobjects/components/ModelComponent.hpp b/src/engine/gameobjects/components/ModelComponent.hpp index bea68be..5b62c7e 100644 --- a/src/engine/gameobjects/components/ModelComponent.hpp +++ b/src/engine/gameobjects/components/ModelComponent.hpp @@ -22,28 +22,16 @@ namespace fgl::engine ModelComponent( std::shared_ptr< Model > && model ) : m_model( std::forward< decltype( m_model ) >( model ) ) {} -#ifdef TITOR_EDITOR void drawImGui() override; - std::string_view name() const override - { - //TODO: Get name of component - return "TEST NAME"; - } -#endif + std::string_view name() const override; virtual ~ModelComponent() override {} - Model* operator->() - { - return m_model.get(); - } + Model* operator->(); - const Model* operator->() const - { - return m_model.get(); - } + const Model* operator->() const; }; static_assert( is_component< ModelComponent > ); diff --git a/src/engine/gameobjects/components/drawers.cpp b/src/engine/gameobjects/components/drawers.cpp new file mode 100644 index 0000000..96daa4c --- /dev/null +++ b/src/engine/gameobjects/components/drawers.cpp @@ -0,0 +1,69 @@ +// +// Created by kj16609 on 8/13/24. +// + +#include "drawers.hpp" + +#include + +namespace fgl::engine +{ + + void InputRotation( const char* label, Rotation& rot, float speed ) + { + enum Axis + { + Pitch = 0, + Yaw = 1, + Roll = 2 + }; + + glm::vec3 dat { glm::degrees( rot.euler() ) }; + const glm::vec3 c_dat { dat }; + + assert( &dat.x + 1 == &dat.y ); + assert( &dat.y + 1 == &dat.z ); + + ImGui::DragFloat3( label, &dat.x, speed ); + + const glm::vec3 diff { c_dat - dat }; + constexpr float epsilon { std::numeric_limits< float >::epsilon() }; + + const glm::vec< 3, bool > changed_high { glm::greaterThanEqual( diff, glm::vec3( epsilon ) ) }; + const glm::vec< 3, bool > changed_low { glm::lessThanEqual( diff, glm::vec3( -epsilon ) ) }; + const glm::vec< 3, bool > changed { changed_high || changed_low }; + + // Convert back to radians + dat = glm::radians( dat ); + + if ( changed[ Pitch ] ) + { + rot.pitch() = dat[ Pitch ]; + } + + if ( changed[ Roll ] ) + { + rot.roll() = dat[ Roll ]; + } + + if ( changed[ Yaw ] ) + { + rot.yaw() = dat[ Yaw ]; + } + } + + void drawComponentTransform( ComponentTransform& transform ) + { + if ( ImGui::CollapsingHeader( "Transform" ) ) + { + constexpr float speed { 1.0f }; + + ImGui::DragFloat3( "Position", &transform.translation.x, speed ); + + InputRotation( "Rotation", transform.rotation, speed ); + + ImGui::DragFloat3( "Scale", &transform.scale.x, speed ); + } + } + +} // namespace fgl::engine diff --git a/src/engine/gameobjects/components/drawers.hpp b/src/engine/gameobjects/components/drawers.hpp new file mode 100644 index 0000000..11815f6 --- /dev/null +++ b/src/engine/gameobjects/components/drawers.hpp @@ -0,0 +1,13 @@ +// +// Created by kj16609 on 8/13/24. +// + +#pragma once +#include "interface/GameObjectComponent.hpp" + +namespace fgl::engine +{ + + void drawComponentTransform( ComponentTransform& transform ); + +} \ No newline at end of file diff --git a/src/engine/gameobjects/components/interface/ComponentEditorInterface.cpp b/src/engine/gameobjects/components/interface/ComponentEditorInterface.cpp new file mode 100644 index 0000000..ffa606b --- /dev/null +++ b/src/engine/gameobjects/components/interface/ComponentEditorInterface.cpp @@ -0,0 +1,12 @@ +// +// Created by kj16609 on 8/13/24. +// + +#include "ComponentEditorInterface.hpp" + +#include + +namespace fgl::engine +{ + +} // namespace fgl::engine diff --git a/src/engine/gameobjects/components/interface/ComponentEditorInterface.hpp b/src/engine/gameobjects/components/interface/ComponentEditorInterface.hpp index 66455ff..97648c1 100644 --- a/src/engine/gameobjects/components/interface/ComponentEditorInterface.hpp +++ b/src/engine/gameobjects/components/interface/ComponentEditorInterface.hpp @@ -4,19 +4,15 @@ #pragma once -#ifdef TITOR_EDITOR #include -#endif namespace fgl::engine { struct ComponentEditorInterface { -#ifdef TITOR_EDITOR virtual void drawImGui() = 0; virtual std::string_view name() const = 0; -#endif virtual ~ComponentEditorInterface() = default; }; diff --git a/src/engine/gameobjects/components/interface/GameObjectComponent.cpp b/src/engine/gameobjects/components/interface/GameObjectComponent.cpp new file mode 100644 index 0000000..c0ead0a --- /dev/null +++ b/src/engine/gameobjects/components/interface/GameObjectComponent.cpp @@ -0,0 +1,33 @@ +// +// Created by kj16609 on 8/13/24. +// + +#include "GameObjectComponent.hpp" + +#include + +namespace fgl::engine +{ + constexpr auto indent_amount { 1.0f }; + + void GameObjectComponentBase::drawNode( GameObjectComponentPtr& selected_out ) + { + ImGui::Indent( indent_amount ); + if ( ImGui::Selectable( this->name().data() ) ) + { + selected_out = this; + } + + drawChildren( selected_out ); + ImGui::Unindent( indent_amount ); + } + + void GameObjectComponentBase::drawChildren( GameObjectComponentPtr& selected_out ) + { + for ( auto* child : m_children ) + { + child->drawNode( selected_out ); + } + } + +} // namespace fgl::engine \ No newline at end of file diff --git a/src/engine/gameobjects/components/interface/GameObjectComponent.hpp b/src/engine/gameobjects/components/interface/GameObjectComponent.hpp index d650a1f..a3d4ad6 100644 --- a/src/engine/gameobjects/components/interface/GameObjectComponent.hpp +++ b/src/engine/gameobjects/components/interface/GameObjectComponent.hpp @@ -4,6 +4,8 @@ #pragma once +#include + #include "ComponentEngineInterface.hpp" #include "engine/primitives/TransformComponent.hpp" @@ -16,7 +18,7 @@ namespace fgl::engine { enum Mode { - //! Object is non moving, + //! Object is non moving, When this is set only the transform on the component should be used. Static, //! Object moves in relation to it's parent Local, @@ -26,7 +28,13 @@ namespace fgl::engine }; struct GameObjectComponentBase : public ComponentEditorInterface, public ComponentEngineInterface - {}; + { + std::vector< GameObjectComponentBase* > m_children {}; + + void drawNode( GameObjectComponentBase*& selected_out ); + + void drawChildren( GameObjectComponentBase*& selected_out ); + }; using GameObjectComponentPtr = GameObjectComponentBase*; @@ -44,7 +52,9 @@ namespace fgl::engine template < typename T > concept is_component = requires( T t ) { std::is_base_of_v< T, ComponentEngineInterface >; - { t.ID } -> std::same_as< const ComponentEngineInterface::ComponentID& >; + { + t.ID + } -> std::same_as< const ComponentEngineInterface::ComponentID& >; }; } // namespace fgl::engine \ No newline at end of file diff --git a/src/engine/image/ImageHandle.hpp b/src/engine/image/ImageHandle.hpp index fdcd054..b579c2d 100644 --- a/src/engine/image/ImageHandle.hpp +++ b/src/engine/image/ImageHandle.hpp @@ -9,7 +9,7 @@ #include #include "engine/logging/logging.hpp" -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" #include "vma/vma_impl.hpp" #include "vulkan/vulkan.hpp" diff --git a/src/engine/image/Sampler.cpp b/src/engine/image/Sampler.cpp index 6acab85..5750e77 100644 --- a/src/engine/image/Sampler.cpp +++ b/src/engine/image/Sampler.cpp @@ -6,7 +6,7 @@ #include -#include "engine/rendering/Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine { diff --git a/src/engine/model/Model.cpp b/src/engine/model/Model.cpp index 02bf334..23e06fb 100644 --- a/src/engine/model/Model.cpp +++ b/src/engine/model/Model.cpp @@ -78,19 +78,22 @@ namespace fgl::engine } Model::Model( - ModelBuilder& builder, const OrientedBoundingBox< CoordinateSpace::Model > bounding_box, std::string name ) : + ModelBuilder& builder, + const OrientedBoundingBox< CoordinateSpace::Model >& bounding_box, + const std::string& name ) : Model( std::move( builder.m_primitives ), bounding_box, name ) {} Model::Model( std::vector< Primitive >&& primitives, - const OrientedBoundingBox< CoordinateSpace::Model > bounding_box, - std::string name ) : + const OrientedBoundingBox< CoordinateSpace::Model >& bounding_box, + const std::string& name ) : m_draw_parameters( buildParameters( primitives ) ), m_name( name ), m_bounding_box( bounding_box ) { - assert( bounding_box.middle.vec() != constants::DEFAULT_VEC3 ); + assert( !name.empty() ); + assert( bounding_box.m_transform.translation.vec() != constants::DEFAULT_VEC3 ); m_primitives = std::move( primitives ); } diff --git a/src/engine/model/Model.hpp b/src/engine/model/Model.hpp index 06a7e8e..276c444 100644 --- a/src/engine/model/Model.hpp +++ b/src/engine/model/Model.hpp @@ -72,12 +72,14 @@ namespace fgl::engine const std::string& getName() const { return m_name; } Model( - ModelBuilder& builder, OrientedBoundingBox< CoordinateSpace::Model > bounding_box, std::string name = {} ); + ModelBuilder& builder, + const OrientedBoundingBox< CoordinateSpace::Model >& bounding_box, + const std::string& name = {} ); Model( std::vector< Primitive >&& primitives, - OrientedBoundingBox< CoordinateSpace::Model > bounding_box, - std::string name = {} ); + const OrientedBoundingBox< CoordinateSpace::Model >& bounding_box, + const std::string& name = {} ); ~Model() = default; diff --git a/src/engine/model/Primitive.hpp b/src/engine/model/Primitive.hpp index 4e419f1..cd424d5 100644 --- a/src/engine/model/Primitive.hpp +++ b/src/engine/model/Primitive.hpp @@ -74,6 +74,8 @@ namespace fgl::engine PrimitiveTextures m_textures; + std::string m_name { "Unnamed Primitive" }; + //! Returns true if the primitive is ready to be rendered (must have all textures, vertex buffer, and index buffer ready) bool ready() const { return m_textures.ready() && m_vertex_buffer.ready() && m_index_buffer.ready(); } diff --git a/src/engine/model/builders/SceneBuilder.cpp b/src/engine/model/builders/SceneBuilder.cpp index 81f9b89..c8a29ce 100644 --- a/src/engine/model/builders/SceneBuilder.cpp +++ b/src/engine/model/builders/SceneBuilder.cpp @@ -433,7 +433,8 @@ namespace fgl::engine const auto bounding_box { createModelBoundingBox( finished_primitives ) }; - return std::make_shared< Model >( std::move( finished_primitives ), bounding_box, mesh.name ); + return std::make_shared< + Model >( std::move( finished_primitives ), bounding_box, mesh.name.empty() ? "Unnamed Model" : mesh.name ); } void SceneBuilder::handleNode( const int node_idx, const tinygltf::Model& root ) diff --git a/src/engine/rendering/QueuePool.cpp b/src/engine/rendering/QueuePool.cpp index 5294542..d3a2c57 100644 --- a/src/engine/rendering/QueuePool.cpp +++ b/src/engine/rendering/QueuePool.cpp @@ -4,7 +4,7 @@ #include "QueuePool.hpp" -#include "Attachment.hpp" +#include "pipelines/Attachment.hpp" namespace fgl::engine { diff --git a/src/engine/rendering/Renderer.cpp b/src/engine/rendering/Renderer.cpp index 955e1d5..70fc62d 100644 --- a/src/engine/rendering/Renderer.cpp +++ b/src/engine/rendering/Renderer.cpp @@ -11,7 +11,6 @@ #include #include -#include "Device.hpp" #include "SwapChain.hpp" #include "engine/Window.hpp" diff --git a/src/engine/rendering/Renderer.hpp b/src/engine/rendering/Renderer.hpp index 0484b11..088677d 100644 --- a/src/engine/rendering/Renderer.hpp +++ b/src/engine/rendering/Renderer.hpp @@ -9,7 +9,6 @@ #include #include -#include "Device.hpp" #include "SwapChain.hpp" //clang-format: off diff --git a/src/engine/rendering/SwapChain.cpp b/src/engine/rendering/SwapChain.cpp index 42c6f0d..3aa2bb0 100644 --- a/src/engine/rendering/SwapChain.cpp +++ b/src/engine/rendering/SwapChain.cpp @@ -7,11 +7,10 @@ #include #include -#include "Attachment.hpp" -#include "RenderPass.hpp" -#include "Subpass.hpp" #include "engine/assets/TransferManager.hpp" #include "engine/descriptors/DescriptorSet.hpp" +#include "pipelines/Attachment.hpp" +#include "renderpass/RenderPass.hpp" namespace fgl::engine { diff --git a/src/engine/rendering/SwapChain.hpp b/src/engine/rendering/SwapChain.hpp index cc9361b..8aff393 100644 --- a/src/engine/rendering/SwapChain.hpp +++ b/src/engine/rendering/SwapChain.hpp @@ -3,10 +3,10 @@ #include #include -#include "Attachment.hpp" -#include "Device.hpp" +#include "devices/Device.hpp" #include "engine/FrameInfo.hpp" #include "engine/texture/Texture.hpp" +#include "pipelines/Attachment.hpp" #include "types.hpp" namespace fgl::engine diff --git a/src/engine/rendering/Device.cpp b/src/engine/rendering/devices/Device.cpp similarity index 99% rename from src/engine/rendering/Device.cpp rename to src/engine/rendering/devices/Device.cpp index ddc771e..a87760d 100644 --- a/src/engine/rendering/Device.cpp +++ b/src/engine/rendering/devices/Device.cpp @@ -170,7 +170,7 @@ namespace fgl::engine global_device = this; - DescriptorPool::init( *global_device ); + DescriptorPool::init(); } Device::~Device() diff --git a/src/engine/rendering/Device.hpp b/src/engine/rendering/devices/Device.hpp similarity index 97% rename from src/engine/rendering/Device.hpp rename to src/engine/rendering/devices/Device.hpp index c94b18d..3215fce 100644 --- a/src/engine/rendering/Device.hpp +++ b/src/engine/rendering/devices/Device.hpp @@ -5,10 +5,10 @@ #include -#include "Instance.hpp" #include "PhysicalDevice.hpp" -#include "Surface.hpp" #include "engine/Window.hpp" +#include "engine/rendering/Instance.hpp" +#include "engine/rendering/Surface.hpp" #include "vma/vma_impl.hpp" namespace fgl::engine diff --git a/src/engine/rendering/PhysicalDevice.cpp b/src/engine/rendering/devices/PhysicalDevice.cpp similarity index 97% rename from src/engine/rendering/PhysicalDevice.cpp rename to src/engine/rendering/devices/PhysicalDevice.cpp index 5169dea..9a633f1 100644 --- a/src/engine/rendering/PhysicalDevice.cpp +++ b/src/engine/rendering/devices/PhysicalDevice.cpp @@ -4,9 +4,9 @@ #include "PhysicalDevice.hpp" -#include "Instance.hpp" -#include "Surface.hpp" #include "engine/logging/logging.hpp" +#include "engine/rendering/Instance.hpp" +#include "engine/rendering/Surface.hpp" namespace fgl::engine { diff --git a/src/engine/rendering/PhysicalDevice.hpp b/src/engine/rendering/devices/PhysicalDevice.hpp similarity index 95% rename from src/engine/rendering/PhysicalDevice.hpp rename to src/engine/rendering/devices/PhysicalDevice.hpp index 288794f..1c4a1d8 100644 --- a/src/engine/rendering/PhysicalDevice.hpp +++ b/src/engine/rendering/devices/PhysicalDevice.hpp @@ -6,8 +6,8 @@ #include -#include "QueuePool.hpp" #include "engine/FGL_DEFINES.hpp" +#include "engine/rendering/QueuePool.hpp" namespace fgl::engine { diff --git a/src/engine/rendering/Attachment.hpp b/src/engine/rendering/pipelines/Attachment.hpp similarity index 98% rename from src/engine/rendering/Attachment.hpp rename to src/engine/rendering/pipelines/Attachment.hpp index 43790b3..34b12b6 100644 --- a/src/engine/rendering/Attachment.hpp +++ b/src/engine/rendering/pipelines/Attachment.hpp @@ -11,9 +11,9 @@ #include #include -#include "engine/concepts/is_attachment.hpp" -#include "engine/image/Image.hpp" -#include "types.hpp" +#include "../../concepts/is_attachment.hpp" +#include "../../image/Image.hpp" +#include "../types.hpp" namespace fgl::engine { diff --git a/src/engine/pipeline/Pipeline.cpp b/src/engine/rendering/pipelines/Pipeline.cpp similarity index 98% rename from src/engine/pipeline/Pipeline.cpp rename to src/engine/rendering/pipelines/Pipeline.cpp index c56f154..c1f6654 100644 --- a/src/engine/pipeline/Pipeline.cpp +++ b/src/engine/rendering/pipelines/Pipeline.cpp @@ -7,7 +7,7 @@ #include #include "Shader.hpp" -#include "engine/model/Model.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::internal { diff --git a/src/engine/pipeline/Pipeline.hpp b/src/engine/rendering/pipelines/Pipeline.hpp similarity index 96% rename from src/engine/pipeline/Pipeline.hpp rename to src/engine/rendering/pipelines/Pipeline.hpp index dc4448a..d572648 100644 --- a/src/engine/pipeline/Pipeline.hpp +++ b/src/engine/rendering/pipelines/Pipeline.hpp @@ -8,10 +8,10 @@ #include #include "PipelineConfigInfo.hpp" -#include "engine/rendering/Device.hpp" namespace fgl::engine { + class Device; struct ShaderHandle; } diff --git a/src/engine/pipeline/PipelineConfigInfo.cpp b/src/engine/rendering/pipelines/PipelineConfigInfo.cpp similarity index 99% rename from src/engine/pipeline/PipelineConfigInfo.cpp rename to src/engine/rendering/pipelines/PipelineConfigInfo.cpp index 62174b1..d147cf0 100644 --- a/src/engine/pipeline/PipelineConfigInfo.cpp +++ b/src/engine/rendering/pipelines/PipelineConfigInfo.cpp @@ -4,7 +4,7 @@ #include "PipelineConfigInfo.hpp" -#include "engine/model/Model.hpp" +#include "../../model/Model.hpp" namespace fgl::engine { @@ -91,6 +91,7 @@ namespace fgl::engine { case None: disableVertexInput( info ); + break; case Simple: { info.binding_descriptions = SimpleVertex::getBindingDescriptions(); diff --git a/src/engine/pipeline/PipelineConfigInfo.hpp b/src/engine/rendering/pipelines/PipelineConfigInfo.hpp similarity index 98% rename from src/engine/pipeline/PipelineConfigInfo.hpp rename to src/engine/rendering/pipelines/PipelineConfigInfo.hpp index 5b1cff8..c6c10e3 100644 --- a/src/engine/pipeline/PipelineConfigInfo.hpp +++ b/src/engine/rendering/pipelines/PipelineConfigInfo.hpp @@ -10,7 +10,7 @@ #include #include -#include "engine/FGL_DEFINES.hpp" +#include "../../FGL_DEFINES.hpp" namespace fgl::engine { diff --git a/src/engine/pipeline/PipelineT.hpp b/src/engine/rendering/pipelines/PipelineT.hpp similarity index 96% rename from src/engine/pipeline/PipelineT.hpp rename to src/engine/rendering/pipelines/PipelineT.hpp index 7529e05..3f62c79 100644 --- a/src/engine/pipeline/PipelineT.hpp +++ b/src/engine/rendering/pipelines/PipelineT.hpp @@ -4,11 +4,11 @@ #pragma once +#include "../../concepts/is_descriptor_set_collection.hpp" +#include "../../concepts/is_empty_descriptor_set.hpp" +#include "../../descriptors/DescriptorSet.hpp" #include "Pipeline.hpp" #include "Shader.hpp" -#include "engine/concepts/is_descriptor_set_collection.hpp" -#include "engine/concepts/is_empty_descriptor_set.hpp" -#include "engine/descriptors/DescriptorSet.hpp" namespace fgl::engine { diff --git a/src/engine/pipeline/Shader.cpp b/src/engine/rendering/pipelines/Shader.cpp similarity index 95% rename from src/engine/pipeline/Shader.cpp rename to src/engine/rendering/pipelines/Shader.cpp index 4a8a6af..4ba3e53 100644 --- a/src/engine/pipeline/Shader.cpp +++ b/src/engine/rendering/pipelines/Shader.cpp @@ -4,8 +4,8 @@ #include "Shader.hpp" -#include "engine/rendering/Device.hpp" -#include "engine/shaders/Compiler.hpp" +#include "engine/rendering/devices/Device.hpp" +#include "shaders/Compiler.hpp" namespace fgl::engine { diff --git a/src/engine/pipeline/Shader.hpp b/src/engine/rendering/pipelines/Shader.hpp similarity index 98% rename from src/engine/pipeline/Shader.hpp rename to src/engine/rendering/pipelines/Shader.hpp index dbaf6fe..49b6cda 100644 --- a/src/engine/pipeline/Shader.hpp +++ b/src/engine/rendering/pipelines/Shader.hpp @@ -8,7 +8,7 @@ #include -#include "engine/logging/logging.hpp" +#include "../../logging/logging.hpp" namespace fgl::engine { diff --git a/src/engine/shaders/Compiler.cpp b/src/engine/rendering/pipelines/shaders/Compiler.cpp similarity index 100% rename from src/engine/shaders/Compiler.cpp rename to src/engine/rendering/pipelines/shaders/Compiler.cpp diff --git a/src/engine/shaders/Compiler.hpp b/src/engine/rendering/pipelines/shaders/Compiler.hpp similarity index 100% rename from src/engine/shaders/Compiler.hpp rename to src/engine/rendering/pipelines/shaders/Compiler.hpp diff --git a/src/engine/rendering/RenderPass.cpp b/src/engine/rendering/renderpass/RenderPass.cpp similarity index 99% rename from src/engine/rendering/RenderPass.cpp rename to src/engine/rendering/renderpass/RenderPass.cpp index 487c581..ae583f4 100644 --- a/src/engine/rendering/RenderPass.cpp +++ b/src/engine/rendering/renderpass/RenderPass.cpp @@ -4,7 +4,7 @@ #include "RenderPass.hpp" -#include "Device.hpp" +#include "engine/rendering/devices/Device.hpp" namespace fgl::engine::rendering { diff --git a/src/engine/rendering/RenderPass.hpp b/src/engine/rendering/renderpass/RenderPass.hpp similarity index 100% rename from src/engine/rendering/RenderPass.hpp rename to src/engine/rendering/renderpass/RenderPass.hpp diff --git a/src/engine/rendering/Subpass.hpp b/src/engine/rendering/renderpass/Subpass.hpp similarity index 99% rename from src/engine/rendering/Subpass.hpp rename to src/engine/rendering/renderpass/Subpass.hpp index 29240fb..7511996 100644 --- a/src/engine/rendering/Subpass.hpp +++ b/src/engine/rendering/renderpass/Subpass.hpp @@ -9,8 +9,8 @@ #include #include -#include "Attachment.hpp" #include "engine/concepts/is_attachment.hpp" +#include "pipelines/Attachment.hpp" namespace fgl::engine { diff --git a/src/engine/systems/CompositionSystem.hpp b/src/engine/systems/CompositionSystem.hpp index 666a22d..01dc919 100644 --- a/src/engine/systems/CompositionSystem.hpp +++ b/src/engine/systems/CompositionSystem.hpp @@ -4,11 +4,11 @@ #pragma once -#include - #include "concepts.hpp" #include "engine/FrameInfo.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" +#include "engine/rendering/pipelines/PipelineT.hpp" +#include "engine/rendering/pipelines/Shader.hpp" namespace fgl::engine { diff --git a/src/engine/systems/EntityRendererSystem.hpp b/src/engine/systems/EntityRendererSystem.hpp index 4791ed2..1a9eafd 100644 --- a/src/engine/systems/EntityRendererSystem.hpp +++ b/src/engine/systems/EntityRendererSystem.hpp @@ -6,9 +6,9 @@ #include +#include "../rendering/pipelines/PipelineT.hpp" #include "engine/buffers/vector/HostVector.hpp" #include "engine/model/Model.hpp" -#include "engine/pipeline/PipelineT.hpp" #include "engine/rendering/SwapChain.hpp" #include "engine/systems/modelRendering/StandardPipeline.hpp" #include "engine/systems/modelRendering/TexturedPipeline.hpp" diff --git a/src/engine/systems/GuiSystem.hpp b/src/engine/systems/GuiSystem.hpp index bb2ab00..be1073c 100644 --- a/src/engine/systems/GuiSystem.hpp +++ b/src/engine/systems/GuiSystem.hpp @@ -3,11 +3,11 @@ // #pragma once +#include "../rendering/pipelines/PipelineT.hpp" +#include "../rendering/pipelines/Shader.hpp" #include "engine/FrameInfo.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" #include "engine/descriptors/DescriptorSetLayout.hpp" -#include "engine/pipeline/PipelineT.hpp" -#include "engine/pipeline/Shader.hpp" namespace fgl::engine { diff --git a/src/engine/systems/LineDrawer.hpp b/src/engine/systems/LineDrawer.hpp index e15d32a..6618785 100644 --- a/src/engine/systems/LineDrawer.hpp +++ b/src/engine/systems/LineDrawer.hpp @@ -3,11 +3,11 @@ // #pragma once +#include "../rendering/pipelines/PipelineT.hpp" #include "engine/buffers/vector/HostVector.hpp" #include "engine/camera/CameraDescriptor.hpp" #include "engine/descriptors/Descriptor.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" -#include "engine/pipeline/PipelineT.hpp" #include "engine/rendering/SwapChain.hpp" namespace fgl::engine diff --git a/src/engine/systems/TerrainSystem.hpp b/src/engine/systems/TerrainSystem.hpp index d27ac9f..8b50f66 100644 --- a/src/engine/systems/TerrainSystem.hpp +++ b/src/engine/systems/TerrainSystem.hpp @@ -4,13 +4,13 @@ #pragma once +#include "../rendering/pipelines/PipelineT.hpp" #include "concepts.hpp" #include "engine/FrameInfo.hpp" #include "engine/buffers/vector/HostVector.hpp" #include "engine/camera/Camera.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" #include "engine/model/Model.hpp" -#include "engine/pipeline/PipelineT.hpp" #include "engine/rendering/SwapChain.hpp" namespace fgl::engine diff --git a/src/engine/systems/modelRendering/StandardPipeline.hpp b/src/engine/systems/modelRendering/StandardPipeline.hpp index da48a01..98fdf56 100644 --- a/src/engine/systems/modelRendering/StandardPipeline.hpp +++ b/src/engine/systems/modelRendering/StandardPipeline.hpp @@ -3,11 +3,11 @@ // #pragma once +#include "../../rendering/pipelines/PipelineT.hpp" +#include "../../rendering/pipelines/Shader.hpp" #include "engine/FrameInfo.hpp" #include "engine/camera/CameraDescriptor.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" -#include "engine/pipeline/PipelineT.hpp" -#include "engine/pipeline/Shader.hpp" namespace fgl::engine { diff --git a/src/engine/systems/modelRendering/TexturedPipeline.hpp b/src/engine/systems/modelRendering/TexturedPipeline.hpp index ca464c7..5e8bcc4 100644 --- a/src/engine/systems/modelRendering/TexturedPipeline.hpp +++ b/src/engine/systems/modelRendering/TexturedPipeline.hpp @@ -3,10 +3,10 @@ // #pragma once +#include "../../rendering/pipelines/PipelineT.hpp" +#include "../../rendering/pipelines/Shader.hpp" #include "engine/FrameInfo.hpp" #include "engine/descriptors/DescriptorSetCollection.hpp" -#include "engine/pipeline/PipelineT.hpp" -#include "engine/pipeline/Shader.hpp" namespace fgl::engine {