diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugEvent.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugEvent.cpp index 8baa0ac..a7b5ebc 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugEvent.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugEvent.cpp @@ -4,12 +4,13 @@ #include "CogDebugTracker.h" //-------------------------------------------------------------------------------------------------------------------------- -float FCogDebugEvent::GetActualEndTime() const +float FCogDebugEvent::GetActualEndTime(const UWorld& World) const { - const UWorld* World = Track != nullptr ? Track->World.Get() : nullptr; - const float WorldTime = World != nullptr ? World->GetTimeSeconds() : 0.0f; - const float ActualEndTime = EndTime != 0.0f ? EndTime : WorldTime; - return ActualEndTime; + if (EndTime != 0.0f) + { return EndTime; } + + const float WorldTime = World.GetTimeSeconds(); + return WorldTime; } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugTracker.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugTracker.cpp index 5095ab4..dc58710 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugTracker.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugTracker.cpp @@ -71,7 +71,6 @@ void FCogDebugTracker::InitializeTrack(FCogDebugTrack& OutTrack, const UWorld* I } OutTrack.Id = InTrackId; - OutTrack.World = InWorld; OutTrack.Time = InWorld->GetTimeSeconds(); OutTrack.Frame = GFrameCounter; } diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugEvent.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugEvent.h index 75fa2c2..60c8ee0 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugEvent.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugEvent.h @@ -17,7 +17,7 @@ struct COGDEBUG_API FCogDebugEventParams //-------------------------------------------------------------------------------------------------------------------------- struct COGDEBUG_API FCogDebugEvent { - float GetActualEndTime() const; + float GetActualEndTime(const UWorld& World) const; uint64 GetActualEndFrame() const; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 179df8b..ede02ce 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -383,7 +383,8 @@ void FCogEngineWindow_Plots::RenderPlots(FCogDebugTracker& InTracker) Config->TimeRange = TimeRange; } - const float Time = GetWorld() ? GetWorld()->GetTimeSeconds() : 0.0; + const UWorld* World = GetWorld(); + const float Time = World != nullptr ? World->GetTimeSeconds() : 0.0; //------------------------------------------------------------------ // Setup all the X axis limits. Must be done before calling @@ -633,9 +634,14 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventTrack& InTrack, const ch for (const FCogDebugEvent& Event : InTrack.Events) { - const ImVec2 PosBot = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.8f)); - const ImVec2 PosTop = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.2f)); - const ImVec2 PosMid(PosBot.x, PosBot.y + (PosTop.y - PosBot.y) * 0.5f); + const ImVec2 PosStartBot = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.8f)); + const ImVec2 PosStartTop = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.2f)); + const ImVec2 PosMid(PosStartBot.x, PosStartBot.y + (PosStartTop.y - PosStartBot.y) * 0.5f); + const ImVec2 PosEnd = ImPlot::PlotToPixels(ImPlotPoint(Event.GetActualEndTime(*GetWorld()), 0)); + + // Clipping + if (PosStartBot.x > InPlotMax.x || PosEnd.x < InPlotMin.x) + { continue; } const bool IsInstant = Event.StartTime == Event.EndTime; if (IsInstant) @@ -652,10 +658,8 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventTrack& InTrack, const ch } else { - const float ActualEndTime = Event.GetActualEndTime(); - const ImVec2 PosEnd = ImPlot::PlotToPixels(ImPlotPoint(ActualEndTime, 0)); - const ImVec2 Min = ImVec2(PosBot.x, PosBot.y); - const ImVec2 Max = ImVec2(PosEnd.x, PosTop.y); + const ImVec2 Min = ImVec2(PosStartBot.x, PosStartBot.y); + const ImVec2 Max = ImVec2(PosEnd.x, PosStartTop.y); const ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll; PlotDrawList->AddRect(Min, Max, Event.BorderColor, 6.0f, Flags); @@ -687,7 +691,7 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventTrack& InTrack, const ch } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry) +void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry) const { if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr) { @@ -718,7 +722,7 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEve //------------------------ if (HoveredEvent->EndTime != HoveredEvent->StartTime) { - const float ActualEndTime = HoveredEvent->GetActualEndTime(); + const float ActualEndTime = HoveredEvent->GetActualEndTime(*GetWorld()); const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame(); ImGui::TableNextRow(); diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h index 2249316..6959362 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h @@ -47,7 +47,7 @@ protected: virtual void RenderEvents(FCogDebugEventTrack& InTrack, const char* InLabel, const ImVec2& InPlotMin, const ImVec2& InPlotMax) const; - static void RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry); + virtual void RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry) const; virtual void AssignToGraphAndAxis(FCogDebugTracker& InTracker, FName InName, int32 InGraphIndex, ImAxis InYAxis);