Skip to content

Commit

Permalink
Merge pull request #143 from jmorton06/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jmorton06 authored Sep 14, 2024
2 parents d65c523 + 2d57072 commit 5b16bf1
Show file tree
Hide file tree
Showing 116 changed files with 3,202 additions and 3,789 deletions.
73 changes: 33 additions & 40 deletions Editor/Source/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ namespace Lumos
: Application()
, m_IniFile("")
{
// #if LUMOS_ENABLE_LOG
// spdlog::sink_ptr sink = std::make_shared<ImGuiConsoleSink_mt>();
//
// Lumos::Debug::Log::AddSink(sink);
// #endif

Debug::Log::SetLoggerFunction(ConsoleLoggerFunction);
}

Expand Down Expand Up @@ -750,8 +744,8 @@ namespace Lumos

if(ImGui::BeginMenu("Scenes"))
{
ArenaTemp scratch = ScratchBegin(0,0);
auto scenes = Application::Get().GetSceneManager()->GetSceneNames(scratch.arena);
ArenaTemp scratch = ScratchBegin(0, 0);
auto scenes = Application::Get().GetSceneManager()->GetSceneNames(scratch.arena);

for(size_t i = 0; i < scenes.Size(); i++)
{
Expand Down Expand Up @@ -852,7 +846,7 @@ namespace Lumos
Lumos::OS::Instance()->OpenURL("https://github.com/skypjack/entt");
if(ImGui::MenuItem((const char*)PushStr8F(scratch.arena, "Cereal - Version : %i.%i.%i", CEREAL_VERSION_MAJOR, CEREAL_VERSION_MINOR, CEREAL_VERSION_PATCH).str))
Lumos::OS::Instance()->OpenURL("https://github.com/USCiLab/cereal");
if (ImGui::MenuItem((const char*)PushStr8F(scratch.arena, "Box2D - Version : %i.%i", 3, 0).str))
if(ImGui::MenuItem((const char*)PushStr8F(scratch.arena, "Box2D - Version : %i.%i", 3, 0).str))
Lumos::OS::Instance()->OpenURL("https://github.com/erincatto/box2d");
ScratchEnd(scratch);

Expand Down Expand Up @@ -1159,15 +1153,15 @@ namespace Lumos
if(ImGui::Button("OK", ImVec2(120, 0)))
{
String8 sceneName = Str8StdS(newSceneName);
ArenaTemp scratch = ScratchBegin(0,0);
int sameNameCount = 0;
String8 Path = PushStr8F(scratch.arena, "//Assets/Scenes/%s.lsn", (char*)sceneName.str);
ArenaTemp scratch = ScratchBegin(0, 0);
int sameNameCount = 0;

String8 Path = PushStr8F(scratch.arena, "//Assets/Scenes/%s.lsn", (char*)sceneName.str);
while(FileSystem::FileExists((const char*)Path.str) || m_SceneManager->ContainsScene((const char*)sceneName.str))
{
sameNameCount++;
sceneName = PushStr8F(scratch.arena, "%s%i", (char*)newSceneName.c_str(), sameNameCount);
Path = PushStr8F(scratch.arena, "//Assets/Scenes/%s.lsn", (char*)sceneName.str);
sceneName = PushStr8F(scratch.arena, "%s%i", (char*)newSceneName.c_str(), sameNameCount);
Path = PushStr8F(scratch.arena, "//Assets/Scenes/%s.lsn", (char*)sceneName.str);
}
auto scene = new Scene(std::string((const char*)sceneName.str));

Expand All @@ -1176,23 +1170,23 @@ namespace Lumos
{
auto cube = scene->GetEntityManager()->Create("Cube");
cube.AddComponent<Graphics::ModelComponent>(Graphics::PrimitiveType::Cube);

auto light = scene->GetEntityManager()->Create("Light");
auto& lightComp = light.AddComponent<Graphics::Light>();
Mat4 lightView = Mat4::LookAt(Vec3(30.0f, 9.0f, 50.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
light.GetTransform().SetLocalTransform(lightView);
light.GetTransform().SetWorldMatrix(Mat4(1.0f));

auto camera = scene->GetEntityManager()->Create("Camera");
camera.AddComponent<Camera>();
camera.GetComponent<Camera>().SetFar(10000);
camera.AddComponent<Camera>();
camera.GetComponent<Camera>().SetFar(10000);
Mat4 viewMat = Mat4::LookAt(Vec3(-1.0f, 0.5f, 1.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
camera.GetTransform().SetLocalTransform(viewMat);
camera.GetTransform().SetWorldMatrix(Mat4(1.0f));
camera.GetTransform().SetLocalTransform(viewMat);
camera.GetTransform().SetWorldMatrix(Mat4(1.0f));

auto bb = cube.GetComponent<Graphics::ModelComponent>().ModelRef->GetMeshes().Front()->GetBoundingBox();
camera.GetTransform().SetLocalPosition(-(camera.GetTransform().GetForwardDirection()) * Maths::Distance(bb.Max(), bb.Min()));
camera.GetTransform().SetWorldMatrix(Mat4(1.0f));
camera.GetTransform().SetLocalPosition(-(camera.GetTransform().GetForwardDirection()) * Maths::Distance(bb.Max(), bb.Min()));
camera.GetTransform().SetWorldMatrix(Mat4(1.0f));

auto environment = scene->GetEntityManager()->Create("Environment");
environment.AddComponent<Graphics::Environment>();
Expand Down Expand Up @@ -2333,9 +2327,9 @@ namespace Lumos
auto& meshes = model->ModelRef->GetMeshes();
for(auto mesh : meshes)
{
auto& worldTransform = transform->GetWorldMatrix();
auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
DebugRenderer::DebugDraw(bbCopy, colour, true);
auto& worldTransform = transform->GetWorldMatrix();
auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
DebugRenderer::DebugDraw(bbCopy, colour, true);
}
}
auto sprite = m_HoveredEntity.TryGetComponent<Graphics::Sprite>();
Expand Down Expand Up @@ -2390,9 +2384,9 @@ namespace Lumos
auto& meshes = model->ModelRef->GetMeshes();
for(auto mesh : meshes)
{
auto& worldTransform = transform->GetWorldMatrix();
auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
DebugRenderer::DebugDraw(bbCopy, selectedColour, true);
auto& worldTransform = transform->GetWorldMatrix();
auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
DebugRenderer::DebugDraw(bbCopy, selectedColour, true);
}
}

Expand Down Expand Up @@ -2469,21 +2463,20 @@ namespace Lumos

for(auto mesh : meshes)
{
auto& worldTransform = trans.GetWorldMatrix();
auto& worldTransform = trans.GetWorldMatrix();

auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
float distance;
ray.Intersects(bbCopy, distance);
auto bbCopy = mesh->GetBoundingBox().Transformed(worldTransform);
float distance;
ray.Intersects(bbCopy, distance);

if(distance < Maths::M_INFINITY)
if(distance < Maths::M_INFINITY)
{
if(distance < closestEntityDist)
{
if(distance < closestEntityDist)
{
closestEntityDist = distance;
currentClosestEntity = { entity, scene };
}
closestEntityDist = distance;
currentClosestEntity = { entity, scene };
}

}
}
}
if(!hoveredOnly)
Expand Down
2 changes: 2 additions & 0 deletions Editor/Source/EditorSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace Lumos
m_Editor->GetCamera()->SetNear(editorSettings.m_CameraNear);
if(ImGuiUtilities::Property("Camera Far", editorSettings.m_CameraFar))
m_Editor->GetCamera()->SetFar(editorSettings.m_CameraFar);
float currentSpeed = m_Editor->GetEditorCameraController().GetSpeed();
ImGuiUtilities::Property("Current Camera Speed", currentSpeed, 0.0f, 0.0f, 0.0f, ImGuiUtilities::PropertyFlag::ReadOnly);

ImGui::TextUnformatted("Camera Transform");
ImGui::Columns(1);
Expand Down
5 changes: 4 additions & 1 deletion Editor/Source/InspectorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ namespace Lumos
{
if(selected.Valid())
{
//ImGui::Text("ID: %d", static_cast<int>(registry.entity(selected)));
ImGui::Text("entt ID: %u", static_cast<uint32_t>(selected));
}
else
{
Expand Down Expand Up @@ -2991,6 +2991,9 @@ namespace Lumos

if(hierarchyComp)
{
uint32_t childCount = static_cast<uint32_t>(hierarchyComp->m_ChildCount);
Lumos::ImGuiUtilities::Property("Child Count", childCount, Lumos::ImGuiUtilities::PropertyFlag::ReadOnly);

if(registry.valid(hierarchyComp->Parent()))
{
idComponent = registry.try_get<IDComponent>(hierarchyComp->Parent());
Expand Down
14 changes: 7 additions & 7 deletions Editor/Source/PreviewDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ namespace Lumos
m_PreviewRenderer->m_DebugRenderEnabled = false;
}

m_PreviewScene = new Scene("Preview");
auto& sceneSettings = m_PreviewScene->GetSettings();
m_PreviewScene = new Scene("Preview");
auto& sceneSettings = m_PreviewScene->GetSettings();
sceneSettings.RenderSettings.MSAASamples = 1;
sceneSettings.RenderSettings.BloomEnabled = false;
sceneSettings.RenderSettings.BloomEnabled = false;
{
auto light = m_PreviewScene->GetEntityManager()->Create("Light");
auto& lightComp = light.AddComponent<Graphics::Light>();
Expand Down Expand Up @@ -103,14 +103,14 @@ namespace Lumos
m_PreviewObjectEntity.AddComponent<Graphics::ModelComponent>(ToStdString(path));
}

Mat4 viewMat = Mat4::LookAt(Vec3(-1.0f, 0.5f, 1.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
Mat4 viewMat = Mat4::LookAt(Vec3(-1.0f, 0.5f, 1.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
m_CameraEntity.GetTransform().SetLocalTransform(viewMat);
m_CameraEntity.GetTransform().SetWorldMatrix(Mat4(1.0f));

auto bb = m_PreviewObjectEntity.GetComponent<Graphics::ModelComponent>().ModelRef->GetMeshes().Front()->GetBoundingBox();
viewMat = Mat4::LookAt(-(m_CameraEntity.GetTransform().GetForwardDirection()) * Maths::Distance(bb.Max(), bb.Min()), bb.Center(), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
m_CameraEntity.GetTransform().SetLocalTransform(viewMat);
m_CameraEntity.GetTransform().SetWorldMatrix(Mat4(1.0f));
viewMat = Mat4::LookAt(-(m_CameraEntity.GetTransform().GetForwardDirection()) * Maths::Distance(bb.Max(), bb.Min()), bb.Center(), Vec3(0.0f, 1.0f, 0.0f)).Inverse();
m_CameraEntity.GetTransform().SetLocalTransform(viewMat);
m_CameraEntity.GetTransform().SetWorldMatrix(Mat4(1.0f));
}

void PreviewDraw::LoadMaterial(String8 path)
Expand Down
Loading

0 comments on commit 5b16bf1

Please sign in to comment.