mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 07:08:46 +00:00
Fix plotted event not correctly rendered when not the event is not ended
This commit is contained in:
@@ -4,12 +4,13 @@
|
|||||||
#include "CogDebugTracker.h"
|
#include "CogDebugTracker.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
float FCogDebugEvent::GetActualEndTime() const
|
float FCogDebugEvent::GetActualEndTime(const UWorld& World) const
|
||||||
{
|
{
|
||||||
const UWorld* World = Track != nullptr ? Track->World.Get() : nullptr;
|
if (EndTime != 0.0f)
|
||||||
const float WorldTime = World != nullptr ? World->GetTimeSeconds() : 0.0f;
|
{ return EndTime; }
|
||||||
const float ActualEndTime = EndTime != 0.0f ? EndTime : WorldTime;
|
|
||||||
return ActualEndTime;
|
const float WorldTime = World.GetTimeSeconds();
|
||||||
|
return WorldTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ void FCogDebugTracker::InitializeTrack(FCogDebugTrack& OutTrack, const UWorld* I
|
|||||||
}
|
}
|
||||||
|
|
||||||
OutTrack.Id = InTrackId;
|
OutTrack.Id = InTrackId;
|
||||||
OutTrack.World = InWorld;
|
|
||||||
OutTrack.Time = InWorld->GetTimeSeconds();
|
OutTrack.Time = InWorld->GetTimeSeconds();
|
||||||
OutTrack.Frame = GFrameCounter;
|
OutTrack.Frame = GFrameCounter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ struct COGDEBUG_API FCogDebugEventParams
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
struct COGDEBUG_API FCogDebugEvent
|
struct COGDEBUG_API FCogDebugEvent
|
||||||
{
|
{
|
||||||
float GetActualEndTime() const;
|
float GetActualEndTime(const UWorld& World) const;
|
||||||
|
|
||||||
uint64 GetActualEndFrame() const;
|
uint64 GetActualEndFrame() const;
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,8 @@ void FCogEngineWindow_Plots::RenderPlots(FCogDebugTracker& InTracker)
|
|||||||
Config->TimeRange = TimeRange;
|
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
|
// 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)
|
for (const FCogDebugEvent& Event : InTrack.Events)
|
||||||
{
|
{
|
||||||
const ImVec2 PosBot = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.8f));
|
const ImVec2 PosStartBot = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.8f));
|
||||||
const ImVec2 PosTop = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.2f));
|
const ImVec2 PosStartTop = ImPlot::PlotToPixels(ImPlotPoint(Event.StartTime, Event.Row + 0.2f));
|
||||||
const ImVec2 PosMid(PosBot.x, PosBot.y + (PosTop.y - PosBot.y) * 0.5f);
|
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;
|
const bool IsInstant = Event.StartTime == Event.EndTime;
|
||||||
if (IsInstant)
|
if (IsInstant)
|
||||||
@@ -652,10 +658,8 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventTrack& InTrack, const ch
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const float ActualEndTime = Event.GetActualEndTime();
|
const ImVec2 Min = ImVec2(PosStartBot.x, PosStartBot.y);
|
||||||
const ImVec2 PosEnd = ImPlot::PlotToPixels(ImPlotPoint(ActualEndTime, 0));
|
const ImVec2 Max = ImVec2(PosEnd.x, PosStartTop.y);
|
||||||
const ImVec2 Min = ImVec2(PosBot.x, PosBot.y);
|
|
||||||
const ImVec2 Max = ImVec2(PosEnd.x, PosTop.y);
|
|
||||||
|
|
||||||
const ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll;
|
const ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll;
|
||||||
PlotDrawList->AddRect(Min, Max, Event.BorderColor, 6.0f, Flags);
|
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)
|
if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr)
|
||||||
{
|
{
|
||||||
@@ -718,7 +722,7 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEve
|
|||||||
//------------------------
|
//------------------------
|
||||||
if (HoveredEvent->EndTime != HoveredEvent->StartTime)
|
if (HoveredEvent->EndTime != HoveredEvent->StartTime)
|
||||||
{
|
{
|
||||||
const float ActualEndTime = HoveredEvent->GetActualEndTime();
|
const float ActualEndTime = HoveredEvent->GetActualEndTime(*GetWorld());
|
||||||
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame();
|
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame();
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ protected:
|
|||||||
|
|
||||||
virtual void RenderEvents(FCogDebugEventTrack& InTrack, const char* InLabel, const ImVec2& InPlotMin, const ImVec2& InPlotMax) const;
|
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);
|
virtual void AssignToGraphAndAxis(FCogDebugTracker& InTracker, FName InName, int32 InGraphIndex, ImAxis InYAxis);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user