diff --git a/Editor/Source/Editor.cpp b/Editor/Source/Editor.cpp index 33e1dc75..8c3c6d68 100644 --- a/Editor/Source/Editor.cpp +++ b/Editor/Source/Editor.cpp @@ -81,12 +81,6 @@ namespace Lumos : Application() , m_IniFile("") { - // #if LUMOS_ENABLE_LOG - // spdlog::sink_ptr sink = std::make_shared(); - // - // Lumos::Debug::Log::AddSink(sink); - // #endif - Debug::Log::SetLoggerFunction(ConsoleLoggerFunction); } @@ -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++) { @@ -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); @@ -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)); @@ -1176,23 +1170,23 @@ namespace Lumos { auto cube = scene->GetEntityManager()->Create("Cube"); cube.AddComponent(Graphics::PrimitiveType::Cube); - + auto light = scene->GetEntityManager()->Create("Light"); auto& lightComp = light.AddComponent(); 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.GetComponent().SetFar(10000); + camera.AddComponent(); + camera.GetComponent().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().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(); @@ -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(); @@ -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); } } @@ -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) diff --git a/Editor/Source/EditorSettingsPanel.cpp b/Editor/Source/EditorSettingsPanel.cpp index 720073bb..13b375a1 100644 --- a/Editor/Source/EditorSettingsPanel.cpp +++ b/Editor/Source/EditorSettingsPanel.cpp @@ -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); diff --git a/Editor/Source/InspectorPanel.cpp b/Editor/Source/InspectorPanel.cpp index 1e77208f..cb0c4fc8 100644 --- a/Editor/Source/InspectorPanel.cpp +++ b/Editor/Source/InspectorPanel.cpp @@ -2891,7 +2891,7 @@ namespace Lumos { if(selected.Valid()) { - //ImGui::Text("ID: %d", static_cast(registry.entity(selected))); + ImGui::Text("entt ID: %u", static_cast(selected)); } else { @@ -2991,6 +2991,9 @@ namespace Lumos if(hierarchyComp) { + uint32_t childCount = static_cast(hierarchyComp->m_ChildCount); + Lumos::ImGuiUtilities::Property("Child Count", childCount, Lumos::ImGuiUtilities::PropertyFlag::ReadOnly); + if(registry.valid(hierarchyComp->Parent())) { idComponent = registry.try_get(hierarchyComp->Parent()); diff --git a/Editor/Source/PreviewDraw.cpp b/Editor/Source/PreviewDraw.cpp index 8aabf514..33f88833 100644 --- a/Editor/Source/PreviewDraw.cpp +++ b/Editor/Source/PreviewDraw.cpp @@ -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(); @@ -103,14 +103,14 @@ namespace Lumos m_PreviewObjectEntity.AddComponent(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().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) diff --git a/Editor/Source/ResourcePanel.cpp b/Editor/Source/ResourcePanel.cpp index 76be7b37..0def2389 100644 --- a/Editor/Source/ResourcePanel.cpp +++ b/Editor/Source/ResourcePanel.cpp @@ -195,19 +195,19 @@ namespace Lumos if(directory && directory->Opened) return directory->AssetPath; - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 absolutePath = StringUtilities::RelativeToAbsolutePath(temp.arena, directoryPath, Str8Lit("//Assets"), m_BasePath); - auto stdPath = std::filesystem::path(std::string((const char*)absolutePath.str, absolutePath.size)); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 absolutePath = StringUtilities::RelativeToAbsolutePath(temp.arena, directoryPath, Str8Lit("//Assets"), m_BasePath); + auto stdPath = std::filesystem::path(std::string((const char*)absolutePath.str, absolutePath.size)); SharedPtr directoryInfo = directory ? directory : CreateSharedPtr(directoryPath, !std::filesystem::is_directory(stdPath)); directoryInfo->Parent = parent; - //TODO: create paths at max size and use free list + // TODO: create paths at max size and use free list directoryInfo->AssetPath = StringUtilities::AbsolutePathToRelativeFileSystemPath(m_Arena, directoryPath, m_BasePath, Str8Lit("//Assets")); - String8 extension = StringUtilities::Str8PathSkipLastPeriod(directoryInfo->AssetPath); + String8 extension = StringUtilities::Str8PathSkipLastPeriod(directoryInfo->AssetPath); - ScratchEnd(temp); + ScratchEnd(temp); if(std::filesystem::is_directory(stdPath)) { @@ -219,10 +219,10 @@ namespace Lumos { continue; } - + if(Str8Match(directoryInfo->AssetPath, Str8Lit("//Assets/Cache"))) { - directoryInfo->Hidden = true; + directoryInfo->Hidden = true; continue; } @@ -245,12 +245,12 @@ namespace Lumos if(fileTypeIt != s_FileTypes.end()) fileType = fileTypeIt->second; - directoryInfo->IsFile = true; - directoryInfo->Type = fileType; - directoryInfo->FileSize = std::filesystem::exists(stdPath) ? std::filesystem::file_size(stdPath) : 0; - directoryInfo->Hidden = std::filesystem::exists(stdPath) ? IsHidden(stdPath) : true; - directoryInfo->Opened = true; - directoryInfo->Leaf = true; + directoryInfo->IsFile = true; + directoryInfo->Type = fileType; + directoryInfo->FileSize = std::filesystem::exists(stdPath) ? std::filesystem::file_size(stdPath) : 0; + directoryInfo->Hidden = std::filesystem::exists(stdPath) ? IsHidden(stdPath) : true; + directoryInfo->Opened = true; + directoryInfo->Leaf = true; ImVec4 fileTypeColor = { 1.0f, 1.0f, 1.0f, 1.0f }; const auto& fileTypeColorIt = s_TypeColors.find(fileType); @@ -312,10 +312,10 @@ namespace Lumos for(int i = 0; i < dirInfo->Children.Size(); i++) { - if(!m_ShowHiddenFiles && dirInfo->Children[i]->Hidden) - { - continue; - } + if(!m_ShowHiddenFiles && dirInfo->Children[i]->Hidden) + { + continue; + } if(!dirInfo->Children[i]->IsFile) { @@ -458,10 +458,10 @@ namespace Lumos if(ImGui::Selectable("New folder")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); - std::filesystem::create_directory(std::filesystem::path(std::string((char*)fullPath.str, fullPath.size)) / "NewFolder"); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + std::filesystem::create_directory(std::filesystem::path(std::string((char*)fullPath.str, fullPath.size)) / "NewFolder"); + ScratchEnd(temp); QueueRefresh(); } @@ -513,10 +513,10 @@ namespace Lumos } } - for(u32 i = 0; i < (u32)m_BreadCrumbData.Size() / 2; i++) - { - Swap(m_BreadCrumbData[i], m_BreadCrumbData[m_BreadCrumbData.Size() - i - 1]); - } + for(u32 i = 0; i < (u32)m_BreadCrumbData.Size() / 2; i++) + { + Swap(m_BreadCrumbData[i], m_BreadCrumbData[m_BreadCrumbData.Size() - i - 1]); + } m_UpdateNavigationPath = false; } @@ -537,13 +537,12 @@ namespace Lumos if(newPwdLastSecIdx >= 0) { - int i = 0; + int i = 0; - - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); - auto stdPath = std::filesystem::path(std::string((const char*)currentPath.str, currentPath.size)); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + auto stdPath = std::filesystem::path(std::string((const char*)currentPath.str, currentPath.size)); + ScratchEnd(temp); for(const auto& sec : stdPath) { @@ -644,25 +643,25 @@ namespace Lumos { for(int i = 0; i < m_CurrentDir->Children.Size(); i++) { - if(!m_ShowHiddenFiles && m_CurrentDir->Children[i]->Hidden) - { - continue; - } - - if(m_Filter.IsActive()) - { - if(!m_Filter.PassFilter((const char*)(StringUtilities::Str8PathSkipLastSlash(m_CurrentDir->Children[i]->AssetPath).str))) - { - continue; - } - } - - ImGui::TableNextColumn(); - bool doubleClicked = RenderFile(i, !m_CurrentDir->Children[i]->IsFile, shownIndex, !m_IsInListView); - - if(doubleClicked) - break; - shownIndex++; + if(!m_ShowHiddenFiles && m_CurrentDir->Children[i]->Hidden) + { + continue; + } + + if(m_Filter.IsActive()) + { + if(!m_Filter.PassFilter((const char*)(StringUtilities::Str8PathSkipLastSlash(m_CurrentDir->Children[i]->AssetPath).str))) + { + continue; + } + } + + ImGui::TableNextColumn(); + bool doubleClicked = RenderFile(i, !m_CurrentDir->Children[i]->IsFile, shownIndex, !m_IsInListView); + + if(doubleClicked) + break; + shownIndex++; } } else @@ -703,12 +702,12 @@ namespace Lumos std::string filename = fullPath.stem().string(); std::string extension = fullPath.extension().string(); - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); - auto stdPath = std::filesystem::path(std::string((const char*)currentPath.str, currentPath.size)); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + auto stdPath = std::filesystem::path(std::string((const char*)currentPath.str, currentPath.size)); + ScratchEnd(temp); - std::filesystem::path destinationPath = stdPath/ (filename + extension); + std::filesystem::path destinationPath = stdPath / (filename + extension); { while(std::filesystem::exists(destinationPath)) @@ -725,8 +724,8 @@ namespace Lumos std::string filename = fullPath.stem().string(); std::string extension = fullPath.extension().string(); - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); std::filesystem::path destinationPath = std::filesystem::path(ToStdString(currentPath)) / (filename + extension); { @@ -738,7 +737,7 @@ namespace Lumos } std::filesystem::copy(fullPath, destinationPath); - ScratchEnd(temp); + ScratchEnd(temp); } m_CopiedPath.str = nullptr; m_CopiedPath.size = 0; @@ -766,10 +765,10 @@ namespace Lumos if(ImGui::Selectable("New folder")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); - std::filesystem::create_directory(std::filesystem::path(ToStdString(currentPath))); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + std::filesystem::create_directory(std::filesystem::path(ToStdString(currentPath))); + ScratchEnd(temp); Refresh(); } @@ -835,88 +834,88 @@ namespace Lumos if(CurrentEnty->IsFile) { - textureId = m_FileIcon; - switch(CurrentEnty->Type) - { - case FileType::Texture : - { - if(CurrentEnty->Thumbnail) - { - textureId = CurrentEnty->Thumbnail; - } - else if(!textureCreated) - { - textureCreated = true; - std::string assetPathString = std::string((const char*)CurrentEnty->AssetPath.str, CurrentEnty->AssetPath.size); - if(!m_Editor->GetAssetManager()->AssetExists(assetPathString)) - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(assetPathString, true); - else - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(assetPathString).As(); - textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; - } - break; - } - case FileType::Scene : - { - ArenaTemp scratch = ArenaTempBegin(m_Arena); - String8 fileName = PushStr8Copy(scratch.arena, StringUtilities::GetFileName(CurrentEnty->AssetPath)); - String8 sceneScreenShotPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", (const char*)m_BasePath.str, (const char*)fileName.str); - std::string sceneScreenShotPathtdString = std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size); - if(std::filesystem::exists(std::filesystem::path(sceneScreenShotPathtdString))) - { - textureCreated = true; - String8 sceneScreenShotAssetPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", (const char*)Str8Lit("//Assets").str, (const char*)fileName.str); - - if(!m_Editor->GetAssetManager()->AssetExists(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size))) - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size), true); - else - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size)).As(); - textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; - } - ArenaTempEnd(scratch); - break; - } - case FileType::Material : - case FileType::Model : - { - if(CurrentEnty->Thumbnail) - { - textureId = CurrentEnty->Thumbnail; - } - else if(!textureCreated) - { - textureCreated = true; - ArenaTemp scratch = ArenaTempBegin(m_Arena); - - String8 thumbnailPath; - String8 thumbnailAssetPath; - CreateThumbnailPath(scratch.arena, CurrentEnty, thumbnailAssetPath, thumbnailPath); - - std::string thumbnailpathStdString = std::string((const char*)thumbnailPath.str, thumbnailPath.size); - if(std::filesystem::exists(std::filesystem::path(thumbnailpathStdString))) - { - std::string thumbnailAssetPathStdString = std::string((const char*)thumbnailAssetPath.str, thumbnailAssetPath.size); - - textureCreated = true; - if(!m_Editor->GetAssetManager()->AssetExists(thumbnailpathStdString)) - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(thumbnailAssetPathStdString, true); - else - CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(thumbnailAssetPathStdString).As(); - textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; - } - else - { - m_Editor->RequestThumbnail(CurrentEnty->AssetPath); - textureId = m_FileIcon; - } - - ArenaTempEnd(scratch); - } - break; - } - default: - break; - } + textureId = m_FileIcon; + switch(CurrentEnty->Type) + { + case FileType::Texture: + { + if(CurrentEnty->Thumbnail) + { + textureId = CurrentEnty->Thumbnail; + } + else if(!textureCreated) + { + textureCreated = true; + std::string assetPathString = std::string((const char*)CurrentEnty->AssetPath.str, CurrentEnty->AssetPath.size); + if(!m_Editor->GetAssetManager()->AssetExists(assetPathString)) + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(assetPathString, true); + else + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(assetPathString).As(); + textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; + } + break; + } + case FileType::Scene: + { + ArenaTemp scratch = ArenaTempBegin(m_Arena); + String8 fileName = PushStr8Copy(scratch.arena, StringUtilities::GetFileName(CurrentEnty->AssetPath)); + String8 sceneScreenShotPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", (const char*)m_BasePath.str, (const char*)fileName.str); + std::string sceneScreenShotPathtdString = std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size); + if(std::filesystem::exists(std::filesystem::path(sceneScreenShotPathtdString))) + { + textureCreated = true; + String8 sceneScreenShotAssetPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", (const char*)Str8Lit("//Assets").str, (const char*)fileName.str); + + if(!m_Editor->GetAssetManager()->AssetExists(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size))) + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size), true); + else + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size)).As(); + textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; + } + ArenaTempEnd(scratch); + break; + } + case FileType::Material: + case FileType::Model: + { + if(CurrentEnty->Thumbnail) + { + textureId = CurrentEnty->Thumbnail; + } + else if(!textureCreated) + { + textureCreated = true; + ArenaTemp scratch = ArenaTempBegin(m_Arena); + + String8 thumbnailPath; + String8 thumbnailAssetPath; + CreateThumbnailPath(scratch.arena, CurrentEnty, thumbnailAssetPath, thumbnailPath); + + std::string thumbnailpathStdString = std::string((const char*)thumbnailPath.str, thumbnailPath.size); + if(std::filesystem::exists(std::filesystem::path(thumbnailpathStdString))) + { + std::string thumbnailAssetPathStdString = std::string((const char*)thumbnailAssetPath.str, thumbnailAssetPath.size); + + textureCreated = true; + if(!m_Editor->GetAssetManager()->AssetExists(thumbnailpathStdString)) + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(thumbnailAssetPathStdString, true); + else + CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(thumbnailAssetPathStdString).As(); + textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon; + } + else + { + m_Editor->RequestThumbnail(CurrentEnty->AssetPath); + textureId = m_FileIcon; + } + + ArenaTempEnd(scratch); + } + break; + } + default: + break; + } } bool flipImage = false; @@ -950,20 +949,20 @@ namespace Lumos if(ImGui::Selectable("Delete")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); - std::filesystem::remove_all(std::string((const char*)fullPath.str, fullPath.size)); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + std::filesystem::remove_all(std::string((const char*)fullPath.str, fullPath.size)); + ScratchEnd(temp); QueueRefresh(); } if(ImGui::Selectable("Duplicate")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); - std::filesystem::path fullPathFS = std::string((const char*)fullPath.str, fullPath.size); + std::filesystem::path fullPathFS = std::string((const char*)fullPath.str, fullPath.size); std::filesystem::path destinationPath = fullPathFS; { @@ -978,7 +977,7 @@ namespace Lumos } std::filesystem::copy(fullPathFS, destinationPath); - ScratchEnd(temp); + ScratchEnd(temp); QueueRefresh(); } @@ -986,27 +985,26 @@ namespace Lumos if(ImGui::Selectable("Open Location")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); - Lumos::OS::Instance()->OpenFileLocation(std::string((const char*)fullPath.str, fullPath.size)); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + Lumos::OS::Instance()->OpenFileLocation(std::string((const char*)fullPath.str, fullPath.size)); + ScratchEnd(temp); } if(m_CurrentDir->Children[dirIndex]->IsFile && ImGui::Selectable("Open External")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); - Lumos::OS::Instance()->OpenFileExternal(std::string((const char*)fullPath.str, fullPath.size)); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + Lumos::OS::Instance()->OpenFileExternal(std::string((const char*)fullPath.str, fullPath.size)); + ScratchEnd(temp); } if(ImGui::Selectable("Copy Full Path")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); - ImGui::SetClipboardText((const char*)ToStdString(fullPath).c_str()); - ScratchEnd(temp); - + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + ImGui::SetClipboardText((const char*)ToStdString(fullPath).c_str()); + ScratchEnd(temp); } if(m_CurrentDir->Children[dirIndex]->IsFile && ImGui::Selectable("Copy Asset Path")) @@ -1028,10 +1026,10 @@ namespace Lumos if(ImGui::Selectable("New folder")) { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); - std::filesystem::create_directory(std::filesystem::path(std::string((const char*)fullPath.str, fullPath.size) + "/NewFolder")); - ScratchEnd(temp); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 fullPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->AssetPath, Str8Lit("//Assets"), m_BasePath); + std::filesystem::create_directory(std::filesystem::path(std::string((const char*)fullPath.str, fullPath.size) + "/NewFolder")); + ScratchEnd(temp); QueueRefresh(); } @@ -1163,8 +1161,8 @@ namespace Lumos } else { - ArenaTemp temp = ScratchBegin(&m_Arena, 1); - String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); + ArenaTemp temp = ScratchBegin(&m_Arena, 1); + String8 currentPath = StringUtilities::RelativeToAbsolutePath(temp.arena, m_CurrentDir->Children[dirIndex]->AssetPath, Str8Lit("//Assets"), m_BasePath); m_Editor->FileOpenCallback(std::string((const char*)currentPath.str, currentPath.size)); ScratchEnd(temp); } @@ -1221,18 +1219,18 @@ namespace Lumos } if(!dirFound) ChangeDirectory(m_BaseProjectDir); - else - ChangeDirectory(m_CurrentDir); + else + ChangeDirectory(m_CurrentDir); ScratchEnd(temp); } - void ResourcePanel::CreateThumbnailPath(Arena* arena, DirectoryInformation* directoryInfo, String8& assetPath, String8& AbsolutePath) - { - String8 assetPath1 = directoryInfo->AssetPath; - String8 thumbnailPath = PushStr8F(arena, "%s_thumbnail.png", (const char*)assetPath1.str); + void ResourcePanel::CreateThumbnailPath(Arena* arena, DirectoryInformation* directoryInfo, String8& assetPath, String8& AbsolutePath) + { + String8 assetPath1 = directoryInfo->AssetPath; + String8 thumbnailPath = PushStr8F(arena, "%s_thumbnail.png", (const char*)assetPath1.str); - assetPath = StringUtilities::AbsolutePathToRelativeFileSystemPath(arena, thumbnailPath, Str8Lit("//Assets"), Str8Lit("//Assets/Cache")); - AbsolutePath = StringUtilities::AbsolutePathToRelativeFileSystemPath(arena, assetPath, Str8Lit("//Assets"), m_BasePath); - } + assetPath = StringUtilities::AbsolutePathToRelativeFileSystemPath(arena, thumbnailPath, Str8Lit("//Assets"), Str8Lit("//Assets/Cache")); + AbsolutePath = StringUtilities::AbsolutePathToRelativeFileSystemPath(arena, assetPath, Str8Lit("//Assets"), m_BasePath); + } } diff --git a/Editor/Source/ResourcePanel.h b/Editor/Source/ResourcePanel.h index 88ca42c7..b8311e48 100644 --- a/Editor/Source/ResourcePanel.h +++ b/Editor/Source/ResourcePanel.h @@ -41,7 +41,7 @@ namespace Lumos FileType Type; uint64_t FileSize; ImVec4 FileTypeColour; - + bool Hidden = false; bool IsFile = true; bool Opened = false; @@ -51,8 +51,8 @@ namespace Lumos DirectoryInformation(String8 path, bool isF) { AssetPath = path; - IsFile = isF; - Hidden = false; + IsFile = isF; + Hidden = false; } ~DirectoryInformation() @@ -99,7 +99,7 @@ namespace Lumos static bool MoveFile(String8 filePath, String8 movePath); // String8 StripExtras(String8& filename); - String8 ProcessDirectory(String8 directoryPath,DirectoryInformation* parent, bool processChildren); + String8 ProcessDirectory(String8 directoryPath, DirectoryInformation* parent, bool processChildren); void ChangeDirectory(DirectoryInformation* directory); void RemoveDirectory(DirectoryInformation* directory, bool removeFromParent = true); @@ -111,8 +111,8 @@ namespace Lumos static inline TDArray assetTypes = { Str8Lit("fbx"), Str8Lit("obj"), Str8Lit("wav"), Str8Lit("cs"), Str8Lit("png"), Str8Lit("blend"), Str8Lit("lsc"), Str8Lit("ogg"), Str8Lit("lua") }; - - void CreateThumbnailPath(Arena* arena, DirectoryInformation* directoryInfo, String8& assetPath, String8& AbsolutePath); + + void CreateThumbnailPath(Arena* arena, DirectoryInformation* directoryInfo, String8& assetPath, String8& AbsolutePath); float MinGridSize = 50; float MaxGridSize = 400; diff --git a/Editor/Source/SceneViewPanel.cpp b/Editor/Source/SceneViewPanel.cpp index de2ada3d..930bffe6 100644 --- a/Editor/Source/SceneViewPanel.cpp +++ b/Editor/Source/SceneViewPanel.cpp @@ -388,43 +388,43 @@ namespace Lumos if(physics2D) { - uint32_t flags = physics2D->GetDebugDrawFlags(); - - bool show2DShapes = flags & PhysicsDebugFlags2D::LINEARFORCE2D; - if(ImGui::Checkbox("Shapes (2D)", &show2DShapes)) - { - if(show2DShapes) - flags += PhysicsDebugFlags2D::LINEARFORCE2D; - else - flags -= PhysicsDebugFlags2D::LINEARFORCE2D; - } - - bool showCOG = flags & PhysicsDebugFlags2D::COLLISIONVOLUMES2D; - if(ImGui::Checkbox("Centre of Mass (2D)", &showCOG)) - { - if(showCOG) - flags += PhysicsDebugFlags2D::COLLISIONVOLUMES2D; - else - flags -= PhysicsDebugFlags2D::COLLISIONVOLUMES2D; - } - - bool showJoint = flags & PhysicsDebugFlags2D::CONSTRAINT2D; - if(ImGui::Checkbox("Joint Connection (2D)", &showJoint)) - { - if(showJoint) - flags += PhysicsDebugFlags2D::CONSTRAINT2D; - else - flags -= PhysicsDebugFlags2D::CONSTRAINT2D; - } - - bool showAABB = flags & PhysicsDebugFlags2D::AABB2D; - if(ImGui::Checkbox("AABB (2D)", &showAABB)) - { - if(showAABB) - flags += PhysicsDebugFlags2D::AABB2D; - else - flags -= PhysicsDebugFlags2D::AABB2D; - } + uint32_t flags = physics2D->GetDebugDrawFlags(); + + bool show2DShapes = flags & PhysicsDebugFlags2D::LINEARFORCE2D; + if(ImGui::Checkbox("Shapes (2D)", &show2DShapes)) + { + if(show2DShapes) + flags += PhysicsDebugFlags2D::LINEARFORCE2D; + else + flags -= PhysicsDebugFlags2D::LINEARFORCE2D; + } + + bool showCOG = flags & PhysicsDebugFlags2D::COLLISIONVOLUMES2D; + if(ImGui::Checkbox("Centre of Mass (2D)", &showCOG)) + { + if(showCOG) + flags += PhysicsDebugFlags2D::COLLISIONVOLUMES2D; + else + flags -= PhysicsDebugFlags2D::COLLISIONVOLUMES2D; + } + + bool showJoint = flags & PhysicsDebugFlags2D::CONSTRAINT2D; + if(ImGui::Checkbox("Joint Connection (2D)", &showJoint)) + { + if(showJoint) + flags += PhysicsDebugFlags2D::CONSTRAINT2D; + else + flags -= PhysicsDebugFlags2D::CONSTRAINT2D; + } + + bool showAABB = flags & PhysicsDebugFlags2D::AABB2D; + if(ImGui::Checkbox("AABB (2D)", &showAABB)) + { + if(showAABB) + flags += PhysicsDebugFlags2D::AABB2D; + else + flags -= PhysicsDebugFlags2D::AABB2D; + } physics2D->SetDebugDrawFlags(flags); } diff --git a/ExampleProject/AssetRegistry.lmar b/ExampleProject/AssetRegistry.lmar index acb74a1c..b9ec15a8 100644 --- a/ExampleProject/AssetRegistry.lmar +++ b/ExampleProject/AssetRegistry.lmar @@ -1,10 +1,13 @@ { "value0": { "Version": 2, - "Count": 194, + "Count": 265, "Name": "//Assets/Meshes/greenhouse/skPlantsFlowerYellowTex0.png", "UUID": 22592664930542702, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/16299174074766089871.jpg", + "UUID": 98043891877507985, + "AssetType": 1, "Name": "DepthPrePassAnim", "UUID": 220796699938349989, "AssetType": 6, @@ -35,6 +38,9 @@ "Name": "EnvironmentIrradiance", "UUID": 960524816459447479, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/8006627369776289000.png", + "UUID": 1014597301889436762, + "AssetType": 1, "Name": "//Assets/Scenes/Cache/Sponza.png", "UUID": 1092808811581182007, "AssetType": 1, @@ -47,6 +53,9 @@ "Name": "//Assets/Textures/particle_dust.png", "UUID": 1123372390369367885, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2411100444841994089.jpg", + "UUID": 1130475611784785173, + "AssetType": 1, "Name": "//Assets/Textures/icon32.png", "UUID": 1169913861966067682, "AssetType": 1, @@ -56,6 +65,12 @@ "Name": "//Assets/Cache/Meshes/gym.obj_thumbnail.png", "UUID": 1229536781878886413, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/715093869573992647.jpg", + "UUID": 1290130847179135662, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/332936164838540657.jpg", + "UUID": 1368807874242567164, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skForestFern4Tex0.png", "UUID": 1374507108360195902, "AssetType": 1, @@ -74,6 +89,12 @@ "Name": "EnvironmentMipFilter", "UUID": 1675502722393171918, "AssetType": 6, + "Name": "//Assets/Cache/Meshes/Sponza/Sponza.gltf_thumbnail.png", + "UUID": 1680779725720779975, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8114461559286000061.jpg", + "UUID": 1773864723472139353, + "AssetType": 1, "Name": "Batch2DLine", "UUID": 2094088944344111971, "AssetType": 6, @@ -107,21 +128,39 @@ "Name": "//Assets/Meshes/greenhouse/circlewindow.png", "UUID": 2650902651226494616, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/5823059166183034438.jpg", + "UUID": 2885037267360439351, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8481240838833932244.jpg", + "UUID": 2914807766181672733, + "AssetType": 1, "Name": "//Assets/Meshes/material_sphere/material_sphere.fbx", "UUID": 2948647025781413142, "AssetType": 9, "Name": "//Assets/Textures/PreintegratedFG.tga", "UUID": 3011559381961549495, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/6772804448157695701.jpg", + "UUID": 3015511777157830972, + "AssetType": 1, "Name": "ForwardPBR", "UUID": 3031085133988255604, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/11474523244911310074.jpg", + "UUID": 3040184915685281629, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/6593109234861095314.jpg", + "UUID": 3056158552645787691, + "AssetType": 1, "Name": "ForwardPBRAnim", "UUID": 3175668397740860526, "AssetType": 6, "Name": "//Assets/Meshes/greenhouse/exteriorArch1A.png", "UUID": 3447614406999776187, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/9916269861720640319.jpg", + "UUID": 3459788155502725901, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/greenstoneFloor_Diff.png", "UUID": 3566627028576158015, "AssetType": 1, @@ -137,12 +176,27 @@ "Name": "//Assets/Meshes/Scene/scene.gltf", "UUID": 3853544921239423074, "AssetType": 9, + "Name": "//Assets/Meshes/Sponza/white.png", + "UUID": 3910422899472164735, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/6047387724914829168.jpg", + "UUID": 4039401209977963489, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/13196865903111448057.jpg", + "UUID": 4043297105255920395, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/15295713303328085182.jpg", + "UUID": 4046501193320037423, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/specialbeam_GH4.png", "UUID": 4347402336064998355, "AssetType": 1, "Name": "//Assets/Meshes/stormtrooper/stormtrooper.gltf", "UUID": 4378391369236188799, "AssetType": 9, + "Name": "//Assets/Meshes/Sponza/7441062115984513793.jpg", + "UUID": 4382739155512825190, + "AssetType": 1, "Name": "DepthPrePass", "UUID": 4415649574143950547, "AssetType": 6, @@ -152,24 +206,42 @@ "Name": "//Assets/Meshes/basket.glb", "UUID": 4500161985950185631, "AssetType": 0, + "Name": "//Assets/Meshes/Sponza/2299742237651021498.jpg", + "UUID": 4512582615374619531, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/15722799267630235092.jpg", + "UUID": 4609169353622061456, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/Quid_Sky_DN.png", "UUID": 4757980925201342159, "AssetType": 1, "Name": "//Assets/Meshes/gym.obj", "UUID": 4951225963790835797, "AssetType": 0, + "Name": "//Assets/Meshes/Sponza/6667038893015345571.jpg", + "UUID": 4964605092713413959, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skShowerHeadTex0.png", "UUID": 4974850072488045174, "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/greenstoneFloor.png", "UUID": 5200015067037167424, "AssetType": 1, + "Name": "//Assets/Cache/Meshes/Scene/scene.gltf_thumbnail.png", + "UUID": 5357948409829461133, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8503262930880235456.jpg", + "UUID": 5417088191633740685, + "AssetType": 1, "Name": "//Assets/Meshes/AnimatedMorphCube.glb", "UUID": 5543534150634670453, "AssetType": 9, "Name": "//Assets/Cache/Meshes/DamagedHelmet/glTF/DamagedHelmet.gltf_thumbnail.png", "UUID": 5554588689799643674, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/16275776544635328252.png", + "UUID": 5698093024760268905, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skGnomeHomeTex0.png", "UUID": 5749842087445720401, "AssetType": 1, @@ -179,6 +251,12 @@ "Name": "//Assets/Meshes/greenhouse/Dfurnace.png", "UUID": 5953217185310301223, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/12501374198249454378.jpg", + "UUID": 6066560373137509260, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/10388182081421875623.jpg", + "UUID": 6155090306630358422, + "AssetType": 1, "Name": "//Assets/Scenes/Cache/Platformer.png", "UUID": 6194444174986539845, "AssetType": 1, @@ -188,6 +266,9 @@ "Name": "//Assets/Meshes/greenhouse/HogFoundation_GH1.png", "UUID": 6280961174024816424, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/4871783166746854860.jpg", + "UUID": 6465736750029772252, + "AssetType": 1, "Name": "//Assets/Meshes/Spyro/ArtisansHub.obj", "UUID": 6538867603038803317, "AssetType": 9, @@ -209,18 +290,27 @@ "Name": "//Assets/Meshes/lowpoly_bonfire/scene.gltf", "UUID": 7027018599794543603, "AssetType": 9, + "Name": "//Assets/Meshes/Sponza/14650633544276105767.jpg", + "UUID": 7191417769818910883, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skToolsWateringCanTex0.png", "UUID": 7201228779077066790, "AssetType": 1, "Name": "ChromaticAberation", "UUID": 7375714513771862660, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/3371964815757888145.jpg", + "UUID": 7455977591346813500, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/leafdesign_GH4.png", "UUID": 7612302876869615578, "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/ExWallBorder_GH4.png", "UUID": 7755834373603763581, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/5061699253647017043.png", + "UUID": 7781615148054800833, + "AssetType": 1, "Name": "//Assets/Textures/particle_dust_copy.png", "UUID": 7834188427659250029, "AssetType": 1, @@ -230,9 +320,18 @@ "Name": "//Assets/Meshes/greenhouse/HHut_Inside_Floor_GH4.png", "UUID": 7921666898532392208, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8747919177698443163.jpg", + "UUID": 7983540564144083672, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/1219024358953944284.jpg", + "UUID": 8020769921885392567, + "AssetType": 1, "Name": "//Assets/Cache/Meshes/sphere.obj_thumbnail.png", "UUID": 8071842674810667482, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/7815564343179553343.jpg", + "UUID": 8132119746132615003, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/devilface_B.png", "UUID": 8295672923578575637, "AssetType": 1, @@ -242,6 +341,9 @@ "Name": "//Assets/Scenes/Cache/CollisionPyramidTest.png", "UUID": 8377029983424632478, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/11490520546946913238.jpg", + "UUID": 8417509157257117499, + "AssetType": 1, "Name": "//Assets/Meshes/Fox.glb", "UUID": 8425291053532852983, "AssetType": 9, @@ -254,6 +356,9 @@ "Name": "//Assets/Meshes/greenhouse/WoodBeam_GH4.png", "UUID": 8684206229813379877, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/13982482287905699490.jpg", + "UUID": 9068205711881955648, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/GreenhouseWall2.png", "UUID": 9116119470097498382, "AssetType": 1, @@ -269,6 +374,9 @@ "Name": "Bloom", "UUID": 9292640677943495227, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/8750083169368950601.jpg", + "UUID": 9373390944974422671, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skFootStoolTex0.png", "UUID": 9430157078387944291, "AssetType": 1, @@ -302,9 +410,15 @@ "Name": "//Assets/Meshes/greenhouse/WoodDungeonDoor.png", "UUID": 10093175237610798880, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2969916736137545357.jpg", + "UUID": 10325223064981364649, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skPlantsWindowBoxTex0.png", "UUID": 10331530903584006055, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2185409758123873465.jpg", + "UUID": 10336628128976782605, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/HogBrick2_GH4.png", "UUID": 10362315839565976692, "AssetType": 1, @@ -314,12 +428,18 @@ "Name": "//Assets/Cache/Meshes/material_sphere/material_sphere.obj_thumbnail.png", "UUID": 10387484473150550112, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/7645212358685992005.jpg", + "UUID": 10517838985572401790, + "AssetType": 1, "Name": "//Assets/Meshes/Spyro/Low.png", "UUID": 10543428672904306405, "AssetType": 1, "Name": "DepthOfField", "UUID": 10557890345575391864, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/11968150294050148237.jpg", + "UUID": 10581766720067404949, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/PalegreyFl_GH4.png", "UUID": 10724666440079376789, "AssetType": 1, @@ -338,6 +458,9 @@ "Name": "//Assets/Meshes/greenhouse/LgWindow.png", "UUID": 11077811304147940396, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/14118779221266351425.jpg", + "UUID": 11125725866154499932, + "AssetType": 1, "Name": "//Assets/Textures/round_outline.png", "UUID": 11126978127519170907, "AssetType": 1, @@ -356,15 +479,30 @@ "Name": "//Assets/Meshes/greenhouse/woodmover_sk.png", "UUID": 11546689571810384605, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/759203620573749278.jpg", + "UUID": 11632626362579178205, + "AssetType": 1, "Name": "//Assets/Meshes/DamagedHelmet/glTF/Default_normal.jpg", "UUID": 11696113533973076960, "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/HogWindow1_GH1.png", "UUID": 11805970974342685887, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/466164707995436622.jpg", + "UUID": 11891175326145363048, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2051777328469649772.jpg", + "UUID": 11934113162438817988, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skDiffindoRope64Tex0.png", "UUID": 11981827742016789208, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8773302468495022225.jpg", + "UUID": 12263650696633721287, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/16885566240357350108.jpg", + "UUID": 12288186569820185047, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/Tallpillar_GH4.png", "UUID": 12291039238526031868, "AssetType": 1, @@ -389,6 +527,9 @@ "Name": "//Assets/Meshes/greenhouse/MossyGreenFlagstone_GH4.png", "UUID": 12671691340944658913, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/4975155472559461469.jpg", + "UUID": 12716124099546830009, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/WallTorch_Gh4.png", "UUID": 12752526827353792098, "AssetType": 1, @@ -425,15 +566,30 @@ "Name": "//Assets/Meshes/DamagedHelmet/glTF/DamagedHelmet.gltf", "UUID": 13579337366301463653, "AssetType": 9, + "Name": "//Assets/Meshes/Sponza/6151467286084645207.jpg", + "UUID": 13586315271515006503, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/7268504077753552595.jpg", + "UUID": 13652647086728268907, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/9288698199695299068.jpg", + "UUID": 13745938771577501408, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/HogFoundation_GH4.png", "UUID": 13796017636552425731, "AssetType": 1, "Name": "//Assets/Textures/fire.png", "UUID": 13831315025881660061, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/11872827283454512094.jpg", + "UUID": 13831699179923534725, + "AssetType": 1, "Name": "//Assets/Meshes/lowpoly_bonfire/textures/lambert1.002_metallicRoughness.png", "UUID": 13837274997362013530, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2374361008830720677.jpg", + "UUID": 13854994827704966763, + "AssetType": 1, "Name": "SSAOBlur", "UUID": 13910922921860105132, "AssetType": 6, @@ -443,6 +599,12 @@ "Name": "//Assets/Meshes/greenhouse/skDiffindoWeb2Tex0.png", "UUID": 14000566495614954288, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8051790464816141987.jpg", + "UUID": 14057995666735149327, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/10381718147657362067.jpg", + "UUID": 14073583180272832789, + "AssetType": 1, "Name": "FinalPass", "UUID": 14113443814160806123, "AssetType": 6, @@ -452,6 +614,12 @@ "Name": "//Assets/Scenes/Cache/CapsuleTest.png", "UUID": 14269581500391755498, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/3628158980083700836.jpg", + "UUID": 14334753069666248614, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/17556969131407844942.jpg", + "UUID": 14341758253079944201, + "AssetType": 1, "Name": "//Assets/Scenes/Cache/2D.png", "UUID": 14433233690600321844, "AssetType": 1, @@ -482,9 +650,21 @@ "Name": "//Assets/Meshes/greenhouse/IvyTall2_GH4.png", "UUID": 14927263090769801705, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/755318871556304029.jpg", + "UUID": 14951603529344960874, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/14267839433702832875.jpg", + "UUID": 14968883023977719254, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/4910669866631290573.jpg", + "UUID": 15294549561331977269, + "AssetType": 1, "Name": "//Assets/Cache/Meshes/greenhouse/Adv4Greenhouse.obj_thumbnail.png", "UUID": 15316715895923119879, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/14170708867020035030.jpg", + "UUID": 15334241507007352352, + "AssetType": 1, "Name": "ToneMapping", "UUID": 15576366496581061081, "AssetType": 6, @@ -506,12 +686,18 @@ "Name": "//Assets/Meshes/greenhouse/StrGrate_GH4.png", "UUID": 16003769903633202712, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/4477655471536070370.jpg", + "UUID": 16012405407936891595, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/LowerTwistArch_GH4.png", "UUID": 16044667088453235702, "AssetType": 1, "Name": "ShadowAnim", "UUID": 16067132574532594367, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/17876391417123941155.jpg", + "UUID": 16097551380465138131, + "AssetType": 1, "Name": "//Assets/Cache/Meshes/Fox.glb_thumbnail.png", "UUID": 16179565767608334086, "AssetType": 1, @@ -527,12 +713,27 @@ "Name": "//Assets/Cache/Meshes/pyramid.obj_thumbnail.png", "UUID": 16554280716107352421, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/4601176305987539675.jpg", + "UUID": 16670775855148515879, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/3827035219084910048.jpg", + "UUID": 16767180019371278740, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/13824894030729245199.jpg", + "UUID": 16785658059555628681, + "AssetType": 1, "Name": "//Assets/Textures/backgroundColorGrass.png", "UUID": 16838368057738779843, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/2775690330959970771.jpg", + "UUID": 16858304654623083456, + "AssetType": 1, "Name": "//Assets/Meshes/lowpoly_bonfire/textures/lambert1.002_normal.png", "UUID": 16935851122039710704, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/8783994986360286082.jpg", + "UUID": 16979890630243606762, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skPlantsCactus1Tex0.png", "UUID": 17032178551709164156, "AssetType": 1, @@ -548,6 +749,9 @@ "Name": "Grid", "UUID": 17174639512606516617, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/4675343432951571524.jpg", + "UUID": 17175991898379740832, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skMapleTreeFullTex1.png", "UUID": 17187225970241321334, "AssetType": 1, @@ -575,12 +779,21 @@ "Name": "//Assets/Meshes/greenhouse/Sky_DN.png", "UUID": 17783438993853067061, "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/5792855332885324923.jpg", + "UUID": 17904024027961317902, + "AssetType": 1, "Name": "//Assets/Meshes/greenhouse/skPlantsHangingPlant1Tex0.png", "UUID": 18048577803622114842, "AssetType": 1, "Name": "ShadowAlpha", "UUID": 18088774006192505129, "AssetType": 6, + "Name": "//Assets/Meshes/Sponza/3455394979645218238.jpg", + "UUID": 18224986816777564923, + "AssetType": 1, + "Name": "//Assets/Meshes/Sponza/7056944414013900257.jpg", + "UUID": 18261938858643575233, + "AssetType": 1, "Name": "//Assets/Meshes/capsule.glb", "UUID": 18324794523591720199, "AssetType": 9 diff --git a/ExampleProject/Assets/Scripts/Script(1).lua b/ExampleProject/Assets/Scripts/Script(1).lua index 16cb6ff9..fab7a560 100755 --- a/ExampleProject/Assets/Scripts/Script(1).lua +++ b/ExampleProject/Assets/Scripts/Script(1).lua @@ -53,8 +53,10 @@ function OnInit() entity = LuaComponent:GetCurrentEntity() phys = entity:GetRigidBody3DComponent() -children = entity:GetChildren() -cameraEntity = children[1] +--children = entity:GetChildren() +--cameraEntity = children[1] + +cameraEntity = GetEntityByName(scene, "Camera") jumpTimer = 1 end @@ -63,9 +65,6 @@ function OnUpdate(dt) phys = entity:GetRigidBody3DComponent() -children = entity:GetChildren() -cameraEntity = children[1] - movementX = 0.0 movementY = 0.0 @@ -104,3 +103,5 @@ end function OnCleanUp() end + + diff --git a/ExampleProject/Example.lmproj b/ExampleProject/Example.lmproj index d2590928..edc49665 100644 --- a/ExampleProject/Example.lmproj +++ b/ExampleProject/Example.lmproj @@ -20,7 +20,7 @@ "//Assets/Scenes/MeshCollisionTest", "//Assets/Scenes/CollisionPyramidTest" ], - "SceneIndex": 0, + "SceneIndex": 1, "Borderless": false, "EngineAssetPath": "/Users/jmorton/Dev/Lumos/Lumos/Assets/", "GPUIndex": -1 diff --git a/Lumos/Assets/Shaders/CompiledSPV/Batch2D.frag.spv b/Lumos/Assets/Shaders/CompiledSPV/Batch2D.frag.spv index 06d9804d..e4c0778e 100644 Binary files a/Lumos/Assets/Shaders/CompiledSPV/Batch2D.frag.spv and b/Lumos/Assets/Shaders/CompiledSPV/Batch2D.frag.spv differ diff --git a/Lumos/Assets/Shaders/CompiledSPV/Batch2D.vert.spv b/Lumos/Assets/Shaders/CompiledSPV/Batch2D.vert.spv index fa66a137..6c0e4571 100644 Binary files a/Lumos/Assets/Shaders/CompiledSPV/Batch2D.vert.spv and b/Lumos/Assets/Shaders/CompiledSPV/Batch2D.vert.spv differ diff --git a/Lumos/Assets/Shaders/CompiledSPV/DepthPrePass.frag.spv b/Lumos/Assets/Shaders/CompiledSPV/DepthPrePass.frag.spv index f56f996c..0a2e7af8 100644 Binary files a/Lumos/Assets/Shaders/CompiledSPV/DepthPrePass.frag.spv and b/Lumos/Assets/Shaders/CompiledSPV/DepthPrePass.frag.spv differ diff --git a/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dfragspv.hpp b/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dfragspv.hpp index def608b6..3294745b 100644 --- a/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dfragspv.hpp +++ b/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dfragspv.hpp @@ -5,7 +5,7 @@ constexpr uint32_t spirv_Batch2Dfragspv_size = 5584; constexpr std::array spirv_Batch2Dfragspv = { - 0x07230203, 0x00010000, 0x000D000A, 0x00000101, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, + 0x07230203, 0x00010000, 0x000D000B, 0x00000101, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001, 0x0007000F, 0x00000004, 0x00000004, 0x6E69616D, 0x00000000, 0x00000022, 0x000000FF, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x000001C2, 0x00090004, 0x415F4C47, 0x735F4252, diff --git a/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dvertspv.hpp b/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dvertspv.hpp index e52243fc..dfbb1233 100644 --- a/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dvertspv.hpp +++ b/Lumos/Assets/Shaders/CompiledSPV/Headers/Batch2Dvertspv.hpp @@ -5,7 +5,7 @@ constexpr uint32_t spirv_Batch2Dvertspv_size = 2012; constexpr std::array spirv_Batch2Dvertspv = { - 0x07230203, 0x00010000, 0x000D000A, 0x0000003E, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, + 0x07230203, 0x00010000, 0x000D000B, 0x0000003E, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001, 0x000B000F, 0x00000000, 0x00000004, 0x6E69616D, 0x00000000, 0x0000000D, 0x00000019, 0x00000026, 0x0000002C, 0x00000033, 0x0000003B, 0x00030003, 0x00000002, 0x000001C2, 0x00090004, 0x415F4C47, diff --git a/Lumos/Assets/Shaders/CompiledSPV/Headers/DepthPrePassfragspv.hpp b/Lumos/Assets/Shaders/CompiledSPV/Headers/DepthPrePassfragspv.hpp index 43256ffe..57d26780 100644 --- a/Lumos/Assets/Shaders/CompiledSPV/Headers/DepthPrePassfragspv.hpp +++ b/Lumos/Assets/Shaders/CompiledSPV/Headers/DepthPrePassfragspv.hpp @@ -3,9 +3,9 @@ #include #include -constexpr uint32_t spirv_DepthPrePassfragspv_size = 1012; -constexpr std::array spirv_DepthPrePassfragspv = { - 0x07230203, 0x00010000, 0x000D000A, 0x0000001F, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, +constexpr uint32_t spirv_DepthPrePassfragspv_size = 4224; +constexpr std::array spirv_DepthPrePassfragspv = { + 0x07230203, 0x00010000, 0x000D000B, 0x00000039, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001, 0x0007000F, 0x00000004, 0x00000004, 0x6E69616D, 0x00000000, 0x00000009, 0x0000000F, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x000001C2, 0x00090004, 0x415F4C47, 0x735F4252, @@ -19,22 +19,123 @@ constexpr std::array spirv_DepthPrePassfragspv = { 0x64726F6F, 0x00000000, 0x00060006, 0x0000000D, 0x00000002, 0x69736F50, 0x6E6F6974, 0x00000000, 0x00050006, 0x0000000D, 0x00000003, 0x6D726F4E, 0x00006C61, 0x00060006, 0x0000000D, 0x00000004, 0x6C726F57, 0x726F4E64, 0x006C616D, 0x00060005, 0x0000000F, 0x74726556, 0x754F7865, 0x74757074, -0x00000000, 0x00040047, 0x00000009, 0x0000001E, 0x00000000, 0x00040047, 0x0000000F, 0x0000001E, -0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, -0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040020, 0x00000008, 0x00000003, -0x00000007, 0x0004003B, 0x00000008, 0x00000009, 0x00000003, 0x00040017, 0x0000000A, 0x00000006, -0x00000003, 0x00040017, 0x0000000B, 0x00000006, 0x00000002, 0x00040018, 0x0000000C, 0x0000000A, -0x00000003, 0x0007001E, 0x0000000D, 0x0000000A, 0x0000000B, 0x00000007, 0x0000000A, 0x0000000C, -0x00040020, 0x0000000E, 0x00000001, 0x0000000D, 0x0004003B, 0x0000000E, 0x0000000F, 0x00000001, -0x00040015, 0x00000010, 0x00000020, 0x00000001, 0x0004002B, 0x00000010, 0x00000011, 0x00000003, -0x00040020, 0x00000012, 0x00000001, 0x0000000A, 0x0004002B, 0x00000006, 0x00000015, 0x3F000000, -0x0004002B, 0x00000006, 0x0000001A, 0x3F800000, 0x00050036, 0x00000002, 0x00000004, 0x00000000, -0x00000003, 0x000200F8, 0x00000005, 0x00050041, 0x00000012, 0x00000013, 0x0000000F, 0x00000011, -0x0004003D, 0x0000000A, 0x00000014, 0x00000013, 0x0005008E, 0x0000000A, 0x00000016, 0x00000014, -0x00000015, 0x00060050, 0x0000000A, 0x00000017, 0x00000015, 0x00000015, 0x00000015, 0x00050081, -0x0000000A, 0x00000018, 0x00000016, 0x00000017, 0x0006000C, 0x0000000A, 0x00000019, 0x00000001, -0x00000045, 0x00000018, 0x00050051, 0x00000006, 0x0000001B, 0x00000019, 0x00000000, 0x00050051, -0x00000006, 0x0000001C, 0x00000019, 0x00000001, 0x00050051, 0x00000006, 0x0000001D, 0x00000019, -0x00000002, 0x00070050, 0x00000007, 0x0000001E, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001A, -0x0003003E, 0x00000009, 0x0000001E, 0x000100FD, 0x00010038, +0x00000000, 0x00030005, 0x00000020, 0x004F4255, 0x00060006, 0x00000020, 0x00000000, 0x6A6F7270, +0x77656956, 0x00000000, 0x00060005, 0x00000022, 0x61435F75, 0x6172656D, 0x61746144, 0x00000000, +0x00050005, 0x00000026, 0x64616853, 0x6144776F, 0x00006174, 0x00080006, 0x00000026, 0x00000000, +0x4C726944, 0x74686769, 0x7274614D, 0x73656369, 0x00000000, 0x00050005, 0x00000028, 0x69445F75, +0x61685372, 0x00776F64, 0x00070005, 0x00000029, 0x66696E55, 0x4D6D726F, 0x72657461, 0x446C6169, +0x00617461, 0x00070006, 0x00000029, 0x00000000, 0x65626C41, 0x6F436F64, 0x72756F6C, 0x00000000, +0x00060006, 0x00000029, 0x00000001, 0x67756F52, 0x73656E68, 0x00000073, 0x00060006, 0x00000029, +0x00000002, 0x6174654D, 0x63696C6C, 0x00000000, 0x00060006, 0x00000029, 0x00000003, 0x6C666552, +0x61746365, 0x0065636E, 0x00060006, 0x00000029, 0x00000004, 0x73696D45, 0x65766973, 0x00000000, +0x00070006, 0x00000029, 0x00000005, 0x65626C41, 0x614D6F64, 0x63614670, 0x00726F74, 0x00080006, +0x00000029, 0x00000006, 0x6174654D, 0x63696C6C, 0x4670614D, 0x6F746361, 0x00000072, 0x00080006, +0x00000029, 0x00000007, 0x67756F52, 0x73656E68, 0x70614D73, 0x74636146, 0x0000726F, 0x00070006, +0x00000029, 0x00000008, 0x6D726F4E, 0x614D6C61, 0x63614670, 0x00726F74, 0x00080006, 0x00000029, +0x00000009, 0x73696D45, 0x65766973, 0x4670614D, 0x6F746361, 0x00000072, 0x00060006, 0x00000029, +0x0000000A, 0x614D4F41, 0x63614670, 0x00726F74, 0x00060006, 0x00000029, 0x0000000B, 0x68706C41, +0x74754361, 0x0066664F, 0x00060006, 0x00000029, 0x0000000C, 0x6B726F77, 0x776F6C66, 0x00000000, +0x00060005, 0x0000002B, 0x614D5F75, 0x69726574, 0x61446C61, 0x00006174, 0x00040005, 0x0000002C, +0x6867694C, 0x00000074, 0x00050006, 0x0000002C, 0x00000000, 0x6F6C6F63, 0x00007275, 0x00060006, +0x0000002C, 0x00000001, 0x69736F70, 0x6E6F6974, 0x00000000, 0x00060006, 0x0000002C, 0x00000002, +0x65726964, 0x6F697463, 0x0000006E, 0x00060006, 0x0000002C, 0x00000003, 0x65746E69, 0x7469736E, +0x00000079, 0x00050006, 0x0000002C, 0x00000004, 0x69646172, 0x00007375, 0x00050006, 0x0000002C, +0x00000005, 0x65707974, 0x00000000, 0x00050006, 0x0000002C, 0x00000006, 0x6C676E61, 0x00000065, +0x00070005, 0x00000031, 0x66696E55, 0x536D726F, 0x656E6563, 0x61746144, 0x00000000, 0x00050006, +0x00000031, 0x00000000, 0x6867696C, 0x00007374, 0x00070006, 0x00000031, 0x00000001, 0x64616853, +0x7254776F, 0x66736E61, 0x006D726F, 0x00060006, 0x00000031, 0x00000002, 0x77656956, 0x7274614D, +0x00007869, 0x00060006, 0x00000031, 0x00000003, 0x6867694C, 0x65695674, 0x00000077, 0x00060006, +0x00000031, 0x00000004, 0x73616942, 0x7274614D, 0x00007869, 0x00070006, 0x00000031, 0x00000005, +0x656D6163, 0x6F506172, 0x69746973, 0x00006E6F, 0x00060006, 0x00000031, 0x00000006, 0x696C7053, +0x70654474, 0x00736874, 0x00060006, 0x00000031, 0x00000007, 0x6867694C, 0x7A695374, 0x00000065, +0x00070006, 0x00000031, 0x00000008, 0x5378614D, 0x6F646168, 0x73694477, 0x00000074, 0x00060006, +0x00000031, 0x00000009, 0x64616853, 0x6146776F, 0x00006564, 0x00060006, 0x00000031, 0x0000000A, +0x63736143, 0x46656461, 0x00656461, 0x00060006, 0x00000031, 0x0000000B, 0x6867694C, 0x756F4374, +0x0000746E, 0x00060006, 0x00000031, 0x0000000C, 0x64616853, 0x6F43776F, 0x00746E75, 0x00050006, +0x00000031, 0x0000000D, 0x65646F4D, 0x00000000, 0x00060006, 0x00000031, 0x0000000E, 0x4D766E45, +0x6F437069, 0x00746E75, 0x00060006, 0x00000031, 0x0000000F, 0x74696E49, 0x426C6169, 0x00736169, +0x00050006, 0x00000031, 0x00000010, 0x74646957, 0x00000068, 0x00050006, 0x00000031, 0x00000011, +0x67696548, 0x00007468, 0x00070006, 0x00000031, 0x00000012, 0x64616873, 0x6E45776F, 0x656C6261, +0x00000064, 0x00050005, 0x00000033, 0x63535F75, 0x44656E65, 0x00617461, 0x00060005, 0x00000036, +0x656E6F42, 0x6E617254, 0x726F6673, 0x0000736D, 0x00070006, 0x00000036, 0x00000000, 0x656E6F42, +0x6E617254, 0x726F6673, 0x0000736D, 0x00070005, 0x00000038, 0x6F425F75, 0x7254656E, 0x66736E61, +0x736D726F, 0x00000000, 0x00040047, 0x00000009, 0x0000001E, 0x00000000, 0x00040047, 0x0000000F, +0x0000001E, 0x00000000, 0x00040048, 0x00000020, 0x00000000, 0x00000005, 0x00050048, 0x00000020, +0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000020, 0x00000000, 0x00000007, 0x00000010, +0x00030047, 0x00000020, 0x00000002, 0x00040047, 0x00000022, 0x00000022, 0x00000000, 0x00040047, +0x00000022, 0x00000021, 0x00000000, 0x00040047, 0x00000025, 0x00000006, 0x00000040, 0x00040048, +0x00000026, 0x00000000, 0x00000005, 0x00050048, 0x00000026, 0x00000000, 0x00000023, 0x00000000, +0x00050048, 0x00000026, 0x00000000, 0x00000007, 0x00000010, 0x00030047, 0x00000026, 0x00000002, +0x00040047, 0x00000028, 0x00000022, 0x00000000, 0x00040047, 0x00000028, 0x00000021, 0x00000001, +0x00050048, 0x00000029, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000029, 0x00000001, +0x00000023, 0x00000010, 0x00050048, 0x00000029, 0x00000002, 0x00000023, 0x00000014, 0x00050048, +0x00000029, 0x00000003, 0x00000023, 0x00000018, 0x00050048, 0x00000029, 0x00000004, 0x00000023, +0x0000001C, 0x00050048, 0x00000029, 0x00000005, 0x00000023, 0x00000020, 0x00050048, 0x00000029, +0x00000006, 0x00000023, 0x00000024, 0x00050048, 0x00000029, 0x00000007, 0x00000023, 0x00000028, +0x00050048, 0x00000029, 0x00000008, 0x00000023, 0x0000002C, 0x00050048, 0x00000029, 0x00000009, +0x00000023, 0x00000030, 0x00050048, 0x00000029, 0x0000000A, 0x00000023, 0x00000034, 0x00050048, +0x00000029, 0x0000000B, 0x00000023, 0x00000038, 0x00050048, 0x00000029, 0x0000000C, 0x00000023, +0x0000003C, 0x00030047, 0x00000029, 0x00000002, 0x00040047, 0x0000002B, 0x00000022, 0x00000001, +0x00040047, 0x0000002B, 0x00000021, 0x00000006, 0x00050048, 0x0000002C, 0x00000000, 0x00000023, +0x00000000, 0x00050048, 0x0000002C, 0x00000001, 0x00000023, 0x00000010, 0x00050048, 0x0000002C, +0x00000002, 0x00000023, 0x00000020, 0x00050048, 0x0000002C, 0x00000003, 0x00000023, 0x00000030, +0x00050048, 0x0000002C, 0x00000004, 0x00000023, 0x00000034, 0x00050048, 0x0000002C, 0x00000005, +0x00000023, 0x00000038, 0x00050048, 0x0000002C, 0x00000006, 0x00000023, 0x0000003C, 0x00040047, +0x0000002E, 0x00000006, 0x00000040, 0x00040047, 0x0000002F, 0x00000006, 0x00000040, 0x00040047, +0x00000030, 0x00000006, 0x00000010, 0x00050048, 0x00000031, 0x00000000, 0x00000023, 0x00000000, +0x00040048, 0x00000031, 0x00000001, 0x00000005, 0x00050048, 0x00000031, 0x00000001, 0x00000023, +0x00000800, 0x00050048, 0x00000031, 0x00000001, 0x00000007, 0x00000010, 0x00040048, 0x00000031, +0x00000002, 0x00000005, 0x00050048, 0x00000031, 0x00000002, 0x00000023, 0x00000900, 0x00050048, +0x00000031, 0x00000002, 0x00000007, 0x00000010, 0x00040048, 0x00000031, 0x00000003, 0x00000005, +0x00050048, 0x00000031, 0x00000003, 0x00000023, 0x00000940, 0x00050048, 0x00000031, 0x00000003, +0x00000007, 0x00000010, 0x00040048, 0x00000031, 0x00000004, 0x00000005, 0x00050048, 0x00000031, +0x00000004, 0x00000023, 0x00000980, 0x00050048, 0x00000031, 0x00000004, 0x00000007, 0x00000010, +0x00050048, 0x00000031, 0x00000005, 0x00000023, 0x000009C0, 0x00050048, 0x00000031, 0x00000006, +0x00000023, 0x000009D0, 0x00050048, 0x00000031, 0x00000007, 0x00000023, 0x00000A10, 0x00050048, +0x00000031, 0x00000008, 0x00000023, 0x00000A14, 0x00050048, 0x00000031, 0x00000009, 0x00000023, +0x00000A18, 0x00050048, 0x00000031, 0x0000000A, 0x00000023, 0x00000A1C, 0x00050048, 0x00000031, +0x0000000B, 0x00000023, 0x00000A20, 0x00050048, 0x00000031, 0x0000000C, 0x00000023, 0x00000A24, +0x00050048, 0x00000031, 0x0000000D, 0x00000023, 0x00000A28, 0x00050048, 0x00000031, 0x0000000E, +0x00000023, 0x00000A2C, 0x00050048, 0x00000031, 0x0000000F, 0x00000023, 0x00000A30, 0x00050048, +0x00000031, 0x00000010, 0x00000023, 0x00000A34, 0x00050048, 0x00000031, 0x00000011, 0x00000023, +0x00000A38, 0x00050048, 0x00000031, 0x00000012, 0x00000023, 0x00000A3C, 0x00030047, 0x00000031, +0x00000002, 0x00040047, 0x00000033, 0x00000022, 0x00000002, 0x00040047, 0x00000033, 0x00000021, +0x00000005, 0x00040047, 0x00000035, 0x00000006, 0x00000040, 0x00040048, 0x00000036, 0x00000000, +0x00000005, 0x00050048, 0x00000036, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000036, +0x00000000, 0x00000007, 0x00000010, 0x00030047, 0x00000036, 0x00000002, 0x00040047, 0x00000038, +0x00000022, 0x00000003, 0x00040047, 0x00000038, 0x00000021, 0x00000000, 0x00020013, 0x00000002, +0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, +0x00000006, 0x00000004, 0x00040020, 0x00000008, 0x00000003, 0x00000007, 0x0004003B, 0x00000008, +0x00000009, 0x00000003, 0x00040017, 0x0000000A, 0x00000006, 0x00000003, 0x00040017, 0x0000000B, +0x00000006, 0x00000002, 0x00040018, 0x0000000C, 0x0000000A, 0x00000003, 0x0007001E, 0x0000000D, +0x0000000A, 0x0000000B, 0x00000007, 0x0000000A, 0x0000000C, 0x00040020, 0x0000000E, 0x00000001, +0x0000000D, 0x0004003B, 0x0000000E, 0x0000000F, 0x00000001, 0x00040015, 0x00000010, 0x00000020, +0x00000001, 0x0004002B, 0x00000010, 0x00000011, 0x00000003, 0x00040020, 0x00000012, 0x00000001, +0x0000000A, 0x0004002B, 0x00000006, 0x00000015, 0x3F000000, 0x0004002B, 0x00000006, 0x0000001A, +0x3F800000, 0x00040018, 0x0000001F, 0x00000007, 0x00000004, 0x0003001E, 0x00000020, 0x0000001F, +0x00040020, 0x00000021, 0x00000002, 0x00000020, 0x0004003B, 0x00000021, 0x00000022, 0x00000002, +0x00040015, 0x00000023, 0x00000020, 0x00000000, 0x0004002B, 0x00000023, 0x00000024, 0x00000004, +0x0004001C, 0x00000025, 0x0000001F, 0x00000024, 0x0003001E, 0x00000026, 0x00000025, 0x00040020, +0x00000027, 0x00000002, 0x00000026, 0x0004003B, 0x00000027, 0x00000028, 0x00000002, 0x000F001E, +0x00000029, 0x00000007, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, +0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00040020, 0x0000002A, +0x00000002, 0x00000029, 0x0004003B, 0x0000002A, 0x0000002B, 0x00000002, 0x0009001E, 0x0000002C, +0x00000007, 0x00000007, 0x00000007, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x0004002B, +0x00000023, 0x0000002D, 0x00000020, 0x0004001C, 0x0000002E, 0x0000002C, 0x0000002D, 0x0004001C, +0x0000002F, 0x0000001F, 0x00000024, 0x0004001C, 0x00000030, 0x00000007, 0x00000024, 0x0015001E, +0x00000031, 0x0000002E, 0x0000002F, 0x0000001F, 0x0000001F, 0x0000001F, 0x00000007, 0x00000030, +0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000010, 0x00000010, 0x00000010, 0x00000010, +0x00000006, 0x00000006, 0x00000006, 0x00000010, 0x00040020, 0x00000032, 0x00000002, 0x00000031, +0x0004003B, 0x00000032, 0x00000033, 0x00000002, 0x0004002B, 0x00000023, 0x00000034, 0x00000064, +0x0004001C, 0x00000035, 0x0000001F, 0x00000034, 0x0003001E, 0x00000036, 0x00000035, 0x00040020, +0x00000037, 0x00000002, 0x00000036, 0x0004003B, 0x00000037, 0x00000038, 0x00000002, 0x00050036, +0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200F8, 0x00000005, 0x00050041, 0x00000012, +0x00000013, 0x0000000F, 0x00000011, 0x0004003D, 0x0000000A, 0x00000014, 0x00000013, 0x0005008E, +0x0000000A, 0x00000016, 0x00000014, 0x00000015, 0x00060050, 0x0000000A, 0x00000017, 0x00000015, +0x00000015, 0x00000015, 0x00050081, 0x0000000A, 0x00000018, 0x00000016, 0x00000017, 0x0006000C, +0x0000000A, 0x00000019, 0x00000001, 0x00000045, 0x00000018, 0x00050051, 0x00000006, 0x0000001B, +0x00000019, 0x00000000, 0x00050051, 0x00000006, 0x0000001C, 0x00000019, 0x00000001, 0x00050051, +0x00000006, 0x0000001D, 0x00000019, 0x00000002, 0x00070050, 0x00000007, 0x0000001E, 0x0000001B, +0x0000001C, 0x0000001D, 0x0000001A, 0x0003003E, 0x00000009, 0x0000001E, 0x000100FD, 0x00010038, + }; \ No newline at end of file diff --git a/Lumos/Assets/Shaders/CompiledSPV/Headers/Shadowfragspv.hpp b/Lumos/Assets/Shaders/CompiledSPV/Headers/Shadowfragspv.hpp index e3755bee..9e3b773b 100644 --- a/Lumos/Assets/Shaders/CompiledSPV/Headers/Shadowfragspv.hpp +++ b/Lumos/Assets/Shaders/CompiledSPV/Headers/Shadowfragspv.hpp @@ -3,20 +3,121 @@ #include #include -constexpr uint32_t spirv_Shadowfragspv_size = 416; -constexpr std::array spirv_Shadowfragspv = { - 0x07230203, 0x00010000, 0x000D000A, 0x0000000A, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, +constexpr uint32_t spirv_Shadowfragspv_size = 3660; +constexpr std::array spirv_Shadowfragspv = { + 0x07230203, 0x00010000, 0x000D000B, 0x00000026, 0x00000000, 0x00020011, 0x00000001, 0x0006000B, 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001, -0x0006000F, 0x00000004, 0x00000004, 0x6E69616D, 0x00000000, 0x00000009, 0x00030010, 0x00000004, +0x0006000F, 0x00000004, 0x00000004, 0x6E69616D, 0x00000000, 0x00000025, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x000001C2, 0x00090004, 0x415F4C47, 0x735F4252, 0x72617065, 0x5F657461, 0x64616873, 0x6F5F7265, 0x63656A62, 0x00007374, 0x00090004, 0x415F4C47, 0x735F4252, 0x69646168, 0x6C5F676E, 0x75676E61, 0x5F656761, 0x70303234, 0x006B6361, 0x000A0004, 0x475F4C47, 0x4C474F4F, 0x70635F45, 0x74735F70, 0x5F656C79, 0x656E696C, 0x7269645F, 0x69746365, 0x00006576, 0x00080004, 0x475F4C47, 0x4C474F4F, 0x6E695F45, 0x64756C63, 0x69645F65, 0x74636572, 0x00657669, -0x00040005, 0x00000004, 0x6E69616D, 0x00000000, 0x00030005, 0x00000009, 0x00007675, 0x00040047, -0x00000009, 0x0000001E, 0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, -0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000002, 0x00040020, -0x00000008, 0x00000001, 0x00000007, 0x0004003B, 0x00000008, 0x00000009, 0x00000001, 0x00050036, -0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200F8, 0x00000005, 0x000100FD, 0x00010038, - +0x00040005, 0x00000004, 0x6E69616D, 0x00000000, 0x00030005, 0x00000009, 0x004F4255, 0x00060006, +0x00000009, 0x00000000, 0x6A6F7270, 0x77656956, 0x00000000, 0x00060005, 0x0000000B, 0x61435F75, +0x6172656D, 0x61746144, 0x00000000, 0x00050005, 0x0000000F, 0x64616853, 0x6144776F, 0x00006174, +0x00080006, 0x0000000F, 0x00000000, 0x4C726944, 0x74686769, 0x7274614D, 0x73656369, 0x00000000, +0x00050005, 0x00000011, 0x69445F75, 0x61685372, 0x00776F64, 0x00070005, 0x00000012, 0x66696E55, +0x4D6D726F, 0x72657461, 0x446C6169, 0x00617461, 0x00070006, 0x00000012, 0x00000000, 0x65626C41, +0x6F436F64, 0x72756F6C, 0x00000000, 0x00060006, 0x00000012, 0x00000001, 0x67756F52, 0x73656E68, +0x00000073, 0x00060006, 0x00000012, 0x00000002, 0x6174654D, 0x63696C6C, 0x00000000, 0x00060006, +0x00000012, 0x00000003, 0x6C666552, 0x61746365, 0x0065636E, 0x00060006, 0x00000012, 0x00000004, +0x73696D45, 0x65766973, 0x00000000, 0x00070006, 0x00000012, 0x00000005, 0x65626C41, 0x614D6F64, +0x63614670, 0x00726F74, 0x00080006, 0x00000012, 0x00000006, 0x6174654D, 0x63696C6C, 0x4670614D, +0x6F746361, 0x00000072, 0x00080006, 0x00000012, 0x00000007, 0x67756F52, 0x73656E68, 0x70614D73, +0x74636146, 0x0000726F, 0x00070006, 0x00000012, 0x00000008, 0x6D726F4E, 0x614D6C61, 0x63614670, +0x00726F74, 0x00080006, 0x00000012, 0x00000009, 0x73696D45, 0x65766973, 0x4670614D, 0x6F746361, +0x00000072, 0x00060006, 0x00000012, 0x0000000A, 0x614D4F41, 0x63614670, 0x00726F74, 0x00060006, +0x00000012, 0x0000000B, 0x68706C41, 0x74754361, 0x0066664F, 0x00060006, 0x00000012, 0x0000000C, +0x6B726F77, 0x776F6C66, 0x00000000, 0x00060005, 0x00000014, 0x614D5F75, 0x69726574, 0x61446C61, +0x00006174, 0x00040005, 0x00000015, 0x6867694C, 0x00000074, 0x00050006, 0x00000015, 0x00000000, +0x6F6C6F63, 0x00007275, 0x00060006, 0x00000015, 0x00000001, 0x69736F70, 0x6E6F6974, 0x00000000, +0x00060006, 0x00000015, 0x00000002, 0x65726964, 0x6F697463, 0x0000006E, 0x00060006, 0x00000015, +0x00000003, 0x65746E69, 0x7469736E, 0x00000079, 0x00050006, 0x00000015, 0x00000004, 0x69646172, +0x00007375, 0x00050006, 0x00000015, 0x00000005, 0x65707974, 0x00000000, 0x00050006, 0x00000015, +0x00000006, 0x6C676E61, 0x00000065, 0x00070005, 0x0000001B, 0x66696E55, 0x536D726F, 0x656E6563, +0x61746144, 0x00000000, 0x00050006, 0x0000001B, 0x00000000, 0x6867696C, 0x00007374, 0x00070006, +0x0000001B, 0x00000001, 0x64616853, 0x7254776F, 0x66736E61, 0x006D726F, 0x00060006, 0x0000001B, +0x00000002, 0x77656956, 0x7274614D, 0x00007869, 0x00060006, 0x0000001B, 0x00000003, 0x6867694C, +0x65695674, 0x00000077, 0x00060006, 0x0000001B, 0x00000004, 0x73616942, 0x7274614D, 0x00007869, +0x00070006, 0x0000001B, 0x00000005, 0x656D6163, 0x6F506172, 0x69746973, 0x00006E6F, 0x00060006, +0x0000001B, 0x00000006, 0x696C7053, 0x70654474, 0x00736874, 0x00060006, 0x0000001B, 0x00000007, +0x6867694C, 0x7A695374, 0x00000065, 0x00070006, 0x0000001B, 0x00000008, 0x5378614D, 0x6F646168, +0x73694477, 0x00000074, 0x00060006, 0x0000001B, 0x00000009, 0x64616853, 0x6146776F, 0x00006564, +0x00060006, 0x0000001B, 0x0000000A, 0x63736143, 0x46656461, 0x00656461, 0x00060006, 0x0000001B, +0x0000000B, 0x6867694C, 0x756F4374, 0x0000746E, 0x00060006, 0x0000001B, 0x0000000C, 0x64616853, +0x6F43776F, 0x00746E75, 0x00050006, 0x0000001B, 0x0000000D, 0x65646F4D, 0x00000000, 0x00060006, +0x0000001B, 0x0000000E, 0x4D766E45, 0x6F437069, 0x00746E75, 0x00060006, 0x0000001B, 0x0000000F, +0x74696E49, 0x426C6169, 0x00736169, 0x00050006, 0x0000001B, 0x00000010, 0x74646957, 0x00000068, +0x00050006, 0x0000001B, 0x00000011, 0x67696548, 0x00007468, 0x00070006, 0x0000001B, 0x00000012, +0x64616873, 0x6E45776F, 0x656C6261, 0x00000064, 0x00050005, 0x0000001D, 0x63535F75, 0x44656E65, +0x00617461, 0x00060005, 0x00000020, 0x656E6F42, 0x6E617254, 0x726F6673, 0x0000736D, 0x00070006, +0x00000020, 0x00000000, 0x656E6F42, 0x6E617254, 0x726F6673, 0x0000736D, 0x00070005, 0x00000022, +0x6F425F75, 0x7254656E, 0x66736E61, 0x736D726F, 0x00000000, 0x00030005, 0x00000025, 0x00007675, +0x00040048, 0x00000009, 0x00000000, 0x00000005, 0x00050048, 0x00000009, 0x00000000, 0x00000023, +0x00000000, 0x00050048, 0x00000009, 0x00000000, 0x00000007, 0x00000010, 0x00030047, 0x00000009, +0x00000002, 0x00040047, 0x0000000B, 0x00000022, 0x00000000, 0x00040047, 0x0000000B, 0x00000021, +0x00000000, 0x00040047, 0x0000000E, 0x00000006, 0x00000040, 0x00040048, 0x0000000F, 0x00000000, +0x00000005, 0x00050048, 0x0000000F, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000000F, +0x00000000, 0x00000007, 0x00000010, 0x00030047, 0x0000000F, 0x00000002, 0x00040047, 0x00000011, +0x00000022, 0x00000000, 0x00040047, 0x00000011, 0x00000021, 0x00000001, 0x00050048, 0x00000012, +0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000012, 0x00000001, 0x00000023, 0x00000010, +0x00050048, 0x00000012, 0x00000002, 0x00000023, 0x00000014, 0x00050048, 0x00000012, 0x00000003, +0x00000023, 0x00000018, 0x00050048, 0x00000012, 0x00000004, 0x00000023, 0x0000001C, 0x00050048, +0x00000012, 0x00000005, 0x00000023, 0x00000020, 0x00050048, 0x00000012, 0x00000006, 0x00000023, +0x00000024, 0x00050048, 0x00000012, 0x00000007, 0x00000023, 0x00000028, 0x00050048, 0x00000012, +0x00000008, 0x00000023, 0x0000002C, 0x00050048, 0x00000012, 0x00000009, 0x00000023, 0x00000030, +0x00050048, 0x00000012, 0x0000000A, 0x00000023, 0x00000034, 0x00050048, 0x00000012, 0x0000000B, +0x00000023, 0x00000038, 0x00050048, 0x00000012, 0x0000000C, 0x00000023, 0x0000003C, 0x00030047, +0x00000012, 0x00000002, 0x00040047, 0x00000014, 0x00000022, 0x00000001, 0x00040047, 0x00000014, +0x00000021, 0x00000006, 0x00050048, 0x00000015, 0x00000000, 0x00000023, 0x00000000, 0x00050048, +0x00000015, 0x00000001, 0x00000023, 0x00000010, 0x00050048, 0x00000015, 0x00000002, 0x00000023, +0x00000020, 0x00050048, 0x00000015, 0x00000003, 0x00000023, 0x00000030, 0x00050048, 0x00000015, +0x00000004, 0x00000023, 0x00000034, 0x00050048, 0x00000015, 0x00000005, 0x00000023, 0x00000038, +0x00050048, 0x00000015, 0x00000006, 0x00000023, 0x0000003C, 0x00040047, 0x00000017, 0x00000006, +0x00000040, 0x00040047, 0x00000018, 0x00000006, 0x00000040, 0x00040047, 0x00000019, 0x00000006, +0x00000010, 0x00050048, 0x0000001B, 0x00000000, 0x00000023, 0x00000000, 0x00040048, 0x0000001B, +0x00000001, 0x00000005, 0x00050048, 0x0000001B, 0x00000001, 0x00000023, 0x00000800, 0x00050048, +0x0000001B, 0x00000001, 0x00000007, 0x00000010, 0x00040048, 0x0000001B, 0x00000002, 0x00000005, +0x00050048, 0x0000001B, 0x00000002, 0x00000023, 0x00000900, 0x00050048, 0x0000001B, 0x00000002, +0x00000007, 0x00000010, 0x00040048, 0x0000001B, 0x00000003, 0x00000005, 0x00050048, 0x0000001B, +0x00000003, 0x00000023, 0x00000940, 0x00050048, 0x0000001B, 0x00000003, 0x00000007, 0x00000010, +0x00040048, 0x0000001B, 0x00000004, 0x00000005, 0x00050048, 0x0000001B, 0x00000004, 0x00000023, +0x00000980, 0x00050048, 0x0000001B, 0x00000004, 0x00000007, 0x00000010, 0x00050048, 0x0000001B, +0x00000005, 0x00000023, 0x000009C0, 0x00050048, 0x0000001B, 0x00000006, 0x00000023, 0x000009D0, +0x00050048, 0x0000001B, 0x00000007, 0x00000023, 0x00000A10, 0x00050048, 0x0000001B, 0x00000008, +0x00000023, 0x00000A14, 0x00050048, 0x0000001B, 0x00000009, 0x00000023, 0x00000A18, 0x00050048, +0x0000001B, 0x0000000A, 0x00000023, 0x00000A1C, 0x00050048, 0x0000001B, 0x0000000B, 0x00000023, +0x00000A20, 0x00050048, 0x0000001B, 0x0000000C, 0x00000023, 0x00000A24, 0x00050048, 0x0000001B, +0x0000000D, 0x00000023, 0x00000A28, 0x00050048, 0x0000001B, 0x0000000E, 0x00000023, 0x00000A2C, +0x00050048, 0x0000001B, 0x0000000F, 0x00000023, 0x00000A30, 0x00050048, 0x0000001B, 0x00000010, +0x00000023, 0x00000A34, 0x00050048, 0x0000001B, 0x00000011, 0x00000023, 0x00000A38, 0x00050048, +0x0000001B, 0x00000012, 0x00000023, 0x00000A3C, 0x00030047, 0x0000001B, 0x00000002, 0x00040047, +0x0000001D, 0x00000022, 0x00000002, 0x00040047, 0x0000001D, 0x00000021, 0x00000005, 0x00040047, +0x0000001F, 0x00000006, 0x00000040, 0x00040048, 0x00000020, 0x00000000, 0x00000005, 0x00050048, +0x00000020, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000020, 0x00000000, 0x00000007, +0x00000010, 0x00030047, 0x00000020, 0x00000002, 0x00040047, 0x00000022, 0x00000022, 0x00000003, +0x00040047, 0x00000022, 0x00000021, 0x00000000, 0x00040047, 0x00000025, 0x0000001E, 0x00000000, +0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, +0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040018, 0x00000008, 0x00000007, 0x00000004, +0x0003001E, 0x00000009, 0x00000008, 0x00040020, 0x0000000A, 0x00000002, 0x00000009, 0x0004003B, +0x0000000A, 0x0000000B, 0x00000002, 0x00040015, 0x0000000C, 0x00000020, 0x00000000, 0x0004002B, +0x0000000C, 0x0000000D, 0x00000004, 0x0004001C, 0x0000000E, 0x00000008, 0x0000000D, 0x0003001E, +0x0000000F, 0x0000000E, 0x00040020, 0x00000010, 0x00000002, 0x0000000F, 0x0004003B, 0x00000010, +0x00000011, 0x00000002, 0x000F001E, 0x00000012, 0x00000007, 0x00000006, 0x00000006, 0x00000006, +0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, +0x00000006, 0x00040020, 0x00000013, 0x00000002, 0x00000012, 0x0004003B, 0x00000013, 0x00000014, +0x00000002, 0x0009001E, 0x00000015, 0x00000007, 0x00000007, 0x00000007, 0x00000006, 0x00000006, +0x00000006, 0x00000006, 0x0004002B, 0x0000000C, 0x00000016, 0x00000020, 0x0004001C, 0x00000017, +0x00000015, 0x00000016, 0x0004001C, 0x00000018, 0x00000008, 0x0000000D, 0x0004001C, 0x00000019, +0x00000007, 0x0000000D, 0x00040015, 0x0000001A, 0x00000020, 0x00000001, 0x0015001E, 0x0000001B, +0x00000017, 0x00000018, 0x00000008, 0x00000008, 0x00000008, 0x00000007, 0x00000019, 0x00000006, +0x00000006, 0x00000006, 0x00000006, 0x0000001A, 0x0000001A, 0x0000001A, 0x0000001A, 0x00000006, +0x00000006, 0x00000006, 0x0000001A, 0x00040020, 0x0000001C, 0x00000002, 0x0000001B, 0x0004003B, +0x0000001C, 0x0000001D, 0x00000002, 0x0004002B, 0x0000000C, 0x0000001E, 0x00000064, 0x0004001C, +0x0000001F, 0x00000008, 0x0000001E, 0x0003001E, 0x00000020, 0x0000001F, 0x00040020, 0x00000021, +0x00000002, 0x00000020, 0x0004003B, 0x00000021, 0x00000022, 0x00000002, 0x00040017, 0x00000023, +0x00000006, 0x00000002, 0x00040020, 0x00000024, 0x00000001, 0x00000023, 0x0004003B, 0x00000024, +0x00000025, 0x00000001, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200F8, +0x00000005, 0x000100FD, 0x00010038, }; \ No newline at end of file diff --git a/Lumos/Assets/Shaders/CompiledSPV/Headers/Textfragspv.hpp b/Lumos/Assets/Shaders/CompiledSPV/Headers/Textfragspv.hpp index fd9af5cc..dc0da804 100644 --- a/Lumos/Assets/Shaders/CompiledSPV/Headers/Textfragspv.hpp +++ b/Lumos/Assets/Shaders/CompiledSPV/Headers/Textfragspv.hpp @@ -5,7 +5,7 @@ constexpr uint32_t spirv_Textfragspv_size = 8708; constexpr std::array spirv_Textfragspv = { - 0x07230203, 0x00010000, 0x000D000A, 0x00000184, 0x00000000, 0x00020011, 0x00000001, 0x00020011, + 0x07230203, 0x00010000, 0x000D000B, 0x00000184, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x00000032, 0x0006000B, 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001, 0x0007000F, 0x00000004, 0x00000004, 0x6E69616D, 0x00000000, 0x0000003F, 0x00000182, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x000001C2, 0x00090004, diff --git a/Lumos/Assets/Shaders/CompiledSPV/Shadow.frag.spv b/Lumos/Assets/Shaders/CompiledSPV/Shadow.frag.spv index 13b8e837..42c2c3e4 100644 Binary files a/Lumos/Assets/Shaders/CompiledSPV/Shadow.frag.spv and b/Lumos/Assets/Shaders/CompiledSPV/Shadow.frag.spv differ diff --git a/Lumos/Assets/Shaders/CompiledSPV/Text.frag.spv b/Lumos/Assets/Shaders/CompiledSPV/Text.frag.spv index 972695cb..7eb239f6 100644 Binary files a/Lumos/Assets/Shaders/CompiledSPV/Text.frag.spv and b/Lumos/Assets/Shaders/CompiledSPV/Text.frag.spv differ diff --git a/Lumos/Assets/Shaders/DepthPrePass.frag b/Lumos/Assets/Shaders/DepthPrePass.frag index 47f206c9..0decaca7 100644 --- a/Lumos/Assets/Shaders/DepthPrePass.frag +++ b/Lumos/Assets/Shaders/DepthPrePass.frag @@ -1,6 +1,7 @@ #version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable +#include "Buffers.glslh" struct VertexData { @@ -17,4 +18,4 @@ layout(location = 0) out vec4 OutNormal; void main(void) { OutNormal = vec4(normalize(VertexOutput.Normal * 0.5 + 0.5), 1.0f); -} \ No newline at end of file +} diff --git a/Lumos/Assets/Shaders/Shadow.frag b/Lumos/Assets/Shaders/Shadow.frag index 27bd0c4e..cf77d107 100644 --- a/Lumos/Assets/Shaders/Shadow.frag +++ b/Lumos/Assets/Shaders/Shadow.frag @@ -1,6 +1,7 @@ #version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable +#include "Buffers.glslh" layout(location = 0) in vec2 uv; diff --git a/Lumos/Source/Lumos/AI/AStar.cpp b/Lumos/Source/Lumos/AI/AStar.cpp index 2d954c68..5a0a7571 100644 --- a/Lumos/Source/Lumos/AI/AStar.cpp +++ b/Lumos/Source/Lumos/AI/AStar.cpp @@ -10,7 +10,7 @@ namespace Lumos HashMapInit(&m_NodeData); // Create node data - for (auto it = nodes.begin(); it != nodes.end(); ++it) + for(auto it = nodes.begin(); it != nodes.end(); ++it) { QueueablePathNode* pathNode = new QueueablePathNode(*it); HashMapInsert(&m_NodeData, *it, pathNode); @@ -38,9 +38,9 @@ namespace Lumos ForHashMapEach(PathNode*, QueueablePathNode*, &m_NodeData, it) { QueueablePathNode* value = *it.value; - value->Parent = nullptr; - value->fScore = std::numeric_limits::max(); - value->gScore = std::numeric_limits::max(); + value->Parent = nullptr; + value->fScore = std::numeric_limits::max(); + value->gScore = std::numeric_limits::max(); } } @@ -50,7 +50,7 @@ namespace Lumos Reset(); QueueablePathNode* startNode = nullptr; - if (HashMapFind(&m_NodeData, start, &startNode)) + if(HashMapFind(&m_NodeData, start, &startNode)) { // Add start node to open list startNode->gScore = 0.0f; @@ -83,9 +83,9 @@ namespace Lumos if(!pq->Traversable()) continue; - QueueablePathNode* q = nullptr; + QueueablePathNode* q = nullptr; QueueablePathNode* otherNode = nullptr; - auto otherNodePtr = pq->OtherNode(p->node); + auto otherNodePtr = pq->OtherNode(p->node); HashMapFind(&m_NodeData, otherNodePtr, &q); // Calculate new scores diff --git a/Lumos/Source/Lumos/Core/Application.cpp b/Lumos/Source/Lumos/Core/Application.cpp index fed6ad22..99b3f867 100644 --- a/Lumos/Source/Lumos/Core/Application.cpp +++ b/Lumos/Source/Lumos/Core/Application.cpp @@ -58,7 +58,7 @@ namespace Lumos { Application* Application::s_Instance = nullptr; - + Application::Application() : m_Frames(0) , m_Updates(0) @@ -67,22 +67,22 @@ namespace Lumos { LUMOS_PROFILE_FUNCTION(); ASSERT(!s_Instance, "Application already exists!"); - + s_Instance = this; } - + Application::~Application() { LUMOS_PROFILE_FUNCTION(); ImGui::DestroyContext(); ImPlot::DestroyContext(); } - + static i32 EmbedShaderCount = 0; - void EmbedShaderFunc(const char* path) + void EmbedShaderFunc(const char* path) { auto extension = StringUtilities::GetFilePathExtension(path); - if (extension == "spv") + if(extension == "spv") { EmbedShader(path); EmbedShaderCount++; @@ -93,29 +93,29 @@ namespace Lumos LUMOS_PROFILE_FUNCTION(); m_FrameArena = ArenaAlloc(Megabytes(1)); m_Arena = ArenaAlloc(Kilobytes(64)); - + m_EventQueue.Reserve(16); - + SetMaxImageDimensions(2048, 2048); - + m_SceneManager = CreateUniquePtr(); m_AssetManager = CreateSharedPtr(); - + Deserialise(); - + CommandLine* cmdline = Internal::CoreSystem::GetCmdLine(); if(cmdline->OptionBool(Str8Lit("help"))) { LINFO("Print this help.\n Option 1 : EnableVulkanValidation"); } - + Engine::Get(); LuaManager::Get().OnInit(); LuaManager::Get().OnNewProject(m_ProjectSettings.m_ProjectRoot); m_Timer = CreateUniquePtr(); - + Graphics::GraphicsContext::SetRenderAPI(static_cast(m_ProjectSettings.RenderAPI)); - + WindowDesc windowDesc; windowDesc.Width = m_ProjectSettings.Width; windowDesc.Height = m_ProjectSettings.Height; @@ -125,44 +125,44 @@ namespace Lumos windowDesc.ShowConsole = m_ProjectSettings.ShowConsole; windowDesc.Title = Str8StdS(m_ProjectSettings.Title); windowDesc.VSync = m_ProjectSettings.VSync; - + if(m_ProjectSettings.DefaultIcon) { windowDesc.IconPaths = { Str8Lit("//Assets/Textures/icon.png"), Str8Lit("//Assets/Textures/icon32.png") }; } - + // Initialise the Window m_Window = UniquePtr(Window::Create(windowDesc)); if(!m_Window->HasInitialised()) OnQuit(); - + m_Window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent)); - + m_EditorState = EditorState::Play; - + ImGui::CreateContext(); ImPlot::CreateContext(); ImGui::StyleColorsDark(); - + bool loadEmbeddedShaders = true; if(FileSystem::FolderExists(m_ProjectSettings.m_EngineAssetPath + "Shaders")) loadEmbeddedShaders = false; - + if(!loadEmbeddedShaders) { - ArenaTemp temp = ScratchBegin(0, 0); + ArenaTemp temp = ScratchBegin(0, 0); String8 shaderPath = PushStr8F(temp.arena, "%sShaders/CompiledSPV/", m_ProjectSettings.m_EngineAssetPath.c_str()); FileSystem::IterateFolder((const char*)shaderPath.str, EmbedShaderFunc); ScratchEnd(temp); - + LINFO("Embedded %i shaders.", EmbedShaderCount); } Graphics::Renderer::Init(loadEmbeddedShaders, m_ProjectSettings.m_EngineAssetPath); - + if(m_ProjectSettings.Fullscreen) m_Window->Maximise(); - + // Draw Splash Screen { auto desc = Graphics::TextureDesc(Graphics::TextureFilter::LINEAR, Graphics::TextureFilter::LINEAR, Graphics::TextureWrap::REPEAT); @@ -174,19 +174,19 @@ namespace Lumos // To Display the window m_Window->ProcessInput(); m_Window->OnUpdate(); - + delete splashTexture; } - + uint32_t screenWidth = m_Window->GetWidth(); uint32_t screenHeight = m_Window->GetHeight(); m_SystemManager = CreateUniquePtr(); - + System::JobSystem::Context context; - + System::JobSystem::Execute(context, [](JobDispatchArgs args) { Lumos::Input::Get(); }); - + System::JobSystem::Execute(context, [this](JobDispatchArgs args) { auto audioManager = AudioManager::Create(); @@ -194,26 +194,26 @@ namespace Lumos { m_SystemManager->RegisterSystem(audioManager); } }); - + System::JobSystem::Execute(context, [this](JobDispatchArgs args) { m_SystemManager->RegisterSystem(); m_SystemManager->RegisterSystem(); LINFO("Initialised Physics Manager"); }); - + System::JobSystem::Execute(context, [this](JobDispatchArgs args) { m_SceneManager->LoadCurrentList(); }); - + m_ImGuiManager = CreateUniquePtr(false); m_ImGuiManager->OnInit(); LINFO("Initialised ImGui Manager"); - + m_SceneRenderer = CreateUniquePtr(screenWidth, screenHeight); - + System::JobSystem::Wait(context); - + m_CurrentState = AppState::Running; - + Graphics::Material::InitDefaultTexture(); Graphics::Font::InitDefaultFont(); m_SceneRenderer->EnableDebugRenderer(true); @@ -221,95 +221,88 @@ namespace Lumos #ifdef LUMOS_SSE LINFO("SSE Maths Enabled"); #endif - + m_UIArena = ArenaAlloc(Megabytes(8)); InitialiseUI(m_UIArena); GetUIState()->DPIScale = Application::Get().GetWindow()->GetDPIScale(); LINFO("Initalised UI"); - - Maths::TestMaths(); - - //Function test; - //test = [](float a) -> int { LINFO("Test Func"); }; - - Function func; - func = [](float a) -> int { return static_cast(a + 1.5); }; // Bind lambda func + Maths::TestMaths(); } - + void Application::OnQuit() { LUMOS_PROFILE_FUNCTION(); Serialise(); - + ArenaRelease(m_FrameArena); ArenaRelease(m_Arena); - + ShutDownUI(); ArenaRelease(m_UIArena); - + Graphics::Material::ReleaseDefaultTexture(); Graphics::Font::ShutdownDefaultFont(); Engine::Release(); Input::Release(); - + m_AssetManager.reset(); m_SceneManager.reset(); m_SceneRenderer.reset(); m_SystemManager.reset(); m_ImGuiManager.reset(); LuaManager::Release(); - + Graphics::Pipeline::ClearCache(); Graphics::RenderPass::ClearCache(); Graphics::Framebuffer::ClearCache(); - + m_Window.reset(); - + Graphics::Renderer::Release(); } - + void Application::OpenProject(const std::string& filePath) { LUMOS_PROFILE_FUNCTION(); m_ProjectSettings.m_ProjectName = StringUtilities::GetFileName(filePath); m_ProjectSettings.m_ProjectName = StringUtilities::RemoveFilePathExtension(m_ProjectSettings.m_ProjectName); - + #ifndef LUMOS_PLATFORM_IOS auto projectRoot = StringUtilities::GetFileLocation(filePath); m_ProjectSettings.m_ProjectRoot = projectRoot; - + String8 pathCopy = PushStr8Copy(m_FrameArena, projectRoot.c_str()); pathCopy = StringUtilities::ResolveRelativePath(m_FrameArena, pathCopy); m_ProjectSettings.m_ProjectRoot = (const char*)pathCopy.str; #endif - + FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Prefabs"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Materials"); - + m_SceneManager = CreateUniquePtr(); - + Deserialise(); - + m_SceneManager->LoadCurrentList(); m_SceneManager->ApplySceneSwitch(); - + LuaManager::Get().OnNewProject(m_ProjectSettings.m_ProjectRoot); } - + void Application::OpenNewProject(const std::string& path, const std::string& name) { LUMOS_PROFILE_FUNCTION(); m_ProjectSettings.m_ProjectRoot = path + name + "/"; m_ProjectSettings.m_ProjectName = name; - + String8 pathCopy = PushStr8Copy(m_FrameArena, m_ProjectSettings.m_ProjectRoot.c_str()); pathCopy = StringUtilities::ResolveRelativePath(m_FrameArena, pathCopy); m_ProjectSettings.m_ProjectRoot = (const char*)pathCopy.str; - + FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot); m_SceneManager = CreateUniquePtr(); - + MountFileSystemPaths(); // Set Default values m_ProjectSettings.RenderAPI = 1; @@ -320,7 +313,7 @@ namespace Lumos m_ProjectSettings.Title = "App"; m_ProjectSettings.ShowConsole = false; m_ProjectSettings.Fullscreen = false; - + #ifdef LUMOS_PLATFORM_MACOS // This is assuming Application in bin/Release-macos-x86_64/LumosEditor.app LINFO(StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()).c_str()); @@ -328,7 +321,7 @@ namespace Lumos #else m_ProjectSettings.m_EngineAssetPath = StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()) + "../../Lumos/Assets/"; #endif - + FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Scripts"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Scenes"); @@ -337,58 +330,58 @@ namespace Lumos FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Sounds"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Prefabs"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Materials"); - + MountFileSystemPaths(); - + m_SceneManager->EnqueueScene(new Scene("Empty Scene")); m_SceneManager->SwitchScene(0); - + // Set Default values m_ProjectSettings.Title = "App"; m_ProjectSettings.Fullscreen = false; - + m_SceneManager->ApplySceneSwitch(); - + m_ProjectLoaded = true; - + Serialise(); - + LuaManager::Get().OnNewProject(m_ProjectSettings.m_ProjectRoot); } - + void Application::MountFileSystemPaths() { - FileSystem::Get().SetAssetRoot(PushStr8Copy(m_Arena, (m_ProjectSettings.m_ProjectRoot + std::string("Assets")).c_str())); + FileSystem::Get().SetAssetRoot(PushStr8F(m_Arena, "%sAssets", m_ProjectSettings.m_ProjectRoot.c_str())); } - + Scene* Application::GetCurrentScene() const { LUMOS_PROFILE_FUNCTION_LOW(); return m_SceneManager->GetCurrentScene(); } - + Vec2 Application::GetWindowSize() const { if(!m_Window) return Vec2(0.0f, 0.0f); return Vec2(static_cast(m_Window->GetWidth()), static_cast(m_Window->GetHeight())); } - + float Application::GetWindowDPI() const { if(!m_Window) return 1.0f; - + return m_Window->GetDPIScale(); } - + bool Application::OnFrame() { LUMOS_PROFILE_FUNCTION(); LUMOS_PROFILE_FRAMEMARKER(); - + ArenaClear(m_FrameArena); - + if(m_SceneManager->GetSwitchingScene()) { LUMOS_PROFILE_SCOPE("Application::SceneSwitch"); @@ -396,67 +389,71 @@ namespace Lumos m_SceneManager->ApplySceneSwitch(); return m_CurrentState != AppState::Closing; } - + double now = m_Timer->GetElapsedSD(); auto& stats = Engine::Get().Statistics(); auto& ts = Engine::GetTimeStep(); - + static int s_NumContiguousLargeFrames = 0; const int maxContiguousLargeFrames = 2; - + if(ts.GetSeconds() > 5) { LWARN("Large frame time %.2f", ts.GetSeconds()); - + s_NumContiguousLargeFrames++; #ifdef LUMOS_DISABLE_LARGE_FRAME_TIME // Added to stop application locking computer // Exit if frametime exceeds 5 seconds return false; #endif - + if(s_NumContiguousLargeFrames > maxContiguousLargeFrames) return false; } else s_NumContiguousLargeFrames = 0; - + ExecuteMainThreadQueue(); - + { LUMOS_PROFILE_SCOPE("Application::TimeStepUpdates"); ts.OnUpdate(); - + ImGuiIO& io = ImGui::GetIO(); io.DeltaTime = (float)ts.GetSeconds(); - + stats.FrameTime = ts.GetMillis(); } - + // Process Input events before ImGui::NewFrame Input::Get().ResetPressed(); m_Window->ProcessInput(); - ImGui::NewFrame(); - - Vec2 frameSize = GetWindowSize(); + + { + LUMOS_PROFILE_SCOPE("ImGui::NewFrame"); + ImGui::NewFrame(); + } + + Vec2 frameSize = { (float)m_SceneViewWidth, (float)m_SceneViewHeight }; // GetWindowSize(); UIBeginFrame(frameSize, (float)ts.GetSeconds(), m_SceneViewPosition); UIBeginBuild(); - + static bool showTestUI = false; if(Input::Get().GetKeyPressed(Lumos::InputCode::Key::Escape)) showTestUI = !showTestUI; if(showTestUI) TestUI(); - + { std::scoped_lock lock(m_EventQueueMutex); - + for(auto& event : m_EventQueue) { event(); } m_EventQueue.Clear(); - + // Process custom event queue while(!m_EventQueue.Empty()) { @@ -465,24 +462,18 @@ namespace Lumos m_EventQueue.PopBack(); } } - + System::JobSystem::Context context; - + { LUMOS_PROFILE_SCOPE("Application::Update"); OnUpdate(ts); - + System::JobSystem::Execute(context, [](JobDispatchArgs args) { Application::UpdateSystems(); }); - - // UpdateSystems(); - - // m_SystemManager->GetSystem()->SyncTransforms(m_SceneManager->GetCurrentScene()); - // m_SystemManager->GetSystem()->SyncTransforms(m_SceneManager->GetCurrentScene()); - m_Updates++; } - + // Exit frame early if escape or close button clicked // Prevents a crash with vulkan/moltenvk if(m_CurrentState == AppState::Closing) @@ -490,9 +481,9 @@ namespace Lumos System::JobSystem::Wait(context); return false; } - + UIEndFrame(Graphics::Font::GetDefaultFont()); - + UIEndBuild(); UILayout(); // if (Platform->WindowIsActive) @@ -500,25 +491,24 @@ namespace Lumos // UIProcessInteractions(); } UIAnimate(); - // DearIMGUIDebugPanel(); - + if(!m_Minimized) { LUMOS_PROFILE_SCOPE("Application::Render"); Engine::Get().ResetStats(); - + Graphics::Renderer::GetRenderer()->Begin(); OnRender(); m_ImGuiManager->OnNewFrame(); m_ImGuiManager->OnRender(m_SceneManager->GetCurrentScene()); - + // Clears debug line and point lists DebugRenderer::Reset((float)ts.GetSeconds()); - + Graphics::Pipeline::DeleteUnusedCache(); Graphics::Framebuffer::DeleteUnusedCache(); Graphics::RenderPass::DeleteUnusedCache(); - + m_AssetManager->Update((float)ts.GetElapsedSeconds()); m_Frames++; } @@ -526,98 +516,104 @@ namespace Lumos { ImGui::Render(); } - + { LUMOS_PROFILE_SCOPE("Application::UpdateGraphicsStats"); stats.UsedGPUMemory = Graphics::Renderer::GetGraphicsContext()->GetGPUMemoryUsed(); stats.TotalGPUMemory = Graphics::Renderer::GetGraphicsContext()->GetTotalGPUMemory(); } - + { LUMOS_PROFILE_SCOPE("Application::WindowUpdate"); m_Window->UpdateCursorImGui(); m_Window->OnUpdate(); } - + if(now - m_SecondTimer > 1.0f) { LUMOS_PROFILE_SCOPE("Application::FrameRateCalc"); m_SecondTimer += 1.0f; - + stats.FramesPerSecond = m_Frames; stats.UpdatesPerSecond = m_Updates; - + m_Frames = 0; m_Updates = 0; } - - if(!m_Minimized) - Graphics::Renderer::GetRenderer()->Present(); - + // Sync transforms from physics for the next frame { System::JobSystem::Wait(context); - + m_SystemManager->GetSystem()->SyncTransforms(m_SceneManager->GetCurrentScene()); m_SystemManager->GetSystem()->SyncTransforms(m_SceneManager->GetCurrentScene()); } if(!m_Minimized) - OnDebugDraw(); //Moved after update thread sync to fix debug drawing physics Engine - + OnDebugDraw(); // Moved after update thread sync to fix debug drawing physics Engine + + if(!m_Minimized) + Graphics::Renderer::GetRenderer()->Present(); + return m_CurrentState != AppState::Closing; } - + void Application::OnRender() { LUMOS_PROFILE_FUNCTION(); if(!m_SceneManager->GetCurrentScene()) return; - + if(!m_DisableMainSceneRenderer) { m_SceneRenderer->BeginScene(m_SceneManager->GetCurrentScene()); m_SceneRenderer->OnRender(); } } - + void Application::OnDebugDraw() { m_SystemManager->OnDebugDraw(); } - + void Application::TestUI() { { UIPushStyle(StyleVar_BackgroundColor, { 0.1f, 0.1f, 0.1f, 0.4f }); UIPushStyle(StyleVar_BorderColor, { 0.4f, 0.4f, 0.4f, 0.6f }); UIPushStyle(StyleVar_TextColor, { 0.8f, 0.8f, 0.8f, 1.0f }); - - UIPushStyle(StyleVar_FontSize, { 24.0f, 1.0f, 1.0f, 1.0f }); - static bool value = false; - + + // UIPushStyle(StyleVar_FontSize, { 24.0f, 1.0f, 1.0f, 1.0f }); + static bool value = false; + static bool showDebugDearImGuiPanel = false; + { - UIBeginPanel("First Panel", WidgetFlags_StackVertically); + UIBeginPanel("First Panel", WidgetFlags_StackVertically | WidgetFlags_CentreX | WidgetFlags_CentreY); if(UIButton("Test Button2").clicked) LINFO("clicked button2"); - + + UIToggle("Dear ImGui Debug UI Panel", &showDebugDearImGuiPanel); + UILabel("Info1", Str8Lit("Test 1")); UILabel("Info2", Str8Lit("Test 2")); UILabel("Info3", Str8Lit("Test 3")); UILabel("Info4", Str8Lit("Test 4")); UIToggle("Test Toggle", &value); - + if(UIButton("Exit App").clicked) SetAppState(Lumos::AppState::Closing); - + static float valueS = 0.5f; UISlider("Test Slider", &valueS); UIEndPanel(); + + if(showDebugDearImGuiPanel) + DearIMGUIDebugPanel(); } - + if(value) { - UIBeginPanel("Second Panel",WidgetFlags_StackVertically);// WidgetFlags_Draggable | WidgetFlags_Floating_X | WidgetFlags_Floating_Y); + UIBeginPanel("Second Panel", WidgetFlags_StackVertically); // WidgetFlags_Draggable | WidgetFlags_Floating_X | WidgetFlags_Floating_Y); UILabel("Info 5", Str8Lit("Test 1234")); UILabel("Info 6", Str8Lit("Test 56789")); UILabel("Info 7", Str8Lit("Test")); @@ -626,20 +622,20 @@ namespace Lumos UILabel("Info 1###samenametest", Str8Lit("Test")); UIEndPanel(); } - + UIPopStyle(StyleVar_TextColor); UIPopStyle(StyleVar_BorderColor); UIPopStyle(StyleVar_BackgroundColor); - UIPopStyle(StyleVar_FontSize); + // UIPopStyle(StyleVar_FontSize); } } - + void Application::OnUpdate(const TimeStep& dt) { LUMOS_PROFILE_FUNCTION(); if(!m_SceneManager->GetCurrentScene()) return; - + if(Application::Get().GetEditorState() != EditorState::Paused && Application::Get().GetEditorState() != EditorState::Preview) { @@ -648,74 +644,74 @@ namespace Lumos } m_ImGuiManager->OnUpdate(dt, m_SceneManager->GetCurrentScene()); } - + void Application::OnEvent(Event& e) { LUMOS_PROFILE_FUNCTION(); EventDispatcher dispatcher(e); dispatcher.Dispatch(BIND_EVENT_FN(Application::OnWindowClose)); dispatcher.Dispatch(BIND_EVENT_FN(Application::OnWindowResize)); - + if(m_ImGuiManager) m_ImGuiManager->OnEvent(e); if(e.Handled()) return; - + if(m_SceneRenderer) m_SceneRenderer->OnEvent(e); - + if(e.Handled()) return; - + if(m_SceneManager->GetCurrentScene()) m_SceneManager->GetCurrentScene()->OnEvent(e); - + Input::Get().OnEvent(e); } - + void Application::Run() { while(OnFrame()) { } - + OnQuit(); } - + void Application::OnNewScene(Scene* scene) { LUMOS_PROFILE_FUNCTION(); m_SceneRenderer->OnNewScene(scene); } - + SharedPtr& Application::GetAssetManager() { return m_AssetManager; } - + void Application::SubmitToMainThread(const Function& function) { LUMOS_PROFILE_FUNCTION(); std::scoped_lock lock(m_MainThreadQueueMutex); - + m_MainThreadQueue.PushBack(function); } - + void Application::ExecuteMainThreadQueue() { LUMOS_PROFILE_FUNCTION(); std::scoped_lock lock(m_MainThreadQueueMutex); - + for(const auto& func : m_MainThreadQueue) func(); - + m_MainThreadQueue.Clear(); } - + void Application::OnExitScene() { } - + void Application::AddDefaultScene() { if(m_SceneManager->GetScenes().Size() == 0) @@ -724,46 +720,46 @@ namespace Lumos m_SceneManager->SwitchScene(0); } } - + bool Application::OnWindowClose(WindowCloseEvent& e) { m_CurrentState = AppState::Closing; return true; } - + bool Application::OnWindowResize(WindowResizeEvent& e) { LUMOS_PROFILE_FUNCTION(); Graphics::Renderer::GetGraphicsContext()->WaitIdle(); - + int width = e.GetWidth(), height = e.GetHeight(); - + if(width == 0 || height == 0) { m_Minimized = true; return false; } m_Minimized = false; - + Graphics::Renderer::GetRenderer()->OnResize(width, height); - + if(m_SceneRenderer) m_SceneRenderer->OnResize(width, height); - + Graphics::Renderer::GetGraphicsContext()->WaitIdle(); - + return false; } - + void Application::OnImGui() { LUMOS_PROFILE_FUNCTION(); if(!m_SceneManager->GetCurrentScene()) return; - + m_SceneManager->GetCurrentScene()->OnImGui(); } - + void Application::UpdateSystems() { LUMOS_PROFILE_FUNCTION(); @@ -771,19 +767,19 @@ namespace Lumos && Application::Get().GetEditorState() != EditorState::Preview) { auto scene = Application::Get().GetSceneManager()->GetCurrentScene(); - + if(!scene) return; - + Application::Get().GetSystemManager()->OnUpdate(Engine::GetTimeStep(), scene); } } - + void Application::OnSceneViewSizeUpdated(uint32_t width, uint32_t height) { LUMOS_PROFILE_FUNCTION(); Graphics::Renderer::GetGraphicsContext()->WaitIdle(); - + WindowResizeEvent e(width, height); if(width == 0 || height == 0) { @@ -793,10 +789,10 @@ namespace Lumos m_Minimized = false; m_SceneRenderer->OnResize(width, height); m_SceneRenderer->OnEvent(e); - + Graphics::Renderer::GetGraphicsContext()->WaitIdle(); } - + void Application::Serialise() { LUMOS_PROFILE_FUNCTION(); @@ -811,30 +807,30 @@ namespace Lumos LINFO("Serialising Application %s", fullPath.c_str()); FileSystem::WriteTextFile(fullPath, storage.str()); } - + // Save Asset Registry { String8 path = PushStr8F(m_FrameArena, "%sAssetRegistry.lmar", m_ProjectSettings.m_ProjectRoot.c_str()); // m_ProjectSettings.m_ProjectRoot + std::string("AssetRegistry.lmar"); SerialiseAssetRegistry(path, *m_AssetManager->GetAssetRegistry()); } } - + void Application::Deserialise() { LUMOS_PROFILE_FUNCTION(); { auto filePath = m_ProjectSettings.m_ProjectRoot + m_ProjectSettings.m_ProjectName + std::string(".lmproj"); - + MountFileSystemPaths(); - + LINFO("Loading Project : %s", filePath.c_str()); - + if(!FileSystem::FileExists(filePath)) { LINFO("No saved Project file found %s", filePath.c_str()); { m_SceneManager = CreateUniquePtr(); - + // Set Default values m_ProjectSettings.RenderAPI = 1; m_ProjectSettings.Width = 1200; @@ -844,14 +840,14 @@ namespace Lumos m_ProjectSettings.Title = "App"; m_ProjectSettings.ShowConsole = false; m_ProjectSettings.Fullscreen = false; - + m_ProjectLoaded = false; - + #ifdef LUMOS_PLATFORM_MACOS // This is assuming Application in bin/Release-macos-x86_64/LumosEditor.app LINFO(StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()).c_str()); m_ProjectSettings.m_EngineAssetPath = StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()) + "../../../../../Lumos/Assets/"; - + if(!FileSystem::FolderExists(m_ProjectSettings.m_EngineAssetPath)) { m_ProjectSettings.m_EngineAssetPath = StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()) + "../../Lumos/Assets/"; @@ -864,7 +860,7 @@ namespace Lumos } return; } - + FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Scripts"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Scenes"); @@ -873,9 +869,9 @@ namespace Lumos FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Sounds"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Prefabs"); FileSystem::CreateFolderIfDoesntExist(m_ProjectSettings.m_ProjectRoot + "Assets/Materials"); - + m_ProjectLoaded = true; - + std::string data = FileSystem::ReadTextFile(filePath); std::istringstream istr; istr.str(data); @@ -883,7 +879,7 @@ namespace Lumos { cereal::JSONInputArchive input(istr); input(*this); - + // Load Asset Registry { String8 path = PushStr8F(m_FrameArena, "%sAssetRegistry.lmar", m_ProjectSettings.m_ProjectRoot.c_str()); @@ -904,16 +900,16 @@ namespace Lumos m_ProjectSettings.Title = "App"; m_ProjectSettings.ShowConsole = false; m_ProjectSettings.Fullscreen = false; - + #ifdef LUMOS_PLATFORM_MACOS m_ProjectSettings.m_EngineAssetPath = StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()) + "../../../../../Lumos/Assets/"; #else m_ProjectSettings.m_EngineAssetPath = StringUtilities::GetFileLocation(OS::Instance()->GetExecutablePath()) + "../../Lumos/Assets/"; #endif - + m_SceneManager->EnqueueScene(new Scene("Empty Scene")); m_SceneManager->SwitchScene(0); - + LERROR("Failed to load project - %s", filePath.c_str()); } } diff --git a/Lumos/Source/Lumos/Core/Asset/AssetRegistry.cpp b/Lumos/Source/Lumos/Core/Asset/AssetRegistry.cpp index b006a7f6..90928f58 100644 --- a/Lumos/Source/Lumos/Core/Asset/AssetRegistry.cpp +++ b/Lumos/Source/Lumos/Core/Asset/AssetRegistry.cpp @@ -26,7 +26,7 @@ namespace Lumos void AssetRegistry::ReplaceID(UUID current, UUID newID) { - auto metaData = m_AssetRegistry[current]; + auto metaData = m_AssetRegistry[current]; m_AssetRegistry[newID] = metaData; m_AssetRegistry.erase(current); std::string name; @@ -34,7 +34,7 @@ namespace Lumos #ifndef LUMOS_PRODUCTION if(GetName(current, name)) { - m_NameMap[name] = newID; + m_NameMap[name] = newID; m_UUIDNameMap[newID] = name; m_UUIDNameMap.erase(current); } diff --git a/Lumos/Source/Lumos/Core/Core.h b/Lumos/Source/Lumos/Core/Core.h index 566cc9fd..2f5f24f0 100644 --- a/Lumos/Source/Lumos/Core/Core.h +++ b/Lumos/Source/Lumos/Core/Core.h @@ -254,11 +254,26 @@ constexpr inline void Swap(T& t1, T& t2) t2 = Move(temp); } -template struct IsLValueReference { static constexpr bool value = false; }; -template struct IsLValueReference { static constexpr bool value = true; }; -template struct IsRValueReference { static constexpr bool value = false; }; -template struct IsRValueReference { static constexpr bool value = true; }; - +template +struct IsLValueReference +{ + static constexpr bool value = false; +}; +template +struct IsLValueReference +{ + static constexpr bool value = true; +}; +template +struct IsRValueReference +{ + static constexpr bool value = false; +}; +template +struct IsRValueReference +{ + static constexpr bool value = true; +}; /// RemovePointer removes the pointer qualification from a type `T`. template @@ -276,18 +291,54 @@ struct RemovePointer { using type = T; }; -template struct RemoveReference { using type = T; }; -template struct RemoveReference { using type = T; }; -template struct RemoveReference { using type = T; }; -template struct AddPointer { using type = typename RemoveReference::type*; }; -template struct EnableIf {}; -template struct EnableIf { using type = T; }; -template struct IsSame { static constexpr bool value = false; }; -template struct IsSame { static constexpr bool value = true; }; - -template constexpr T&& Forward(typename RemoveReference::type& value) { return static_cast(value); } - -template constexpr T&& Forward(typename RemoveReference::type&& value) +template +struct RemoveReference +{ + using type = T; +}; +template +struct RemoveReference +{ + using type = T; +}; +template +struct RemoveReference +{ + using type = T; +}; +template +struct AddPointer +{ + using type = typename RemoveReference::type*; +}; +template +struct EnableIf +{ +}; +template +struct EnableIf +{ + using type = T; +}; +template +struct IsSame +{ + static constexpr bool value = false; +}; +template +struct IsSame +{ + static constexpr bool value = true; +}; + +template +constexpr T&& Forward(typename RemoveReference::type& value) +{ + return static_cast(value); +} + +template +constexpr T&& Forward(typename RemoveReference::type&& value) { static_assert(!IsLValueReference::value, "Forward an rvalue as an lvalue is not allowed"); return static_cast(value); diff --git a/Lumos/Source/Lumos/Core/DataStructures/TArray.h b/Lumos/Source/Lumos/Core/DataStructures/TArray.h index 9d8cf506..d041e729 100644 --- a/Lumos/Source/Lumos/Core/DataStructures/TArray.h +++ b/Lumos/Source/Lumos/Core/DataStructures/TArray.h @@ -142,7 +142,7 @@ namespace Lumos } other.m_Size = 0; } - + template TArray::TArray(std::initializer_list values, Arena* arena) : m_Size(_Size) @@ -152,7 +152,7 @@ namespace Lumos if(m_Arena) m_Data = PushArrayNoZero(m_Arena, T, m_Size); else - m_Data = new T[m_Size]; + m_Data = new T[m_Size]; size_t index = 0; for(auto& value : values) m_Data[index++] = value; @@ -262,7 +262,7 @@ namespace Lumos { m_Size = 0; } - + template void TArray::Destroy() noexcept { @@ -281,7 +281,7 @@ namespace Lumos } } - m_Data = nullptr; - m_Size = 0; + m_Data = nullptr; + m_Size = 0; } } diff --git a/Lumos/Source/Lumos/Core/Engine.h b/Lumos/Source/Lumos/Core/Engine.h index e09d4035..b65027af 100644 --- a/Lumos/Source/Lumos/Core/Engine.h +++ b/Lumos/Source/Lumos/Core/Engine.h @@ -46,7 +46,7 @@ namespace Lumos m_Stats.TotalGPUMemory = 0.0f; m_Stats.BoundPipelines = 0; m_Stats.BoundSceneRenderer = 0; - m_Stats.TriangleCount = 0; + m_Stats.TriangleCount = 0; } Stats& Statistics() { return m_Stats; } diff --git a/Lumos/Source/Lumos/Core/Function.h b/Lumos/Source/Lumos/Core/Function.h index 1f36d1f7..f8f995ba 100644 --- a/Lumos/Source/Lumos/Core/Function.h +++ b/Lumos/Source/Lumos/Core/Function.h @@ -16,47 +16,48 @@ namespace Lumos CopyConstruct, MoveConstruct }; - using StubFunction = R(*)(const void* const*, typename AddPointer::type...); + using StubFunction = R (*)(const void* const*, typename AddPointer::type...); using OperationFunction = void (*)(FunctionErasedOperation operation, const void** other, const void* const*); static const int MAX_LAMBDA_SIZE = sizeof(void*) * 8; - StubFunction functionStub; + StubFunction functionStub; OperationFunction functionOperation; union { const void* classInstance; - char lambdaMemory[MAX_LAMBDA_SIZE] = { 0 }; + char lambdaMemory[MAX_LAMBDA_SIZE] = { 0 }; }; void ExecuteOperation(FunctionErasedOperation operation, const void** other) const { - if (functionOperation) + if(functionOperation) (*functionOperation)(operation, other, &classInstance); } Function(const void* instance, StubFunction stub, OperationFunction operation) - : functionStub(stub), functionOperation(operation) + : functionStub(stub) + , functionOperation(operation) { classInstance = instance; } - using FreeFunction = R(*)(Args...); + using FreeFunction = R (*)(Args...); public: Function() { - functionStub = nullptr; + functionStub = nullptr; functionOperation = nullptr; } template < typename Lambda, typename = typename EnableIf< - not IsSame::type, Function>::value, void>::type> + not IsSame::type, Function>::value, void>::type> Function(Lambda&& lambda) { - functionStub = nullptr; + functionStub = nullptr; functionOperation = nullptr; Bind(Forward::type>(lambda)); } @@ -65,18 +66,18 @@ namespace Lumos Function(Function&& other) { - functionStub = other.functionStub; + functionStub = other.functionStub; functionOperation = other.functionOperation; - classInstance = other.classInstance; + classInstance = other.classInstance; other.ExecuteOperation(FunctionErasedOperation::MoveConstruct, &classInstance); other.ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - other.functionStub = nullptr; + other.functionStub = nullptr; other.functionOperation = nullptr; } Function(const Function& other) { - functionStub = other.functionStub; + functionStub = other.functionStub; functionOperation = other.functionOperation; other.ExecuteOperation(FunctionErasedOperation::CopyConstruct, &classInstance); } @@ -84,7 +85,7 @@ namespace Lumos Function& operator=(const Function& other) { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - functionStub = other.functionStub; + functionStub = other.functionStub; functionOperation = other.functionOperation; other.ExecuteOperation(FunctionErasedOperation::CopyConstruct, &classInstance); return *this; @@ -93,7 +94,7 @@ namespace Lumos Function& operator=(Function&& other) noexcept { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - functionStub = other.functionStub; + functionStub = other.functionStub; functionOperation = other.functionOperation; other.ExecuteOperation(FunctionErasedOperation::MoveConstruct, &classInstance); other.ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); @@ -108,68 +109,68 @@ namespace Lumos void Bind(Lambda&& lambda) { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - functionStub = nullptr; + functionStub = nullptr; functionOperation = nullptr; - new (&classInstance) Lambda(Forward(lambda)); + new(&classInstance) Lambda(Forward(lambda)); static_assert(sizeof(Lambda) <= sizeof(lambdaMemory), "Lambda is too big"); functionStub = [](const void* const* p, typename AddPointer::type... args) -> R - { - Lambda& lambda = *reinterpret_cast(const_cast(p)); - return lambda(*args...); - }; + { + Lambda& lambda = *reinterpret_cast(const_cast(p)); + return lambda(*args...); + }; functionOperation = [](FunctionErasedOperation operation, const void** other, const void* const* p) - { - Lambda& lambda = *reinterpret_cast(const_cast(p)); - if (operation == FunctionErasedOperation::Destruct) - lambda.~Lambda(); - else if (operation == FunctionErasedOperation::CopyConstruct) - new (other) Lambda(lambda); - else if (operation == FunctionErasedOperation::MoveConstruct) - new (other) Lambda(Move(lambda)); - else + { + Lambda& lambda = *reinterpret_cast(const_cast(p)); + if(operation == FunctionErasedOperation::Destruct) + lambda.~Lambda(); + else if(operation == FunctionErasedOperation::CopyConstruct) + new(other) Lambda(lambda); + else if(operation == FunctionErasedOperation::MoveConstruct) + new(other) Lambda(Move(lambda)); + else #if LUMOS_PLATFORM_WINDOWS - __assume(false); + __assume(false); #else - __builtin_unreachable(); + __builtin_unreachable(); #endif - }; + }; } - template + template void Bind() { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - classInstance = nullptr; - functionStub = &FunctionWrapper; + classInstance = nullptr; + functionStub = &FunctionWrapper; functionOperation = &FunctionOperation; } - template + template void Bind(const Class& c) { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - classInstance = &c; - functionStub = &MemberWrapper; + classInstance = &c; + functionStub = &MemberWrapper; functionOperation = &MemberOperation; } - template + template void Bind(Class& c) { ExecuteOperation(FunctionErasedOperation::Destruct, nullptr); - classInstance = &c; - functionStub = &MemberWrapper; + classInstance = &c; + functionStub = &MemberWrapper; functionOperation = &MemberOperation; } - template + template static Function FromMember(Class& c) { return Function(&c, &MemberWrapper, &MemberOperation); } - template + template static Function FromMember(const Class& c) { return Function(&c, &MemberWrapper, &MemberOperation); @@ -180,30 +181,30 @@ namespace Lumos private: static void MemberOperation(FunctionErasedOperation operation, const void** other, const void* const* p) { - if (operation == FunctionErasedOperation::CopyConstruct or operation == FunctionErasedOperation::MoveConstruct) + if(operation == FunctionErasedOperation::CopyConstruct or operation == FunctionErasedOperation::MoveConstruct) *other = *p; } - template + template static R MemberWrapper(const void* const* p, typename RemoveReference::type*... args) { Class* cls = const_cast(static_cast(*p)); return (cls->*MemberFunction)(*args...); } - template + template static R MemberWrapper(const void* const* p, typename RemoveReference::type*... args) { const Class* cls = static_cast(*p); return (cls->*MemberFunction)(*args...); } - template + template static R FunctionWrapper(const void* const* p, typename RemoveReference::type*... args) { LUMOS_UNUSED(p); return FreeFunction(*args...); } - static void FunctionOperation(FunctionErasedOperation, const void**, const void* const*) {} + static void FunctionOperation(FunctionErasedOperation, const void**, const void* const*) { } }; } \ No newline at end of file diff --git a/Lumos/Source/Lumos/Core/LMLog.cpp b/Lumos/Source/Lumos/Core/LMLog.cpp index 9ea1c728..b3a05ca7 100644 --- a/Lumos/Source/Lumos/Core/LMLog.cpp +++ b/Lumos/Source/Lumos/Core/LMLog.cpp @@ -18,8 +18,8 @@ namespace Lumos::Debug { static const char* levelStrs[5] = { "[INFO] : ", "[TRACE] : ", "[WARN] : ", "[ERROR] : ", "[FATAL] : " }; - if(!message) - return; + if(!message) + return; ArenaTemp scratch = ScratchBegin(nullptr, 0); String8 formattedMessage = { 0 }; @@ -29,7 +29,7 @@ namespace Lumos::Debug formattedMessage = PushStr8FV(scratch.arena, message, args); va_end(args); - formattedMessage = PushStr8F(scratch.arena, "%s%s\n", levelStrs[(u8)level], formattedMessage.str); + formattedMessage = PushStr8F(scratch.arena, " %s%s\n", levelStrs[(u8)level], formattedMessage.str); OS::ConsoleWrite((const char*)formattedMessage.str, u8(level)); if(s_LogFunction) diff --git a/Lumos/Source/Lumos/Core/OS/FileSystem.cpp b/Lumos/Source/Lumos/Core/OS/FileSystem.cpp index 925741ac..beb5379f 100644 --- a/Lumos/Source/Lumos/Core/OS/FileSystem.cpp +++ b/Lumos/Source/Lumos/Core/OS/FileSystem.cpp @@ -11,12 +11,12 @@ namespace Lumos { bool FileSystem::IsRelativePath(const char* path) { - if (!path || path[0] == '/' || path[0] == '\\') + if(!path || path[0] == '/' || path[0] == '\\') { return false; } - if (strlen(path) >= 2 && isalpha(path[0]) && path[1] == ':') + if(strlen(path) >= 2 && isalpha(path[0]) && path[1] == ':') { return false; } @@ -26,7 +26,7 @@ namespace Lumos bool FileSystem::IsAbsolutePath(const char* path) { - if (!path) + if(!path) { return false; } @@ -36,19 +36,19 @@ namespace Lumos const char* FileSystem::GetFileOpenModeString(FileOpenFlags flag) { - if (flag == FileOpenFlags::READ) + if(flag == FileOpenFlags::READ) { return "rb"; } - else if (flag == FileOpenFlags::WRITE) + else if(flag == FileOpenFlags::WRITE) { return "wb"; } - else if (flag == FileOpenFlags::READ_WRITE) + else if(flag == FileOpenFlags::READ_WRITE) { return "rb+"; } - else if (flag == FileOpenFlags::WRITE_READ) + else if(flag == FileOpenFlags::WRITE_READ) { return "wb+"; } @@ -64,7 +64,7 @@ namespace Lumos LUMOS_PROFILE_FUNCTION(); const std::string& updatedPath = path; - if (!(path[0] == '/' && path[1] == '/')) + if(!(path[0] == '/' && path[1] == '/')) { outPhysicalPath = path; return folder ? FileSystem::FolderExists(outPhysicalPath) : FileSystem::FileExists(outPhysicalPath); @@ -72,7 +72,7 @@ namespace Lumos // Assume path starts with //Assets #ifndef LUMOS_PRODUCTION - if (path.substr(2, 6) != "Assets") + if(path.substr(2, 6) != "Assets") { // Previously paths saved in scenes could be like //Textures and then converted to .../Assets/Textures/... outPhysicalPath = ToStdString(m_AssetRootPath) + path.substr(1, path.size()); @@ -122,9 +122,9 @@ namespace Lumos std::string updatedPath = path; std::replace(updatedPath.begin(), updatedPath.end(), '\\', '/'); - if (updatedPath.find(ToStdString(m_AssetRootPath)) != std::string::npos) + if(updatedPath.find(ToStdString(m_AssetRootPath)) != std::string::npos) { - std::string newPath = updatedPath; + std::string newPath = updatedPath; std::string newPartPath = "//Assets"; newPath.replace(0, m_AssetRootPath.size, newPartPath); outFileSystemPath = newPath; @@ -144,7 +144,7 @@ namespace Lumos void FileSystem::CreateFolderIfDoesntExist(const std::string& path) { - if (!FileSystem::FolderExists(path)) + if(!FileSystem::FolderExists(path)) { std::filesystem::create_directory(path); LINFO("Creating folder &s", path.c_str()); @@ -155,13 +155,12 @@ namespace Lumos { auto folderPath = std::filesystem::path(path); - if (std::filesystem::is_directory(folderPath)) + if(std::filesystem::is_directory(folderPath)) { - for (auto entry : std::filesystem::directory_iterator(folderPath)) + for(auto entry : std::filesystem::directory_iterator(folderPath)) { f(entry.path().string().c_str()); } } } } - \ No newline at end of file diff --git a/Lumos/Source/Lumos/Core/OS/Input.h b/Lumos/Source/Lumos/Core/OS/Input.h index e576e11a..92933c30 100644 --- a/Lumos/Source/Lumos/Core/OS/Input.h +++ b/Lumos/Source/Lumos/Core/OS/Input.h @@ -38,7 +38,7 @@ namespace Lumos KeyState OldState = KeyState::None; }; - #define MAX_CONTROLLER_COUNT 16 +#define MAX_CONTROLLER_COUNT 16 struct Controller { int ID; diff --git a/Lumos/Source/Lumos/Core/OS/OS.cpp b/Lumos/Source/Lumos/Core/OS/OS.cpp index 97f24d7e..021279b8 100644 --- a/Lumos/Source/Lumos/Core/OS/OS.cpp +++ b/Lumos/Source/Lumos/Core/OS/OS.cpp @@ -72,12 +72,12 @@ namespace Lumos void OS::ConsoleWrite(const char* msg, u8 level) { - #ifdef LUMOS_PLATFORM_MACOS - const char* colour_strings[] = {"1;32", "1;30", "1;33", "1;31", "0;41"}; - printf("\033[%sm%s\033[0m", colour_strings[level], msg); - #else - printf("%s", msg); - #endif +#ifdef LUMOS_PLATFORM_MACOS + const char* colour_strings[] = { "1;32", "1;30", "1;33", "1;31", "0;41" }; + printf("\033[%sm%s\033[0m", colour_strings[level], msg); +#else + printf("%s", msg); +#endif } } diff --git a/Lumos/Source/Lumos/Core/QualitySettings.h b/Lumos/Source/Lumos/Core/QualitySettings.h index be8897af..2bf8d81c 100644 --- a/Lumos/Source/Lumos/Core/QualitySettings.h +++ b/Lumos/Source/Lumos/Core/QualitySettings.h @@ -21,7 +21,7 @@ namespace Lumos struct QualitySettings { #ifdef LUMOS_PLATFORM_MACOS - float RendererScale = 1.0f; //Keep at 1 until fix ui input with this + float RendererScale = 1.0f; // Keep at 1 until fix ui input with this #else float RendererScale = 1.0f; diff --git a/Lumos/Source/Lumos/Core/Reference.h b/Lumos/Source/Lumos/Core/Reference.h index 24cff678..32c1f250 100644 --- a/Lumos/Source/Lumos/Core/Reference.h +++ b/Lumos/Source/Lumos/Core/Reference.h @@ -4,7 +4,7 @@ #include "OS/Memory.h" #include "Core/LMLog.h" -//#define DEBUG_REFERENCE_CAST +// #define DEBUG_REFERENCE_CAST #ifdef DEBUG_REFERENCE_CAST #include "Core/DataStructures/TDArray.h" #include "Utilities/StringUtilities.h" @@ -101,14 +101,14 @@ namespace Lumos m_Counter->reference(); } } - #ifdef DEBUG_REFERENCE_CAST +#ifdef DEBUG_REFERENCE_CAST else { auto type1 = StringUtilities::Demangle(typeid(T).name()); auto type2 = StringUtilities::Demangle(typeid(U).name()); LERROR("Failed to cast Reference %s to %s", type2.c_str(), type1.c_str()); } - #endif +#endif } ~Reference() noexcept @@ -191,14 +191,14 @@ namespace Lumos m_Counter->reference(); } } - #ifdef DEBUG_REFERENCE_CAST +#ifdef DEBUG_REFERENCE_CAST else { auto type1 = StringUtilities::Demangle(typeid(T).name()); auto type2 = StringUtilities::Demangle(typeid(U).name()); LERROR("Failed to cast Reference %s to %s", type2.c_str(), type1.c_str()); } - #endif +#endif return *this; } diff --git a/Lumos/Source/Lumos/Core/String.cpp b/Lumos/Source/Lumos/Core/String.cpp index eb5a73ff..b6adf128 100644 --- a/Lumos/Source/Lumos/Core/String.cpp +++ b/Lumos/Source/Lumos/Core/String.cpp @@ -224,29 +224,29 @@ namespace Lumos return result; } - String8 Str8FV(String8 allocatedString, const char* fmt, va_list args) - { - String8 result = { 0 }; - va_list args2; - va_copy(args2, args); - - uint64_t needed_bytes = stbsp_vsnprintf(0, 0, fmt, args) + 1; - result.size = needed_bytes - 1; - result.str = allocatedString.str; - - stbsp_vsnprintf((char*)result.str, (int)needed_bytes, fmt, args2); - return result; - } - - String8 Str8F(String8 allocatedString, const char* fmt, ...) - { - String8 result = { 0 }; - va_list args; - va_start(args, fmt); - result = Str8FV(allocatedString, fmt, args); - va_end(args); - return result; - } + String8 Str8FV(String8 allocatedString, const char* fmt, va_list args) + { + String8 result = { 0 }; + va_list args2; + va_copy(args2, args); + + uint64_t needed_bytes = stbsp_vsnprintf(0, 0, fmt, args) + 1; + result.size = needed_bytes - 1; + result.str = allocatedString.str; + + stbsp_vsnprintf((char*)result.str, (int)needed_bytes, fmt, args2); + return result; + } + + String8 Str8F(String8 allocatedString, const char* fmt, ...) + { + String8 result = { 0 }; + va_list args; + va_start(args, fmt); + result = Str8FV(allocatedString, fmt, args); + va_end(args); + return result; + } String8 PushStr8FillByte(Arena* arena, uint64_t size, uint8_t byte) { diff --git a/Lumos/Source/Lumos/Core/String.h b/Lumos/Source/Lumos/Core/String.h index f9f70304..4e432348 100644 --- a/Lumos/Source/Lumos/Core/String.h +++ b/Lumos/Source/Lumos/Core/String.h @@ -98,8 +98,8 @@ namespace Lumos String8 PushStr8F(Arena* arena, const char* fmt, ...); String8 PushStr8FillByte(Arena* arena, uint64_t size, uint8_t byte); - String8 Str8FV(String8 allocatedString, const char* fmt, va_list args); - String8 Str8F(String8 allocatedString, const char* fmt, ...); + String8 Str8FV(String8 allocatedString, const char* fmt, va_list args); + String8 Str8F(String8 allocatedString, const char* fmt, ...); void Str8ListPushNode(String8List* list, String8Node* n); void Str8ListPushNodeFront(String8List* list, String8Node* n); diff --git a/Lumos/Source/Lumos/Graphics/AnimatedSprite.h b/Lumos/Source/Lumos/Graphics/AnimatedSprite.h index 8c53c530..50cec55c 100644 --- a/Lumos/Source/Lumos/Graphics/AnimatedSprite.h +++ b/Lumos/Source/Lumos/Graphics/AnimatedSprite.h @@ -25,8 +25,8 @@ namespace Lumos::Graphics std::vector Frames; float FrameDuration = 1.0f; - template - friend void serialize(Archive& archive, AnimationState& state); + template + friend void serialize(Archive& archive, AnimationState& state); }; AnimatedSprite(); diff --git a/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.cpp b/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.cpp index 04757d8d..7b047718 100644 --- a/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.cpp +++ b/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.cpp @@ -400,19 +400,26 @@ namespace Lumos } else { - - if(offset != 0.0f) + if(Input::Get().GetMouseHeld(InputCode::MouseKey::ButtonRight) && offset != 0.0f) { - m_ZoomVelocity += dt * offset * 10.0f; + m_CameraSpeed += dt * offset * (m_CameraSpeed * 0.05f); + m_CameraSpeed = Maths::Max(0.0f, m_CameraSpeed); } - - if(!Maths::Equals(m_ZoomVelocity, 0.0f)) + else { - Vec3 pos = transform.GetLocalPosition(); - pos += transform.GetForwardDirection() * m_ZoomVelocity; - m_ZoomVelocity = m_ZoomVelocity * pow(m_ZoomDampeningFactor, dt); + if(offset != 0.0f) + { + m_ZoomVelocity += dt * offset * 10.0f; + } - transform.SetLocalPosition(pos); + if(!Maths::Equals(m_ZoomVelocity, 0.0f)) + { + Vec3 pos = transform.GetLocalPosition(); + pos += transform.GetForwardDirection() * m_ZoomVelocity; + m_ZoomVelocity = m_ZoomVelocity * pow(m_ZoomDampeningFactor, dt); + + transform.SetLocalPosition(pos); + } } } } diff --git a/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.h b/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.h index 13b4ee62..50016498 100644 --- a/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.h +++ b/Lumos/Source/Lumos/Graphics/Camera/EditorCamera.h @@ -34,6 +34,7 @@ namespace Lumos void StopMovement(); void SetSpeed(float speed) { m_CameraSpeed = speed; } + float GetSpeed() const { return m_CameraSpeed; } void SetCurrentMode(EditorCameraMode mode) { m_CameraMode = mode; } EditorCameraMode GetCurrentMode() const { return m_CameraMode; } diff --git a/Lumos/Source/Lumos/Graphics/Camera/ThirdPersonCamera.cpp b/Lumos/Source/Lumos/Graphics/Camera/ThirdPersonCamera.cpp index b8ebd4d7..2fc60ac0 100644 --- a/Lumos/Source/Lumos/Graphics/Camera/ThirdPersonCamera.cpp +++ b/Lumos/Source/Lumos/Graphics/Camera/ThirdPersonCamera.cpp @@ -67,8 +67,8 @@ namespace Lumos void ThirdPersonCameraController::HandleKeyboard(Maths::Transform& transform, float dt) { - // Temp - #if 0 +// Temp +#if 0 float multiplier = 1000.0f; if(Input::Get().GetKeyHeld(InputCode::Key::LeftShift)) @@ -118,6 +118,6 @@ namespace Lumos transform.SetLocalPosition(position); m_Velocity = m_Velocity * pow(m_DampeningFactor, dt); } - #endif +#endif } } diff --git a/Lumos/Source/Lumos/Graphics/Font.cpp b/Lumos/Source/Lumos/Graphics/Font.cpp index 18fef692..61bf5c15 100644 --- a/Lumos/Source/Lumos/Graphics/Font.cpp +++ b/Lumos/Source/Lumos/Graphics/Font.cpp @@ -426,12 +426,12 @@ namespace Lumos Buffer storageBuffer; AtlasHeader header; void* pixels; - if(TryReadFontAtlasFromCache(fontName, (float)config.emSize, header, pixels, storageBuffer)) + if(TryReadFontAtlasFromCache(fontName, (float)config.emSize, header, pixels, storageBuffer)) { - m_TextureAtlas = CreateCachedAtlas(header, pixels); - storageBuffer.Release(); - } - else + m_TextureAtlas = CreateCachedAtlas(header, pixels); + storageBuffer.Release(); + } + else { bool floatingPointFormat = true; SharedPtr texture; diff --git a/Lumos/Source/Lumos/Graphics/Mesh.cpp b/Lumos/Source/Lumos/Graphics/Mesh.cpp index 4f827876..1aa0ed32 100644 --- a/Lumos/Source/Lumos/Graphics/Mesh.cpp +++ b/Lumos/Source/Lumos/Graphics/Mesh.cpp @@ -44,9 +44,9 @@ namespace Lumos m_VertexBuffer = SharedPtr(VertexBuffer::Create((uint32_t)(sizeof(Graphics::Vertex) * vertices.Size()), vertices.Data(), BufferUsage::STATIC)); #ifndef LUMOS_PRODUCTION - m_Stats.VertexCount = (uint32_t)vertices.Size(); - m_Stats.TriangleCount = m_Stats.VertexCount / 3; - m_Stats.IndexCount = (uint32_t)indices.Size(); + m_Stats.VertexCount = (uint32_t)vertices.Size(); + m_Stats.TriangleCount = m_Stats.VertexCount / 3; + m_Stats.IndexCount = (uint32_t)indices.Size(); #endif } @@ -63,9 +63,9 @@ namespace Lumos m_AnimVertexBuffer = SharedPtr(VertexBuffer::Create((uint32_t)(sizeof(Graphics::AnimVertex) * vertices.Size()), vertices.Data(), BufferUsage::STATIC)); #ifndef LUMOS_PRODUCTION - m_Stats.VertexCount = (uint32_t)vertices.Size(); - m_Stats.TriangleCount = m_Stats.VertexCount / 3; - m_Stats.IndexCount = (uint32_t)indices.Size(); + m_Stats.VertexCount = (uint32_t)vertices.Size(); + m_Stats.TriangleCount = m_Stats.VertexCount / 3; + m_Stats.IndexCount = (uint32_t)indices.Size(); #endif } diff --git a/Lumos/Source/Lumos/Graphics/Model.h b/Lumos/Source/Lumos/Graphics/Model.h index c2d97862..618112f9 100644 --- a/Lumos/Source/Lumos/Graphics/Model.h +++ b/Lumos/Source/Lumos/Graphics/Model.h @@ -60,7 +60,7 @@ namespace Lumos Model& operator=(Model&&); private: - //Move to Animation Component + // Move to Animation Component PrimitiveType m_PrimitiveType = PrimitiveType::None; TDArray> m_Meshes; std::string m_FilePath; diff --git a/Lumos/Source/Lumos/Graphics/ModelLoader/GLTFLoader.cpp b/Lumos/Source/Lumos/Graphics/ModelLoader/GLTFLoader.cpp index 8f48dad8..f5426fbc 100644 --- a/Lumos/Source/Lumos/Graphics/ModelLoader/GLTFLoader.cpp +++ b/Lumos/Source/Lumos/Graphics/ModelLoader/GLTFLoader.cpp @@ -334,14 +334,14 @@ namespace Lumos::Graphics for(auto& attribute : primitive.attributes) { // Get accessor info - auto& accessor = model.accessors.at(attribute.second); - auto& bufferView = model.bufferViews.at(accessor.bufferView); - auto& buffer = model.buffers.at(bufferView.buffer); - //int componentLength = GLTF_COMPONENT_LENGTH_LOOKUP.at(accessor.type); - //int componentTypeByteSize = GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(accessor.componentType); + auto& accessor = model.accessors.at(attribute.second); + auto& bufferView = model.bufferViews.at(accessor.bufferView); + auto& buffer = model.buffers.at(bufferView.buffer); + // int componentLength = GLTF_COMPONENT_LENGTH_LOOKUP.at(accessor.type); + // int componentTypeByteSize = GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(accessor.componentType); - int componentLength = 0;// GLTF_COMPONENT_LENGTH_LOOKUP.at(indexAccessor.type); - int componentTypeByteSize = 0;// GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(indexAccessor.componentType); + int componentLength = 0; // GLTF_COMPONENT_LENGTH_LOOKUP.at(indexAccessor.type); + int componentTypeByteSize = 0; // GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(indexAccessor.componentType); HashMapFind(&GLTF_COMPONENT_LENGTH_LOOKUP, accessor.type, &componentLength); HashMapFind(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, accessor.componentType, &componentTypeByteSize); @@ -566,8 +566,8 @@ namespace Lumos::Graphics auto indexBufferView = model.bufferViews.at(indexAccessor.bufferView); auto indexBuffer = model.buffers.at(indexBufferView.buffer); - int componentLength = 0;// GLTF_COMPONENT_LENGTH_LOOKUP.at(indexAccessor.type); - int componentTypeByteSize = 0;// GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(indexAccessor.componentType); + int componentLength = 0; // GLTF_COMPONENT_LENGTH_LOOKUP.at(indexAccessor.type); + int componentTypeByteSize = 0; // GLTF_COMPONENT_BYTE_SIZE_LOOKUP.at(indexAccessor.componentType); HashMapFind(&GLTF_COMPONENT_LENGTH_LOOKUP, indexAccessor.type, &componentLength); HashMapFind(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, indexAccessor.componentType, &componentTypeByteSize); @@ -656,13 +656,12 @@ namespace Lumos::Graphics else lMesh = new Graphics::Mesh(indices, vertices); - - //Moved from mesh - //Move this lbmesh + // Moved from mesh + // Move this lbmesh /* // int lod = 2; // float threshold = powf(0.7f, float(lod)); - + if(optimise) { size_t indexCount = indices.Size(); @@ -813,62 +812,62 @@ namespace Lumos::Graphics { LUMOS_PROFILE_FUNCTION(); - if (!HashMapsInitialised) + if(!HashMapsInitialised) { HashMapInit(&GLTF_COMPONENT_LENGTH_LOOKUP); HashMapInit(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP); - int key = (int)TINYGLTF_TYPE_SCALAR; + int key = (int)TINYGLTF_TYPE_SCALAR; int value = 1; { HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_VEC2; + key = (int)TINYGLTF_TYPE_VEC2; value = 2; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_VEC3; + key = (int)TINYGLTF_TYPE_VEC3; value = 3; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_VEC4; + key = (int)TINYGLTF_TYPE_VEC4; value = 4; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_MAT2; + key = (int)TINYGLTF_TYPE_MAT2; value = 4; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_MAT3; + key = (int)TINYGLTF_TYPE_MAT3; value = 9; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); - key = (int)TINYGLTF_TYPE_MAT4; + key = (int)TINYGLTF_TYPE_MAT4; value = 16; HashMapInsert(&GLTF_COMPONENT_LENGTH_LOOKUP, key, value); } { - key = (int)TINYGLTF_COMPONENT_TYPE_BYTE; + key = (int)TINYGLTF_COMPONENT_TYPE_BYTE; value = 1; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); - key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE; + key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE; value = 1; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); - key = (int)TINYGLTF_COMPONENT_TYPE_SHORT; + key = (int)TINYGLTF_COMPONENT_TYPE_SHORT; value = 2; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); - key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT; + key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT; value = 2; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); - key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT; + key = (int)TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT; value = 4; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); - key = (int)TINYGLTF_COMPONENT_TYPE_FLOAT; + key = (int)TINYGLTF_COMPONENT_TYPE_FLOAT; value = 4; HashMapInsert(&GLTF_COMPONENT_BYTE_SIZE_LOOKUP, key, value); } diff --git a/Lumos/Source/Lumos/Graphics/RHI/Renderer.cpp b/Lumos/Source/Lumos/Graphics/RHI/Renderer.cpp index 1f2cb80c..40087809 100644 --- a/Lumos/Source/Lumos/Graphics/RHI/Renderer.cpp +++ b/Lumos/Source/Lumos/Graphics/RHI/Renderer.cpp @@ -93,7 +93,7 @@ namespace Lumos void Renderer::LoadEngineShaders(bool loadEmbeddedShaders, const std::string& engineShaderPath) { auto shaderLibrary = Application::Get().GetAssetManager(); - if(true) + if(loadEmbeddedShaders) { LINFO("Loading shaders - embedded"); LoadShaderEmbedded("Skybox", Skybox, Skybox); @@ -171,7 +171,7 @@ namespace Lumos LoadShaderFromFile("DepthPrePassAnim", "Shaders/DepthPrePassAnim.shader"); LoadShaderFromFile("DepthPrePassAlphaAnim", "Shaders/DepthPrePassAlphaAnim.shader") - if(Renderer::GetCapabilities().SupportCompute) + if(Renderer::GetCapabilities().SupportCompute) { LoadShaderFromFile("FXAAComp", "Shaders/FXAACompute.shader"); LoadShaderFromFile("BloomComp", "Shaders/BloomComp.shader"); diff --git a/Lumos/Source/Lumos/Graphics/RHI/Renderer.h b/Lumos/Source/Lumos/Graphics/RHI/Renderer.h index eec3bab2..479b0425 100644 --- a/Lumos/Source/Lumos/Graphics/RHI/Renderer.h +++ b/Lumos/Source/Lumos/Graphics/RHI/Renderer.h @@ -47,7 +47,7 @@ namespace Lumos virtual void PresentInternal(Graphics::CommandBuffer* commandBuffer) = 0; virtual void BindDescriptorSetsInternal(Graphics::Pipeline* pipeline, Graphics::CommandBuffer* commandBuffer, uint32_t dynamicOffset, Graphics::DescriptorSet** descriptorSets, uint32_t descriptorCount) = 0; - virtual const std::string& GetTitleInternal() const = 0; + virtual const char* GetTitleInternal() const = 0; virtual void DrawIndexedInternal(CommandBuffer* commandBuffer, DrawType type, uint32_t count, uint32_t start) const = 0; virtual void DrawInternal(CommandBuffer* commandBuffer, DrawType type, uint32_t count, DataType datayType, void* indices) const = 0; virtual void Dispatch(CommandBuffer* commandBuffer, uint32_t workGroupSizeX, uint32_t workGroupSizeY, uint32_t workGroupSizeZ) { } @@ -77,7 +77,7 @@ namespace Lumos { s_Instance->DrawIndexedInternal(commandBuffer, type, count, start); } - inline static const std::string& GetTitle() + inline static const char* GetTitle() { return s_Instance->GetTitleInternal(); } diff --git a/Lumos/Source/Lumos/Graphics/Renderers/DebugRenderer.cpp b/Lumos/Source/Lumos/Graphics/Renderers/DebugRenderer.cpp index 35e4c423..ff62ee20 100644 --- a/Lumos/Source/Lumos/Graphics/Renderers/DebugRenderer.cpp +++ b/Lumos/Source/Lumos/Graphics/Renderers/DebugRenderer.cpp @@ -206,9 +206,9 @@ namespace Lumos void DebugRenderer::DrawMatrix(const Mat3& mtx, const Vec3& position, bool depthTested, float time) { LUMOS_PROFILE_FUNCTION(); - //GenDrawHairLine(!depthTested, position, position + Vec3(mtx[0], mtx[1], mtx[2]), Vec4(1.0f, 0.0f, 0.0f, 1.0f), time); - //GenDrawHairLine(!depthTested, position, position + Vec3(mtx[4], mtx[5], mtx[6]), Vec4(0.0f, 1.0f, 0.0f, 1.0f), time); - // GenDrawHairLine(!depthTested, position, position + Vec3(mtx[8], mtx[9], mtx[10]), Vec4(0.0f, 0.0f, 1.0f, 1.0f), time); + // GenDrawHairLine(!depthTested, position, position + Vec3(mtx[0], mtx[1], mtx[2]), Vec4(1.0f, 0.0f, 0.0f, 1.0f), time); + // GenDrawHairLine(!depthTested, position, position + Vec3(mtx[4], mtx[5], mtx[6]), Vec4(0.0f, 1.0f, 0.0f, 1.0f), time); + // GenDrawHairLine(!depthTested, position, position + Vec3(mtx[8], mtx[9], mtx[10]), Vec4(0.0f, 0.0f, 1.0f, 1.0f), time); } // Draw Triangle diff --git a/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.cpp b/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.cpp index 70405548..73e21886 100644 --- a/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.cpp +++ b/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.cpp @@ -1060,7 +1060,7 @@ namespace Lumos::Graphics pipelineDesc.cullMode = command.material->GetFlag(Material::RenderFlags::TWOSIDED) ? Graphics::CullMode::NONE : Graphics::CullMode::BACK; pipelineDesc.transparencyEnabled = command.material->GetFlag(Material::RenderFlags::ALPHABLEND); pipelineDesc.samples = m_MainTextureSamples; - pipelineDesc.polygonMode = PolygonMode::FILL; + pipelineDesc.polygonMode = PolygonMode::FILL; if(m_MainTextureSamples > 1) pipelineDesc.resolveTexture = m_ResolveTexture; if(m_ForwardData.m_DepthTest && command.material->GetFlag(Material::RenderFlags::DEPTHTEST)) @@ -1221,6 +1221,11 @@ namespace Lumos::Graphics if(sceneRenderSettings.DepthPrePass) DepthPrePass(); + if(m_MainTextureSamples > 1) + { + sceneRenderSettings.SSAOEnabled = false; + } + if(sceneRenderSettings.SSAOEnabled && !m_DisablePostProcess) { SSAOPass(); @@ -1627,17 +1632,11 @@ namespace Lumos::Graphics auto& pushConstants = command.pipeline->GetShader()->GetPushConstants(); memcpy(pushConstants[0].data + sizeof(Mat4), &layer, sizeof(uint32_t)); currentDescriptors[0] = alphaBlend ? m_ShadowData.m_DescriptorSet[1].get() : m_ShadowData.m_DescriptorSet[0].get(); + currentDescriptors[2] = m_ForwardData.m_DescriptorSet[2]; if(command.animated) { - if(alphaBlend) - { - currentDescriptors[2] = command.AnimatedDescriptorSet; - } - else - { - currentDescriptors[1] = command.AnimatedDescriptorSet; - } + currentDescriptors[3] = command.AnimatedDescriptorSet; } auto pipeline = command.pipeline; @@ -1648,7 +1647,7 @@ namespace Lumos::Graphics memcpy(pushConstants[0].data, &transform, sizeof(Mat4)); command.pipeline->GetShader()->BindPushConstants(commandBuffer, pipeline); - Renderer::BindDescriptorSets(pipeline, commandBuffer, 0, currentDescriptors, command.animated ? (alphaBlend ? 3 : 2) : (alphaBlend ? 2 : 1)); + Renderer::BindDescriptorSets(pipeline, commandBuffer, 0, currentDescriptors, command.animated ? 4 : 3); Renderer::DrawMesh(commandBuffer, pipeline, mesh); m_Stats.NumShadowObjects++; } @@ -1674,8 +1673,9 @@ namespace Lumos::Graphics pipelineDesc.DebugName = "Depth Prepass"; pipelineDesc.samples = m_MainTextureSamples; - DescriptorSet* sets[3]; + DescriptorSet* sets[4]; sets[0] = m_ForwardData.m_DescriptorSet[0].get(); + sets[2] = m_ForwardData.m_DescriptorSet[2].get(); for(auto& command : m_ForwardData.m_CommandQueue) { @@ -1688,10 +1688,7 @@ namespace Lumos::Graphics if(command.animated) { - if(alphaBlend) - sets[2] = command.AnimatedDescriptorSet; - else - sets[1] = command.AnimatedDescriptorSet; + sets[3] = command.AnimatedDescriptorSet; } pipelineDesc.transparencyEnabled = alphaBlend; @@ -1707,7 +1704,7 @@ namespace Lumos::Graphics pushConstants.SetValue("transform", (void*)&worldTransform); m_DepthPrePassShader->BindPushConstants(commandBuffer, pipeline); - Renderer::BindDescriptorSets(pipeline, commandBuffer, 0, sets, command.animated ? (alphaBlend ? 3 : 2) : (alphaBlend ? 2 : 1)); + Renderer::BindDescriptorSets(pipeline, commandBuffer, 0, sets, command.animated ? 4 : 3); Renderer::DrawMesh(commandBuffer, pipeline, mesh); } } @@ -1717,6 +1714,12 @@ namespace Lumos::Graphics LUMOS_PROFILE_FUNCTION(); LUMOS_PROFILE_GPU("SSAO Pass"); + if(m_MainTextureSamples > 1) + { + // LWARN("SSAOPass pass currently not working with msaa"); + return; + } + if(!m_Camera || !m_SSAOShader || !m_SSAOShader->IsCompiled()) return; @@ -2019,16 +2022,16 @@ namespace Lumos::Graphics Vec4 background_color = widget->style_vars[StyleVar_BackgroundColor]; Vec4 text_color = widget->style_vars[StyleVar_TextColor]; - if( widget->HotTransition > 0.0f) + if(widget->HotTransition > 0.0f) { border_color = border_color.Lerp(widget->style_vars[StyleVar_HotBorderColor], widget->HotTransition); - background_color = background_color.Lerp( widget->style_vars[StyleVar_HotBackgroundColor], widget->HotTransition); + background_color = background_color.Lerp(widget->style_vars[StyleVar_HotBackgroundColor], widget->HotTransition); text_color = text_color.Lerp(widget->style_vars[StyleVar_HotTextColor], widget->HotTransition); } else if(widget->ActiveTransition > 0.0f) { border_color = border_color.Lerp(widget->style_vars[StyleVar_ActiveBorderColor], widget->ActiveTransition); - background_color = background_color.Lerp( widget->style_vars[StyleVar_ActiveBackgroundColor], widget->ActiveTransition); + background_color = background_color.Lerp(widget->style_vars[StyleVar_ActiveBackgroundColor], widget->ActiveTransition); text_color = text_color.Lerp(widget->style_vars[StyleVar_ActiveTextColor], widget->ActiveTransition); } @@ -4121,8 +4124,6 @@ namespace Lumos::Graphics if(m_DebugTextRendererData.m_IndexCount != 0) TextFlush(m_DebugTextRendererData, DebugTextVertexBufferBase, DebugTextVertexBufferPtr); - - } auto& ndtDebugText = DebugRenderer::GetInstance()->GetDebugTextNDT(); @@ -4554,7 +4555,7 @@ namespace Lumos::Graphics descriptorDesc.layoutIndex = 0; descriptorDesc.shader = shader.get(); auto descriptorSet = SharedPtr(Graphics::DescriptorSet::Create(descriptorDesc)); - SharedPtr hdri = nullptr; + SharedPtr hdri = nullptr; if(!filePath.empty()) { diff --git a/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.h b/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.h index bb85b01e..1b9829de 100644 --- a/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.h +++ b/Lumos/Source/Lumos/Graphics/Renderers/SceneRenderer.h @@ -32,7 +32,7 @@ namespace Lumos struct Light; class VertexBuffer; class IndexBuffer; - + struct LineVertexData { Vec3 vertex; @@ -296,7 +296,6 @@ namespace Lumos Texture2D* m_ResolveTexture = nullptr; Texture2D* m_LastRenderTarget = nullptr; Texture2D* m_PostProcessTexture1 = nullptr; - Texture2D* m_PostProcessTexture2 = nullptr; Camera* m_Camera = nullptr; Maths::Transform* m_CameraTransform = nullptr; diff --git a/Lumos/Source/Lumos/Graphics/UI.cpp b/Lumos/Source/Lumos/Graphics/UI.cpp index ff6d6d7c..fc1b89ed 100644 --- a/Lumos/Source/Lumos/Graphics/UI.cpp +++ b/Lumos/Source/Lumos/Graphics/UI.cpp @@ -24,7 +24,7 @@ namespace Lumos s_UIState->hot_widget = 0; s_UIState->next_hot_widget = 0; s_UIState->FrameIndex = 0; - s_UIState->AnimationRate = 10.0f; + s_UIState->AnimationRate = 10.0f; s_UIState->UIArena = arena; s_UIState->UIFrameArena = ArenaAlloc(Megabytes(1)); @@ -170,9 +170,9 @@ namespace Lumos HashMapFind(&s_UIState->widgets, hash, &widget); if(!widget) { - void* mem = s_UIState->WidgetAllocator->Allocate(); - widget = new(mem) UI_Widget(); - widget->HotTransition = 0.0f; + void* mem = s_UIState->WidgetAllocator->Allocate(); + widget = new(mem) UI_Widget(); + widget->HotTransition = 0.0f; widget->ActiveTransition = 0.0f; HashMapInsert(&s_UIState->widgets, hash, widget); } @@ -226,7 +226,7 @@ namespace Lumos const Vec2& position = widget->position; const Vec2& size = widget->size; - const Vec2& mouse = Input::Get().GetMousePosition() * s_UIState->DPIScale - s_UIState->InputOffset; //Needs to take Quality setting render scale into accoutn too + const Vec2& mouse = Input::Get().GetMousePosition() * s_UIState->DPIScale - s_UIState->InputOffset; // Needs to take Quality setting render scale into accoutn too bool hovering = mouse.x >= position.x && mouse.x <= position.x + size.x && mouse.y >= position.y && mouse.y <= position.y + size.y; if(hovering) @@ -310,7 +310,7 @@ namespace Lumos UI_Widget* widget = s_UIState->active_widget_state; UI_Widget* parent = widget->parent; - Vec2 min_p = parent->position;// s_UIState->active_widget_state->drag_offset; + Vec2 min_p = parent->position; // s_UIState->active_widget_state->drag_offset; Vec2 max_p = parent->size - (widget->size - s_UIState->active_widget_state->drag_offset); if(s_UIState->active_widget_state->drag_constraint_x) @@ -324,7 +324,7 @@ namespace Lumos } mouse_p = Maths::Clamp(mouse_p, min_p, max_p); - //Application::Get().GetWindow()->SetMousePosition(mouse_p); + // Application::Get().GetWindow()->SetMousePosition(mouse_p); s_UIState->active_widget_state->relative_position = (mouse_p - s_UIState->active_widget_state->drag_offset); } } @@ -351,22 +351,21 @@ namespace Lumos { s_UIState->active_widget = s_UIState->hot_widget; s_UIState->hot_widget = 0; - + HashMapFind(&s_UIState->widgets, s_UIState->active_widget, &s_UIState->active_widget_state); if(s_UIState->active_widget_state) s_UIState->active_widget_state->clicked = true; } } - } - + } TDArray lWidgetsToDelete(s_UIState->UIFrameArena); ForHashMapEach(u64, UI_Widget*, &s_UIState->widgets, it) { u64 key = *it.key; UI_Widget* value = *it.value; - + if(key == s_UIState->hot_widget || key == s_UIState->active_widget) { if(key == s_UIState->hot_widget) @@ -374,14 +373,14 @@ namespace Lumos else value->ActiveTransition += s_UIState->AnimationRateDT; } - else - { - value->HotTransition -= s_UIState->AnimationRateDT; - value->ActiveTransition -= s_UIState->AnimationRateDT; + else + { + value->HotTransition -= s_UIState->AnimationRateDT; + value->ActiveTransition -= s_UIState->AnimationRateDT; } - value->HotTransition = Maths::Clamp(value->HotTransition, 0.0f, 1.0f); - value->ActiveTransition = Maths::Clamp(value->ActiveTransition, 0.0f, 1.0f); + value->HotTransition = Maths::Clamp(value->HotTransition, 0.0f, 1.0f); + value->ActiveTransition = Maths::Clamp(value->ActiveTransition, 0.0f, 1.0f); if(value->LastFrameIndexActive < s_UIState->FrameIndex) { @@ -410,45 +409,13 @@ namespace Lumos } return text; } - + UI_Interaction UIBeginPanel(const char* str, u32 extraFlags) { - u64 hash; - String8 text = HandleUIString(str, &hash); - - String8 WindowText = PushStr8F(s_UIState->UIFrameArena, "Window###window%s", (char*)text.str); - u64 hashWindow; - String8 WindowText2 = HandleUIString((char*)WindowText.str, &hashWindow); - UI_Widget* window = PushWidget(WidgetFlags_DrawBackground | extraFlags, - WindowText2, - hashWindow, - { SizeKind_MaxChild, 1.0f }, - { SizeKind_ChildSum, 1.0f }); - PushParent(window); - - String8 HeaderText = PushStr8F(s_UIState->UIFrameArena, "Header###header%s", (char*)text.str); - u64 hashHeader; - String8 HeaderText2 = HandleUIString((char*)HeaderText.str, &hashHeader); - UIPushStyle(StyleVar_Padding, { 0.0f, 0.0f, 0.0f, 0.0f }); - UI_Widget* header = PushWidget(WidgetFlags_DrawBackground | WidgetFlags_StackVertically, - HeaderText2, - hashHeader, - { SizeKind_PercentOfParent, 1.0f }, - { SizeKind_ChildSum, 1.0f }); - UIPopStyle(StyleVar_Padding); - PushParent(header); - - UI_Widget* title = PushWidget(WidgetFlags_DrawText, - text, - hash, - { SizeKind_TextContent, 1.0f }, - { SizeKind_TextContent, 1.0f }); - - PopParent(header); - return HandleWidgetInteraction(header); + return UIBeginPanel(str, SizeKind_MaxChild, 1.0f, SizeKind_ChildSum, 1.0f, extraFlags); } - - UI_Interaction UIBeginPanel(const char* str, Vec4 rect, u32 extraFlags) + + UI_Interaction UIBeginPanel(const char* str, SizeKind sizeKindX, float xValue, SizeKind sizeKindY, float yValue, u32 extraFlags) { u64 hash; String8 text = HandleUIString(str, &hash); @@ -459,10 +426,8 @@ namespace Lumos UI_Widget* window = PushWidget(WidgetFlags_DrawBackground | extraFlags, WindowText2, hashWindow, - { SizeKind_MaxChild, 1.0f }, - { SizeKind_ChildSum, 1.0f }); - - window->position = Vec2(rect.x * s_UIState->root_parent.size.x, rect.y * s_UIState->root_parent.size.y); + { sizeKindX, xValue }, + { sizeKindY, yValue }); PushParent(window); String8 HeaderText = PushStr8F(s_UIState->UIFrameArena, "Header###header%s", (char*)text.str); @@ -558,23 +523,23 @@ namespace Lumos PushParent(spacer); { - float lSliderWidth = 250.0f; + float lSliderWidth = 250.0f; float lSliderHeight = 20.0f; - String8 parentText = PushStr8F(s_UIState->UIFrameArena, "parent###parent%s", (char*)text.str); - UI_Widget* parent = PushWidget(WidgetFlags_Clickable | WidgetFlags_DrawBorder | WidgetFlags_DrawBackground, - text, - HashUIStr8Name(parentText), - { SizeKind_Pixels, lSliderWidth }, - { SizeKind_Pixels, lSliderHeight }); + String8 parentText = PushStr8F(s_UIState->UIFrameArena, "parent###parent%s", (char*)text.str); + UI_Widget* parent = PushWidget(WidgetFlags_Clickable | WidgetFlags_DrawBorder | WidgetFlags_DrawBackground, + text, + HashUIStr8Name(parentText), + { SizeKind_Pixels, lSliderWidth }, + { SizeKind_Pixels, lSliderHeight }); UI_Interaction parent_interaction = HandleWidgetInteraction(parent); PushParent(parent); - UI_Widget* slider = PushWidget(WidgetFlags_Clickable | WidgetFlags_DrawBorder | WidgetFlags_DrawBackground | WidgetFlags_Floating_X | WidgetFlags_Draggable, - text, - hash, - { SizeKind_PercentOfParent, 0.1f }, - { SizeKind_PercentOfParent, 1.0f }); + UI_Widget* slider = PushWidget(WidgetFlags_Clickable | WidgetFlags_DrawBorder | WidgetFlags_DrawBackground | WidgetFlags_Floating_X | WidgetFlags_Draggable, + text, + hash, + { SizeKind_PercentOfParent, 0.1f }, + { SizeKind_PercentOfParent, 1.0f }); slider->style_vars[StyleVar_Border] = Vec4(0.0f, 0.0f, 0.0f, 0.0f); slider->style_vars[StyleVar_Padding] = Vec4(0.0f, 0.0f, 0.0f, 0.0f); slider_interaction = HandleWidgetInteraction(slider); @@ -601,26 +566,26 @@ namespace Lumos f32 t = 0.0f; if(slider->dragging) { - t = (slider_x - parent_x) / (lSliderWidth - 0.1f * lSliderWidth); + t = (slider_x - parent_x) / (lSliderWidth - 0.1f * lSliderWidth); *value = min_value + (max_value - min_value) * t; } else { - t = (*value - min_value) / (max_value - min_value); + t = (*value - min_value) / (max_value - min_value); slider_p.x = t * (lSliderWidth - 0.1f * lSliderWidth); } *value = Maths::Clamp(*value, min_value, max_value); - t = Maths::Clamp(t, 0.0f, 1.0f); + t = Maths::Clamp(t, 0.0f, 1.0f); - String8 slider_text = PushStr8F(s_UIState->UIFrameArena, "%.2f - %s", *value, (const char*)text.str); - String8 text = HandleUIString((char*)slider_text.str, &hash); + String8 slider_text = PushStr8F(s_UIState->UIFrameArena, "%.2f - %s", *value, (const char*)text.str); + String8 text = HandleUIString((char*)slider_text.str, &hash); slider->relative_position[UIAxis_X] = lSliderWidth * t - (0.1f * lSliderWidth * 0.5f); - UI_Widget* widget = PushWidget(WidgetFlags_DrawText, - text, - hash, - { SizeKind_TextContent, 1.0f }, - { SizeKind_TextContent, 1.0f }); + UI_Widget* widget = PushWidget(WidgetFlags_DrawText, + text, + hash, + { SizeKind_TextContent, 1.0f }, + { SizeKind_TextContent, 1.0f }); } PopParent(spacer); @@ -864,7 +829,7 @@ namespace Lumos if(Axis == UIAxis_X && !(Child->flags & WidgetFlags_Floating_X)) { float xOffset = 0; - if(Child->flags & WidgetFlags_CentreY) + if(Child->flags & WidgetFlags_CentreX) { xOffset = Parent->size[Axis] * 0.5f - Child->size[Axis] * 0.5f; } @@ -875,8 +840,14 @@ namespace Lumos } if(Axis == UIAxis_Y && !(Child->flags & WidgetFlags_Floating_Y)) { - Child->relative_position[Axis] = LayoutPosition; - LayoutPosition += /*(Axis == Parent->LayoutingAxis)*/ (Parent->flags & WidgetFlags_StackVertically ? 1 : 0) * Child->size[Axis]; + float yOffset = 0; + if(Child->flags & WidgetFlags_CentreY) + { + yOffset = Parent->size[Axis] * 0.5f - Child->size[Axis] * 0.5f; + } + + Child->relative_position[Axis] = LayoutPosition + yOffset; + LayoutPosition += /*(Axis == Parent->LayoutingAxis)*/ (Parent->flags & WidgetFlags_StackVertically ? 1 : 0) * (Child->size[Axis] + yOffset); } Vec2 padding = Child->style_vars[StyleVar_Padding].ToVector2(); diff --git a/Lumos/Source/Lumos/Graphics/UI.h b/Lumos/Source/Lumos/Graphics/UI.h index 63c4bab4..a83c4492 100644 --- a/Lumos/Source/Lumos/Graphics/UI.h +++ b/Lumos/Source/Lumos/Graphics/UI.h @@ -28,7 +28,8 @@ namespace Lumos WidgetFlags_StackHorizontally = (1 << 6), WidgetFlags_Floating_X = (1 << 7), WidgetFlags_Floating_Y = (1 << 8), - WidgetFlags_CentreY = (1 << 9) + WidgetFlags_CentreX = (1 << 9), + WidgetFlags_CentreY = (1 << 10) }; enum UITextAlignment : u32 @@ -179,7 +180,7 @@ namespace Lumos void UIEndFrame(Graphics::Font* font); UI_Interaction UIBeginPanel(const char* str, u32 extraFlags = 0); - UI_Interaction UIBeginPanel(const char* str, Vec4 rect, u32 extraFlags = 0); + UI_Interaction UIBeginPanel(const char* str, SizeKind sizeKindX, float xValue, SizeKind sizeKindY, float yValue, u32 extraFlags = 0); void UIEndPanel(); diff --git a/Lumos/Source/Lumos/ImGui/ImGuiUtilities.cpp b/Lumos/Source/Lumos/ImGui/ImGuiUtilities.cpp index 5f6e6683..dd7a296c 100644 --- a/Lumos/Source/Lumos/ImGui/ImGuiUtilities.cpp +++ b/Lumos/Source/Lumos/ImGui/ImGuiUtilities.cpp @@ -30,7 +30,7 @@ namespace Lumos const char* ImGuiUtilities::GenerateID() { - stbsp_sprintf(s_IDBuffer + 2, "%x", s_Counter++); + stbsp_sprintf(s_IDBuffer + 2, "%x", s_Counter++); //_itoa(s_Counter++, s_IDBuffer + 2, 16); return s_IDBuffer; } diff --git a/Lumos/Source/Lumos/Maths/MathsUtilities.cpp b/Lumos/Source/Lumos/Maths/MathsUtilities.cpp index 1e499a54..b3de688f 100644 --- a/Lumos/Source/Lumos/Maths/MathsUtilities.cpp +++ b/Lumos/Source/Lumos/Maths/MathsUtilities.cpp @@ -13,7 +13,7 @@ namespace Lumos::Maths { return !(value & (value - 1)); } - + /// Round up to next power of two. unsigned NextPowerOfTwo(unsigned value) { @@ -26,7 +26,7 @@ namespace Lumos::Maths value |= value >> 16u; return ++value; } - + /// Round up or down to the closest power of two. unsigned ClosestPowerOfTwo(unsigned value) { @@ -34,7 +34,7 @@ namespace Lumos::Maths unsigned prev = next >> (unsigned)1; return (value - prev) > (next - value) ? next : prev; } - + /// Return log base two or the MSB position of the given value. unsigned LogBaseTwo(unsigned value) { @@ -44,7 +44,7 @@ namespace Lumos::Maths ++ret; return ret; } - + /// Count the number of set bits in a mask. unsigned CountSetBits(unsigned value) { @@ -54,13 +54,13 @@ namespace Lumos::Maths value &= value - 1; return count; } - + /// Update a hash with the given 8-bit value using the SDBM algorithm. constexpr unsigned SDBMHash(unsigned hash, unsigned char c) { return c + (hash << 6u) + (hash << 16u) - hash; } - + /// Convert float to half float unsigned short FloatToHalf(float value) { @@ -68,42 +68,42 @@ namespace Lumos::Maths unsigned t1 = inu & 0x7fffffffu; // Non-sign bits unsigned t2 = inu & 0x80000000u; // Sign bit unsigned t3 = inu & 0x7f800000u; // Exponent - + t1 >>= 13; // Align mantissa on MSB t2 >>= 16; // Shift sign bit into position - + t1 -= 0x1c000; // Adjust bias - + t1 = (t3 < 0x38800000) ? 0 : t1; // Flush-to-zero t1 = (t3 > 0x47000000) ? 0x7bff : t1; // Clamp-to-max t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero - + t1 |= t2; // Re-insert sign bit - + return (unsigned short)t1; } - + /// Convert half float to float float HalfToFloat(unsigned short value) { unsigned t1 = value & 0x7fffu; // Non-sign bits unsigned t2 = value & 0x8000u; // Sign bit unsigned t3 = value & 0x7c00u; // Exponent - + t1 <<= 13; // Align mantissa on MSB t2 <<= 16; // Shift sign bit into position - + t1 += 0x38000000; // Adjust bias - + t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero - + t1 |= t2; // Re-insert sign bit - + float out; *((unsigned*)&out) = t1; return out; } - + void SinCos(float angle, float& sin, float& cos) { float angleRadians = angle * M_DEGTORAD; @@ -116,7 +116,7 @@ namespace Lumos::Maths cos = cosf(angleRadians); #endif } - + uint32_t nChoosek(uint32_t n, uint32_t k) { if(k > n) @@ -125,7 +125,7 @@ namespace Lumos::Maths k = n - k; if(k == 0) return 1; - + uint32_t result = n; for(uint32_t i = 2; i <= k; ++i) { @@ -134,35 +134,35 @@ namespace Lumos::Maths } return result; } - + Vec3 ComputeClosestPointOnSegment(const Vec3& segPointA, const Vec3& segPointB, const Vec3& pointC) { const Vec3 ab = segPointB - segPointA; - + float abLengthSquare = Maths::Length2(ab); - + // If the segment has almost zero length if(abLengthSquare < M_EPSILON) { // Return one end-point of the segment as the closest point return segPointA; } - + // Project point C onto "AB" line float t = Maths::Dot((pointC - segPointA), ab) / abLengthSquare; - + // If projected point onto the line is outside the segment, clamp it to the segment t = Clamp(t, 0.0f, 1.0f); - + // Return the closest point on the segment return segPointA + t * ab; } - + void ClosestPointBetweenTwoSegments(const Vec3& seg1PointA, const Vec3& seg1PointB, const Vec3& seg2PointA, const Vec3& seg2PointB, Vec3& closestPointSeg1, Vec3& closestPointSeg2) { - + const Vec3 d1 = seg1PointB - seg1PointA; const Vec3 d2 = seg2PointB - seg2PointA; const Vec3 r = seg1PointA - seg2PointA; @@ -170,7 +170,7 @@ namespace Lumos::Maths float e = Maths::Length2(d2); float f = Maths::Dot(d2, r); float s, t; - + // If both segments degenerate into points if(a <= M_EPSILON && e <= M_EPSILON) { @@ -180,21 +180,21 @@ namespace Lumos::Maths } if(a <= M_EPSILON) { // If first segment degenerates into a point - + s = 0.0f; - + // Compute the closest point on second segment t = Maths::Clamp(f / e, 0.0f, 1.0f); } else { - + float c = Maths::Dot(d1, r); - + // If the second segment degenerates into a point if(e <= M_EPSILON) { - + t = 0.0f; s = Clamp(-c / a, 0.0f, 1.0f); } @@ -202,26 +202,26 @@ namespace Lumos::Maths { float b = Maths::Dot(d1, d2); float denom = a * e - b * b; - + // If the segments are not parallel if(denom != 0.0f) { - + // Compute the closest point on line 1 to line 2 and // clamp to first segment. s = Clamp((b * f - c * e) / denom, 0.0f, 1.0f); } else { - + // Pick an arbitrary point on first segment s = 0.0f; } - + // Compute the point on line 2 closest to the closest point // we have just found t = (b * s + f) / e; - + // If this closest point is inside second segment (t in [0, 1]), we are done. // Otherwise, we clamp the point to the second segment and compute again the // closest point on segment 1 @@ -237,17 +237,17 @@ namespace Lumos::Maths } } } - + // Compute the closest points on both segments closestPointSeg1 = seg1PointA + d1 * s; closestPointSeg2 = seg2PointA + d2 * t; } - + bool AreVectorsParallel(const Vec3& v1, const Vec3& v2) { return v1.Cross(v2).LengthSquared() < M_EPSILON; } - + Vec2 WorldToScreen(const Vec3& worldPos, const Mat4& mvp, float width, float height, float winPosX, float winPosY) { Vec4 trans = mvp * Vec4(worldPos, 1.0f); @@ -260,43 +260,43 @@ namespace Lumos::Maths trans.y += winPosY; return Vec2(trans.x, trans.y); } - + void SetScale(Mat4& transform, float scale) { transform.SetScaling(Vector3(scale)); } - + void SetScale(Mat4& transform, const Vec3& scale) { transform.SetScaling(scale); } - + void SetRotation(Mat4& transform, const Vec3& rotation) { LERROR("ERROR SetRotation"); // transform.SetRotation(Quaternion(rotation.x, rotation.y, rotation.z)); } - + void SetTranslation(Mat4& transform, const Vec3& translation) { transform.SetTranslation(translation); } - + Mat4 ToMat4(const Quat& quat) { return quat.ToMatrix4(); } - + Vec3 GetScale(const Mat4& transform) { return transform.Scale(); } - + Vec3 GetRotation(const Mat4& transform) { return transform.Rotation().ToEuler(); } - + Mat4 Mat4FromTRS(const Vec3& translation, const Vec3& rotation, const Vec3& scale) { Mat4 transform = Mat4(); @@ -305,132 +305,132 @@ namespace Lumos::Maths SetTranslation(transform, translation); return transform; } - + Vec3 Cross(const Vec3& a, const Vec3& b) { return a.Cross(b); } - + float Dot(const Vec3& a, const Vec3& b) { return a.Dot(b); } - + float Length(const Vec2& vec) { return vec.Length(); } - + float Length(const Vec3& vec) { return vec.Length(); } - + float Length2(const Vec3& vec) { return vec.LengthSquared(); } - + float Distance(const Vec2& a, const Vec2& b) { return (a - b).Length(); } - + float Distance2(const Vec2& a, const Vec2& b) { return (a - b).LengthSquared(); } - + float Distance(const Vec3& a, const Vec3& b) { return (a - b).Length(); } - + float Distance2(const Vec3& a, const Vec3& b) { return (a - b).LengthSquared(); } - + float Distance(const Vec4& a, const Vec4& b) { return (a - b).Length(); } - + float Distance2(const Vec4& a, const Vec4& b) { return (a - b).LengthSquared(); } - + float* ValuePtr(Vec2& vec) { return &vec.x; } - + float* ValuePtr(Vec3& vec) { return &vec.x; } - + float* ValuePtr(Vec4& vec) { return &vec.x; } - + float* ValuePtr(Quat& quat) { return &quat.x; } - + float* ValuePtr(Mat3& mat) { return mat.values; } - + float* ValuePtr(Mat4& mat) { return mat.values; } - + const float* ValuePtr(const Vec2& vec) { return &vec.x; } - + const float* ValuePtr(const Vec3& vec) { return &vec.x; } - + const float* ValuePtr(const Vec4& vec) { return &vec.x; } - + const float* ValuePtr(const Quat& quat) { return &quat.x; } - + const float* ValuePtr(const Mat3& mat) { return mat.values; } - + const float* ValuePtr(const Mat4& mat) { return mat.values; } - + Matrix3 Transpose(const Mat3& mat) { return Matrix3::Transpose(mat); } - + Matrix4 Transpose(const Mat4& mat) { return mat.Transpose(); } - + #define ENABLE_MATHS_TEST 0 #if ENABLE_MATHS_TEST #define GIVEN(x) LINFO(x); @@ -438,35 +438,35 @@ namespace Lumos::Maths #define THEN(x) LINFO(x); #define AND_THEN(x) LINFO(x); #define CHECK(x) \ -if(x) \ -{ \ -LINFO("SUCCESS"); \ -} \ -else \ -{ \ -LERROR("FAIL"); \ -LERROR(#x); \ -ASSERT(false); \ -} + if(x) \ + { \ + LINFO("SUCCESS"); \ + } \ + else \ + { \ + LERROR("FAIL"); \ + LERROR(#x); \ + ASSERT(false); \ + } #define REQUIRE(x) \ -if(x) \ -{ \ -LINFO("SUCCESS"); \ -} \ -else \ -{ \ -LERROR("FAIL"); \ -LERROR(#x); \ -ASSERT(false); \ -} + if(x) \ + { \ + LINFO("SUCCESS"); \ + } \ + else \ + { \ + LERROR("FAIL"); \ + LERROR(#x); \ + ASSERT(false); \ + } #define Approx(x) x; #endif - + void TestMaths() { #if ENABLE_MATHS_TEST LINFO("Running Maths Tests"); - + { { float const R(1.0f); @@ -474,184 +474,184 @@ ASSERT(false); \ float const T(3.0f); float const U(4.0f); Vector4 const O(1.0f, 2.0f, 3.0f, 4.0f); - + Vector4 const A(R); Vector4 const B(1.0f); REQUIRE(A == B); - + Vector4 const C(R, S, T, U); REQUIRE(C == O); - + Vector4 const D(R, 2.0f, 3.0f, 4.0f); REQUIRE(D == O); - + Vector4 const E(1.0f, S, 3.0f, 4.0f); REQUIRE(E == O); - + Vector4 const F(R, S, 3.0f, 4.0f); REQUIRE(F == O); - + Vector4 const G(1.0f, 2.0f, T, 4.0f); REQUIRE(G == O); - + Vector4 const H(R, 2.0f, T, 4.0f); REQUIRE(H == O); - + Vector4 const I(1.0f, S, T, 4.0f); REQUIRE(I == O); - + Vector4 const J(R, S, T, 4.0f); REQUIRE(J == O); - + Vector4 const K(R, 2.0f, 3.0f, U); REQUIRE(K == O); - + Vector4 const L(1.0f, S, 3.0f, U); REQUIRE(L == O); - + Vector4 const M(R, S, 3.0f, U); REQUIRE(M == O); - + Vector4 const N(1.0f, 2.0f, T, U); REQUIRE(N == O); - + Vector4 const P(R, 2.0f, T, U); REQUIRE(P == O); - + Vector4 const Q(1.0f, S, T, U); REQUIRE(Q == O); - + Vector4 const V(R, S, T, U); REQUIRE(V == O); } - + { float const R(1.0f); double const S(2.0); float const T(3.0); double const U(4.0); Vector4 const O(1.0f, 2.0, 3.0f, 4.0); - + Vector4 const A(R); Vector4 const B(1.0); REQUIRE(A == B); - + Vector4 const C(R, S, T, U); REQUIRE(C == O); - + Vector4 const D(R, 2.0f, 3.0, 4.0f); REQUIRE(D == O); - + Vector4 const E(1.0, S, 3.0f, 4.0); REQUIRE(E == O); - + Vector4 const F(R, S, 3.0, 4.0f); REQUIRE(F == O); - + Vector4 const G(1.0f, 2.0, T, 4.0); REQUIRE(G == O); - + Vector4 const H(R, 2.0, T, 4.0); REQUIRE(H == O); - + Vector4 const I(1.0, S, T, 4.0f); REQUIRE(I == O); - + Vector4 const J(R, S, T, 4.0f); REQUIRE(J == O); - + Vector4 const K(R, 2.0f, 3.0, U); REQUIRE(K == O); - + Vector4 const L(1.0f, S, 3.0, U); REQUIRE(L == O); - + Vector4 const M(R, S, 3.0, U); REQUIRE(M == O); - + Vector4 const N(1.0f, 2.0, T, U); REQUIRE(N == O); - + Vector4 const P(R, 2.0, T, U); REQUIRE(P == O); - + Vector4 const Q(1.0f, S, T, U); REQUIRE(Q == O); - + Vector4 const V(R, S, T, U); REQUIRE(V == O); } - + { float const v1_0(1.0f); float const v1_1(2.0f); float const v1_2(3.0f); float const v1_3(4.0f); - + Vector2 const v2_0(1.0f, 2.0f); Vector2 const v2_1(2.0f, 3.0f); Vector2 const v2_2(3.0f, 4.0f); - + Vector3 const v3_0(1.0f, 2.0f, 3.0f); Vector3 const v3_1(2.0f, 3.0f, 4.0f); - + Vector4 const O(1.0f, 2.0f, 3.0f, 4.0f); - + Vector4 const A(v1_0, v1_1, v2_2); REQUIRE(A == O); - + Vector4 const B(1.0f, 2.0f, v2_2); REQUIRE(B == O); - + Vector4 const C(v1_0, 2.0f, v2_2); REQUIRE(C == O); - + Vector4 const D(1.0f, v1_1, v2_2); REQUIRE(D == O); - + Vector4 const E(v2_0, v1_2, v1_3); REQUIRE(E == O); - + Vector4 const F(v2_0, 3.0, v1_3); REQUIRE(F == O); - + Vector4 const G(v2_0, v1_2, 4.0); REQUIRE(G == O); - + Vector4 const H(v2_0, 3.0f, 4.0); REQUIRE(H == O); } - + { float const v1_0(1.0f); float const v1_1(2.0f); float const v1_2(3.0f); float const v1_3(4.0f); - + Vector2 const v2(2.0f, 3.0f); - + Vector4 const O(1.0f, 2.0, 3.0f, 4.0); - + Vector4 const A(v1_0, v2, v1_3); REQUIRE(A == O); - + Vector4 const B(v1_0, v2, 4.0); REQUIRE(B == O); - + Vector4 const C(1.0, v2, v1_3); REQUIRE(C == O); - + Vector4 const D(1.0f, v2, 4.0); REQUIRE(D == O); - + Vector4 const E(1.0, v2, 4.0f); REQUIRE(E == O); } - + { Vector4 const A(1.0f, 2.0f, 3.0f, 4.0f); Vector4 const B(4.0f, 5.0f, 6.0f, 7.0f); - + Vector4 const C = A + B; Vector4 const D = B - A; Vector4 const E = A * B; @@ -664,7 +664,7 @@ ASSERT(false); \ Vector4 const L = 1.0f - B; Vector4 const M = 2.0f * A; Vector4 const N = 2.0f / B; - + REQUIRE(C == Vector4(5, 7, 9, 11)); REQUIRE(D == Vector4(3, 3, 3, 3)); REQUIRE(E == Vector4(4, 10, 18, 28)); @@ -679,7 +679,7 @@ ASSERT(false); \ REQUIRE(N == Vector4(0.5f, 2.0f / 5.0f, 2.0f / 6.0f, 2.0f / 7.0f)); } } - + GIVEN("Default quaternion") { WHEN("We convert to a Matrix4") @@ -692,12 +692,12 @@ ASSERT(false); \ } } } - + { Maths::Quaternion firstQuaternion = Maths::Quaternion::AxisAngleToQuaterion(Vector3(1.0f, 0.0f, 0.0f), 180.f); Maths::Quaternion secondQuaternion(1.f, 0.f, 0.f, 0.f); secondQuaternion.GenerateW(); - + { REQUIRE(Maths::Equals(firstQuaternion, secondQuaternion)); REQUIRE(Maths::Equals(firstQuaternion, secondQuaternion.Normalised())); @@ -705,16 +705,16 @@ ASSERT(false); \ REQUIRE(Maths::Equals(firstQuaternion.Dot(secondQuaternion), 1.f)); } } - + GIVEN("The four unit quaternions") { Maths::Quaternion w(0.f, 0.f, 0.f, 1.f); Maths::Quaternion x(1.f, 0.f, 0.f, 0.f); Maths::Quaternion y(0.f, 1.f, 0.f, 0.f); Maths::Quaternion z(0.f, 0.f, 1.f, 0.f); - + Maths::Quaternion xyzw = x * y * z * w; - + WHEN("We ask for the norm") { THEN("They are all equal to 1") @@ -726,7 +726,7 @@ ASSERT(false); \ REQUIRE(Maths::Equals(xyzw.Magnitude(), 1.0f)); } } - + WHEN("We multiply them") { THEN("Results should follow") @@ -735,12 +735,12 @@ ASSERT(false); \ Maths::Quaternion oppositeOfX = x.Conjugate(); Maths::Quaternion oppositeOfY = y.Conjugate(); Maths::Quaternion oppositeOfZ = z.Conjugate(); - + REQUIRE(Maths::Equals((x * x), (oppositeOfW))); REQUIRE(Maths::Equals((y * y), (oppositeOfW))); REQUIRE(Maths::Equals((z * z), (oppositeOfW))); REQUIRE(Maths::Equals((x * y * z), (oppositeOfW))); - + REQUIRE(Maths::Equals((x * y), z)); REQUIRE(Maths::Equals((y * x), oppositeOfZ)); REQUIRE(Maths::Equals((y * z), x)); @@ -750,15 +750,15 @@ ASSERT(false); \ } } } - + GIVEN("Two different quaternions (10, (1, 0, 0) and (20, (1, 0, 0))") { Maths::Quaternion x10 = Maths::Quaternion::AxisAngleToQuaterion(Vector3(1.0f, 0.0f, 0.0f), (10.f)); Maths::Quaternion x20 = x10 * x10; - + Maths::Quaternion x30a = x10 * x20; Maths::Quaternion x30b = x20 * x10; - + WHEN("We multiply them") { THEN("These results are expected") @@ -767,13 +767,13 @@ ASSERT(false); \ REQUIRE(Maths::Equals(x30a, x30b)); } } - + WHEN("Convert euler to quaternion") { Maths::Quaternion X45(Vector3((45.f), 0.f, 0.f)); Maths::Quaternion Y45(Vector3(0.f, (45.f), 0.f)); Maths::Quaternion Z45(Vector3(0.f, 0.f, (45.f))); - + THEN("They must be equal") { REQUIRE(Maths::Equals(X45, Maths::Quaternion(0.38268346f, 0.f, 0.f, 0.9238795f))); @@ -781,20 +781,20 @@ ASSERT(false); \ REQUIRE(Maths::Equals(Z45, Maths::Quaternion(0.f, 0.f, 0.38268346f, 0.9238795f))); } } - + WHEN("We convert to euler angles and then to quaternions") { THEN("These results are expected") { REQUIRE(Maths::Equals(x30a.ToEuler(), x30b.ToEuler())); REQUIRE(Maths::Equals(Maths::Quaternion(x30a.ToEuler()), Maths::Quaternion(x30b.ToEuler()))); - + Maths::Quaternion tmp(1.f, 1.f, 0.f, 0.f); tmp.Normalise(); REQUIRE(Maths::Equals(tmp, Maths::Quaternion(tmp.ToEuler()))); } } - + WHEN("We slerp") { THEN("The half of 10 and 30 is 20") @@ -812,18 +812,18 @@ ASSERT(false); \ REQUIRE(Maths::Equals(Maths::Quaternion::Slerp(x10, x30a, 0.f), x10)); REQUIRE(Maths::Equals(Maths::Quaternion::Slerp(x10, x30a, 1.f), x30a)); } - + AND_THEN("The half of 45 is 22.5") { Maths::Quaternion quaternionA = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 0.0f, 1.0f), (0.f)); Maths::Quaternion quaternionB = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 0.0f, 1.0f), (45.f)); Maths::Quaternion quaternionC = Maths::Quaternion::Slerp(quaternionA, quaternionB, 0.5f); - + Maths::Quaternion unitZ225 = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 0.0f, 1.0f), (22.5f)); REQUIRE(Maths::Equals(quaternionC, unitZ225)); } } - + WHEN("We get the rotation between two vectors") { THEN("The rotation in right-handed is 90 degree on z") @@ -834,49 +834,49 @@ ASSERT(false); \ rotation90Z.Normalise(); REQUIRE(Maths::Equals(rotation90Z, rotationBetweenXY)); } - + THEN("The rotation in right-handed is 90 degree on y") { Maths::Quaternion rotationBetweenXZ = Maths::Quaternion::FromVectors(Vector3(1.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f)); Maths::Quaternion rotation90Y = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 1.0f, 0.0f), (90.f)); REQUIRE(Maths::Equals(rotation90Y, rotationBetweenXZ)); } - + THEN("The rotation in right-handed is 90 degree on x") { Maths::Quaternion rotationBetweenYZ = Maths::Quaternion::FromVectors(Vector3(0.0f, 1.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f)); Maths::Quaternion rotation90X = Maths::Quaternion::AxisAngleToQuaterion(Vector3(1.0f, 0.0f, 0.0f), -(90.f)); REQUIRE(Maths::Equals(rotation90X, rotationBetweenYZ)); } - + THEN("The rotation in right-handed is 90 degree on y with non-unit vectors") { Vector3 origin(1.f, 1.f, 0.f); Vector3 extremity(-1.f, 1.f, 0.f); Maths::Quaternion rotation = Maths::Quaternion::FromVectors(origin, extremity); - + Maths::Quaternion::RotatePointByQuaternion(rotation, origin); REQUIRE(Maths::Equals(origin, extremity)); } } } - + GIVEN("Different angles") { Maths::Quaternion rotation90X(0.707f, 0.f, 0.f, 0.707f); Maths::Quaternion rotation90Y(0.f, 0.707f, 0.f, 0.707f); Maths::Quaternion rotation90Z(0.f, 0.f, 0.707f, 0.707f); - + Maths::Quaternion rotation180X(1.f, 0.f, 0.f, 0.f); Maths::Quaternion rotation180Y(0.f, 1.f, 0.f, 0.f); Maths::Quaternion rotation180Z(0.f, 0.f, 1.f, 0.f); - + Maths::Quaternion rotation270X(0.707f, 0.f, 0.f, -0.707f); Maths::Quaternion rotation270Y(0.f, 0.707f, 0.f, -0.707f); Maths::Quaternion rotation270Z(0.f, 0.f, 0.707f, -0.707f); - + Maths::Quaternion special(0.006f, 0.006f, 0.707f, 0.707f); - + WHEN("We convert them to euler angles") { THEN("Those are equal to") @@ -884,120 +884,120 @@ ASSERT(false); \ CHECK(Maths::Equals(rotation90X.ToEuler().x, (90.f), 1.0f)); CHECK(Maths::Equals(rotation90Y.ToEuler().y, (90.f), 2.0f)); CHECK(Maths::Equals(rotation90Z.ToEuler().z, (90.f), 1.0f)); - + CHECK(Maths::Equals(rotation180X.ToEuler(), (Vector3(180.f, 0.f, 0.f)))); CHECK(Maths::Equals(rotation180Y.ToEuler(), (Vector3(180.f, 0.f, 180.f)))); CHECK(Maths::Equals(rotation180Z.ToEuler(), (Vector3(0.f, 0.f, 180.f)))); - + CHECK(Maths::Equals(rotation270X.ToEuler().x, (-90.f), 1.0f)); CHECK(Maths::Equals(rotation270Y.ToEuler().y, (-90.f), 2.0f)); CHECK(Maths::Equals(rotation270Z.ToEuler().z, (-90.f), 1.0f)); - + CHECK(Maths::Equals(special.ToEuler().x, (0.f), 1.0f)); CHECK(Maths::Equals(special.ToEuler().y, (1.f), 2.0f)); CHECK(Maths::Equals(special.ToEuler().z, (90.f), 1.0f)); } } } - + { Matrix3 a, b, c; a.RotationX(Maths::M_PI / 2.0f * Maths::M_RADTODEG); b.RotationZ(50); c = a * b; - + Vector3 u = Vector3(1.0f); Vector3 v = c * u; - + Maths::Quaternion q = Maths::Quaternion::FromMatrix(c); Matrix3 m = q.ToMatrix3(); - + Vector3 w = m * u; - + REQUIRE(v == w); } - + { Matrix4 a, b, c; a.RotationY(83); b.RotationX(122); c = a * b; - + Vector4 u = Vector4(1.0f); Vector4 v = c * u; - + Maths::Quaternion q = Maths::Quaternion::FromMatrix(c); Matrix4 m = q.ToMatrix4(); - + Vector4 w = m * u; - + REQUIRE(w == v); } - + { Maths::Quaternion q = Maths::Quaternion::AxisAngleToQuaterion(Vector3(1.0f, 0.0f, 0.0f), Maths::M_PI * Maths::M_RADTODEG); - + Matrix4 m = q.ToMatrix4(); - + Vector4 v = Vector4(0.0f, 1.0f, 0.0f, 1.0f); v = m * v; - + REQUIRE(v.Equals(Vector4(0.0f, -1.0f, 0.0f, 1.0f))); } - + { Maths::Quaternion q = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 1.0f, 0.0f), Maths::M_PI * Maths::M_RADTODEG); - + Matrix4 m = q.ToMatrix4(); - + Vector4 v = Vector4(0.0f, 0.0f, -1.0f, 1.0f); // Forward v = m * v; - + REQUIRE(v.Equals(Vector4(0.0f, 0.0f, 1.0f, 1.0f))); } - + { Maths::Quaternion q = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 0.0f, -1.0f), Maths::M_PI * Maths::M_RADTODEG); - + Matrix4 m = q.ToMatrix4(); - + Vector4 v = Vector4(1.0f, 0.0f, 0.0f, 1.0f); v = m * v; - + REQUIRE(v.Equals(Vector4(-1.0f, 0.0f, 0.0f, 1.0f))); } - + { Matrix3 m = Matrix3::RotationX(Maths::M_PI / 2.0f * Maths::M_RADTODEG); Maths::Quaternion q = Maths::Quaternion::FromMatrix(m); - + Vector3 u = Vector3(1.0f); Vector3 v = m * u; - + Matrix3 n = q.ToMatrix3(); - + Vector3 w = n * u; - + REQUIRE(Maths::Equals(v, w)); } - + { Maths::Quaternion q = Maths::Quaternion::AxisAngleToQuaterion(Vector3(1.0f, 0.0f, 0.0f), -Maths::M_PI / 2.0f * Maths::M_RADTODEG); Maths::Quaternion r = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 1.0f, 0.0f), -40.0f); Maths::Quaternion t = Maths::Quaternion::AxisAngleToQuaterion(Vector3(0.0f, 0.0f, -1.0f), -310.0f); - + Maths::Quaternion k = q * r * t; - + Vector4 v = Vector4(1.0f); Matrix4 m = k.ToMatrix4(); v = m * v; - + REQUIRE(v.Equals(Vector4(0.436440f, 1.671624f, 0.123257f, 1.0f))); } - + #endif } - + float SineOut(float time) { return Maths::Sin(time * 90.0f); @@ -1010,17 +1010,17 @@ ASSERT(false); \ { return -0.5f * (Maths::Cos(180.0f * time) - 1.0f); } - + float ExponentialOut(float time) { return time == 1.0f ? 1.0f : -Maths::Pow(2.0f, -10.0f * time / 1.0f) + 1.0f; } - + float ExponentialIn(float time) { return time == 0.0f ? 0.0f : Pow(2.0f, 10.0f * (time / 1.0f - 1.0f)) - 1.0f * 0.001f; } - + float ExponentialInOut(float time) { time /= 0.5f; @@ -1028,43 +1028,43 @@ ASSERT(false); \ return 0.5f * (float)Pow(2.0f, 10.0f * (time - 1.0f)); return 0.5f * (-(float)Pow(2.0f, -10.0f * (time - 1.0f)) + 2.0f); } - + float ElasticIn(float time, float period) { if(time == 0 || time == 1) return time; - + auto s = period / 4.0f; time = time - 1; return -(Maths::Pow(2, 10 * time) * Sin((time - s) * 180.0f * 2.0f / period)); } - + float ElasticOut(float time, float period) { if(time == 0 || time == 1) return time; - + auto s = period * 0.25f; return (Maths::Pow(2, -10 * time) * Maths::Sin((time - s) * 180.0f * 2.0f / period) + 1); } - + float ElasticInOut(float time, float period) { if(time == 0 || time == 1) return time; - + time = time * 2; if(period == 0) period = 0.3f * 1.5f; - + auto s = period / 4.0f; - + time = time - 1; if(time < 0) return (float)(-0.5f * Maths::Pow(2, 10 * time) * Maths::Sin((time - s) * 360.0f / period)); return (float)(Maths::Pow(2, -10 * time) * Maths::Sin((time - s) * 360.0f / period) * 0.5f + 1); } - + bool AnimateToTarget(float* value, float target, float delta_t, float rate) { *value += (target - *value) * (1.0f - Pow(2.0f, -rate * delta_t)); @@ -1073,25 +1073,25 @@ ASSERT(false); \ *value = target; return true; // reached } - + return false; } - + void Print(const Vector3& vec) { LINFO("%.2f, %.2f, %.2f", vec.x, vec.y, vec.z); } - + void Print(const Vector4& vec) { LINFO("%.2f, %.2f, %.2f, %.2f", vec.x, vec.y, vec.z, vec.w); } - + void Print(const Quaternion& vec) { LINFO("%.2f, %.2f, %.2f, %.2f", vec.x, vec.y, vec.z, vec.w); } - + void Print(const Matrix4& mat) { LINFO("------------------------"); diff --git a/Lumos/Source/Lumos/Maths/Vector4.cpp b/Lumos/Source/Lumos/Maths/Vector4.cpp index 94859253..48c7515e 100644 --- a/Lumos/Source/Lumos/Maths/Vector4.cpp +++ b/Lumos/Source/Lumos/Maths/Vector4.cpp @@ -73,12 +73,12 @@ namespace Lumos bool Vector4::Equals(const Vector4& rhs) const { return Maths::Equals(x, rhs.x) && Maths::Equals(y, rhs.y) && Maths::Equals(z, rhs.z) && Maths::Equals(w, rhs.w); - } - + } + Vector4 Vector4::Lerp(const Vector4& rhs, float t) { return Vector4(Maths::Lerp(x, rhs.x, t), Maths::Lerp(y, rhs.y, t), Maths::Lerp(z, rhs.z, t), Maths::Lerp(w, rhs.w, t)); - } + } bool Vector4::IsValid() const { diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.cpp b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.cpp index b617615c..3cd3da6a 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.cpp +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.cpp @@ -6,14 +6,14 @@ namespace Lumos { - static inline Vec4 MakeRGBA8( b2HexColor c, float alpha ) - { - return { static_cast(uint8_t( ( c >> 16 ) & 0xFF )), static_cast(uint8_t( ( c >> 8 ) & 0xFF )), static_cast(uint8_t( c & 0xFF )), static_cast(uint8_t( 0xFF * alpha )) }; - } + static inline Vec4 MakeRGBA8(b2HexColor c, float alpha) + { + return { static_cast(uint8_t((c >> 16) & 0xFF)), static_cast(uint8_t((c >> 8) & 0xFF)), static_cast(uint8_t(c & 0xFF)), static_cast(uint8_t(0xFF * alpha)) }; + } void B2DebugDraw::DrawPolygon(const b2Vec2* vertices, int vertexCount, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); b2Vec2 p1 = vertices[vertexCount - 1]; for(int i = 0; i < vertexCount; ++i) @@ -25,9 +25,9 @@ namespace Lumos } // - void B2DebugDraw::DrawSolidPolygon(b2Transform xf,const b2Vec2* vertices, int vertexCount,float radius, b2HexColor hexColour, void* context) + void B2DebugDraw::DrawSolidPolygon(b2Transform xf, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); Vec4 fillColour(0.5f * colour.x, 0.5f * colour.y, 0.5f * colour.z, 0.5f); for(int i = 1; i < vertexCount - 1; ++i) @@ -51,13 +51,13 @@ namespace Lumos // void B2DebugDraw::DrawCircle(b2Vec2 center, float radius, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); const float k_segments = 16.0f; const float k_increment = 2.0f * b2_pi / k_segments; float sinInc = sinf(k_increment); float cosInc = cosf(k_increment); - b2Vec2 r1 = {1.0f, 0.0f}; - b2Vec2 v1 = center + radius * r1; + b2Vec2 r1 = { 1.0f, 0.0f }; + b2Vec2 v1 = center + radius * r1; for(int i = 0; i < k_segments; ++i) { // Perform rotation to avoid additional trigonometry. @@ -74,14 +74,14 @@ namespace Lumos // void B2DebugDraw::DrawSolidCircle(b2Transform xf, float radius, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); const float k_segments = 16.0f; const float k_increment = 2.0f * b2_pi / k_segments; float sinInc = sinf(k_increment); float cosInc = cosf(k_increment); - b2Vec2 v0 = b2TransformPoint(xf, { 0.0f, 0.0f }); - b2Vec2 r1 = {cosInc, sinInc}; - b2Vec2 v1 = v0 + radius * r1; + b2Vec2 v0 = b2TransformPoint(xf, { 0.0f, 0.0f }); + b2Vec2 r1 = { cosInc, sinInc }; + b2Vec2 v1 = v0 + radius * r1; Vec4 fillColour(0.5f * colour.x, 0.5f * colour.y, 0.5f * colour.z, 0.5f); for(int i = 0; i < k_segments; ++i) { @@ -95,7 +95,7 @@ namespace Lumos v1 = v2; } - r1 = { 1.0f, 0.0f }; + r1 = { 1.0f, 0.0f }; v1 = v0 + radius * r1; for(int i = 0; i < k_segments; ++i) { @@ -110,14 +110,14 @@ namespace Lumos } // Draw a line fixed in the circle to animate rotation. - //b2Vec2 p = v0 + radius * axis; - //DebugRenderer::DrawHairLine({ p.x, p.y, 0.0f }, { v0.x, v0.y, 0.0f }, false, { colour.x, colour.y, colour.z, colour.w }); + // b2Vec2 p = v0 + radius * axis; + // DebugRenderer::DrawHairLine({ p.x, p.y, 0.0f }, { v0.x, v0.y, 0.0f }, false, { colour.x, colour.y, colour.z, colour.w }); } // void B2DebugDraw::DrawSegment(b2Vec2 p1, b2Vec2 p2, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); DebugRenderer::DrawHairLine({ p1.x, p1.y, 0.0f }, { p2.x, p2.y, 0.0f }, false, { colour.x, colour.y, colour.z, colour.w }); } @@ -126,21 +126,21 @@ namespace Lumos { const float k_axisScale = 0.4f; Vec4 red(1.0f, 0.0f, 0.0f, 1.0f); - Vec4 green(0.0f, 1.0f, 0.0f, 1.0f); + Vec4 green(0.0f, 1.0f, 0.0f, 1.0f); b2Vec2 p1 = xf.p, p2; - // p2 = p1 + k_axisScale * xf.q.GetXAxis(); + // p2 = p1 + k_axisScale * xf.q.GetXAxis(); DebugRenderer::DrawHairLine({ p1.x, p1.y, 0.0f }, { p2.x, p2.y, 0.0f }, false, { red.x, red.y, red.z, red.w }); - // p2 = p1 + k_axisScale * xf.q.GetYAxis(); + // p2 = p1 + k_axisScale * xf.q.GetYAxis(); DebugRenderer::DrawHairLine({ p1.x, p1.y, 0.0f }, { p2.x, p2.y, 0.0f }, false, { green.x, green.y, green.z, green.w }); } // void B2DebugDraw::DrawPoint(b2Vec2 p, float size, b2HexColor hexColour, void* context) { - Vec4 colour = MakeRGBA8(hexColour, 0.8f); - DebugRenderer::DrawPoint({ p.x, p.y, 0.0f }, size * 0.1f, false, { colour.x, colour.y, colour.z, colour.w }); + Vec4 colour = MakeRGBA8(hexColour, 0.8f); + DebugRenderer::DrawPoint({ p.x, p.y, 0.0f }, size * 0.1f, false, { colour.x, colour.y, colour.z, colour.w }); } void B2DebugDraw::DrawString(b2Vec2 p, const char* s, void* context) diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.h b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.h index 404d9d03..5d5b2d75 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.h +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2DebugDraw.h @@ -5,28 +5,28 @@ namespace Lumos { -// class B2DebugDraw : public b2Draw -// { -// public: -// B2DebugDraw() = default; -// ~B2DebugDraw() = default; -// - namespace B2DebugDraw - { - void DrawPolygon(const b2Vec2* vertices, int vertexCount, b2HexColor colour, void* context); - void DrawSolidPolygon(b2Transform xf, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor colour, void* context); - void DrawCircle(b2Vec2 center, float radius, b2HexColor colour, void* context); - void DrawSolidCircle(b2Transform xf, float radius, b2HexColor colour, void* context); - void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2HexColor colour, void* context); - void DrawTransform(b2Transform xf, void* context); - void DrawPoint(b2Vec2 p, float size, b2HexColor colour, void* context); - void DrawString(b2Vec2 p, const char* s, void* context); - } -// -// void DrawString(int x, int y, const char* string, ...); -// -// void DrawString(b2Vec2 p, const char* string, ...); -// -// void DrawAABB(b2AABB* aabb, const b2Color& colour); -// }; + // class B2DebugDraw : public b2Draw + // { + // public: + // B2DebugDraw() = default; + // ~B2DebugDraw() = default; + // + namespace B2DebugDraw + { + void DrawPolygon(const b2Vec2* vertices, int vertexCount, b2HexColor colour, void* context); + void DrawSolidPolygon(b2Transform xf, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor colour, void* context); + void DrawCircle(b2Vec2 center, float radius, b2HexColor colour, void* context); + void DrawSolidCircle(b2Transform xf, float radius, b2HexColor colour, void* context); + void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2HexColor colour, void* context); + void DrawTransform(b2Transform xf, void* context); + void DrawPoint(b2Vec2 p, float size, b2HexColor colour, void* context); + void DrawString(b2Vec2 p, const char* s, void* context); + } + // + // void DrawString(int x, int y, const char* string, ...); + // + // void DrawString(b2Vec2 p, const char* string, ...); + // + // void DrawAABB(b2AABB* aabb, const b2Color& colour); + // }; } diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.cpp b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.cpp index 1a448c89..9fb82ee9 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.cpp +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.cpp @@ -24,36 +24,36 @@ namespace Lumos { m_DebugName = "Box2D Physics Engine"; - b2Vec2 gravity = { 0.0f, -9.81f }; - b2WorldDef worldDef = b2DefaultWorldDef(); - worldDef.gravity = gravity; - m_B2DWorld = b2CreateWorld(&worldDef); - - b2AABB bounds = { { -FLT_MAX, -FLT_MAX }, { FLT_MAX, FLT_MAX } }; - - m_DebugDraw = { B2DebugDraw::DrawPolygon, - B2DebugDraw::DrawSolidPolygon, - B2DebugDraw::DrawCircle, - B2DebugDraw::DrawSolidCircle, - 0,//capsule - 0,//solid capsule - B2DebugDraw::DrawSegment, - B2DebugDraw::DrawTransform, - B2DebugDraw::DrawPoint, - B2DebugDraw::DrawString, //Draw String - bounds, - true, // drawUsingBounds - true, // shapes - false, // joints - false, // joint extras - false, // aabbs - false, // mass - false, // contacts - false, // colors - false, // normals - false, // impulse - false, // friction - this }; + b2Vec2 gravity = { 0.0f, -9.81f }; + b2WorldDef worldDef = b2DefaultWorldDef(); + worldDef.gravity = gravity; + m_B2DWorld = b2CreateWorld(&worldDef); + + b2AABB bounds = { { -FLT_MAX, -FLT_MAX }, { FLT_MAX, FLT_MAX } }; + + m_DebugDraw = { B2DebugDraw::DrawPolygon, + B2DebugDraw::DrawSolidPolygon, + B2DebugDraw::DrawCircle, + B2DebugDraw::DrawSolidCircle, + 0, // capsule + 0, // solid capsule + B2DebugDraw::DrawSegment, + B2DebugDraw::DrawTransform, + B2DebugDraw::DrawPoint, + B2DebugDraw::DrawString, // Draw String + bounds, + true, // drawUsingBounds + true, // shapes + false, // joints + false, // joint extras + false, // aabbs + false, // mass + false, // contacts + false, // colors + false, // normals + false, // impulse + false, // friction + this }; } B2PhysicsEngine::~B2PhysicsEngine() @@ -71,24 +71,24 @@ namespace Lumos if(!m_Paused) { - b2World_Step(m_B2DWorld, (float)timeStep.GetSeconds(), 4); + b2World_Step(m_B2DWorld, (float)timeStep.GetSeconds(), 4); b2ContactEvents contactEvents = b2World_GetContactEvents(m_B2DWorld); - for (int i = 0; i < contactEvents.beginCount; ++i) + for(int i = 0; i < contactEvents.beginCount; ++i) { b2ContactBeginTouchEvent event = contactEvents.beginEvents[i]; - b2BodyId bodyIdA = b2Shape_GetBody(event.shapeIdA); - b2BodyId bodyIdB = b2Shape_GetBody(event.shapeIdB); + b2BodyId bodyIdA = b2Shape_GetBody(event.shapeIdA); + b2BodyId bodyIdB = b2Shape_GetBody(event.shapeIdB); ContactCallback* callbackA = (ContactCallback*)b2Body_GetUserData(bodyIdA); - if (callbackA) + if(callbackA) { - callbackA->OnCollision(bodyIdA, bodyIdB, 1.0f);//event.approachSpeed); + callbackA->OnCollision(bodyIdA, bodyIdB, 1.0f); // event.approachSpeed); } ContactCallback* callbackB = (ContactCallback*)b2Body_GetUserData(bodyIdB); - if (callbackB) + if(callbackB) { - callbackB->OnCollision(bodyIdB, bodyIdA, 1.0f);//event.approachSpeed); + callbackB->OnCollision(bodyIdB, bodyIdA, 1.0f); // event.approachSpeed); } } } @@ -114,8 +114,8 @@ namespace Lumos ImGui::TextUnformatted("Number Of Rigid Bodys"); ImGui::NextColumn(); ImGui::PushItemWidth(-1); - - //ImGui::Text("%5.2i", m_B2DWorld->GetBodyCount()); + + // ImGui::Text("%5.2i", m_B2DWorld->GetBodyCount()); ImGui::PopItemWidth(); ImGui::NextColumn(); @@ -131,8 +131,8 @@ namespace Lumos ImGui::TextUnformatted("Gravity"); ImGui::NextColumn(); ImGui::PushItemWidth(-1); - // float grav[2] = { m_B2DWorld->GetGravity().x, m_B2DWorld->GetGravity().y }; - //if(ImGui::InputFloat2("##Gravity", grav)) + // float grav[2] = { m_B2DWorld->GetGravity().x, m_B2DWorld->GetGravity().y }; + // if(ImGui::InputFloat2("##Gravity", grav)) // m_B2DWorld->SetGravity({ grav[0], grav[1] }); ImGui::PopItemWidth(); ImGui::NextColumn(); @@ -144,8 +144,8 @@ namespace Lumos b2BodyId B2PhysicsEngine::CreateB2Body(b2BodyDef bodyDef) const { - b2BodyId bodyId = b2CreateBody(m_B2DWorld, &bodyDef); - return bodyId; + b2BodyId bodyId = b2CreateBody(m_B2DWorld, &bodyDef); + return bodyId; } void B2PhysicsEngine::OnDebugDraw() @@ -157,20 +157,20 @@ namespace Lumos void B2PhysicsEngine::SetDebugDrawFlags(uint32_t flags) { m_DebugDrawFlags = flags; - //m_DebugDraw.drawShapes = true; - m_DebugDraw.drawJoints = m_DebugDrawFlags & PhysicsDebugFlags2D::CONSTRAINT2D; - m_DebugDraw.drawJointExtras = m_DebugDrawFlags & PhysicsDebugFlags2D::CONSTRAINT2D; - m_DebugDraw.drawAABBs = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; - m_DebugDraw.drawMass = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; - m_DebugDraw.drawContacts = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; - m_DebugDraw.drawContactNormals = m_DebugDrawFlags & PhysicsDebugFlags2D::COLLISIONNORMALS2D; - m_DebugDraw.drawContactImpulses = m_DebugDrawFlags & PhysicsDebugFlags2D::MANIFOLD2D; + // m_DebugDraw.drawShapes = true; + m_DebugDraw.drawJoints = m_DebugDrawFlags & PhysicsDebugFlags2D::CONSTRAINT2D; + m_DebugDraw.drawJointExtras = m_DebugDrawFlags & PhysicsDebugFlags2D::CONSTRAINT2D; + m_DebugDraw.drawAABBs = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; + m_DebugDraw.drawMass = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; + m_DebugDraw.drawContacts = m_DebugDrawFlags & PhysicsDebugFlags2D::AABB2D; + m_DebugDraw.drawContactNormals = m_DebugDrawFlags & PhysicsDebugFlags2D::COLLISIONNORMALS2D; + m_DebugDraw.drawContactImpulses = m_DebugDrawFlags & PhysicsDebugFlags2D::MANIFOLD2D; m_DebugDraw.drawFrictionImpulses = m_DebugDrawFlags & PhysicsDebugFlags2D::MANIFOLD2D; } uint32_t B2PhysicsEngine::GetDebugDrawFlags() { - return m_DebugDrawFlags; + return m_DebugDrawFlags; } void B2PhysicsEngine::SetGravity(const Vec2& gravity) diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.h b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.h index 920d66ff..7aa85422 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.h +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/B2PhysicsEngine.h @@ -22,7 +22,7 @@ namespace Lumos struct ContactCallback { - virtual void OnCollision(b2BodyId a, b2BodyId b, float approachSpeed) { }; + virtual void OnCollision(b2BodyId a, b2BodyId b, float approachSpeed) {}; }; class LUMOS_EXPORT B2PhysicsEngine : public ISystem @@ -40,7 +40,7 @@ namespace Lumos b2WorldId GetB2World() const { return m_B2DWorld; } b2BodyId CreateB2Body(b2BodyDef bodyDef) const; - + void SetPaused(bool paused) { m_Paused = paused; } bool IsPaused() const { return m_Paused; } void OnDebugDraw() override; @@ -53,7 +53,7 @@ namespace Lumos private: b2WorldId m_B2DWorld; - b2DebugDraw m_DebugDraw; + b2DebugDraw m_DebugDraw; u32 m_DebugDrawFlags = 0; @@ -63,6 +63,6 @@ namespace Lumos int32_t m_VelocityIterations = 6; int32_t m_PositionIterations = 2; - //b2ContactListener* m_Listener; + // b2ContactListener* m_Listener; }; } diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.cpp b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.cpp index ccc7cbbd..aad9f9f2 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.cpp +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.cpp @@ -21,43 +21,43 @@ namespace Lumos RigidBody2D::~RigidBody2D() { - ASSERT(Application::Get().GetSystemManager() && Application::Get().GetSystem()); + ASSERT(Application::Get().GetSystemManager() && Application::Get().GetSystem()); ContactCallback* callback = (ContactCallback*)b2Body_GetUserData(m_B2Body); if(callback) delete callback; - b2DestroyBody(m_B2Body); + b2DestroyBody(m_B2Body); } void RigidBody2D::SetLinearVelocity(const Vec2& v) const { - b2Body_SetLinearVelocity(m_B2Body, { v.x, v.y}); + b2Body_SetLinearVelocity(m_B2Body, { v.x, v.y }); } void RigidBody2D::SetAngularVelocity(float velocity) { - b2Body_SetAngularVelocity(m_B2Body, velocity); + b2Body_SetAngularVelocity(m_B2Body, velocity); } void RigidBody2D::SetForce(const Vec2& v) const { - b2Body_ApplyForceToCenter(m_B2Body, { v.x, v.y }, true); + b2Body_ApplyForceToCenter(m_B2Body, { v.x, v.y }, true); } void RigidBody2D::SetPosition(const Vec2& pos) const { - b2Body_SetTransform(m_B2Body, {pos.x, pos.y} , b2Body_GetRotation(m_B2Body)); + b2Body_SetTransform(m_B2Body, { pos.x, pos.y }, b2Body_GetRotation(m_B2Body)); } void RigidBody2D::SetOrientation(float angle) const { - b2Body_SetTransform(m_B2Body, b2Body_GetPosition(m_B2Body), b2MakeRot( angle )); + b2Body_SetTransform(m_B2Body, b2Body_GetPosition(m_B2Body), b2MakeRot(angle)); } void RigidBody2D::SetIsStatic(bool isStatic) { m_Static = isStatic; - b2Body_SetType(m_B2Body, isStatic ? b2_staticBody : b2_dynamicBody); + b2Body_SetType(m_B2Body, isStatic ? b2_staticBody : b2_dynamicBody); } void RigidBody2D::Init(const RigidBodyParameters& params) @@ -75,32 +75,32 @@ namespace Lumos bodyDef.type = b2_dynamicBody; bodyDef.linearDamping = 1.0f; - bodyDef.position = {params.position.x, params.position.y}; - - b2WorldId lWorldID = Application::Get().GetSystem()->GetB2World(); - m_B2Body = b2CreateBody(lWorldID, &bodyDef); + bodyDef.position = { params.position.x, params.position.y }; + + b2WorldId lWorldID = Application::Get().GetSystem()->GetB2World(); + m_B2Body = b2CreateBody(lWorldID, &bodyDef); if(params.shape == Shape::Circle) { - b2Circle circle = {{ 0.0f, 0.0f }, params.scale.x }; + b2Circle circle = { { 0.0f, 0.0f }, params.scale.x }; - b2ShapeDef shapeDef = b2DefaultShapeDef(); - shapeDef.density = 1.0f; - shapeDef.friction = 0.3f; + b2ShapeDef shapeDef = b2DefaultShapeDef(); + shapeDef.density = 1.0f; + shapeDef.friction = 0.3f; shapeDef.enableHitEvents = true; - b2CreateCircleShape(m_B2Body, &shapeDef, &circle); + b2CreateCircleShape(m_B2Body, &shapeDef, &circle); } else if(params.shape == Shape::Square) { - b2Polygon box = b2MakeBox(params.scale.x, params.scale.y); + b2Polygon box = b2MakeBox(params.scale.x, params.scale.y); - b2ShapeDef shapeDef = b2DefaultShapeDef(); - shapeDef.density = 1.0f; - shapeDef.friction = 0.3f; + b2ShapeDef shapeDef = b2DefaultShapeDef(); + shapeDef.density = 1.0f; + shapeDef.friction = 0.3f; shapeDef.enableHitEvents = true; - b2CreatePolygonShape(m_B2Body, &shapeDef, &box); + b2CreatePolygonShape(m_B2Body, &shapeDef, &box); } else if(params.shape == Shape::Custom) { @@ -114,15 +114,15 @@ namespace Lumos b2ShapePositions[i].y = m_CustomShapePositions[i].y; } - b2Hull hull = b2ComputeHull(b2ShapePositions, i32(params.customShapePositions.size())); + b2Hull hull = b2ComputeHull(b2ShapePositions, i32(params.customShapePositions.size())); b2Polygon customPolygon = b2MakePolygon(&hull, 0.0f); - b2ShapeDef shapeDef = b2DefaultShapeDef(); - shapeDef.density = 1.0f; - shapeDef.friction = 0.3f; + b2ShapeDef shapeDef = b2DefaultShapeDef(); + shapeDef.density = 1.0f; + shapeDef.friction = 0.3f; shapeDef.enableHitEvents = true; - b2CreatePolygonShape(m_B2Body, &shapeDef, &customPolygon); + b2CreatePolygonShape(m_B2Body, &shapeDef, &customPolygon); ScratchEnd(temp); } else @@ -139,15 +139,15 @@ namespace Lumos float RigidBody2D::GetAngle() const { - return b2Rot_GetAngle(b2Body_GetRotation(m_B2Body)); + return b2Rot_GetAngle(b2Body_GetRotation(m_B2Body)); } const Vec2 RigidBody2D::GetLinearVelocity() const { - b2Vec2 vel = b2Body_GetLinearVelocity(m_B2Body); + b2Vec2 vel = b2Body_GetLinearVelocity(m_B2Body); return Vec2(vel.x, vel.y); } - + void RigidBody2D::SetLinearDamping(float dampening) { b2Body_SetLinearDamping(m_B2Body, dampening); @@ -160,14 +160,14 @@ namespace Lumos m_CustomShapePositions = customPositions; RigidBodyParameters params; - params.shape = m_ShapeType; - params.position = Vec3(GetPosition(), 1.0f); + params.shape = m_ShapeType; + params.position = Vec3(GetPosition(), 1.0f); params.customShapePositions = customPositions; params.mass = m_Mass; params.scale = m_Scale; params.isStatic = m_Static; - b2DestroyBody(m_B2Body); + b2DestroyBody(m_B2Body); Init(params); } } diff --git a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.h b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.h index 22c883c2..7ca8c4d8 100644 --- a/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.h +++ b/Lumos/Source/Lumos/Physics/B2PhysicsEngine/RigidBody2D.h @@ -45,7 +45,7 @@ namespace Lumos virtual ~RigidBody2D(); - b2BodyId GetB2Body() const + b2BodyId GetB2Body() const { return m_B2Body; } @@ -100,7 +100,7 @@ namespace Lumos } protected: - b2BodyId m_B2Body; + b2BodyId m_B2Body; Shape m_ShapeType; float m_Mass; float m_Angle; diff --git a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/CollisionShapes/HullCollisionShape.cpp b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/CollisionShapes/HullCollisionShape.cpp index d5c7d217..fddd2ba1 100644 --- a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/CollisionShapes/HullCollisionShape.cpp +++ b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/CollisionShapes/HullCollisionShape.cpp @@ -27,13 +27,13 @@ namespace Lumos void HullCollisionShape::BuildFromMesh(Graphics::Mesh* mesh) { - m_Hull = CreateSharedPtr(); - - //TODO: Needs to happen after a mesh import - // [] Toggle Collider generation - // Or option to load mesh to generate collider - // const auto& vertices = mesh->GetVertices(); - // const auto& indices = mesh->GetIndices(); + m_Hull = CreateSharedPtr(); + + // TODO: Needs to happen after a mesh import + // [] Toggle Collider generation + // Or option to load mesh to generate collider + // const auto& vertices = mesh->GetVertices(); + // const auto& indices = mesh->GetIndices(); // /* auto vertexBuffer = mesh->GetVertexBuffer(); // Graphics::Vertex* vertices = vertexBuffer->GetPointer(); diff --git a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.cpp b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.cpp index 5769ee2f..eb292dd4 100644 --- a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.cpp +++ b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.cpp @@ -230,4 +230,22 @@ namespace Lumos return m_CollisionShape; } + RigidBody3DProperties RigidBody3D::GetProperties() + { + RigidBody3DProperties properties; + properties.Position = m_Position; + properties.LinearVelocity = m_LinearVelocity; + properties.Force = m_Force; + properties.Elasticity = m_Elasticity; + + if(m_InvMass != 0.0f) + properties.Mass = 1.0f / m_InvMass; + else + properties.Mass = 1.0f; + //TODO: Finish rest; + LWARN("WIP Rigidbody GetProperties"); + + return properties; + } + } diff --git a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.h b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.h index d987b650..1bf391bb 100644 --- a/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.h +++ b/Lumos/Source/Lumos/Physics/LumosPhysicsEngine/RigidBody3D.h @@ -203,6 +203,8 @@ namespace Lumos uint16_t GetCollisionLayer() const { return m_CollisionLayer; } void SetCollisionLayer(u16 layer) { m_CollisionLayer = layer; } + RigidBody3DProperties GetProperties(); + protected: RigidBody3D(const RigidBody3DProperties& properties = RigidBody3DProperties()); diff --git a/Lumos/Source/Lumos/Platform/GLFW/GLFWKeyCodes.h b/Lumos/Source/Lumos/Platform/GLFW/GLFWKeyCodes.h index 8366a433..4fc6e6c3 100644 --- a/Lumos/Source/Lumos/Platform/GLFW/GLFWKeyCodes.h +++ b/Lumos/Source/Lumos/Platform/GLFW/GLFWKeyCodes.h @@ -15,7 +15,7 @@ namespace Lumos static bool arrayInitialised = false; if(!arrayInitialised) { - arrayInitialised = true; + arrayInitialised = true; keyMapArray[GLFW_KEY_A] = Lumos::InputCode::Key::A; keyMapArray[GLFW_KEY_B] = Lumos::InputCode::Key::B; keyMapArray[GLFW_KEY_C] = Lumos::InputCode::Key::C; @@ -42,7 +42,7 @@ namespace Lumos keyMapArray[GLFW_KEY_X] = Lumos::InputCode::Key::X; keyMapArray[GLFW_KEY_Y] = Lumos::InputCode::Key::Y; keyMapArray[GLFW_KEY_Z] = Lumos::InputCode::Key::Z; - + keyMapArray[GLFW_KEY_0] = Lumos::InputCode::Key::D0; keyMapArray[GLFW_KEY_1] = Lumos::InputCode::Key::D1; keyMapArray[GLFW_KEY_2] = Lumos::InputCode::Key::D2; @@ -53,41 +53,41 @@ namespace Lumos keyMapArray[GLFW_KEY_7] = Lumos::InputCode::Key::D7; keyMapArray[GLFW_KEY_8] = Lumos::InputCode::Key::D8; keyMapArray[GLFW_KEY_9] = Lumos::InputCode::Key::D9; - - keyMapArray[GLFW_KEY_F1] = Lumos::InputCode::Key::F1; - keyMapArray[GLFW_KEY_F2] = Lumos::InputCode::Key::F2; - keyMapArray[GLFW_KEY_F3] = Lumos::InputCode::Key::F3; - keyMapArray[GLFW_KEY_F4] = Lumos::InputCode::Key::F4; - keyMapArray[GLFW_KEY_F5] = Lumos::InputCode::Key::F5; - keyMapArray[GLFW_KEY_F6] = Lumos::InputCode::Key::F6; - keyMapArray[GLFW_KEY_F7] = Lumos::InputCode::Key::F7; - keyMapArray[GLFW_KEY_F8] = Lumos::InputCode::Key::F8; - keyMapArray[GLFW_KEY_F9] = Lumos::InputCode::Key::F9; + + keyMapArray[GLFW_KEY_F1] = Lumos::InputCode::Key::F1; + keyMapArray[GLFW_KEY_F2] = Lumos::InputCode::Key::F2; + keyMapArray[GLFW_KEY_F3] = Lumos::InputCode::Key::F3; + keyMapArray[GLFW_KEY_F4] = Lumos::InputCode::Key::F4; + keyMapArray[GLFW_KEY_F5] = Lumos::InputCode::Key::F5; + keyMapArray[GLFW_KEY_F6] = Lumos::InputCode::Key::F6; + keyMapArray[GLFW_KEY_F7] = Lumos::InputCode::Key::F7; + keyMapArray[GLFW_KEY_F8] = Lumos::InputCode::Key::F8; + keyMapArray[GLFW_KEY_F9] = Lumos::InputCode::Key::F9; keyMapArray[GLFW_KEY_F10] = Lumos::InputCode::Key::F10; keyMapArray[GLFW_KEY_F11] = Lumos::InputCode::Key::F11; keyMapArray[GLFW_KEY_F12] = Lumos::InputCode::Key::F12; - - keyMapArray[GLFW_KEY_MINUS] = Lumos::InputCode::Key::Minus; - keyMapArray[GLFW_KEY_DELETE] = Lumos::InputCode::Key::Delete; - keyMapArray[GLFW_KEY_SPACE] = Lumos::InputCode::Key::Space; - keyMapArray[GLFW_KEY_LEFT] = Lumos::InputCode::Key::Left; - keyMapArray[GLFW_KEY_RIGHT] = Lumos::InputCode::Key::Right; - keyMapArray[GLFW_KEY_UP] = Lumos::InputCode::Key::Up; - keyMapArray[GLFW_KEY_DOWN] = Lumos::InputCode::Key::Down; - keyMapArray[GLFW_KEY_LEFT_SHIFT] = Lumos::InputCode::Key::LeftShift; - keyMapArray[GLFW_KEY_RIGHT_SHIFT] = Lumos::InputCode::Key::RightShift; - keyMapArray[GLFW_KEY_ESCAPE] = Lumos::InputCode::Key::Escape; - keyMapArray[GLFW_KEY_KP_ADD] = Lumos::InputCode::Key::KPAdd; - keyMapArray[GLFW_KEY_COMMA] = Lumos::InputCode::Key::Comma; - keyMapArray[GLFW_KEY_BACKSPACE] = Lumos::InputCode::Key::Backspace; - keyMapArray[GLFW_KEY_ENTER] = Lumos::InputCode::Key::Enter; - keyMapArray[GLFW_KEY_LEFT_SUPER] = Lumos::InputCode::Key::LeftSuper; - keyMapArray[GLFW_KEY_RIGHT_SUPER] = Lumos::InputCode::Key::RightSuper; - keyMapArray[GLFW_KEY_LEFT_ALT] = Lumos::InputCode::Key::LeftAlt; - keyMapArray[GLFW_KEY_RIGHT_ALT] = Lumos::InputCode::Key::RightAlt; - keyMapArray[GLFW_KEY_LEFT_CONTROL] = Lumos::InputCode::Key::LeftControl; + + keyMapArray[GLFW_KEY_MINUS] = Lumos::InputCode::Key::Minus; + keyMapArray[GLFW_KEY_DELETE] = Lumos::InputCode::Key::Delete; + keyMapArray[GLFW_KEY_SPACE] = Lumos::InputCode::Key::Space; + keyMapArray[GLFW_KEY_LEFT] = Lumos::InputCode::Key::Left; + keyMapArray[GLFW_KEY_RIGHT] = Lumos::InputCode::Key::Right; + keyMapArray[GLFW_KEY_UP] = Lumos::InputCode::Key::Up; + keyMapArray[GLFW_KEY_DOWN] = Lumos::InputCode::Key::Down; + keyMapArray[GLFW_KEY_LEFT_SHIFT] = Lumos::InputCode::Key::LeftShift; + keyMapArray[GLFW_KEY_RIGHT_SHIFT] = Lumos::InputCode::Key::RightShift; + keyMapArray[GLFW_KEY_ESCAPE] = Lumos::InputCode::Key::Escape; + keyMapArray[GLFW_KEY_KP_ADD] = Lumos::InputCode::Key::KPAdd; + keyMapArray[GLFW_KEY_COMMA] = Lumos::InputCode::Key::Comma; + keyMapArray[GLFW_KEY_BACKSPACE] = Lumos::InputCode::Key::Backspace; + keyMapArray[GLFW_KEY_ENTER] = Lumos::InputCode::Key::Enter; + keyMapArray[GLFW_KEY_LEFT_SUPER] = Lumos::InputCode::Key::LeftSuper; + keyMapArray[GLFW_KEY_RIGHT_SUPER] = Lumos::InputCode::Key::RightSuper; + keyMapArray[GLFW_KEY_LEFT_ALT] = Lumos::InputCode::Key::LeftAlt; + keyMapArray[GLFW_KEY_RIGHT_ALT] = Lumos::InputCode::Key::RightAlt; + keyMapArray[GLFW_KEY_LEFT_CONTROL] = Lumos::InputCode::Key::LeftControl; keyMapArray[GLFW_KEY_RIGHT_CONTROL] = Lumos::InputCode::Key::RightControl; - keyMapArray[GLFW_KEY_TAB] = Lumos::InputCode::Key::Tab; + keyMapArray[GLFW_KEY_TAB] = Lumos::InputCode::Key::Tab; } return keyMapArray[glfwKey]; @@ -100,9 +100,9 @@ namespace Lumos static bool arrayInitialised = false; if(!arrayInitialised) { - arrayInitialised = true; - keyMap[GLFW_MOUSE_BUTTON_LEFT] = Lumos::InputCode::MouseKey::ButtonLeft; - keyMap[GLFW_MOUSE_BUTTON_RIGHT] = Lumos::InputCode::MouseKey::ButtonRight; + arrayInitialised = true; + keyMap[GLFW_MOUSE_BUTTON_LEFT] = Lumos::InputCode::MouseKey::ButtonLeft; + keyMap[GLFW_MOUSE_BUTTON_RIGHT] = Lumos::InputCode::MouseKey::ButtonRight; keyMap[GLFW_MOUSE_BUTTON_MIDDLE] = Lumos::InputCode::MouseKey::ButtonMiddle; } return keyMap[glfwKey]; diff --git a/Lumos/Source/Lumos/Platform/GLFW/GLFWWindow.cpp b/Lumos/Source/Lumos/Platform/GLFW/GLFWWindow.cpp index 99ebf316..113d77a8 100644 --- a/Lumos/Source/Lumos/Platform/GLFW/GLFWWindow.cpp +++ b/Lumos/Source/Lumos/Platform/GLFW/GLFWWindow.cpp @@ -341,7 +341,7 @@ namespace Lumos { for(int i = 0; i < desc.IconData.Size(); i++) { - u8* data = desc.IconData[i]; + u8* data = desc.IconData[i]; u32 iconSize = desc.IconDataSizes[i]; GLFWimage image; @@ -504,6 +504,7 @@ namespace Lumos void GLFWWindow::ProcessInput() { + LUMOS_PROFILE_FUNCTION(); { LUMOS_PROFILE_SCOPE("GLFW PollEvents"); glfwPollEvents(); @@ -538,8 +539,8 @@ namespace Lumos Controller* controller = &controllers[id]; if(!controller->Present) { - controller->ID = id; - controller->Name = glfwGetJoystickName(id); + controller->ID = id; + controller->Name = glfwGetJoystickName(id); controller->Present = true; } @@ -556,7 +557,6 @@ namespace Lumos controller->ButtonDown[i] = buttons[i] == GLFW_PRESS; } - int axisCount; const float* axes = glfwGetJoystickAxes(id, &axisCount); @@ -575,7 +575,6 @@ namespace Lumos } else controllers[id].Present = false; - } } } diff --git a/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.cpp b/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.cpp index 8263144f..132de26f 100644 --- a/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.cpp +++ b/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.cpp @@ -149,7 +149,7 @@ namespace Lumos GLCall(glViewport(x, y, width, height)); } - const std::string& GLRenderer::GetTitleInternal() const + const char* GLRenderer::GetTitleInternal() const { return m_RendererTitle; } diff --git a/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.h b/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.h index e144037f..33aadf42 100644 --- a/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.h +++ b/Lumos/Source/Lumos/Platform/OpenGL/GLRenderer.h @@ -57,7 +57,7 @@ namespace Lumos static void ClearInternal(uint32_t buffer); void ClearRenderTarget(Graphics::Texture* texture, Graphics::CommandBuffer* commandBuffer, Vec4 clearColour) override; - const std::string& GetTitleInternal() const override; + const char* GetTitleInternal() const override; static void MakeDefault(); @@ -67,7 +67,7 @@ namespace Lumos protected: static Renderer* CreateFuncGL(); - std::string m_RendererTitle; + const char* m_RendererTitle; int32_t m_BoundVertexBuffer = -1; int32_t m_BoundIndexBuffer = -1; GLPipeline* m_BoundPipeline = nullptr; diff --git a/Lumos/Source/Lumos/Platform/Unix/UnixOS.cpp b/Lumos/Source/Lumos/Platform/Unix/UnixOS.cpp index f8791dc6..463ad166 100644 --- a/Lumos/Source/Lumos/Platform/Unix/UnixOS.cpp +++ b/Lumos/Source/Lumos/Platform/Unix/UnixOS.cpp @@ -38,43 +38,45 @@ namespace Lumos SystemMemoryInfo MemoryManager::GetSystemInfo() { - - #ifdef LUMOS_PLATFORM_MACOS + +#ifdef LUMOS_PLATFORM_MACOS int64_t total_physical; size_t len = sizeof(total_physical); sysctlbyname("hw.memsize", &total_physical, &len, NULL, 0); - + mach_port_t mach_port = mach_host_self(); vm_size_t page_size; mach_msg_type_number_t count = HOST_VM_INFO_COUNT; vm_statistics64_data_t vm_stats; - - if (host_page_size(mach_port, &page_size) != KERN_SUCCESS) { + + if(host_page_size(mach_port, &page_size) != KERN_SUCCESS) + { perror("Failed to get page size"); exit(EXIT_FAILURE); } - - if (host_statistics64(mach_port, HOST_VM_INFO, (host_info64_t)&vm_stats, &count) != KERN_SUCCESS) { + + if(host_statistics64(mach_port, HOST_VM_INFO, (host_info64_t)&vm_stats, &count) != KERN_SUCCESS) + { perror("Failed to get VM statistics"); exit(EXIT_FAILURE); } - + int64_t available_physical = (int64_t)vm_stats.free_count * (int64_t)page_size; - int64_t total_virtual = (int64_t)(vm_stats.wire_count + vm_stats.active_count + vm_stats.inactive_count + vm_stats.free_count) * (int64_t)page_size; - int64_t available_virtual = (int64_t)vm_stats.free_count * (int64_t)page_size; - + int64_t total_virtual = (int64_t)(vm_stats.wire_count + vm_stats.active_count + vm_stats.inactive_count + vm_stats.free_count) * (int64_t)page_size; + int64_t available_virtual = (int64_t)vm_stats.free_count * (int64_t)page_size; + SystemMemoryInfo result = { available_physical, total_physical, available_virtual, total_virtual }; - + return result; - #else +#else SystemMemoryInfo result = {}; return result; - #endif +#endif } void UnixOS::Delay(uint32_t usec) diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VK.h b/Lumos/Source/Lumos/Platform/Vulkan/VK.h index 02b3c37d..ba46fab4 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VK.h +++ b/Lumos/Source/Lumos/Platform/Vulkan/VK.h @@ -22,12 +22,12 @@ inline PFN_vkSetDebugUtilsObjectNameEXT fpSetDebugUtilsObjectNameEXT; #if ENABLE_VMA_LOG static char VMA_LOG_BUFFER[100]; -#define VMA_DEBUG_LOG(...) \ - stbsp_sprintf(VMA_LOG_BUFFER, __VA_ARGS__); \ +#define VMA_DEBUG_LOG(...) \ + stbsp_sprintf(VMA_LOG_BUFFER, __VA_ARGS__); \ LINFO((const char*)VMA_LOG_BUFFER) -#define VMA_DEBUG_LOG_FORMAT(...) \ - stbsp_sprintf(VMA_LOG_BUFFER, __VA_ARGS__); \ +#define VMA_DEBUG_LOG_FORMAT(...) \ + stbsp_sprintf(VMA_LOG_BUFFER, __VA_ARGS__); \ LERROR((const char*)VMA_LOG_BUFFER) #endif diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.cpp index 6232d153..bb711093 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.cpp @@ -138,7 +138,7 @@ namespace Lumos m_State = CommandBufferState::Ended; } - void VKCommandBuffer::Execute(VkPipelineStageFlags flags, VkSemaphore waitSemaphore, bool waitFence) + bool VKCommandBuffer::Execute(VkPipelineStageFlags flags, VkSemaphore waitSemaphore, bool waitFence) { LUMOS_PROFILE_FUNCTION_LOW(); ASSERT(m_Primary, "Used Execute on secondary command buffer!"); @@ -160,10 +160,12 @@ namespace Lumos { LUMOS_PROFILE_SCOPE("vkQueueSubmit"); - VK_CHECK_RESULT(vkQueueSubmit(VKDevice::Get().GetGraphicsQueue(), 1, &submitInfo, m_Fence->GetHandle())); + VK_CHECK_RESULT_RETURN_FALSE(vkQueueSubmit(VKDevice::Get().GetGraphicsQueue(), 1, &submitInfo, m_Fence->GetHandle())); } m_State = CommandBufferState::Submitted; + + return true; } void VKCommandBuffer::ExecuteSecondary(CommandBuffer* primaryCmdBuffer) diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.h b/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.h index 57f01f65..9ce7ca63 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.h +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKCommandBuffer.h @@ -46,7 +46,7 @@ namespace Lumos void BeginRenderPass(RenderPass* renderpass, float* clearColour, Framebuffer* framebuffer, uint32_t width, uint32_t height); - void Execute(VkPipelineStageFlags flags, VkSemaphore signalSemaphore, bool waitFence); + bool Execute(VkPipelineStageFlags flags, VkSemaphore signalSemaphore, bool waitFence); void ExecuteSecondary(CommandBuffer* primaryCmdBuffer) override; void UpdateViewport(uint32_t width, uint32_t height, bool flipViewport) override; diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKContext.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKContext.cpp index f78805a3..c62b484b 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKContext.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKContext.cpp @@ -178,6 +178,7 @@ namespace Lumos } VKContext::VKContext() + : m_ValidationEnabled(false) { } @@ -277,6 +278,8 @@ namespace Lumos enableValidation = true; } + m_ValidationEnabled = enableValidation; + m_InstanceLayerNames = GetRequiredLayers(enableValidation); m_InstanceExtensionNames = GetRequiredExtensions(enableValidation); diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKContext.h b/Lumos/Source/Lumos/Platform/Vulkan/VKContext.h index 81f3c54f..6ee04dff 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKContext.h +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKContext.h @@ -42,6 +42,8 @@ namespace Lumos const TDArray& GetLayerNames() const { return m_InstanceLayerNames; } const TDArray& GetExtensionNames() const { return m_InstanceExtensionNames; } + bool ValidationEnabled() const { return m_ValidationEnabled; } + static void MakeDefault(); static uint32_t GetVKVersion() { return m_VKVersion; } @@ -64,6 +66,8 @@ namespace Lumos TDArray m_InstanceLayerNames; TDArray m_InstanceExtensionNames; + bool m_ValidationEnabled = false; + static uint32_t m_VKVersion; }; } diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKDevice.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKDevice.cpp index 0069936c..970010d5 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKDevice.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKDevice.cpp @@ -57,7 +57,7 @@ namespace Lumos if(Vendor == "Nvidia") { - stbsp_sprintf( + stbsp_sprintf( buffer, "%d.%d.%d.%d", (version >> 22) & 0x3ff, @@ -68,7 +68,7 @@ namespace Lumos #if LUMOS_PLATFORM_WINDOWS else if(Vendor == "Intel") { - stbsp_sprintf( + stbsp_sprintf( buffer, "%d.%d", (version >> 14), @@ -77,7 +77,7 @@ namespace Lumos #endif else // Vulkan version conventions { - stbsp_sprintf( + stbsp_sprintf( buffer, "%d.%d.%d", (version >> 22), diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.cpp index ca766305..ef9bb222 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.cpp @@ -19,6 +19,7 @@ #include #define DELETION_QUEUE_CAPACITY 3 // 12 +#define DESCRIPTOR_POOL_CAPACITY 100 namespace Lumos { namespace Graphics @@ -158,7 +159,7 @@ namespace Lumos ScratchEnd(scratch); } - const std::string& VKRenderer::GetTitleInternal() const + const char* VKRenderer::GetTitleInternal() const { return m_RendererTitle; } @@ -439,7 +440,7 @@ file.close(); LUMOS_PROFILE_FUNCTION_LOW(); Engine::Get().Statistics().NumDrawCalls++; Engine::Get().Statistics().TriangleCount += count / 3; - + vkCmdDraw(static_cast(commandBuffer)->GetHandle(), count, 1, 0, 0); } @@ -572,21 +573,19 @@ file.close(); VkDescriptorPool VKRenderer::CreatePool(VkDevice device, uint32_t count, VkDescriptorPoolCreateFlags flags) { - ArenaTemp scratch = ScratchBegin(0,0); - TArray poolSizes = TArray({ - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_SAMPLER, count / 2 }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count * 4 }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, count * 2 }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, count * 2 }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, count }, - VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, count / 2 } }, - scratch.arena); - + ArenaTemp scratch = ScratchBegin(0, 0); + TArray poolSizes = TArray({ VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_SAMPLER, count / 2 }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count * 4 }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, count * 2 }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, count * 2 }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, count }, + VkDescriptorPoolSize { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, count / 2 } }, + scratch.arena); // Create info VkDescriptorPoolCreateInfo poolCreateInfo = {}; @@ -604,6 +603,7 @@ file.close(); VkDescriptorPool VKRenderer::GetPool() { + //TODO: Add pools to freelist once all descriptor sets have been marked as freed if(m_FreeDescriptorPools.Size() > 0) { VkDescriptorPool pool = m_FreeDescriptorPools.Back(); @@ -671,6 +671,14 @@ file.close(); return false; } + + bool VKRenderer::DeallocateDescriptorSet(VkDescriptorSet* set, VkDescriptorPool& pool) + { + //Find pool index + //Decrease Pool capcity by 1 + //Check if capacity is 0 + //Add to free list if empty + } void VKRenderer::ReleaseDescriptorPools() { diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.h b/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.h index e6e6350d..ebb0c3a4 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.h +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKRenderer.h @@ -52,7 +52,7 @@ namespace Lumos void SaveScreenshot(const std::string& path, Graphics::Texture* texture = nullptr) override; - const std::string& GetTitleInternal() const override; + const char* GetTitleInternal() const override; void BindDescriptorSetsInternal(Graphics::Pipeline* pipeline, Graphics::CommandBuffer* commandBuffer, uint32_t dynamicOffset, Graphics::DescriptorSet** descriptorSets, uint32_t descriptorCount) override; void DrawIndexedInternal(CommandBuffer* commandBuffer, DrawType type, uint32_t count, uint32_t start) const override; @@ -63,6 +63,7 @@ namespace Lumos void Dispatch(CommandBuffer* commandBuffer, uint32_t workGroupSizeX, uint32_t workGroupSizeY, uint32_t workGroupSizeZ) override; bool AllocateDescriptorSet(VkDescriptorSet* set, VkDescriptorPool& pool, VkDescriptorSetLayout layout, uint32_t descriptorCount); + bool DeallocateDescriptorSet(VkDescriptorSet* set, VkDescriptorPool& pool); void ReleaseDescriptorPools(); static DeletionQueue& GetDeletionQueue(int frameIndex) @@ -101,10 +102,11 @@ namespace Lumos uint32_t m_CurrentSemaphoreIndex = 0; - std::string m_RendererTitle; - uint32_t m_DescriptorCapacity = 0; + const char* m_RendererTitle; VkDescriptorPool m_CurrentPool; + + TDArray m_UsedDescriptorPoolsCapacity; TDArray m_UsedDescriptorPools; TDArray m_FreeDescriptorPools; diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKSwapChain.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKSwapChain.cpp index 42a9e58d..d4a89b54 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKSwapChain.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKSwapChain.cpp @@ -345,6 +345,8 @@ namespace Lumos return; } } + + //TODO: Check if in pending state before resetting commandBuffer->Reset(); VKRenderer::GetDeletionQueue(m_CurrentBuffer).Flush(); AcquireNextImage(); diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKTexture.cpp b/Lumos/Source/Lumos/Platform/Vulkan/VKTexture.cpp index 552478f4..96c66c8c 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKTexture.cpp +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKTexture.cpp @@ -1309,8 +1309,16 @@ namespace Lumos m_VKFormat = VKUtilities::FormatToVK(m_Format); #ifdef LUMOS_PLATFORM_MACOS + //Bug on macos with shadows having artifacts when using the VK_IMAGE_USAGE_SAMPLED_BIT flag + #ifndef LUMOS_PRODUCTION + VkImageUsageFlags usage; + if(((VKContext*)Graphics::Renderer::GetGraphicsContext())->ValidationEnabled()) + usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + else + usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + #else VkImageUsageFlags usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; - + #endif #else VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; #endif diff --git a/Lumos/Source/Lumos/Platform/Vulkan/VKUtilities.h b/Lumos/Source/Lumos/Platform/Vulkan/VKUtilities.h index d5eed3e6..85235ed4 100644 --- a/Lumos/Source/Lumos/Platform/Vulkan/VKUtilities.h +++ b/Lumos/Source/Lumos/Platform/Vulkan/VKUtilities.h @@ -11,6 +11,16 @@ } \ } +#define VK_CHECK_RESULT_RETURN_FALSE(f) \ + { \ + VkResult res = (f); \ + if(res != VK_SUCCESS) \ + { \ + LERROR("[VULKAN] : VkResult is %s in %s at line %i", Lumos::Graphics::VKUtilities::ErrorString(res).c_str(), __FILE__, __LINE__); \ + return false; \ + } \ + } + namespace Lumos { namespace Graphics diff --git a/Lumos/Source/Lumos/Platform/Windows/WindowsKeycodes.h b/Lumos/Source/Lumos/Platform/Windows/WindowsKeycodes.h index 5742b154..c59fe7a2 100644 --- a/Lumos/Source/Lumos/Platform/Windows/WindowsKeycodes.h +++ b/Lumos/Source/Lumos/Platform/Windows/WindowsKeycodes.h @@ -160,7 +160,7 @@ namespace Lumos static Lumos::InputCode::Key keyArray[KEYBOARD_MAX]; static bool keyArrayInitialised = false; - if (!keyArrayInitialised) + if(!keyArrayInitialised) { // Map specific keys to their values keyArray[KEYBOARD_A] = Lumos::InputCode::Key::A; @@ -202,27 +202,27 @@ namespace Lumos keyArray[KEYBOARD_9] = Lumos::InputCode::Key::D9; keyArray[KEYBOARD_SUBTRACT] = Lumos::InputCode::Key::Minus; - keyArray[KEYBOARD_DELETE] = Lumos::InputCode::Key::Delete; - keyArray[KEYBOARD_SPACE] = Lumos::InputCode::Key::Space; - keyArray[KEYBOARD_LEFT] = Lumos::InputCode::Key::Left; - keyArray[KEYBOARD_RIGHT] = Lumos::InputCode::Key::Right; - keyArray[KEYBOARD_UP] = Lumos::InputCode::Key::Up; - keyArray[KEYBOARD_DOWN] = Lumos::InputCode::Key::Down; - keyArray[KEYBOARD_LSHIFT] = Lumos::InputCode::Key::LeftShift; - keyArray[KEYBOARD_RSHIFT] = Lumos::InputCode::Key::RightShift; + keyArray[KEYBOARD_DELETE] = Lumos::InputCode::Key::Delete; + keyArray[KEYBOARD_SPACE] = Lumos::InputCode::Key::Space; + keyArray[KEYBOARD_LEFT] = Lumos::InputCode::Key::Left; + keyArray[KEYBOARD_RIGHT] = Lumos::InputCode::Key::Right; + keyArray[KEYBOARD_UP] = Lumos::InputCode::Key::Up; + keyArray[KEYBOARD_DOWN] = Lumos::InputCode::Key::Down; + keyArray[KEYBOARD_LSHIFT] = Lumos::InputCode::Key::LeftShift; + keyArray[KEYBOARD_RSHIFT] = Lumos::InputCode::Key::RightShift; keyArray[KEYBOARD_LCONTROL] = Lumos::InputCode::Key::LeftControl; keyArray[KEYBOARD_RCONTROL] = Lumos::InputCode::Key::RightControl; - keyArray[KEYBOARD_LWIN] = Lumos::InputCode::Key::LeftSuper; - keyArray[KEYBOARD_RWIN] = Lumos::InputCode::Key::RightSuper; - keyArray[KEYBOARD_LMENU] = Lumos::InputCode::Key::Menu; - keyArray[KEYBOARD_ESCAPE] = Lumos::InputCode::Key::Escape; - keyArray[KEYBOARD_ADD] = Lumos::InputCode::Key::Equal; - keyArray[KEYBOARD_BACK] = Lumos::InputCode::Key::Backspace; - keyArray[KEYBOARD_RETURN] = Lumos::InputCode::Key::Enter; - keyArray[KEYBOARD_COMMA] = Lumos::InputCode::Key::Comma; - keyArrayInitialised = true; + keyArray[KEYBOARD_LWIN] = Lumos::InputCode::Key::LeftSuper; + keyArray[KEYBOARD_RWIN] = Lumos::InputCode::Key::RightSuper; + keyArray[KEYBOARD_LMENU] = Lumos::InputCode::Key::Menu; + keyArray[KEYBOARD_ESCAPE] = Lumos::InputCode::Key::Escape; + keyArray[KEYBOARD_ADD] = Lumos::InputCode::Key::Equal; + keyArray[KEYBOARD_BACK] = Lumos::InputCode::Key::Backspace; + keyArray[KEYBOARD_RETURN] = Lumos::InputCode::Key::Enter; + keyArray[KEYBOARD_COMMA] = Lumos::InputCode::Key::Comma; + keyArrayInitialised = true; } - + return keyArray[key]; } } diff --git a/Lumos/Source/Lumos/Scene/Component/RigidBody3DComponent.cpp b/Lumos/Source/Lumos/Scene/Component/RigidBody3DComponent.cpp index 8a0db547..41f6227c 100644 --- a/Lumos/Source/Lumos/Scene/Component/RigidBody3DComponent.cpp +++ b/Lumos/Source/Lumos/Scene/Component/RigidBody3DComponent.cpp @@ -45,8 +45,12 @@ namespace Lumos RigidBody3DComponent::RigidBody3DComponent(const RigidBody3DComponent& other) { - m_RigidBody = other.m_RigidBody; + m_RigidBody = other.m_RigidBody; m_OwnRigidBody = other.m_OwnRigidBody; + + //TODO: Create Separate Move constructor and change this to duplicate the rigidbody + //auto properties = other.m_RigidBody->Body->GetProperties(); + //m_RigidBody = CreateSharedPtr(properties); } RigidBody3DComponent::~RigidBody3DComponent() diff --git a/Lumos/Source/Lumos/Scene/Entity.cpp b/Lumos/Source/Lumos/Scene/Entity.cpp index d893bd5c..34b98197 100644 --- a/Lumos/Source/Lumos/Scene/Entity.cpp +++ b/Lumos/Source/Lumos/Scene/Entity.cpp @@ -2,161 +2,200 @@ #include "Entity.h" #include "Maths/Transform.h" #include "Scene/SceneGraph.h" +#include "Core/Application.h" namespace Lumos { - bool Entity::Active() + bool Entity::Active() + { + LUMOS_PROFILE_FUNCTION_LOW(); + bool active = true; + if(HasComponent()) + active = m_Scene->GetRegistry().get(m_EntityHandle).active; + + auto parent = GetParent(); + if(parent) + active &= parent.Active(); + return active; + } + + void Entity::SetActive(bool isActive) + { + LUMOS_PROFILE_FUNCTION_LOW(); + GetOrAddComponent().active = isActive; + } + + Maths::Transform& Entity::GetTransform() + { + LUMOS_PROFILE_FUNCTION_LOW(); + return m_Scene->GetRegistry().get(m_EntityHandle); + } + + const Maths::Transform& Entity::GetTransform() const + { + LUMOS_PROFILE_FUNCTION_LOW(); + return m_Scene->GetRegistry().get(m_EntityHandle); + } + + uint64_t Entity::GetID() + { + LUMOS_PROFILE_FUNCTION_LOW(); + return m_Scene->GetRegistry().get(m_EntityHandle).ID; + } + + const std::string& Entity::GetName() + { + LUMOS_PROFILE_FUNCTION_LOW(); + auto nameComponent = TryGetComponent(); + + if(nameComponent) + return nameComponent->name; + else { - LUMOS_PROFILE_FUNCTION_LOW(); - bool active = true; - if(HasComponent()) - active = m_Scene->GetRegistry().get(m_EntityHandle).active; - - auto parent = GetParent(); - if(parent) - active &= parent.Active(); - return active; + static std::string tempName = "Entity"; + return tempName; } - - void Entity::SetActive(bool isActive) - { - LUMOS_PROFILE_FUNCTION_LOW(); - GetOrAddComponent().active = isActive; - } - - Maths::Transform& Entity::GetTransform() + } + + void Entity::SetParent(Entity entity) + { + LUMOS_PROFILE_FUNCTION_LOW(); + bool acceptable = false; + auto hierarchyComponent = TryGetComponent(); + if(hierarchyComponent != nullptr) { - LUMOS_PROFILE_FUNCTION_LOW(); - return m_Scene->GetRegistry().get(m_EntityHandle); + acceptable = entity.m_EntityHandle != m_EntityHandle && (!entity.IsParent(*this)) && (hierarchyComponent->Parent() != m_EntityHandle); } + else + acceptable = entity.m_EntityHandle != m_EntityHandle; - const Maths::Transform& Entity::GetTransform() const + if(!acceptable) { - LUMOS_PROFILE_FUNCTION_LOW(); - return m_Scene->GetRegistry().get(m_EntityHandle); + LWARN("Failed to parent entity!"); + return; } - uint64_t Entity::GetID() + if(hierarchyComponent) + Hierarchy::Reparent(m_EntityHandle, entity.m_EntityHandle, m_Scene->GetRegistry(), *hierarchyComponent); + else { - LUMOS_PROFILE_FUNCTION_LOW(); - return m_Scene->GetRegistry().get(m_EntityHandle).ID; + m_Scene->GetRegistry().emplace(m_EntityHandle, entity.m_EntityHandle); } - - const std::string& Entity::GetName() + } + + Entity Entity::GetParent() + { + LUMOS_PROFILE_FUNCTION_LOW(); + auto hierarchyComp = TryGetComponent(); + if(hierarchyComp) + return Entity(hierarchyComp->Parent(), m_Scene); + else + return Entity(entt::null, nullptr); + } + + Entity* Entity::GetChildren(Arena* arena) + { + LUMOS_PROFILE_FUNCTION_LOW(); + + Entity* children = nullptr; + u32 childIndex = 0; + + auto hierarchyComponent = TryGetComponent(); + if(hierarchyComponent) { - LUMOS_PROFILE_FUNCTION_LOW(); - auto nameComponent = TryGetComponent(); - - if(nameComponent) - return nameComponent->name; - else + u32 childCount = 0; + // TODO: remove { - static std::string tempName = "Entity"; - return tempName; - } - } + entt::entity child = hierarchyComponent->First(); + while(child != entt::null && m_Scene->GetRegistry().valid(child)) + { + childCount++; - void Entity::SetParent(Entity entity) - { - LUMOS_PROFILE_FUNCTION_LOW(); - bool acceptable = false; - auto hierarchyComponent = TryGetComponent(); - if(hierarchyComponent != nullptr) - { - acceptable = entity.m_EntityHandle != m_EntityHandle && (!entity.IsParent(*this)) && (hierarchyComponent->Parent() != m_EntityHandle); + hierarchyComponent = m_Scene->GetRegistry().try_get(child); + if(hierarchyComponent) + child = hierarchyComponent->Next(); + } } - else - acceptable = entity.m_EntityHandle != m_EntityHandle; - if(!acceptable) - { - LWARN("Failed to parent entity!"); - return; - } + hierarchyComponent = TryGetComponent(); + hierarchyComponent->m_ChildCount = childCount; - if(hierarchyComponent) - Hierarchy::Reparent(m_EntityHandle, entity.m_EntityHandle, m_Scene->GetRegistry(), *hierarchyComponent); - else + children = PushArrayNoZero(arena, Entity, childCount); + entt::entity child = hierarchyComponent->First(); + while(child != entt::null && m_Scene->GetRegistry().valid(child)) { - m_Scene->GetRegistry().emplace(m_EntityHandle, entity.m_EntityHandle); + children[childIndex] = { child, m_Scene }; + childIndex++; + + hierarchyComponent = m_Scene->GetRegistry().try_get(child); + if(hierarchyComponent) + child = hierarchyComponent->Next(); } } - Entity Entity::GetParent() - { - LUMOS_PROFILE_FUNCTION_LOW(); - auto hierarchyComp = TryGetComponent(); - if(hierarchyComp) - return Entity(hierarchyComp->Parent(), m_Scene); - else - return Entity(entt::null, nullptr); - } + return children; + } - TDArray Entity::GetChildren() - { - LUMOS_PROFILE_FUNCTION_LOW(); - TDArray children; - auto hierarchyComponent = TryGetComponent(); - if(hierarchyComponent) - { - entt::entity child = hierarchyComponent->First(); - while(child != entt::null && m_Scene->GetRegistry().valid(child)) - { - children.EmplaceBack(child, m_Scene); - hierarchyComponent = m_Scene->GetRegistry().try_get(child); - if(hierarchyComponent) - child = hierarchyComponent->Next(); - } - } + Entity* Entity::GetChildrenTemp() + { + return GetChildren(Application::Get().GetFrameArena()); + } - return children; + u32 Entity::GetChildCount() + { + auto hierarchyComponent = TryGetComponent(); + if(hierarchyComponent) + { + return hierarchyComponent->m_ChildCount; } - void Entity::ClearChildren() + return 0; + } + + void Entity::ClearChildren() + { + LUMOS_PROFILE_FUNCTION_LOW(); + auto hierarchyComponent = TryGetComponent(); + if(hierarchyComponent) { - LUMOS_PROFILE_FUNCTION_LOW(); - auto hierarchyComponent = TryGetComponent(); - if(hierarchyComponent) - { - hierarchyComponent->m_First = entt::null; - } + hierarchyComponent->m_First = entt::null; } + } - bool Entity::IsParent(Entity potentialParent) + bool Entity::IsParent(Entity potentialParent) + { + LUMOS_PROFILE_FUNCTION_LOW(); + auto nodeHierarchyComponent = m_Scene->GetRegistry().try_get(m_EntityHandle); + if(nodeHierarchyComponent) { - LUMOS_PROFILE_FUNCTION_LOW(); - auto nodeHierarchyComponent = m_Scene->GetRegistry().try_get(m_EntityHandle); - if(nodeHierarchyComponent) + auto parent = nodeHierarchyComponent->Parent(); + while(parent != entt::null) { - auto parent = nodeHierarchyComponent->Parent(); - while(parent != entt::null) + if(parent == potentialParent.m_EntityHandle) { - if(parent == potentialParent.m_EntityHandle) - { - return true; - } - else - { - nodeHierarchyComponent = m_Scene->GetRegistry().try_get(parent); - parent = nodeHierarchyComponent ? nodeHierarchyComponent->Parent() : entt::null; - } + return true; + } + else + { + nodeHierarchyComponent = m_Scene->GetRegistry().try_get(parent); + parent = nodeHierarchyComponent ? nodeHierarchyComponent->Parent() : entt::null; } } - - return false; - } - - void Entity::Destroy() - { - LUMOS_PROFILE_FUNCTION_LOW(); - m_Scene->GetRegistry().destroy(m_EntityHandle); } - bool Entity::Valid() - { - LUMOS_PROFILE_FUNCTION_LOW(); - return m_Scene && m_Scene->GetRegistry().valid(m_EntityHandle); - } + return false; + } + + void Entity::Destroy() + { + LUMOS_PROFILE_FUNCTION_LOW(); + m_Scene->GetRegistry().destroy(m_EntityHandle); + } + bool Entity::Valid() + { + LUMOS_PROFILE_FUNCTION_LOW(); + return m_Scene && m_Scene->GetRegistry().valid(m_EntityHandle); + } -} \ No newline at end of file +} diff --git a/Lumos/Source/Lumos/Scene/Entity.h b/Lumos/Source/Lumos/Scene/Entity.h index 9dacccad..7fe0a93c 100644 --- a/Lumos/Source/Lumos/Scene/Entity.h +++ b/Lumos/Source/Lumos/Scene/Entity.h @@ -14,7 +14,7 @@ namespace Lumos { class Transform; } - + struct IDComponent { UUID ID; @@ -120,12 +120,16 @@ namespace Lumos const std::string& GetName(); void SetParent(Entity entity); Entity GetParent(); - TDArray GetChildren(); + + Entity* GetChildren(Arena* arena); + Entity* GetChildrenTemp(); // Using Frame Arena + u32 GetChildCount(); + void ClearChildren(); bool IsParent(Entity potentialParent); void Destroy(); bool Valid(); - + operator entt::entity() const { return m_EntityHandle; @@ -155,7 +159,7 @@ namespace Lumos { return m_EntityHandle; } - + Scene* GetScene() const { return m_Scene; } private: diff --git a/Lumos/Source/Lumos/Scene/Scene.cpp b/Lumos/Source/Lumos/Scene/Scene.cpp index a364128e..7daad330 100644 --- a/Lumos/Source/Lumos/Scene/Scene.cpp +++ b/Lumos/Source/Lumos/Scene/Scene.cpp @@ -719,11 +719,12 @@ namespace Lumos hierarchyComponent->m_Prev = entt::null; } - auto children = entity.GetChildren(); + auto children = entity.GetChildrenTemp(); + u32 childCount = entity.GetChildCount(); - for(auto child : children) + for(u32 i = 0; i < childCount; i++) { - DuplicateEntity(child, newEntity); + DuplicateEntity(children[i], newEntity); } if(parent) @@ -826,12 +827,13 @@ namespace Lumos SerialiseEntity(entity, archive); // Serialize the children recursively - auto children = entity.GetChildren(); - archive((int)children.Size()); + auto children = entity.GetChildrenTemp(); + u32 childCount = entity.GetChildCount(); + archive((int)childCount); - for(auto child : children) + for(u32 i = 0; i < childCount; i++) { - SerializeEntityHierarchy(child, archive); + SerializeEntityHierarchy(children[i], archive); } } diff --git a/Lumos/Source/Lumos/Scene/SceneGraph.cpp b/Lumos/Source/Lumos/Scene/SceneGraph.cpp index c09e7dab..77492ae7 100644 --- a/Lumos/Source/Lumos/Scene/SceneGraph.cpp +++ b/Lumos/Source/Lumos/Scene/SceneGraph.cpp @@ -140,10 +140,11 @@ namespace Lumos void Hierarchy::Reset() { - m_Parent = entt::null; - m_First = entt::null; - m_Next = entt::null; - m_Prev = entt::null; + m_Parent = entt::null; + m_First = entt::null; + m_Next = entt::null; + m_Prev = entt::null; + m_ChildCount = 0; } void Hierarchy::OnConstruct(entt::registry& registry, entt::entity entity) @@ -172,12 +173,8 @@ namespace Lumos current_hierarchy->m_Next = entity; hierarchy.m_Prev = prev_ent; } - // sort - // registry.sort([®istry](const entt::entity lhs, const entt::entity rhs) { - // auto& right_h = registry.get(rhs); - // auto result = right_h.Compare(registry, lhs); - // return result; - // }); + + parent_hierarchy.m_ChildCount++; } } @@ -200,6 +197,7 @@ namespace Lumos child = hierarchy->Next(); } } + hierarchy->m_ChildCount = 0; } } @@ -243,13 +241,6 @@ namespace Lumos } } } - - // sort - // registry.sort([®istry](const entt::entity lhs, const entt::entity rhs) - // { - // auto& right_h = registry.get(rhs); - // return right_h.Compare(registry, lhs); - // }); } void Hierarchy::OnDestroy(entt::registry& registry, entt::entity entity) @@ -273,6 +264,8 @@ namespace Lumos next_hierarchy->m_Prev = entt::null; } } + + parent_hierarchy->m_ChildCount--; } } } @@ -282,6 +275,7 @@ namespace Lumos if(prev_hierarchy != nullptr) { prev_hierarchy->m_Next = hierarchy.m_Next; + prev_hierarchy->m_ChildCount--; } if(hierarchy.m_Next != entt::null) { @@ -292,13 +286,6 @@ namespace Lumos } } } - - // sort - // registry.sort([®istry](const entt::entity lhs, const entt::entity rhs) - // { - // auto& right_h = registry.get(rhs); - // return right_h.Compare(registry, lhs); - // }); } void SceneGraph::DisableOnConstruct(bool disable, entt::registry& registry) diff --git a/Lumos/Source/Lumos/Scene/SceneGraph.h b/Lumos/Source/Lumos/Scene/SceneGraph.h index 2ddb6ad6..ff576c7e 100644 --- a/Lumos/Source/Lumos/Scene/SceneGraph.h +++ b/Lumos/Source/Lumos/Scene/SceneGraph.h @@ -202,6 +202,7 @@ namespace Lumos entt::entity m_First; entt::entity m_Next; entt::entity m_Prev; + u32 m_ChildCount = 0; template void serialize(Archive& archive) diff --git a/Lumos/Source/Lumos/Scene/Serialisation/SerialisationImplementation.h b/Lumos/Source/Lumos/Scene/Serialisation/SerialisationImplementation.h index bf4ee513..190f14a6 100644 --- a/Lumos/Source/Lumos/Scene/Serialisation/SerialisationImplementation.h +++ b/Lumos/Source/Lumos/Scene/Serialisation/SerialisationImplementation.h @@ -242,7 +242,7 @@ namespace Lumos else archive(cereal::make_nvp("Name", key), cereal::make_nvp("UUID", value), cereal::make_nvp("AssetType", type)); - registry.AddName(key, (UUID)value); + registry.AddName(key, (UUID)value); if(type) { UUID currentID; @@ -423,13 +423,13 @@ namespace Lumos archive(sprite.UsingSpriteSheet, sprite.SpriteSheetTileSize); } - template - void serialize(Archive& archive, AnimatedSprite::AnimationState& state) - { - archive(cereal::make_nvp("PlayMode", state.Mode), - cereal::make_nvp("Frames", state.Frames), - cereal::make_nvp("FrameDuration", state.FrameDuration)); - } + template + void serialize(Archive& archive, AnimatedSprite::AnimationState& state) + { + archive(cereal::make_nvp("PlayMode", state.Mode), + cereal::make_nvp("Frames", state.Frames), + cereal::make_nvp("FrameDuration", state.FrameDuration)); + } template void save(Archive& archive, const Graphics::AnimatedSprite& sprite) diff --git a/Lumos/Source/Lumos/Scripting/Lua/LuaManager.cpp b/Lumos/Source/Lumos/Scripting/Lua/LuaManager.cpp index c654fe3d..e76eca19 100644 --- a/Lumos/Source/Lumos/Scripting/Lua/LuaManager.cpp +++ b/Lumos/Source/Lumos/Scripting/Lua/LuaManager.cpp @@ -140,17 +140,17 @@ namespace Lumos auto V = curLuaState.new_usertype>>(#Comp "_view"); \ V.set_function("each", &view>::each>); \ V.set_function("front", &view>::front); \ - s_Identifiers.PushBack(#Comp); \ - s_Identifiers.PushBack("Add" #Comp); \ - s_Identifiers.PushBack("Remove" #Comp); \ - s_Identifiers.PushBack("Get" #Comp); \ - s_Identifiers.PushBack("GetOrAdd" #Comp); \ - s_Identifiers.PushBack("TryGet" #Comp); \ - s_Identifiers.PushBack("AddOrReplace" #Comp); \ - s_Identifiers.PushBack("Has" #Comp); \ + s_Identifiers.PushBack(#Comp); \ + s_Identifiers.PushBack("Add" #Comp); \ + s_Identifiers.PushBack("Remove" #Comp); \ + s_Identifiers.PushBack("Get" #Comp); \ + s_Identifiers.PushBack("GetOrAdd" #Comp); \ + s_Identifiers.PushBack("TryGet" #Comp); \ + s_Identifiers.PushBack("AddOrReplace" #Comp); \ + s_Identifiers.PushBack("Has" #Comp); \ } - TDArray LuaManager::s_Identifiers; + TDArray LuaManager::s_Identifiers; LuaManager::LuaManager() : m_State(nullptr) @@ -183,47 +183,47 @@ namespace Lumos app_type.set_function("ZoneName", &Empty); app_type.set_function("ZoneMessage", &Empty); #endif - s_Identifiers = { - "Log", - "Trace", - "Info", - "Warn", - "Error", - "FATAL", - "Input", - "GetKeyPressed", - "GetKeyHeld", - "GetMouseClicked", - "GetMouseHeld", - "GetMousePosition", - "GetScrollOffset", - "enttRegistry", - "Entity", - "EntityManager", - "Create" - "GetRegistry", - "Valid", - "Destroy", - "SetParent", - "GetParent", - "IsParent", - "GetChildren", - "SetActive", - "Active", - "GetEntityByName", - "AddPyramidEntity", - "AddSphereEntity", - "AddLightCubeEntity", - "NameComponent", - "GetNameComponent", - "GetCurrentEntity", - "SetThisComponent", - "LuaScriptComponent", - "GetLuaScriptComponent", - "Transform", - "GetTransform" - }; - + s_Identifiers = { + "Log", + "Trace", + "Info", + "Warn", + "Error", + "FATAL", + "Input", + "GetKeyPressed", + "GetKeyHeld", + "GetMouseClicked", + "GetMouseHeld", + "GetMousePosition", + "GetScrollOffset", + "enttRegistry", + "Entity", + "EntityManager", + "Create" + "GetRegistry", + "Valid", + "Destroy", + "SetParent", + "GetParent", + "IsParent", + "GetChildren", + "SetActive", + "Active", + "GetEntityByName", + "AddPyramidEntity", + "AddSphereEntity", + "AddLightCubeEntity", + "NameComponent", + "GetNameComponent", + "GetCurrentEntity", + "SetThisComponent", + "LuaScriptComponent", + "GetLuaScriptComponent", + "Transform", + "GetTransform" + }; + BindAppLua(*m_State); BindInputLua(*m_State); BindMathsLua(*m_State); @@ -311,10 +311,11 @@ namespace Lumos state["package"]["path"] = std::string(package_path.string()) + currentPaths; } - entt::entity GetEntityByName(entt::registry& registry, const std::string& name) + Entity GetEntityByName(Scene* scene, const std::string& name) { LUMOS_PROFILE_FUNCTION(); - entt::entity e = entt::null; + entt::entity e = entt::null; + entt::registry& registry = scene->GetRegistry(); registry.view().each([&](const entt::entity& entity, const NameComponent& component) { if(name == component.name) @@ -324,7 +325,7 @@ namespace Lumos if(e == entt::null) LWARN("Failed to find entity %s", name.c_str()); - return e; + return { e, scene }; } void LuaManager::BindLogLua(sol::state& state) @@ -518,7 +519,7 @@ namespace Lumos entityType.set_function("SetParent", &Entity::SetParent); entityType.set_function("GetParent", &Entity::GetParent); entityType.set_function("IsParent", &Entity::IsParent); - entityType.set_function("GetChildren", &Entity::GetChildren); + entityType.set_function("GetChildren", &Entity::GetChildrenTemp); entityType.set_function("SetActive", &Entity::SetActive); entityType.set_function("Active", &Entity::Active); diff --git a/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.cpp b/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.cpp index 597a2a73..90c08bed 100644 --- a/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.cpp +++ b/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.cpp @@ -106,6 +106,5 @@ namespace Lumos state.set_function("SetCallback", &SetCallback); state.set_function("SetB2DGravity", &SetB2DGravity); - } } diff --git a/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.h b/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.h index f7dc344f..62052549 100644 --- a/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.h +++ b/Lumos/Source/Lumos/Scripting/Lua/PhysicsLua.h @@ -7,5 +7,5 @@ namespace sol namespace Lumos { - void BindPhysicsLua(sol::state& state); + void BindPhysicsLua(sol::state& state); } diff --git a/Lumos/Source/Lumos/Utilities/StringUtilities.cpp b/Lumos/Source/Lumos/Utilities/StringUtilities.cpp index dd6a86bc..13bbb5fd 100644 --- a/Lumos/Source/Lumos/Utilities/StringUtilities.cpp +++ b/Lumos/Source/Lumos/Utilities/StringUtilities.cpp @@ -597,7 +597,7 @@ namespace Lumos ScratchEnd(scratch); return outString; } - + String8 RelativeToAbsolutePath(Arena* arena, String8 path, String8 prefix, String8 fileSystemPath) { LUMOS_PROFILE_FUNCTION();