mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
Major Change - Rework how Cog gets integrated
Cog integration has been reworked to make it easier, to keep Cog available between level loadings, and to properly tick ImGui while the game is paused. Cog 's WindowManager is now a GameInstanceSubsystem. The WindowManager ticks ImGui and the windows during the OnWorldPostActorTick delegate. (If this is not working for your project, don't hesitate to open an issue.) Check the readme to see how to integrate Cog. The Plot debug functions (displayed by the Engine/Plot window) have been reworked as they were not properly working in Multi PIE in Single Process. API changes: - use FCogDebug::Plot instead of FCogDebugPlot::PlotValue - use FCogDebug::InstantEvent instead of FCogDebugPlot::PlotEventInstant - use FCogDebug::StartEvent instead of FCogDebugPlot::PlotEventStart - use FCogDebug::StopEvent instead of FCogDebugPlot::PlotEventStop
This commit is contained in:
@@ -9,86 +9,21 @@
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TWeakObjectPtr<AActor> FCogDebug::Selection[] = {};
|
||||
TMap<int32, FCogDebugContext> FCogDebug::DebugContexts;
|
||||
FCogDebugSettings FCogDebug::Settings = FCogDebugSettings();
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::Reset()
|
||||
FCogDebugContext& FCogDebug::Get(const int32 InPieId)
|
||||
{
|
||||
Settings = FCogDebugSettings();
|
||||
FCogDebugContext& Context = DebugContexts.FindOrAdd(InPieId);
|
||||
return Context;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
|
||||
FCogDebugContext& FCogDebug::Get()
|
||||
{
|
||||
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (World->GetNetMode() == NM_DedicatedServer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection[GetPieSessionId()].Get(), Settings.bIsFilteringBySelection);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection)
|
||||
{
|
||||
return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection)
|
||||
{
|
||||
if (InIsFilteringBySelection == false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (WorldContextObject == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const AActor* SelectionPtr = InSelection;
|
||||
if (SelectionPtr == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const UObject* Outer = WorldContextObject;
|
||||
for (;;)
|
||||
{
|
||||
if (SelectionPtr == Outer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Cast<ICogCommonDebugFilteredActorInterface>(Outer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const UObject* NewOuter = Outer->GetOuter();
|
||||
if (NewOuter == Outer || NewOuter == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Outer = NewOuter;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogDebug::GetSelection()
|
||||
{
|
||||
return Selection[GetPieSessionId()].Get();
|
||||
const int32 PieId = GetPieSessionId();
|
||||
return Get(PieId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -107,31 +42,91 @@ int32 FCogDebug::GetPieSessionId()
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::SetSelection(const UWorld* World, AActor* Value)
|
||||
void FCogDebug::Reset()
|
||||
{
|
||||
Selection[GetPieSessionId()] = Value;
|
||||
Settings = FCogDebugSettings();
|
||||
}
|
||||
|
||||
ReplicateSelection(World, Value);
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
|
||||
{
|
||||
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
if (World == nullptr)
|
||||
{ return true; }
|
||||
|
||||
if (World->GetNetMode() == NM_DedicatedServer)
|
||||
{ return true; }
|
||||
|
||||
const bool Result = IsDebugActiveForObject_Internal(WorldContextObject, GetSelection(), Settings.bIsFilteringBySelection);
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection)
|
||||
{
|
||||
return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection)
|
||||
{
|
||||
if (InIsFilteringBySelection == false)
|
||||
{ return true; }
|
||||
|
||||
if (WorldContextObject == nullptr)
|
||||
{ return true; }
|
||||
|
||||
const AActor* SelectionPtr = InSelection;
|
||||
if (SelectionPtr == nullptr)
|
||||
{ return true; }
|
||||
|
||||
const UObject* Outer = WorldContextObject;
|
||||
for (;;)
|
||||
{
|
||||
if (SelectionPtr == Outer)
|
||||
{ return true; }
|
||||
|
||||
if (Cast<ICogCommonDebugFilteredActorInterface>(Outer))
|
||||
{ return false; }
|
||||
|
||||
const UObject* NewOuter = Outer->GetOuter();
|
||||
if (NewOuter == Outer || NewOuter == nullptr)
|
||||
{ return true; }
|
||||
|
||||
Outer = NewOuter;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogDebug::GetSelection()
|
||||
{
|
||||
return Get().Selection.Get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugTracker& FCogDebug::GetTracker()
|
||||
{
|
||||
return Get().Tracker;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::SetSelection(AActor* InValue)
|
||||
{
|
||||
Get().Selection = InValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::ReplicateSelection(const UWorld* World, AActor* Value)
|
||||
{
|
||||
if (World == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(*World);
|
||||
if (Replicator == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
if (Replicator->HasAuthority())
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
Replicator->Server_SetSelection(Value, Settings.ReplicateSelection);
|
||||
}
|
||||
@@ -172,13 +167,9 @@ float FCogDebug::GetDebugDuration(bool bPersistent)
|
||||
float FCogDebug::GetDebugTextDuration(bool bPersistent)
|
||||
{
|
||||
if (bPersistent)
|
||||
{
|
||||
return Settings.Persistent ? 100 : Settings.Duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
{ return Settings.Persistent ? 100 : Settings.Duration; }
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -215,14 +206,12 @@ uint8 FCogDebug::GetDebugDepthPriority(float InDepthPriority)
|
||||
FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent)
|
||||
{
|
||||
if (bPersistent == false)
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
{ return Color; }
|
||||
|
||||
switch (Settings.RecolorMode)
|
||||
{
|
||||
case ECogDebugRecolorMode::None:
|
||||
{
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
|
||||
@@ -285,9 +274,7 @@ bool FCogDebug::IsSecondarySkeletonBone(FName BoneName)
|
||||
for (const FString& Wildcard : Settings.SecondaryBoneWildcards)
|
||||
{
|
||||
if (BoneString.MatchesWildcard(Wildcard))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
{ return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -367,4 +354,40 @@ void FCogDebug::GetDebugDrawSweepSettings(FCogDebugDrawSweepParams& Params)
|
||||
GetDebugDrawLineTraceSettings(Params);
|
||||
|
||||
Params.DrawHitShapes = Settings.CollisionQueryDrawHitShapes;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::Plot(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const float Value)
|
||||
{
|
||||
Get().Tracker.Plot(WorldContextObject, InTrackId, Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebug::StartEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, bool IsInstant, const int32 Row, const FColor& Color)
|
||||
{
|
||||
return Get().Tracker.StartEvent(WorldContextObject, InTrackId, InEventId, IsInstant, Row, Color);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebug::InstantEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugTrackId& InEventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
return Get().Tracker.InstantEvent(WorldContextObject, InTrackId, InEventId, Row, Color);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebug::StartEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugTrackId& InEventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
return Get().Tracker.StartEvent(WorldContextObject, InTrackId, InEventId, Row, Color);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebug::StopEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugTrackId& InEventId)
|
||||
{
|
||||
return Get().Tracker.StopEvent(WorldContextObject, InTrackId, InEventId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebug::ToggleEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugTrackId& InEventId, const bool ToggleValue, const int32 Row, const FColor& Color)
|
||||
{
|
||||
return Get().Tracker.ToggleEvent(WorldContextObject, InTrackId, InEventId, ToggleValue, Row, Color);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "CogDebugEvent.h"
|
||||
|
||||
#include "CogDebugTrack.h"
|
||||
#include "CogDebugTracker.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugEvent::GetActualEndTime() 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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
uint64 FCogDebugEvent::GetActualEndFrame() const
|
||||
{
|
||||
const float ActualEndFame = EndFrame != 0.0f ? EndFrame : GFrameCounter;
|
||||
return ActualEndFame;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEvent::AddParam(const FCogDebugEventParamId& InParamId, bool InValue)
|
||||
{
|
||||
if (Track == nullptr || Track->Owner == nullptr || Track->Owner->IsVisible == false)
|
||||
{ return *this; }
|
||||
|
||||
return AddParam(InParamId, FString::Printf(TEXT("%s"), InValue ? TEXT("True") : TEXT("False")));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEvent::AddParam(const FCogDebugEventParamId& InParamId, int InValue)
|
||||
{
|
||||
if (Track == nullptr || Track->Owner == nullptr || Track->Owner->IsVisible == false)
|
||||
{ return *this; }
|
||||
|
||||
return AddParam(InParamId, FString::Printf(TEXT("%d"), InValue));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEvent::AddParam(const FCogDebugEventParamId& InParamId, float InValue)
|
||||
{
|
||||
if (Track == nullptr || Track->Owner == nullptr || Track->Owner->IsVisible == false)
|
||||
{ return *this; }
|
||||
|
||||
return AddParam(InParamId, FString::Printf(TEXT("%0.2f"), InValue));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEvent::AddParam(const FCogDebugEventParamId& InParamId, FName InValue)
|
||||
{
|
||||
if (Track == nullptr || Track->Owner == nullptr || Track->Owner->IsVisible == false)
|
||||
{ return *this; }
|
||||
|
||||
return AddParam(InParamId, InValue.ToString());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEvent::AddParam(const FCogDebugEventParamId& InParamId, const FString& InValue)
|
||||
{
|
||||
if (Track == nullptr || Track->Owner == nullptr || Track->Owner->IsVisible == false)
|
||||
{ return *this; }
|
||||
|
||||
if (InParamId == "Name")
|
||||
{
|
||||
DisplayName = InValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
FCogDebugEventParams& Param = Params.AddDefaulted_GetRef();
|
||||
Param.Name = InParamId;
|
||||
Param.Value = InValue;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
#include "CogDebugEventTrack.h"
|
||||
|
||||
#include "CogDebugTracker.h"
|
||||
#include "CogDebugHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEventTrack::AddEvent(
|
||||
const FString& OwnerName,
|
||||
const bool IsInstant,
|
||||
const FName EventId,
|
||||
const int32 Row,
|
||||
const FColor& Color)
|
||||
{
|
||||
if (Events.Max() < 200)
|
||||
{
|
||||
Events.Reserve(200);
|
||||
}
|
||||
|
||||
//----------------------------
|
||||
// Stop if it already exist.
|
||||
//----------------------------
|
||||
StopEvent(EventId);
|
||||
|
||||
FCogDebugEvent* Event;
|
||||
int32 AddedIndex;
|
||||
|
||||
if (Events.Num() < Events.Max())
|
||||
{
|
||||
Event = &Events.AddDefaulted_GetRef();
|
||||
AddedIndex = Events.Num() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Event = &Events[EventOffset];
|
||||
AddedIndex = EventOffset;
|
||||
EventOffset = (EventOffset + 1) % Events.Num();
|
||||
}
|
||||
|
||||
Event->Id = EventId;
|
||||
Event->OwnerName = OwnerName;
|
||||
Event->DisplayName = EventId.ToString();
|
||||
Event->StartTime = Time;
|
||||
Event->EndTime = IsInstant ? Time : 0.0f;
|
||||
Event->StartFrame = Frame;
|
||||
Event->EndFrame = IsInstant ? Frame : 0.0f;
|
||||
Event->Row = (Row == FCogDebugTracker::AutoRow) ? Owner->FindFreeViewRow(GraphIndex) : Row;
|
||||
|
||||
if (IsInstant == false)
|
||||
{
|
||||
Owner->OccupyViewRow(GraphIndex, Event->Row);
|
||||
}
|
||||
|
||||
MaxRow = FMath::Max(Event->Row, MaxRow);
|
||||
|
||||
const FColor BorderColor = FCogDebugHelper::GetAutoColor(EventId, Color).WithAlpha(200);
|
||||
const FColor FillColor = BorderColor.WithAlpha(100);
|
||||
Event->BorderColor = FCogImguiHelper::ToImColor(BorderColor);
|
||||
Event->FillColor = FCogImguiHelper::ToImColor(FillColor);
|
||||
|
||||
Owner->LastAddedEventTrackId = Id;
|
||||
Owner->LastAddedEventIndex = AddedIndex;
|
||||
|
||||
return *Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugEventTrack::StopEvent(const FCogDebugEventId EventId)
|
||||
{
|
||||
FCogDebugEvent* Event = FindLastEventByName(EventId);
|
||||
if (Event == nullptr)
|
||||
{
|
||||
return Owner->DefaultEvent;
|
||||
}
|
||||
|
||||
if (Event->EndTime == 0.0f)
|
||||
{
|
||||
Event->EndTime = Time;
|
||||
Event->EndFrame = Frame;
|
||||
|
||||
Owner->FreeViewRow(GraphIndex, Event->Row);
|
||||
}
|
||||
|
||||
return *Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent* FCogDebugEventTrack::GetLastEvent()
|
||||
{
|
||||
if (Events.Num() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 Index = Events.Num() - 1;
|
||||
if (EventOffset != 0)
|
||||
{
|
||||
Index = (Index + EventOffset) % Events.Num();
|
||||
}
|
||||
|
||||
return &Events[Index];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent* FCogDebugEventTrack::FindLastEventByName(FCogDebugEventId EventId)
|
||||
{
|
||||
for (int32 i = Events.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// The array cycle so we must offset the index
|
||||
//--------------------------------------------------
|
||||
int32 Index = i;
|
||||
if (EventOffset != 0)
|
||||
{
|
||||
Index = (i + EventOffset) % Events.Num();
|
||||
}
|
||||
|
||||
if (Events[Index].Id == EventId)
|
||||
{
|
||||
return &Events[Index];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugEventTrack::Clear()
|
||||
{
|
||||
FCogDebugTrack::Clear();
|
||||
|
||||
Owner->ResetLastAddedEvent();
|
||||
|
||||
MaxRow = 0;
|
||||
|
||||
if (Events.Num() > 0)
|
||||
{
|
||||
Events.Empty();
|
||||
Events.Shrink();
|
||||
EventOffset = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
#include "CogDebugPlot.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
FCogDebugPlotEvent FCogDebugPlot::DefaultEvent;
|
||||
TMap<FName, FCogDebugValueHistory> FCogDebugPlot::Values;
|
||||
TMap<FName, FCogDebugEventHistory> FCogDebugPlot::Events;
|
||||
int32 FCogDebugPlot::NumRecordedValues = 2000;
|
||||
bool FCogDebugPlot::IsVisible = false;
|
||||
bool FCogDebugPlot::Pause = false;
|
||||
bool FCogDebugPlot::RecordValuesWhenPause = true;
|
||||
FName FCogDebugPlot::LastAddedEventPlotName = NAME_None;
|
||||
int32 FCogDebugPlot::LastAddedEventIndex = INDEX_NONE;
|
||||
TMap<int32, TMap<int32, int32>> FCogDebugPlot::OccupationMap;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::Reset()
|
||||
{
|
||||
Values.Empty();
|
||||
Events.Empty();
|
||||
OccupationMap.Empty();
|
||||
Pause = false;
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::Clear()
|
||||
{
|
||||
for (auto& kv : Values)
|
||||
{
|
||||
kv.Value.Clear();
|
||||
}
|
||||
|
||||
for (auto& kv : Events)
|
||||
{
|
||||
kv.Value.Clear();
|
||||
}
|
||||
|
||||
OccupationMap.Empty();
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugPlot::ShouldRegisterEntry(const UObject* WorldContextObject, const UWorld*& World)
|
||||
{
|
||||
//----------------------------------------------------------
|
||||
// When not visible, we don't go further for performances.
|
||||
//----------------------------------------------------------
|
||||
if (IsVisible == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::InitializeEntry(FCogDebugHistory& OutValue, const UWorld* InWorld, const FName InName)
|
||||
{
|
||||
const float Time = InWorld->GetTimeSeconds();
|
||||
if (Time < OutValue.Time)
|
||||
{
|
||||
OutValue.Clear();
|
||||
}
|
||||
|
||||
OutValue.Name = InName;
|
||||
OutValue.World = InWorld;
|
||||
OutValue.Time = InWorld->GetTimeSeconds();
|
||||
OutValue.Frame = GFrameCounter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::OccupyGraphRow(const int32 InGraphIndex, const int32 InRow)
|
||||
{
|
||||
TMap<int32, int32>& GraphOccupation = OccupationMap.FindOrAdd(InGraphIndex);
|
||||
|
||||
if (int32* RowOccupation = GraphOccupation.Find(InRow))
|
||||
{
|
||||
(*RowOccupation)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphOccupation.Add(InRow, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::FreeGraphRow(const int32 InGraphIndex, const int32 Row)
|
||||
{
|
||||
TMap<int32, int32>* GraphOccupation = OccupationMap.Find(InGraphIndex);
|
||||
if (GraphOccupation == nullptr)
|
||||
{ return; }
|
||||
|
||||
int32* RowOccupation = GraphOccupation->Find(Row);
|
||||
if (RowOccupation == nullptr)
|
||||
{ return; }
|
||||
|
||||
(*RowOccupation)--;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int32 FCogDebugPlot::FindFreeGraphRow(const int32 InGraphIndex)
|
||||
{
|
||||
constexpr int32 MaxRows = 100;
|
||||
|
||||
int32 FreeRow = 0;
|
||||
|
||||
TMap<int32, int32>* GraphOccupation = OccupationMap.Find(InGraphIndex);
|
||||
if (GraphOccupation == nullptr)
|
||||
{
|
||||
return FreeRow;
|
||||
}
|
||||
|
||||
for (; FreeRow < MaxRows; ++FreeRow)
|
||||
{
|
||||
const int32* Occupation = GraphOccupation->Find(FreeRow);
|
||||
if (Occupation == nullptr || *Occupation == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return FreeRow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugHistory* FCogDebugPlot::FindEntry(const FName InName)
|
||||
{
|
||||
FCogDebugHistory* Entry = Events.Find(InName);
|
||||
if (Entry != nullptr)
|
||||
{
|
||||
return Entry;
|
||||
}
|
||||
|
||||
Entry = Values.Find(InName);
|
||||
if (Entry != nullptr)
|
||||
{
|
||||
return Entry;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::SetNumRecordedValues(int32 InValue)
|
||||
{
|
||||
NumRecordedValues = InValue;
|
||||
|
||||
for (auto& kv : Values)
|
||||
{
|
||||
kv.Value.SetNumRecordedValues(InValue);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "CogDebugPlotBlueprint.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
#include "CogDebugPlot.h"
|
||||
#include "CogDebugTracker.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogDebugPlotBlueprint::Plot(const UObject* Owner, const FName Name, const float Value)
|
||||
{
|
||||
#if ENABLE_COG
|
||||
FCogDebugPlot::PlotValue(Owner, Name, Value);
|
||||
FCogDebug::Plot(Owner, Name, Value);
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
#include "CogDebugPlot.h"
|
||||
|
||||
#include "CogDebugHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugPlotEvent::GetActualEndTime(const FCogDebugHistory& Plot) const
|
||||
{
|
||||
const UWorld* World = Plot.World.Get();
|
||||
const float WorldTime = World != nullptr ? World->GetTimeSeconds() : 0.0f;
|
||||
const float ActualEndTime = EndTime != 0.0f ? EndTime : WorldTime;
|
||||
return ActualEndTime;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
uint64 FCogDebugPlotEvent::GetActualEndFrame(const FCogDebugHistory& Plot) const
|
||||
{
|
||||
const float ActualEndFame = EndFrame != 0.0f ? EndFrame : GFrameCounter;
|
||||
return ActualEndFame;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, bool Value)
|
||||
{
|
||||
if (FCogDebugPlot::IsVisible)
|
||||
{
|
||||
AddParam(Name, FString::Printf(TEXT("%s"), Value ? TEXT("True") : TEXT("False")));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, int Value)
|
||||
{
|
||||
if (FCogDebugPlot::IsVisible)
|
||||
{
|
||||
AddParam(Name, FString::Printf(TEXT("%d"), Value));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, float Value)
|
||||
{
|
||||
if (FCogDebugPlot::IsVisible)
|
||||
{
|
||||
AddParam(Name, FString::Printf(TEXT("%0.2f"), Value));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, FName Value)
|
||||
{
|
||||
if (FCogDebugPlot::IsVisible)
|
||||
{
|
||||
AddParam(Name, Value.ToString());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, const FString& Value)
|
||||
{
|
||||
if (FCogDebugPlot::IsVisible)
|
||||
{
|
||||
|
||||
if (Name == "Name")
|
||||
{
|
||||
DisplayName = Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
FCogDebugPlotEventParams& Param = Params.AddDefaulted_GetRef();
|
||||
Param.Name = Name;
|
||||
Param.Value = Value;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugEventHistory::AddEvent(
|
||||
const FString& OwnerName,
|
||||
const bool IsInstant,
|
||||
const FName EventId,
|
||||
const int32 Row,
|
||||
const FColor& Color)
|
||||
{
|
||||
if (Events.Max() < 200)
|
||||
{
|
||||
Events.Reserve(200);
|
||||
}
|
||||
|
||||
//----------------------------
|
||||
// Stop if it already exist.
|
||||
//----------------------------
|
||||
StopEvent(EventId);
|
||||
|
||||
FCogDebugPlotEvent* Event;
|
||||
int32 AddedIndex;
|
||||
|
||||
if (Events.Num() < Events.Max())
|
||||
{
|
||||
Event = &Events.AddDefaulted_GetRef();
|
||||
AddedIndex = Events.Num() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Event = &Events[EventOffset];
|
||||
AddedIndex = EventOffset;
|
||||
EventOffset = (EventOffset + 1) % Events.Num();
|
||||
}
|
||||
|
||||
Event->Id = EventId;
|
||||
Event->OwnerName = OwnerName;
|
||||
Event->DisplayName = EventId.ToString();
|
||||
Event->StartTime = Time;
|
||||
Event->EndTime = IsInstant ? Time : 0.0f;
|
||||
Event->StartFrame = Frame;
|
||||
Event->EndFrame = IsInstant ? Frame : 0.0f;
|
||||
Event->Row = (Row == FCogDebugPlot::AutoRow) ? FCogDebugPlot::FindFreeGraphRow(GraphIndex) : Row;
|
||||
|
||||
if (IsInstant == false)
|
||||
{
|
||||
FCogDebugPlot::OccupyGraphRow(GraphIndex, Event->Row);
|
||||
}
|
||||
|
||||
MaxRow = FMath::Max(Event->Row, MaxRow);
|
||||
|
||||
const FColor BorderColor = FCogDebugHelper::GetAutoColor(EventId, Color).WithAlpha(200);
|
||||
const FColor FillColor = BorderColor.WithAlpha(100);
|
||||
Event->BorderColor = FCogImguiHelper::ToImColor(BorderColor);
|
||||
Event->FillColor = FCogImguiHelper::ToImColor(FillColor);
|
||||
|
||||
FCogDebugPlot::LastAddedEventPlotName = Name;
|
||||
FCogDebugPlot::LastAddedEventIndex = AddedIndex;
|
||||
|
||||
return *Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugEventHistory::StopEvent(const FName EventId)
|
||||
{
|
||||
FCogDebugPlotEvent* Event = FindLastEventByName(EventId);
|
||||
if (Event == nullptr)
|
||||
{
|
||||
return FCogDebugPlot::DefaultEvent;
|
||||
}
|
||||
|
||||
if (Event->EndTime == 0.0f)
|
||||
{
|
||||
Event->EndTime = Time;
|
||||
Event->EndFrame = Frame;
|
||||
|
||||
FCogDebugPlot::FreeGraphRow(GraphIndex, Event->Row);
|
||||
}
|
||||
|
||||
return *Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent* FCogDebugEventHistory::GetLastEvent()
|
||||
{
|
||||
if (Events.Num() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 Index = Events.Num() - 1;
|
||||
if (EventOffset != 0)
|
||||
{
|
||||
Index = (Index + EventOffset) % Events.Num();
|
||||
}
|
||||
|
||||
return &Events[Index];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent* FCogDebugEventHistory::FindLastEventByName(FName EventId)
|
||||
{
|
||||
for (int32 i = Events.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// The array cycle so we must offset the index
|
||||
//--------------------------------------------------
|
||||
int32 Index = i;
|
||||
if (EventOffset != 0)
|
||||
{
|
||||
Index = (i + EventOffset) % Events.Num();
|
||||
}
|
||||
|
||||
if (Events[Index].Id == EventId)
|
||||
{
|
||||
return &Events[Index];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugEventHistory::Clear()
|
||||
{
|
||||
FCogDebugHistory::Clear();
|
||||
|
||||
FCogDebugPlot::ResetLastAddedEvent();
|
||||
|
||||
MaxRow = 0;
|
||||
|
||||
if (Events.Num() > 0)
|
||||
{
|
||||
Events.Empty();
|
||||
Events.Shrink();
|
||||
EventOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEvent(const UObject* WorldContextObject, const FName PlotName, const FName EventId, bool IsInstant, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugEventHistory* EventHistory = RegisterEvent(WorldContextObject, PlotName);
|
||||
if (EventHistory == nullptr)
|
||||
{
|
||||
ResetLastAddedEvent();
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugPlotEvent& Event = EventHistory->AddEvent(GetNameSafe(WorldContextObject), IsInstant, EventId, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEventInstant(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugPlotEvent& Event = PlotEvent(WorldContextObject, PlotName, EventId, true, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEventStart(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugPlotEvent& Event = PlotEvent(WorldContextObject, PlotName, EventId, false, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEventStop(const UObject* WorldContextObject, const FName PlotName, const FName EventId)
|
||||
{
|
||||
FCogDebugEventHistory* EventHistory = RegisterEvent(WorldContextObject, PlotName);
|
||||
if (EventHistory == nullptr)
|
||||
{
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugPlotEvent& Event = EventHistory->StopEvent(EventId);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEventToggle(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const bool ToggleValue, const int32 Row, const FColor& Color)
|
||||
{
|
||||
if (ToggleValue)
|
||||
{
|
||||
return PlotEventStart(WorldContextObject, PlotName, EventId, Row, Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PlotEventStop(WorldContextObject, PlotName, EventId);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEventHistory* FCogDebugPlot::RegisterEvent(const UObject* InWorldContextObject, const FName InName)
|
||||
{
|
||||
|
||||
const UWorld* World;
|
||||
if (ShouldRegisterEntry(InWorldContextObject, World) == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FCogDebugEventHistory& Event = Events.FindOrAdd(InName);
|
||||
Event.Type = FCogDebugHistoryType::Event;
|
||||
|
||||
InitializeEntry(Event, World, InName);
|
||||
|
||||
return &Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::ResetLastAddedEvent()
|
||||
{
|
||||
LastAddedEventPlotName = NAME_None;
|
||||
LastAddedEventIndex = INDEX_NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent* FCogDebugPlot::GetLastAddedEvent()
|
||||
{
|
||||
FCogDebugEventHistory* EventHistory = Events.Find(LastAddedEventPlotName);
|
||||
if (EventHistory == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return EventHistory->GetLastEvent();
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
#include "CogDebugPlot.h"
|
||||
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugValueHistory::SetNumRecordedValues(const int32 Value)
|
||||
{
|
||||
Values.reserve(Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugValueHistory::AddPoint(float X, float Y)
|
||||
{
|
||||
if (Values.Capacity == 0)
|
||||
{
|
||||
Values.reserve(FCogDebugPlot::NumRecordedValues);
|
||||
}
|
||||
|
||||
if (Values.size() < Values.Capacity)
|
||||
{
|
||||
Values.push_back(ImVec2(X, Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
Values[ValueOffset] = ImVec2(X, Y);
|
||||
ValueOffset = (ValueOffset + 1) % Values.size();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugValueHistory::Clear()
|
||||
{
|
||||
FCogDebugHistory::Clear();
|
||||
|
||||
if (Values.size() > 0)
|
||||
{
|
||||
Values.shrink(0);
|
||||
ValueOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugValueHistory::FindValue(float x, float& y) const
|
||||
{
|
||||
y = 0.0f;
|
||||
|
||||
bool FoundAfter = false;
|
||||
bool FoundBefore = false;
|
||||
|
||||
for (int32 i = Values.size() - 1; i >= 0; --i)
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// The array cycle so we must offset the index
|
||||
//--------------------------------------------------
|
||||
int32 Index = i;
|
||||
if (ValueOffset != 0)
|
||||
{
|
||||
Index = (i + ValueOffset) % Values.size();
|
||||
}
|
||||
|
||||
const ImVec2 Point = Values[Index];
|
||||
if (Point.x > x)
|
||||
{
|
||||
FoundAfter = true;
|
||||
}
|
||||
|
||||
if (Point.x < x)
|
||||
{
|
||||
FoundBefore = true;
|
||||
}
|
||||
|
||||
if (FoundAfter && FoundBefore)
|
||||
{
|
||||
y = Point.y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugValueHistory* FCogDebugPlot::RegisterValue(const UObject* InWorldContextObject, const FName InName)
|
||||
{
|
||||
const UWorld* World;
|
||||
if (ShouldRegisterEntry(InWorldContextObject, World) == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FCogDebugValueHistory& Value = Values.FindOrAdd(InName);
|
||||
Value.Type = FCogDebugHistoryType::Value;
|
||||
|
||||
InitializeEntry(Value, World, InName);
|
||||
|
||||
return &Value;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::PlotValue(const UObject* WorldContextObject, const FName PlotName, const float Value)
|
||||
{
|
||||
if (Pause && RecordValuesWhenPause == false)
|
||||
{ return; }
|
||||
|
||||
FCogDebugValueHistory* ValueHistory = RegisterValue(WorldContextObject, PlotName);
|
||||
if (ValueHistory == nullptr)
|
||||
{ return; }
|
||||
|
||||
ValueHistory->AddPoint(ValueHistory->Time, Value);
|
||||
}
|
||||
@@ -217,11 +217,11 @@ void ACogDebugReplicator::Server_SetSelection_Implementation(AActor* Value, bool
|
||||
|
||||
if (ForceSelection)
|
||||
{
|
||||
FCogDebug::SetSelection(GetWorld(), Value);
|
||||
FCogDebug::SetSelection(Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
FCogDebug::SetSelection(GetWorld(), nullptr);
|
||||
FCogDebug::SetSelection(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
#include "CogDebugTracker.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugEventTrack.h"
|
||||
#include "CogDebugPlotTrack.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
int32 FCogDebugTracker::NumRecordedValues = 2000;
|
||||
FCogDebugEvent FCogDebugTracker::DefaultEvent;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::Reset()
|
||||
{
|
||||
Values.Empty();
|
||||
Events.Empty();
|
||||
OccupationMap.Empty();
|
||||
Pause = false;
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::Clear()
|
||||
{
|
||||
for (auto& kv : Values)
|
||||
{
|
||||
kv.Value.Clear();
|
||||
}
|
||||
|
||||
for (auto& kv : Events)
|
||||
{
|
||||
kv.Value.Clear();
|
||||
}
|
||||
|
||||
OccupationMap.Empty();
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugTracker::CanCreateTrack(const UObject* WorldContextObject, const UWorld*& World) const
|
||||
{
|
||||
//----------------------------------------------------------
|
||||
// When not visible, we don't go further for performances.
|
||||
//----------------------------------------------------------
|
||||
if (IsVisible == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::InitializeTrack(FCogDebugTrack& OutTrack, const UWorld* InWorld, const FCogDebugTrackId& InTrackId)
|
||||
{
|
||||
const float Time = InWorld->GetTimeSeconds();
|
||||
if (Time < OutTrack.Time)
|
||||
{
|
||||
OutTrack.Clear();
|
||||
}
|
||||
|
||||
OutTrack.Id = InTrackId;
|
||||
OutTrack.World = InWorld;
|
||||
OutTrack.Time = InWorld->GetTimeSeconds();
|
||||
OutTrack.Frame = GFrameCounter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::OccupyViewRow(const int32 InViewIndex, const int32 InRow)
|
||||
{
|
||||
TMap<int32, int32>& GraphOccupation = OccupationMap.FindOrAdd(InViewIndex);
|
||||
|
||||
if (int32* RowOccupation = GraphOccupation.Find(InRow))
|
||||
{
|
||||
(*RowOccupation)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphOccupation.Add(InRow, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::FreeViewRow(const int32 InViewIndex, const int32 Row)
|
||||
{
|
||||
TMap<int32, int32>* GraphOccupation = OccupationMap.Find(InViewIndex);
|
||||
if (GraphOccupation == nullptr)
|
||||
{ return; }
|
||||
|
||||
int32* RowOccupation = GraphOccupation->Find(Row);
|
||||
if (RowOccupation == nullptr)
|
||||
{ return; }
|
||||
|
||||
(*RowOccupation)--;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int32 FCogDebugTracker::FindFreeViewRow(const int32 InViewIndex)
|
||||
{
|
||||
constexpr int32 MaxRows = 100;
|
||||
|
||||
int32 FreeRow = 0;
|
||||
|
||||
TMap<int32, int32>* GraphOccupation = OccupationMap.Find(InViewIndex);
|
||||
if (GraphOccupation == nullptr)
|
||||
{
|
||||
return FreeRow;
|
||||
}
|
||||
|
||||
for (; FreeRow < MaxRows; ++FreeRow)
|
||||
{
|
||||
const int32* Occupation = GraphOccupation->Find(FreeRow);
|
||||
if (Occupation == nullptr || *Occupation == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return FreeRow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugTrack* FCogDebugTracker::FindTrack(const FCogDebugTrackId& InTrackId)
|
||||
{
|
||||
FCogDebugTrack* Track = Events.Find(InTrackId);
|
||||
if (Track != nullptr)
|
||||
{
|
||||
return Track;
|
||||
}
|
||||
|
||||
Track = Values.Find(InTrackId);
|
||||
if (Track != nullptr)
|
||||
{
|
||||
return Track;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::SetNumRecordedValues(const int32 InValue)
|
||||
{
|
||||
NumRecordedValues = InValue;
|
||||
|
||||
for (auto& kv : Values)
|
||||
{
|
||||
kv.Value.SetNumPlots(InValue);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotTrack::SetNumPlots(const int32 Value)
|
||||
{
|
||||
Values.reserve(Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotTrack::Plot(float X, float Y)
|
||||
{
|
||||
if (Values.Capacity == 0)
|
||||
{
|
||||
Values.reserve(FCogDebugTracker::NumRecordedValues);
|
||||
}
|
||||
|
||||
if (Values.size() < Values.Capacity)
|
||||
{
|
||||
Values.push_back(ImVec2(X, Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
Values[ValueOffset] = ImVec2(X, Y);
|
||||
ValueOffset = (ValueOffset + 1) % Values.size();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotTrack::Clear()
|
||||
{
|
||||
FCogDebugTrack::Clear();
|
||||
|
||||
if (Values.size() > 0)
|
||||
{
|
||||
Values.shrink(0);
|
||||
ValueOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugPlotTrack::FindValue(float InX, float& OutY) const
|
||||
{
|
||||
OutY = 0.0f;
|
||||
|
||||
bool FoundAfter = false;
|
||||
bool FoundBefore = false;
|
||||
|
||||
for (int32 i = Values.size() - 1; i >= 0; --i)
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// The array cycle so we must offset the index
|
||||
//--------------------------------------------------
|
||||
int32 Index = i;
|
||||
if (ValueOffset != 0)
|
||||
{
|
||||
Index = (i + ValueOffset) % Values.size();
|
||||
}
|
||||
|
||||
const ImVec2 Point = Values[Index];
|
||||
if (Point.x > InX)
|
||||
{
|
||||
FoundAfter = true;
|
||||
}
|
||||
|
||||
if (Point.x < InX)
|
||||
{
|
||||
FoundBefore = true;
|
||||
}
|
||||
|
||||
if (FoundAfter && FoundBefore)
|
||||
{
|
||||
OutY = Point.y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Plot Track Creation
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotTrack* FCogDebugTracker::GetOrCreatePlotTrack(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId)
|
||||
{
|
||||
const UWorld* World;
|
||||
if (CanCreateTrack(InWorldContextObject, World) == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FCogDebugPlotTrack& Track = Values.FindOrAdd(InTrackId);
|
||||
Track.Owner = this;
|
||||
Track.Type = ECogDebugTrackType::Value;
|
||||
|
||||
InitializeTrack(Track, World, InTrackId);
|
||||
|
||||
return &Track;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::Plot(const UObject* InWorldContextObject, const FName InTrackId, const float Value)
|
||||
{
|
||||
if (Pause && RecordValuesWhenPause == false)
|
||||
{ return; }
|
||||
|
||||
FCogDebugPlotTrack* Track = GetOrCreatePlotTrack(InWorldContextObject, InTrackId);
|
||||
if (Track == nullptr)
|
||||
{ return; }
|
||||
|
||||
Track->Plot(Track->Time, Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Event Track Creation
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugTracker::StartEvent(const UObject* InWorldContextObject, const FCogDebugEventId& InTrackId, const FCogDebugEventId& InEventId, bool IsInstant, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugEventTrack* Track = GetOrCreateEventTrack(InWorldContextObject, InTrackId);
|
||||
if (Track == nullptr)
|
||||
{
|
||||
ResetLastAddedEvent();
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugEvent& Event = Track->AddEvent(GetNameSafe(InWorldContextObject), IsInstant, InEventId, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugTracker::InstantEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugEvent& Event = StartEvent(InWorldContextObject, InTrackId, InEventId, true, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugTracker::StartEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugEvent& Event = StartEvent(InWorldContextObject, InTrackId, InEventId, false, Row, Color);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugTracker::StopEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId)
|
||||
{
|
||||
FCogDebugEventTrack* EventHistory = GetOrCreateEventTrack(InWorldContextObject, InTrackId);
|
||||
if (EventHistory == nullptr)
|
||||
{
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugEvent& Event = EventHistory->StopEvent(InEventId);
|
||||
return Event;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent& FCogDebugTracker::ToggleEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const bool ToggleValue, const int32 Row, const FColor& Color)
|
||||
{
|
||||
if (ToggleValue)
|
||||
{
|
||||
return StartEvent(InWorldContextObject, InTrackId, InEventId, Row, Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
return StopEvent(InWorldContextObject, InTrackId, InEventId);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEventTrack* FCogDebugTracker::GetOrCreateEventTrack(const UObject* InWorldContextObject, const FCogDebugEventId& InTrackId)
|
||||
{
|
||||
const UWorld* World;
|
||||
if (CanCreateTrack(InWorldContextObject, World) == false)
|
||||
{ return nullptr; }
|
||||
|
||||
FCogDebugEventTrack& Track = Events.FindOrAdd(InTrackId);
|
||||
Track.Type = ECogDebugTrackType::Event;
|
||||
Track.Owner = this;
|
||||
|
||||
InitializeTrack(Track, World, InTrackId);
|
||||
|
||||
return &Track;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugTracker::ResetLastAddedEvent()
|
||||
{
|
||||
LastAddedEventTrackId = NAME_None;
|
||||
LastAddedEventIndex = INDEX_NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugEvent* FCogDebugTracker::GetLastAddedEvent()
|
||||
{
|
||||
FCogDebugEventTrack* EventHistory = Events.Find(LastAddedEventTrackId);
|
||||
if (EventHistory == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return EventHistory->GetLastEvent();
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugEvent.h"
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebugTracker.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
#include "CogDebug.generated.h"
|
||||
|
||||
class AActor;
|
||||
class UObject;
|
||||
@@ -12,388 +14,31 @@ struct FCogDebugDrawLineTraceParams;
|
||||
struct FCogDebugDrawOverlapParams;
|
||||
struct FCogDebugDrawSweepParams;
|
||||
|
||||
UENUM()
|
||||
enum class ECogDebugRecolorMode : uint8
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct FCogDebugContext
|
||||
{
|
||||
None,
|
||||
Color,
|
||||
HueOverTime,
|
||||
HueOverFrames,
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
struct FCogDebugSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bIsFilteringBySelection = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ReplicateSelection = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool Persistent = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool TextShadow = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool Fade2D = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float Duration = 3.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int DepthPriority = 0;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int Segments = 12;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float Thickness = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ServerThickness = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ServerColorMultiplier = 0.8f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ArrowSize = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float AxesScale = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogDebugRecolorMode RecolorMode = ECogDebugRecolorMode::None;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RecolorIntensity = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor RecolorColor = FColor(255, 0, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RecolorTimeSpeed = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int32 RecolorFrameCycle = 6;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float TextSize = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ActorNameUseLabel = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScale = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoUseLocalSpace = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoZLow = 0;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoZHigh = 100;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoThicknessZLow = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoThicknessZHigh = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoCursorDraggingThreshold = 4.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoCursorSelectionThreshold = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationAxisLength = 80.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoTranslationSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationSnapValue = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationPlaneOffset = 18.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationPlaneExtent = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoRotationSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationSnapValue = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationSpeed = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationRadius = 40.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoRotationSegments = 8;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoScaleSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleSnapValue = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleBoxOffset = 85.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleBoxExtent = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleSpeed = 0.01f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleMin = 0.001f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoGroundRaycastLength = 100000.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
TEnumAsByte<ECollisionChannel> GizmoGroundRaycastChannel = ECollisionChannel::ECC_WorldStatic;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoGroundRaycastCircleRadius = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighX = FColor(255, 50, 50, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighY = FColor(50, 255, 50, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighZ = FColor(50, 50, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighW = FColor(255, 255, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowX = FColor(128, 0, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowY = FColor(0, 128, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowZ = FColor(0, 0, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowW = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionX = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionY = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionZ = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionW = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoGroundRaycastColor = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoGroundRaycastCircleColor = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoTextColor = FColor(255, 255, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryHitColor = FColor::Green;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryNoHitColor = FColor::Red;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitPrimitives = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitPrimitiveActorsName = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryHitPrimitiveActorsNameShadow = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float CollisionQueryHitPrimitiveActorsNameSize = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitLocation = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitImpactPoints = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitNormals = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitImpactNormals = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float CollisionQueryHitPointSize = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryNormalColor = FColor::Yellow;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryImpactNormalColor = FColor::Cyan;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitShapes = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorWorldStatic = FColor(255, 0, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorWorldDynamic = FColor(255, 0, 188, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorPawn = FColor(105, 0, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorVisibility = FColor(0, 15, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorCamera = FColor(0, 105, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorPhysicsBody = FColor(0, 255, 208, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorVehicle = FColor(52, 255, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorDestructible = FColor(255, 255, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel1 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel2 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel3 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel4 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel5 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel6 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel1 = FColor(255, 105, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel2 = FColor(255, 30, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel3 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel4 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel5 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel6 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel7 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel8 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel9 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel10 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel11 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel12 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel13 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel14 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel15 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel16 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel17 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel18 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
TArray<FString> SecondaryBoneWildcards = {
|
||||
"interaction",
|
||||
"center_of_mass",
|
||||
"ik_*",
|
||||
"index_*",
|
||||
"middle_*",
|
||||
"pinky_*",
|
||||
"ring_*",
|
||||
"thumb_*",
|
||||
"wrist_*",
|
||||
"*_bck_*",
|
||||
"*_fwd_*",
|
||||
"*_in_*",
|
||||
"*_out_*",
|
||||
"*_pec_*",
|
||||
"*_scap_*",
|
||||
"*_bicep_*",
|
||||
"*_tricep_*",
|
||||
"*ankle*",
|
||||
"*knee*",
|
||||
"*corrective*",
|
||||
"*twist*",
|
||||
"*latissimus*",
|
||||
};
|
||||
FCogDebugTracker Tracker;
|
||||
|
||||
TWeakObjectPtr<AActor> Selection;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebug
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
static bool IsDebugActiveForObject(const UObject* WorldContextObject);
|
||||
|
||||
static bool IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection);
|
||||
|
||||
static AActor* GetSelection();
|
||||
|
||||
static void SetSelection(const UWorld* World, AActor* Value);
|
||||
static void SetSelection(AActor* InValue);
|
||||
|
||||
static bool GetIsFilteringBySelection();
|
||||
|
||||
static void SetIsFilteringBySelection(const UWorld* World, bool Value);
|
||||
|
||||
static FCogDebugTracker& GetTracker();
|
||||
|
||||
static bool GetDebugPersistent(bool bPersistent);
|
||||
|
||||
static float GetDebugDuration(bool bPersistent);
|
||||
@@ -426,17 +71,32 @@ public:
|
||||
|
||||
static void GetDebugDrawSweepSettings(FCogDebugDrawSweepParams& Params);
|
||||
|
||||
static FCogDebugContext& Get(int32 InPieId);
|
||||
|
||||
static FCogDebugContext& Get();
|
||||
|
||||
static int32 GetPieSessionId();
|
||||
|
||||
static void Plot(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const float Value);
|
||||
|
||||
static FCogDebugEvent& StartEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, bool IsInstant, const int32 Row = -1, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugEvent& InstantEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row = -1, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugEvent& StartEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row = -1, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugEvent& StopEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId);
|
||||
|
||||
static FCogDebugEvent& ToggleEvent(const UObject* WorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const bool ToggleValue, const int32 Row = -1, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugSettings Settings;
|
||||
|
||||
private:
|
||||
|
||||
static int32 GetPieSessionId();
|
||||
|
||||
static void ReplicateSelection(const UWorld* World, AActor* Value);
|
||||
|
||||
static bool IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection);
|
||||
|
||||
static constexpr uint32 MaxPie = 16;
|
||||
|
||||
static TWeakObjectPtr<AActor> Selection[MaxPie];
|
||||
static TMap<int32, FCogDebugContext> DebugContexts;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "imgui.h"
|
||||
|
||||
typedef FName FCogDebugEventId;
|
||||
typedef FName FCogDebugEventParamId;
|
||||
struct FCogDebugTrack;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugEventParams
|
||||
{
|
||||
FCogDebugEventParamId Name;
|
||||
FString Value;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugEvent
|
||||
{
|
||||
float GetActualEndTime() const;
|
||||
|
||||
uint64 GetActualEndFrame() const;
|
||||
|
||||
FCogDebugEvent& AddParam(const FCogDebugEventParamId& InParamId, bool InValue);
|
||||
|
||||
FCogDebugEvent& AddParam(const FCogDebugEventParamId& InParamId, int InValue);
|
||||
|
||||
FCogDebugEvent& AddParam(const FCogDebugEventParamId& InParamId, float InValue);
|
||||
|
||||
FCogDebugEvent& AddParam(const FCogDebugEventParamId& InParamId, FName InValue);
|
||||
|
||||
FCogDebugEvent& AddParam(const FCogDebugEventParamId& InParamId, const FString& InValue);
|
||||
|
||||
FCogDebugTrack* Track = nullptr;
|
||||
|
||||
FCogDebugEventParamId Id;
|
||||
|
||||
float StartTime = 0.0f;
|
||||
|
||||
float EndTime = 0.0f;
|
||||
|
||||
uint64 StartFrame = 0;
|
||||
|
||||
uint64 EndFrame = 0;
|
||||
|
||||
ImU32 BorderColor;
|
||||
|
||||
ImU32 FillColor;
|
||||
|
||||
int32 Row;
|
||||
|
||||
FString OwnerName;
|
||||
|
||||
FString DisplayName;
|
||||
|
||||
TArray<FCogDebugEventParams> Params;
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugEvent.h"
|
||||
#include "CogDebugTrack.h"
|
||||
|
||||
struct COGDEBUG_API FCogDebugEventTrack : FCogDebugTrack
|
||||
{
|
||||
FCogDebugEvent& AddEvent(const FString& OwnerName, bool IsInstant, const FCogDebugEventId EventId, const int32 Row, const FColor& Color);
|
||||
|
||||
FCogDebugEvent& StopEvent(const FCogDebugEventId EventId);
|
||||
|
||||
FCogDebugEvent* GetLastEvent();
|
||||
|
||||
FCogDebugEvent* FindLastEventByName(FCogDebugEventId EventId);
|
||||
|
||||
virtual void Clear() override;
|
||||
|
||||
int32 EventOffset = 0;
|
||||
|
||||
int32 MaxRow = 1;
|
||||
|
||||
TArray<FCogDebugEvent> Events;
|
||||
};
|
||||
@@ -1,192 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommon.h"
|
||||
#include "imgui.h"
|
||||
|
||||
#ifdef ENABLE_COG
|
||||
|
||||
struct FCogDebugHistory;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotEventParams
|
||||
{
|
||||
FName Name;
|
||||
FString Value;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotEvent
|
||||
{
|
||||
float GetActualEndTime(const FCogDebugHistory& Plot) const;
|
||||
|
||||
uint64 GetActualEndFrame(const FCogDebugHistory& Plot) const;
|
||||
|
||||
FCogDebugPlotEvent& AddParam(const FName Name, bool Value);
|
||||
|
||||
FCogDebugPlotEvent& AddParam(const FName Name, int Value);
|
||||
|
||||
FCogDebugPlotEvent& AddParam(const FName Name, float Value);
|
||||
|
||||
FCogDebugPlotEvent& AddParam(const FName Name, FName Value);
|
||||
|
||||
FCogDebugPlotEvent& AddParam(const FName Name, const FString& Value);
|
||||
|
||||
FName Id;
|
||||
float StartTime = 0.0f;
|
||||
float EndTime = 0.0f;
|
||||
uint64 StartFrame = 0;
|
||||
uint64 EndFrame = 0;
|
||||
ImU32 BorderColor;
|
||||
ImU32 FillColor;
|
||||
int32 Row;
|
||||
FString OwnerName;
|
||||
FString DisplayName;
|
||||
TArray<FCogDebugPlotEventParams> Params;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
enum class FCogDebugHistoryType
|
||||
{
|
||||
Value,
|
||||
Event,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugHistory
|
||||
{
|
||||
virtual ~FCogDebugHistory() {}
|
||||
|
||||
virtual void Clear() {}
|
||||
|
||||
FName Name;
|
||||
|
||||
float Time = 0;
|
||||
|
||||
uint64 Frame = 0;
|
||||
|
||||
int32 GraphIndex = 0;
|
||||
|
||||
FCogDebugHistoryType Type = FCogDebugHistoryType::Value;
|
||||
|
||||
TWeakObjectPtr<const UWorld> World;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugValueHistory : FCogDebugHistory
|
||||
{
|
||||
void AddPoint(float X, float Y);
|
||||
|
||||
bool FindValue(float Time, float& Value) const;
|
||||
|
||||
virtual void Clear() override;
|
||||
|
||||
void SetNumRecordedValues(const int32 Value);
|
||||
|
||||
int32 ValueOffset = 0;
|
||||
|
||||
ImVector<ImVec2> Values;
|
||||
|
||||
bool ShowValuesMarkers = false;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugEventHistory : FCogDebugHistory
|
||||
{
|
||||
FCogDebugPlotEvent& AddEvent(const FString& OwnerName, bool IsInstant, const FName EventId, const int32 Row, const FColor& Color);
|
||||
|
||||
FCogDebugPlotEvent& StopEvent(const FName EventId);
|
||||
|
||||
FCogDebugPlotEvent* GetLastEvent();
|
||||
|
||||
FCogDebugPlotEvent* FindLastEventByName(FName EventId);
|
||||
|
||||
virtual void Clear() override;
|
||||
|
||||
int32 EventOffset = 0;
|
||||
|
||||
TArray<FCogDebugPlotEvent> Events;
|
||||
|
||||
int32 MaxRow = 1;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class COGDEBUG_API FCogDebugPlot
|
||||
{
|
||||
public:
|
||||
static constexpr int32 AutoRow = -1;
|
||||
|
||||
static constexpr int32 MaxNumGraphs = 5;
|
||||
|
||||
static constexpr int32 MaxNumEntriesPerGraph = 10;
|
||||
|
||||
|
||||
static void PlotValue(const UObject* WorldContextObject, const FName PlotName, const float Value);
|
||||
|
||||
static FCogDebugPlotEvent& PlotEvent(const UObject* WorldContextObject, const FName PlotName, const FName EventId, bool IsInstant, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugPlotEvent& PlotEventInstant(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugPlotEvent& PlotEventStart(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugPlotEvent& PlotEventStop(const UObject* WorldContextObject, const FName PlotName, const FName EventId);
|
||||
|
||||
static FCogDebugPlotEvent& PlotEventToggle(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const bool ToggleValue, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
static FCogDebugHistory* FindEntry(const FName InName);
|
||||
|
||||
static void SetNumRecordedValues(int32 InValue);
|
||||
|
||||
static void Reset();
|
||||
|
||||
static void Clear();
|
||||
|
||||
static TMap<FName, FCogDebugValueHistory> Values;
|
||||
|
||||
static TMap<FName, FCogDebugEventHistory> Events;
|
||||
|
||||
static bool IsVisible;
|
||||
|
||||
static bool Pause;
|
||||
|
||||
static bool RecordValuesWhenPause;
|
||||
|
||||
|
||||
private:
|
||||
friend struct FCogDebugHistory;
|
||||
friend struct FCogDebugEventHistory;
|
||||
friend struct FCogDebugValueHistory;
|
||||
|
||||
static void ResetLastAddedEvent();
|
||||
|
||||
static FCogDebugValueHistory* RegisterValue(const UObject* InWorldContextObject, const FName InName);
|
||||
|
||||
static FCogDebugEventHistory* RegisterEvent(const UObject* InWorldContextObject, const FName InName);
|
||||
|
||||
static bool ShouldRegisterEntry(const UObject* WorldContextObject, const UWorld*& World);
|
||||
|
||||
static void InitializeEntry(FCogDebugHistory& OutValue, const UWorld* InWorld, const FName InName);
|
||||
|
||||
static FCogDebugPlotEvent* GetLastAddedEvent();
|
||||
|
||||
static void OccupyGraphRow(const int32 InGraphIndex, const int32 InRow);
|
||||
|
||||
static void FreeGraphRow(const int32 InGraphIndex, const int32 InRow);
|
||||
|
||||
static int32 FindFreeGraphRow(const int32 InGraphIndex);
|
||||
|
||||
static int32 NumRecordedValues;
|
||||
|
||||
static FName LastAddedEventPlotName;
|
||||
|
||||
static int32 LastAddedEventIndex;
|
||||
|
||||
static FCogDebugPlotEvent DefaultEvent;
|
||||
|
||||
// graph index to row index to number of objects occupying the row
|
||||
static TMap<int32, TMap<int32, int32>> OccupationMap;
|
||||
};
|
||||
|
||||
#endif //ENABLE_COG
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugTrack.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotTrack : FCogDebugTrack
|
||||
{
|
||||
virtual void Clear() override;
|
||||
|
||||
void Plot(float X, float Y);
|
||||
|
||||
bool FindValue(float Time, float& Value) const;
|
||||
|
||||
void SetNumPlots(const int32 Value);
|
||||
|
||||
int32 ValueOffset = 0;
|
||||
|
||||
ImVector<ImVec2> Values;
|
||||
|
||||
bool ShowValuesMarkers = false;
|
||||
};
|
||||
@@ -0,0 +1,375 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "CogDebugSettings.generated.h"
|
||||
|
||||
class AActor;
|
||||
class UObject;
|
||||
class UWorld;
|
||||
|
||||
|
||||
UENUM()
|
||||
enum class ECogDebugRecolorMode : uint8
|
||||
{
|
||||
None,
|
||||
Color,
|
||||
HueOverTime,
|
||||
HueOverFrames,
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
struct FCogDebugSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bIsFilteringBySelection = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ReplicateSelection = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool Persistent = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool TextShadow = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool Fade2D = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float Duration = 3.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int DepthPriority = 0;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int Segments = 12;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float Thickness = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ServerThickness = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ServerColorMultiplier = 0.8f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ArrowSize = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float AxesScale = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogDebugRecolorMode RecolorMode = ECogDebugRecolorMode::None;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RecolorIntensity = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor RecolorColor = FColor(255, 0, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RecolorTimeSpeed = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int32 RecolorFrameCycle = 6;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float TextSize = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ActorNameUseLabel = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScale = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoUseLocalSpace = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoZLow = 0;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoZHigh = 100;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoThicknessZLow = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoThicknessZHigh = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoCursorDraggingThreshold = 4.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoCursorSelectionThreshold = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationAxisLength = 80.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoTranslationSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationSnapValue = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationPlaneOffset = 18.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoTranslationPlaneExtent = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoRotationSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationSnapValue = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationSpeed = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoRotationRadius = 40.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int GizmoRotationSegments = 8;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool GizmoScaleSnapEnable = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleSnapValue = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleBoxOffset = 85.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleBoxExtent = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleSpeed = 0.01f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleMin = 0.001f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoGroundRaycastLength = 100000.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
TEnumAsByte<ECollisionChannel> GizmoGroundRaycastChannel = ECollisionChannel::ECC_WorldStatic;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoGroundRaycastCircleRadius = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighX = FColor(255, 50, 50, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighY = FColor(50, 255, 50, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighZ = FColor(50, 50, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZHighW = FColor(255, 255, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowX = FColor(128, 0, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowY = FColor(0, 128, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowZ = FColor(0, 0, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsZLowW = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionX = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionY = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionZ = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoAxisColorsSelectionW = FColor(255, 255, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoGroundRaycastColor = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoGroundRaycastCircleColor = FColor(128, 128, 128, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor GizmoTextColor = FColor(255, 255, 255, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryHitColor = FColor::Green;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryNoHitColor = FColor::Red;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitPrimitives = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitPrimitiveActorsName = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryHitPrimitiveActorsNameShadow = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float CollisionQueryHitPrimitiveActorsNameSize = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitLocation = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitImpactPoints = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitNormals = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitImpactNormals = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float CollisionQueryHitPointSize = 5.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryNormalColor = FColor::Yellow;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor CollisionQueryImpactNormalColor = FColor::Cyan;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool CollisionQueryDrawHitShapes = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorWorldStatic = FColor(255, 0, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorWorldDynamic = FColor(255, 0, 188, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorPawn = FColor(105, 0, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorVisibility = FColor(0, 15, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorCamera = FColor(0, 105, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorPhysicsBody = FColor(0, 255, 208, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorVehicle = FColor(52, 255, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorDestructible = FColor(255, 255, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel1 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel2 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel3 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel4 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel5 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorEngineTraceChannel6 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel1 = FColor(255, 105, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel2 = FColor(255, 30, 0, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel3 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel4 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel5 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel6 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel7 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel8 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel9 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel10 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel11 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel12 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel13 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel14 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel15 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel16 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel17 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel18 = FColor(0, 0, 0, 0);
|
||||
|
||||
UPROPERTY(Config)
|
||||
TArray<FString> SecondaryBoneWildcards = {
|
||||
"interaction",
|
||||
"center_of_mass",
|
||||
"ik_*",
|
||||
"index_*",
|
||||
"middle_*",
|
||||
"pinky_*",
|
||||
"ring_*",
|
||||
"thumb_*",
|
||||
"wrist_*",
|
||||
"*_bck_*",
|
||||
"*_fwd_*",
|
||||
"*_in_*",
|
||||
"*_out_*",
|
||||
"*_pec_*",
|
||||
"*_scap_*",
|
||||
"*_bicep_*",
|
||||
"*_tricep_*",
|
||||
"*ankle*",
|
||||
"*knee*",
|
||||
"*corrective*",
|
||||
"*twist*",
|
||||
"*latissimus*",
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
struct FCogDebugTracker;
|
||||
|
||||
typedef FName FCogDebugTrackId;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
enum class ECogDebugTrackType
|
||||
{
|
||||
Value,
|
||||
Event,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugTrack
|
||||
{
|
||||
virtual ~FCogDebugTrack() {}
|
||||
|
||||
virtual void Clear() {}
|
||||
|
||||
FCogDebugTrackId Id;
|
||||
|
||||
float Time = 0;
|
||||
|
||||
uint64 Frame = 0;
|
||||
|
||||
int32 GraphIndex = 0;
|
||||
|
||||
ECogDebugTrackType Type = ECogDebugTrackType::Value;
|
||||
|
||||
TWeakObjectPtr<const UWorld> World;
|
||||
|
||||
FCogDebugTracker* Owner = nullptr;
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#include "CogDebugTrack.h"
|
||||
#include "CogDebugEvent.h"
|
||||
#include "CogDebugPlotTrack.h"
|
||||
#include "CogDebugEventTrack.h"
|
||||
|
||||
struct COGDEBUG_API FCogDebugTracker
|
||||
{
|
||||
static constexpr int32 AutoRow = -1;
|
||||
|
||||
static constexpr int32 MaxNumViews = 5;
|
||||
|
||||
static constexpr int32 MaxNumTrackPerView = 10;
|
||||
|
||||
void Plot(const UObject* InWorldContextObject, const FCogDebugTrackId InTrackId, const float Value);
|
||||
|
||||
FCogDebugEvent& InstantEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
FCogDebugEvent& StartEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, bool IsInstant, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
FCogDebugEvent& StartEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
FCogDebugEvent& StopEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId);
|
||||
|
||||
FCogDebugEvent& ToggleEvent(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId, const FCogDebugEventId& InEventId, const bool ToggleValue, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
|
||||
|
||||
FCogDebugTrack* FindTrack(const FCogDebugTrackId& InTrackId);
|
||||
|
||||
void SetNumRecordedValues(int32 InValue);
|
||||
|
||||
void Reset();
|
||||
|
||||
void Clear();
|
||||
|
||||
TMap<FCogDebugTrackId, FCogDebugPlotTrack> Values;
|
||||
|
||||
TMap<FCogDebugTrackId, FCogDebugEventTrack> Events;
|
||||
|
||||
bool IsVisible = false;
|
||||
|
||||
bool Pause = false;
|
||||
|
||||
bool RecordValuesWhenPause = true;
|
||||
|
||||
private:
|
||||
friend struct FCogDebugEvent;
|
||||
friend struct FCogDebugTrack;
|
||||
friend struct FCogDebugEventTrack;
|
||||
friend struct FCogDebugPlotTrack;
|
||||
|
||||
void ResetLastAddedEvent();
|
||||
|
||||
FCogDebugPlotTrack* GetOrCreatePlotTrack(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId);
|
||||
|
||||
FCogDebugEventTrack* GetOrCreateEventTrack(const UObject* InWorldContextObject, const FCogDebugTrackId& InTrackId);
|
||||
|
||||
bool CanCreateTrack(const UObject* WorldContextObject, const UWorld*& World) const;
|
||||
|
||||
static void InitializeTrack(FCogDebugTrack& OutTrack, const UWorld* InWorld, const FCogDebugTrackId& InTrackId);
|
||||
|
||||
FCogDebugEvent* GetLastAddedEvent();
|
||||
|
||||
void OccupyViewRow(const int32 InViewIndex, const int32 InRow);
|
||||
|
||||
void FreeViewRow(const int32 InViewIndex, const int32 InRow);
|
||||
|
||||
int32 FindFreeViewRow(const int32 InViewIndex);
|
||||
|
||||
static int32 NumRecordedValues;
|
||||
|
||||
static FCogDebugEvent DefaultEvent;
|
||||
|
||||
FCogDebugTrackId LastAddedEventTrackId = NAME_None;
|
||||
|
||||
int32 LastAddedEventIndex = INDEX_NONE;
|
||||
|
||||
// view index to row index to number of objects occupying the row
|
||||
TMap<int32, TMap<int32, int32>> OccupationMap;
|
||||
};
|
||||
@@ -47,7 +47,7 @@ void FCogEngineWindow_CollisionTester::RenderContent()
|
||||
NewActor->SetActorLabel(NewActor->GetName().Replace(TEXT("CogEngine"), TEXT("")));
|
||||
#endif
|
||||
|
||||
FCogDebug::SetSelection(GetWorld(), NewActor);
|
||||
FCogDebug::SetSelection(NewActor);
|
||||
}
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
@@ -79,7 +79,7 @@ void FCogEngineWindow_CollisionTester::RenderContent()
|
||||
AActor* NewSelection = nullptr;
|
||||
if (FCogWindowWidgets::MenuActorsCombo("CollisionTesters", NewSelection, *GetWorld(), ACogEngineCollisionTester::StaticClass()))
|
||||
{
|
||||
FCogDebug::SetSelection(GetWorld(), NewSelection);
|
||||
FCogDebug::SetSelection(NewSelection);
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
|
||||
@@ -221,11 +221,6 @@ void FCogEngineWindow_OutputLog::RenderContent()
|
||||
Clear();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Test"))
|
||||
{
|
||||
COG_NOTIFY(TEXT("Test Notification"));
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 9);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "CogEngineWindow_Plots.h"
|
||||
|
||||
#include "CogDebugPlot.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugTracker.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Engine/World.h"
|
||||
#include "imgui.h"
|
||||
@@ -14,14 +16,14 @@ void FCogEngineWindow_Plots::Initialize()
|
||||
|
||||
bHasMenu = true;
|
||||
|
||||
auto& Tracker = FCogDebug::GetTracker();
|
||||
Tracker.Clear();
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_Plots>();
|
||||
|
||||
if (Config != nullptr)
|
||||
{
|
||||
RefreshPlotSettings();
|
||||
}
|
||||
|
||||
FCogDebugPlot::Clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -44,7 +46,9 @@ void FCogEngineWindow_Plots::ResetConfig()
|
||||
void FCogEngineWindow_Plots::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DeltaTime);
|
||||
FCogDebugPlot::IsVisible = GetIsVisible();
|
||||
|
||||
FCogDebugTracker& Tracker = FCogDebug::GetTracker();
|
||||
Tracker.IsVisible = GetIsVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -64,7 +68,9 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
RenderMenu();
|
||||
FCogDebugTracker& Tracker = FCogDebug::GetTracker();
|
||||
|
||||
RenderMenu(Tracker);
|
||||
|
||||
if (Config->DockEntries)
|
||||
{
|
||||
@@ -81,10 +87,10 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
RenderAllEntriesNames(ImVec2(0, -1));
|
||||
RenderAllEntriesNames(Tracker, ImVec2(0, -1));
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
RenderPlots();
|
||||
RenderPlots(Tracker);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
@@ -92,7 +98,7 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPlots();
|
||||
RenderPlots(Tracker);
|
||||
}
|
||||
|
||||
bApplyTimeScale = false;
|
||||
@@ -101,12 +107,13 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RefreshPlotSettings()
|
||||
{
|
||||
FCogDebugPlot::SetNumRecordedValues(Config->NumRecordedValues);
|
||||
FCogDebugPlot::RecordValuesWhenPause = Config->RecordValuesWhenPaused;
|
||||
FCogDebugTracker& Tracker = FCogDebug::GetTracker();
|
||||
Tracker.SetNumRecordedValues(Config->NumRecordedValues);
|
||||
Tracker.RecordValuesWhenPause = Config->RecordValuesWhenPaused;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderMenu()
|
||||
void FCogEngineWindow_Plots::RenderMenu(FCogDebugTracker& InTracker)
|
||||
{
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
@@ -114,7 +121,7 @@ void FCogEngineWindow_Plots::RenderMenu()
|
||||
{
|
||||
if (ImGui::BeginMenu("Entries"))
|
||||
{
|
||||
RenderAllEntriesNames(ImVec2(ImGui::GetFontSize() * 15, ImGui::GetFontSize() * 20));
|
||||
RenderAllEntriesNames(InTracker, ImVec2(ImGui::GetFontSize() * 15, ImGui::GetFontSize() * 20));
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
@@ -176,8 +183,8 @@ void FCogEngineWindow_Plots::RenderMenu()
|
||||
|
||||
if (ImGui::MenuItem("Reset Settings"))
|
||||
{
|
||||
FCogDebugPlot::Pause = false;
|
||||
FCogDebugPlot::Reset();
|
||||
InTracker.Pause = false;
|
||||
InTracker.Reset();
|
||||
ResetConfig();
|
||||
bApplyTimeScale = true;
|
||||
}
|
||||
@@ -187,17 +194,17 @@ void FCogEngineWindow_Plots::RenderMenu()
|
||||
|
||||
if (ImGui::MenuItem("Clear"))
|
||||
{
|
||||
FCogDebugPlot::Clear();
|
||||
InTracker.Clear();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::ToggleMenuButton(&FCogDebugPlot::Pause, "Pause", ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
FCogWindowWidgets::ToggleMenuButton(&InTracker.Pause, "Pause", ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderEntryName(const int Index, FCogDebugHistory& Entry)
|
||||
void FCogEngineWindow_Plots::RenderEntryName(FCogDebugTracker& InTracker, const int Index, FCogDebugTrack& Entry)
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
|
||||
@@ -206,28 +213,28 @@ void FCogEngineWindow_Plots::RenderEntryName(const int Index, FCogDebugHistory&
|
||||
for (int32 i = 0; i < UCogEngineConfig_Plots::MaxNumGraphs; ++i)
|
||||
{
|
||||
FCogEngineConfig_Plots_GraphInfo& GraphInfo = Config->Graphs[i];
|
||||
if (GraphInfo.Entries.ContainsByPredicate([Entry](const auto& InEntry) { return InEntry.Name == Entry.Name; }))
|
||||
if (GraphInfo.Entries.ContainsByPredicate([Entry](const auto& InEntry) { return InEntry.Name == Entry.Id; }))
|
||||
{
|
||||
IsAssignedToGraph = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Entry.Name.ToString()), IsAssignedToGraph, ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Entry.Id.ToString()), IsAssignedToGraph, ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
if (IsAssignedToGraph)
|
||||
{
|
||||
UnassignToGraphAndAxis(Entry.Name);
|
||||
UnassignToGraphAndAxis(InTracker, Entry.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignToGraphAndAxis(Entry.Name, 0, ImAxis_Y1);
|
||||
AssignToGraphAndAxis(InTracker, Entry.Id, 0, ImAxis_Y1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
|
||||
{
|
||||
const auto EntryName = StringCast<ANSICHAR>(*Entry.Name.ToString());
|
||||
const auto EntryName = StringCast<ANSICHAR>(*Entry.Id.ToString());
|
||||
ImGui::SetDragDropPayload("DragAndDrop", EntryName.Get(), EntryName.Length() + 1);
|
||||
ImGui::Text("%s", EntryName.Get());
|
||||
ImGui::EndDragDropSource();
|
||||
@@ -237,7 +244,7 @@ void FCogEngineWindow_Plots::RenderEntryName(const int Index, FCogDebugHistory&
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
|
||||
void FCogEngineWindow_Plots::RenderAllEntriesNames(FCogDebugTracker& InTracker, const ImVec2& InSize)
|
||||
{
|
||||
const int32 Indent = ImGui::GetFontSize() * 0.5f;
|
||||
|
||||
@@ -248,15 +255,15 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
|
||||
if (FCogWindowWidgets::DarkCollapsingHeader("Events", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Indent(Indent);
|
||||
if (FCogDebugPlot::Events.IsEmpty())
|
||||
if (InTracker.Events.IsEmpty())
|
||||
{
|
||||
ImGui::TextDisabled("No event added yet");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& kv : FCogDebugPlot::Events)
|
||||
for (auto& kv : InTracker.Events)
|
||||
{
|
||||
RenderEntryName(Index, kv.Value);
|
||||
RenderEntryName(InTracker, Index, kv.Value);
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
@@ -266,15 +273,15 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
|
||||
if (FCogWindowWidgets::DarkCollapsingHeader("Plots", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Indent(Indent);
|
||||
if (FCogDebugPlot::Values.IsEmpty())
|
||||
if (InTracker.Values.IsEmpty())
|
||||
{
|
||||
ImGui::TextDisabled("No plot added yet");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& kv : FCogDebugPlot::Values)
|
||||
for (auto& kv : InTracker.Values)
|
||||
{
|
||||
RenderEntryName(Index, kv.Value);
|
||||
RenderEntryName(InTracker, Index, kv.Value);
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
@@ -287,14 +294,14 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
|
||||
{
|
||||
if (const ImGuiPayload* Payload = ImGui::AcceptDragDropPayload("DragAndDrop"))
|
||||
{
|
||||
UnassignToGraphAndAxis(GetDroppedEntryName(Payload));
|
||||
UnassignToGraphAndAxis(InTracker, GetDroppedEntryName(Payload));
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderPlots()
|
||||
void FCogEngineWindow_Plots::RenderPlots(FCogDebugTracker& InTracker)
|
||||
{
|
||||
if (ImGui::BeginChild("Graph", ImVec2(0, -1)))
|
||||
{
|
||||
@@ -302,7 +309,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
static float ColRatios[] = { 1 };
|
||||
static ImPlotSubplotFlags SubplotsFlags = ImPlotSubplotFlags_LinkCols;
|
||||
|
||||
const bool PushPlotBgStyle = FCogDebugPlot::Pause;
|
||||
const bool PushPlotBgStyle = InTracker.Pause;
|
||||
if (PushPlotBgStyle)
|
||||
{
|
||||
ImPlot::PushStyleColor(ImPlotCol_PlotBg, FCogImguiHelper::ToImVec4(Config->PauseBackgroundColor));
|
||||
@@ -340,7 +347,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
{
|
||||
IsAssigned |= GraphEntry.YAxis == YAxis;
|
||||
|
||||
if (FCogDebugEventHistory* EventHistory = FCogDebugPlot::Events.Find(GraphEntry.Name))
|
||||
if (FCogDebugEventTrack* EventHistory = InTracker.Events.Find(GraphEntry.Name))
|
||||
{
|
||||
YMax = FMath::Max(FMath::Max(5, YMax), EventHistory->MaxRow);
|
||||
}
|
||||
@@ -386,7 +393,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
//--------------------------------------------------------------------------------
|
||||
// Make the time axis move forward automatically, unless the user pauses or zoom.
|
||||
//--------------------------------------------------------------------------------
|
||||
if (FCogDebugPlot::Pause == false && ImGui::GetIO().MouseWheel == 0)
|
||||
if (InTracker.Pause == false && ImGui::GetIO().MouseWheel == 0)
|
||||
{
|
||||
ImPlot::SetupAxisLimits(ImAxis_X1, Time - TimeRange, Time, ImGuiCond_Always);
|
||||
}
|
||||
@@ -417,14 +424,14 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
|
||||
if (FMath::Abs(Drag.x) > Config->DragPauseSensitivity)
|
||||
{
|
||||
FCogDebugPlot::Pause = true;
|
||||
InTracker.Pause = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
FCogDebugPlot::Pause = false;
|
||||
InTracker.Pause = false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -443,7 +450,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
PlotDrawList->AddLine(ImVec2(ImGui::GetMousePos().x, PlotTop), ImVec2(ImGui::GetMousePos().x, TimeBarBottom), IM_COL32(128, 128, 128, 64));
|
||||
}
|
||||
|
||||
if (Config->ShowTimeBarAtGameTime && FCogDebugPlot::Pause)
|
||||
if (Config->ShowTimeBarAtGameTime && InTracker.Pause)
|
||||
{
|
||||
const float TimeBarX = ImPlot::PlotToPixels(Time, 0.0f).x;
|
||||
PlotDrawList->AddLine(ImVec2(TimeBarX, PlotTop), ImVec2(TimeBarX, TimeBarBottom), IM_COL32(255, 255, 255, 64));
|
||||
@@ -456,8 +463,8 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
//-----------------------------------------------------------
|
||||
for (FCogEngineConfig_Plots_GraphEntryInfo& Entry : GraphInfo.Entries)
|
||||
{
|
||||
FCogDebugHistory* History = FCogDebugPlot::FindEntry(Entry.Name);
|
||||
if (History == nullptr)
|
||||
FCogDebugTrack* Track = InTracker.FindTrack(Entry.Name);
|
||||
if (Track == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -470,17 +477,17 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
//-------------------------------------------------------
|
||||
// Plot Events
|
||||
//-------------------------------------------------------
|
||||
switch (History->Type)
|
||||
switch (Track->Type)
|
||||
{
|
||||
case FCogDebugHistoryType::Event:
|
||||
case ECogDebugTrackType::Event:
|
||||
{
|
||||
RenderEvents(*static_cast<FCogDebugEventHistory*>(History), Label.Get(), PlotMin, PlotMax);
|
||||
RenderEvents(*static_cast<FCogDebugEventTrack*>(Track), Label.Get(), PlotMin, PlotMax);
|
||||
break;
|
||||
}
|
||||
|
||||
case FCogDebugHistoryType::Value:
|
||||
case ECogDebugTrackType::Value:
|
||||
{
|
||||
RenderValues(*static_cast<FCogDebugValueHistory*>(History), Label.Get());
|
||||
RenderValues(*static_cast<FCogDebugPlotTrack*>(Track), Label.Get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -505,7 +512,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
{
|
||||
if (const ImGuiPayload* Payload = ImGui::AcceptDragDropPayload("DragAndDrop"))
|
||||
{
|
||||
AssignToGraphAndAxis(GetDroppedEntryName(Payload), GraphIndex, ImAxis_Y1);
|
||||
AssignToGraphAndAxis(InTracker, GetDroppedEntryName(Payload), GraphIndex, ImAxis_Y1);
|
||||
}
|
||||
ImPlot::EndDragDropTarget();
|
||||
}
|
||||
@@ -520,7 +527,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
{
|
||||
if (const ImGuiPayload* Payload = ImGui::AcceptDragDropPayload("DragAndDrop"))
|
||||
{
|
||||
AssignToGraphAndAxis(GetDroppedEntryName(Payload), GraphIndex, YAxis);
|
||||
AssignToGraphAndAxis(InTracker, GetDroppedEntryName(Payload), GraphIndex, YAxis);
|
||||
}
|
||||
ImPlot::EndDragDropTarget();
|
||||
}
|
||||
@@ -533,7 +540,7 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
{
|
||||
if (const ImGuiPayload* Payload = ImGui::AcceptDragDropPayload("DragAndDrop"))
|
||||
{
|
||||
AssignToGraphAndAxis(GetDroppedEntryName(Payload), GraphIndex, ImAxis_Y1);
|
||||
AssignToGraphAndAxis(InTracker, GetDroppedEntryName(Payload), GraphIndex, ImAxis_Y1);
|
||||
}
|
||||
ImPlot::EndDragDropTarget();
|
||||
}
|
||||
@@ -557,9 +564,9 @@ void FCogEngineWindow_Plots::RenderPlots()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderValues(FCogDebugValueHistory& Entry, const char* Label) const
|
||||
void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotTrack& Timeline, const char* Label) const
|
||||
{
|
||||
if (Entry.Values.empty())
|
||||
if (Timeline.Values.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -570,7 +577,7 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugValueHistory& Entry, const ch
|
||||
if (Config->ShowValueAtCursor && ImPlot::IsPlotHovered())
|
||||
{
|
||||
float Value;
|
||||
if (Entry.FindValue(ImPlot::GetPlotMousePos().x, Value))
|
||||
if (Timeline.FindValue(ImPlot::GetPlotMousePos().x, Value))
|
||||
{
|
||||
if (FCogWindowWidgets::BeginTableTooltip())
|
||||
{
|
||||
@@ -588,26 +595,26 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugValueHistory& Entry, const ch
|
||||
}
|
||||
}
|
||||
|
||||
if (Entry.ShowValuesMarkers)
|
||||
if (Timeline.ShowValuesMarkers)
|
||||
{
|
||||
ImPlot::SetNextMarkerStyle(ImPlotMarker_Circle);
|
||||
}
|
||||
|
||||
ImPlot::PlotLine(Label, &Entry.Values[0].x, &Entry.Values[0].y, Entry.Values.size(), ImPlotLineFlags_None, Entry.ValueOffset, 2 * sizeof(float));
|
||||
ImPlot::PlotLine(Label, &Timeline.Values[0].x, &Timeline.Values[0].y, Timeline.Values.size(), ImPlotLineFlags_None, Timeline.ValueOffset, 2 * sizeof(float));
|
||||
|
||||
if (ImPlot::BeginLegendPopup(Label))
|
||||
{
|
||||
if (ImGui::Button("Clear"))
|
||||
{
|
||||
Entry.Clear();
|
||||
Timeline.Clear();
|
||||
}
|
||||
ImGui::Checkbox("Show Markers", &Entry.ShowValuesMarkers);
|
||||
ImGui::Checkbox("Show Markers", &Timeline.ShowValuesMarkers);
|
||||
ImPlot::EndLegendPopup();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventHistory& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax) const
|
||||
void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventTrack& InTrack, const char* InLabel, const ImVec2& InPlotMin, const ImVec2& InPlotMax) const
|
||||
{
|
||||
const ImVec2 Mouse = ImGui::GetMousePos();
|
||||
ImDrawList* PlotDrawList = ImPlot::GetPlotDrawList();
|
||||
@@ -620,11 +627,11 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventHistory& Entry, const ch
|
||||
ImVector<ImVec2> DummyData;
|
||||
DummyData.push_back(ImVec2(0, 0));
|
||||
DummyData.push_back(ImVec2(0, 8));
|
||||
ImPlot::PlotLine(Label, &DummyData[0].x, &DummyData[0].y, DummyData.size(), Entry.EventOffset, 2 * sizeof(float));
|
||||
ImPlot::PlotLine(InLabel, &DummyData[0].x, &DummyData[0].y, DummyData.size(), InTrack.EventOffset, 2 * sizeof(float));
|
||||
|
||||
const FCogDebugPlotEvent* HoveredEvent = nullptr;
|
||||
const FCogDebugEvent* HoveredEvent = nullptr;
|
||||
|
||||
for (const FCogDebugPlotEvent& Event : Entry.Events)
|
||||
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));
|
||||
@@ -645,7 +652,7 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventHistory& Entry, const ch
|
||||
}
|
||||
else
|
||||
{
|
||||
const float ActualEndTime = Event.GetActualEndTime(Entry);
|
||||
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);
|
||||
@@ -653,7 +660,7 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventHistory& Entry, const ch
|
||||
const ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll;
|
||||
PlotDrawList->AddRect(Min, Max, Event.BorderColor, 6.0f, Flags);
|
||||
PlotDrawList->AddRectFilled(Min, Max, Event.FillColor, 6.0f, Flags);
|
||||
PlotDrawList->PushClipRect(ImMax(Min, PlotMin), ImMin(Max, PlotMax));
|
||||
PlotDrawList->PushClipRect(ImMax(Min, InPlotMin), ImMin(Max, InPlotMax));
|
||||
PlotDrawList->AddText(ImVec2(PosMid.x + 5, PosMid.y - 7), IM_COL32(255, 255, 255, 255), TCHAR_TO_ANSI(*Event.DisplayName));
|
||||
PlotDrawList->PopClipRect();
|
||||
|
||||
@@ -669,18 +676,18 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugEventHistory& Entry, const ch
|
||||
//-------------------------------------------------------
|
||||
//char Buffer[64];
|
||||
//ImFormatString(Buffer, 64, "%0.1f %0.1f", Mouse.x, Mouse.y);
|
||||
//PlotDrawList->AddText(ImVec2(PlotMin.x + 50, PlotMin.y + 100), IM_COL32(255, 255, 255, 255), Buffer);
|
||||
//PlotDrawList->AddText(ImVec2(InPlotMin.x + 50, InPlotMin.y + 100), IM_COL32(255, 255, 255, 255), Buffer);
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Hovered event tooltip
|
||||
//-------------------------------------------------------
|
||||
RenderEventTooltip(HoveredEvent, Entry);
|
||||
RenderEventTooltip(HoveredEvent, InTrack);
|
||||
|
||||
ImPlot::PopPlotClipRect();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* HoveredEvent, const FCogDebugHistory& Entry)
|
||||
void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry)
|
||||
{
|
||||
if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr)
|
||||
{
|
||||
@@ -711,8 +718,8 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* Hovere
|
||||
//------------------------
|
||||
if (HoveredEvent->EndTime != HoveredEvent->StartTime)
|
||||
{
|
||||
const float ActualEndTime = HoveredEvent->GetActualEndTime(Entry);
|
||||
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame(Entry);
|
||||
const float ActualEndTime = HoveredEvent->GetActualEndTime();
|
||||
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
@@ -741,7 +748,7 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* Hovere
|
||||
//------------------------
|
||||
// Params
|
||||
//------------------------
|
||||
for (FCogDebugPlotEventParams Param : HoveredEvent->Params)
|
||||
for (FCogDebugEventParams Param : HoveredEvent->Params)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
@@ -764,11 +771,11 @@ FName FCogEngineWindow_Plots::GetDroppedEntryName(const ImGuiPayload* Payload)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::AssignToGraphAndAxis(const FName InName, const int32 InGraphIndex, const ImAxis InYAxis)
|
||||
void FCogEngineWindow_Plots::AssignToGraphAndAxis(FCogDebugTracker& InTracker, const FName InName, const int32 InGraphIndex, const ImAxis InYAxis)
|
||||
{
|
||||
UnassignToGraphAndAxis(InName);
|
||||
UnassignToGraphAndAxis(InTracker, InName);
|
||||
|
||||
FCogDebugHistory* History = FCogDebugPlot::FindEntry(InName);
|
||||
FCogDebugTrack* History = InTracker.FindTrack(InName);
|
||||
if (History == nullptr)
|
||||
{ return; }
|
||||
|
||||
@@ -790,9 +797,9 @@ void FCogEngineWindow_Plots::AssignToGraphAndAxis(const FName InName, const int3
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Plots::UnassignToGraphAndAxis(const FName InName)
|
||||
void FCogEngineWindow_Plots::UnassignToGraphAndAxis(FCogDebugTracker& InTracker, const FName InName)
|
||||
{
|
||||
const FCogDebugHistory* History = FCogDebugPlot::FindEntry(InName);
|
||||
const FCogDebugTrack* History = InTracker.FindTrack(InName);
|
||||
if (History == nullptr)
|
||||
{ return; }
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DeltaTime);
|
||||
|
||||
if (FCogDebug::GetSelection() == nullptr)
|
||||
if (GetSelection() == nullptr)
|
||||
{
|
||||
SetGlobalSelection(GetLocalPlayerPawn());
|
||||
}
|
||||
@@ -236,7 +236,7 @@ bool FCogEngineWindow_Selection::TickSelectionMode()
|
||||
// Prioritize another actor than the selected actor unless we only touch the selected actor.
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
TArray<AActor*> IgnoreList;
|
||||
IgnoreList.Add(FCogDebug::GetSelection());
|
||||
IgnoreList.Add(GetSelection());
|
||||
|
||||
FHitResult HitResult;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
@@ -328,7 +328,7 @@ void FCogEngineWindow_Selection::RenderActorContextMenu(AActor& Actor)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const
|
||||
{
|
||||
FCogDebug::SetSelection(GetWorld(), Value);
|
||||
FCogDebug::SetSelection(Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -66,7 +66,8 @@ void FCogEngineWindow_TimeScale::RenderMainMenuWidget()
|
||||
ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*GetWorld());
|
||||
if (Replicator == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Invalid Replicator");
|
||||
ImGui::TextDisabled("x?");
|
||||
ImGui::SetItemTooltip("Invalid Replicator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
#include "implot.h"
|
||||
#include "CogEngineWindow_Plots.generated.h"
|
||||
|
||||
struct FCogDebugEventHistory;
|
||||
struct FCogDebugValueHistory;
|
||||
struct FCogDebugTrack;
|
||||
struct FCogDebugTracker;
|
||||
struct FCogDebugPlotTrack;
|
||||
struct FCogDebugEventTrack;
|
||||
struct FCogDebugEvent;
|
||||
struct ImVec2;
|
||||
struct FCogDebugPlotEvent;
|
||||
struct FCogDebugHistory;
|
||||
class UCogEngineConfig_Plots;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -34,23 +35,23 @@ protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderAllEntriesNames(const ImVec2& InSize);
|
||||
virtual void RenderAllEntriesNames(FCogDebugTracker& InTracker, const ImVec2& InSize);
|
||||
|
||||
virtual void RenderEntryName(const int Index, FCogDebugHistory& Entry);
|
||||
virtual void RenderEntryName(FCogDebugTracker& InTracker, int Index, FCogDebugTrack& Entry);
|
||||
|
||||
virtual void RenderPlots();
|
||||
virtual void RenderPlots(FCogDebugTracker& InTracker);
|
||||
|
||||
virtual void RenderMenu();
|
||||
virtual void RenderMenu(FCogDebugTracker& InTracker);
|
||||
|
||||
virtual void RenderValues(FCogDebugValueHistory& Entry, const char* Label) const;
|
||||
virtual void RenderValues(FCogDebugPlotTrack& Timeline, const char* Label) const;
|
||||
|
||||
virtual void RenderEvents(FCogDebugEventHistory& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax) const;
|
||||
virtual void RenderEvents(FCogDebugEventTrack& InTrack, const char* InLabel, const ImVec2& InPlotMin, const ImVec2& InPlotMax) const;
|
||||
|
||||
static void RenderEventTooltip(const FCogDebugPlotEvent* HoveredEvent, const FCogDebugHistory& Entry);
|
||||
static void RenderEventTooltip(const FCogDebugEvent* HoveredEvent, const FCogDebugTrack& Entry);
|
||||
|
||||
virtual void AssignToGraphAndAxis(const FName InName, const int32 InGraphIndex, const ImAxis InYAxis);
|
||||
virtual void AssignToGraphAndAxis(FCogDebugTracker& InTracker, FName InName, int32 InGraphIndex, ImAxis InYAxis);
|
||||
|
||||
virtual void UnassignToGraphAndAxis(const FName InName);
|
||||
virtual void UnassignToGraphAndAxis(FCogDebugTracker& InTracker, FName InName);
|
||||
|
||||
virtual void RefreshPlotSettings();
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@ FCogImGuiContextScope::~FCogImGuiContextScope()
|
||||
bool FCogImguiContext::bIsNetImGuiInitialized = false;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogImguiContext::Initialize()
|
||||
void FCogImguiContext::Initialize(UGameViewportClient* InGameViewport)
|
||||
{
|
||||
IMGUI_CHECKVERSION();
|
||||
|
||||
GameViewport = GEngine->GameViewport;
|
||||
GameViewport = InGameViewport;
|
||||
|
||||
if (GameViewport != nullptr)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ class COGIMGUI_API FCogImguiContext : public TSharedFromThis<FCogImguiContext>
|
||||
{
|
||||
public:
|
||||
|
||||
void Initialize();
|
||||
void Initialize(UGameViewportClient* InGameViewport);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
|
||||
@@ -9,6 +9,19 @@
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::Initialize()
|
||||
{
|
||||
ensure(bIsInitialized == false);
|
||||
bIsInitialized = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::Shutdown()
|
||||
{
|
||||
bIsInitialized = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::SetFullName(const FString& InFullName)
|
||||
{
|
||||
@@ -129,17 +142,18 @@ void FCogWindow::GameTick(float DeltaTime)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::SetSelection(AActor* NewSelection)
|
||||
{
|
||||
if (CurrentSelection == NewSelection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AActor* OldActor = GetSelection();
|
||||
FCogDebug::SetSelection(NewSelection);
|
||||
|
||||
AActor* OldActor = CurrentSelection.Get();
|
||||
|
||||
CurrentSelection = NewSelection;
|
||||
OnSelectionChanged(OldActor, NewSelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogWindow::GetSelection() const
|
||||
{
|
||||
return FCogDebug::GetSelection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::SetIsVisible(const bool Value)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CogWindowManager.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
#include "CogDebugDrawImGui.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogImguiInputHelper.h"
|
||||
@@ -28,9 +29,33 @@ UCogWindowManager::UCogWindowManager()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::InitializeInternal()
|
||||
void UCogWindowManager::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Context.Initialize();
|
||||
Super::Initialize(Collection);
|
||||
FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ThisClass::Tick);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::Deinitialize()
|
||||
{
|
||||
Super::Deinitialize();
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::TryInitializeInternal()
|
||||
{
|
||||
if (IsInitialized)
|
||||
{ return; }
|
||||
|
||||
FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(GetWorld());
|
||||
if (WorldContext == nullptr)
|
||||
{ return; }
|
||||
|
||||
if (WorldContext->GameViewport == nullptr && IsRunningDedicatedServer() == false)
|
||||
{ return; }
|
||||
|
||||
Context.Initialize(WorldContext->GameViewport.Get());
|
||||
|
||||
FCogImGuiContextScope ImGuiContextScope(Context);
|
||||
|
||||
@@ -111,7 +136,6 @@ void UCogWindowManager::InitializeInternal()
|
||||
}));
|
||||
|
||||
IsInitialized = true;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -155,18 +179,22 @@ void UCogWindowManager::Shutdown()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::Tick(float DeltaTime)
|
||||
void UCogWindowManager::Tick(UWorld* World, ELevelTick TickType, float DeltaTime)
|
||||
{
|
||||
//----------------------------------------------------------------------------------------------
|
||||
// The tick currently gets called from a static tick function, which tick for all PIE worlds.
|
||||
// We must not tick for a different world than ours.
|
||||
// TODO: find a cleaner way to tick only for our world.
|
||||
//----------------------------------------------------------------------------------------------
|
||||
if (GetWorld() != World)
|
||||
{ return; }
|
||||
|
||||
FCogImGuiContextScope ImGuiContextScope(Context);
|
||||
|
||||
if (GEngine->GameViewport == nullptr && IsRunningDedicatedServer() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsInitialized == false)
|
||||
{
|
||||
InitializeInternal();
|
||||
TryInitializeInternal();
|
||||
return;
|
||||
}
|
||||
|
||||
if (LayoutToLoad != -1)
|
||||
@@ -247,6 +275,12 @@ void UCogWindowManager::Render(float DeltaTime)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const bool AddToMainMenu /*= true*/)
|
||||
{
|
||||
if (Windows.ContainsByPredicate([&](const FCogWindow* w) { return w->GetName() == Name; }))
|
||||
{
|
||||
COG_LOG_FUNC(LogCogImGui, ELogVerbosity::Warning, TEXT("Trying to add a window, but one already exist with the same name: %s"), *Name);
|
||||
return;
|
||||
}
|
||||
|
||||
Window->SetFullName(Name);
|
||||
Window->SetOwner(this);
|
||||
Windows.Add(Window);
|
||||
@@ -745,9 +779,7 @@ void UCogWindowManager::ResetAllWindowsConfig()
|
||||
void UCogWindowManager::AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key)
|
||||
{
|
||||
if (PlayerInput == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
//---------------------------------------------------
|
||||
// Reassign conflicting commands
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "UObject/ReflectedTypeAccessors.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
|
||||
struct FCogDebugContext;
|
||||
class AActor;
|
||||
class APawn;
|
||||
class APlayerController;
|
||||
@@ -20,9 +21,9 @@ public:
|
||||
|
||||
virtual ~FCogWindow() {}
|
||||
|
||||
virtual void Initialize() {}
|
||||
virtual void Initialize();
|
||||
|
||||
virtual void Shutdown() {}
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void ResetConfig();
|
||||
|
||||
@@ -39,7 +40,8 @@ public:
|
||||
|
||||
/** */
|
||||
virtual void RenderMainMenuWidget();
|
||||
void RenderSettings();
|
||||
|
||||
virtual void RenderSettings();
|
||||
|
||||
ImGuiID GetID() const { return ID; }
|
||||
|
||||
@@ -51,7 +53,7 @@ public:
|
||||
/** The short name of the window. "Effect" if the window full name is "Gameplay.Character.Effect" */
|
||||
const FString& GetName() const { return Name; }
|
||||
|
||||
AActor* GetSelection() const { return CurrentSelection.Get(); }
|
||||
AActor* GetSelection() const;
|
||||
|
||||
void SetSelection(AActor* Actor);
|
||||
|
||||
@@ -119,8 +121,8 @@ protected:
|
||||
|
||||
ULocalPlayer* GetLocalPlayer() const;
|
||||
|
||||
protected:
|
||||
|
||||
bool bIsInitialized = false;
|
||||
|
||||
bool bShowMenu = true;
|
||||
|
||||
bool bHasMenu = false;
|
||||
@@ -143,10 +145,6 @@ protected:
|
||||
|
||||
UCogWindowManager* Owner = nullptr;
|
||||
|
||||
TWeakObjectPtr<AActor> CurrentSelection;
|
||||
|
||||
TWeakObjectPtr<AActor> OverridenSelection;
|
||||
|
||||
mutable TArray<TWeakObjectPtr<UCogCommonConfig>> ConfigsToResetOnRequest;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "CogImguiContext.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "imgui.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "CogWindowManager.generated.h"
|
||||
|
||||
class UCogCommonConfig;
|
||||
@@ -19,7 +20,7 @@ struct ImGuiTextBuffer;
|
||||
struct FKey;
|
||||
|
||||
UCLASS(Config = Cog)
|
||||
class COGWINDOW_API UCogWindowManager : public UObject
|
||||
class COGWINDOW_API UCogWindowManager : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -27,14 +28,17 @@ public:
|
||||
|
||||
UCogWindowManager();
|
||||
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void SortMainMenu();
|
||||
|
||||
virtual void Render(float DeltaTime);
|
||||
|
||||
virtual void Tick(float DeltaTime);
|
||||
|
||||
virtual void Tick(UWorld* World, ELevelTick TickType, float DeltaTime);
|
||||
|
||||
virtual void AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu = true);
|
||||
|
||||
@@ -75,15 +79,14 @@ public:
|
||||
|
||||
FCogImguiContext& GetContext() { return Context; }
|
||||
|
||||
|
||||
static void AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key);
|
||||
|
||||
static void SortCommands(UPlayerInput* PlayerInput);
|
||||
|
||||
void OnShortcutsDefined() const;
|
||||
|
||||
bool IsRenderingMainMenu() const { return IsRenderingInMainMenu; }
|
||||
|
||||
static void AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key);
|
||||
|
||||
static void SortCommands(UPlayerInput* PlayerInput);
|
||||
|
||||
protected:
|
||||
|
||||
friend class FCogWindow_Layouts;
|
||||
@@ -96,7 +99,7 @@ protected:
|
||||
TArray<FMenu> SubMenus;
|
||||
};
|
||||
|
||||
virtual void InitializeInternal();
|
||||
virtual void TryInitializeInternal();
|
||||
|
||||
virtual void RenderMainMenu();
|
||||
|
||||
@@ -144,7 +147,7 @@ protected:
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShowMainMenu = false;
|
||||
|
||||
|
||||
FCogImguiContext Context;
|
||||
|
||||
TArray<FCogWindow*> Windows;
|
||||
|
||||
Reference in New Issue
Block a user