Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	Editor/Source/ResourcePanel.cpp
#	Editor/Source/ResourcePanel.h
  • Loading branch information
jmorton06 committed Dec 4, 2023
2 parents 0682b10 + 57fe40d commit 2d55212
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 46 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: Jmorton06
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.idea/

# User-specific files
*.code-workspace
*.suo
*.user
*.userosscache
Expand Down
37 changes: 18 additions & 19 deletions Editor/Source/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,28 +1815,27 @@ namespace Lumos
if(m_EditorState == EditorState::Play)
autoSaveTimer = 0.0f;

if(Input::Get().GetKeyPressed(Lumos::InputCode::Key::Escape))
if (Input::Get().GetKeyPressed(Lumos::InputCode::Key::Delete))
{
if(GetEditorState() == EditorState::Preview)
{
m_CurrentState = AppState::Closing;
return;
}
else
{
Application::Get().GetSystem<LumosPhysicsEngine>()->SetPaused(true);
Application::Get().GetSystem<B2PhysicsEngine>()->SetPaused(true);
auto *scene = Application::Get().GetCurrentScene();
for(auto entity : m_SelectedEntities)
scene->DestroyEntity(Entity(entity, scene));
}

Application::Get().GetSystem<AudioManager>()->UpdateListener(Application::Get().GetCurrentScene());
Application::Get().GetSystem<AudioManager>()->SetPaused(true);
Application::Get().SetEditorState(EditorState::Preview);
if(Input::Get().GetKeyPressed(Lumos::InputCode::Key::Escape) && GetEditorState() != EditorState::Preview)
{
Application::Get().GetSystem<LumosPhysicsEngine>()->SetPaused(true);
Application::Get().GetSystem<B2PhysicsEngine>()->SetPaused(true);

// m_SelectedEntity = entt::null;
m_SelectedEntities.clear();
ImGui::SetWindowFocus("###scene");
LoadCachedScene();
SetEditorState(EditorState::Preview);
}
Application::Get().GetSystem<AudioManager>()->UpdateListener(Application::Get().GetCurrentScene());
Application::Get().GetSystem<AudioManager>()->SetPaused(true);
Application::Get().SetEditorState(EditorState::Preview);

// m_SelectedEntity = entt::null;
m_SelectedEntities.clear();
ImGui::SetWindowFocus("###scene");
LoadCachedScene();
SetEditorState(EditorState::Preview);
}

if(m_SceneViewActive)
Expand Down
22 changes: 2 additions & 20 deletions Editor/Source/HierarchyPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ namespace Lumos

if(deleteEntity)
{
DestroyEntity(node, registry);
nodeEntity.GetScene()->DestroyEntity(nodeEntity);
if(nodeOpen)
ImGui::TreePop();

Expand Down Expand Up @@ -479,24 +479,6 @@ namespace Lumos
}
}

void HierarchyPanel::DestroyEntity(entt::entity entity, entt::registry& registry)
{
LUMOS_PROFILE_FUNCTION();
auto hierarchyComponent = registry.try_get<Hierarchy>(entity);
if(hierarchyComponent)
{
entt::entity child = hierarchyComponent->First();
while(child != entt::null)
{
auto hierarchyComponent = registry.try_get<Hierarchy>(child);
auto next = hierarchyComponent ? hierarchyComponent->Next() : entt::null;
DestroyEntity(child, registry);
child = next;
}
}
registry.destroy(entity);
}

bool HierarchyPanel::IsParentOfEntity(entt::entity entity, entt::entity child, entt::registry& registry)
{
LUMOS_PROFILE_FUNCTION();
Expand Down Expand Up @@ -712,7 +694,7 @@ ImGui::GetStyle().ChildBorderSize = backup_border_size;

if(m_Editor->GetCutCopyEntity())
{
DestroyEntity(entity, registry);
copiedEntity.GetScene()->DestroyEntity(copiedEntity);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Editor/Source/HierarchyPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace Lumos

void DrawNode(entt::entity node, entt::registry& registry);
void OnImGui() override;

void DestroyEntity(entt::entity entity, entt::registry& registry);
bool IsParentOfEntity(entt::entity entity, entt::entity child, entt::registry& registry);

private:
Expand Down
31 changes: 27 additions & 4 deletions Editor/Source/ResourcePanel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Editor.h"
#include "ResourcePanel.h"
#include <Lumos/Core/OS/Input.h>
#include <Lumos/Graphics/RHI/Texture.h>
#include <Lumos/Core/Profiler.h>
#include <Lumos/Utilities/StringUtilities.h>
Expand Down Expand Up @@ -103,8 +104,11 @@ namespace Lumos
m_Delimiter = Str8Lit("/");
#endif

m_GridSize = 130.0f;
m_GridSize *= Application::Get().GetWindow()->GetDPIScale();
float dpi = Application::Get().GetWindow()->GetDPIScale();
m_GridSize = 180.0f;
m_GridSize *= dpi;
MinGridSize *= dpi;
MaxGridSize *= dpi;
m_BasePath = PushStr8F(m_Arena, "%sAssets", Application::Get().GetProjectSettings().m_ProjectRoot.c_str());

std::string assetsBasePath;
Expand Down Expand Up @@ -262,6 +266,25 @@ namespace Lumos
const float SmallOffsetX = 6.0f * Application::Get().GetWindowDPI();
ImDrawList* drawList = ImGui::GetWindowDrawList();

if(Input::Get().GetKeyHeld(InputCode::Key::LeftControl))
{
float mouseScroll = Input::Get().GetScrollOffset();

if(m_IsInListView)
{
if (mouseScroll > 0)
m_IsInListView = false;
}
else
{
m_GridSize += mouseScroll;
if(m_GridSize < MinGridSize)
m_IsInListView = true;
}

m_GridSize = Maths::Clamp(m_GridSize, MinGridSize, MaxGridSize);
}

if(!dirInfo->IsFile)
{
if(dirInfo->Leaf)
Expand Down Expand Up @@ -716,7 +739,7 @@ namespace Lumos

if(!m_IsInListView)
{
ImGui::SliderFloat("##GridSize", &m_GridSize, 40.0f, 400.0f);
ImGui::SliderFloat("##GridSize", &m_GridSize, MinGridSize, MaxGridSize);
}
ImGui::EndPopup();
}
Expand Down Expand Up @@ -913,7 +936,7 @@ namespace Lumos

if(!m_IsInListView)
{
ImGui::SliderFloat("##GridSize", &m_GridSize, 40.0f, 400.0f);
ImGui::SliderFloat("##GridSize", &m_GridSize, MinGridSize, MaxGridSize);
}
ImGui::EndPopup();
}
Expand Down
2 changes: 2 additions & 0 deletions Editor/Source/ResourcePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ namespace Lumos
Str8Lit("fbx"), Str8Lit("obj"), Str8Lit("wav"), Str8Lit("cs"), Str8Lit("png"), Str8Lit("blend"), Str8Lit("lsc"), Str8Lit("ogg"), Str8Lit("lua")
};

float MinGridSize = 50;
float MaxGridSize = 400;
String8 m_MovePath;
String8 m_LastNavPath;
String8 m_Delimiter;
Expand Down
26 changes: 26 additions & 0 deletions Lumos/Source/Lumos/Scene/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,32 @@ namespace Lumos
return m_EntityManager->GetEntityByUUID(id);
}

namespace
{
void _DestroyEntity(entt::entity entity, entt::registry& registry)
{
LUMOS_PROFILE_FUNCTION();
auto hierarchyComponent = registry.try_get<Hierarchy>(entity);
if(hierarchyComponent)
{
entt::entity child = hierarchyComponent->First();
while(child != entt::null)
{
auto hierarchyComponent = registry.try_get<Hierarchy>(child);
auto next = hierarchyComponent ? hierarchyComponent->Next() : entt::null;
_DestroyEntity(child, registry);
child = next;
}
}
registry.destroy(entity);
}
}

void Scene::DestroyEntity(Entity entity)
{
_DestroyEntity(entity.GetHandle(), GetRegistry());
}

void Scene::DuplicateEntity(Entity entity)
{
LUMOS_PROFILE_FUNCTION();
Expand Down
1 change: 1 addition & 0 deletions Lumos/Source/Lumos/Scene/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace Lumos
Entity CreateEntity(const std::string& name);
Entity GetEntityByUUID(uint64_t id);
Entity InstantiatePrefab(const std::string& path);
void DestroyEntity(Entity entity);
void SavePrefab(Entity entity, const std::string& path);

EntityManager* GetEntityManager() { return m_EntityManager.get(); }
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Install Vulkan SDK (https://vulkan.lunarg.com/)
sudo apt-get install -y g++-11 libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libopenal-dev mesa-common-dev
cd Lumos
Tools/linux/premake5 gmake2
cd build
make -j8 # config=release
```
#### Windows
Expand Down

0 comments on commit 2d55212

Please sign in to comment.