more logging stuff
This commit is contained in:
@@ -49,6 +49,7 @@ namespace Game
|
|||||||
char AssetHandlePaths[MaxAssets][128];
|
char AssetHandlePaths[MaxAssets][128];
|
||||||
bool ShowImguiDemo = false;
|
bool ShowImguiDemo = false;
|
||||||
uint8_t DebugCardRotation = 0;
|
uint8_t DebugCardRotation = 0;
|
||||||
|
bool ShortenLogFileNames = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameInstance
|
struct GameInstance
|
||||||
|
|||||||
@@ -320,10 +320,13 @@ namespace Game
|
|||||||
TileHandles[i] = level.PuzzleTiles.New();
|
TileHandles[i] = level.PuzzleTiles.New();
|
||||||
auto& tile = level.PuzzleTiles.Get(TileHandles[i]);
|
auto& tile = level.PuzzleTiles.Get(TileHandles[i]);
|
||||||
tile.EData.MaterialHandle = EMaterial::Default;
|
tile.EData.MaterialHandle = EMaterial::Default;
|
||||||
|
tile.EData.Visible = false;
|
||||||
|
|
||||||
UIPlacedCards[i] = level.UIQuads.New();
|
UIPlacedCards[i] = level.UIQuads.New();
|
||||||
auto& quad = level.UIQuads.Get(UIPlacedCards[i]);
|
auto& quad = level.UIQuads.Get(UIPlacedCards[i]);
|
||||||
quad.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/plane.glb");
|
quad.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/plane.glb");
|
||||||
quad.EData.MaterialHandle = EMaterial::Default;
|
quad.EData.MaterialHandle = EMaterial::Default;
|
||||||
|
quad.EData.Visible = false;
|
||||||
}
|
}
|
||||||
IsSetup = true;
|
IsSetup = true;
|
||||||
LOG("finished setup!");
|
LOG("finished setup!");
|
||||||
@@ -361,8 +364,10 @@ namespace Game
|
|||||||
tile.EData.Transform.SetPosition(cardPos);
|
tile.EData.Transform.SetPosition(cardPos);
|
||||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||||
|
|
||||||
Vec3 fw = {0, 0, 0};
|
Mat4 tp = camTransform.M.Transpose();
|
||||||
Vec3 pos = {camTransform.Position.x, camTransform.Position.y, camTransform.Position.z};
|
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.SetPosition(pos);
|
||||||
quad.EData.Transform.Rotation = {};
|
quad.EData.Transform.Rotation = {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
bx::strCopy(&History.LogBuffer[History.WriteIdx * LogInternal::MaxLineSize], LogInternal::MaxLineSize, OutBuffer);
|
||||||
History.WriteTime[History.WriteIdx] = bx::getHPCounter();
|
History.WriteTime[History.WriteIdx] = bx::getHPCounter();
|
||||||
|
bx::strCopy(&History.FileBuffer[History.WriteIdx * LogInternal::MaxLineSize], LogInternal::MaxLineSize, file);
|
||||||
|
History.LineBuffer[History.WriteIdx] = line;
|
||||||
|
|
||||||
++History.WriteIdx;
|
++History.WriteIdx;
|
||||||
if (History.WriteIdx >= LogInternal::LogHistorySize) History.WriteIdx = 0;
|
if (History.WriteIdx >= LogInternal::LogHistorySize) History.WriteIdx = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace LogInternal
|
|||||||
struct LogHistory
|
struct LogHistory
|
||||||
{
|
{
|
||||||
char LogBuffer[LogInternal::MaxLineSize * LogInternal::LogHistorySize]{0};
|
char LogBuffer[LogInternal::MaxLineSize * LogInternal::LogHistorySize]{0};
|
||||||
|
char FileBuffer[LogInternal::MaxLineSize * LogInternal::LogHistorySize]{0};
|
||||||
|
uint32_t LineBuffer[LogInternal::LogHistorySize]{0};
|
||||||
int32_t WriteIdx = 0;
|
int32_t WriteIdx = 0;
|
||||||
int64_t WriteTime[LogInternal::LogHistorySize]{0};
|
int64_t WriteTime[LogInternal::LogHistorySize]{0};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "bgfx/platform.h"
|
#include "bgfx/platform.h"
|
||||||
#include "bx/bx.h"
|
#include "bx/bx.h"
|
||||||
#include "bx/constants.h"
|
#include "bx/constants.h"
|
||||||
|
#include "bx/debug.h"
|
||||||
#include "bx/filepath.h"
|
#include "bx/filepath.h"
|
||||||
#include "bx/math.h"
|
#include "bx/math.h"
|
||||||
#include "bx/string.h"
|
#include "bx/string.h"
|
||||||
@@ -468,14 +469,39 @@ namespace Game
|
|||||||
auto& shared = GetShared();
|
auto& shared = GetShared();
|
||||||
auto& debug = GetInstance().DebugData;
|
auto& debug = GetInstance().DebugData;
|
||||||
auto& level = GetInstance().GameLevel;
|
auto& level = GetInstance().GameLevel;
|
||||||
|
auto& time = GetInstance().Time;
|
||||||
|
|
||||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||||
{
|
{
|
||||||
debug.DebugCardRotation++;
|
debug.DebugCardRotation++;
|
||||||
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
|
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"))
|
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)
|
for (int32_t i = 0; i < bx::min(100, LogInternal::LogHistorySize); ++i)
|
||||||
{
|
{
|
||||||
int32_t idx = GetLogHistory().WriteIdx - i - 1;
|
int32_t idx = GetLogHistory().WriteIdx - i - 1;
|
||||||
@@ -485,9 +511,28 @@ namespace Game
|
|||||||
{
|
{
|
||||||
int64_t timeOffset = GetLogHistory().WriteTime[idx] - GetInstance().Time.StartTime;
|
int64_t timeOffset = GetLogHistory().WriteTime[idx] - GetInstance().Time.StartTime;
|
||||||
double writeTime = (double)timeOffset / bx::getHPFrequency();
|
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();
|
ImGui::End();
|
||||||
if (ImGui::Begin("Rendering"))
|
if (ImGui::Begin("Rendering"))
|
||||||
|
|||||||
Reference in New Issue
Block a user