Some component and rendering cleanup

This commit is contained in:
2024-08-14 16:01:44 -04:00
parent 9e9b116232
commit aec48186c6
58 changed files with 297 additions and 126 deletions

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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 );

View File

@@ -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