Skip to content

Commit

Permalink
General editor improvements, Bitangents, Sky generation, enable aniso…
Browse files Browse the repository at this point in the history
…tropic filtering
  • Loading branch information
jmorton06 committed Mar 26, 2023
1 parent 9ec87b9 commit 505d25d
Show file tree
Hide file tree
Showing 94 changed files with 3,317 additions and 2,080 deletions.
40 changes: 37 additions & 3 deletions Editor/Source/ConsolePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
namespace Lumos
{
uint32_t ConsolePanel::s_MessageBufferRenderFilter = 0;
uint16_t ConsolePanel::s_MessageBufferCapacity = 200;
uint16_t ConsolePanel::s_MessageBufferCapacity = 2000;
uint16_t ConsolePanel::s_MessageBufferSize = 0;
uint16_t ConsolePanel::s_MessageBufferBegin = 0;
Vector<SharedPtr<ConsolePanel::Message>> ConsolePanel::s_MessageBuffer = Vector<SharedPtr<ConsolePanel::Message>>(200);
Vector<SharedPtr<ConsolePanel::Message>> ConsolePanel::s_MessageBuffer = Vector<SharedPtr<ConsolePanel::Message>>(2000);
bool ConsolePanel::s_AllowScrollingToBottom = true;
bool ConsolePanel::s_RequestScrollToBottom = false;

Expand Down Expand Up @@ -235,13 +235,18 @@ namespace Lumos
LUMOS_PROFILE_FUNCTION();
if(s_MessageBufferRenderFilter & m_Level)
{
ImGuiUtilities::ScopedID((int)m_MessageID);
ImGuiUtilities::ScopedID scopedID((int)m_MessageID);
ImGui::PushStyleColor(ImGuiCol_Text, GetRenderColour(m_Level));
auto levelIcon = GetLevelIcon(m_Level);
ImGui::TextUnformatted(levelIcon);
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::TextUnformatted(m_Message.c_str());

bool clicked = false;
if (ImGui::IsItemClicked())
clicked = true;

if(ImGui::BeginPopupContextItem(m_Message.c_str()))
{
if(ImGui::MenuItem("Copy"))
Expand All @@ -251,6 +256,35 @@ namespace Lumos

ImGui::EndPopup();
}
static bool m_DetailedPanelOpen = false;
if (clicked)
{
ImGui::OpenPopup("Message");
ImVec2 size = ImGui::GetMainViewport()->Size;
ImGui::SetNextWindowSize({ size.x * 0.5f, size.y * 0.5f });
ImGui::SetNextWindowPos({ size.x / 2.0f, size.y / 2.5f }, 0, { 0.5, 0.5 });
m_DetailedPanelOpen = true;
}

if (m_DetailedPanelOpen)
{
if (ImGui::BeginPopupModal("Message", &m_DetailedPanelOpen, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextWrapped("%s", m_Message.c_str());

if (ImGui::BeginPopupContextItem(m_Message.c_str()))
{
if (ImGui::MenuItem("Copy"))
{
ImGui::SetClipboardText(m_Message.c_str());
}

ImGui::EndPopup();
}

ImGui::EndPopup();
}
}

if(ImGui::IsItemHovered())
{
Expand Down
453 changes: 360 additions & 93 deletions Editor/Source/Editor.cpp

Large diffs are not rendered by default.

55 changes: 47 additions & 8 deletions Editor/Source/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,62 @@ namespace Lumos
return m_Settings.m_SnapAmount;
}

void ClearSelected()
{
m_SelectedEntities.clear();
}

void SetSelected(entt::entity entity)
{
m_SelectedEntity = entity;
if (std::find(m_SelectedEntities.begin(), m_SelectedEntities.end(), entity) != m_SelectedEntities.end())
return;

m_SelectedEntities.push_back(entity);
}

void UnSelect(entt::entity entity)
{
auto it = std::find(m_SelectedEntities.begin(), m_SelectedEntities.end(), entity);

if (it != m_SelectedEntities.end())
{
m_SelectedEntities.erase(it);
}
}
entt::entity GetSelected() const

const std::vector<entt::entity>& GetSelected() const
{
return m_SelectedEntity;
return m_SelectedEntities;
}

bool IsSelected(entt::entity entity)
{
if (std::find(m_SelectedEntities.begin(), m_SelectedEntities.end(), entity) != m_SelectedEntities.end())
return true;

return false;
}

bool IsCopied(entt::entity entity)
{
if (std::find(m_CopiedEntities.begin(), m_CopiedEntities.end(), entity) != m_CopiedEntities.end())
return true;

return false;
}

void SetCopiedEntity(entt::entity entity, bool cut = false)
{
m_CopiedEntity = entity;
if (std::find(m_CopiedEntities.begin(), m_CopiedEntities.end(), entity) != m_CopiedEntities.end())
return;

m_CopiedEntities.push_back(entity);
m_CutCopyEntity = cut;
}

entt::entity GetCopiedEntity() const
const std::vector<entt::entity>& GetCopiedEntity() const
{
return m_CopiedEntity;
return m_CopiedEntities;
}

bool GetCutCopyEntity()
Expand Down Expand Up @@ -258,8 +296,9 @@ namespace Lumos
Application* m_Application;

uint32_t m_ImGuizmoOperation = 14463;
entt::entity m_SelectedEntity;
entt::entity m_CopiedEntity;
std::vector<entt::entity> m_SelectedEntities;
std::vector<entt::entity> m_CopiedEntities;

bool m_CutCopyEntity = false;
float m_CurrentSceneAspectRatio = 0.0f;
float m_CameraTransitionStartTime = 0.0f;
Expand Down
129 changes: 71 additions & 58 deletions Editor/Source/HierarchyPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Lumos
if(hierarchyComponent != nullptr && hierarchyComponent->First() != entt::null)
noChildren = false;

ImGuiTreeNodeFlags nodeFlags = ((m_Editor->GetSelected() == node) ? ImGuiTreeNodeFlags_Selected : 0);
ImGuiTreeNodeFlags nodeFlags = ((m_Editor->IsSelected(node)) ? ImGuiTreeNodeFlags_Selected : 0);

nodeFlags |= ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_SpanAvailWidth;

Expand All @@ -69,8 +69,8 @@ namespace Lumos
nodeFlags |= ImGuiTreeNodeFlags_Leaf;
}

auto activeComponent = registry.try_get<ActiveComponent>(node);
bool active = activeComponent ? activeComponent->active : true;
//auto activeComponent = registry.try_get<ActiveComponent>(node);
bool active = Entity(node, m_Editor->GetCurrentScene()).Active();//activeComponent ? activeComponent->active : true;

if(!active)
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
Expand Down Expand Up @@ -139,8 +139,17 @@ namespace Lumos
bool nodeOpen = ImGui::TreeNodeEx((void*)(intptr_t)entt::to_integral(node), nodeFlags, "%s", icon.c_str());
{
// Allow clicking of icon and text. Need twice as they are separated
if(ImGui::IsItemClicked())
m_Editor->SetSelected(node);
if(ImGui::IsItemClicked() && !ImGui::IsItemToggledOpen())
{
bool ctrlDown = Input::Get().GetKeyHeld(Lumos::InputCode::Key::LeftControl) || Input::Get().GetKeyHeld(Lumos::InputCode::Key::RightControl) || Input::Get().GetKeyHeld(Lumos::InputCode::Key::LeftSuper);
if(!ctrlDown)
m_Editor->ClearSelected();

if(!m_Editor->IsSelected(node))
m_Editor->SetSelected(node);
else
m_Editor->UnSelect(node);
}
else if(m_DoubleClicked == node && ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !ImGui::IsItemHovered(ImGuiHoveredFlags_None))
m_DoubleClicked = entt::null;
}
Expand All @@ -159,17 +168,6 @@ namespace Lumos
registry.get_or_emplace<NameComponent>(node).name = objName;
ImGui::PopStyleVar();
}
#if 0
ImGui::SameLine(ImGui::GetWindowContentRegionMax().x - 22.0f);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.7f, 0.7f, 0.7f, 0.0f));
if(ImGui::Button(active ? ICON_MDI_EYE : ICON_MDI_EYE_OFF))
{
auto& activeComponent = registry.get_or_emplace<ActiveComponent>(node);

activeComponent.active = !active;
}
ImGui::PopStyleColor();
#endif

if(!active)
ImGui::PopStyleColor();
Expand All @@ -183,22 +181,25 @@ namespace Lumos
if(ImGui::Selectable("Cut"))
m_Editor->SetCopiedEntity(node, true);

if(m_Editor->GetCopiedEntity() != entt::null && registry.valid(m_Editor->GetCopiedEntity()))
if(m_Editor->GetCopiedEntity().size() > 0 && registry.valid(m_Editor->GetCopiedEntity().front()))
{
if(ImGui::Selectable("Paste"))
{
auto scene = Application::Get().GetSceneManager()->GetCurrentScene();
Entity copiedEntity = { m_Editor->GetCopiedEntity(), scene };
if(!copiedEntity.Valid())
for(auto entity : m_Editor->GetCopiedEntity() )
{
m_Editor->SetCopiedEntity(entt::null);
}
else
{
scene->DuplicateEntity(copiedEntity, { node, scene });
auto scene = Application::Get().GetSceneManager()->GetCurrentScene();
Entity copiedEntity = { entity, scene };
if(!copiedEntity.Valid())
{
m_Editor->SetCopiedEntity(entt::null);
}
else
{
scene->DuplicateEntity(copiedEntity, { node, scene });

if(m_Editor->GetCutCopyEntity())
deleteEntity = true;
if(m_Editor->GetCutCopyEntity())
deleteEntity = true;
}
}
}
}
Expand All @@ -216,8 +217,8 @@ namespace Lumos
}
if(ImGui::Selectable("Delete"))
deleteEntity = true;
if(m_Editor->GetSelected() == node)
m_Editor->SetSelected(entt::null);
if(m_Editor->IsSelected(node))
m_Editor->UnSelect(node);
ImGui::Separator();
if(ImGui::Selectable("Rename"))
m_DoubleClicked = node;
Expand Down Expand Up @@ -275,8 +276,8 @@ namespace Lumos
ImGui::EndDragDropTarget();
}

if(m_Editor->GetSelected() == entity)
m_Editor->SetSelected(entt::null);
if(m_Editor->IsSelected(entity))
m_Editor->UnSelect(entity);
}

if(ImGui::IsItemClicked() && !deleteEntity)
Expand Down Expand Up @@ -307,7 +308,7 @@ namespace Lumos

if(m_SelectUp)
{
if(m_Editor->GetSelected() == node && registry.valid(m_CurrentPrevious))
if(m_Editor->GetSelected().front() == node && registry.valid(m_CurrentPrevious))
{
m_SelectUp = false;
m_Editor->SetSelected(m_CurrentPrevious);
Expand All @@ -316,7 +317,7 @@ namespace Lumos

if(m_SelectDown)
{
if(registry.valid(m_CurrentPrevious) && m_CurrentPrevious == m_Editor->GetSelected())
if(registry.valid(m_CurrentPrevious) && m_CurrentPrevious == m_Editor->GetSelected().front())
{
m_SelectDown = false;
m_Editor->SetSelected(node);
Expand All @@ -325,6 +326,18 @@ namespace Lumos

m_CurrentPrevious = node;

#if 1
ImGui::SameLine(ImGui::GetWindowContentRegionMax().x - ImGui::CalcTextSize(ICON_MDI_EYE).x * 2.0f);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.7f, 0.7f, 0.7f, 0.0f));
if (ImGui::Button(active ? ICON_MDI_EYE : ICON_MDI_EYE_OFF))
{
auto& activeComponent = registry.get_or_emplace<ActiveComponent>(node);

activeComponent.active = !active;
}
ImGui::PopStyleColor();
#endif

if(nodeOpen == false)
{
ImGui::PopID();
Expand Down Expand Up @@ -534,31 +547,31 @@ namespace Lumos

if(ImGui::BeginPopupContextWindow())
{
if(m_Editor->GetCopiedEntity() != entt::null && registry.valid(m_Editor->GetCopiedEntity()))
{
if(ImGui::Selectable("Paste"))
{
auto scene = Application::Get().GetSceneManager()->GetCurrentScene();
Entity copiedEntity = { m_Editor->GetCopiedEntity(), scene };
if(!copiedEntity.Valid())
{
m_Editor->SetCopiedEntity(entt::null);
}
else
{
scene->DuplicateEntity(copiedEntity);

if(m_Editor->GetCutCopyEntity())
{
DestroyEntity(m_Editor->GetCopiedEntity(), registry);
}
}
}
}
else
{
ImGui::TextDisabled("Paste");
}
// if(m_Editor->GetCopiedEntity() != entt::null && registry.valid(m_Editor->GetCopiedEntity()))
// {
// if(ImGui::Selectable("Paste"))
// {
// auto scene = Application::Get().GetSceneManager()->GetCurrentScene();
// Entity copiedEntity = { m_Editor->GetCopiedEntity(), scene };
// if(!copiedEntity.Valid())
// {
// m_Editor->SetCopiedEntity(entt::null);
// }
// else
// {
// scene->DuplicateEntity(copiedEntity);
//
// if(m_Editor->GetCutCopyEntity())
// {
// DestroyEntity(m_Editor->GetCopiedEntity(), registry);
// }
// }
// }
// }
// else
// {
// ImGui::TextDisabled("Paste");
// }

ImGui::Separator();

Expand Down
Loading

0 comments on commit 505d25d

Please sign in to comment.