Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
roeas committed Sep 16, 2023
2 parents c690cb1 + f04ab6e commit 6a2f689
Show file tree
Hide file tree
Showing 21 changed files with 302 additions and 176 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions Engine/BuiltInShaders/shaders/fs_wireframe_line.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "../common/common.sh"

void main()
{
gl_FragColor = vec4(0.5, 1.0, 1.0, 1.0);
}
File renamed without changes.
8 changes: 8 additions & 0 deletions Engine/BuiltInShaders/shaders/vs_wireframe_line.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$input a_position//, a_color1

#include "../common/common.sh"

void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0));
}
1 change: 1 addition & 0 deletions Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void ECWorldConsumer::AddStaticMesh(engine::Entity entity, const cd::Mesh& mesh,
staticMeshComponent.SetMeshData(&mesh);
staticMeshComponent.SetRequiredVertexFormat(&vertexFormat);
staticMeshComponent.Build();
staticMeshComponent.Submit();
}

void ECWorldConsumer::AddSkinMesh(engine::Entity entity, const cd::Mesh& mesh, const cd::VertexFormat& vertexFormat)
Expand Down
41 changes: 24 additions & 17 deletions Engine/Source/Editor/EditorApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#ifdef ENABLE_DDGI
#include "Rendering/DDGIRenderer.h"
#endif
#include "Rendering/DebugRenderer.h"
#include "Rendering/WhiteModelRenderer.h"
#include "Rendering/WireframeRenderer.h"
#include "Rendering/ImGuiRenderer.h"
#include "Rendering/PBRSkyRenderer.h"
#include "Rendering/BloomRenderer.h"
Expand Down Expand Up @@ -176,7 +177,8 @@ void EditorApp::InitEditorUILayers()
m_pSceneView = pSceneView.get();
pSceneView->SetCameraController(m_pViewportCameraController.get());
pSceneView->SetSceneRenderer(m_pSceneRenderer);
pSceneView->SetDebugRenderer(m_pDebugRenderer);
pSceneView->SetWhiteModelRenderer(m_pWhiteModelRenderer);
pSceneView->SetWireframeRenderer(m_pWireframeRenderer);
pSceneView->SetAABBRenderer(m_pAABBRenderer);
m_pEditorImGuiContext->AddDynamicLayer(cd::MoveTemp(pSceneView));

Expand Down Expand Up @@ -325,6 +327,7 @@ void EditorApp::InitSkyEntity()
meshComponent.SetMeshData(&optMesh.value());
meshComponent.SetRequiredVertexFormat(&vertexFormat);
meshComponent.Build();
meshComponent.Submit();
}

#ifdef ENABLE_DDGI
Expand Down Expand Up @@ -398,36 +401,40 @@ void EditorApp::InitEngineRenderers()
pTerrainRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pTerrainRenderer));

auto pSkeletonRenderer = std::make_unique<engine::SkeletonRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pSkeletonRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pSkeletonRenderer));

auto pAnimationRenderer = std::make_unique<engine::AnimationRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pAnimationRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pAnimationRenderer));

auto pDebugRenderer = std::make_unique<engine::DebugRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pDebugRenderer = pDebugRenderer.get();
pDebugRenderer->SetSceneWorld(m_pSceneWorld.get());
pDebugRenderer->SetEnable(false);
AddEngineRenderer(cd::MoveTemp(pDebugRenderer));

auto pAABBRenderer = std::make_unique<engine::AABBRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pAABBRenderer = pAABBRenderer.get();
pAABBRenderer->SetSceneWorld(m_pSceneWorld.get());
pAABBRenderer->SetEnable(false);
AddEngineRenderer(cd::MoveTemp(pAABBRenderer));
auto pWhiteModelRenderer = std::make_unique<engine::WhiteModelRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pWhiteModelRenderer = pWhiteModelRenderer.get();
pWhiteModelRenderer->SetSceneWorld(m_pSceneWorld.get());
pWhiteModelRenderer->SetEnable(false);
AddEngineRenderer(cd::MoveTemp(pWhiteModelRenderer));

auto pParticlerenderer = std::make_unique<engine::ParticleRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pParticlerenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pParticlerenderer));

auto pSkeletonRenderer = std::make_unique<engine::SkeletonRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pSkeletonRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pSkeletonRenderer));

#ifdef ENABLE_DDGI
auto pDDGIRenderer = std::make_unique<engine::DDGIRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pDDGIRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pDDGIRenderer));
#endif

auto pAABBRenderer = std::make_unique<engine::AABBRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pAABBRenderer = pAABBRenderer.get();
pAABBRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pAABBRenderer));

auto pWireframeRenderer = std::make_unique<engine::WireframeRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pWireframeRenderer = pWireframeRenderer.get();
pWireframeRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pWireframeRenderer));

auto pBlitRTRenderPass = std::make_unique<engine::BlitRenderTargetPass>(m_pRenderContext->CreateView(), pSceneRenderTarget);
AddEngineRenderer(cd::MoveTemp(pBlitRTRenderPass));

Expand Down
3 changes: 2 additions & 1 deletion Engine/Source/Editor/EditorApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class EditorApp final : public engine::IApplication
std::unique_ptr<engine::SceneWorld> m_pSceneWorld;
editor::SceneView* m_pSceneView = nullptr;
engine::Renderer* m_pSceneRenderer = nullptr;
engine::Renderer* m_pDebugRenderer = nullptr;
engine::Renderer* m_pWhiteModelRenderer = nullptr;
engine::Renderer* m_pWireframeRenderer = nullptr;
engine::Renderer* m_pPBRSkyRenderer = nullptr;
engine::Renderer* m_pIBLSkyRenderer = nullptr;
engine::Renderer* m_pTerrainRenderer = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions Engine/Source/Editor/UILayers/EntityList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld)
staticMeshComponent.SetMeshData(&mesh);
staticMeshComponent.SetRequiredVertexFormat(&pMaterialType->GetRequiredVertexFormat());
staticMeshComponent.Build();
staticMeshComponent.Submit();

mesh.SetName(pSceneWorld->GetNameComponent(entity)->GetName());
mesh.SetID(cd::MeshID(pSceneDatabase->GetMeshCount()));
Expand Down Expand Up @@ -113,6 +114,7 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld)
meshComponent.SetMeshData(&mesh);
meshComponent.SetRequiredVertexFormat(&pTerrainMaterialType->GetRequiredVertexFormat());//to do : modify vertexFormat
meshComponent.Build();
meshComponent.Submit();

mesh.SetName(pSceneWorld->GetNameComponent(entity)->GetName());
mesh.SetID(cd::MeshID(pSceneDatabase->GetMeshCount()));
Expand Down
27 changes: 25 additions & 2 deletions Engine/Source/Editor/UILayers/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ void UpdateComponentWidget(engine::SceneWorld* pSceneWorld, engine::Entity entit
{
}

template<>
void UpdateComponentWidget<engine::CollisionMeshComponent>(engine::SceneWorld* pSceneWorld, engine::Entity entity)
{
auto* pCollisionMesh = pSceneWorld->GetCollisionMeshComponent(entity);
if (!pCollisionMesh)
{
return;
}

bool isHeaderOpen = ImGui::CollapsingHeader("Collision Mesh Component", ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_DefaultOpen);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 2));
ImGui::Separator();

if (isHeaderOpen)
{
ImGuiUtils::ImGuiBoolProperty("Debug Draw", pCollisionMesh->IsDebugDrawEnable());
}

ImGui::Separator();
ImGui::PopStyleVar();
}

template<>
void UpdateComponentWidget<engine::NameComponent>(engine::SceneWorld* pSceneWorld, engine::Entity entity)
{
Expand Down Expand Up @@ -542,13 +564,14 @@ void Inspector::Update()

details::UpdateComponentWidget<engine::NameComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::TransformComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::StaticMeshComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::MaterialComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::CameraComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::LightComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::SkyComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::TerrainComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::StaticMeshComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::ParticleComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::CollisionMeshComponent>(pSceneWorld, selectedEntity);
details::UpdateComponentWidget<engine::MaterialComponent>(pSceneWorld, selectedEntity);

#ifdef ENABLE_DDGI
details::UpdateComponentWidget<engine::DDGIComponent>(pSceneWorld, selectedEntity);
Expand Down
51 changes: 13 additions & 38 deletions Engine/Source/Editor/UILayers/SceneView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Log/Log.h"
#include "Material/ShaderSchema.h"
#include "Math/Ray.hpp"
#include "Rendering/AABBRenderer.h"
#include "Rendering/WireframeRenderer.h"
#include "Rendering/RenderContext.h"
#include "Rendering/Renderer.h"
#include "Rendering/RenderTarget.h"
Expand Down Expand Up @@ -104,44 +106,16 @@ void SceneView::UpdateOperationButtons()
}
}

void SceneView::UpdateAABBCombo()
{
ImGui::SetNextItemWidth(150);
if(ImGui::Combo("##AABBCombo", reinterpret_cast<int*>(&m_AABBMode), AABBModes, IM_ARRAYSIZE(AABBModes)))
{
if (AABBModeType::NoAABB == m_AABBMode)
{
m_pAABBRenderer->SetEnable(false);
}
else if (AABBModeType::AABBSelected == m_AABBMode)
{
m_pAABBRenderer->SetEnable(true);
static_cast<engine::AABBRenderer*>(m_pAABBRenderer)->SetIsRenderSelected(true);
}
else if (AABBModeType::AABBAll == m_AABBMode)
{
m_pAABBRenderer->SetEnable(true);
static_cast<engine::AABBRenderer*>(m_pAABBRenderer)->SetIsRenderSelected(false);
}
}
ImGui::PushItemWidth(150);
}

void SceneView::UpdateDebugCombo()
void SceneView::UpdateRenderModeCombo()
{
ImGui::SetNextItemWidth(130);
if (ImGui::Combo("##DebugCombo", reinterpret_cast<int*>(&m_debugMode), DebugModes, IM_ARRAYSIZE(DebugModes)))
if (ImGui::Combo("##DebugCombo", reinterpret_cast<int*>(&m_renderMode), RenderModes, IM_ARRAYSIZE(RenderModes)))
{
if (DebugModeType::NoDebug == m_debugMode)
{
m_pSceneRenderer->SetEnable(true);
m_pDebugRenderer->SetEnable(false);
}
else if (DebugModeType::WhiteModel == m_debugMode)
{
m_pSceneRenderer->SetEnable(false);
m_pDebugRenderer->SetEnable(true);
}
m_pSceneRenderer->SetEnable(RenderModeType::Rendered == m_renderMode);
m_pWhiteModelRenderer->SetEnable(RenderModeType::Solid == m_renderMode);

auto* pWireframeRenderer = static_cast<engine::WireframeRenderer*>(m_pWireframeRenderer);
pWireframeRenderer->SetEnableGlobalWireframe(RenderModeType::Wireframe == m_renderMode);
}
ImGui::PushItemWidth(130);
}
Expand Down Expand Up @@ -193,7 +167,8 @@ void SceneView::UpdateSwitchAABBButton()

if (ImGui::Button(reinterpret_cast<const char*>(ICON_MDI_CUBE " AABB")))
{
GetRenderContext();
auto* pAABBRenderer = static_cast<engine::AABBRenderer*>(m_pAABBRenderer);
pAABBRenderer->SetEnableGlobalAABB(!pAABBRenderer->IsGlobalAABBEnable());
}

if (isAABBActive)
Expand Down Expand Up @@ -251,10 +226,10 @@ void SceneView::UpdateToolMenuButtons()
//ImGui::SameLine();

ImGui::SameLine();
UpdateAABBCombo();
UpdateRenderModeCombo();

ImGui::SameLine();
UpdateDebugCombo();
UpdateSwitchAABBButton();

ImGui::SameLine();
UpdateSwitchTerrainButton();
Expand Down
52 changes: 17 additions & 35 deletions Engine/Source/Editor/UILayers/SceneView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ECWorld/Entity.h"
#include "ImGui/ImGuiBaseLayer.h"
#include "Rendering/AABBRenderer.h"
#include "Rendering/DebugRenderer.h"
#include "Rendering/WhiteModelRenderer.h"

#include <imgui/imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
Expand All @@ -23,41 +23,24 @@ class RenderTarget;
namespace editor
{

enum class DebugModeType
enum class RenderModeType
{
NoDebug,
WhiteModel,
Rendered,
Solid,
Wireframe,

Count,
};

constexpr const char* DebugModes[] = {
"NoDebug",
"WhiteModel",
//"WireFrame"
constexpr const char* RenderModes[] = {
"Rendered",
"Solid",
"Wireframe",
};

static_assert(static_cast<int>(DebugModeType::Count) == sizeof(DebugModes) / sizeof(char*),
static_assert(static_cast<int>(RenderModeType::Count) == sizeof(RenderModes) / sizeof(char*),
"Debug mode type and names mismatch.");

enum class AABBModeType
{
NoAABB,
AABBSelected,
AABBAll,

Count,
};

constexpr const char* AABBModes[] = {
"NoAABB",
"AABBSelected",
"AABBAll"
};

static_assert(static_cast<int>(AABBModeType::Count) == sizeof(AABBModes) / sizeof(char*),
"AABB mode type and names mismatch.");

class SceneView : public engine::ImGuiBaseLayer
{
public:
Expand All @@ -72,11 +55,11 @@ class SceneView : public engine::ImGuiBaseLayer
void PickSceneMesh(float regionWidth, float regionHeight);

ImGuizmo::OPERATION GetImGuizmoOperation() const { return m_currentOperation; }
DebugModeType GetDebugMode() const { return m_debugMode; }
AABBModeType GetAABBMode() const { return m_AABBMode; }
RenderModeType GetRenderMode() const { return m_renderMode; }

void SetSceneRenderer(engine::Renderer* pSceneRenderer) { m_pSceneRenderer = pSceneRenderer; }
void SetDebugRenderer(engine::Renderer* pDebugRenderer) { m_pDebugRenderer = pDebugRenderer; }
void SetWhiteModelRenderer(engine::Renderer* pWhiteModelRenderer) { m_pWhiteModelRenderer = pWhiteModelRenderer; }
void SetWireframeRenderer(engine::Renderer* pWireframeRenderer) { m_pWireframeRenderer = pWireframeRenderer; }
void SetAABBRenderer(engine::Renderer* pAABBRenderer) { m_pAABBRenderer = pAABBRenderer; }

bool IsTerrainEditMode() const { return m_isTerrainEditMode; }
Expand All @@ -90,8 +73,7 @@ class SceneView : public engine::ImGuiBaseLayer
void UpdateSwitchAABBButton();
void UpdateSwitchTerrainButton();
void UpdateOperationButtons();
void UpdateDebugCombo();
void UpdateAABBCombo();
void UpdateRenderModeCombo();

private:
uint16_t m_lastContentWidth = 0;
Expand All @@ -102,11 +84,11 @@ class SceneView : public engine::ImGuiBaseLayer
bool m_is3DMode = true;
bool m_isIBLActive = false;
bool m_isTerrainEditMode = false;
DebugModeType m_debugMode = DebugModeType::NoDebug;
AABBModeType m_AABBMode = AABBModeType::NoAABB;
RenderModeType m_renderMode = RenderModeType::Rendered;

engine::Renderer* m_pSceneRenderer = nullptr;
engine::Renderer* m_pDebugRenderer = nullptr;
engine::Renderer* m_pWhiteModelRenderer = nullptr;
engine::Renderer* m_pWireframeRenderer = nullptr;
engine::Renderer* m_pAABBRenderer = nullptr;

engine::RenderTarget* m_pRenderTarget = nullptr;
Expand Down
8 changes: 1 addition & 7 deletions Engine/Source/Game/GameApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifdef ENABLE_DDGI
#include "Rendering/DDGIRenderer.h"
#endif
#include "Rendering/DebugRenderer.h"
#include "Rendering/WhiteModelRenderer.h"
#include "Rendering/ImGuiRenderer.h"
#include "Rendering/PBRSkyRenderer.h"
#include "Rendering/PostProcessRenderer.h"
Expand Down Expand Up @@ -251,12 +251,6 @@ void GameApp::InitEngineRenderers()
pAnimationRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pAnimationRenderer));

auto pDebugRenderer = std::make_unique<engine::DebugRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
m_pDebugRenderer = pDebugRenderer.get();
pDebugRenderer->SetSceneWorld(m_pSceneWorld.get());
pDebugRenderer->SetEnable(false);
AddEngineRenderer(cd::MoveTemp(pDebugRenderer));

#ifdef ENABLE_DDGI
auto pDDGIRenderer = std::make_unique<engine::DDGIRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pDDGIRenderer->SetSceneWorld(m_pSceneWorld.get());
Expand Down
Loading

0 comments on commit 6a2f689

Please sign in to comment.