Skip to content

Commit

Permalink
Merge pull request #124 from jmorton06/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jmorton06 authored Dec 7, 2023
2 parents 57fe40d + 479f759 commit 0b2a6d0
Show file tree
Hide file tree
Showing 1,431 changed files with 390,996 additions and 525,249 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,6 @@ ExampleProject/Assets/Meshes/Source
ExampleProject/Assets/Kenney Game Assets All-in-1 1.7.0
DerivedData
ClangBuildAnalyzerSession.txt
compileData.*
ExampleProject/Assets/Meshes/Sponza
Scripts/Setup
25 changes: 20 additions & 5 deletions Editor/Source/ApplicationInfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include <Lumos/Scene/Scene.h>

#include <Lumos/Core/Engine.h>
#include <Lumos/Core/OS/Window.h>
#include <Lumos/Graphics/Renderers/RenderPasses.h>
#include <Lumos/ImGui/ImGuiUtilities.h>
#include <Lumos/Utilities/StringUtilities.h>
#include <imgui/imgui.h>
#include <imgui/Plugins/implot/implot.h>

Expand Down Expand Up @@ -45,8 +47,8 @@ namespace Lumos

ApplicationInfoPanel::ApplicationInfoPanel()
{
m_Name = "ApplicationInfo";
m_SimpleName = "ApplicationInfo";
m_Name = "Application Info##ApplicationInfo";
m_SimpleName = "Application Info";
}

static float MaxFrameTime = 0;
Expand Down Expand Up @@ -127,14 +129,27 @@ namespace Lumos
auto editor = m_Editor;
Application::Get().QueueEvent([VSync, editor]
{
Application::Get().GetWindow()->SetVSync(VSync);
Application::Get().GetWindow()->GetSwapChain()->SetVSync(VSync);
Graphics::Renderer::GetRenderer()->OnResize(Application::Get().GetWindow()->GetWidth(), Application::Get().GetWindow()->GetHeight()); });
Application::Get().GetWindow()->SetVSync(VSync);
Application::Get().GetWindow()->GetSwapChain()->SetVSync(VSync);
Graphics::Renderer::GetRenderer()->OnResize(Application::Get().GetWindow()->GetWidth(), Application::Get().GetWindow()->GetHeight()); });
}
ImGui::Columns(1);
ImGui::Text("FPS : %5.2i", Engine::Get().Statistics().FramesPerSecond);
ImGui::Text("UPS : %5.2i", Engine::Get().Statistics().UpdatesPerSecond);
ImGui::Text("Frame Time : %5.2f ms", Engine::Get().Statistics().FrameTime);
ImGui::Text("Arena Count : %i", GetArenaCount());

uint64_t totalAllocated = 0;
for(int i = 0; i < GetArenaCount(); i++)
{
auto arena = GetArena(i);
totalAllocated += arena->Size;
float percentageFull = (float)arena->Position / (float)arena->Size;
ImGui::ProgressBar((float)arena->Position / (float)arena->Size);
Lumos::ImGuiUtilities::Tooltip((Lumos::StringUtilities::BytesToString(arena->Position) + " / " + Lumos::StringUtilities::BytesToString(arena->Size)).c_str());
}

ImGui::Text("Total %s", Lumos::StringUtilities::BytesToString(totalAllocated).c_str());
ImGui::NewLine();
ImGui::Text("Scene : %s", Application::Get().GetSceneManager()->GetCurrentScene()->GetSceneName().c_str());
ImGui::TreePop();
Expand Down
144 changes: 24 additions & 120 deletions Editor/Source/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Lumos/Core/OS/OS.h>
#include <Lumos/Core/Version.h>
#include <Lumos/Core/Engine.h>
#include <Lumos/Core/OS/Window.h>
#include <Lumos/Audio/AudioManager.h>
#include <Lumos/Scene/Scene.h>
#include <Lumos/Scene/SceneManager.h>
Expand All @@ -43,7 +44,6 @@
#include <Lumos/Graphics/Renderers/DebugRenderer.h>
#include <Lumos/Graphics/Model.h>
#include <Lumos/Graphics/Environment.h>
#include <Lumos/Scene/EntityFactory.h>
#include <Lumos/ImGui/IconsMaterialDesignIcons.h>
#include <Lumos/Embedded/EmbedAsset.h>
#include <Lumos/Scene/Component/ModelComponent.h>
Expand All @@ -54,6 +54,7 @@
#include <Lumos/Maths/Plane.h>
#include <Lumos/Maths/MathsUtilities.h>
#include <Lumos/Core/LMLog.h>
#include <Lumos/Core/String.h>

#include <spdlog/spdlog.h>
#include <spdlog/fmt/ostr.h>
Expand All @@ -71,9 +72,11 @@ namespace Lumos
: Application()
, m_IniFile("")
{
#if LUMOS_ENABLE_LOG
spdlog::sink_ptr sink = std::make_shared<ImGuiConsoleSink_mt>();

Lumos::Debug::Log::AddSink(sink);
#endif

// Remove?
s_Editor = this;
Expand Down Expand Up @@ -426,7 +429,7 @@ namespace Lumos
ImVec2 pos = tab.Window->Pos;
pos.x = pos.x + tab.Offset + ImGui::GetStyle().FramePadding.x;
pos.y = pos.y + ImGui::GetStyle().ItemSpacing.y;
ImRect bb(pos, { pos.x + tab.ContentWidth, pos.y });
ImRect bb(pos, { pos.x + tab.Width, pos.y });

tab.Window->DrawList->AddLine(bb.Min, bb.Max, (!tab_bar_focused) ? ImGui::GetColorU32(ImGuiCol_SliderGrabActive) : ImGui::GetColorU32(ImGuiCol_Text), 2.0f);
}
Expand Down Expand Up @@ -678,7 +681,7 @@ namespace Lumos

ImGui::EndMenu();
}
if(ImGui::BeginMenu("Panels"))
if(ImGui::BeginMenu("View"))
{
for(auto& panel : m_Panels)
{
Expand All @@ -700,7 +703,7 @@ namespace Lumos
{
auto scenes = Application::Get().GetSceneManager()->GetSceneNames();

for(size_t i = 0; i < scenes.size(); i++)
for(size_t i = 0; i < scenes.Size(); i++)
{
auto name = scenes[i];
if(ImGui::MenuItem(name.c_str()))
Expand All @@ -712,65 +715,6 @@ namespace Lumos
ImGui::EndMenu();
}

if(ImGui::BeginMenu("Entity"))
{
auto scene = Application::Get().GetSceneManager()->GetCurrentScene();

if(ImGui::MenuItem("CreateEmpty"))
{
scene->CreateEntity();
}

if(ImGui::MenuItem("Cube"))
{
auto entity = scene->CreateEntity("Cube");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Cube);
}

if(ImGui::MenuItem("Sphere"))
{
auto entity = scene->CreateEntity("Sphere");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Sphere);
}

if(ImGui::MenuItem("Pyramid"))
{
auto entity = scene->CreateEntity("Pyramid");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Pyramid);
}

if(ImGui::MenuItem("Plane"))
{
auto entity = scene->CreateEntity("Plane");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Plane);
}

if(ImGui::MenuItem("Cylinder"))
{
auto entity = scene->CreateEntity("Cylinder");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Cylinder);
}

if(ImGui::MenuItem("Capsule"))
{
auto entity = scene->CreateEntity("Capsule");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Capsule);
}

if(ImGui::MenuItem("Terrain"))
{
auto entity = scene->CreateEntity("Terrain");
entity.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Terrain);
}

if(ImGui::MenuItem("Light Cube"))
{
EntityFactory::AddLightCube(Application::Get().GetSceneManager()->GetCurrentScene(), glm::vec3(0.0f), glm::vec3(0.0f));
}

ImGui::EndMenu();
}

if(ImGui::BeginMenu("Graphics"))
{
if(ImGui::MenuItem("Compile Shaders"))
Expand All @@ -780,8 +724,7 @@ namespace Lumos
if(ImGui::MenuItem("Embed Shaders"))
{
std::string coreDataPath;
VFS::Get().ResolvePhysicalPath("//CoreShaders", coreDataPath, true);
auto shaderPath = std::filesystem::path(coreDataPath + "/CompiledSPV/");
auto shaderPath = std::filesystem::path(m_ProjectSettings.m_EngineAssetPath + "Shaders/CompiledSPV/");
int shaderCount = 0;
if(std::filesystem::is_directory(shaderPath))
{
Expand Down Expand Up @@ -871,14 +814,18 @@ namespace Lumos
ImGui::SameLine();
ImGui::TextUnformatted(m_ProjectSettings.m_ProjectName.c_str());

ImGuiUtilities::Tooltip(("Current project (" + m_ProjectSettings.m_ProjectName + ".lmproj)").c_str());
String8 projectString = PushStr8F(GetFrameArena(), "Current project ( %s.lmproj )", m_ProjectSettings.m_ProjectName.c_str());

ImGuiUtilities::Tooltip((const char*)projectString.str);
ImGuiUtilities::DrawBorder(ImGuiUtilities::RectExpanded(ImGuiUtilities::GetItemRect(), 24.0f, 68.0f), 1.0f, 3.0f, 0.0f, -60.0f);

ImGui::SameLine();
ImGui::Separator();
ImGui::SameLine(ImGui::GetCursorPosX() + 32.0f);
ImGui::TextUnformatted(GetCurrentScene()->GetSceneName().c_str());
ImGuiUtilities::Tooltip(("Current Scene (" + GetCurrentScene()->GetSceneName() + ".lsn)").c_str());
String8 sceneString = PushStr8F(GetFrameArena(), "Current Scene ( %s.lsn )", GetCurrentScene()->GetSceneName().c_str());

ImGuiUtilities::Tooltip((const char*)sceneString.str);
ImGuiUtilities::DrawBorder(ImGuiUtilities::RectExpanded(ImGuiUtilities::GetItemRect(), 24.0f, 68.0f), 1.0f, 3.0f, 0.0f, -60.0f);
}

Expand Down Expand Up @@ -1145,7 +1092,7 @@ namespace Lumos
int sameNameCount = 0;
auto sceneNames = m_SceneManager->GetSceneNames();

while(FileSystem::FileExists("//Scenes/" + sceneName + ".lsn") || std::find(sceneNames.begin(), sceneNames.end(), sceneName) != sceneNames.end())
while(FileSystem::FileExists("//Assets/Scenes/" + sceneName + ".lsn") || m_SceneManager->ContainsScene(sceneName))
{
sameNameCount++;
sceneName = fmt::format(newSceneName + "{0}", sameNameCount);
Expand Down Expand Up @@ -1175,7 +1122,7 @@ namespace Lumos
scene->Serialise(m_ProjectSettings.m_ProjectRoot + "Assets/Scenes/");
}
Application::Get().GetSceneManager()->EnqueueScene(scene);
Application::Get().GetSceneManager()->SwitchScene((int)(Application::Get().GetSceneManager()->GetScenes().size()) - 1);
Application::Get().GetSceneManager()->SwitchScene((int)(Application::Get().GetSceneManager()->GetScenes().Size()) - 1);

ImGui::CloseCurrentPopup();
}
Expand Down Expand Up @@ -1631,8 +1578,8 @@ namespace Lumos
ImGui::DockBuilderDockWindow("###profiler", DockingBottomLeftChild);
ImGui::DockBuilderDockWindow("###resources", DockingBottomLeftChild);
ImGui::DockBuilderDockWindow("Dear ImGui Demo", DockLeft);
ImGui::DockBuilderDockWindow("GraphicsInfo", DockLeft);
ImGui::DockBuilderDockWindow("ApplicationInfo", DockLeft);
ImGui::DockBuilderDockWindow("###GraphicsInfo", DockLeft);
ImGui::DockBuilderDockWindow("###ApplicationInfo", DockLeft);
ImGui::DockBuilderDockWindow("###hierarchy", DockLeft);
ImGui::DockBuilderDockWindow("###textEdit", DockMiddleLeft);
ImGui::DockBuilderDockWindow("###scenesettings", DockLeft);
Expand Down Expand Up @@ -1685,9 +1632,9 @@ namespace Lumos
#ifdef LUMOS_PLATFORM_WINDOWS
Platform = "Windows";
#elif LUMOS_PLATFORM_LINUX
Platform = "Linux";
Platform = "Linux";
#elif LUMOS_PLATFORM_MACOS
Platform = "MacOS";
Platform = "MacOS";
#elif LUMOS_PLATFORM_IOS
Platform = "iOS";
#endif
Expand Down Expand Up @@ -1860,13 +1807,6 @@ namespace Lumos
if(m_EditorState == EditorState::Play)
autoSaveTimer = 0.0f;

if (Input::Get().GetKeyPressed(Lumos::InputCode::Key::Delete))
{
auto *scene = Application::Get().GetCurrentScene();
for(auto entity : m_SelectedEntities)
scene->DestroyEntity(Entity(entity, scene));
}

if(Input::Get().GetKeyPressed(Lumos::InputCode::Key::Escape) && GetEditorState() != EditorState::Preview)
{
Application::Get().GetSystem<LumosPhysicsEngine>()->SetPaused(true);
Expand Down Expand Up @@ -2171,43 +2111,6 @@ namespace Lumos
DebugRenderer::DebugDraw(bbCopy, selectedColour, true);
}
}
if(model->ModelRef->GetSkeleton())
{
auto& skeleton = *model->ModelRef->GetSkeleton().get();
const int num_joints = skeleton.num_joints();

// Iterate through each joint in the skeleton
for(int i = 0; i < num_joints; ++i)
{
// Get the current joint's world space transform

const ozz::math::Transform joint_transform; //= skeleton.joint_rest_poses()[i];

// Convert ozz::math::Transform to glm::mat4
glm::mat4 joint_world_transform = glm::translate(glm::mat4(1.0f), glm::vec3(joint_transform.translation.x, joint_transform.translation.y, joint_transform.translation.z));
joint_world_transform *= glm::mat4_cast(glm::quat(joint_transform.rotation.x, joint_transform.rotation.y, joint_transform.rotation.z, joint_transform.rotation.w));
joint_world_transform = glm::scale(joint_world_transform, glm::vec3(joint_transform.scale.x, joint_transform.scale.y, joint_transform.scale.z));

// Multiply the joint's world transform by the entity transform
glm::mat4 final_transform = transform->GetWorldMatrix() * joint_world_transform;

// Get the parent joint's world space transform
const int parent_index = skeleton.joint_parents()[i];
glm::mat4 parent_world_transform(1.0f);
if(parent_index != ozz::animation::Skeleton::Constants::kNoParent)
{
const ozz::math::Transform parent_transform; // = skeleton.joint_rest_poses()[parent_index];
parent_world_transform = glm::translate(glm::mat4(1.0f), glm::vec3(parent_transform.translation.x, parent_transform.translation.y, parent_transform.translation.z));
parent_world_transform *= glm::mat4_cast(glm::quat(parent_transform.rotation.x, parent_transform.rotation.y, parent_transform.rotation.z, parent_transform.rotation.w));
parent_world_transform = glm::scale(parent_world_transform, glm::vec3(parent_transform.scale.x, parent_transform.scale.y, parent_transform.scale.z));
parent_world_transform = transform->GetWorldMatrix() * parent_world_transform;
}

// Draw a line between the current joint and its parent joint
// (assuming you have a function to draw a line between two points)
DebugRenderer::DrawHairLine(glm::vec3(final_transform[3]), glm::vec3(parent_world_transform[3]), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f)); // Example color: red
}
}
}

auto sprite = registry.try_get<Graphics::Sprite>(m_SelectedEntity);
Expand Down Expand Up @@ -2393,7 +2296,7 @@ namespace Lumos
{
LUMOS_PROFILE_FUNCTION();
std::string physicalPath;
if(!VFS::Get().ResolvePhysicalPath(filePath, physicalPath))
if(!FileSystem::Get().ResolvePhysicalPath(filePath, physicalPath))
{
LUMOS_LOG_ERROR("Failed to Load Lua script {0}", filePath);
return;
Expand Down Expand Up @@ -2532,7 +2435,7 @@ namespace Lumos
else if(IsAudioFile(path))
{
std::string physicalPath;
Lumos::VFS::Get().ResolvePhysicalPath(path, physicalPath);
Lumos::FileSystem::Get().ResolvePhysicalPath(path, physicalPath);
auto sound = Sound::Create(physicalPath, StringUtilities::GetFilePathExtension(path));

auto soundNode = SharedPtr<SoundNode>(SoundNode::Create());
Expand Down Expand Up @@ -2655,6 +2558,7 @@ namespace Lumos
void Editor::AddDefaultEditorSettings()
{
LUMOS_PROFILE_FUNCTION();
LUMOS_LOG_INFO("Setting default editor settings");
m_ProjectSettings.m_ProjectRoot = "../../ExampleProject/";
m_ProjectSettings.m_ProjectName = "Example";

Expand Down Expand Up @@ -2785,7 +2689,7 @@ namespace Lumos
else
{
std::string physicalPath;
if(Lumos::VFS::Get().ResolvePhysicalPath("//Scenes/" + Application::Get().GetCurrentScene()->GetSceneName() + ".lsn", physicalPath))
if(Lumos::FileSystem::Get().ResolvePhysicalPath("//Assets/Scenes/" + Application::Get().GetCurrentScene()->GetSceneName() + ".lsn", physicalPath))
{
auto newPath = StringUtilities::RemoveName(physicalPath);
Application::Get().GetCurrentScene()->Deserialise(newPath, false);
Expand Down
8 changes: 4 additions & 4 deletions Editor/Source/EditorSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Lumos
{
EditorSettingsPanel::EditorSettingsPanel()
{
m_Name = "EditorSettings###editorsettings";
m_Name = "Editor Settings###editorsettings";
m_SimpleName = "Editor Settings";
}

Expand Down Expand Up @@ -61,19 +61,19 @@ namespace Lumos
// Call this to fix alignment with columns
ImGui::AlignTextToFramePadding();

if(Lumos::ImGuiUtilities::PorpertyTransform("Position", position, itemWidth))
if(Lumos::ImGuiUtilities::PropertyTransform("Position", position, itemWidth))
transform.SetLocalPosition(position);

ImGui::SameLine();
if(Lumos::ImGuiUtilities::PorpertyTransform("Rotation", rotation, itemWidth))
if(Lumos::ImGuiUtilities::PropertyTransform("Rotation", rotation, itemWidth))
{
float pitch = Lumos::Maths::Min(rotation.x, 89.9f);
pitch = Lumos::Maths::Max(pitch, -89.9f);
transform.SetLocalOrientation(glm::quat(glm::radians(glm::vec3(pitch, rotation.y, rotation.z))));
}

ImGui::SameLine();
if(Lumos::ImGuiUtilities::PorpertyTransform("Scale", scale, itemWidth))
if(Lumos::ImGuiUtilities::PropertyTransform("Scale", scale, itemWidth))
{
transform.SetLocalScale(scale);
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Source/FileBrowserPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "FileBrowserPanel.h"
#include "Editor.h"
#include <Lumos/Core/StringUtilities.h>
#include <Lumos/Utilities/StringUtilities.h>
#include <Lumos/Core/OS/FileSystem.h>
#include <Lumos/ImGui/IconsMaterialDesignIcons.h>
#include <imgui/imgui.h>
Expand Down
Loading

0 comments on commit 0b2a6d0

Please sign in to comment.