Skip to content

Commit

Permalink
msaa
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorton06 committed Mar 12, 2024
1 parent ecd4f33 commit de5dbf5
Show file tree
Hide file tree
Showing 44 changed files with 654 additions and 325 deletions.
2 changes: 1 addition & 1 deletion Editor/Source/ApplicationInfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace Lumos
auto arena = GetArena(i);
totalAllocated += arena->Size;
float percentageFull = (float)arena->Position / (float)arena->Size;
ImGui::ProgressBar((float)arena->Position / (float)arena->Size);
ImGui::ProgressBar(percentageFull);
Lumos::ImGuiUtilities::Tooltip((Lumos::StringUtilities::BytesToString(arena->Position) + " / " + Lumos::StringUtilities::BytesToString(arena->Size)).c_str());
}
ImGui::Text("Total %s", Lumos::StringUtilities::BytesToString(totalAllocated).c_str());
Expand Down
2 changes: 1 addition & 1 deletion Editor/Source/AssetManagerPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace Lumos
ImGui::TextUnformatted(AssetTypeToString(metaData.Type));

ImGui::TableNextColumn();
ImGui::Text("%lld", metaData.lastAccessed);
ImGui::Text("%.2f", metaData.lastAccessed);

ImGui::TableNextRow();
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Source/ConsolePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Lumos
{
for(auto messIt = messageStart; messIt != s_MessageBuffer.end(); ++messIt)
{
if(message->GetMessageID() == (*messIt)->GetMessageID())
if((*messIt) && message->GetMessageID() == (*messIt)->GetMessageID())
{
(*messIt)->IncreaseCount();
return;
Expand Down
4 changes: 2 additions & 2 deletions Editor/Source/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,6 @@ namespace Lumos

if(ImGui::Button("OK", ImVec2(120, 0)))
{
auto scene = new Scene("New Scene");
Application::Get().GetSceneManager()->SwitchScene(Application::Get().GetSceneManager()->GetCurrentSceneIndex());

ImGui::CloseCurrentPopup();
Expand Down Expand Up @@ -1732,6 +1731,7 @@ namespace Lumos

m_GridRenderer->OnImGui();

m_GridRenderer->SetDepthTarget(m_RenderPasses->GetForwardData().m_DepthTexture);
m_GridRenderer->BeginScene(Application::Get().GetSceneManager()->GetCurrentScene(), m_EditorCamera.get(), &m_EditorCameraTransform);
m_GridRenderer->RenderScene();
#endif
Expand Down Expand Up @@ -2533,8 +2533,8 @@ namespace Lumos
Entity modelEntity = Application::Get().GetSceneManager()->GetCurrentScene()->GetEntityManager()->Create(StringUtilities::GetFileName(path));
modelEntity.AddComponent<Graphics::ModelComponent>(path);

m_SelectedEntities.clear();
SetSelected(modelEntity.GetHandle());
// m_SelectedEntity = modelEntity.GetHandle();
}
else if(IsAudioFile(path))
{
Expand Down
4 changes: 2 additions & 2 deletions Editor/Source/HierarchyPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace Lumos

ImGui::PushStyleColor(ImGuiCol_Text, ImGuiUtilities::GetIconColour());
// ImGui::BeginGroup();
bool nodeOpen = ImGui::TreeNodeEx((void*)(intptr_t)entt::to_integral(node), nodeFlags, (const char*)icon.str);
bool nodeOpen = ImGui::TreeNodeEx((void*)(intptr_t)entt::to_integral(node), nodeFlags, "%s", (const char*)icon.str);
{
if(ImGui::BeginDragDropSource())
{
Expand Down Expand Up @@ -265,7 +265,7 @@ namespace Lumos
if(ImGui::Selectable("Cut"))
{
for(auto entity : m_Editor->GetSelected())
m_Editor->SetCopiedEntity(node, true);
m_Editor->SetCopiedEntity(entity, true);
}

if(m_Editor->GetCopiedEntity().size() > 0 && registry.valid(m_Editor->GetCopiedEntity().front()))
Expand Down
15 changes: 14 additions & 1 deletion Editor/Source/InspectorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ end

ImGui::Columns(1);
ImGui::Separator();

if (ImGui::Button("Copy Editor Camera Transforn", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
{
Lumos::Application* app = &Lumos::Editor::Get();
glm::mat4 cameraTransform = ((Lumos::Editor*)app)->GetEditorCameraTransform().GetWorldMatrix();
transform.SetLocalTransform(cameraTransform);
}
}

static void CuboidCollisionShapeInspector(Lumos::CuboidCollisionShape* shape, const Lumos::RigidBody3DComponent& phys)
Expand Down Expand Up @@ -311,6 +318,12 @@ end
ImGui::TextUnformatted("Hull Collision Shape");
ImGui::NextColumn();
ImGui::PushItemWidth(-1);

if (ImGui::Button("Generate Collider"))
{
auto test = Lumos::SharedPtr<Lumos::Graphics::Mesh>(Lumos::Graphics::CreatePrimative(Lumos::Graphics::PrimitiveType::Cube));
shape->BuildFromMesh(test.get());
}
}

std::string CollisionShape2DTypeToString(Lumos::Shape shape)
Expand Down Expand Up @@ -530,7 +543,7 @@ end
int index = 0;
for(auto& shape : shapes)
{
if(shape == shape_current)
if(strcmp(shape, shape_current) == 0)
{
selectedIndex = index;
break;
Expand Down
71 changes: 42 additions & 29 deletions Editor/Source/ResourcePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace Lumos
m_Name = ICON_MDI_FOLDER_STAR " Resources###resources";
m_SimpleName = "Resources";

m_Arena = ArenaAlloc(Kilobytes(64));
m_Arena = ArenaAlloc(Megabytes(8));
#ifdef LUMOS_PLATFORM_WINDOWS
m_Delimiter = Str8Lit("\\");
#else
Expand Down Expand Up @@ -275,25 +275,6 @@ namespace Lumos
const float SmallOffsetX = 6.0f * Application::Get().GetWindowDPI();
ImDrawList* drawList = ImGui::GetWindowDrawList();

if(ImGui::IsWindowFocused() && (Input::Get().GetKeyHeld(InputCode::Key::LeftSuper) || Input::Get().GetKeyHeld(InputCode::Key::LeftControl)))
{
float mouseScroll = Input::Get().GetScrollOffset();

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

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

if(!dirInfo->IsFile)
{
if(dirInfo->Leaf)
Expand Down Expand Up @@ -371,7 +352,6 @@ namespace Lumos
{
LUMOS_PROFILE_FUNCTION();

// m_TextureLibrary.Update((float)Engine::Get().GetTimeStep().GetElapsedSeconds());
if(ImGui::Begin(m_Name.c_str(), &m_Active))
{
FileIndex = 0;
Expand Down Expand Up @@ -618,6 +598,28 @@ namespace Lumos

if(ImGui::BeginTable("BodyTable", columnCount, flags))
{
if(ImGui::IsItemHovered() && (Input::Get().GetKeyHeld(InputCode::Key::LeftSuper) || Input::Get().GetKeyHeld(InputCode::Key::LeftControl)))
{
float mouseScroll = Input::Get().GetScrollOffset();

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

LUMOS_LOG_INFO("changing icon size {0}", m_GridSize);

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


m_GridItemsPerRow = (int)floor(xAvail / (m_GridSize + ImGui::GetStyle().ItemSpacing.x));
m_GridItemsPerRow = Maths::Max(1, m_GridItemsPerRow);

Expand Down Expand Up @@ -839,17 +841,16 @@ namespace Lumos
ArenaTemp scratch = ArenaTempBegin(m_Arena);

String8 fileName = PushStr8Copy(scratch.arena, StringUtilities::GetFileName(CurrentEnty->Path));
String8 sceneScreenShotPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", m_BasePath.str, fileName);
// auto sceneScreenShotPath = m_BasePath + "/Scenes/Cache/" + CurrentEnty->FilePath.stem().string() + ".png";
String8 sceneScreenShotPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", m_BasePath.str, fileName.str);
if(std::filesystem::exists(std::filesystem::path(std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size))))
{
textureCreated = true;
String8 sceneScreenShotAssetPath = PushStr8F(scratch.arena, "%s/Scenes/Cache/%s.png", Str8Lit("//Assets").str, fileName.str);

if(!m_Editor->GetAssetManager()->AssetExists(std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size)))
CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->LoadTextureAsset(std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size), true);
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*)sceneScreenShotPath.str, sceneScreenShotPath.size)).As<Graphics::Texture2D>();
// CurrentEnty->Thumbnail = nullptr;// m_TextureLibrary.GetAsset(std::string((const char*)sceneScreenShotPath.str, sceneScreenShotPath.size));
CurrentEnty->Thumbnail = m_Editor->GetAssetManager()->GetAssetData(std::string((const char*)sceneScreenShotAssetPath.str, sceneScreenShotAssetPath.size)).As<Graphics::Texture2D>();
textureId = CurrentEnty->Thumbnail ? CurrentEnty->Thumbnail : m_FileIcon;
}
else
Expand Down Expand Up @@ -923,6 +924,8 @@ namespace Lumos
QueueRefresh();
}

ImGui::Separator();

if(ImGui::Selectable("Open Location"))
{
auto fullPath = m_CurrentDir->Children[dirIndex]->Path;
Expand All @@ -935,6 +938,16 @@ namespace Lumos
Lumos::OS::Instance()->OpenFileExternal(std::string((const char*)fullPath.str, fullPath.size));
}

if (ImGui::Selectable("Copy Full Path"))
{
ImGui::SetClipboardText((const char*)m_CurrentDir->Children[dirIndex]->Path.str);
}

if (m_CurrentDir->Children[dirIndex]->IsFile && ImGui::Selectable("Copy Asset Path"))
{
ImGui::SetClipboardText((const char*)ToStdString(m_CurrentDir->Children[dirIndex]->AssetPath).c_str());
}

ImGui::Separator();

if(ImGui::Selectable("Import New Asset"))
Expand Down Expand Up @@ -1023,7 +1036,7 @@ namespace Lumos
ImGui::TextUnformatted((const char*)(fileTypeString).str);
ImGui::Unindent();
cursorPos = ImGui::GetCursorPos();
ImGui::SetCursorPos({ cursorPos.x + padding * (float)m_Editor->GetWindow()->GetDPIScale(), cursorPos.y - (ImGui::GetIO().Fonts->Fonts[2]->FontSize * 0.6f - padding * (float)m_Editor->GetWindow()->GetDPIScale()) });
ImGui::SetCursorPos({ cursorPos.x + padding * (float)m_Editor->GetWindow()->GetDPIScale(), cursorPos.y - (ImGui::GetIO().Fonts->Fonts[2]->FontSize * 0.8f - padding * (float)m_Editor->GetWindow()->GetDPIScale()) });
ImGui::Indent();
ImGui::TextUnformatted((const char*)CurrentEnty->FileSizeString.str);
ImGui::Unindent();
Expand Down Expand Up @@ -1052,7 +1065,7 @@ namespace Lumos

ImGui::SameLine();
m_MovePath = m_CurrentDir->Children[dirIndex]->Path;
ImGui::TextUnformatted((const char*)m_MovePath.str);
ImGui::TextUnformatted((const char*)ToStdString(m_MovePath).c_str());

size_t size = sizeof(const char*) + m_MovePath.size;
ImGui::SetDragDropPayload("AssetFile", m_MovePath.str, size);
Expand Down
60 changes: 60 additions & 0 deletions Editor/Source/SceneSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Lumos/Physics/LumosPhysicsEngine/LumosPhysicsEngine.h>
#include <Lumos/Core/OS/FileSystem.h>
#include <Lumos/Core/Profiler.h>
#include <Lumos/Graphics/RHI/Renderer.h>

namespace Lumos
{
Expand Down Expand Up @@ -164,6 +165,65 @@ namespace Lumos
ImGuiUtilities::Property("Brightness", sceneSettings.RenderSettings.Brightness, -1.0f, 1.0f, 0.01f);
ImGuiUtilities::Property("Contrast", sceneSettings.RenderSettings.Contrast, 0.0f, 2.0f, 0.01f);
ImGuiUtilities::Property("Saturation", sceneSettings.RenderSettings.Saturation, 0.0f, 1.0f, 0.01f);

int32_t maxSupportedSampleCount = Lumos::Graphics::Renderer::GetCapabilities().MaxSamples;
uint8_t cachedValue = sceneSettings.RenderSettings.MSAASamples;
static const char* msaaValues[4] =
{
"1",
"2",
"4",
"8"
};
int index = 0;
switch(cachedValue)
{
case 1:
index = 0;
break;
case 2:
index = 1;
break;
case 4:
index = 2;
break;
case 8:
index = 3;
break;
}

uint8_t choiceCount = 4;
if (maxSupportedSampleCount < 2)
choiceCount = 1;
else if (maxSupportedSampleCount < 4)
choiceCount = 2;
else if (maxSupportedSampleCount < 8)
choiceCount = 3;

ImGuiUtilities::PropertyDropdown("MSAA Samples", msaaValues, choiceCount, &index);
switch(index)
{
case 0:
sceneSettings.RenderSettings.MSAASamples = 1;
break;
case 1:
sceneSettings.RenderSettings.MSAASamples = 2;
break;
case 2:
sceneSettings.RenderSettings.MSAASamples = 4;
break;
case 3:
sceneSettings.RenderSettings.MSAASamples = 8;
break;
}


// if(sceneSettings.RenderSettings.MSAASamples > cachedValue)
// sceneSettings.RenderSettings.MSAASamples = Maths::NextPowerOfTwo(sceneSettings.RenderSettings.MSAASamples);
// else if (sceneSettings.RenderSettings.MSAASamples < cachedValue)
// sceneSettings.RenderSettings.MSAASamples = sceneSettings.RenderSettings.MSAASamples / 2U;
// sceneSettings.RenderSettings.MSAASamples = Maths::Clamp(sceneSettings.RenderSettings.MSAASamples, (uint8_t)1, (uint8_t)8);

ImGui::Separator();

auto& registry = m_CurrentScene->GetRegistry();
Expand Down
Loading

0 comments on commit de5dbf5

Please sign in to comment.