diff --git a/src/game/Instance.h b/src/game/Instance.h index c69cc22..0ec4e74 100644 --- a/src/game/Instance.h +++ b/src/game/Instance.h @@ -49,6 +49,7 @@ namespace Game char AssetHandlePaths[MaxAssets][128]; bool ShowImguiDemo = false; uint8_t DebugCardRotation = 0; + bool ShortenLogFileNames = true; }; struct GameInstance diff --git a/src/game/Level.cpp b/src/game/Level.cpp index 2079115..ea79eb2 100644 --- a/src/game/Level.cpp +++ b/src/game/Level.cpp @@ -320,10 +320,13 @@ namespace Game TileHandles[i] = level.PuzzleTiles.New(); auto& tile = level.PuzzleTiles.Get(TileHandles[i]); tile.EData.MaterialHandle = EMaterial::Default; + tile.EData.Visible = false; + UIPlacedCards[i] = level.UIQuads.New(); auto& quad = level.UIQuads.Get(UIPlacedCards[i]); quad.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/plane.glb"); quad.EData.MaterialHandle = EMaterial::Default; + quad.EData.Visible = false; } IsSetup = true; LOG("finished setup!"); @@ -361,8 +364,10 @@ namespace Game tile.EData.Transform.SetPosition(cardPos); bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f); - Vec3 fw = {0, 0, 0}; - Vec3 pos = {camTransform.Position.x, camTransform.Position.y, camTransform.Position.z}; + Mat4 tp = camTransform.M.Transpose(); + Vec3 fw = {tp.M[8], tp.M[9], tp.M[10]}; + Vec3 pos = camTransform.GetPosition() * -1; + pos += fw; quad.EData.Transform.SetPosition(pos); quad.EData.Transform.Rotation = {}; } diff --git a/src/game/Log.cpp b/src/game/Log.cpp index 2603f8d..8ad286d 100644 --- a/src/game/Log.cpp +++ b/src/game/Log.cpp @@ -41,6 +41,9 @@ void Log(ELogType logType, const char* file, uint32_t line, const char* format, bx::strCopy(&History.LogBuffer[History.WriteIdx * LogInternal::MaxLineSize], LogInternal::MaxLineSize, OutBuffer); History.WriteTime[History.WriteIdx] = bx::getHPCounter(); + bx::strCopy(&History.FileBuffer[History.WriteIdx * LogInternal::MaxLineSize], LogInternal::MaxLineSize, file); + History.LineBuffer[History.WriteIdx] = line; + ++History.WriteIdx; if (History.WriteIdx >= LogInternal::LogHistorySize) History.WriteIdx = 0; } diff --git a/src/game/Log.h b/src/game/Log.h index cc6daf9..f670ea7 100644 --- a/src/game/Log.h +++ b/src/game/Log.h @@ -36,6 +36,8 @@ namespace LogInternal struct LogHistory { char LogBuffer[LogInternal::MaxLineSize * LogInternal::LogHistorySize]{0}; + char FileBuffer[LogInternal::MaxLineSize * LogInternal::LogHistorySize]{0}; + uint32_t LineBuffer[LogInternal::LogHistorySize]{0}; int32_t WriteIdx = 0; int64_t WriteTime[LogInternal::LogHistorySize]{0}; }; diff --git a/src/game/rendering/Rendering.cpp b/src/game/rendering/Rendering.cpp index 65ca170..a1ba82c 100644 --- a/src/game/rendering/Rendering.cpp +++ b/src/game/rendering/Rendering.cpp @@ -12,6 +12,7 @@ #include "bgfx/platform.h" #include "bx/bx.h" #include "bx/constants.h" +#include "bx/debug.h" #include "bx/filepath.h" #include "bx/math.h" #include "bx/string.h" @@ -468,14 +469,39 @@ namespace Game auto& shared = GetShared(); auto& debug = GetInstance().DebugData; auto& level = GetInstance().GameLevel; + auto& time = GetInstance().Time; if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { debug.DebugCardRotation++; if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0; } + ImGui::SetNextWindowPos({0, 0}); + if (ImGui::Begin("Stats", + nullptr, + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs | + ImGuiWindowFlags_AlwaysAutoResize)) + { + if (GetInstance().Player.CameraM == CameraMode::Freefly) + { + ImGui::PushStyleColor(ImGuiCol_Text, {0.8f, 0.1f, 0.1f, 1.0f}); + ImGui::Text("NOCLIP"); + ImGui::PopStyleColor(); + } + ImGui::Text("Delta: %.01fms", time.Delta * 1000); + ImGui::Text("FPS: %.0f", 1.0 / time.Delta); + } + ImGui::End(); if (ImGui::Begin("Log")) { + ImGui::Checkbox("Shorten File Names", &GetInstance().DebugData.ShortenLogFileNames); + ImGui::BeginTable( + "tbl", 4, ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_SizingFixedFit); + ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize); + ImGui::TableSetupColumn("Log"); + ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize); + ImGui::TableSetupColumn("File", ImGuiTableColumnFlags_NoResize); + ImGui::TableHeadersRow(); for (int32_t i = 0; i < bx::min(100, LogInternal::LogHistorySize); ++i) { int32_t idx = GetLogHistory().WriteIdx - i - 1; @@ -485,9 +511,28 @@ namespace Game { int64_t timeOffset = GetLogHistory().WriteTime[idx] - GetInstance().Time.StartTime; double writeTime = (double)timeOffset / bx::getHPFrequency(); - ImGui::Text("%.04f: %s", writeTime, line); + uint32_t fileLine = GetLogHistory().LineBuffer[idx]; + const char* filePath = &GetLogHistory().FileBuffer[idx * LogInternal::MaxLineSize]; + const char* filePathRes = GetInstance().DebugData.ShortenLogFileNames + ? bx::FilePath{filePath}.getFileName().getPtr() + : filePath; + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%.01f", writeTime); + + ImGui::TableNextColumn(); + ImGui::Text("%s", line); + ImGui::SetItemTooltip("%f\n%s%s:%u", writeTime, line, filePath, fileLine); + + ImGui::TableNextColumn(); + ImGui::Text("%u", fileLine); + + ImGui::TableNextColumn(); + ImGui::Text("%s", filePathRes); } } + ImGui::EndTable(); } ImGui::End(); if (ImGui::Begin("Rendering"))