mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
Merge remote-tracking branch 'arnaud-jamin/main'
# Conflicts: # .gitignore # Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h # Plugins/Cog/Source/ThirdParty/ImGui/imgui_widgets.cpp
This commit is contained in:
@@ -80,4 +80,5 @@ Plugins/*/Intermediate/*
|
||||
DerivedDataCache/*
|
||||
.vsconfig
|
||||
enc_temp_folder/*
|
||||
*.user
|
||||
Release
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
GameDefaultMap=/Game/Maps/L_Level1.L_Level1
|
||||
EditorStartupMap=/Game/Maps/L_Level1.L_Level1
|
||||
GlobalDefaultGameMode="/Script/CogSample.CogSampleGameMode"
|
||||
GameInstanceClass=/Script/Engine.GameInstance
|
||||
|
||||
[/Script/Engine.RendererSettings]
|
||||
r.ReflectionMethod=1
|
||||
@@ -110,10 +111,11 @@ ManualIPAddress=
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="CharacterMesh")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="TraceCustom")
|
||||
+EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Ignore),(Channel="TraceCustom")))
|
||||
+EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap),(Channel="TraceCustom",Response=ECR_Ignore),(Channel="CharacterMesh",Response=ECR_Overlap)))
|
||||
+EditProfiles=(Name="BlockAll",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Projectile",Response=ECR_Overlap)))
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel4,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="TraceCogSelection")
|
||||
+EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Ignore),(Channel="TraceCustom"),(Channel="TraceCogSelection")))
|
||||
+EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap),(Channel="TraceCustom",Response=ECR_Ignore),(Channel="CharacterMesh",Response=ECR_Overlap),(Channel="TraceCogSelection")))
|
||||
+EditProfiles=(Name="BlockAll",CustomResponses=((Channel="Projectile"),(Channel="TraceCogSelection")))
|
||||
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Projectile",Response=ECR_Overlap),(Channel="TraceCogSelection")))
|
||||
+EditProfiles=(Name="BlockAllDynamic",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="OverlapAllDynamic",CustomResponses=((Channel="Projectile",Response=ECR_Overlap)))
|
||||
+EditProfiles=(Name="IgnoreOnlyPawn",CustomResponses=((Channel="Projectile")))
|
||||
|
||||
@@ -69,6 +69,7 @@ bCaptureMouseOnLaunch=True
|
||||
bEnableLegacyInputScales=True
|
||||
bEnableMotionControls=True
|
||||
bFilterInputByPlatformUser=False
|
||||
bEnableInputDeviceSubsystem=True
|
||||
bShouldFlushPressedKeysOnViewportFocusLost=True
|
||||
bEnableDynamicComponentInputBinding=True
|
||||
bAlwaysShowTouchInterface=False
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -22,7 +22,7 @@
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
{
|
||||
"Name": "CogWindow",
|
||||
"Name": "Cog",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
[CoreRedirects]
|
||||
+StructRedirects=(OldName="/Script/CogDebug.CogLogCategory",NewName="/Script/CogCommon.CogLogCategory")
|
||||
+PropertyRedirects=(OldName="/Script/CogEngine.CogEngineCheatCategory.PersistentEffects",NewName="/Script/CogEngine.CogEngineCheatCategory.PersistentCheats")
|
||||
+PropertyRedirects=(OldName="/Script/CogEngine.CogEngineCheatCategory.InstantEffects",NewName="/Script/CogEngine.CogEngineCheatCategory.InstantCheats")
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class CogWindow : ModuleRules
|
||||
public class Cog : ModuleRules
|
||||
{
|
||||
public CogWindow(ReadOnlyTargetRules Target) : base(Target)
|
||||
public Cog(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
+22
-13
@@ -1,11 +1,11 @@
|
||||
#include "CogWindowConsoleCommandManager.h"
|
||||
#include "CogConsoleCommandManager.h"
|
||||
|
||||
#include "Engine/World.h"
|
||||
|
||||
TMap<FString, FCogCommandInfo> FCogWindowConsoleCommandManager::CommandMap;
|
||||
TMap<FString, FCogCommandInfo> FCogConsoleCommandManager::CommandMap;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* InName, const TCHAR* InHelp, UWorld* InWorld, const FCogWindowConsoleCommandDelegate& InDelegate)
|
||||
void FCogConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* InName, const TCHAR* InHelp, UWorld* InWorld, const FCogWindowConsoleCommandDelegate& InDelegate)
|
||||
{
|
||||
FCogCommandInfo& commandInfo = CommandMap.FindOrAdd(InName);
|
||||
|
||||
@@ -20,13 +20,15 @@ void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* I
|
||||
{
|
||||
FCogCommandInfo* commandInfo = CommandMap.Find(InName);
|
||||
if (commandInfo == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InCommandWorld);
|
||||
if (WorldContext == nullptr)
|
||||
{ return; }
|
||||
|
||||
for (auto& receiver : commandInfo->Receivers)
|
||||
{
|
||||
if (receiver.World == InCommandWorld)
|
||||
if (receiver.PIEInstance == WorldContext->PIEInstance)
|
||||
{
|
||||
receiver.Delegate.ExecuteIfBound(Args, InCommandWorld);
|
||||
break;
|
||||
@@ -37,21 +39,28 @@ void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* I
|
||||
);
|
||||
}
|
||||
|
||||
FCogCommandReceiver& receiver = commandInfo.Receivers.AddDefaulted_GetRef();
|
||||
receiver.World = InWorld;
|
||||
receiver.Delegate = InDelegate;
|
||||
if (const FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InWorld))
|
||||
{
|
||||
FCogCommandReceiver& receiver = commandInfo.Receivers.AddDefaulted_GetRef();
|
||||
receiver.PIEInstance = WorldContext->PIEInstance;
|
||||
receiver.Delegate = InDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UWorld* InWorld)
|
||||
void FCogConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UWorld* InWorld)
|
||||
{
|
||||
FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InWorld);
|
||||
if (WorldContext == nullptr)
|
||||
{ return; }
|
||||
|
||||
for (auto& kv : CommandMap)
|
||||
{
|
||||
FCogCommandInfo& commandInfo = kv.Value;
|
||||
|
||||
for (int32 i = commandInfo.Receivers.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
if (commandInfo.Receivers[i].World == InWorld)
|
||||
if (commandInfo.Receivers[i].PIEInstance == WorldContext->PIEInstance)
|
||||
{
|
||||
commandInfo.Receivers.RemoveAt(i);
|
||||
}
|
||||
@@ -63,4 +72,4 @@ void FCogWindowConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UW
|
||||
commandInfo.ConsoleObject = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-6
@@ -1,4 +1,4 @@
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogHelper.h"
|
||||
|
||||
#include "AssetRegistry/AssetRegistryModule.h"
|
||||
#include "AssetRegistry/IAssetRegistry.h"
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "imgui.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
const UObject* FCogWindowHelper::GetFirstAssetByClass(const TSubclassOf<UObject> AssetClass)
|
||||
const UObject* FCogHelper::GetFirstAssetByClass(const TSubclassOf<UObject>& AssetClass)
|
||||
{
|
||||
const IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")).Get();
|
||||
|
||||
@@ -23,7 +23,7 @@ const UObject* FCogWindowHelper::GetFirstAssetByClass(const TSubclassOf<UObject>
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FString FCogWindowHelper::GetActorName(const AActor* Actor)
|
||||
FString FCogHelper::GetActorName(const AActor* Actor)
|
||||
{
|
||||
if (Actor == nullptr)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ FString FCogWindowHelper::GetActorName(const AActor* Actor)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FString FCogWindowHelper::GetActorName(const AActor& Actor)
|
||||
FString FCogHelper::GetActorName(const AActor& Actor)
|
||||
{
|
||||
#if WITH_EDITOR
|
||||
|
||||
@@ -50,7 +50,7 @@ FString FCogWindowHelper::GetActorName(const AActor& Actor)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool FCogWindowHelper::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max)
|
||||
bool FCogHelper::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max)
|
||||
{
|
||||
FVector Corners[8];
|
||||
Corners[0].Set(-Extent.X, -Extent.Y, -Extent.Z); // - - -
|
||||
@@ -89,4 +89,12 @@ bool FCogWindowHelper::ComputeBoundingBoxScreenPosition(const APlayerController*
|
||||
Max.Y = FMath::Min(DisplaySize.y * 2, Max.Y);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogHelper::IsTraceChannelHidden(const UCollisionProfile& InCollisionProfile, const ECollisionChannel InCollisionChannel)
|
||||
{
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
+5
-5
@@ -1,17 +1,17 @@
|
||||
#include "CogWindowModule.h"
|
||||
#include "CogModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FCogWindowModule"
|
||||
#define LOCTEXT_NAMESPACE "FCogModule"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowModule::StartupModule()
|
||||
void FCogModule::StartupModule()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowModule::ShutdownModule()
|
||||
void FCogModule::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FCogWindowModule, CogWindow)
|
||||
IMPLEMENT_MODULE(FCogModule, Cog)
|
||||
File diff suppressed because it is too large
Load Diff
+588
-173
File diff suppressed because it is too large
Load Diff
+108
-48
@@ -2,13 +2,27 @@
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "CogWindowManager.h"
|
||||
#include "CogSubsystem.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "Engine/World.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
#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)
|
||||
{
|
||||
@@ -52,59 +66,64 @@ bool FCogWindow::CheckEditorVisibility()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::RenderMainMenuWidget()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::RenderContextMenu()
|
||||
{
|
||||
RenderSettings();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::RenderSettings()
|
||||
{
|
||||
if (bHasMenu)
|
||||
{
|
||||
ImGui::Checkbox("Show Menu", &bShowMenu);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Reset Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0)))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::Render(float DeltaTime)
|
||||
{
|
||||
ImGuiWindowFlags WindowFlags = 0;
|
||||
PreRender(WindowFlags);
|
||||
|
||||
const FString WindowTitle = GetTitle() + "##" + Name;
|
||||
|
||||
if (bHasMenu && bShowMenu)
|
||||
{
|
||||
WindowFlags |= ImGuiWindowFlags_MenuBar;
|
||||
}
|
||||
|
||||
if (bNoPadding)
|
||||
PreBegin(WindowFlags);
|
||||
|
||||
const FString WindowTitle = GetTitle() + "##" + Name;
|
||||
const bool IsOpen = ImGui::Begin(StringCast<ANSICHAR>(*WindowTitle).Get(), &bIsVisible, WindowFlags);
|
||||
|
||||
PostBegin();
|
||||
|
||||
if (IsOpen)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
if (ImGui::Begin(TCHAR_TO_ANSI(*WindowTitle), &bIsVisible, WindowFlags))
|
||||
{
|
||||
if (bNoPadding)
|
||||
{
|
||||
ImGui::PopStyleVar(1);
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (bHasMenu)
|
||||
{
|
||||
ImGui::Checkbox("Show Menu", &bShowMenu);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Reset Settings"))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
RenderContent();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bNoPadding)
|
||||
|
||||
if (bUseCustomContextMenu == false)
|
||||
{
|
||||
ImGui::PopStyleVar(1);
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
RenderContextMenu();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
PostRender();
|
||||
|
||||
PostEnd();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -127,19 +146,19 @@ 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)
|
||||
{
|
||||
if (bIsVisible == Value)
|
||||
@@ -189,13 +208,32 @@ ULocalPlayer* FCogWindow::GetLocalPlayer() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCogCommonConfig* FCogWindow::GetConfig(const TSubclassOf<UCogCommonConfig> ConfigClass) const
|
||||
UCogCommonConfig* FCogWindow::GetConfig(const TSubclassOf<UCogCommonConfig>& InConfigClass, bool InResetConfigOnRequest) const
|
||||
{
|
||||
return GetOwner()->GetConfig(ConfigClass);
|
||||
UCogCommonConfig* Config = GetOwner()->GetConfig(InConfigClass);
|
||||
|
||||
if (Config != nullptr && InResetConfigOnRequest)
|
||||
{
|
||||
ConfigsToResetOnRequest.AddUnique(Config);
|
||||
}
|
||||
|
||||
return Config;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
const UObject* FCogWindow::GetAsset(const TSubclassOf<UObject> AssetClass) const
|
||||
void FCogWindow::ResetConfig()
|
||||
{
|
||||
for (auto& Config : ConfigsToResetOnRequest)
|
||||
{
|
||||
if (Config != nullptr)
|
||||
{
|
||||
Config->Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
const UObject* FCogWindow::GetAsset(const TSubclassOf<UObject>& AssetClass) const
|
||||
{
|
||||
return GetOwner()->GetAsset(AssetClass);
|
||||
}
|
||||
@@ -205,3 +243,25 @@ UWorld* FCogWindow::GetWorld() const
|
||||
{
|
||||
return Owner->GetWorld();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindow::IsWindowRenderedInMainMenu()
|
||||
{
|
||||
return Owner->IsRenderingMainMenu();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogWindow::GetDpiScale() const
|
||||
{
|
||||
return GetOwner()->GetContext().GetDpiScale();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::RenderConfigShortcuts(UCogCommonConfig& InConfig) const
|
||||
{
|
||||
FProperty* InModifiedProperty = nullptr;
|
||||
if (FCogWidgets::AllInputChordsOfConfig(InConfig, &InModifiedProperty))
|
||||
{
|
||||
GetOwner()->RebindShortcut(InConfig, *InModifiedProperty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "CogWindow_Layouts.h"
|
||||
|
||||
#include "CogImguiInputHelper.h"
|
||||
#include "CogSubsystem.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "InputCoreTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogWindow_Layouts::FCogWindow_Layouts()
|
||||
{
|
||||
bShowInMainMenu = false;
|
||||
bHasMenu = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderContent()
|
||||
{
|
||||
const UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GetWorld());
|
||||
if (PlayerInput == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Reset Window Layout"))
|
||||
{
|
||||
GetOwner()->ResetLayout();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
UCogWindowConfig_Settings* Settings = GetOwner()->GetSettings();
|
||||
RenderLoadLayoutMenuItem(1, Settings->Shortcut_LoadLayout1);
|
||||
RenderLoadLayoutMenuItem(2, Settings->Shortcut_LoadLayout2);
|
||||
RenderLoadLayoutMenuItem(3, Settings->Shortcut_LoadLayout3);
|
||||
RenderLoadLayoutMenuItem(4, Settings->Shortcut_LoadLayout4);
|
||||
|
||||
ImGui::Separator();
|
||||
RenderSaveLayoutMenuItem(1, Settings->Shortcut_SaveLayout1);
|
||||
RenderSaveLayoutMenuItem(2, Settings->Shortcut_SaveLayout2);
|
||||
RenderSaveLayoutMenuItem(3, Settings->Shortcut_SaveLayout3);
|
||||
RenderSaveLayoutMenuItem(4, Settings->Shortcut_SaveLayout4);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderLoadLayoutMenuItem(int InLayoutIndex, const FInputChord& InInputChord)
|
||||
{
|
||||
const auto Shortcut = StringCast<ANSICHAR>(*FCogImguiInputHelper::InputChordToString(InInputChord));
|
||||
const auto Text = StringCast<ANSICHAR>(*FString::Printf(TEXT("Load Layout %d"), InLayoutIndex));
|
||||
|
||||
if (ImGui::MenuItem(Text.Get(), Shortcut.Get()))
|
||||
{
|
||||
GetOwner()->LoadLayout(InLayoutIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderSaveLayoutMenuItem(int InLayoutIndex, const FInputChord& InInputChord)
|
||||
{
|
||||
const auto Shortcut = StringCast<ANSICHAR>(*FCogImguiInputHelper::InputChordToString(InInputChord));
|
||||
const auto Text = StringCast<ANSICHAR>(*FString::Printf(TEXT("Save Layout %d"), InLayoutIndex));
|
||||
|
||||
if (ImGui::MenuItem(Text.Get(), Shortcut.Get()))
|
||||
{
|
||||
GetOwner()->SaveLayout(InLayoutIndex + 1);
|
||||
}
|
||||
}
|
||||
+142
-30
@@ -2,18 +2,24 @@
|
||||
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogImguiInputHelper.h"
|
||||
#include "CogWindowManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "imgui.h"
|
||||
#include "CogSubsystem.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "InputCoreTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogWindow_Settings::FCogWindow_Settings()
|
||||
{
|
||||
bShowInMainMenu = false;
|
||||
bHasMenu = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Settings::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = false;
|
||||
|
||||
Config = GetConfig<UCogWindowConfig_Settings>();
|
||||
|
||||
@@ -38,6 +44,10 @@ void FCogWindow_Settings::PreSaveConfig()
|
||||
Super::PreSaveConfig();
|
||||
|
||||
ImGuiIO& IO = ImGui::GetIO();
|
||||
|
||||
if (Config == nullptr)
|
||||
{ return; }
|
||||
|
||||
Config->bNavEnableKeyboard = IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard;
|
||||
//Config->bNavEnableGamepad = IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad;
|
||||
//Config->bNavNoCaptureInput = IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard;
|
||||
@@ -49,14 +59,6 @@ void FCogWindow_Settings::PreSaveConfig()
|
||||
Config->bShareMouseWithGameplay = Context.GetShareMouseWithGameplay();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Settings::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
@@ -77,8 +79,8 @@ void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
Context.SetEnableInput(bEnableInput);
|
||||
}
|
||||
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
|
||||
FCogWindowWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
|
||||
FCogWidgets::ItemTooltipWrappedText("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
|
||||
FCogWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::InputChordToString(Config->Shortcut_ToggleImguiInput));
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool bShareKeyboard = Context.GetShareKeyboard();
|
||||
@@ -86,7 +88,7 @@ void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
Context.SetShareKeyboard(bShareKeyboard);
|
||||
}
|
||||
ImGui::SetItemTooltip("Forward the keyboard inputs to the game when ImGui does not need them.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Forward the keyboard inputs to the game when ImGui does not need them.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool bShareMouse = Context.GetShareMouse();
|
||||
@@ -94,7 +96,7 @@ void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
Context.SetShareMouse(bShareMouse);
|
||||
}
|
||||
ImGui::SetItemTooltip("Forward mouse inputs to the game when ImGui does not need them.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Forward mouse inputs to the game when ImGui does not need them.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if (bShareMouse == false)
|
||||
@@ -107,7 +109,7 @@ void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
Context.SetShareMouseWithGameplay(bShareMouseWithGameplay);
|
||||
}
|
||||
ImGui::SetItemTooltip("When disabled, mouse inputs are only forwarded to game menus. "
|
||||
FCogWidgets::ItemTooltipWrappedText("When disabled, mouse inputs are only forwarded to game menus. "
|
||||
"When enabled, mouse inputs are also forwarded to the gameplay. Note that this mode: \n"
|
||||
" - Force the cursor to be visible.\n"
|
||||
" - Prevent the interaction of Cog's transform gizmos.\n"
|
||||
@@ -120,13 +122,23 @@ void FCogWindow_Settings::RenderContent()
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
|
||||
ImGui::SetItemTooltip("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
//ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
|
||||
//FCogWidgets::ItemTooltipWrappedText("Use the gamepad to navigate in ImGui windows.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Disable Conflicting Commands", &Config->bDisableConflictingCommands);
|
||||
FCogWidgets::ItemTooltipWrappedText("Disable the existing Unreal command shortcuts mapped to same shortcuts Cog is using. Typically, if the F1 shortcut is used to toggle Inputs, the Unreal wireframe command will get disabled.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Disable shortcuts when ImGui want text input", &Config->bDisableShortcutsWhenImGuiWantTextInput);
|
||||
FCogWidgets::ItemTooltipWrappedText("Disable Cog's shortcuts (ToggleInput, ToggleSelectionMode, LoadLayout, ...) when ImGui want text input."
|
||||
" This can be required if the shortcuts are mapped by keys generating a text input (letters, or Backspace for example)."
|
||||
" This is not required if the shortcuts are set to keys such as F1 or F2.");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
//ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
|
||||
//ImGui::SetItemTooltip("Use the gamepad to navigate in ImGui windows.");
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Window", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
@@ -134,22 +146,26 @@ void FCogWindow_Settings::RenderContent()
|
||||
{
|
||||
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports);
|
||||
}
|
||||
ImGui::SetItemTooltip("Enable moving ImGui windows outside of the main viewport.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Enable moving ImGui windows outside of the main viewport.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Compact Mode", &Config->bCompactMode);
|
||||
ImGui::SetItemTooltip("Enable compact mode.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Enable compact mode.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Transparent Mode", &Config->bTransparentMode);
|
||||
FCogWidgets::ItemTooltipWrappedText("Enable transparent mode.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu);
|
||||
ImGui::SetItemTooltip("Show the content of the windows when hovering the window menu item.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Show the content of the windows when hovering the window menu item.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
ImGui::Checkbox("Show Help", &Config->bShowHelp);
|
||||
ImGui::SetItemTooltip("Show windows help on the window menu items.");
|
||||
FCogWidgets::ItemTooltipWrappedText("Show windows help on the window menu items.");
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderFloat("DPI Scale", &Config->DPIScale, 0.5f, 2.0f, "%.1f");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
@@ -164,12 +180,108 @@ void FCogWindow_Settings::RenderContent()
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Config"))
|
||||
if (ImGui::CollapsingHeader("Widgets (?)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::Button("Reset All Windows Config", ImVec2(-1.0f, 0.0f)))
|
||||
FCogWidgets::ItemTooltipWrappedText("Widgets appear in the main menu bar.");
|
||||
|
||||
ImGui::Checkbox("Show Widget Borders", &Config->ShowWidgetBorders);
|
||||
FCogWidgets::ItemTooltipWrappedText("Should a border be visible between widgets.");
|
||||
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
FCogWidgets::ComboboxEnum("Widgets Alignment", Config->WidgetAlignment);
|
||||
FCogWidgets::ItemTooltipWrappedText("How the widgets should be aligned in the main menu bar.");
|
||||
|
||||
if (ImGui::BeginChild("Widgets", ImVec2(0, ImGui::GetFontSize() * 10), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_MenuBar))
|
||||
{
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
ImGui::TextUnformatted("Widgets visibility and ordering");
|
||||
ImGui::SameLine();
|
||||
FCogWidgets::HelpMarker("Drag and drop the widget names to reorder them.");
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
TArray<FCogWindow*>& Widgets = GetOwner()->Widgets;
|
||||
for (int32 i = 0; i < Widgets.Num(); ++i)
|
||||
{
|
||||
FCogWindow* Window = Widgets[i];
|
||||
|
||||
ImGui::PushID(i);
|
||||
|
||||
bool Visible = Window->GetIsWidgetVisible();
|
||||
if (ImGui::Checkbox("##Visibility", &Visible))
|
||||
{
|
||||
Window->SetIsWidgetVisible(Visible);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Selectable(TCHAR_TO_ANSI(*Window->GetName()), false, ImGuiSelectableFlags_SpanAvailWidth);
|
||||
{
|
||||
Window->SetIsWidgetVisible(Visible);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS);
|
||||
}
|
||||
|
||||
if (ImGui::IsItemActive() && ImGui::IsItemHovered() == false)
|
||||
{
|
||||
const int iNext = i + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1);
|
||||
if (iNext >= 0 && iNext < Widgets.Num())
|
||||
{
|
||||
Widgets[i] = Widgets[iNext];
|
||||
Widgets[iNext] = Window;
|
||||
ImGui::ResetMouseDragDelta();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Shortcuts", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
for (TObjectPtr SomeConfig : GetOwner()->GetConfigs())
|
||||
{
|
||||
if (SomeConfig == nullptr)
|
||||
{ continue; }
|
||||
|
||||
if (FCogWidgets::IsConfigContainingInputChords(*SomeConfig))
|
||||
{
|
||||
auto ConfigName = StringCast<ANSICHAR>(*FCogWidgets::FormatConfigName(SomeConfig->GetClass()->GetName()));
|
||||
ImGui::SeparatorText(ConfigName.Get());
|
||||
|
||||
FProperty* InModifiedProperty = nullptr;
|
||||
if (FCogWidgets::AllInputChordsOfConfig(*SomeConfig, &InModifiedProperty))
|
||||
{
|
||||
GetOwner()->RebindShortcut(*SomeConfig, *InModifiedProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Settings", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::Button("Save All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
|
||||
{
|
||||
GetOwner()->SaveAllSettings();
|
||||
}
|
||||
|
||||
// if (ImGui::Button("Reload All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
|
||||
// {
|
||||
// GetOwner()->ReloadAllSettings();
|
||||
// }
|
||||
|
||||
FCogWidgets::PushButtonBackColor(ImVec4(1.0f, 0.0f, 0.0f, 1));
|
||||
if (ImGui::Button("Reset All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
|
||||
{
|
||||
GetOwner()->ResetAllWindowsConfig();
|
||||
}
|
||||
FCogWidgets::PopButtonBackColor();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -1,13 +1,19 @@
|
||||
#include "CogWindow_Spacing.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Spacing::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
FCogWindow_Spacing::FCogWindow_Spacing()
|
||||
{
|
||||
bShowInMainMenu = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Spacing::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Spacing::PostRender()
|
||||
void FCogWindow_Spacing::PostBegin()
|
||||
{
|
||||
ImGui::PopStyleColor(1);
|
||||
}
|
||||
+2
-5
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "HAL/IConsoleManager.h"
|
||||
#include "Templates/Function.h"
|
||||
|
||||
class UWorld;
|
||||
|
||||
@@ -11,7 +10,7 @@ DECLARE_DELEGATE_TwoParams(FCogWindowConsoleCommandDelegate, const TArray<FStrin
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct FCogCommandReceiver
|
||||
{
|
||||
UWorld* World = nullptr;
|
||||
int32 PIEInstance = INDEX_NONE;
|
||||
|
||||
FCogWindowConsoleCommandDelegate Delegate;
|
||||
};
|
||||
@@ -25,10 +24,8 @@ struct FCogCommandInfo
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGWINDOW_API FCogWindowConsoleCommandManager
|
||||
struct COG_API FCogConsoleCommandManager
|
||||
{
|
||||
public:
|
||||
|
||||
static void RegisterWorldConsoleCommand(const TCHAR* InName, const TCHAR* InHelp, UWorld* InWorld, const FCogWindowConsoleCommandDelegate& InDelegate);
|
||||
|
||||
static void UnregisterAllWorldConsoleCommands(const UWorld* InWorld);
|
||||
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetRegistry/AssetData.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include "Templates/SubclassOf.h"
|
||||
|
||||
class UCollisionProfile;
|
||||
|
||||
class COG_API FCogHelper
|
||||
{
|
||||
public:
|
||||
|
||||
static FString GetActorName(const AActor* Actor);
|
||||
|
||||
static FString GetActorName(const AActor& Actor);
|
||||
|
||||
static bool ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max);
|
||||
|
||||
template<typename T>
|
||||
static const T* GetFirstAssetByClass();
|
||||
|
||||
static const UObject* GetFirstAssetByClass(const TSubclassOf<UObject>& AssetClass);
|
||||
|
||||
template<typename TCLass, typename TMember>
|
||||
static FProperty* FindProperty(TCLass* Instance, TMember TCLass::*PointerToMember);
|
||||
|
||||
static bool IsTraceChannelHidden(const UCollisionProfile& InCollisionProfile, ECollisionChannel InCollisionChannel);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
const T* FCogHelper::GetFirstAssetByClass()
|
||||
{
|
||||
return Cast<T>(GetFirstAssetByClass(T::StaticClass()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
template<typename TCLass, typename TMember>
|
||||
FProperty* FCogHelper::FindProperty(TCLass* Instance, TMember TCLass::*PointerToMember)
|
||||
{
|
||||
for (TFieldIterator<FProperty> It(Instance->GetClass()); It; ++It)
|
||||
{
|
||||
FProperty* Property = *It;
|
||||
|
||||
if (Property == nullptr)
|
||||
{ continue; }
|
||||
|
||||
const void* MemberAddress = &(Instance->*PointerToMember);
|
||||
const void* PropertyAddress = Property->ContainerPtrToValuePtr<void>(Instance);
|
||||
|
||||
if (MemberAddress == PropertyAddress)
|
||||
{ return Property; }
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class COG_API FCogModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
static inline FCogModule& Get() { return FModuleManager::LoadModuleChecked<FCogModule>("Cog"); }
|
||||
|
||||
virtual void StartupModule() override;
|
||||
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "CogPluginSubsystem.generated.h"
|
||||
|
||||
UCLASS(Abstract)
|
||||
class COG_API UCogPluginSubsystem : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnPlayerControllerSet(APlayerController* InController) {}
|
||||
};
|
||||
+116
-35
@@ -1,9 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogHelper.h"
|
||||
#include "CogImguiContext.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "imgui.h"
|
||||
#include "CogWindowManager.generated.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
|
||||
#include "CogSubsystem.generated.h"
|
||||
|
||||
class UCogCommonConfig;
|
||||
class FCogWindow;
|
||||
@@ -17,31 +21,30 @@ struct ImGuiSettingsHandler;
|
||||
struct ImGuiTextBuffer;
|
||||
struct FKey;
|
||||
|
||||
UCLASS(Config = Cog)
|
||||
class COGWINDOW_API UCogWindowManager : public UObject
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS()
|
||||
class COG_API UCogSubsystem : public UTickableWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
|
||||
UCogWindowManager();
|
||||
virtual TStatId GetStatId() const override;
|
||||
|
||||
virtual void PostInitProperties() override;
|
||||
virtual void PostInitialize() override;
|
||||
|
||||
virtual void Shutdown();
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
virtual void SortMainMenu();
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
virtual void Render(float DeltaTime);
|
||||
|
||||
virtual void Tick(float DeltaTime);
|
||||
|
||||
|
||||
virtual void AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu = true);
|
||||
virtual void AddWindow(FCogWindow* Window, const FString& Name);
|
||||
|
||||
template<class T>
|
||||
T* AddWindow(const FString& Name, bool AddToMainMenu = true);
|
||||
|
||||
T* AddWindow(const FString& Name);
|
||||
|
||||
virtual void SortMainMenu();
|
||||
|
||||
virtual FCogWindow* FindWindowByID(ImGuiID ID);
|
||||
|
||||
virtual void CloseAllWindows();
|
||||
@@ -52,34 +55,43 @@ public:
|
||||
|
||||
virtual void SaveLayout(int32 LayoutIndex);
|
||||
|
||||
virtual bool GetHideAllWindows() const { return bIsSelectionModeActive; }
|
||||
|
||||
virtual void SetActivateSelectionMode(bool Value);
|
||||
|
||||
virtual bool GetActivateSelectionMode() const;
|
||||
|
||||
virtual void ResetAllWindowsConfig();
|
||||
|
||||
virtual bool RegisterDefaultCommandBindings();
|
||||
|
||||
const FCogWindow_Settings* GetSettingsWindow() const { return SettingsWindow; }
|
||||
UCogWindowConfig_Settings* GetSettings() const { return Settings.Get(); }
|
||||
|
||||
UCogCommonConfig* GetConfig(const TSubclassOf<UCogCommonConfig> ConfigClass);
|
||||
UCogCommonConfig* GetConfig(const TSubclassOf<UCogCommonConfig>& ConfigClass);
|
||||
|
||||
template<class T>
|
||||
T* GetConfig();
|
||||
|
||||
const UObject* GetAsset(const TSubclassOf<UObject> AssetClass) const;
|
||||
const UObject* GetAsset(const TSubclassOf<UObject>& AssetClass) const;
|
||||
|
||||
template<typename T>
|
||||
T* GetAsset();
|
||||
|
||||
FInputActionHandlerSignature& AddShortcut(const UObject& InInstance, const FProperty& InProperty);
|
||||
|
||||
template<typename TCLass, typename TMember>
|
||||
FInputActionHandlerSignature& AddShortcut(TCLass* InInstance, TMember TCLass::*InPointerToMember);
|
||||
|
||||
void RebindShortcut(const UCogCommonConfig& InConfig, const FProperty& InProperty);
|
||||
|
||||
const FCogImguiContext& GetContext() const { return Context; }
|
||||
|
||||
FCogImguiContext& GetContext() { return Context; }
|
||||
|
||||
bool IsRenderingMainMenu() const { return bIsRenderingInMainMenu; }
|
||||
|
||||
static void AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key);
|
||||
|
||||
static void SortCommands(UPlayerInput* PlayerInput);
|
||||
|
||||
TArray<TObjectPtr<UCogCommonConfig>>& GetConfigs() const { return Configs; };
|
||||
|
||||
protected:
|
||||
|
||||
friend class FCogWindow_Layouts;
|
||||
@@ -92,10 +104,29 @@ protected:
|
||||
TArray<FMenu> SubMenus;
|
||||
};
|
||||
|
||||
virtual void InitializeInternal();
|
||||
struct FCogShortcut
|
||||
{
|
||||
FName PropertyName;
|
||||
|
||||
TWeakObjectPtr<const UObject> Config;
|
||||
|
||||
FInputActionHandlerSignature Delegate;
|
||||
|
||||
FInputChord InputChord;
|
||||
};
|
||||
|
||||
virtual void Render(float DeltaTime);
|
||||
|
||||
virtual void TryInitialize(UWorld& World);
|
||||
|
||||
virtual void UpdatePlayerControllers(UWorld& World);
|
||||
|
||||
virtual void InitializeWindow(FCogWindow* Window);
|
||||
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void RenderMainMenu();
|
||||
|
||||
|
||||
virtual FMenu* AddMenu(const FString& Name);
|
||||
|
||||
virtual void RenderOptionMenu(FMenu& Menu);
|
||||
@@ -104,10 +135,24 @@ protected:
|
||||
|
||||
virtual void RenderMenuItemHelp(FCogWindow& Window);
|
||||
|
||||
void SetLocalPlayerController(APlayerController& PlayerController);
|
||||
|
||||
virtual void ToggleInputMode();
|
||||
|
||||
virtual void DisableInputMode();
|
||||
|
||||
virtual void TryDisableCommandsConflictingWithShortcuts(UPlayerInput* PlayerInput);
|
||||
|
||||
virtual void RequestDisableCommandsConflictingWithShortcuts();
|
||||
|
||||
virtual bool BindShortcut(FCogShortcut& InShortcut) const;
|
||||
|
||||
virtual void RenderWidgets();
|
||||
|
||||
virtual void SaveAllSettings();
|
||||
|
||||
virtual void ReloadAllSettings();
|
||||
|
||||
static void SettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*);
|
||||
|
||||
static void SettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*);
|
||||
@@ -118,6 +163,8 @@ protected:
|
||||
|
||||
static void SettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
|
||||
|
||||
static FString EnableCommand;
|
||||
|
||||
static FString ToggleInputCommand;
|
||||
|
||||
static FString DisableInputCommand;
|
||||
@@ -129,13 +176,19 @@ protected:
|
||||
static FString ResetLayoutCommand;
|
||||
|
||||
UPROPERTY()
|
||||
mutable TArray<UCogCommonConfig*> Configs;
|
||||
TWeakObjectPtr<UWorld> CurrentWorld;
|
||||
|
||||
UPROPERTY()
|
||||
mutable TArray<TObjectPtr<UCogCommonConfig>> Configs;
|
||||
|
||||
UPROPERTY()
|
||||
mutable TArray<const UObject*> Assets;
|
||||
mutable TArray<TObjectPtr<const UObject>> Assets;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bRegisterDefaultCommands = true;
|
||||
TArray<TWeakObjectPtr<APlayerController>> ServerPlayerControllers;
|
||||
|
||||
TWeakObjectPtr<APlayerController> LocalPlayerController;
|
||||
|
||||
TWeakObjectPtr<UInputComponent> InputComponent;
|
||||
|
||||
FCogImguiContext Context;
|
||||
|
||||
@@ -143,11 +196,15 @@ protected:
|
||||
|
||||
TArray<FCogWindow*> Widgets;
|
||||
|
||||
TArray<FCogShortcut> Shortcuts;
|
||||
|
||||
int32 WidgetsOrderIndex = 0;
|
||||
|
||||
TArray<FCogWindow*> SpaceWindows;
|
||||
|
||||
FCogWindow_Settings* SettingsWindow = nullptr;
|
||||
|
||||
TWeakObjectPtr<UCogWindowConfig_Settings> Settings;
|
||||
|
||||
FCogWindow_Layouts* LayoutsWindow = nullptr;
|
||||
|
||||
@@ -156,32 +213,56 @@ protected:
|
||||
int32 LayoutToLoad = -1;
|
||||
|
||||
int32 SelectionModeActiveCounter = 0;
|
||||
|
||||
bool bIsInputEnabledBeforeEnteringSelectionMode = false;
|
||||
|
||||
bool bIsSelectionModeActive = false;
|
||||
|
||||
bool IsInitialized = false;
|
||||
bool bIsInitialized = false;
|
||||
|
||||
bool bIsRenderingInMainMenu = false;
|
||||
|
||||
int32 NumExecBindingsChecked = 0;
|
||||
|
||||
FInputActionHandlerSignature InvalidShortcutDelegate;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template<class T>
|
||||
T* UCogWindowManager::AddWindow(const FString& Name, bool AddToMainMenu)
|
||||
T* UCogSubsystem::AddWindow(const FString& Name)
|
||||
{
|
||||
T* Window = new T();
|
||||
AddWindow(Window, Name, AddToMainMenu);
|
||||
AddWindow(Window, Name);
|
||||
return Window;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template<class T>
|
||||
T* UCogWindowManager::GetConfig()
|
||||
T* UCogSubsystem::GetConfig()
|
||||
{
|
||||
static_assert(TPointerIsConvertibleFromTo<T, const UCogCommonConfig>::Value);
|
||||
return Cast<T>(&GetConfig(T::StaticClass()));
|
||||
return Cast<T>(GetConfig(T::StaticClass()));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
T* UCogWindowManager::GetAsset()
|
||||
T* UCogSubsystem::GetAsset()
|
||||
{
|
||||
return Cast<T>(GetAsset(T::StaticClass()));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename TCLass, typename TMember>
|
||||
FInputActionHandlerSignature& UCogSubsystem::AddShortcut(TCLass* InInstance, TMember TCLass::* InPointerToMember)
|
||||
{
|
||||
if (InInstance == nullptr)
|
||||
{ return InvalidShortcutDelegate; }
|
||||
|
||||
const FProperty* Property = FCogHelper::FindProperty(InInstance, InPointerToMember);
|
||||
if (Property == nullptr)
|
||||
{ return InvalidShortcutDelegate; }
|
||||
|
||||
return AddShortcut(*InInstance, *Property);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "imgui.h"
|
||||
#include "UObject/ReflectedTypeAccessors.h"
|
||||
|
||||
#include <Templates/SubclassOf.h>
|
||||
|
||||
#include "CogHelper.h"
|
||||
|
||||
class AActor;
|
||||
class APawn;
|
||||
class FEnumProperty;
|
||||
class UCollisionProfile;
|
||||
class UEnum;
|
||||
class UObject;
|
||||
enum class ECheckBoxState : uint8;
|
||||
enum ECollisionChannel : int;
|
||||
struct FKeyBind;
|
||||
|
||||
using FCogWindowActorContextMenuFunction = TFunction<void(AActor& Actor)>;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COG_API FCogWidgets
|
||||
{
|
||||
public:
|
||||
|
||||
static bool BeginTableTooltip();
|
||||
|
||||
static void EndTableTooltip();
|
||||
|
||||
static bool ItemTooltipWrappedText(const char* InText);
|
||||
|
||||
static bool BeginItemTooltipWrappedText();
|
||||
|
||||
static void EndItemTooltipWrappedText();
|
||||
|
||||
static bool BeginItemTableTooltip();
|
||||
|
||||
static void EndItemTableTooltip();
|
||||
|
||||
static void ThinSeparatorText(const char* Label);
|
||||
|
||||
static bool DarkCollapsingHeader(const char* InLabel, ImGuiTreeNodeFlags InFlags);
|
||||
|
||||
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
|
||||
|
||||
static bool ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor);
|
||||
|
||||
static bool ToggleButton(bool* Value, const char* Text, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
static bool ToggleButton(bool* Value, const char* TextTrue, const char* TextFalse, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
static bool MultiChoiceButton(const char* Label, bool IsSelected, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
static bool MultiChoiceButtonsInt(TArray<int32>& Values, int32& Value, const ImVec2& Size = ImVec2(0, 0), bool InInline = true);
|
||||
|
||||
static bool MultiChoiceButtonsFloat(TArray<float>& InValues, float& InValue, const ImVec2& InSize = ImVec2(0, 0), bool InInline = true, float InTolerance = UE_SMALL_NUMBER);
|
||||
|
||||
static void SliderWithReset(const char* Name, float* Value, float Min, float Max, const float& ResetValue, const char* Format);
|
||||
|
||||
static void HelpMarker(const char* Text);
|
||||
|
||||
static void PushStyleCompact();
|
||||
|
||||
static void PopStyleCompact();
|
||||
|
||||
static void AddTextWithShadow(ImDrawList* DrawList, const ImVec2& Position, ImU32 Color, const char* TextBegin, const char* TextEnd = nullptr);
|
||||
|
||||
static bool SearchBar(const char* InLabel, ImGuiTextFilter& InFilter, float InWidth = -1.0f);
|
||||
|
||||
static void PushButtonBackColor(const ImVec4& Color);
|
||||
|
||||
static void PopButtonBackColor();
|
||||
static void PushFrameBackColor(const ImVec4& Color);
|
||||
static void PushSliderBackColor(const ImVec4& Color);
|
||||
|
||||
static void PushBackColor(const ImVec4& Color);
|
||||
static void PopSliderBackColor();
|
||||
static void PopFrameBackColor();
|
||||
|
||||
static void PopBackColor();
|
||||
|
||||
static float GetShortWidth();
|
||||
|
||||
static void SetNextItemToShortWidth();
|
||||
|
||||
static float GetFontWidth();
|
||||
|
||||
template<typename EnumType>
|
||||
static bool ComboboxEnum(const char* Label, const EnumType CurrentValue, EnumType& NewValue);
|
||||
|
||||
template<typename EnumType>
|
||||
static bool ComboboxEnum(const char* Label, EnumType& Value);
|
||||
|
||||
static bool ComboboxEnum(const char* Label, const UEnum* Enum, int64 CurrentValue, int64& NewValue);
|
||||
|
||||
|
||||
static bool ComboboxEnum(const char* Label, const UObject* Object, const char* FieldName, uint8* PointerToEnumValue);
|
||||
|
||||
static bool ComboboxEnum(const char* Label, const FEnumProperty* EnumProperty, uint8* PointerToEnumValue);
|
||||
|
||||
static bool CheckBoxState(const char* Label, ECheckBoxState& State, bool ShowTooltip = true);
|
||||
|
||||
static bool InputChord(const char* Label, FInputChord& InInputChord);
|
||||
|
||||
static bool InputChord(FInputChord& InInputChord);
|
||||
|
||||
static bool Key(FKey& InKey);
|
||||
|
||||
static bool KeyBind(FKeyBind& InKeyBind);
|
||||
|
||||
static bool ButtonWithTooltip(const char* Text, const char* Tooltip);
|
||||
|
||||
static bool DeleteArrayItemButton();
|
||||
|
||||
static bool ComboTraceChannel(const char* Label, ECollisionChannel& Channel);
|
||||
|
||||
static bool CollisionProfileChannels(int32& OutChannels);
|
||||
|
||||
static bool CollisionTraceChannels(int32& OutChannels);
|
||||
|
||||
static bool CollisionObjectTypeChannels(int32& OutChannels);
|
||||
|
||||
static bool CollisionProfileChannel(const UCollisionProfile& InCollisionProfile, int32 InChannelIndex, FColor& InChannelColor, int32& InChannels);
|
||||
|
||||
static bool MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TSubclassOf<AActor>& ActorClass, const FCogWindowActorContextMenuFunction& ContextMenuFunction = nullptr);
|
||||
|
||||
static bool MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TArray<TSubclassOf<AActor>>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction = nullptr);
|
||||
|
||||
static bool ActorsListWithFilters(AActor*& NewSelection, const UWorld& World, const TArray<TSubclassOf<AActor>>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction = nullptr);
|
||||
|
||||
static bool ActorsList(AActor*& NewSelection, const UWorld& World, const TSubclassOf<AActor>& ActorClass, const ImGuiTextFilter* Filter = nullptr, const APawn* LocalPlayerPawn = nullptr, const FCogWindowActorContextMenuFunction& ContextMenuFunction = nullptr);
|
||||
|
||||
static void ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction);
|
||||
|
||||
static void ActorFrame(const AActor& Actor);
|
||||
|
||||
static void SmallButton(const char* Text, const ImVec4& Color);
|
||||
|
||||
static bool InputText(const char* Text, FString& Value, ImGuiInputTextFlags InFlags = 0, ImGuiInputTextCallback InCallback = nullptr, void* InUserData = nullptr);
|
||||
|
||||
static bool InputTextWithHint(const char* InText, const char* InHint, FString& InValue, ImGuiInputTextFlags InFlags = 0, ImGuiInputTextCallback InCallback = nullptr, void* InUserData = nullptr);
|
||||
|
||||
static bool BeginRightAlign(const char* Id);
|
||||
|
||||
static void EndRightAlign();
|
||||
|
||||
static void MenuItemShortcut(const char* Id, const FString& Text);
|
||||
|
||||
template <typename TCLass, typename TMember>
|
||||
static void InputChordProperty(TCLass* InConfig, TMember TCLass::* InInputChordPointerToMember);
|
||||
|
||||
template <typename TCLass, typename TMember>
|
||||
static void TextInputChordProperty(TCLass* InConfig, TMember TCLass::* InInputChordPointerToMember);
|
||||
|
||||
static bool BrowseToAssetButton(const UObject* InAsset, const ImVec2& InSize = ImVec2(0, 0));
|
||||
|
||||
static bool BrowseToAssetButton(const FAssetData& InAssetData, const ImVec2& InSize = ImVec2(0, 0));
|
||||
|
||||
static bool BrowseToObjectAssetButton(const UObject* InObject, const ImVec2& InSize = ImVec2(0, 0));
|
||||
|
||||
static bool OpenAssetButton(const UObject* InAsset, const ImVec2& InSize = ImVec2(0, 0));
|
||||
|
||||
static bool OpenObjectAssetButton(const UObject* InObject, const ImVec2& InSize = ImVec2(0, 0));
|
||||
|
||||
static void RenderCloseButton(const ImVec2& InPos);
|
||||
|
||||
static bool PickButton(const char* InLabel, const ImVec2& InSize, ImGuiButtonFlags InFlags = ImGuiButtonFlags_None);
|
||||
|
||||
static FString RemoveFirstZero(const FString& InText);
|
||||
|
||||
static FString FormatSmallFloat(float InValue);
|
||||
|
||||
static void FloatArray(const char* InLabel, TArray<float>& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
static void IntArray(const char* InLabel, TArray<int>& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
template<typename T>
|
||||
static bool ScalarArray(const char* InLabel, ImGuiDataType InDataType, TArray<T>& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0));
|
||||
|
||||
static ImVec2 ComputeScreenCornerLocation(const FVector2f& InAlignment, const FIntVector2& InPadding);
|
||||
|
||||
static ImVec2 ComputeScreenCornerLocation(const ImVec2& InAlignment, const ImVec2& InPadding);
|
||||
|
||||
static FString GetStringAfterCharacter(const FString& InString, TCHAR InChar);
|
||||
|
||||
static FString FormatConfigName(const FString& InConfigName);
|
||||
|
||||
static FString FormatShortcutName(const FString& InShortcutName);
|
||||
|
||||
static void TextInputChordProperty(UObject& InConfig, const FProperty& InInputChordProperty);
|
||||
|
||||
static bool InputChordProperty(UObject& InConfig, const FProperty& InInputChordProperty);
|
||||
|
||||
static bool IsConfigContainingInputChords(const UObject& InConfig);
|
||||
|
||||
static bool AllInputChordsOfConfig(UObject& InConfig, FProperty** InModifiedProperty = nullptr);
|
||||
|
||||
static void TextOfAllInputChordsOfConfig(UObject& InConfig);
|
||||
};
|
||||
|
||||
template<typename EnumType>
|
||||
bool FCogWidgets::ComboboxEnum(const char* Label, const EnumType CurrentValue, EnumType& NewValue)
|
||||
{
|
||||
int64 NewValueInt;
|
||||
if (ComboboxEnum(Label, StaticEnum<EnumType>(), static_cast<int64>(CurrentValue), NewValueInt))
|
||||
{
|
||||
NewValue = static_cast<EnumType>(NewValueInt);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename EnumType>
|
||||
bool FCogWidgets::ComboboxEnum(const char* Label, EnumType& Value)
|
||||
{
|
||||
return ComboboxEnum(Label, Value, Value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool FCogWidgets::ScalarArray(const char* InLabel, ImGuiDataType InDataType, TArray<T>& InArray, int32 InMaxEntries, const ImVec2& Size)
|
||||
{
|
||||
bool Result = false;
|
||||
ImGui::PushID(InLabel);
|
||||
|
||||
if (ImGui::BeginChild("##Entries", Size, ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_MenuBar))
|
||||
{
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
ImGui::TextUnformatted(InLabel);
|
||||
|
||||
int32 NumEntries = InArray.Num();
|
||||
SetNextItemToShortWidth();
|
||||
if (ImGui::SliderInt("##Size", &NumEntries, 0, InMaxEntries))
|
||||
{
|
||||
InArray.SetNum(NumEntries);
|
||||
Result = true;
|
||||
}
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < InArray.Num(); i++)
|
||||
{
|
||||
ImGui::PushID(i);
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
if (ImGui::InputScalar("##Entry", InDataType, &InArray[i]))
|
||||
{
|
||||
Result = true;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename TCLass, typename TMember>
|
||||
void FCogWidgets::InputChordProperty(TCLass* InConfig, TMember TCLass::* InInputChordPointerToMember)
|
||||
{
|
||||
if (InConfig == nullptr)
|
||||
{ return; }
|
||||
|
||||
FProperty* Property = FCogHelper::FindProperty(InConfig, InInputChordPointerToMember);
|
||||
if (Property == nullptr)
|
||||
{ return; }
|
||||
|
||||
InputChordProperty(*InConfig, *Property);
|
||||
}
|
||||
|
||||
template <typename TCLass, typename TMember>
|
||||
void FCogWidgets::TextInputChordProperty(TCLass* InConfig, TMember TCLass::* InInputChordPointerToMember)
|
||||
{
|
||||
if (InConfig == nullptr)
|
||||
{ return; }
|
||||
|
||||
FProperty* Property = FCogHelper::FindProperty(InConfig, InInputChordPointerToMember);
|
||||
if (Property == nullptr)
|
||||
{ return; }
|
||||
|
||||
TextInputChordProperty(*InConfig, *Property);
|
||||
}
|
||||
+42
-28
@@ -7,24 +7,25 @@
|
||||
#include "UObject/ReflectedTypeAccessors.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
|
||||
struct FCogDebugContext;
|
||||
class AActor;
|
||||
class APawn;
|
||||
class APlayerController;
|
||||
class UCogWindowManager;
|
||||
class UCogSubsystem;
|
||||
class ULocalPlayer;
|
||||
class UWorld;
|
||||
|
||||
class COGWINDOW_API FCogWindow
|
||||
class COG_API FCogWindow
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~FCogWindow() {}
|
||||
|
||||
virtual void Initialize() {}
|
||||
virtual void Initialize();
|
||||
|
||||
virtual void Shutdown() {}
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void ResetConfig() {}
|
||||
virtual void ResetConfig();
|
||||
|
||||
virtual void PreSaveConfig() {}
|
||||
|
||||
@@ -34,15 +35,16 @@ public:
|
||||
/** Called every frame with a valid imgui context even if the window is hidden. */
|
||||
virtual void RenderTick(float DeltaTime);
|
||||
|
||||
/** Called every frame without a valid imgui context (outside of the imgui NewFrame/EndFrame) even if the window is hidden. */
|
||||
/** Called every frame without a valid imgui context (outside the imgui NewFrame/EndFrame) even if the window is hidden. */
|
||||
virtual void GameTick(float DeltaTime);
|
||||
|
||||
/** */
|
||||
virtual float GetMainMenuWidgetWidth(int32 SubWidgetIndex, float MaxWidth) { return -1.0f; }
|
||||
virtual void RenderMainMenuWidget();
|
||||
|
||||
/** */
|
||||
virtual void RenderMainMenuWidget(int32 SubWidgetIndex, float Width) {}
|
||||
virtual void RenderSettings();
|
||||
|
||||
virtual void BindInputs(UInputComponent* InputComponent) {}
|
||||
|
||||
ImGuiID GetID() const { return ID; }
|
||||
|
||||
/** The full name of the window, that contains the path in the main menu. For example "Gameplay.Character.Effect" */
|
||||
@@ -53,7 +55,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);
|
||||
|
||||
@@ -71,23 +73,27 @@ public:
|
||||
|
||||
void SetWidgetOrderIndex(int32 Value) { WidgetOrderIndex = Value; }
|
||||
|
||||
void SetOwner(UCogWindowManager* InOwner) { Owner = InOwner; }
|
||||
void SetOwner(UCogSubsystem* InOwner) { Owner = InOwner; }
|
||||
|
||||
UCogWindowManager* GetOwner() const { return Owner; }
|
||||
UCogSubsystem* GetOwner() const { return Owner; }
|
||||
|
||||
float GetDpiScale() const;
|
||||
|
||||
|
||||
template<class T>
|
||||
T* GetConfig() const { return Cast<T>(GetConfig(T::StaticClass())); }
|
||||
T* GetConfig(bool InResetConfigOnRequest = true) const { return Cast<T>(GetConfig(T::StaticClass(), InResetConfigOnRequest)); }
|
||||
|
||||
UCogCommonConfig* GetConfig(const TSubclassOf<UCogCommonConfig> ConfigClass) const;
|
||||
UCogCommonConfig* GetConfig(const TSubclassOf<UCogCommonConfig>& InConfigClass, bool InResetConfigOnRequest = true) const;
|
||||
|
||||
template<class T>
|
||||
const T* GetAsset() const { return Cast<T>(GetAsset(T::StaticClass())); }
|
||||
|
||||
const UObject* GetAsset(const TSubclassOf<UObject> AssetClass) const;
|
||||
const UObject* GetAsset(const TSubclassOf<UObject>& AssetClass) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
friend class UCogWindowManager;
|
||||
friend class UCogSubsystem;
|
||||
|
||||
virtual const FString& GetTitle() const { return Title; }
|
||||
|
||||
@@ -95,30 +101,36 @@ protected:
|
||||
|
||||
virtual void RenderHelp();
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) {}
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) {}
|
||||
|
||||
virtual void PostRender() {}
|
||||
virtual void PostBegin() {}
|
||||
|
||||
virtual void PostEnd() {}
|
||||
|
||||
virtual void RenderContent() {}
|
||||
|
||||
virtual bool CheckEditorVisibility();
|
||||
|
||||
virtual void RenderContextMenu();
|
||||
|
||||
virtual void OnWindowVisibilityChanged(bool NewVisibility) { }
|
||||
|
||||
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) {}
|
||||
|
||||
virtual bool IsWindowRenderedInMainMenu();
|
||||
|
||||
virtual void RenderConfigShortcuts(UCogCommonConfig& InConfig) const;
|
||||
|
||||
APawn* GetLocalPlayerPawn() const;
|
||||
|
||||
APlayerController* GetLocalPlayerController() const;
|
||||
|
||||
ULocalPlayer* GetLocalPlayer() const;
|
||||
|
||||
protected:
|
||||
|
||||
bool bIsInitialized = false;
|
||||
|
||||
bool bShowMenu = true;
|
||||
|
||||
bool bNoPadding = false;
|
||||
|
||||
bool bHasMenu = false;
|
||||
|
||||
bool bIsVisible = false;
|
||||
@@ -127,20 +139,22 @@ protected:
|
||||
|
||||
bool bIsWidgetVisible = false;
|
||||
|
||||
bool bShowInMainMenu = true;
|
||||
|
||||
bool bUseCustomContextMenu = false;
|
||||
|
||||
int32 WidgetOrderIndex = -1;
|
||||
|
||||
ImGuiID ID;
|
||||
ImGuiID ID = 0;
|
||||
|
||||
FString FullName;
|
||||
|
||||
FString Name;
|
||||
|
||||
FString Title;
|
||||
|
||||
UCogSubsystem* Owner = nullptr;
|
||||
|
||||
UCogWindowManager* Owner = nullptr;
|
||||
|
||||
TWeakObjectPtr<AActor> CurrentSelection;
|
||||
|
||||
TWeakObjectPtr<AActor> OverridenSelection;
|
||||
mutable TArray<TWeakObjectPtr<UCogCommonConfig>> ConfigsToResetOnRequest;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
class UPlayerInput;
|
||||
|
||||
class COG_API FCogWindow_Layouts : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
FCogWindow_Layouts();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderLoadLayoutMenuItem(int InLayoutIndex, const FInputChord& InInputChord);
|
||||
|
||||
virtual void RenderSaveLayoutMenuItem(int InLayoutIndex, const FInputChord& InInputChord);
|
||||
};
|
||||
@@ -0,0 +1,165 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommonConfig.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindow_Settings.generated.h"
|
||||
|
||||
class UCogEngineConfig_Settings;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COG_API FCogWindow_Settings : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
FCogWindow_Settings();
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
const UCogWindowConfig_Settings* GetSettingsConfig() const { return Config; }
|
||||
|
||||
void SetDPIScale(float Value) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void PreSaveConfig() override;
|
||||
|
||||
TObjectPtr<UCogWindowConfig_Settings> Config = nullptr;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogWidgetAlignment
|
||||
{
|
||||
Left = 0,
|
||||
Center = 1,
|
||||
Right = 2,
|
||||
Manual = 3
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class UCogWindowConfig_Settings : public UCogCommonConfig
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Config)
|
||||
float DPIScale = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bEnableViewports = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bCompactMode = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bTransparentMode = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShowHelp = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShowWindowsInMainMenu = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bEnableInput = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShareMouse = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShareMouseWithGameplay = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bShareKeyboard = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bNavEnableKeyboard = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bDisableConflictingCommands = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bDisableShortcutsWhenImGuiWantTextInput = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogWidgetAlignment WidgetAlignment = ECogWidgetAlignment::Right;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowWidgetBorders = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_ToggleImguiInput = FInputChord(EKeys::F1);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_LoadLayout1 = FInputChord(EKeys::F2);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_LoadLayout2 = FInputChord(EKeys::F3);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_LoadLayout3 = FInputChord(EKeys::F4);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_LoadLayout4 = FInputChord();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_SaveLayout1 = FInputChord();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_SaveLayout2 = FInputChord();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_SaveLayout3 = FInputChord();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_SaveLayout4 = FInputChord();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FInputChord Shortcut_ResetLayout = FInputChord();
|
||||
|
||||
//UPROPERTY(Config)
|
||||
//bool bNavEnableGamepad = false;
|
||||
|
||||
//UPROPERTY(Config)
|
||||
//bool bNavNoCaptureInput = true;
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
|
||||
DPIScale = 1.0f;
|
||||
bEnableViewports = false;
|
||||
bCompactMode = false;
|
||||
bTransparentMode = false;
|
||||
bShowHelp = true;
|
||||
bShowWindowsInMainMenu = true;
|
||||
bEnableInput = false;
|
||||
bShareMouse = false;
|
||||
bShareMouseWithGameplay = false;
|
||||
bShareKeyboard = false;
|
||||
bNavEnableKeyboard = false;
|
||||
bDisableConflictingCommands = true;
|
||||
bDisableShortcutsWhenImGuiWantTextInput = false;
|
||||
WidgetAlignment = ECogWidgetAlignment::Right;
|
||||
ShowWidgetBorders = false;
|
||||
Shortcut_ToggleImguiInput = FInputChord(EKeys::F1);
|
||||
Shortcut_LoadLayout1 = FInputChord(EKeys::F2);
|
||||
Shortcut_LoadLayout2 = FInputChord(EKeys::F3);
|
||||
Shortcut_LoadLayout3 = FInputChord(EKeys::F4);
|
||||
Shortcut_LoadLayout4 = FInputChord();
|
||||
Shortcut_SaveLayout1 = FInputChord();
|
||||
Shortcut_SaveLayout2 = FInputChord();
|
||||
Shortcut_SaveLayout3 = FInputChord();
|
||||
Shortcut_SaveLayout4 = FInputChord();
|
||||
Shortcut_ResetLayout = FInputChord();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
class COG_API FCogWindow_Spacing : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
FCogWindow_Spacing();
|
||||
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void PostBegin() override;
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "CogCommonLogCategory.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogCogNotify);
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Templates/IsArrayOrRefOfType.h"
|
||||
#include "CogCommonLogCategory.h"
|
||||
|
||||
#ifndef ENABLE_COG
|
||||
#define ENABLE_COG !UE_BUILD_SHIPPING
|
||||
@@ -17,6 +18,37 @@
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (FCogDebug::IsDebugActiveForObject(Object))
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_NOTIFY(Format, ...) \
|
||||
{ \
|
||||
static_assert(TIsArrayOrRefOfType<decltype(Format), TCHAR>::Value, "Formatting string must be a TCHAR array."); \
|
||||
FMsg::Logf_Internal(nullptr, 0, LogCogNotify.GetCategoryName(), ELogVerbosity::Log, Format, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_NOTIFY_WARNING(Format, ...) \
|
||||
{ \
|
||||
static_assert(TIsArrayOrRefOfType<decltype(Format), TCHAR>::Value, "Formatting string must be a TCHAR array."); \
|
||||
FMsg::Logf_Internal(nullptr, 0, LogCogNotify.GetCategoryName(), ELogVerbosity::Warning, Format, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_NOTIFY_ERROR(Format, ...) \
|
||||
{ \
|
||||
static_assert(TIsArrayOrRefOfType<decltype(Format), TCHAR>::Value, "Formatting string must be a TCHAR array."); \
|
||||
FMsg::Logf_Internal(nullptr, 0, LogCogNotify.GetCategoryName(), ELogVerbosity::Error, Format, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_NOTIFY_VERBOSITY(Verbosity, Format, ...) \
|
||||
{ \
|
||||
static_assert(TIsArrayOrRefOfType<decltype(Format), TCHAR>::Value, "Formatting string must be a TCHAR array."); \
|
||||
if (LogCogNotify.IsSuppressed(Verbosity) == false) \
|
||||
{ \
|
||||
FMsg::Logf_Internal(nullptr, 0, LogCogNotify.GetCategoryName(), Verbosity, Format, ##__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_LOG(LogCategory, Verbosity, Format, ...) \
|
||||
{ \
|
||||
@@ -50,10 +82,13 @@
|
||||
|
||||
#else //ENABLE_COG
|
||||
|
||||
#define IF_COG(expr) (0)
|
||||
#define COG_LOG_CATEGORY FNoLoggingCategory
|
||||
#define COG_LOG_ABILITY(...) (0)
|
||||
|
||||
#define IF_COG(expr) (0)
|
||||
#define COG_LOG_CATEGORY FNoLoggingCategory
|
||||
#define COG_LOG_ABILITY(...) (0)
|
||||
#define COG_NOTIFY(Format, ...) (0)
|
||||
#define COG_NOTIFY_WARNING(Format, ...) (0)
|
||||
#define COG_NOTIFY_ERROR(Format, ...) (0)
|
||||
#define COG_NOTIFY_VERBOSITY(Verbosity, Format, ...) (0)
|
||||
#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (0)
|
||||
#define COG_LOG(LogCategory, Verbosity, Format, ...) (0)
|
||||
#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) (0)
|
||||
|
||||
@@ -12,7 +12,6 @@ public:
|
||||
|
||||
UCogCommonConfig()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
virtual void Reset()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Logging/LogMacros.h"
|
||||
|
||||
COGCOMMON_API DECLARE_LOG_CATEGORY_EXTERN(LogCogNotify, All, All);
|
||||
@@ -5,91 +5,33 @@
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
|
||||
{
|
||||
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
if (World == nullptr)
|
||||
if (InPieId == INDEX_NONE)
|
||||
{
|
||||
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)
|
||||
if (FCogDebugContext* Context = DebugContexts.Find(1))
|
||||
{
|
||||
return true;
|
||||
return *Context;
|
||||
}
|
||||
|
||||
if (Cast<ICogCommonDebugFilteredActorInterface>(Outer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const UObject* NewOuter = Outer->GetOuter();
|
||||
if (NewOuter == Outer || NewOuter == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Outer = NewOuter;
|
||||
}
|
||||
|
||||
FCogDebugContext& Context = DebugContexts.FindOrAdd(InPieId);
|
||||
return Context;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogDebug::GetSelection()
|
||||
FCogDebugContext& FCogDebug::Get()
|
||||
{
|
||||
return Selection[GetPieSessionId()].Get();
|
||||
const int32 PieId = GetPieSessionId();
|
||||
return Get(PieId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -108,31 +50,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);
|
||||
}
|
||||
@@ -144,7 +146,7 @@ bool FCogDebug::GetIsFilteringBySelection()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::SetIsFilteringBySelection(UWorld* World, bool Value)
|
||||
void FCogDebug::SetIsFilteringBySelection(const UWorld* World, bool Value)
|
||||
{
|
||||
Settings.bIsFilteringBySelection = Value;
|
||||
|
||||
@@ -173,13 +175,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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -191,7 +189,7 @@ int FCogDebug::GetDebugSegments()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int FCogDebug::GetCircleSegments()
|
||||
{
|
||||
return (Settings.Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
||||
return (Settings.Segments * 2) + 2; // because DrawDebugCircle do: Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -216,14 +214,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;
|
||||
}
|
||||
|
||||
@@ -252,7 +248,7 @@ FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, b
|
||||
case ECogDebugRecolorMode::HueOverFrames:
|
||||
{
|
||||
const FLinearColor BaseColor(Color);
|
||||
const float Factor = (Settings.RecolorFrameCycle > 0) ? (GFrameCounter % Settings.RecolorFrameCycle) / (float)Settings.RecolorFrameCycle : 0.0f;
|
||||
const float Factor = (Settings.RecolorFrameCycle > 0) ? (GFrameCounter % Settings.RecolorFrameCycle) / static_cast<float>(Settings.RecolorFrameCycle) : 0.0f;
|
||||
const FLinearColor NewColor(Factor * 360.0f, 1.0f, 1.0f);
|
||||
const FLinearColor BlendColor = BaseColor * (1.0f - Settings.RecolorIntensity) + NewColor.HSVToLinearRGB() * Settings.RecolorIntensity;
|
||||
return BlendColor.ToFColor(true);
|
||||
@@ -286,9 +282,7 @@ bool FCogDebug::IsSecondarySkeletonBone(FName BoneName)
|
||||
for (const FString& Wildcard : Settings.SecondaryBoneWildcards)
|
||||
{
|
||||
if (BoneString.MatchesWildcard(Wildcard))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
{ return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -305,12 +299,6 @@ void FCogDebug::GetDebugChannelColors(FColor ChannelColors[ECC_MAX])
|
||||
ChannelColors[ECC_PhysicsBody] = Settings.ChannelColorPhysicsBody;
|
||||
ChannelColors[ECC_Vehicle] = Settings.ChannelColorVehicle;
|
||||
ChannelColors[ECC_Destructible] = Settings.ChannelColorDestructible;
|
||||
ChannelColors[ECC_EngineTraceChannel1] = Settings.ChannelColorEngineTraceChannel1;
|
||||
ChannelColors[ECC_EngineTraceChannel2] = Settings.ChannelColorEngineTraceChannel2;
|
||||
ChannelColors[ECC_EngineTraceChannel3] = Settings.ChannelColorEngineTraceChannel3;
|
||||
ChannelColors[ECC_EngineTraceChannel4] = Settings.ChannelColorEngineTraceChannel4;
|
||||
ChannelColors[ECC_EngineTraceChannel5] = Settings.ChannelColorEngineTraceChannel5;
|
||||
ChannelColors[ECC_EngineTraceChannel6] = Settings.ChannelColorEngineTraceChannel6;
|
||||
ChannelColors[ECC_GameTraceChannel1] = Settings.ChannelColorGameTraceChannel1;
|
||||
ChannelColors[ECC_GameTraceChannel2] = Settings.ChannelColorGameTraceChannel2;
|
||||
ChannelColors[ECC_GameTraceChannel3] = Settings.ChannelColorGameTraceChannel3;
|
||||
@@ -368,4 +356,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);
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ void FCogDebugDraw::Points(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
int32 Index = 0;
|
||||
for (const FVector& Point : Points)
|
||||
{
|
||||
const FLinearColor Color = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / (float)(Points.Num() - 1));
|
||||
const FLinearColor Color = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / static_cast<float>(Points.Num() - 1));
|
||||
Sphere(LogCategory, WorldContextObject, Point, Radius, Color.ToFColor(true), Persistent, DepthPriority);
|
||||
Index++;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ void FCogDebugDraw::Path(const FLogCategoryBase& LogCategory, const UObject* Wor
|
||||
int32 Index = 0;
|
||||
for (const FVector& Position : Points)
|
||||
{
|
||||
const FLinearColor LinearColor = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / (float)(Points.Num() - 1));
|
||||
const FLinearColor LinearColor = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / static_cast<float>(Points.Num() - 1));
|
||||
FColor Color = LinearColor.ToFColor(true);
|
||||
|
||||
Point(LogCategory, WorldContextObject, Position, PointSize, Color, Persistent, DepthPriority);
|
||||
@@ -622,7 +622,6 @@ void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeleta
|
||||
|
||||
const FTransform Transform = ComponentSpaceTransforms[BoneIndex] * WorldTransform;
|
||||
const FVector BoneLocation = Transform.GetLocation();
|
||||
const FRotator BoneRotation = FRotator(Transform.GetRotation());
|
||||
const int32 ParentIndex = ReferenceSkeleton.GetParentIndex(BoneIndex);
|
||||
|
||||
FVector ParentLocation;
|
||||
@@ -703,7 +702,7 @@ void FCogDebugDraw::Sweep(const FLogCategoryBase& LogCategory, const UObject* Wo
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings)
|
||||
void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings)
|
||||
{
|
||||
if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false)
|
||||
{ return; }
|
||||
@@ -712,7 +711,7 @@ void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject*
|
||||
if (World == nullptr)
|
||||
{ return; }
|
||||
|
||||
FCogDebugDrawHelper::DrawOverlap(World, Shape, Location, Rotation, OverlapResults, Settings);
|
||||
FCogDebugDrawHelper::DrawOverlap(World, Shape, Location, Rotation, HasHits, OverlapResults, Settings);
|
||||
|
||||
const FColor Color = OverlapResults.Num() > 0
|
||||
? Settings.HitColor
|
||||
|
||||
@@ -78,7 +78,7 @@ void FCogDebugDrawHelper::DrawArc(
|
||||
}
|
||||
|
||||
float CurrentAngle = AngleStartRad;
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / float(Segments);
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / static_cast<float>(Segments);
|
||||
FVector PrevVertex = Center + OuterRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
int32 Count = Segments;
|
||||
while (Count--)
|
||||
@@ -94,7 +94,6 @@ void FCogDebugDrawHelper::DrawArc(
|
||||
CurrentAngle = AngleStartRad;
|
||||
PrevVertex = Center + InnerRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
|
||||
Count = Segments;
|
||||
while (Segments--)
|
||||
{
|
||||
CurrentAngle += AngleStep;
|
||||
@@ -189,8 +188,8 @@ void FCogDebugDrawHelper::DrawFrustum(
|
||||
|
||||
const float HozHalfAngleInRadians = FMath::DegreesToRadians(Angle * 0.5f);
|
||||
|
||||
float HozLength = 0.0f;
|
||||
float VertLength = 0.0f;
|
||||
float HozLength;
|
||||
float VertLength;
|
||||
|
||||
if (Angle > 0.0f)
|
||||
{
|
||||
@@ -398,7 +397,7 @@ void FCogDebugDrawHelper::DrawLineTrace(
|
||||
const FVector& Start,
|
||||
const FVector& End,
|
||||
const bool HasHits,
|
||||
TArray<FHitResult>& HitResults,
|
||||
const TArray<FHitResult>& HitResults,
|
||||
const FCogDebugDrawLineTraceParams& Settings
|
||||
)
|
||||
{
|
||||
@@ -460,11 +459,12 @@ void FCogDebugDrawHelper::DrawOverlap(
|
||||
const FCollisionShape& Shape,
|
||||
const FVector& Location,
|
||||
const FQuat& Rotation,
|
||||
TArray<FOverlapResult>& OverlapResults,
|
||||
const bool HasHits,
|
||||
const TArray<FOverlapResult>& OverlapResults,
|
||||
const FCogDebugDrawOverlapParams& Settings
|
||||
)
|
||||
{
|
||||
const FColor Color = OverlapResults.Num() > 0 ? Settings.HitColor : Settings.NoHitColor;
|
||||
const FColor Color = HasHits ? Settings.HitColor : Settings.NoHitColor;
|
||||
DrawShape(World, Shape, Location, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
if (Settings.DrawHitPrimitives)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugDrawImGui::Time = 0;
|
||||
TArray<FCogDebugDrawImGui::FLine> FCogDebugDrawImGui::Lines;
|
||||
TArray<FCogDebugDrawImGui::FTriangle> FCogDebugDrawImGui::Triangles;
|
||||
TArray<FCogDebugDrawImGui::FTriangle> FCogDebugDrawImGui::TrianglesFilled;
|
||||
@@ -22,7 +23,7 @@ void FCogDebugDrawImGui::AddLine(const ImVec2& P1, const ImVec2& P2, ImU32 Color
|
||||
Line.P2 = P2;
|
||||
Line.Color = Color;
|
||||
Line.Thickness = Thickness;
|
||||
Line.Time = ImGui::GetCurrentContext()->Time;
|
||||
Line.Time = Time;
|
||||
Line.Duration = Duration;
|
||||
Line.FadeColor = FadeColor;
|
||||
Lines.Add_GetRef(Line);
|
||||
@@ -37,7 +38,7 @@ void FCogDebugDrawImGui::AddRect(const ImVec2& Min, const ImVec2& Max, ImU32 Col
|
||||
Rectangle.Color = Color;
|
||||
Rectangle.Rounding = Rounding;
|
||||
Rectangle.Thickness = Thickness;
|
||||
Rectangle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Rectangle.Time = Time;
|
||||
Rectangle.Duration = Duration;
|
||||
Rectangle.FadeColor = FadeColor;
|
||||
Rectangles.Add_GetRef(Rectangle);
|
||||
@@ -52,7 +53,7 @@ void FCogDebugDrawImGui::AddRectFilled(const ImVec2& Min, const ImVec2& Max, ImU
|
||||
Rectangle.Color = Color;
|
||||
Rectangle.Rounding = Rounding;
|
||||
Rectangle.Thickness = 0.0f;
|
||||
Rectangle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Rectangle.Time = Time;
|
||||
Rectangle.Duration = Duration;
|
||||
Rectangle.FadeColor = FadeColor;
|
||||
RectanglesFilled.Add_GetRef(Rectangle);
|
||||
@@ -68,7 +69,7 @@ void FCogDebugDrawImGui::AddQuad(const ImVec2& P1, const ImVec2& P2, const ImVec
|
||||
Quad.P4 = P4;
|
||||
Quad.Color = Color;
|
||||
Quad.Thickness = Thickness;
|
||||
Quad.Time = ImGui::GetCurrentContext()->Time;
|
||||
Quad.Time = Time;
|
||||
Quad.Duration = Duration;
|
||||
Quad.FadeColor = FadeColor;
|
||||
Quads.Add_GetRef(Quad);
|
||||
@@ -84,7 +85,7 @@ void FCogDebugDrawImGui::AddQuadFilled(const ImVec2& P1, const ImVec2& P2, const
|
||||
Quad.P4 = P4;
|
||||
Quad.Color = Color;
|
||||
Quad.Thickness = 0.0f;
|
||||
Quad.Time = ImGui::GetCurrentContext()->Time;
|
||||
Quad.Time = Time;
|
||||
Quad.Duration = Duration;
|
||||
Quad.FadeColor = FadeColor;
|
||||
QuadsFilled.Add_GetRef(Quad);
|
||||
@@ -99,7 +100,7 @@ void FCogDebugDrawImGui::AddTriangle(const ImVec2& P1, const ImVec2& P2, const I
|
||||
Triangle.P3 = P3;
|
||||
Triangle.Color = Color;
|
||||
Triangle.Thickness = Thickness;
|
||||
Triangle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Triangle.Time = Time;
|
||||
Triangle.Duration = Duration;
|
||||
Triangle.FadeColor = FadeColor;
|
||||
Triangles.Add_GetRef(Triangle);
|
||||
@@ -114,7 +115,7 @@ void FCogDebugDrawImGui::AddTriangleFilled(const ImVec2& P1, const ImVec2& P2, c
|
||||
Triangle.P3 = P3;
|
||||
Triangle.Color = Color;
|
||||
Triangle.Thickness = 0.0f;
|
||||
Triangle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Triangle.Time = Time;
|
||||
Triangle.Duration = Duration;
|
||||
Triangle.FadeColor = FadeColor;
|
||||
TrianglesFilled.Add_GetRef(Triangle);
|
||||
@@ -123,13 +124,14 @@ void FCogDebugDrawImGui::AddTriangleFilled(const ImVec2& P1, const ImVec2& P2, c
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawImGui::AddCircle(const ImVec2& Center, float Radius, ImU32 Color, int Segments /*= 0*/, float Thickness /*= 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
|
||||
{
|
||||
|
||||
FCircle Circle;
|
||||
Circle.Center = Center;
|
||||
Circle.Radius = Radius > 0.0f ? Radius : 1.0f;
|
||||
Circle.Color = Color;
|
||||
Circle.Segments = Segments;
|
||||
Circle.Thickness = Thickness;
|
||||
Circle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Circle.Time = Time;
|
||||
Circle.Duration = Duration;
|
||||
Circle.FadeColor = FadeColor;
|
||||
Circles.Add_GetRef(Circle);
|
||||
@@ -144,7 +146,7 @@ void FCogDebugDrawImGui::AddCircleFilled(const ImVec2& Center, float Radius, ImU
|
||||
Circle.Color = Color;
|
||||
Circle.Segments = Segments;
|
||||
Circle.Thickness = 0.0f;
|
||||
Circle.Time = ImGui::GetCurrentContext()->Time;
|
||||
Circle.Time = Time;
|
||||
Circle.Duration = Duration;
|
||||
Circle.FadeColor = FadeColor;
|
||||
CirclesFilled.Add_GetRef(Circle);
|
||||
@@ -157,7 +159,7 @@ void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 C
|
||||
TextElement.Pos = Pos;
|
||||
TextElement.Text = Text;
|
||||
TextElement.Color = Color;
|
||||
TextElement.Time = ImGui::GetCurrentContext()->Time;
|
||||
TextElement.Time = Time;
|
||||
TextElement.Duration = Duration;
|
||||
TextElement.FadeColor = FadeColor;
|
||||
Texts.Add_GetRef(TextElement);
|
||||
@@ -169,7 +171,7 @@ void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 C
|
||||
ShadowTextElement.Text = Text;
|
||||
const float Alpha = ImGui::ColorConvertU32ToFloat4(Color).w; // Keep original Alpha and set to black
|
||||
ShadowTextElement.Color = ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, Alpha));
|
||||
ShadowTextElement.Time = ImGui::GetCurrentContext()->Time;
|
||||
ShadowTextElement.Time = Time;
|
||||
ShadowTextElement.Duration = Duration;
|
||||
ShadowTextElement.FadeColor = FadeColor;
|
||||
Texts.Add_GetRef(ShadowTextElement);
|
||||
@@ -181,7 +183,7 @@ void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 C
|
||||
void FCogDebugDrawImGui::Draw()
|
||||
{
|
||||
ImDrawList* DrawList = ImGui::GetBackgroundDrawList();
|
||||
double Time = ImGui::GetCurrentContext()->Time;
|
||||
Time = ImGui::GetCurrentContext()->Time;
|
||||
|
||||
DrawShapes(Lines, [DrawList](const FLine& Line, const ImColor Color) { DrawList->AddLine(Line.P1, Line.P2, Color, Line.Thickness); });
|
||||
DrawShapes(Rectangles, [DrawList](const FRectangle& Rectangle, const ImColor Color) { DrawList->AddRect(Rectangle.Min, Rectangle.Max, Color, Rectangle.Rounding, Rectangle.Thickness); });
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "CogDebugEvent.h"
|
||||
|
||||
#include "CogDebugTrack.h"
|
||||
#include "CogDebugTracker.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugEvent::GetActualEndTime(const UWorld& World) const
|
||||
{
|
||||
if (EndTime != 0.0f)
|
||||
{ return EndTime; }
|
||||
|
||||
const float WorldTime = World.GetTimeSeconds();
|
||||
return WorldTime;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "imgui.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Engine/World.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -74,11 +74,11 @@ float ScreenDistanceToArc(const APlayerController& InPlayerController, const FVe
|
||||
const FVector AxisZ = Matrix.GetScaledAxis(EAxis::Z);
|
||||
|
||||
float CurrentAngle = AngleStartRad;
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / float(NumSegments);
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / static_cast<float>(NumSegments);
|
||||
|
||||
FVector P0 = Center + Radius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
|
||||
FVector2D ScreenP0;
|
||||
FVector2D ScreenP0;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P0, ScreenP0);
|
||||
|
||||
float MinDistanceSqr = FLT_MAX;
|
||||
@@ -163,14 +163,14 @@ void DrawGizmoText(const ImVec2& Position, ImU32 Color, const char* Text)
|
||||
bool RenderComponent(const char* Label, double* Value, double Reset)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::PushItemWidth(-1);
|
||||
bool Result = FCogImguiHelper::DragDouble(Label, Value, 0.1f, 0.0f, 0.0f, "%.1f");
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
*Value = Reset;
|
||||
Result = true;
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
const float GizmoScale = Settings.GizmoScale * ScaleToKeepGizmoScreenSizeConstant;
|
||||
|
||||
const FQuat RotX = Settings.GizmoUseLocalSpace ? InOutTransform.GetRotation() : FQuat(FVector(0.0f, 0.0f, 1.0f), 0.0f);
|
||||
const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f,-1.0f), UE_HALF_PI);
|
||||
const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f, -1.0f), UE_HALF_PI);
|
||||
const FQuat RotZ = RotX * FQuat(FVector(0.0f, 1.0f, 0.0f), UE_HALF_PI);
|
||||
|
||||
const FVector UnitAxisX = Settings.GizmoUseLocalSpace ? RotX.GetAxisX() : FVector::XAxisVector;
|
||||
@@ -255,11 +255,11 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos;
|
||||
const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos);
|
||||
|
||||
const FColor GizmoAxisColorsZLow[] = { Settings.GizmoAxisColorsZLowX, Settings.GizmoAxisColorsZLowY, Settings.GizmoAxisColorsZLowZ, Settings.GizmoAxisColorsZLowW };
|
||||
const FColor GizmoAxisColorsZHigh[] = { Settings.GizmoAxisColorsZHighX, Settings.GizmoAxisColorsZHighY, Settings.GizmoAxisColorsZHighZ, Settings.GizmoAxisColorsZHighW };
|
||||
const FColor GizmoAxisColorsSelection[] = { Settings.GizmoAxisColorsSelectionX, Settings.GizmoAxisColorsSelectionY, Settings.GizmoAxisColorsSelectionZ, Settings.GizmoAxisColorsSelectionW };
|
||||
const FColor GizmoAxisColorsZLow[] = {Settings.GizmoAxisColorsZLowX, Settings.GizmoAxisColorsZLowY, Settings.GizmoAxisColorsZLowZ, Settings.GizmoAxisColorsZLowW};
|
||||
const FColor GizmoAxisColorsZHigh[] = {Settings.GizmoAxisColorsZHighX, Settings.GizmoAxisColorsZHighY, Settings.GizmoAxisColorsZHighZ, Settings.GizmoAxisColorsZHighW};
|
||||
const FColor GizmoAxisColorsSelection[] = {Settings.GizmoAxisColorsSelectionX, Settings.GizmoAxisColorsSelectionY, Settings.GizmoAxisColorsSelectionZ, Settings.GizmoAxisColorsSelectionW};
|
||||
|
||||
FCogDebug_GizmoElement GizmoElements[(uint8)ECogDebug_GizmoElementType::MAX];
|
||||
FCogDebug_GizmoElement GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MAX)];
|
||||
for (FCogDebug_GizmoElement& GizmoElement : GizmoElements)
|
||||
{
|
||||
GizmoElement.Type = ECogDebug_GizmoType::MAX;
|
||||
@@ -267,35 +267,35 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationAxis) == false)
|
||||
{
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveX] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoTranslationAxisLength * GizmoScale };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveY] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoTranslationAxisLength * GizmoScale };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveZ] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoTranslationAxisLength * GizmoScale };
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveX)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoTranslationAxisLength * GizmoScale};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveY)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoTranslationAxisLength * GizmoScale};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveZ)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoTranslationAxisLength * GizmoScale};
|
||||
}
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationPlane) == false)
|
||||
{
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXY] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + ((UnitAxisX + UnitAxisY) * Settings.GizmoTranslationPlaneOffset * GizmoScale) };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + ((UnitAxisX + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale) };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveYZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + ((UnitAxisY + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale) };
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveXY)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + ((UnitAxisX + UnitAxisY) * Settings.GizmoTranslationPlaneOffset * GizmoScale)};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveXZ)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + ((UnitAxisX + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale)};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::MoveYZ)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + ((UnitAxisY + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale)};
|
||||
}
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoRotation) == false)
|
||||
{
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateX] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, FVector::ZeroVector };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateY] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, FVector::ZeroVector };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateZ] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, FVector::ZeroVector };
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::RotateX)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, FVector::ZeroVector};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::RotateY)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, FVector::ZeroVector};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::RotateZ)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, FVector::ZeroVector};
|
||||
}
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoScaleUniform) == false)
|
||||
{
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleXYZ] = { ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter };
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::ScaleXYZ)] = {ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter};
|
||||
}
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoScaleAxis) == false)
|
||||
{
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleX] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoScaleBoxOffset * GizmoScale };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleY] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoScaleBoxOffset * GizmoScale };
|
||||
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleZ] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoScaleBoxOffset * GizmoScale };
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::ScaleX)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoScaleBoxOffset * GizmoScale};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::ScaleY)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoScaleBoxOffset * GizmoScale};
|
||||
GizmoElements[static_cast<uint8>(ECogDebug_GizmoElementType::ScaleZ)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoScaleBoxOffset * GizmoScale};
|
||||
}
|
||||
|
||||
ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX;
|
||||
@@ -306,7 +306,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
else if (IO.WantCaptureMouse == false)
|
||||
{
|
||||
float MinDistanceToMouse = FLT_MAX;
|
||||
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||
for (uint8 i = static_cast<uint8>(ECogDebug_GizmoElementType::MoveX); i < static_cast<uint8>(ECogDebug_GizmoElementType::MAX); ++i)
|
||||
{
|
||||
FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||
float DistanceToMouse = FLT_MAX;
|
||||
@@ -340,22 +340,22 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
break;
|
||||
}
|
||||
|
||||
default:;
|
||||
default: ;
|
||||
}
|
||||
|
||||
if (DistanceToMouse < Settings.GizmoCursorSelectionThreshold && DistanceToMouse < MinDistanceToMouse)
|
||||
{
|
||||
HoveredElementType = (ECogDebug_GizmoElementType)i;
|
||||
HoveredElementType = static_cast<ECogDebug_GizmoElementType>(i);
|
||||
MinDistanceToMouse = DistanceToMouse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||
for (uint8 i = static_cast<uint8>(ECogDebug_GizmoElementType::MoveX); i < static_cast<uint8>(ECogDebug_GizmoElementType::MAX); ++i)
|
||||
{
|
||||
const FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||
const bool IsClosestToMouse = i == (uint8)HoveredElementType;
|
||||
const uint8 AxisIndex = (uint8)Elm.AxisType;
|
||||
const bool IsClosestToMouse = i == static_cast<uint8>(HoveredElementType);
|
||||
const uint8 AxisIndex = static_cast<uint8>(Elm.AxisType);
|
||||
const FColor ZLowColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZLow[AxisIndex];
|
||||
const FColor ZHighColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZHigh[AxisIndex];
|
||||
|
||||
@@ -394,7 +394,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
const FRotationTranslationMatrix Matrix(FRotator(90.0f, 0, 0), GroundHit.ImpactPoint);
|
||||
FCogDebugDrawHelper::DrawArc(World, Matrix, Settings.GizmoGroundRaycastCircleRadius, Settings.GizmoGroundRaycastCircleRadius, 0.0f, 360.0f, 24, Settings.GizmoGroundRaycastCircleColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
}
|
||||
DrawDebugLine(World, GizmoCenter, Bottom, Settings.GizmoGroundRaycastColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
DrawDebugLine(World, GizmoCenter, Bottom, Settings.GizmoGroundRaycastColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
}
|
||||
|
||||
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
@@ -418,18 +418,18 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
}
|
||||
else if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
InOutTransform = InitialTransform;
|
||||
DraggedElementType = ECogDebug_GizmoElementType::MAX;
|
||||
}
|
||||
else if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, Settings.GizmoCursorDraggingThreshold))
|
||||
{
|
||||
const FCogDebug_GizmoElement& DraggedElement = GizmoElements[(uint8)DraggedElementType];
|
||||
const FCogDebug_GizmoElement& DraggedElement = GizmoElements[static_cast<uint8>(DraggedElementType)];
|
||||
|
||||
switch (DraggedElement.Type)
|
||||
{
|
||||
case ECogDebug_GizmoType::MoveAxis:
|
||||
case ECogDebug_GizmoType::MoveAxis:
|
||||
{
|
||||
const FVector CursorOnLine = GetMouseCursorOnLine(InPlayerController, InitialTransform.GetTranslation(), DraggedElement.Direction, MousePos - CursorOffset);
|
||||
const float Delta = FVector::DotProduct(DraggedElement.Direction, CursorOnLine - InitialTransform.GetTranslation());
|
||||
@@ -472,8 +472,8 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
DrawGizmoText(FCogImguiHelper::ToImVec2(Center2D), FCogImguiHelper::ToImU32(Settings.GizmoTextColor), StringCast<ANSICHAR>(*Text).Get());
|
||||
|
||||
//DrawDebugPoint(World, InitialTransform.GetTranslation(), 5.0f, FColor::White);
|
||||
//DrawDebugLine(World, InitialTransform.GetTranslation(), InitialTransform.GetTranslation() + WorldDeltaU, FColor::White);
|
||||
//DrawDebugLine(World, InitialTransform.GetTranslation() + WorldDeltaU, InitialTransform.GetTranslation() + WorldDeltaU + WorldDeltaV, FColor::White);
|
||||
//DrawDebugLine(World, InitialTransform.GetTranslation(), InitialTransform.GetTranslation() + WorldDeltaU, FColor::White);
|
||||
//DrawDebugLine(World, InitialTransform.GetTranslation() + WorldDeltaU, InitialTransform.GetTranslation() + WorldDeltaU + WorldDeltaV, FColor::White);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
const float NormalizedAngle = FRotator::NormalizeAxis(DragAmount * Settings.GizmoRotationSpeed);
|
||||
const float SnappedAngle = FMath::GridSnap(NormalizedAngle, Settings.GizmoRotationSnapEnable ? Settings.GizmoRotationSnapValue : 0.0f);
|
||||
const FQuat RotDelta(-DraggedElement.Axis, FMath::DegreesToRadians(SnappedAngle));
|
||||
const FQuat NewRot = (Settings.GizmoUseLocalSpace) ? InitialTransform.GetRotation() * RotDelta : RotDelta * InitialTransform.GetRotation();
|
||||
const FQuat NewRot = (Settings.GizmoUseLocalSpace) ? InitialTransform.GetRotation() * RotDelta : RotDelta * InitialTransform.GetRotation();
|
||||
InOutTransform.SetRotation(NewRot);
|
||||
Result = true;
|
||||
|
||||
@@ -526,84 +526,136 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (HoveredElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
DraggedElementType = HoveredElementType;
|
||||
DraggedElementType = HoveredElementType;
|
||||
CursorOffset = MousePos - Center2D;
|
||||
InitialTransform = InOutTransform;
|
||||
}
|
||||
//else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
//{
|
||||
// ImGui::OpenPopup(Id);
|
||||
//}
|
||||
else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
if (Settings.GizmoSupportContextMenu)
|
||||
{
|
||||
ImGui::OpenPopup(Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (ImGui::BeginPopup(Id))
|
||||
//{
|
||||
// FVector Translation = InOutTransform.GetTranslation();
|
||||
// FRotator Rotation = InOutTransform.GetRotation().Rotator();
|
||||
// FVector Scale = InOutTransform.GetScale3D();
|
||||
if (Settings.GizmoSupportContextMenu)
|
||||
{
|
||||
if (ImGui::BeginPopup(Id))
|
||||
{
|
||||
FVector Translation = InOutTransform.GetTranslation();
|
||||
FRotator Rotation = InOutTransform.GetRotation().Rotator();
|
||||
FVector Scale = InOutTransform.GetScale3D();
|
||||
|
||||
// ImGui::Checkbox("Local Space", &Settings.GizmoUseLocalSpace);
|
||||
ImGui::Checkbox("Local Space", &Settings.GizmoUseLocalSpace);
|
||||
|
||||
// ImGui::Separator();
|
||||
ImGui::Separator();
|
||||
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(1.0f, 1.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(1.0f, 1.0f));
|
||||
|
||||
// if (ImGui::BeginTable("Pools", 6, ImGuiTableFlags_SizingFixedFit))
|
||||
// {
|
||||
// ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 5);
|
||||
// ImGui::TableSetupColumn("X", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
// ImGui::TableSetupColumn("Y", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
// ImGui::TableSetupColumn("Z", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
// ImGui::TableSetupColumn("SnapEnable", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
// ImGui::TableSetupColumn("Snap", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 3);
|
||||
if (ImGui::BeginTable("Pools", 6, ImGuiTableFlags_SizingFixedFit))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 5);
|
||||
ImGui::TableSetupColumn("X", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
ImGui::TableSetupColumn("Y", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
ImGui::TableSetupColumn("Z", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
ImGui::TableSetupColumn("SnapEnable", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4);
|
||||
ImGui::TableSetupColumn("Snap", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 3);
|
||||
|
||||
// ImGui::PushID("Location");
|
||||
// ImGui::TableNextRow();
|
||||
// ImGui::TableNextColumn();
|
||||
// ImGui::Text("Location");
|
||||
// if (RenderComponent("##X", &Translation.X, 0.0)) { InOutTransform.SetTranslation(Translation); }
|
||||
// if (RenderComponent("##Y", &Translation.Y, 0.0)) { InOutTransform.SetTranslation(Translation); }
|
||||
// if (RenderComponent("##Z", &Translation.Z, 0.0)) { InOutTransform.SetTranslation(Translation); }
|
||||
// RenderSnap(&Settings.GizmoTranslationSnapEnable, &Settings.GizmoTranslationSnapValue);
|
||||
// ImGui::PopID();
|
||||
ImGui::PushID("Location");
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Location");
|
||||
|
||||
bool Translate = false;
|
||||
Translate |= RenderComponent("##X", &Translation.X, 0.0);
|
||||
Translate |= RenderComponent("##Y", &Translation.Y, 0.0);
|
||||
Translate |= RenderComponent("##Z", &Translation.Z, 0.0);
|
||||
if (Translate)
|
||||
{
|
||||
if (Settings.GizmoTranslationSnapEnable)
|
||||
{
|
||||
Translation.X = FMath::GridSnap(Translation.X, Settings.GizmoTranslationSnapValue);
|
||||
Translation.Y = FMath::GridSnap(Translation.Y, Settings.GizmoTranslationSnapValue);
|
||||
Translation.Z = FMath::GridSnap(Translation.Z, Settings.GizmoTranslationSnapValue);
|
||||
}
|
||||
|
||||
InOutTransform.SetTranslation(Translation);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
RenderSnap(&Settings.GizmoTranslationSnapEnable, &Settings.GizmoTranslationSnapValue);
|
||||
ImGui::PopID();
|
||||
|
||||
// ImGui::PushID("Rotation");
|
||||
// ImGui::TableNextRow();
|
||||
// ImGui::TableNextColumn();
|
||||
// ImGui::Text("Rotation");
|
||||
// if (RenderComponent("##X", &Rotation.Yaw, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); }
|
||||
// if (RenderComponent("##Y", &Rotation.Pitch, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); }
|
||||
// if (RenderComponent("##Z", &Rotation.Roll, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); }
|
||||
// RenderSnap(&Settings.GizmoRotationSnapEnable, &Settings.GizmoRotationSnapValue);
|
||||
// ImGui::PopID();
|
||||
ImGui::PushID("Rotation");
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Rotation");
|
||||
|
||||
// ImGui::PushID("Scale");
|
||||
// ImGui::TableNextRow();
|
||||
// ImGui::TableNextColumn();
|
||||
// ImGui::Text("Scale");
|
||||
// if (RenderComponent("##X", &Scale.X, 0.0)) { InOutTransform.SetScale3D(Scale); }
|
||||
// if (RenderComponent("##Y", &Scale.Y, 0.0)) { InOutTransform.SetScale3D(Scale); }
|
||||
// if (RenderComponent("##Z", &Scale.Z, 0.0)) { InOutTransform.SetScale3D(Scale); }
|
||||
// RenderSnap(&Settings.GizmoScaleSnapEnable, &Settings.GizmoScaleSnapValue);
|
||||
// ImGui::PopID();
|
||||
bool Rotate = false;
|
||||
Rotate |= RenderComponent("##X", &Rotation.Yaw, 0.0);
|
||||
Rotate |= RenderComponent("##Y", &Rotation.Pitch, 0.0);
|
||||
Rotate |= RenderComponent("##Z", &Rotation.Roll, 0.0);
|
||||
|
||||
// ImGui::EndTable();
|
||||
// }
|
||||
if (Rotate)
|
||||
{
|
||||
if (Settings.GizmoRotationSnapEnable)
|
||||
{
|
||||
Rotation.Yaw = FMath::GridSnap(Rotation.Yaw, Settings.GizmoRotationSnapValue);
|
||||
Rotation.Pitch = FMath::GridSnap(Rotation.Pitch, Settings.GizmoRotationSnapValue);
|
||||
Rotation.Roll = FMath::GridSnap(Rotation.Roll, Settings.GizmoRotationSnapValue);
|
||||
}
|
||||
|
||||
InOutTransform.SetRotation(Rotation.Quaternion());
|
||||
Result = true;
|
||||
}
|
||||
|
||||
RenderSnap(&Settings.GizmoRotationSnapEnable, &Settings.GizmoRotationSnapValue);
|
||||
ImGui::PopID();
|
||||
|
||||
// ImGui::PopStyleVar();
|
||||
ImGui::PushID("Scale");
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Scale");
|
||||
|
||||
// ImGui::EndPopup();
|
||||
//}
|
||||
bool Rescale = false;
|
||||
Rescale |= RenderComponent("##X", &Scale.X, 1.0);
|
||||
Rescale |= RenderComponent("##Y", &Scale.Y, 1.0);
|
||||
Rescale |= RenderComponent("##Z", &Scale.Z, 1.0);
|
||||
|
||||
if (Rescale)
|
||||
{
|
||||
if (Settings.GizmoScaleSnapEnable)
|
||||
{
|
||||
Scale.X = FMath::GridSnap(Scale.X, Settings.GizmoScaleSnapValue);
|
||||
Scale.Y = FMath::GridSnap(Scale.Y, Settings.GizmoScaleSnapValue);
|
||||
Scale.Z = FMath::GridSnap(Scale.Z, Settings.GizmoScaleSnapValue);
|
||||
}
|
||||
|
||||
InOutTransform.SetScale3D(Scale);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
RenderSnap(&Settings.GizmoScaleSnapEnable, &Settings.GizmoScaleSnapValue);
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ FColor FCogDebugHelper::GetAutoColor(FName Name, const FColor& UserColor)
|
||||
const uint32 Hash = GetTypeHash(Name.ToString());
|
||||
FMath::RandInit(Hash);
|
||||
|
||||
const uint8 Hue = (uint8)(FMath::FRand() * 255);
|
||||
const uint8 Saturation = 255;
|
||||
const uint8 Hue = static_cast<uint8>(FMath::FRand() * 255);
|
||||
constexpr uint8 Saturation = 255;
|
||||
const uint8 Value = FMath::Rand() > 0.5f ? 200 : 255;
|
||||
|
||||
return FLinearColor::MakeFromHSV8(Hue, Saturation, Value).ToFColor(true);
|
||||
@@ -33,9 +33,8 @@ const char* FCogDebugHelper::VerbosityToString(ELogVerbosity::Type Verbosity)
|
||||
case ELogVerbosity::Log: return "Log";
|
||||
case ELogVerbosity::Verbose: return "Verbose";
|
||||
case ELogVerbosity::VeryVerbose: return "Very Verbose";
|
||||
default: return "None";
|
||||
}
|
||||
|
||||
return "None";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -97,16 +97,16 @@ ELogVerbosity::Type FCogDebugLog::GetServerVerbosity(const FName CategoryName)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugLog::SetServerVerbosity(UWorld& World, const FName CategoryName, ELogVerbosity::Type Verbosity)
|
||||
void FCogDebugLog::SetServerVerbosity(const UWorld& World, const FName CategoryName, ELogVerbosity::Type Verbosity)
|
||||
{
|
||||
if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(World))
|
||||
{
|
||||
Replicator->Server_SetCategoryVerbosity(CategoryName, (ECogLogVerbosity)Verbosity);
|
||||
Replicator->Server_SetCategoryVerbosity(CategoryName, static_cast<ECogLogVerbosity>(Verbosity));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugLog::SetServerVerbosityActive(UWorld& World, const FName CategoryName, const bool Value)
|
||||
void FCogDebugLog::SetServerVerbosityActive(const UWorld& World, const FName CategoryName, const bool Value)
|
||||
{
|
||||
SetServerVerbosity(World, CategoryName, Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, const FCogLog
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// ReSharper disable once CppPassValueParameterByConstReference
|
||||
bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, const FCogLogCategory LogCategory)
|
||||
{
|
||||
#if ENABLE_COG
|
||||
|
||||
@@ -1,560 +0,0 @@
|
||||
#include "CogDebugPlot.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
FCogDebugPlotEvent FCogDebugPlot::DefaultEvent;
|
||||
TArray<FCogDebugPlotEntry> FCogDebugPlot::Plots;
|
||||
TArray<FCogDebugPlotEntry> FCogDebugPlot::Events;
|
||||
bool FCogDebugPlot::IsVisible = false;
|
||||
bool FCogDebugPlot::Pause = false;
|
||||
FName FCogDebugPlot::LastAddedEventPlotName = NAME_None;
|
||||
int32 FCogDebugPlot::LastAddedEventIndex = INDEX_NONE;
|
||||
TMap<int32, TMap<int32, int32>> FCogDebugPlot::OccupationMap;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogPlotEvent
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugPlotEvent::GetActualEndTime(const FCogDebugPlotEntry& 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 FCogDebugPlotEntry& 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;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogPlotEntry
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotEntry::AddPoint(float X, float Y)
|
||||
{
|
||||
if (Values.Capacity == 0)
|
||||
{
|
||||
Values.reserve(2000);
|
||||
}
|
||||
|
||||
if (Values.size() < Values.Capacity)
|
||||
{
|
||||
Values.push_back(ImVec2(X, Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
Values[ValueOffset] = ImVec2(X, Y);
|
||||
ValueOffset = (ValueOffset + 1) % Values.size();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlotEntry::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 = nullptr;
|
||||
|
||||
int32 AddedIndex = 0;
|
||||
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& FCogDebugPlotEntry::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* FCogDebugPlotEntry::GetLastEvent()
|
||||
{
|
||||
if (Events.Num() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 Index = Events.Num() - 1;
|
||||
if (EventOffset != 0)
|
||||
{
|
||||
Index = (Index + EventOffset) % Events.Num();
|
||||
}
|
||||
|
||||
return &Events[Index];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent* FCogDebugPlotEntry::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 FCogDebugPlotEntry::AssignGraphAndAxis(int32 InGraph, ImAxis InYAxis)
|
||||
{
|
||||
GraphIndex = InGraph;
|
||||
YAxis = InYAxis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotEntry::ResetGraphAndAxis()
|
||||
{
|
||||
GraphIndex = INDEX_NONE;
|
||||
YAxis = ImAxis_COUNT;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlotEntry::Clear()
|
||||
{
|
||||
FCogDebugPlot::ResetLastAddedEvent();
|
||||
|
||||
MaxRow = 0;
|
||||
|
||||
if (Values.size() > 0)
|
||||
{
|
||||
Values.shrink(0);
|
||||
ValueOffset = 0;
|
||||
}
|
||||
|
||||
if (Events.Num() > 0)
|
||||
{
|
||||
Events.Empty();
|
||||
Events.Shrink();
|
||||
EventOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugPlotEntry::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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogPlot
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::Reset()
|
||||
{
|
||||
Plots.Empty();
|
||||
Events.Empty();
|
||||
OccupationMap.Empty();
|
||||
Pause = false;
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::Clear()
|
||||
{
|
||||
for (FCogDebugPlotEntry& Entry : Plots)
|
||||
{
|
||||
Entry.Clear();
|
||||
}
|
||||
|
||||
for (FCogDebugPlotEntry& Entry : Events)
|
||||
{
|
||||
Entry.Clear();
|
||||
}
|
||||
|
||||
OccupationMap.Empty();
|
||||
ResetLastAddedEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::ResetLastAddedEvent()
|
||||
{
|
||||
LastAddedEventPlotName = NAME_None;
|
||||
LastAddedEventIndex = INDEX_NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent* FCogDebugPlot::GetLastAddedEvent()
|
||||
{
|
||||
FCogDebugPlotEntry* Plot = FindEntry(true, LastAddedEventPlotName);
|
||||
if (Plot == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Plot->GetLastEvent();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEntry* FCogDebugPlot::FindEntry(const FName Name)
|
||||
{
|
||||
if (FCogDebugPlotEntry* Event = Events.FindByPredicate([Name](const FCogDebugPlotEntry& P) { return P.Name == Name; }))
|
||||
{
|
||||
return Event;
|
||||
}
|
||||
|
||||
if (FCogDebugPlotEntry* Plot = Plots.FindByPredicate([Name](const FCogDebugPlotEntry& P) { return P.Name == Name; }))
|
||||
{
|
||||
return Plot;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEntry* FCogDebugPlot::FindEntry(bool IsEvent, const FName Name)
|
||||
{
|
||||
TArray<FCogDebugPlotEntry>* Entries = IsEvent ? &Events : &Plots;
|
||||
FCogDebugPlotEntry* Entry = Entries->FindByPredicate([Name](const FCogDebugPlotEntry& P) { return P.Name == Name; });
|
||||
return Entry;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObject, const FName PlotName, bool IsEventPlot)
|
||||
{
|
||||
//----------------------------------------------------------
|
||||
// When not visible, we don't go further for performances.
|
||||
//----------------------------------------------------------
|
||||
if (IsVisible == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FCogDebugPlotEntry* EntryPtr = FindEntry(IsEventPlot, PlotName);
|
||||
if (EntryPtr == nullptr)
|
||||
{
|
||||
TArray<FCogDebugPlotEntry>* Entries = IsEventPlot ? &Events : &Plots;
|
||||
EntryPtr = &Entries->AddDefaulted_GetRef();
|
||||
EntryPtr->Name = PlotName;
|
||||
EntryPtr->IsEventPlot = IsEventPlot;
|
||||
Entries->Sort([](const FCogDebugPlotEntry& A, const FCogDebugPlotEntry& B) { return A.Name.ToString().Compare(B.Name.ToString()) < 0; });
|
||||
}
|
||||
|
||||
//if (EntryPtr->YAxis == ImAxis_COUNT)
|
||||
//{
|
||||
// return nullptr;
|
||||
//}
|
||||
|
||||
const float Time = World->GetTimeSeconds();
|
||||
if (Time < EntryPtr->Time)
|
||||
{
|
||||
EntryPtr->Clear();
|
||||
}
|
||||
|
||||
EntryPtr->World = World;
|
||||
EntryPtr->Time = World->GetTimeSeconds();
|
||||
EntryPtr->Frame = GFrameCounter;
|
||||
|
||||
return EntryPtr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugPlot::PlotValue(const UObject* WorldContextObject, const FName PlotName, const float Value)
|
||||
{
|
||||
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, false);
|
||||
if (Plot == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plot->AddPoint(Plot->Time, Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FCogDebugPlotEvent& FCogDebugPlot::PlotEvent(const UObject* WorldContextObject, const FName PlotName, const FName EventId, bool IsInstant, const int32 Row, const FColor& Color)
|
||||
{
|
||||
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, true);
|
||||
if (Plot == nullptr)
|
||||
{
|
||||
ResetLastAddedEvent();
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugPlotEvent& Event = Plot->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)
|
||||
{
|
||||
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, true);
|
||||
if (Plot == nullptr)
|
||||
{
|
||||
return DefaultEvent;
|
||||
}
|
||||
|
||||
FCogDebugPlotEvent& Event = Plot->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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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,12 +1,10 @@
|
||||
#include "CogDebugReplicator.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugLog.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "GameFramework/WorldSettings.h"
|
||||
#include "Net/Core/PushModel/PushModel.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -27,17 +25,18 @@ ACogDebugReplicator* ACogDebugReplicator::Spawn(APlayerController* Controller)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ACogDebugReplicator* ACogDebugReplicator::GetLocalReplicator(const UWorld& World)
|
||||
{
|
||||
for (TActorIterator<ACogDebugReplicator> It(&World, StaticClass()); It; ++It)
|
||||
const TActorIterator<ACogDebugReplicator> It(&World, StaticClass());
|
||||
if (It)
|
||||
{
|
||||
ACogDebugReplicator* Replicator = *It;
|
||||
return Replicator;
|
||||
return Replicator;
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogDebugReplicator::GetRemoteReplicators(UWorld& World, TArray<ACogDebugReplicator*>& Replicators)
|
||||
void ACogDebugReplicator::GetRemoteReplicators(const UWorld& World, TArray<ACogDebugReplicator*>& Replicators)
|
||||
{
|
||||
for (TActorIterator<ACogDebugReplicator> It(&World, ACogDebugReplicator::StaticClass()); It; ++It)
|
||||
{
|
||||
@@ -104,7 +103,7 @@ void ACogDebugReplicator::TickActor(float DeltaTime, enum ELevelTick TickType, F
|
||||
#if !UE_BUILD_SHIPPING
|
||||
|
||||
Super::TickActor(DeltaTime, TickType, ThisTickFunction);
|
||||
if (OwnerPlayerController)
|
||||
if (OwnerPlayerController.IsValid())
|
||||
{
|
||||
if (GetWorld()->GetNetMode() == NM_Client)
|
||||
{
|
||||
@@ -128,7 +127,7 @@ void ACogDebugReplicator::Server_SetCategoryVerbosity_Implementation(FName LogCa
|
||||
{
|
||||
if (const FCogDebugLogCategoryInfo* LogCategoryInfo = FCogDebugLog::FindLogCategoryInfo(LogCategoryName))
|
||||
{
|
||||
LogCategoryInfo->LogCategory->SetVerbosity((ELogVerbosity::Type)Verbosity);
|
||||
LogCategoryInfo->LogCategory->SetVerbosity(static_cast<ELogVerbosity::Type>(Verbosity));
|
||||
|
||||
TArray<FCogServerCategoryData> CategoriesData;
|
||||
CategoriesData.Add({ LogCategoryName, Verbosity });
|
||||
@@ -148,7 +147,7 @@ void ACogDebugReplicator::NetMulticast_SendCategoriesVerbosity_Implementation(co
|
||||
{
|
||||
for (const FCogServerCategoryData& Category : Categories)
|
||||
{
|
||||
FCogDebugLog::OnServerVerbosityChanged(Category.LogCategoryName, (ELogVerbosity::Type)Category.Verbosity);
|
||||
FCogDebugLog::OnServerVerbosityChanged(Category.LogCategoryName, static_cast<ELogVerbosity::Type>(Category.Verbosity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +163,7 @@ void ACogDebugReplicator::Client_SendCategoriesVerbosity_Implementation(const TA
|
||||
{
|
||||
for (const FCogServerCategoryData& Category : Categories)
|
||||
{
|
||||
FCogDebugLog::OnServerVerbosityChanged(Category.LogCategoryName, (ELogVerbosity::Type)Category.Verbosity);
|
||||
FCogDebugLog::OnServerVerbosityChanged(Category.LogCategoryName, static_cast<ELogVerbosity::Type>(Category.Verbosity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ void ACogDebugReplicator::Server_RequestAllCategoriesVerbosity_Implementation()
|
||||
CategoriesData.Add(
|
||||
{
|
||||
CategoryInfo.LogCategory->GetCategoryName(),
|
||||
(ECogLogVerbosity)CategoryInfo.LogCategory->GetVerbosity()
|
||||
static_cast<ECogLogVerbosity>(CategoryInfo.LogCategory->GetVerbosity())
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -218,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,14 +247,14 @@ public:
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogReplicatorNetPack
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
|
||||
bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParams)
|
||||
{
|
||||
if (DeltaParms.bUpdateUnmappedObjects || Owner == nullptr)
|
||||
if (DeltaParams.bUpdateUnmappedObjects || Owner == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DeltaParms.Writer)
|
||||
if (DeltaParams.Writer)
|
||||
{
|
||||
const bool bIsOwnerClient = !Owner->bHasAuthority;
|
||||
if (bIsOwnerClient)
|
||||
@@ -263,10 +262,10 @@ bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms
|
||||
return false;
|
||||
}
|
||||
|
||||
const FCogReplicatorNetState* OldState = static_cast<FCogReplicatorNetState*>(DeltaParms.OldState);
|
||||
const FCogReplicatorNetState* OldState = static_cast<FCogReplicatorNetState*>(DeltaParams.OldState);
|
||||
FCogReplicatorNetState* NewState = new FCogReplicatorNetState();
|
||||
check(DeltaParms.NewState);
|
||||
*DeltaParms.NewState = TSharedPtr<INetDeltaBaseState>(NewState);
|
||||
check(DeltaParams.NewState);
|
||||
*DeltaParams.NewState = TSharedPtr<INetDeltaBaseState>(NewState);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Find delta to replicate
|
||||
@@ -289,7 +288,7 @@ bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms
|
||||
const bool bMissingOldState = (OldState == nullptr);
|
||||
const uint8 ShouldUpdateShapes = bMissingOldState || (OldState->ShapesRepCounter != NewState->ShapesRepCounter);
|
||||
|
||||
FBitWriter& Writer = *DeltaParms.Writer;
|
||||
FBitWriter& Writer = *DeltaParams.Writer;
|
||||
Writer.WriteBit(ShouldUpdateShapes);
|
||||
if (ShouldUpdateShapes)
|
||||
{
|
||||
@@ -297,12 +296,12 @@ bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (DeltaParms.Reader)
|
||||
else if (DeltaParams.Reader)
|
||||
{
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Read
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
FBitReader& Reader = *DeltaParms.Reader;
|
||||
FBitReader& Reader = *DeltaParams.Reader;
|
||||
const uint8 ShouldUpdateShapes = Reader.ReadBit();
|
||||
if (ShouldUpdateShapes)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
#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.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,387 +14,30 @@ 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(UWorld* World, bool Value);
|
||||
static void SetIsFilteringBySelection(const UWorld* World, bool Value);
|
||||
|
||||
static FCogDebugTracker& GetTracker();
|
||||
|
||||
static bool GetDebugPersistent(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;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ struct COGDEBUG_API FCogDebugDraw
|
||||
|
||||
static void Sweep(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Start, const FVector& End, const FQuat& Rotation, const bool HasHits, TArray<FHitResult>& HitResults, const FCogDebugDrawSweepParams& Settings);
|
||||
|
||||
static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
|
||||
static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
|
||||
|
||||
static void ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// ReSharper disable CppUEBlueprintCallableFunctionUnused
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "CogDebugDrawBlueprint.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -64,13 +64,13 @@ public:
|
||||
|
||||
static void DrawPrimitiveComponent(const UPrimitiveComponent& PrimitiveComponent, const int32 BodyIndex, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness, const bool DrawName = true, const bool DrawNameShadow = true, const float DrawNameSize = 1.0f);
|
||||
|
||||
static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
|
||||
static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, const TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
|
||||
|
||||
static void DrawHitResult(const UWorld* World, const FHitResult& HitResult, const FCogDebugDrawLineTraceParams& Settings);
|
||||
|
||||
static void DrawHitResults(const UWorld* World, const TArray<FHitResult>& HitResults, const FCogDebugDrawLineTraceParams& Settings);
|
||||
|
||||
static void DrawLineTrace(const UWorld* World, const FVector& Start, const FVector& End, const bool HasHits, TArray<FHitResult>& HitResults, const FCogDebugDrawLineTraceParams& Settings);
|
||||
static void DrawLineTrace(const UWorld* World, const FVector& Start, const FVector& End, const bool HasHits, const TArray<FHitResult>& HitResults, const FCogDebugDrawLineTraceParams& Settings);
|
||||
|
||||
static void DrawSweep(const UWorld* World, const FCollisionShape& Shape, const FVector& Start, const FVector& End, const FQuat& Rotation, const bool HasHits, TArray<FHitResult>& HitResults, const FCogDebugDrawSweepParams& Settings);
|
||||
};
|
||||
|
||||
@@ -77,6 +77,7 @@ private:
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
static float Time;
|
||||
static TArray<FLine> Lines;
|
||||
static TArray<FTriangle> Triangles;
|
||||
static TArray<FTriangle> TrianglesFilled;
|
||||
@@ -92,9 +93,6 @@ private:
|
||||
template<typename TShape, typename TDrawFunction>
|
||||
static void DrawShapes(TArray<TShape>& Shapes, TDrawFunction DrawFunction)
|
||||
{
|
||||
ImDrawList* ImDrawList = ImGui::GetBackgroundDrawList();
|
||||
const double Time = ImGui::GetCurrentContext()->Time;
|
||||
|
||||
for (int32 i = 0; i < Shapes.Num(); i++)
|
||||
{
|
||||
const TShape& Shape = Shapes[i];
|
||||
|
||||
@@ -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 UWorld& World) 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;
|
||||
};
|
||||
@@ -46,13 +46,13 @@ struct COGDEBUG_API FCogDebugLog
|
||||
|
||||
static TMap<FName, FCogDebugLogCategoryInfo>& GetLogCategories() { return LogCategories; }
|
||||
|
||||
static void SetServerVerbosityActive(UWorld& World, FName CategoryName, bool Value);
|
||||
static void SetServerVerbosityActive(const UWorld& World, FName CategoryName, bool Value);
|
||||
|
||||
static bool IsServerVerbosityActive(FName CategoryName);
|
||||
|
||||
static ELogVerbosity::Type GetServerVerbosity(FName CategoryName);
|
||||
|
||||
static void SetServerVerbosity(UWorld& World, FName CategoryName, ELogVerbosity::Type Verbosity);
|
||||
static void SetServerVerbosity(const UWorld& World, FName CategoryName, ELogVerbosity::Type Verbosity);
|
||||
|
||||
static void OnServerVerbosityChanged(FName CategoryName, ELogVerbosity::Type Verbosity);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class COGDEBUG_API FCogDebugModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
static inline FCogDebugModule& Get() { return FModuleManager::LoadModuleChecked<FCogDebugModule>("CogDebug"); }
|
||||
static FCogDebugModule& Get() { return FModuleManager::LoadModuleChecked<FCogDebugModule>("CogDebug"); }
|
||||
|
||||
virtual void StartupModule() override;
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommon.h"
|
||||
#include "imgui.h"
|
||||
#include "implot.h"
|
||||
|
||||
#ifdef ENABLE_COG
|
||||
|
||||
struct FCogDebugPlotEntry;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotEventParams
|
||||
{
|
||||
FName Name;
|
||||
FString Value;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotEvent
|
||||
{
|
||||
float GetActualEndTime(const FCogDebugPlotEntry& Plot) const;
|
||||
|
||||
uint64 GetActualEndFrame(const FCogDebugPlotEntry& 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;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugPlotEntry
|
||||
{
|
||||
void AssignGraphAndAxis(int32 AssignedRow, ImAxis CurrentYAxis);
|
||||
|
||||
void AddPoint(float X, float Y);
|
||||
|
||||
bool FindValue(float Time, float& Value) const;
|
||||
|
||||
void ResetGraphAndAxis();
|
||||
|
||||
void Clear();
|
||||
|
||||
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);
|
||||
|
||||
FName Name;
|
||||
|
||||
bool IsEventPlot = false;
|
||||
|
||||
int32 GraphIndex = INDEX_NONE;
|
||||
|
||||
ImAxis YAxis = ImAxis_COUNT;
|
||||
|
||||
float Time = 0;
|
||||
|
||||
uint64 Frame = 0;
|
||||
|
||||
TWeakObjectPtr<const UWorld> World;
|
||||
|
||||
//--------------------------
|
||||
// Values
|
||||
//--------------------------
|
||||
int32 ValueOffset = 0;
|
||||
|
||||
ImVector<ImVec2> Values;
|
||||
|
||||
bool ShowValuesMarkers = false;
|
||||
|
||||
//--------------------------
|
||||
// Events
|
||||
//--------------------------
|
||||
int32 EventOffset = 0;
|
||||
|
||||
TArray<FCogDebugPlotEvent> Events;
|
||||
|
||||
int32 MaxRow = 1;
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class COGDEBUG_API FCogDebugPlot
|
||||
{
|
||||
public:
|
||||
static constexpr int32 AutoRow = -1;
|
||||
|
||||
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 void Reset();
|
||||
|
||||
static void Clear();
|
||||
|
||||
static FCogDebugPlotEntry* FindEntry(const FName Name);
|
||||
|
||||
static FCogDebugPlotEntry* FindEntry(bool IsEvent, const FName Name);
|
||||
|
||||
static TArray<FCogDebugPlotEntry> Plots;
|
||||
|
||||
static TArray<FCogDebugPlotEntry> Events;
|
||||
|
||||
static bool IsVisible;
|
||||
|
||||
static bool Pause;
|
||||
|
||||
private:
|
||||
friend struct FCogDebugPlotEntry;
|
||||
|
||||
static void ResetLastAddedEvent();
|
||||
|
||||
static FCogDebugPlotEntry* RegisterPlot(const UObject* Owner, const FName PlotName, bool IsEventPlot);
|
||||
|
||||
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 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,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "CogDebugPluginSubsystem.generated.h"
|
||||
|
||||
UCLASS(Abstract)
|
||||
class COGDEBUG_API UCogDebugPluginSubsystem : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnPlayerControllerReady(APlayerController* InController) {}
|
||||
};
|
||||
@@ -32,9 +32,9 @@ struct FCogReplicatorNetPack
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
ACogDebugReplicator* Owner = nullptr;
|
||||
TObjectPtr<ACogDebugReplicator> Owner;
|
||||
|
||||
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms);
|
||||
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParams);
|
||||
|
||||
private:
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
static ACogDebugReplicator* GetLocalReplicator(const UWorld& World);
|
||||
|
||||
static void GetRemoteReplicators(UWorld& World, TArray<ACogDebugReplicator*>& Replicators);
|
||||
static void GetRemoteReplicators(const UWorld& World, TArray<ACogDebugReplicator*>& Replicators);
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
protected:
|
||||
friend FCogReplicatorNetPack;
|
||||
|
||||
TObjectPtr<APlayerController> OwnerPlayerController;
|
||||
TWeakObjectPtr<APlayerController> OwnerPlayerController;
|
||||
|
||||
uint32 bHasAuthority : 1;
|
||||
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
#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 GizmoSupportContextMenu = true;
|
||||
|
||||
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 ChannelColorGameTraceChannel1 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel2 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel3 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel4 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel5 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel6 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel7 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel8 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel9 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel10 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel11 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel12 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel13 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel14 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel15 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel16 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel17 = FColor(255, 255, 255, 5);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor ChannelColorGameTraceChannel18 = FColor(255, 255, 255, 5);
|
||||
|
||||
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*",
|
||||
};
|
||||
};
|
||||
@@ -30,7 +30,7 @@ struct COGDEBUG_API FCogDebugShape
|
||||
{
|
||||
ECogDebugShape Type = ECogDebugShape::Invalid;
|
||||
TArray<FVector> ShapeData;
|
||||
FColor Color;
|
||||
FColor Color = FColor::White;
|
||||
bool bPersistent = false;
|
||||
float Thickness = 0.0f;
|
||||
uint8 DepthPriority = 0;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "CogDebugPluginSubsystem.h"
|
||||
#include "CogDebugSubsystem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class COGDEBUG_API UCogDebugSubsystem : public UCogDebugPluginSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnPlayerControllerReady(APlayerController* InController) override
|
||||
{
|
||||
if (InController != nullptr)
|
||||
{
|
||||
ACogDebugReplicator::Spawn(InController);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
|
||||
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;
|
||||
};
|
||||
@@ -18,7 +18,7 @@ private:
|
||||
/** Pin factory for abilities graph; Cached so it can be unregistered */
|
||||
TSharedPtr<FCogGraphPanelPinFactory> GraphPanelPinFactory;
|
||||
|
||||
EAssetTypeCategories::Type AssetCategory;
|
||||
EAssetTypeCategories::Type AssetCategory = EAssetTypeCategories::None;
|
||||
};
|
||||
|
||||
IMPLEMENT_MODULE(FCogDebugEditorModule, CogDebugEditor);
|
||||
|
||||
@@ -64,7 +64,7 @@ void FCogLogCategoryDetails::CustomizeChildren(TSharedRef<IPropertyHandle> Struc
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogLogCategoryDetails::OnLogCategoryChanged(FName SelectedName)
|
||||
void FCogLogCategoryDetails::OnLogCategoryChanged(const FName SelectedName) const
|
||||
{
|
||||
if (NameProperty.IsValid())
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
*/
|
||||
void Construct(const FArguments& InArgs);
|
||||
|
||||
virtual ~SLogCategoryListWidget();
|
||||
virtual ~SLogCategoryListWidget() override;
|
||||
|
||||
private:
|
||||
typedef TTextFilter<const FName&> FLogCategoryTextFilter;
|
||||
@@ -132,10 +132,10 @@ private:
|
||||
void OnFilterTextChanged(const FText& InFilterText);
|
||||
|
||||
/** Creates the row widget when called by Slate when an item appears on the list. */
|
||||
TSharedRef< ITableRow > OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable);
|
||||
TSharedRef< ITableRow > OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable) const;
|
||||
|
||||
/** Called by Slate when an item is selected from the tree/list. */
|
||||
void OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo);
|
||||
void OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo) const;
|
||||
|
||||
/** Updates the list of items in the dropdown menu */
|
||||
TSharedPtr<FLogCategoryViewerNode> UpdatePropertyOptions();
|
||||
@@ -146,7 +146,7 @@ private:
|
||||
/** The search box */
|
||||
TSharedPtr<SSearchBox> SearchBoxPtr;
|
||||
|
||||
/** Holds the Slate List widget which holds the LogCategorys for the LogCategory Viewer. */
|
||||
/** Holds the Slate List widget which holds the LogCategory for the LogCategory Viewer. */
|
||||
TSharedPtr<SListView<TSharedPtr< FLogCategoryViewerNode > >> LogCategoryList;
|
||||
|
||||
/** Array of items that can be selected in the dropdown menu */
|
||||
@@ -229,7 +229,7 @@ void SLogCategoryListWidget::Construct(const FArguments& InArgs)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedRef<ITableRow> SLogCategoryListWidget::OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable)
|
||||
TSharedRef<ITableRow> SLogCategoryListWidget::OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable) const
|
||||
{
|
||||
TSharedRef< SLogCategoryItem > ReturnRow = SNew(SLogCategoryItem, OwnerTable)
|
||||
.HighlightText(SearchBoxPtr->GetText())
|
||||
@@ -273,7 +273,7 @@ void SLogCategoryListWidget::OnFilterTextChanged(const FText& InFilterText)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SLogCategoryListWidget::OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo)
|
||||
void SLogCategoryListWidget::OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo) const
|
||||
{
|
||||
OnLogCategoryPicked.ExecuteIfBound(Item->Name);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleInterface.h"
|
||||
@@ -9,7 +8,7 @@ class ICogDebugEditorModule : public IModuleInterface
|
||||
|
||||
public:
|
||||
|
||||
static inline ICogDebugEditorModule& Get() { return FModuleManager::LoadModuleChecked<ICogDebugEditorModule>("CogDebugEditor"); }
|
||||
static ICogDebugEditorModule& Get() { return FModuleManager::LoadModuleChecked<ICogDebugEditorModule>("CogDebugEditor"); }
|
||||
|
||||
static inline bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("CogDebugEditor"); }
|
||||
static bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("CogDebugEditor"); }
|
||||
};
|
||||
|
||||
@@ -17,6 +17,6 @@ class FCogGraphPanelPinFactory : public FGraphPanelPinFactory
|
||||
{
|
||||
return SNew(SCogLogCategoryGraphPin, InPin);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,5 +20,5 @@ private:
|
||||
TSharedPtr<IPropertyHandle> NameProperty;
|
||||
TArray<TSharedPtr<FString>> PropertyOptions;
|
||||
|
||||
void OnLogCategoryChanged(FName SelectedName);
|
||||
void OnLogCategoryChanged(FName SelectedName) const;
|
||||
};
|
||||
|
||||
@@ -15,16 +15,18 @@ public class CogEngine : ModuleRules
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new []
|
||||
{
|
||||
"ApplicationCore",
|
||||
"CogCommon",
|
||||
"CogImgui",
|
||||
"CogWindow",
|
||||
"Cog",
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
"NetCore",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"SlateCore",
|
||||
"BuildSettings",
|
||||
});
|
||||
|
||||
if (Target.bBuildEditor)
|
||||
|
||||
@@ -14,10 +14,10 @@ ACogEngineCollisionTester::ACogEngineCollisionTester(const FObjectInitializer& O
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
|
||||
StartComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Start"));
|
||||
StartComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Start"));
|
||||
RootComponent = StartComponent;
|
||||
|
||||
EndComponent = CreateDefaultSubobject<USceneComponent>(TEXT("End"));
|
||||
EndComponent = CreateDefaultSubobject<USceneComponent>(TEXT("End"));
|
||||
EndComponent->SetupAttachment(RootComponent);
|
||||
EndComponent->SetRelativeLocation(FVector(1000, 0, 0));
|
||||
}
|
||||
@@ -29,7 +29,7 @@ bool ACogEngineCollisionTester::ShouldTickIfViewportsOnly() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,13 @@ void ACogEngineCollisionTester::Tick(float DeltaSeconds)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogEngineCollisionTester::Query() const
|
||||
{
|
||||
const UWorld* World = GetWorld();
|
||||
|
||||
FVector QueryStart = StartComponent->GetComponentLocation();
|
||||
FVector QueryEnd = EndComponent->GetComponentLocation();
|
||||
FQuat QueryRotation = StartComponent->GetComponentQuat();
|
||||
bool HasHits = false;
|
||||
|
||||
|
||||
static const FName TraceTag(TEXT("FCogWindow_Collision"));
|
||||
const FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), TraceComplex);
|
||||
|
||||
@@ -58,243 +60,284 @@ void ACogEngineCollisionTester::Query() const
|
||||
{
|
||||
switch (Shape)
|
||||
{
|
||||
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(ShapeExtent.X); break;
|
||||
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(ShapeExtent.X, ShapeExtent.Z); break;
|
||||
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(FVector3f(ShapeExtent)); break;
|
||||
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(ShapeExtent.X);
|
||||
break;
|
||||
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(ShapeExtent.X, ShapeExtent.Z);
|
||||
break;
|
||||
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(FVector3f(ShapeExtent));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case ECogEngine_CollisionQueryType::Overlap:
|
||||
{
|
||||
TArray<FOverlapResult> Overlaps;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
HasHits = GetWorld()->OverlapMultiByChannel(Overlaps, QueryStart, QueryRotation, Channel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryType::Overlap:
|
||||
{
|
||||
TArray<FOverlapResult> Overlaps;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
switch (OverlapMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryOverlapMode::AnyTest:
|
||||
HasHits = World->OverlapAnyTestByChannel(QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
break;
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
HasHits = GetWorld()->OverlapMultiByObjectType(Overlaps, QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryOverlapMode::BlockingTest:
|
||||
HasHits = World->OverlapBlockingTestByChannel(QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
break;
|
||||
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
HasHits = GetWorld()->OverlapMultiByProfile(Overlaps, QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ECogEngine_CollisionQueryOverlapMode::Multi:
|
||||
HasHits = World->OverlapMultiByChannel(Overlaps, QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FCogDebugDrawOverlapParams DrawParams;
|
||||
FCogDebug::GetDebugDrawOverlapSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawOverlap(GetWorld(), QueryShape, QueryStart, QueryRotation, Overlaps, DrawParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
|
||||
case ECogEngine_CollisionQueryType::LineTrace:
|
||||
{
|
||||
TArray<FHitResult> Hits;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->LineTraceSingleByChannel(Hit, QueryStart, QueryEnd, Channel, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceMultiByChannel(Hits, QueryStart, QueryEnd, Channel, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceTestByChannel(QueryStart, QueryEnd, Channel, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (OverlapMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryOverlapMode::AnyTest:
|
||||
HasHits = World->OverlapAnyTestByObjectType(QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryOverlapMode::BlockingTest:
|
||||
break;
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
case ECogEngine_CollisionQueryOverlapMode::Multi:
|
||||
HasHits = World->OverlapMultiByObjectType(Overlaps, QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->LineTraceSingleByObjectType(Hit, QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceMultiByObjectType(Hits, QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceTestByObjectType(QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
switch (OverlapMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryOverlapMode::AnyTest:
|
||||
HasHits = World->OverlapAnyTestByProfile(QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->LineTraceSingleByProfile(Hit, QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceMultiByProfile(Hits, QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->LineTraceTestByProfile(QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ECogEngine_CollisionQueryOverlapMode::BlockingTest:
|
||||
HasHits = World->OverlapBlockingTestByProfile(QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
|
||||
FCogDebugDrawLineTraceParams DrawParams;
|
||||
FCogDebug::GetDebugDrawLineTraceSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawLineTrace(GetWorld(), QueryStart, QueryEnd, HasHits, Hits, DrawParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryOverlapMode::Multi:
|
||||
HasHits = World->OverlapMultiByProfile(Overlaps, QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryType::Sweep:
|
||||
{
|
||||
TArray<FHitResult> Hits;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->SweepSingleByChannel(Hit, QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->SweepMultiByChannel(Hits, QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->SweepTestByChannel(QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
FCogDebugDrawOverlapParams DrawParams;
|
||||
FCogDebug::GetDebugDrawOverlapSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawOverlap(World, QueryShape, QueryStart, QueryRotation, HasHits, Overlaps, DrawParams);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
case ECogEngine_CollisionQueryType::LineTrace:
|
||||
{
|
||||
TArray<FHitResult> Hits;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->LineTraceSingleByChannel(Hit, QueryStart, QueryEnd, TraceChannel, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->LineTraceMultiByChannel(Hits, QueryStart, QueryEnd, TraceChannel, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->LineTraceTestByChannel(QueryStart, QueryEnd, TraceChannel, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->SweepSingleByObjectType(Hit, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->SweepMultiByObjectType(Hits, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->SweepTestByObjectType(QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = GetWorld()->SweepSingleByProfile(Hit, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Multi:
|
||||
{
|
||||
HasHits = GetWorld()->SweepMultiByProfile(Hits, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryMode::Test:
|
||||
{
|
||||
HasHits = GetWorld()->SweepTestByProfile(QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->LineTraceSingleByObjectType(Hit, QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->LineTraceMultiByObjectType(Hits, QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->LineTraceTestByObjectType(QueryStart, QueryEnd, QueryObjectParams, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FCogDebugDrawSweepParams DrawParams;
|
||||
FCogDebug::GetDebugDrawSweepSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawSweep(GetWorld(), QueryShape, QueryStart, QueryEnd, QueryRotation, HasHits, Hits, DrawParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->LineTraceSingleByProfile(Hit, QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->LineTraceMultiByProfile(Hits, QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->LineTraceTestByProfile(QueryStart, QueryEnd, ProfileName, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugDrawLineTraceParams DrawParams;
|
||||
FCogDebug::GetDebugDrawLineTraceSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawLineTrace(World, QueryStart, QueryEnd, HasHits, Hits, DrawParams);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryType::Sweep:
|
||||
{
|
||||
TArray<FHitResult> Hits;
|
||||
switch (By)
|
||||
{
|
||||
case ECogEngine_CollisionQueryBy::Channel:
|
||||
{
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->SweepSingleByChannel(Hit, QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->SweepMultiByChannel(Hits, QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->SweepTestByChannel(QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->SweepSingleByObjectType(Hit, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->SweepMultiByObjectType(Hits, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->SweepTestByObjectType(QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
switch (TraceMode)
|
||||
{
|
||||
case ECogEngine_CollisionQueryTraceMode::Single:
|
||||
{
|
||||
FHitResult Hit;
|
||||
HasHits = World->SweepSingleByProfile(Hit, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
if (HasHits)
|
||||
{
|
||||
Hits.Add(Hit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Multi:
|
||||
{
|
||||
HasHits = World->SweepMultiByProfile(Hits, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
case ECogEngine_CollisionQueryTraceMode::Test:
|
||||
{
|
||||
HasHits = World->SweepTestByProfile(QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugDrawSweepParams DrawParams;
|
||||
FCogDebug::GetDebugDrawSweepSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawSweep(World, QueryShape, QueryStart, QueryEnd, QueryRotation, HasHits, Hits, DrawParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "CogEngineDataAsset.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineCheat_Execution::Execute_Implementation(const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
void UCogEngineCheat_Execution::Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogEngineCheat_ActiveState UCogEngineCheat_Execution::IsActiveOnTargets_Implementation(const TArray<AActor*>& Targets) const
|
||||
ECogEngineCheat_ActiveState UCogEngineCheat_Execution::IsActiveOnTargets_Implementation(const UObject* WorldContextObject, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "CogEngineHelper.h"
|
||||
|
||||
#include "CogEngineReplicator.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "imgui.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
@@ -15,10 +14,10 @@
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineHelper::ActorContextMenu(AActor& Actor)
|
||||
{
|
||||
FCogWindowWidgets::ThinSeparatorText("Object");
|
||||
FCogWidgets::ThinSeparatorText("Object");
|
||||
|
||||
#if WITH_EDITOR
|
||||
FCogWindowWidgets::OpenObjectAssetButton(&Actor, ImVec2(-1, 0));
|
||||
FCogWidgets::OpenObjectAssetButton(&Actor, ImVec2(-1, 0));
|
||||
#endif
|
||||
|
||||
if (ImGui::Button("Delete", ImVec2(-1, 0)))
|
||||
@@ -31,7 +30,7 @@ void FCogEngineHelper::ActorContextMenu(AActor& Actor)
|
||||
|
||||
if (APawn* Pawn = Cast<APawn>(&Actor))
|
||||
{
|
||||
FCogWindowWidgets::ThinSeparatorText("Pawn");
|
||||
FCogWidgets::ThinSeparatorText("Pawn");
|
||||
|
||||
if (ImGui::Button("Possess", ImVec2(-1, 0)))
|
||||
{
|
||||
@@ -55,4 +54,17 @@ void FCogEngineHelper::ActorContextMenu(AActor& Actor)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineHelper::RenderConfigureMessage(const TWeakObjectPtr<const UCogEngineDataAsset> InAsset)
|
||||
{
|
||||
if (InAsset == nullptr)
|
||||
{
|
||||
ImGui::Text("Create a DataAsset child of '%s' to configure. ", StringCast<ANSICHAR>(*UCogEngineDataAsset::StaticClass()->GetName()).Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Can be configured in the '%s' DataAsset. ", StringCast<ANSICHAR>(*GetNameSafe(InAsset.Get())).Get());
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "CogCommon.h"
|
||||
#include "CogCommonPossessorInterface.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogSubsystem.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "Engine/World.h"
|
||||
#include "EngineUtils.h"
|
||||
@@ -32,12 +33,13 @@ ACogEngineReplicator* ACogEngineReplicator::Spawn(APlayerController* Controller)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ACogEngineReplicator* ACogEngineReplicator::GetLocalReplicator(const UWorld& World)
|
||||
{
|
||||
for (TActorIterator<ACogEngineReplicator> It(&World, StaticClass()); It; ++It)
|
||||
const TActorIterator<ACogEngineReplicator> It(&World, StaticClass());
|
||||
if (It)
|
||||
{
|
||||
ACogEngineReplicator* Replicator = *It;
|
||||
return Replicator;
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -226,20 +228,24 @@ void ACogEngineReplicator::Server_DeleteActor_Implementation(AActor* Actor)
|
||||
void ACogEngineReplicator::Server_ApplyCheat_Implementation(const AActor* CheatInstigator, const TArray<AActor*>& Targets, const FCogEngineCheat& Cheat) const
|
||||
{
|
||||
if (Cheat.Execution == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{ return; }
|
||||
|
||||
Cheat.Execution->Execute(CheatInstigator, Targets);
|
||||
if (GetWorld() == nullptr)
|
||||
{ return; }
|
||||
|
||||
Cheat.Execution->Execute(GetWorld(), CheatInstigator, Targets);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogEngineCheat_ActiveState ACogEngineReplicator::IsCheatActiveOnTargets(const TArray<AActor*>& Targets, const FCogEngineCheat& Cheat)
|
||||
ECogEngineCheat_ActiveState ACogEngineReplicator::IsCheatActiveOnTargets(const TArray<AActor*>& Targets, const FCogEngineCheat& Cheat) const
|
||||
{
|
||||
if (GetWorld() == nullptr)
|
||||
{ return ECogEngineCheat_ActiveState::Inactive; }
|
||||
|
||||
if (Cheat.Execution == nullptr)
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
return Cheat.Execution->IsActiveOnTargets(Targets);
|
||||
return Cheat.Execution->IsActiveOnTargets(GetWorld(), Targets);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Audio::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window displays audio settings. "
|
||||
);
|
||||
ImGui::Text("This window displays audio settings.");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
#include "CogEngineWindow_BuildInfo.h"
|
||||
|
||||
#include "CogImguiHelper.h"
|
||||
#include "imgui.h"
|
||||
#include "BuildSettings.h"
|
||||
#include "GenericPlatform/GenericPlatformMisc.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::Initialize()
|
||||
{
|
||||
FCogWindow::Initialize();
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_BuildInfo>();
|
||||
|
||||
BuildText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to display the build information such as the build version, changelist, date, target, and so on."
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderTick(float DeltaTime)
|
||||
{
|
||||
FCogWindow::RenderTick(DeltaTime);
|
||||
|
||||
if (FApp::GetBuildTargetType() == EBuildTargetType::Editor)
|
||||
{
|
||||
if (Config->ShowInEditor == false)
|
||||
{ return; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config->ShowInPackage == false)
|
||||
{ return;}
|
||||
}
|
||||
|
||||
const auto TextStr = StringCast<ANSICHAR>(*Text);
|
||||
ImDrawList* DrawList = Config->ShowInForeground ? ImGui::GetForegroundDrawList() : ImGui::GetBackgroundDrawList();
|
||||
const ImVec2 WindowPadding = ImGui::GetStyle().WindowPadding;
|
||||
const ImVec2 TextSize = ImGui::CalcTextSize(TextStr.Get(), nullptr, false);
|
||||
const ImVec2 RectSize = TextSize + WindowPadding * 2;
|
||||
const ImVec2 Pos = FCogWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding);
|
||||
const ImVec2 AlignedPos = Pos - (FCogImguiHelper::ToImVec2(Config->Alignment) * RectSize);
|
||||
|
||||
DrawList->AddRectFilled(AlignedPos, AlignedPos + RectSize, FCogImguiHelper::ToImU32(Config->BackgroundColor), Config->Rounding);
|
||||
DrawList->AddRect(AlignedPos, AlignedPos + RectSize, FCogImguiHelper::ToImU32(Config->BorderColor), Config->Rounding);
|
||||
DrawList->AddText(AlignedPos + WindowPadding, FCogImguiHelper::ToImU32(Config->TextColor), TextStr.Get());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
FCogWidgets::ThinSeparatorText("Build Properties");
|
||||
|
||||
if (ImGui::BeginChild("Settings", ImVec2(-1, 100 * GetDpiScale()), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY))
|
||||
{
|
||||
if (ImGui::Checkbox("Branch Name", &Config->ShowBranchName)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Date", &Config->ShowBuildDate)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Configuration", &Config->ShowBuildConfiguration)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build User", &Config->ShowBuildUser)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Machine", &Config->ShowBuildMachine)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Target Type", &Config->ShowBuildTargetType)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Current Change list", &Config->ShowCurrentChangelist)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Compatible Change list", &Config->ShowCompatibleChangelist)) { BuildText(); }
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
FCogWidgets::ThinSeparatorText("Display");
|
||||
|
||||
ImGui::Checkbox("Show In Editor", &Config->ShowInEditor);
|
||||
ImGui::Checkbox("Show In Package", &Config->ShowInPackage);
|
||||
ImGui::Checkbox("Show In Foreground", &Config->ShowInForeground);
|
||||
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderFloat2("Alignment", &Config->Alignment.X, 0, 1.0f, "%.2f");
|
||||
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderInt2("Padding", &Config->Padding.X, 0, 100);
|
||||
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderInt("Rounding", &Config->Rounding, 0, 12);
|
||||
|
||||
if (FCogWidgets::InputText("Separator", Config->Separator))
|
||||
{
|
||||
BuildText();
|
||||
}
|
||||
|
||||
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
FCogImguiHelper::ColorEdit4("Background Color", Config->BackgroundColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Border Color", Config->BorderColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Text Color", Config->TextColor, ColorEditFlags);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Reset Settings", ImVec2(-1, 0)))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::BuildText()
|
||||
{
|
||||
FStringBuilderBase S;
|
||||
bool AddSeparator = false;
|
||||
|
||||
if (Config->ShowBranchName) { S.Append(BuildSettings::GetBranchName()); S.Append(Config->Separator); }
|
||||
if (Config->ShowBuildDate) { S.Append(BuildSettings::GetBuildDate()); S.Append(Config->Separator); }
|
||||
if (Config->ShowBuildConfiguration) { S.Append(LexToString(FApp::GetBuildConfiguration())); S.Append(Config->Separator); }
|
||||
if (Config->ShowBuildTargetType) { S.Append(LexToString(FApp::GetBuildTargetType())); S.Append(Config->Separator); }
|
||||
if (Config->ShowBuildUser) { S.Append(BuildSettings::GetBuildUser()); S.Append(Config->Separator); }
|
||||
if (Config->ShowBuildMachine) { S.Append(BuildSettings::GetBuildMachine()); S.Append(Config->Separator); }
|
||||
if (Config->ShowCurrentChangelist) { S.Appendf(TEXT("%d"), BuildSettings::GetCurrentChangelist()); S.Append(Config->Separator); }
|
||||
if (Config->ShowCompatibleChangelist) { S.Appendf(TEXT("%d"),BuildSettings::GetCompatibleChangelist()); S.Append(Config->Separator); }
|
||||
|
||||
S.RemoveSuffix(Config->Separator.Len());
|
||||
|
||||
Text = FString(S);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user