mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
Merge pull request #21 from arnaud-jamin/new-windows
Add Collision Tester window
This commit is contained in:
+16
-13
@@ -88,35 +88,37 @@ ManualIPAddress=
|
||||
-Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.",bCanModify=False)
|
||||
-Profiles=(Name="UI",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Block),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
|
||||
+Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision")
|
||||
+Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.")
|
||||
+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ")
|
||||
+Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ")
|
||||
+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic"),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.")
|
||||
+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="CharacterMesh",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.")
|
||||
+Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Projectile")),HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="Projectile",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Projectile")),HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="Projectile",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Projectile")),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.")
|
||||
+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Projectile")),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ")
|
||||
+Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ")
|
||||
+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.")
|
||||
+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="CharacterMesh",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.")
|
||||
+Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors")
|
||||
+Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors")
|
||||
+Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.")
|
||||
+Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.")
|
||||
+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.")
|
||||
+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.")
|
||||
+Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.")
|
||||
+Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.")
|
||||
+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="ProjectileCollision",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Projectile",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="CharacterMesh",Response=ECR_Overlap)),HelpMessage="Needs description")
|
||||
+Profiles=(Name="ProjectileAssistance",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Projectile",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="CharacterMesh",Response=ECR_Overlap)),HelpMessage="Needs description")
|
||||
+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")
|
||||
+EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Ignore)))
|
||||
+EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap)))
|
||||
+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)))
|
||||
+EditProfiles=(Name="BlockAll",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Projectile",Response=ECR_Overlap)))
|
||||
+EditProfiles=(Name="BlockAllDynamic",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="OverlapAllDynamic",CustomResponses=((Channel="Projectile",Response=ECR_Overlap)))
|
||||
+EditProfiles=(Name="IgnoreOnlyPawn",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="OverlapOnlyPawn",CustomResponses=((Channel="Projectile")))
|
||||
+EditProfiles=(Name="Spectator",CustomResponses=((Channel="TraceCustom",Response=ECR_Ignore)))
|
||||
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
|
||||
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
|
||||
-ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
|
||||
@@ -135,4 +137,5 @@ ManualIPAddress=
|
||||
+CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
|
||||
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
|
||||
+CollisionChannelRedirects=(OldName="Test",NewName="TraceCustom")
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -9,13 +9,13 @@
|
||||
|
||||
#if ENABLE_COG
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
|
||||
#define IF_COG(expr) { expr; }
|
||||
#define COG_LOG_CATEGORY FLogCategoryBase
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (FCogDebugSettings::IsDebugActiveForObject(Object))
|
||||
#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (FCogDebug::IsDebugActiveForObject(Object))
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#define COG_LOG(LogCategory, Verbosity, Format, ...) \
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
#include "CogDebug.h"
|
||||
|
||||
#include "CogCommonDebugFilteredActorInterface.h"
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Engine/Engine.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TWeakObjectPtr<AActor> FCogDebug::Selection;
|
||||
FCogDebugSettings FCogDebug::Settings = FCogDebugSettings();
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::Reset()
|
||||
{
|
||||
Settings = FCogDebugSettings();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
|
||||
{
|
||||
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (World->GetNetMode() == NM_DedicatedServer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), Settings.bIsFilteringBySelection);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection)
|
||||
{
|
||||
return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection)
|
||||
{
|
||||
if (InIsFilteringBySelection == false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (WorldContextObject == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const AActor* SelectionPtr = InSelection;
|
||||
if (SelectionPtr == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const UObject* Outer = WorldContextObject;
|
||||
for (;;)
|
||||
{
|
||||
if (SelectionPtr == Outer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Cast<ICogCommonDebugFilteredActorInterface>(Outer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const UObject* NewOuter = Outer->GetOuter();
|
||||
if (NewOuter == Outer || NewOuter == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Outer = NewOuter;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogDebug::GetSelection()
|
||||
{
|
||||
return Selection.Get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::SetSelection(UWorld* World, AActor* Value)
|
||||
{
|
||||
Selection = Value;
|
||||
|
||||
if (World != nullptr && World->GetNetMode() == NM_Client)
|
||||
{
|
||||
if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(*World))
|
||||
{
|
||||
Replicator->Server_SetSelection(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::GetIsFilteringBySelection()
|
||||
{
|
||||
return Settings.bIsFilteringBySelection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::SetIsFilteringBySelection(UWorld* World, bool Value)
|
||||
{
|
||||
Settings.bIsFilteringBySelection = Value;
|
||||
|
||||
if (World != nullptr && World->GetNetMode() == NM_Client)
|
||||
{
|
||||
if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(*World))
|
||||
{
|
||||
Replicator->Server_SetIsFilteringBySelection(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::GetDebugPersistent(bool bPersistent)
|
||||
{
|
||||
return Settings.Persistent && bPersistent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebug::GetDebugDuration(bool bPersistent)
|
||||
{
|
||||
return bPersistent == false ? 0.0f : Settings.Duration;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebug::GetDebugTextDuration(bool bPersistent)
|
||||
{
|
||||
if (bPersistent)
|
||||
{
|
||||
return Settings.Persistent ? 100 : Settings.Duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int FCogDebug::GetDebugSegments()
|
||||
{
|
||||
return Settings.Segments;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int FCogDebug::GetCircleSegments()
|
||||
{
|
||||
return (Settings.Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebug::GetDebugThickness(float InThickness)
|
||||
{
|
||||
return (Settings.Thickness + InThickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebug::GetDebugServerThickness(float InThickness)
|
||||
{
|
||||
return (Settings.ServerThickness + InThickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
uint8 FCogDebug::GetDebugDepthPriority(float InDepthPriority)
|
||||
{
|
||||
return (Settings.DepthPriority + InDepthPriority);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent)
|
||||
{
|
||||
if (bPersistent == false)
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
|
||||
const float Time = World->GetTimeSeconds();
|
||||
const FLinearColor BaseColor(Color);
|
||||
FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV();
|
||||
|
||||
ComplementaryColor.R = ComplementaryColor.R - 180.0f;
|
||||
if (ComplementaryColor.R < 0.0f)
|
||||
{
|
||||
ComplementaryColor.R = 360.0f - ComplementaryColor.R;
|
||||
}
|
||||
|
||||
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
|
||||
|
||||
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.GradientColorSpeed * Time));
|
||||
const FLinearColor FBlendColor = BaseColor * (1.0f - Settings.GradientColorIntensity) + GradientColor * Settings.GradientColorIntensity;
|
||||
return FBlendColor.ToFColor(true);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FColor FCogDebug::ModulateServerColor(const FColor& Color)
|
||||
{
|
||||
FColor ServerColor(
|
||||
Color.R * Settings.ServerColorMultiplier,
|
||||
Color.G * Settings.ServerColorMultiplier,
|
||||
Color.B * Settings.ServerColorMultiplier,
|
||||
Color.A);
|
||||
|
||||
return ServerColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug::IsSecondarySkeletonBone(FName BoneName)
|
||||
{
|
||||
FString BoneString = BoneName.ToString().ToLower();
|
||||
|
||||
for (const FString& Wildcard : Settings.SecondaryBoneWildcards)
|
||||
{
|
||||
if (BoneString.MatchesWildcard(Wildcard))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::GetDebugChannelColors(FColor ChannelColors[ECC_MAX])
|
||||
{
|
||||
ChannelColors[ECC_WorldStatic] = Settings.ChannelColorWorldStatic;
|
||||
ChannelColors[ECC_WorldDynamic] = Settings.ChannelColorWorldDynamic;
|
||||
ChannelColors[ECC_Pawn] = Settings.ChannelColorPawn;
|
||||
ChannelColors[ECC_Visibility] = Settings.ChannelColorVisibility;
|
||||
ChannelColors[ECC_Camera] = Settings.ChannelColorCamera;
|
||||
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;
|
||||
ChannelColors[ECC_GameTraceChannel4] = Settings.ChannelColorGameTraceChannel4;
|
||||
ChannelColors[ECC_GameTraceChannel5] = Settings.ChannelColorGameTraceChannel5;
|
||||
ChannelColors[ECC_GameTraceChannel6] = Settings.ChannelColorGameTraceChannel6;
|
||||
ChannelColors[ECC_GameTraceChannel7] = Settings.ChannelColorGameTraceChannel7;
|
||||
ChannelColors[ECC_GameTraceChannel8] = Settings.ChannelColorGameTraceChannel8;
|
||||
ChannelColors[ECC_GameTraceChannel9] = Settings.ChannelColorGameTraceChannel9;
|
||||
ChannelColors[ECC_GameTraceChannel10] = Settings.ChannelColorGameTraceChannel10;
|
||||
ChannelColors[ECC_GameTraceChannel11] = Settings.ChannelColorGameTraceChannel11;
|
||||
ChannelColors[ECC_GameTraceChannel12] = Settings.ChannelColorGameTraceChannel12;
|
||||
ChannelColors[ECC_GameTraceChannel13] = Settings.ChannelColorGameTraceChannel13;
|
||||
ChannelColors[ECC_GameTraceChannel14] = Settings.ChannelColorGameTraceChannel14;
|
||||
ChannelColors[ECC_GameTraceChannel15] = Settings.ChannelColorGameTraceChannel15;
|
||||
ChannelColors[ECC_GameTraceChannel16] = Settings.ChannelColorGameTraceChannel16;
|
||||
ChannelColors[ECC_GameTraceChannel17] = Settings.ChannelColorGameTraceChannel17;
|
||||
ChannelColors[ECC_GameTraceChannel18] = Settings.ChannelColorGameTraceChannel18;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::GetDebugDrawOverlapSettings(FCogDebugDrawOverlapParams& Params)
|
||||
{
|
||||
Params.HitColor = Settings.CollisionQueryHitColor;
|
||||
Params.NoHitColor = Settings.CollisionQueryNoHitColor;
|
||||
Params.DrawHitPrimitives = Settings.CollisionQueryDrawHitPrimitives;
|
||||
Params.DrawHitPrimitiveActorsName = Settings.CollisionQueryDrawHitPrimitiveActorsName;
|
||||
Params.HitPrimitiveActorsNameShadow = Settings.CollisionQueryHitPrimitiveActorsNameShadow;
|
||||
Params.HitPrimitiveActorsNameSize = Settings.CollisionQueryHitPrimitiveActorsNameSize;
|
||||
Params.Persistent = false;
|
||||
Params.LifeTime = 0.0f;
|
||||
Params.DepthPriority = Settings.DepthPriority;
|
||||
Params.Thickness = Settings.Thickness;
|
||||
|
||||
GetDebugChannelColors(Params.ChannelColors);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::GetDebugDrawLineTraceSettings(FCogDebugDrawLineTraceParams& Params)
|
||||
{
|
||||
GetDebugDrawOverlapSettings(Params);
|
||||
|
||||
Params.DrawHitLocation = Settings.CollisionQueryDrawHitLocation;
|
||||
Params.DrawHitImpactPoints = Settings.CollisionQueryDrawHitImpactPoints;
|
||||
Params.DrawHitNormals = Settings.CollisionQueryDrawHitNormals;
|
||||
Params.DrawHitImpactNormals = Settings.CollisionQueryDrawHitImpactNormals;
|
||||
Params.HitPointSize = Settings.CollisionQueryHitPointSize;
|
||||
Params.NormalColor = Settings.CollisionQueryNormalColor;
|
||||
Params.ImpactNormalColor = Settings.CollisionQueryImpactNormalColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebug::GetDebugDrawSweepSettings(FCogDebugDrawSweepParams& Params)
|
||||
{
|
||||
GetDebugDrawLineTraceSettings(Params);
|
||||
|
||||
Params.DrawHitShapes = Settings.CollisionQueryDrawHitShapes;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "CogDebugDrawImGui.h"
|
||||
#include "CogDebugLog.h"
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugShape.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Engine/Engine.h"
|
||||
@@ -30,8 +30,8 @@ void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject*
|
||||
Text,
|
||||
FCogImguiHelper::ToImU32(Color),
|
||||
true,
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::Fade2D);
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::Settings.Fade2D);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -46,9 +46,9 @@ void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject
|
||||
FCogImguiHelper::ToImVec2(SegmentStart),
|
||||
FCogImguiHelper::ToImVec2(SegmentEnd),
|
||||
FCogImguiHelper::ToImU32(Color),
|
||||
FCogDebugSettings::GetDebugThickness(0),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::Fade2D);
|
||||
FCogDebug::GetDebugThickness(0),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::Settings.Fade2D);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -63,10 +63,10 @@ void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject*
|
||||
FCogImguiHelper::ToImVec2(Location),
|
||||
Radius,
|
||||
FCogImguiHelper::ToImU32(Color),
|
||||
FCogDebugSettings::GetDebugSegments(),
|
||||
FCogDebugSettings::GetDebugThickness(0),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::Fade2D);
|
||||
FCogDebug::GetDebugSegments(),
|
||||
FCogDebug::GetDebugThickness(0),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::Settings.Fade2D);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -83,9 +83,9 @@ void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
FCogImguiHelper::ToImVec2(Max),
|
||||
FCogImguiHelper::ToImU32(Color),
|
||||
0.0f,
|
||||
FCogDebugSettings::GetDebugThickness(0),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::Fade2D);
|
||||
FCogDebug::GetDebugThickness(0),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::Settings.Fade2D);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -102,7 +102,7 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_LOCATION(WorldContextObject, LogCategory, Verbose, Location, 10.0f, NewColor, TEXT("%s"), *Text);
|
||||
|
||||
::DrawDebugString(
|
||||
@@ -111,9 +111,9 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
*Text,
|
||||
nullptr,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugTextDuration(Persistent),
|
||||
FCogDebugSettings::TextShadow,
|
||||
FCogDebugSettings::TextSize);
|
||||
FCogDebug::GetDebugTextDuration(Persistent),
|
||||
FCogDebug::Settings.TextShadow,
|
||||
FCogDebug::Settings.TextSize);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -130,17 +130,17 @@ void FCogDebugDraw::Point(const FLogCategoryBase& LogCategory, const UObject* Wo
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
::DrawDebugPoint(
|
||||
World,
|
||||
Location,
|
||||
Size,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebugSettings::DepthPriority));
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebug::Settings.DepthPriority));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -157,7 +157,7 @@ void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject*
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
|
||||
|
||||
::DrawDebugLine(
|
||||
@@ -165,10 +165,10 @@ void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject*
|
||||
SegmentStart,
|
||||
SegmentEnd,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSegment(SegmentStart, SegmentEnd, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* Wor
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, BoneLocation, ParentLocation, NewColor, TEXT_EMPTY);
|
||||
|
||||
::DrawDebugLine(
|
||||
@@ -195,19 +195,19 @@ void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* Wor
|
||||
BoneLocation,
|
||||
ParentLocation,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
::DrawDebugPoint(
|
||||
World,
|
||||
BoneLocation,
|
||||
FCogDebugSettings::GetDebugThickness(4.0f),
|
||||
FCogDebug::GetDebugThickness(4.0f),
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBone(BoneLocation, ParentLocation, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -226,21 +226,21 @@ void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* Wo
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
|
||||
|
||||
::DrawDebugDirectionalArrow(
|
||||
World,
|
||||
SegmentStart,
|
||||
SegmentEnd,
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebugSettings::ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebug::Settings.ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -266,13 +266,13 @@ void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* Wor
|
||||
World,
|
||||
AxisLoc,
|
||||
AxisRot,
|
||||
Scale * FCogDebugSettings::AxesScale,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
Scale * FCogDebug::Settings.AxesScale,
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebugSettings::ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebug::Settings.ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -289,7 +289,7 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
const FVector Center = Matrix.GetOrigin();
|
||||
const FVector UpVector = Matrix.GetUnitAxis(EAxis::X);
|
||||
UE_VLOG_CIRCLE(WorldContextObject, LogCategory, Verbose, Center, UpVector, Radius, NewColor, TEXT_EMPTY);
|
||||
@@ -298,12 +298,12 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
World,
|
||||
Matrix,
|
||||
Radius,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebug::GetCircleSegments(),
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0),
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0),
|
||||
false);
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircle(Center, Matrix.Rotator(), Radius, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
@@ -323,7 +323,7 @@ void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
|
||||
//TODO : Add VLOG
|
||||
|
||||
@@ -333,12 +333,12 @@ void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject
|
||||
InnerRadius,
|
||||
OuterRadius,
|
||||
Angle,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebug::GetCircleSegments(),
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircleArc(Matrix.GetOrigin(), Matrix.Rotator(), InnerRadius, OuterRadius, Angle, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -357,7 +357,7 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
// TODO : Add VLOG
|
||||
|
||||
FCogDebugDrawHelper::DrawFlatCapsule(
|
||||
@@ -366,12 +366,12 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje
|
||||
End,
|
||||
Radius,
|
||||
Z,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebug::GetCircleSegments(),
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeFlatCapsule(Start, End, Radius, Z, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -390,19 +390,19 @@ void FCogDebugDraw::Sphere(const FLogCategoryBase& LogCategory, const UObject* W
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Location, 0.0f, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
|
||||
|
||||
FCogDebugDrawHelper::DrawSphere(
|
||||
World,
|
||||
Location,
|
||||
Radius,
|
||||
FCogDebugSettings::GetDebugSegments(),
|
||||
FCogDebug::GetDebugSegments(),
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Location, FQuat::Identity, Radius, 0.0f, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -421,7 +421,7 @@ void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* Worl
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_OBOX(WorldContextObject, LogCategory, Verbose, FBox(-Extent, Extent), FQuatRotationTranslationMatrix::Make(Rotation, Center), NewColor, TEXT_EMPTY);
|
||||
|
||||
::DrawDebugBox(
|
||||
@@ -430,10 +430,10 @@ void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* Worl
|
||||
Extent,
|
||||
Rotation,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBox(Center, FRotator(Rotation), Extent, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -452,7 +452,7 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject*
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_OBOX(WorldContextObject, LogCategory, Verbose, FBox(-Extent, Extent), FQuatRotationTranslationMatrix::Make(Rotation, Center), NewColor, TEXT_EMPTY);
|
||||
|
||||
// If we make the Box Thick enough, it will be displayed as a filled box.
|
||||
@@ -465,9 +465,9 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject*
|
||||
Extent,
|
||||
Rotation,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
NeededThickness);
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSolidBox(Center, FRotator(Rotation), Extent, NewColor, Persistent, DepthPriority));
|
||||
@@ -487,7 +487,7 @@ void FCogDebugDraw::Frustum(const FLogCategoryBase& LogCategory, const UObject*
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
|
||||
FCogDebugDrawHelper::DrawFrustum(
|
||||
World,
|
||||
@@ -497,10 +497,10 @@ void FCogDebugDraw::Frustum(const FLogCategoryBase& LogCategory, const UObject*
|
||||
NearPlane,
|
||||
FarPlane,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
// TODO: Replicate Shape
|
||||
}
|
||||
@@ -519,7 +519,7 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject*
|
||||
return;
|
||||
}
|
||||
|
||||
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent);
|
||||
const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
|
||||
UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Center, HalfHeight, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
|
||||
|
||||
DrawDebugCapsule(
|
||||
@@ -529,10 +529,10 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject*
|
||||
Radius,
|
||||
Rotation,
|
||||
NewColor,
|
||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugThickness(0));
|
||||
FCogDebug::GetDebugPersistent(Persistent),
|
||||
FCogDebug::GetDebugDuration(Persistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugThickness(0));
|
||||
|
||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Center, Rotation, Radius, HalfHeight, NewColor, 0.0f, Persistent, DepthPriority));
|
||||
}
|
||||
@@ -612,8 +612,8 @@ void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeleta
|
||||
{
|
||||
if (DrawSecondaryBones == false)
|
||||
{
|
||||
const FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex);
|
||||
if (FCogDebugSettings::IsSecondarySkeletonBone(BoneName))
|
||||
const FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex);
|
||||
if (FCogDebug::IsSecondarySkeletonBone(BoneName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -664,7 +664,7 @@ void FCogDebugDraw::ReplicateShape(const UObject* WorldContextObject, const FCog
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FCogDebugSettings::IsReplicatedDebugActiveForObject(WorldContextObject, Replicator->GetServerSelection(), Replicator->IsServerFilteringBySelection()) == false)
|
||||
if (FCogDebug::IsReplicatedDebugActiveForObject(WorldContextObject, Replicator->GetServerSelection(), Replicator->IsServerFilteringBySelection()) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "CogDebugDrawHelper.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "Components/LineBatchComponent.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -26,7 +28,8 @@ void FCogDebugDrawHelper::DrawArc(
|
||||
const FMatrix& Matrix,
|
||||
float InnerRadius,
|
||||
float OuterRadius,
|
||||
float Angle,
|
||||
float AngleStart,
|
||||
float AngleEnd,
|
||||
int32 Segments,
|
||||
const FColor& Color,
|
||||
bool bPersistentLines,
|
||||
@@ -46,54 +49,52 @@ void FCogDebugDrawHelper::DrawArc(
|
||||
}
|
||||
|
||||
const float LineLifeTime = GetLineLifeTime(LineBatcher, LifeTime, bPersistentLines);
|
||||
|
||||
const float AngleRad = FMath::DegreesToRadians(Angle);
|
||||
const float AngleStartRad = FMath::DegreesToRadians(AngleStart);
|
||||
const float AngleEndRad = FMath::DegreesToRadians(AngleEnd);
|
||||
const FVector Center = Matrix.GetOrigin();
|
||||
const FVector Direction = Matrix.GetUnitAxis(EAxis::Z);
|
||||
|
||||
// Need at least 4 segments
|
||||
Segments = FMath::Max(Segments, 4);
|
||||
|
||||
FVector AxisY, AxisZ;
|
||||
FVector DirectionNorm = Direction.GetSafeNormal();
|
||||
DirectionNorm.FindBestAxisVectors(AxisZ, AxisY);
|
||||
const FVector AxisY = Matrix.GetScaledAxis(EAxis::Y);
|
||||
const FVector AxisZ = Matrix.GetScaledAxis(EAxis::Z);
|
||||
|
||||
TArray<FBatchedLine> Lines;
|
||||
Lines.Empty(Segments * 2 + 2);
|
||||
|
||||
if (InnerRadius != OuterRadius)
|
||||
{
|
||||
FVector P0 = Center + InnerRadius * (AxisY * -FMath::Sin(-AngleRad) + DirectionNorm * FMath::Cos(-AngleRad));
|
||||
FVector P1 = Center + OuterRadius * (AxisY * -FMath::Sin(-AngleRad) + DirectionNorm * FMath::Cos(-AngleRad));
|
||||
const FVector P0 = Center + InnerRadius * (AxisZ * FMath::Sin(AngleStartRad) + AxisY * FMath::Cos(AngleStartRad));
|
||||
const FVector P1 = Center + OuterRadius * (AxisZ * FMath::Sin(AngleStartRad) + AxisY * FMath::Cos(AngleStartRad));
|
||||
Lines.Emplace(FBatchedLine(P0, P1, Color, LineLifeTime, Thickness, DepthPriority));
|
||||
|
||||
FVector P2 = Center + InnerRadius * (AxisY * -FMath::Sin(AngleRad) + DirectionNorm * FMath::Cos(AngleRad));
|
||||
FVector P3 = Center + OuterRadius * (AxisY * -FMath::Sin(AngleRad) + DirectionNorm * FMath::Cos(AngleRad));
|
||||
const FVector P2 = Center + InnerRadius * (AxisZ * FMath::Sin(AngleEndRad) + AxisY * FMath::Cos(AngleEndRad));
|
||||
const FVector P3 = Center + OuterRadius * (AxisZ * FMath::Sin(AngleEndRad) + AxisY * FMath::Cos(AngleEndRad));
|
||||
Lines.Emplace(FBatchedLine(P2, P3, Color, LineLifeTime, Thickness, DepthPriority));
|
||||
}
|
||||
|
||||
float CurrentAngle = -AngleRad;
|
||||
const float AngleStep = AngleRad / float(Segments) * 2.f;
|
||||
FVector PrevVertex = Center + OuterRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle));
|
||||
float CurrentAngle = AngleStartRad;
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / float(Segments);
|
||||
FVector PrevVertex = Center + OuterRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
int32 Count = Segments;
|
||||
while (Count--)
|
||||
{
|
||||
CurrentAngle += AngleStep;
|
||||
FVector NextVertex = Center + OuterRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle));
|
||||
const FVector NextVertex = Center + OuterRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
Lines.Emplace(FBatchedLine(PrevVertex, NextVertex, Color, LineLifeTime, Thickness, DepthPriority));
|
||||
PrevVertex = NextVertex;
|
||||
}
|
||||
|
||||
if (InnerRadius != 0.0f)
|
||||
{
|
||||
CurrentAngle = -AngleRad;
|
||||
PrevVertex = Center + InnerRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle));
|
||||
CurrentAngle = AngleStartRad;
|
||||
PrevVertex = Center + InnerRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
|
||||
Count = Segments;
|
||||
while (Segments--)
|
||||
{
|
||||
CurrentAngle += AngleStep;
|
||||
FVector NextVertex = Center + InnerRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle));
|
||||
const FVector NextVertex = Center + InnerRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
Lines.Emplace(FBatchedLine(PrevVertex, NextVertex, Color, LineLifeTime, Thickness, DepthPriority));
|
||||
PrevVertex = NextVertex;
|
||||
}
|
||||
@@ -102,6 +103,23 @@ void FCogDebugDrawHelper::DrawArc(
|
||||
LineBatcher->DrawLines(Lines);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawArc(
|
||||
const UWorld* InWorld,
|
||||
const FMatrix& Matrix,
|
||||
float InnerRadius,
|
||||
float OuterRadius,
|
||||
float Angle,
|
||||
int32 Segments,
|
||||
const FColor& Color,
|
||||
bool bPersistentLines,
|
||||
float LifeTime,
|
||||
uint8 DepthPriority,
|
||||
float Thickness)
|
||||
{
|
||||
DrawArc(InWorld, Matrix, InnerRadius, OuterRadius, -Angle / 2.0f, Angle / 2.0f, Segments, Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSphere(
|
||||
const UWorld* InWorld,
|
||||
@@ -145,237 +163,6 @@ void FCogDebugDrawHelper::DrawFlatCapsule(
|
||||
::DrawDebugCircle(InWorld, FRotationTranslationMatrix(FRotator(90, 0, 0), FVector(End, Z)), Radius, Segments, Color, bPersistentLines, LifeTime, DepthPriority, Thickness, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawRaycastSingle(
|
||||
const UWorld* World,
|
||||
const FVector& Start,
|
||||
const FVector& End,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const bool bHit,
|
||||
const FHitResult& Hit,
|
||||
const float HitSize,
|
||||
const FLinearColor DrawColor,
|
||||
const FLinearColor DrawHitColor,
|
||||
const float DrawDuration,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType != EDrawDebugTrace::None)
|
||||
{
|
||||
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
|
||||
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
|
||||
|
||||
if (bHit && Hit.bBlockingHit)
|
||||
{
|
||||
::DrawDebugLine(World, Start, Hit.ImpactPoint, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
::DrawDebugLine(World, Hit.ImpactPoint, End, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
|
||||
DrawHitResult(World, Hit, 0, DrawType, false, HitSize, DrawHitColor, DrawTime, DepthPriority);
|
||||
}
|
||||
else
|
||||
{
|
||||
::DrawDebugLine(World, Start, End, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSphereOverlapMulti(
|
||||
const UWorld* World,
|
||||
const FVector& Position,
|
||||
const float Radius,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const bool bOverlap,
|
||||
const TArray<AActor*>& OutActors,
|
||||
const FLinearColor DrawColor,
|
||||
const FLinearColor DrawHitColor,
|
||||
const float DrawDuration /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
|
||||
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
|
||||
|
||||
DrawSphereOverlapSingle(World, Position, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSphereOverlapSingle(
|
||||
const UWorld* World,
|
||||
const FVector& Position,
|
||||
const float Radius,
|
||||
const FColor& DrawColor,
|
||||
const bool DrawPersistent,
|
||||
const float DrawTime /*= -1.f*/,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
::DrawDebugSphere(World, Position, Radius, 16, DrawColor, DrawPersistent, DrawTime, DepthPriority);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawCapsuleCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration /*= 0*/)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
|
||||
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
|
||||
|
||||
if (bHit && OutHits.Last().bBlockingHit)
|
||||
{
|
||||
FVector const BlockingHitPoint = OutHits.Last().Location;
|
||||
|
||||
DrawCapsuleCastSingle(World, Start, BlockingHitPoint, Rotation, HalfHeight, Radius, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
DrawCapsuleCastSingle(World, Start, End, Rotation, HalfHeight, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawCapsuleCastSingle(World, Start, End, Rotation, HalfHeight, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawCapsuleCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration /*= -1.f*/, const uint8 DepthPriority /*= 0*/)
|
||||
{
|
||||
::DrawDebugCapsule(World, Start, HalfHeight, Radius, Rotation, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
|
||||
::DrawDebugLine(World, Start, End, DrawColor, DrawPersistent, DrawDuration, DepthPriority, 0.5f);
|
||||
::DrawDebugCapsule(World, End, HalfHeight, Radius, Rotation, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSphereCastMulti(
|
||||
const UWorld* World,
|
||||
const FVector& Start,
|
||||
const FVector& End,
|
||||
const float Radius,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const bool bHit,
|
||||
const TArray<FHitResult>& OutHits,
|
||||
const FLinearColor DrawColor,
|
||||
const FLinearColor DrawHitColor,
|
||||
const float DrawDuration /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
|
||||
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
|
||||
|
||||
if (bHit && OutHits.Last().bBlockingHit)
|
||||
{
|
||||
FVector const BlockingHitPoint = OutHits.Last().Location;
|
||||
DrawSphereCastSingle(World, Start, BlockingHitPoint, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
DrawSphereCastSingle(World, BlockingHitPoint, End, Radius, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSphereCastSingle(World, Start, End, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSphereCastSingle(
|
||||
const UWorld* World,
|
||||
const FVector& Start,
|
||||
const FVector& End,
|
||||
const float Radius,
|
||||
const FColor& DrawColor,
|
||||
const bool DrawPersistent,
|
||||
const float DrawDuration /*= -1.f*/,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
FVector const TraceVec = End - Start;
|
||||
float const Dist = TraceVec.Size();
|
||||
|
||||
FVector const Center = Start + TraceVec * 0.5f;
|
||||
float const HalfHeight = (Dist * 0.5f) + Radius;
|
||||
|
||||
FQuat const CapsuleRot = FRotationMatrix::MakeFromZ(TraceVec).ToQuat();
|
||||
::DrawDebugCapsule(World, Center, HalfHeight, Radius, CapsuleRot, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawHitResults(
|
||||
const UWorld* World,
|
||||
const TArray<FHitResult>& OutHits,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const bool ShowHitIndex,
|
||||
const float HitSize,
|
||||
const FLinearColor HitColor,
|
||||
const float DrawDuration,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
for (int32 i = 0; i < OutHits.Num(); ++i)
|
||||
{
|
||||
DrawHitResult(World, OutHits[i], i, DrawType, ShowHitIndex, HitSize, HitColor, DrawDuration, DepthPriority);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawHitResultsDiscarded(
|
||||
const UWorld* World,
|
||||
const TArray<FHitResult>& AllHits,
|
||||
const TArray<FHitResult>& KeptHits,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const float HitSize,
|
||||
const FLinearColor DrawColor,
|
||||
const float DrawDuration,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
for (int32 i = 0; i < AllHits.Num(); ++i)
|
||||
{
|
||||
const FHitResult& PhysicHit = AllHits[i];
|
||||
if (!KeptHits.ContainsByPredicate([&](const FHitResult& Hit)
|
||||
{
|
||||
return Hit.GetActor() == PhysicHit.GetActor() && Hit.Component == PhysicHit.Component && Hit.Distance == PhysicHit.Distance;
|
||||
}))
|
||||
{
|
||||
DrawHitResult(World, PhysicHit, i, DrawType, false, HitSize, DrawColor, DrawDuration, DepthPriority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawHitResult(
|
||||
const UWorld* World,
|
||||
const FHitResult& Hit,
|
||||
const int HitIndex,
|
||||
const EDrawDebugTrace::Type DrawType,
|
||||
const bool ShowHitIndex,
|
||||
const float HitSize,
|
||||
const FLinearColor HitColor,
|
||||
const float DrawDuration,
|
||||
const uint8 DepthPriority /*= 0*/
|
||||
)
|
||||
{
|
||||
if (DrawType == EDrawDebugTrace::None)
|
||||
return;
|
||||
|
||||
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
|
||||
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
|
||||
|
||||
::DrawDebugSphere(World, Hit.ImpactPoint, HitSize, 12, HitColor.ToFColor(true), DrawPersistent, DrawTime, DepthPriority);
|
||||
if (ShowHitIndex)
|
||||
{
|
||||
::DrawDebugString(World, Hit.ImpactPoint, FString::Printf(TEXT("%d"), HitIndex), nullptr, HitColor.ToFColor(true), DrawTime, true, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawFrustum(
|
||||
const UWorld* World,
|
||||
@@ -449,3 +236,401 @@ void FCogDebugDrawHelper::DrawFrustum(
|
||||
DrawDebugLine(World, Verts[2], Verts[6], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
DrawDebugLine(World, Verts[3], Verts[7], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawQuad(const UWorld* World, const FVector& Position, const FQuat& Rotation, const FVector2D& Extents, const FColor& Color, bool bPersistent, float LifeTime, uint8 DepthPriority, const float Thickness)
|
||||
{
|
||||
if (GEngine->GetNetMode(World) == NM_DedicatedServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FVector U = Rotation.GetAxisZ() * Extents.X;
|
||||
const FVector V = Rotation.GetAxisY() * Extents.Y;
|
||||
|
||||
const FVector V0 = Position + U + V;
|
||||
const FVector V1 = Position + U - V;
|
||||
const FVector V2 = Position - U - V;
|
||||
const FVector V3 = Position - U + V;
|
||||
|
||||
DrawDebugLine(World, V0, V1, Color, bPersistent, LifeTime, DepthPriority, Thickness);
|
||||
DrawDebugLine(World, V1, V2, Color, bPersistent, LifeTime, DepthPriority, Thickness);
|
||||
DrawDebugLine(World, V2, V3, Color, bPersistent, LifeTime, DepthPriority, Thickness);
|
||||
DrawDebugLine(World, V3, V0, Color, bPersistent, LifeTime, DepthPriority, Thickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawSolidQuad(const UWorld* World, const FVector& Position, const FQuat& Rotation, const FVector2D& Extents, const FColor& Color, bool bPersistent, float LifeTime, uint8 DepthPriority)
|
||||
{
|
||||
if (GEngine->GetNetMode(World) == NM_DedicatedServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FVector U = Rotation.GetAxisZ() * Extents.X;
|
||||
const FVector V = Rotation.GetAxisY() * Extents.Y;
|
||||
|
||||
TArray<FVector> Verts;
|
||||
Verts.AddUninitialized(4);
|
||||
|
||||
Verts[0] = Position + U + V;
|
||||
Verts[1] = Position - U + V;
|
||||
Verts[2] = Position + U - V;
|
||||
Verts[3] = Position - U - V;
|
||||
|
||||
TArray<int32> Indices;
|
||||
Indices.AddUninitialized(6);
|
||||
|
||||
Indices[0] = 0;
|
||||
Indices[1] = 2;
|
||||
Indices[2] = 1;
|
||||
|
||||
Indices[3] = 1;
|
||||
Indices[4] = 2;
|
||||
Indices[5] = 3;
|
||||
|
||||
DrawDebugMesh(World, Verts, Indices, Color, bPersistent, LifeTime, DepthPriority);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawHitResult(
|
||||
const UWorld* World,
|
||||
const FHitResult& HitResult,
|
||||
const FCogDebugDrawLineTraceParams& Settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawHitResults(
|
||||
const UWorld* World,
|
||||
const TArray<FHitResult>& HitResults,
|
||||
const FCogDebugDrawLineTraceParams& Settings)
|
||||
{
|
||||
TSet<const UPrimitiveComponent*> AlreadyDrawnPrimitives;
|
||||
TSet<const AActor*> AlreadyDrawnActors;
|
||||
|
||||
for (const FHitResult& HitResult : HitResults)
|
||||
{
|
||||
const FColor& HitColor = Settings.HitColor;
|
||||
|
||||
if (Settings.DrawHitLocation)
|
||||
{
|
||||
DrawDebugPoint(
|
||||
World,
|
||||
HitResult.Location,
|
||||
Settings.HitPointSize,
|
||||
HitColor,
|
||||
Settings.Persistent,
|
||||
Settings.LifeTime,
|
||||
Settings.DepthPriority);
|
||||
}
|
||||
|
||||
if (Settings.DrawHitImpactPoints)
|
||||
{
|
||||
DrawDebugPoint(
|
||||
World,
|
||||
HitResult.ImpactPoint,
|
||||
Settings.HitPointSize,
|
||||
HitColor,
|
||||
Settings.Persistent,
|
||||
Settings.LifeTime,
|
||||
Settings.DepthPriority);
|
||||
}
|
||||
|
||||
if (Settings.DrawHitNormals)
|
||||
{
|
||||
DrawDebugDirectionalArrow(
|
||||
World,
|
||||
HitResult.Location,
|
||||
HitResult.Location + HitResult.Normal * 20.0f,
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
Settings.NormalColor,
|
||||
Settings.Persistent,
|
||||
Settings.LifeTime,
|
||||
Settings.DepthPriority,
|
||||
Settings.Thickness);
|
||||
}
|
||||
|
||||
if (Settings.DrawHitImpactNormals)
|
||||
{
|
||||
DrawDebugDirectionalArrow(
|
||||
World,
|
||||
HitResult.ImpactPoint,
|
||||
HitResult.ImpactPoint + HitResult.ImpactNormal * 20.0f,
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
Settings.ImpactNormalColor,
|
||||
Settings.Persistent,
|
||||
Settings.LifeTime,
|
||||
Settings.DepthPriority,
|
||||
Settings.Thickness);
|
||||
}
|
||||
|
||||
if (Settings.DrawHitPrimitives)
|
||||
{
|
||||
const UPrimitiveComponent* PrimitiveComponent = HitResult.GetComponent();
|
||||
if (PrimitiveComponent == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AlreadyDrawnPrimitives.Contains(PrimitiveComponent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AlreadyDrawnPrimitives.Add(PrimitiveComponent);
|
||||
const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
|
||||
const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType];
|
||||
DrawPrimitiveComponent(*PrimitiveComponent, PrimitiveColor, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
if (Settings.DrawHitPrimitiveActorsName)
|
||||
{
|
||||
const AActor* Actor = PrimitiveComponent->GetOwner();
|
||||
if (Actor == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AlreadyDrawnActors.Contains(Actor))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AlreadyDrawnActors.Add(Actor);
|
||||
const FColor TextColor = PrimitiveColor.WithAlpha(255);
|
||||
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, TextColor, 0.0f, Settings.HitPrimitiveActorsNameShadow, Settings.HitPrimitiveActorsNameSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawLineTrace(
|
||||
const UWorld* World,
|
||||
const FVector& Start,
|
||||
const FVector& End,
|
||||
const bool HasHits,
|
||||
TArray<FHitResult>& HitResults,
|
||||
const FCogDebugDrawLineTraceParams& Settings
|
||||
)
|
||||
{
|
||||
DrawDebugDirectionalArrow(
|
||||
World,
|
||||
Start,
|
||||
End,
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
HasHits ? Settings.HitColor : Settings.NoHitColor,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebug::GetDebugDepthPriority(0),
|
||||
FCogDebug::GetDebugThickness(0.0f));
|
||||
|
||||
DrawHitResults(World, HitResults, Settings);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::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
|
||||
)
|
||||
{
|
||||
const FColor Color = HasHits ? Settings.HitColor : Settings.NoHitColor;
|
||||
|
||||
DrawDebugDirectionalArrow(
|
||||
World,
|
||||
Start,
|
||||
End,
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebug::GetDebugDepthPriority(0),
|
||||
FCogDebug::GetDebugThickness(0.0f));
|
||||
|
||||
DrawShape(World, Shape, Start, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
DrawHitResults(World, HitResults, Settings);
|
||||
|
||||
for (const FHitResult& Hit : HitResults)
|
||||
{
|
||||
if (Settings.DrawHitShapes)
|
||||
{
|
||||
DrawShape(World, Shape, Hit.Location, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawOverlap(
|
||||
const UWorld* World,
|
||||
const FCollisionShape& Shape,
|
||||
const FVector& Location,
|
||||
const FQuat& Rotation,
|
||||
TArray<FOverlapResult>& OverlapResults,
|
||||
const FCogDebugDrawOverlapParams& Settings
|
||||
)
|
||||
{
|
||||
const FColor Color = OverlapResults.Num() > 0 ? Settings.HitColor : Settings.NoHitColor;
|
||||
DrawShape(World, Shape, Location, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
if (Settings.DrawHitPrimitives)
|
||||
{
|
||||
for (const FOverlapResult& OverlapResult : OverlapResults)
|
||||
{
|
||||
if (const UPrimitiveComponent* PrimitiveComponent = OverlapResult.GetComponent())
|
||||
{
|
||||
const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
|
||||
const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType];
|
||||
DrawPrimitiveComponent(*PrimitiveComponent, PrimitiveColor, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawPrimitiveComponent(
|
||||
const UPrimitiveComponent& PrimitiveComponent,
|
||||
const FColor& Color,
|
||||
const bool Persistent,
|
||||
const float LifeTime,
|
||||
const uint8 DepthPriority,
|
||||
const float Thickness)
|
||||
{
|
||||
const UWorld* World = PrimitiveComponent.GetWorld();
|
||||
if (World == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const UBoxComponent* BoxComponent = Cast<UBoxComponent>(&PrimitiveComponent);;
|
||||
const FCollisionShape Shape = PrimitiveComponent.GetCollisionShape();
|
||||
|
||||
if (Shape.ShapeType == ECollisionShape::Box && BoxComponent == nullptr)
|
||||
{
|
||||
FVector Location;
|
||||
FVector Extent;
|
||||
PrimitiveComponent.Bounds.GetBox().GetCenterAndExtents(Location, Extent);
|
||||
|
||||
// TODO: this adds padding to prevent Z fight. Maybe add this as a parameter.
|
||||
Extent += FVector::OneVector;
|
||||
|
||||
DrawDebugSolidBox(
|
||||
World,
|
||||
Location,
|
||||
Extent,
|
||||
FQuat::Identity,
|
||||
Color,
|
||||
Persistent,
|
||||
LifeTime,
|
||||
DepthPriority);
|
||||
|
||||
DrawDebugBox(
|
||||
World,
|
||||
Location,
|
||||
Extent,
|
||||
FQuat::Identity,
|
||||
Color,
|
||||
Persistent,
|
||||
LifeTime,
|
||||
DepthPriority,
|
||||
Thickness);
|
||||
}
|
||||
else
|
||||
{
|
||||
const FVector Location = PrimitiveComponent.GetComponentLocation();
|
||||
const FQuat Rotation = PrimitiveComponent.GetComponentQuat();
|
||||
const FVector Scale = PrimitiveComponent.GetComponentScale();
|
||||
DrawShape(World, Shape, Location, Rotation, Scale, Color, Persistent, LifeTime, DepthPriority, Thickness);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawHelper::DrawShape(
|
||||
const UWorld* World,
|
||||
const FCollisionShape& InShape,
|
||||
const FVector& Location,
|
||||
const FQuat& Rotation,
|
||||
const FVector& Scale,
|
||||
const FColor& Color,
|
||||
const bool Persistent,
|
||||
const float LifeTime,
|
||||
const uint8 DepthPriority,
|
||||
const float Thickness)
|
||||
{
|
||||
switch (InShape.ShapeType)
|
||||
{
|
||||
case ECollisionShape::Box:
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// see UBoxComponent::GetScaledBoxExtent()
|
||||
//--------------------------------------------------
|
||||
const FVector HalfExtent(InShape.Box.HalfExtentX * Scale.X, InShape.Box.HalfExtentY * Scale.Y, InShape.Box.HalfExtentZ * Scale.Z);
|
||||
|
||||
DrawDebugBox(
|
||||
World,
|
||||
Location,
|
||||
HalfExtent,
|
||||
Rotation,
|
||||
Color,
|
||||
Persistent,
|
||||
LifeTime,
|
||||
DepthPriority,
|
||||
Thickness);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECollisionShape::Sphere:
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// see USphereComponent::GetScaledSphereRadius()
|
||||
//--------------------------------------------------
|
||||
const float RadiusScale = FMath::Min(Scale.X, FMath::Min(Scale.Y, Scale.Z));
|
||||
const float Radius = InShape.Sphere.Radius * RadiusScale;
|
||||
|
||||
DrawSphere(
|
||||
World,
|
||||
Location,
|
||||
Radius,
|
||||
FCogDebug::GetCircleSegments(),
|
||||
Color,
|
||||
Persistent,
|
||||
LifeTime,
|
||||
DepthPriority,
|
||||
Thickness);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECollisionShape::Capsule:
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// see UCapsuleComponent::GetScaledCapsuleRadius()
|
||||
//--------------------------------------------------
|
||||
const float Radius = InShape.Capsule.Radius * FMath::Min(Scale.X, Scale.Y);
|
||||
const float HalfHeight = InShape.Capsule.HalfHeight * UE_REAL_TO_FLOAT(Scale.Z);
|
||||
|
||||
DrawDebugCapsule(
|
||||
World,
|
||||
Location,
|
||||
HalfHeight,
|
||||
Radius,
|
||||
Rotation,
|
||||
Color,
|
||||
Persistent,
|
||||
LifeTime,
|
||||
DepthPriority,
|
||||
Thickness);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,19 +153,6 @@ void FCogDebugDrawImGui::AddCircleFilled(const ImVec2& Center, float Radius, ImU
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 Color, bool AddShadow /*= false*/, float Duration/* = 0.0f*/, bool FadeColor /*= false*/)
|
||||
{
|
||||
if (AddShadow)
|
||||
{
|
||||
FText ShadowTextElement;
|
||||
ShadowTextElement.Pos = Pos + ImVec2(1, 1);
|
||||
ShadowTextElement.Text = Text;
|
||||
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.Duration = Duration;
|
||||
ShadowTextElement.FadeColor = FadeColor;
|
||||
Texts.Add_GetRef(ShadowTextElement);
|
||||
}
|
||||
|
||||
FText TextElement;
|
||||
TextElement.Pos = Pos;
|
||||
TextElement.Text = Text;
|
||||
@@ -174,6 +161,19 @@ void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 C
|
||||
TextElement.Duration = Duration;
|
||||
TextElement.FadeColor = FadeColor;
|
||||
Texts.Add_GetRef(TextElement);
|
||||
|
||||
if (AddShadow)
|
||||
{
|
||||
FText ShadowTextElement;
|
||||
ShadowTextElement.Pos = Pos + ImVec2(1, 1);
|
||||
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.Duration = Duration;
|
||||
ShadowTextElement.FadeColor = FadeColor;
|
||||
Texts.Add_GetRef(ShadowTextElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
#include "CogDebugGizmo.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float ScreenDistanceToLine(const APlayerController& InPlayerController, const FVector2D& Point2D, const FVector& P0, const FVector& P1)
|
||||
{
|
||||
FVector2D ScreenP0, ScreenP1;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P0, ScreenP0);
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P1, ScreenP1);
|
||||
const FVector2D ClosestPoint = FMath::ClosestPointOnSegment2D(Point2D, ScreenP0, ScreenP1);
|
||||
const float DistanceToMouse = (ClosestPoint - Point2D).Length();
|
||||
return DistanceToMouse;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float ScreenDistanceToSphere(const APlayerController& InPlayerController, const FVector2D& Point2D, const FVector& SphereLocation, float Radius)
|
||||
{
|
||||
FVector2D ElementLocation2D;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, SphereLocation, ElementLocation2D);
|
||||
|
||||
//TODO : radius in 3D
|
||||
const float Distance = FVector2D::Distance(ElementLocation2D, Point2D) - Radius;
|
||||
return Distance;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float ScreenDistanceToQuad(const APlayerController& InPlayerController, const FVector2D& Point2D, const FVector& QuadPosition, const FQuat& QuadRotation, const FVector2D& QuadExtents)
|
||||
{
|
||||
const FVector U = QuadRotation.GetAxisZ() * QuadExtents.X;
|
||||
const FVector V = QuadRotation.GetAxisY() * QuadExtents.Y;
|
||||
|
||||
const FVector V0 = QuadPosition + U + V;
|
||||
const FVector V1 = QuadPosition + U - V;
|
||||
const FVector V2 = QuadPosition - U - V;
|
||||
const FVector V3 = QuadPosition - U + V;
|
||||
|
||||
FVector2D P0, P1, P2, P3;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V0, P0);
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V1, P1);
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V2, P2);
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V3, P3);
|
||||
|
||||
const FVector B0 = FMath::GetBaryCentric2D(Point2D, P0, P1, P2);
|
||||
const FVector B1 = FMath::GetBaryCentric2D(Point2D, P0, P2, P3);
|
||||
|
||||
const bool Inside0 = B0.X > 0.0f && B0.Y > 0.0f && B0.Z > 0.0f;
|
||||
const bool Inside1 = B1.X > 0.0f && B1.Y > 0.0f && B1.Z > 0.0f;
|
||||
|
||||
const float D = (Inside0 || Inside1) ? 0.0f : FLT_MAX;
|
||||
return D;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float ScreenDistanceToArc(const APlayerController& InPlayerController, const FVector2D& Point, const FMatrix& Matrix, const float Radius, const float AngleStart, const float AngleEnd, const int32 Segments)
|
||||
{
|
||||
const float AngleStartRad = FMath::DegreesToRadians(AngleStart);
|
||||
const float AngleEndRad = FMath::DegreesToRadians(AngleEnd);
|
||||
const FVector Center = Matrix.GetOrigin();
|
||||
|
||||
// Need at least 4 segments
|
||||
const int32 NumSegments = FMath::Max(Segments, 4);
|
||||
|
||||
const FVector AxisY = Matrix.GetScaledAxis(EAxis::Y);
|
||||
const FVector AxisZ = Matrix.GetScaledAxis(EAxis::Z);
|
||||
|
||||
float CurrentAngle = AngleStartRad;
|
||||
const float AngleStep = (AngleEndRad - AngleStartRad) / float(NumSegments);
|
||||
|
||||
FVector P0 = Center + Radius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
|
||||
FVector2D ScreenP0;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P0, ScreenP0);
|
||||
|
||||
float MinDistanceSqr = FLT_MAX;
|
||||
|
||||
int32 Count = NumSegments;
|
||||
while (Count--)
|
||||
{
|
||||
CurrentAngle += AngleStep;
|
||||
const FVector P1 = Center + Radius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
|
||||
|
||||
FVector2D ScreenP1;
|
||||
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P1, ScreenP1);
|
||||
|
||||
const FVector2D ClosestPoint = FMath::ClosestPointOnSegment2D(Point, ScreenP0, ScreenP1);
|
||||
const float ScreenDistanceSqr = (ClosestPoint - Point).SquaredLength();
|
||||
|
||||
if (ScreenDistanceSqr < MinDistanceSqr)
|
||||
{
|
||||
MinDistanceSqr = ScreenDistanceSqr;
|
||||
}
|
||||
|
||||
P0 = P1;
|
||||
ScreenP0 = ScreenP1;
|
||||
}
|
||||
|
||||
return FMath::Sqrt(MinDistanceSqr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector GetMouseCursorOnLine(const APlayerController& InPlayerController, const FVector& LinePoint, const FVector& LineDirection, const FVector2D& MousePos)
|
||||
{
|
||||
FVector MouseWorldOrigin, MouseWorldDirection;
|
||||
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, MousePos, MouseWorldOrigin, MouseWorldDirection);
|
||||
|
||||
FVector PointOnAxis;
|
||||
FVector PointOnMouseRay;
|
||||
|
||||
constexpr float LineLength = 10000;
|
||||
FMath::SegmentDistToSegmentSafe(LinePoint - LineDirection * LineLength, LinePoint + LineDirection * LineLength, MouseWorldOrigin - MouseWorldDirection * LineLength, MouseWorldOrigin + MouseWorldDirection * LineLength, PointOnAxis, PointOnMouseRay);
|
||||
|
||||
return PointOnAxis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector GetMouseCursorOnPlane(const APlayerController& InPlayerController, const FVector& PlanePoint, const FVector& PlaneNormal, const FVector2D& MousePos)
|
||||
{
|
||||
FVector MouseWorldOrigin, MouseWorldDirection;
|
||||
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, MousePos, MouseWorldOrigin, MouseWorldDirection);
|
||||
|
||||
const FPlane Plane(PlanePoint, PlaneNormal);
|
||||
const FVector PlaneIntersection = FMath::RayPlaneIntersection(MouseWorldOrigin, MouseWorldDirection, Plane);
|
||||
return PlaneIntersection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector VectorMax(const FVector& Vector, const float MaxValue)
|
||||
{
|
||||
FVector NewValue;
|
||||
NewValue.X = FMath::Max(Vector.X, MaxValue);
|
||||
NewValue.Y = FMath::Max(Vector.Y, MaxValue);
|
||||
NewValue.Z = FMath::Max(Vector.Z, MaxValue);
|
||||
return NewValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void DrawGizmoText(const ImVec2& Position, ImU32 Color, const char* Text)
|
||||
{
|
||||
ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||
if (Viewport == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImDrawList* DrawList = ImGui::GetBackgroundDrawList(Viewport);
|
||||
|
||||
const float Alpha = ImGui::ColorConvertU32ToFloat4(Color).w;
|
||||
DrawList->AddText(Viewport->Pos + Position + ImVec2(1.0f, 1.0f), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, Alpha)), Text, nullptr);
|
||||
DrawList->AddText(Viewport->Pos + Position, Color, Text, nullptr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool RenderComponent(const char* Label, double* Value, double Reset)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushItemWidth(-1);
|
||||
bool Result = FCogImguiHelper::DragDouble(Label, Value, 0.1f, 0.0f, 0.0f, "%.1f");
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
*Value = Reset;
|
||||
Result = true;
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void RenderSnap(bool* SnapEnable, float* Snap)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::Checkbox("Snap", SnapEnable);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::DragFloat("##SnapValue", Snap, 0.1f, 0.1f, 1000.0f, "%.1f");
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerController, FTransform& InOutTransform, ECogDebug_GizmoFlags Flags)
|
||||
{
|
||||
UWorld* World = InPlayerController.GetWorld();
|
||||
|
||||
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||
if (Viewport == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FVector GizmoCenter = InOutTransform.GetTranslation();
|
||||
|
||||
FVector2D Center2D;
|
||||
if (UGameplayStatics::ProjectWorldToScreen(&InPlayerController, GizmoCenter, Center2D) == false)
|
||||
{
|
||||
if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
InOutTransform = InitialTransform;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Result = false;
|
||||
|
||||
const ImGuiIO& IO = ImGui::GetIO();
|
||||
FCogDebugSettings& Settings = FCogDebug::Settings;
|
||||
|
||||
FVector ProjectedGizmoCenter, CenterDirection, AxisProjection, AxisDirection;
|
||||
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D, ProjectedGizmoCenter, CenterDirection);
|
||||
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D + FVector2d(0, 1.0f), AxisProjection, AxisDirection);
|
||||
const FVector CameraLocation = InPlayerController.PlayerCameraManager->GetCameraLocation();
|
||||
const float CameraToProjectedGizmoCenter = FVector::Dist(CameraLocation, ProjectedGizmoCenter);
|
||||
const float ScaleToKeepGizmoScreenSizeConstant = FMath::IsNearlyZero(CameraToProjectedGizmoCenter) ? 1.0f : FVector::Dist(AxisProjection, ProjectedGizmoCenter) * FVector::Dist(CameraLocation, GizmoCenter) / CameraToProjectedGizmoCenter;
|
||||
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 RotZ = RotX * FQuat(FVector(0.0f, 1.0f, 0.0f), UE_HALF_PI);
|
||||
|
||||
const FVector UnitAxisX = Settings.GizmoUseLocalSpace ? RotX.GetAxisX() : FVector::XAxisVector;
|
||||
const FVector UnitAxisY = Settings.GizmoUseLocalSpace ? RotX.GetAxisY() : FVector::YAxisVector;
|
||||
const FVector UnitAxisZ = Settings.GizmoUseLocalSpace ? RotX.GetAxisZ() : FVector::ZAxisVector;
|
||||
|
||||
const float ScaleBoxExtent = Settings.GizmoScaleBoxExtent * GizmoScale;
|
||||
const float PlaneExtent = Settings.GizmoTranslationPlaneExtent * GizmoScale;
|
||||
const float ThicknessZLow = Settings.GizmoThicknessZLow * ScaleToKeepGizmoScreenSizeConstant;
|
||||
const float ThicknessZHigh = Settings.GizmoThicknessZHigh * ScaleToKeepGizmoScreenSizeConstant;
|
||||
|
||||
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 };
|
||||
|
||||
FCogDebug_GizmoElement GizmoElements[ECogDebug_GizmoElementType::MAX];
|
||||
for (FCogDebug_GizmoElement& GizmoElement : GizmoElements)
|
||||
{
|
||||
GizmoElement.Type = ECogDebug_GizmoType::MAX;
|
||||
}
|
||||
|
||||
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 };
|
||||
}
|
||||
|
||||
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) };
|
||||
}
|
||||
|
||||
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 };
|
||||
}
|
||||
|
||||
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoScaleUniform) == false)
|
||||
{
|
||||
GizmoElements[(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 };
|
||||
}
|
||||
|
||||
ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX;
|
||||
if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
HoveredElementType = DraggedElementType;
|
||||
}
|
||||
else if (IO.WantCaptureMouse == false)
|
||||
{
|
||||
float MinDistanceToMouse = FLT_MAX;
|
||||
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||
{
|
||||
FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||
float DistanceToMouse = FLT_MAX;
|
||||
|
||||
switch (Elm.Type)
|
||||
{
|
||||
case ECogDebug_GizmoType::MoveAxis:
|
||||
{
|
||||
DistanceToMouse = ScreenDistanceToLine(InPlayerController, MousePos, GizmoCenter, Elm.Location);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::MovePlane:
|
||||
{
|
||||
DistanceToMouse = ScreenDistanceToQuad(InPlayerController, MousePos, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent));
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::Rotate:
|
||||
{
|
||||
const FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), GizmoCenter);
|
||||
const float RotationGizmoRadius = Settings.GizmoRotationRadius * GizmoScale;
|
||||
DistanceToMouse = ScreenDistanceToArc(InPlayerController, MousePos, Matrix, RotationGizmoRadius, 0.0f, 90.0f, Settings.GizmoRotationSegments);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::ScaleUniform:
|
||||
case ECogDebug_GizmoType::ScaleAxis:
|
||||
{
|
||||
DistanceToMouse = ScreenDistanceToSphere(InPlayerController, MousePos, Elm.Location, Settings.GizmoScaleBoxExtent);
|
||||
break;
|
||||
}
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
if (DistanceToMouse < Settings.GizmoCursorSelectionThreshold && DistanceToMouse < MinDistanceToMouse)
|
||||
{
|
||||
HoveredElementType = (ECogDebug_GizmoElementType)i;
|
||||
MinDistanceToMouse = DistanceToMouse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||
{
|
||||
const FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||
const bool IsClosestToMouse = i == (uint8)HoveredElementType;
|
||||
const uint8 AxisIndex = (uint8)Elm.AxisType;
|
||||
const FColor ZLowColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZLow[AxisIndex];
|
||||
const FColor ZHighColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZHigh[AxisIndex];
|
||||
|
||||
switch (Elm.Type)
|
||||
{
|
||||
case ECogDebug_GizmoType::MoveAxis:
|
||||
{
|
||||
DrawDebugLine(World, GizmoCenter, Elm.Location, ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
DrawDebugLine(World, GizmoCenter, Elm.Location, ZHighColor, false, 0.0f, Settings.GizmoZHigh, Settings.GizmoThicknessZHigh);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::MovePlane:
|
||||
{
|
||||
FCogDebugDrawHelper::DrawQuad(World, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent), ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
FCogDebugDrawHelper::DrawQuad(World, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent), ZHighColor, false, 0.0f, Settings.GizmoZHigh, ThicknessZHigh);
|
||||
FCogDebugDrawHelper::DrawSolidQuad(World, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent), ZLowColor, false, 0.0f, Settings.GizmoZLow);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::Rotate:
|
||||
{
|
||||
FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), GizmoCenter);
|
||||
const float RotationGizmoRadius = Settings.GizmoRotationRadius * GizmoScale;
|
||||
FCogDebugDrawHelper::DrawArc(World, Matrix, RotationGizmoRadius, RotationGizmoRadius, 0.0f, 90.0f, Settings.GizmoRotationSegments, ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
FCogDebugDrawHelper::DrawArc(World, Matrix, RotationGizmoRadius, RotationGizmoRadius, 0.0f, 90.0f, Settings.GizmoRotationSegments, ZHighColor, false, 0.0f, Settings.GizmoZHigh, ThicknessZHigh);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::ScaleUniform:
|
||||
case ECogDebug_GizmoType::ScaleAxis:
|
||||
{
|
||||
DrawDebugBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
|
||||
DrawDebugBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZHighColor, false, 0.0f, Settings.GizmoZHigh, ThicknessZHigh);
|
||||
DrawDebugSolidBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Settings.GizmoZLow);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.GizmoGroundRaycastLength > 0.0f)
|
||||
{
|
||||
FVector Bottom = GizmoCenter - FVector(0.0f, 0.0f, Settings.GizmoGroundRaycastLength);
|
||||
FHitResult GroundHit;
|
||||
if (World->LineTraceSingleByChannel(GroundHit, GizmoCenter, Bottom, Settings.GizmoGroundRaycastChannel))
|
||||
{
|
||||
Bottom = GroundHit.ImpactPoint;
|
||||
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);
|
||||
}
|
||||
|
||||
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
DraggedElementType = ECogDebug_GizmoElementType::MAX;
|
||||
}
|
||||
else if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
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];
|
||||
|
||||
switch (DraggedElement.Type)
|
||||
{
|
||||
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());
|
||||
const float SnappedDelta = FMath::GridSnap(Delta, Settings.GizmoTranslationSnapEnable ? Settings.GizmoTranslationSnapValue : 0.0f);
|
||||
const FVector NewLocation = InitialTransform.GetTranslation() + DraggedElement.Direction * SnappedDelta;
|
||||
InOutTransform.SetLocation(NewLocation);
|
||||
Result = true;
|
||||
|
||||
const FString Text = FString::Printf(TEXT("%0.1f"), SnappedDelta);
|
||||
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() + DraggedElement.Direction * SnappedDelta, FColor::White);
|
||||
//const FVector TextLocation = InitialTransform.GetTranslation() + DraggedElement.Direction * SnappedDelta * 0.5f;
|
||||
//UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D + FVector2d(0, 1.0f), AxisProjection, AxisDirection);
|
||||
//FVector2D TextLocation2D;
|
||||
//if (UGameplayStatics::ProjectWorldToScreen(&InPlayerController, TextLocation, TextLocation2D))
|
||||
//{
|
||||
// FCogDebugDrawImGui::AddText(FCogImguiHelper::ToImVec2(TextLocation2D), FString::Printf(TEXT("%0.1f"), SnappedDelta), IM_COL32(255, 255, 255, 255), true);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::MovePlane:
|
||||
{
|
||||
const FVector CursorOnPlane = GetMouseCursorOnPlane(InPlayerController, InitialTransform.GetTranslation(), DraggedElement.Direction, MousePos - CursorOffset);
|
||||
const FVector U = DraggedElement.Rotation.GetAxisZ();
|
||||
const FVector V = DraggedElement.Rotation.GetAxisY();
|
||||
const float DeltaU = FVector::DotProduct(U, CursorOnPlane - InitialTransform.GetTranslation());
|
||||
const float DeltaV = FVector::DotProduct(V, CursorOnPlane - InitialTransform.GetTranslation());
|
||||
const float SnappedDeltaU = FMath::GridSnap(DeltaU, Settings.GizmoTranslationSnapEnable ? Settings.GizmoTranslationSnapValue : 0.0f);
|
||||
const float SnappedDeltaV = FMath::GridSnap(DeltaV, Settings.GizmoTranslationSnapEnable ? Settings.GizmoTranslationSnapValue : 0.0f);
|
||||
const FVector WorldDeltaU = U * SnappedDeltaU;
|
||||
const FVector WorldDeltaV = V * SnappedDeltaV;
|
||||
const FVector NewLocation = InitialTransform.GetTranslation() + WorldDeltaU + WorldDeltaV;
|
||||
InOutTransform.SetLocation(NewLocation);
|
||||
Result = true;
|
||||
|
||||
const FString Text = FString::Printf(TEXT("%0.1f %0.1f"), SnappedDeltaU, SnappedDeltaV);
|
||||
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);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::Rotate:
|
||||
{
|
||||
const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left));
|
||||
const float DragAmount = DragDelta.X - DragDelta.Y;
|
||||
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();
|
||||
InOutTransform.SetRotation(NewRot);
|
||||
Result = true;
|
||||
|
||||
const FString Text = FString::Printf(TEXT("%0.1f"), SnappedAngle);
|
||||
DrawGizmoText(FCogImguiHelper::ToImVec2(Center2D), FCogImguiHelper::ToImU32(Settings.GizmoTextColor), StringCast<ANSICHAR>(*Text).Get());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::ScaleAxis:
|
||||
{
|
||||
const FVector Point = GetMouseCursorOnLine(InPlayerController, GizmoCenter, DraggedElement.Direction, MousePos - CursorOffset);
|
||||
const float Sign = FMath::Sign(FVector::DotProduct(DraggedElement.Direction, Point - GizmoCenter));
|
||||
const float Delta = (Point - GizmoCenter).Length() * Sign;
|
||||
const float SnappedDelta = FMath::GridSnap(Delta, Settings.GizmoScaleSnapEnable ? Settings.GizmoScaleSnapValue : 0.0f);
|
||||
const FVector NewScale = VectorMax(InitialTransform.GetScale3D() + (DraggedElement.Axis * SnappedDelta * Settings.GizmoScaleSpeed), Settings.GizmoScaleMin);
|
||||
InOutTransform.SetScale3D(NewScale);
|
||||
Result = true;
|
||||
|
||||
const FString Text = FString::Printf(TEXT("%0.1f"), SnappedDelta);
|
||||
DrawGizmoText(FCogImguiHelper::ToImVec2(Center2D), FCogImguiHelper::ToImU32(Settings.GizmoTextColor), StringCast<ANSICHAR>(*Text).Get());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogDebug_GizmoType::ScaleUniform:
|
||||
{
|
||||
const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left));
|
||||
const float Delta = DragDelta.X - DragDelta.Y;
|
||||
const float SnappedDelta = FMath::GridSnap(Delta, Settings.GizmoScaleSnapEnable ? Settings.GizmoScaleSnapValue : 0.0f);
|
||||
const FVector NewScale = VectorMax(InitialTransform.GetScale3D() + (DraggedElement.Axis * SnappedDelta * Settings.GizmoScaleSpeed), Settings.GizmoScaleMin);
|
||||
InOutTransform.SetScale3D(NewScale);
|
||||
Result = true;
|
||||
|
||||
const FString Text = FString::Printf(TEXT("%0.1f"), SnappedDelta);
|
||||
DrawGizmoText(FCogImguiHelper::ToImVec2(Center2D), FCogImguiHelper::ToImU32(Settings.GizmoTextColor), StringCast<ANSICHAR>(*Text).Get());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (HoveredElementType != ECogDebug_GizmoElementType::MAX)
|
||||
{
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
DraggedElementType = HoveredElementType;
|
||||
CursorOffset = MousePos - Center2D;
|
||||
InitialTransform = InOutTransform;
|
||||
}
|
||||
//else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
//{
|
||||
// ImGui::OpenPopup(Id);
|
||||
//}
|
||||
}
|
||||
|
||||
//if (ImGui::BeginPopup(Id))
|
||||
//{
|
||||
// FVector Translation = InOutTransform.GetTranslation();
|
||||
// FRotator Rotation = InOutTransform.GetRotation().Rotator();
|
||||
// FVector Scale = InOutTransform.GetScale3D();
|
||||
|
||||
// ImGui::Checkbox("Local Space", &Settings.GizmoUseLocalSpace);
|
||||
|
||||
// ImGui::Separator();
|
||||
|
||||
// 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);
|
||||
|
||||
// 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("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("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();
|
||||
|
||||
// ImGui::EndTable();
|
||||
// }
|
||||
|
||||
// ImGui::PopStyleVar();
|
||||
|
||||
// ImGui::EndPopup();
|
||||
//}
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CogDebugMetric.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugMetric::MaxDurationSetting = 0.0f;
|
||||
@@ -13,7 +13,7 @@ TMap<FName, FCogDebugMetricEntry> FCogDebugMetric::Metrics;
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params)
|
||||
{
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(Params.WorldContextObject) == false)
|
||||
if (FCogDebug::IsDebugActiveForObject(Params.WorldContextObject) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObjec
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ void ACogDebugReplicator::BeginPlay()
|
||||
if (OwnerPlayerController != nullptr && OwnerPlayerController->IsLocalController())
|
||||
{
|
||||
Server_RequestAllCategoriesVerbosity();
|
||||
Server_SetSelection(FCogDebugSettings::GetSelection());
|
||||
Server_SetIsFilteringBySelection(FCogDebugSettings::GetIsFilteringBySelection());
|
||||
Server_SetSelection(FCogDebug::GetSelection());
|
||||
Server_SetIsFilteringBySelection(FCogDebug::GetIsFilteringBySelection());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
#include "CogDebugSettings.h"
|
||||
|
||||
#include "CogCommonDebugFilteredActorInterface.h"
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Engine/Engine.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
|
||||
bool FCogDebugSettings::bIsFilteringBySelection = true;
|
||||
bool FCogDebugSettings::Persistent = false;
|
||||
bool FCogDebugSettings::TextShadow = true;
|
||||
bool FCogDebugSettings::Fade2D = true;
|
||||
float FCogDebugSettings::Duration = 3.0f;
|
||||
int FCogDebugSettings::DepthPriority = 0;
|
||||
int FCogDebugSettings::Segments = 12;
|
||||
float FCogDebugSettings::Thickness = 0.0f;
|
||||
float FCogDebugSettings::ServerThickness = 2.0f;
|
||||
float FCogDebugSettings::ServerColorMultiplier = 0.8f;
|
||||
float FCogDebugSettings::ArrowSize = 10.0f;
|
||||
float FCogDebugSettings::AxesScale = 1.0f;
|
||||
float FCogDebugSettings::GradientColorIntensity = 0.0f;
|
||||
float FCogDebugSettings::GradientColorSpeed = 2.0f;
|
||||
float FCogDebugSettings::TextSize = 1.0f;
|
||||
TArray<FString> FCogDebugSettings::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*",
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugSettings::Reset()
|
||||
{
|
||||
bIsFilteringBySelection = true;
|
||||
Persistent = false;
|
||||
TextShadow = true;
|
||||
Fade2D = true;
|
||||
Duration = 3.0f;
|
||||
DepthPriority = 0;
|
||||
Segments = 12;
|
||||
Thickness = 0.0f;
|
||||
ServerThickness = 2.0f;
|
||||
ServerColorMultiplier = 0.8f;
|
||||
ArrowSize = 10.0f;
|
||||
AxesScale = 1.0f;
|
||||
GradientColorIntensity = 0.0f;
|
||||
GradientColorSpeed = 2.0f;
|
||||
TextSize = 1.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject)
|
||||
{
|
||||
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (World->GetNetMode() == NM_DedicatedServer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), bIsFilteringBySelection);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection)
|
||||
{
|
||||
return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
AActor* FCogDebugSettings::GetSelection()
|
||||
{
|
||||
return Selection.Get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugSettings::SetSelection(UWorld* World, AActor* Value)
|
||||
{
|
||||
Selection = Value;
|
||||
|
||||
if (World != nullptr && World->GetNetMode() == NM_Client)
|
||||
{
|
||||
if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(*World))
|
||||
{
|
||||
Replicator->Server_SetSelection(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::GetIsFilteringBySelection()
|
||||
{
|
||||
return bIsFilteringBySelection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value)
|
||||
{
|
||||
bIsFilteringBySelection = Value;
|
||||
|
||||
if (World != nullptr && World->GetNetMode() == NM_Client)
|
||||
{
|
||||
if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(*World))
|
||||
{
|
||||
Replicator->Server_SetIsFilteringBySelection(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::GetDebugPersistent(bool bPersistent)
|
||||
{
|
||||
return Persistent && bPersistent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugSettings::GetDebugDuration(bool bPersistent)
|
||||
{
|
||||
return bPersistent == false ? 0.0f : Duration;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugSettings::GetDebugTextDuration(bool bPersistent)
|
||||
{
|
||||
if (bPersistent)
|
||||
{
|
||||
return Persistent ? 100 : Duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int FCogDebugSettings::GetDebugSegments()
|
||||
{
|
||||
return Segments;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
int FCogDebugSettings::GetCircleSegments()
|
||||
{
|
||||
return (Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugSettings::GetDebugThickness(float InThickness)
|
||||
{
|
||||
return (Thickness + InThickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugSettings::GetDebugServerThickness(float InThickness)
|
||||
{
|
||||
return (ServerThickness + InThickness);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
uint8 FCogDebugSettings::GetDebugDepthPriority(float InDepthPriority)
|
||||
{
|
||||
return (DepthPriority + InDepthPriority);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent)
|
||||
{
|
||||
if (bPersistent == false)
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
|
||||
const float Time = World->GetTimeSeconds();
|
||||
const FLinearColor BaseColor(Color);
|
||||
FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV();
|
||||
|
||||
ComplementaryColor.R = ComplementaryColor.R - 180.0f;
|
||||
if (ComplementaryColor.R < 0.0f)
|
||||
{
|
||||
ComplementaryColor.R = 360.0f - ComplementaryColor.R;
|
||||
}
|
||||
|
||||
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
|
||||
|
||||
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(GradientColorSpeed * Time));
|
||||
const FLinearColor FBlendColor = BaseColor * (1.0f - FCogDebugSettings::GradientColorIntensity) + GradientColor * GradientColorIntensity;
|
||||
return FBlendColor.ToFColor(true);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FColor FCogDebugSettings::ModulateServerColor(const FColor& Color)
|
||||
{
|
||||
FColor ServerColor(
|
||||
Color.R * ServerColorMultiplier,
|
||||
Color.G * ServerColorMultiplier,
|
||||
Color.B * ServerColorMultiplier,
|
||||
Color.A);
|
||||
|
||||
return ServerColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogDebugSettings::IsSecondarySkeletonBone(FName BoneName)
|
||||
{
|
||||
FString BoneString = BoneName.ToString().ToLower();
|
||||
|
||||
for (const FString& Wildcard : SecondaryBoneWildcards)
|
||||
{
|
||||
if (BoneString.MatchesWildcard(Wildcard))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -31,11 +31,11 @@ void FCogDebugShape::DrawPoint(UWorld* World) const
|
||||
DrawDebugPoint(
|
||||
World,
|
||||
ShapeData[0],
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::GetDebugServerThickness(Thickness),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -70,11 +70,11 @@ void FCogDebugShape::DrawSegment(UWorld* World) const
|
||||
World,
|
||||
ShapeData[0],
|
||||
ShapeData[1],
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -111,11 +111,11 @@ void FCogDebugShape::DrawArrow(UWorld* World) const
|
||||
ShapeData[0],
|
||||
ShapeData[1],
|
||||
ShapeData[2].X,
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -152,10 +152,10 @@ void FCogDebugShape::DrawAxes(UWorld* World) const
|
||||
ShapeData[0],
|
||||
FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z),
|
||||
ShapeData[2].X,
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -192,11 +192,11 @@ void FCogDebugShape::DrawBox(UWorld* World) const
|
||||
ShapeData[0],
|
||||
ShapeData[1],
|
||||
FQuat(FRotator(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z)),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -231,10 +231,10 @@ void FCogDebugShape::DrawSolidBox(UWorld* World) const
|
||||
ShapeData[0],
|
||||
ShapeData[1],
|
||||
FQuat(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z)),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -274,12 +274,12 @@ void FCogDebugShape::DrawCone(UWorld* World) const
|
||||
ShapeData[2].X,
|
||||
DefaultConeAngle,
|
||||
DefaultConeAngle,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::GetCircleSegments(),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -314,12 +314,12 @@ void FCogDebugShape::DrawCylinder(UWorld* World) const
|
||||
ShapeData[0] - FVector(0, 0, ShapeData[1].Z),
|
||||
ShapeData[0] + FVector(0, 0, ShapeData[1].Z),
|
||||
ShapeData[1].X,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::GetCircleSegments(),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -355,12 +355,12 @@ void FCogDebugShape::DrawCicle(UWorld* World) const
|
||||
World,
|
||||
FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]),
|
||||
ShapeData[2].X,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness),
|
||||
FCogDebug::GetCircleSegments(),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness),
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -399,12 +399,12 @@ void FCogDebugShape::DrawCicleArc(UWorld* World) const
|
||||
ShapeData[2].X,
|
||||
ShapeData[2].Y,
|
||||
ShapeData[2].Z,
|
||||
FCogDebugSettings::GetDebugSegments(),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::GetDebugSegments(),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -442,11 +442,11 @@ void FCogDebugShape::DrawCapsule(UWorld* World) const
|
||||
ShapeData[1].Y,
|
||||
ShapeData[1].X,
|
||||
FQuat::MakeFromEuler(ShapeData[2]),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -484,12 +484,12 @@ void FCogDebugShape::DrawFlatCapsule(UWorld* World) const
|
||||
FVector2D(ShapeData[1].X, ShapeData[1].Y),
|
||||
ShapeData[2].X,
|
||||
ShapeData[2].Y,
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::GetCircleSegments(),
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -524,20 +524,20 @@ void FCogDebugShape::DrawBone(UWorld* World) const
|
||||
World,
|
||||
ShapeData[0],
|
||||
ShapeData[1],
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority),
|
||||
FCogDebug::GetDebugServerThickness(Thickness));
|
||||
|
||||
DrawDebugPoint(
|
||||
World,
|
||||
ShapeData[0],
|
||||
FCogDebugSettings::GetDebugServerThickness(Thickness) + 4.0f,
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::GetDebugServerThickness(Thickness) + 4.0f,
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
@@ -578,10 +578,10 @@ void FCogDebugShape::DrawPolygon(UWorld* World) const
|
||||
World,
|
||||
ShapeData,
|
||||
Indices,
|
||||
FCogDebugSettings::ModulateServerColor(Color),
|
||||
FCogDebugSettings::GetDebugPersistent(bPersistent),
|
||||
FCogDebugSettings::GetDebugDuration(bPersistent),
|
||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||
FCogDebug::ModulateServerColor(Color),
|
||||
FCogDebug::GetDebugPersistent(bPersistent),
|
||||
FCogDebug::GetDebugDuration(bPersistent),
|
||||
FCogDebug::GetDebugDepthPriority(DepthPriority));
|
||||
}
|
||||
|
||||
#endif //ENABLE_COG
|
||||
|
||||
@@ -0,0 +1,411 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
#include "CogDebug.generated.h"
|
||||
|
||||
struct FCogDebugDrawSweepParams;
|
||||
struct FCogDebugDrawLineTraceParams;
|
||||
struct FCogDebugDrawOverlapParams;
|
||||
class UObject;
|
||||
class AActor;
|
||||
class UWorld;
|
||||
|
||||
USTRUCT()
|
||||
struct FCogDebugSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bIsFilteringBySelection = 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)
|
||||
float GradientColorIntensity = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GradientColorSpeed = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float TextSize = 1.0f;
|
||||
|
||||
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 = 50.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 = 50.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GizmoScaleBoxExtent = 2.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*",
|
||||
};
|
||||
};
|
||||
|
||||
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(UWorld* World, AActor* Value);
|
||||
|
||||
static bool GetIsFilteringBySelection();
|
||||
|
||||
static void SetIsFilteringBySelection(UWorld* World, bool Value);
|
||||
|
||||
static bool GetDebugPersistent(bool bPersistent);
|
||||
|
||||
static float GetDebugDuration(bool bPersistent);
|
||||
|
||||
static float GetDebugTextDuration(bool bPersistent);
|
||||
|
||||
static int GetCircleSegments();
|
||||
|
||||
static int GetDebugSegments();
|
||||
|
||||
static float GetDebugThickness(float Thickness);
|
||||
|
||||
static float GetDebugServerThickness(float Thickness);
|
||||
|
||||
static uint8 GetDebugDepthPriority(float DepthPriority);
|
||||
|
||||
static FColor ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent = true);
|
||||
|
||||
static FColor ModulateServerColor(const FColor& Color);
|
||||
|
||||
static bool IsSecondarySkeletonBone(FName BoneName);
|
||||
|
||||
static void Reset();
|
||||
|
||||
static void GetDebugChannelColors(FColor ChannelColors[ECC_MAX]);
|
||||
|
||||
static void GetDebugDrawOverlapSettings(FCogDebugDrawOverlapParams& Params);
|
||||
|
||||
static void GetDebugDrawLineTraceSettings(FCogDebugDrawLineTraceParams& Params);
|
||||
|
||||
static void GetDebugDrawSweepSettings(FCogDebugDrawSweepParams& Params);
|
||||
|
||||
static FCogDebugSettings Settings;
|
||||
|
||||
private:
|
||||
|
||||
static bool IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection);
|
||||
|
||||
static TWeakObjectPtr<AActor> Selection;
|
||||
};
|
||||
@@ -8,36 +8,67 @@ class UWorld;
|
||||
struct FHitResult;
|
||||
class AActor;
|
||||
|
||||
struct FCogDebugDrawOverlapParams
|
||||
{
|
||||
FColor HitColor = FColor::Green;
|
||||
FColor NoHitColor = FColor::Red;
|
||||
bool DrawHitPrimitives = true;
|
||||
bool DrawHitPrimitiveActorsName = false;
|
||||
bool HitPrimitiveActorsNameShadow = true;
|
||||
float HitPrimitiveActorsNameSize = 1.0f;
|
||||
bool Persistent = false;
|
||||
float LifeTime = 0.0f;
|
||||
uint8 DepthPriority = 0;
|
||||
float Thickness = 0.0f;
|
||||
FColor ChannelColors[ECC_MAX];
|
||||
};
|
||||
|
||||
struct FCogDebugDrawLineTraceParams : public FCogDebugDrawOverlapParams
|
||||
{
|
||||
bool DrawHitLocation = true;
|
||||
bool DrawHitImpactPoints = true;
|
||||
bool DrawHitNormals = true;
|
||||
bool DrawHitImpactNormals = true;
|
||||
float HitPointSize = 5.0f;
|
||||
FColor NormalColor = FColor::Yellow;
|
||||
FColor ImpactNormalColor = FColor::Cyan;
|
||||
};
|
||||
|
||||
struct FCogDebugDrawSweepParams : public FCogDebugDrawLineTraceParams
|
||||
{
|
||||
bool DrawHitShapes = true;
|
||||
};
|
||||
|
||||
class COGDEBUG_API FCogDebugDrawHelper
|
||||
{
|
||||
public:
|
||||
|
||||
static void DrawArc(const UWorld* InWorld, const FMatrix& Matrix, const float InnterRadius, const float OuterRadius, const float ArcAngle, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
static void DrawArc(const UWorld* World, const FMatrix& Matrix, const float InnterRadius, const float OuterRadius, const float AngleStart, const float AngleEnd, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawSphere(const UWorld* InWorld, const FVector& Center, const float Radius, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
static void DrawArc(const UWorld* World, const FMatrix& Matrix, const float InnterRadius, const float OuterRadius, const float ArcAngle, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawSphere(const UWorld* World, const FVector& Center, const float Radius, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawFrustum(const UWorld* World, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawFlatCapsule(const UWorld* InWorld, const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const float Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.0f, const uint8 DepthPriority = 0, const float Thickness = 0.0f);
|
||||
static void DrawFlatCapsule(const UWorld* World, const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const float Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.0f, const uint8 DepthPriority = 0, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawRaycastSingle(const UWorld* World, const FVector& Start, const FVector& End, const EDrawDebugTrace::Type DrawType, const bool bHit, const FHitResult& Hit, const float HitSize, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration, const uint8 DepthPriority = 0);
|
||||
static void DrawQuad(const UWorld* World, const FVector& Position, const FQuat& Rotation, const FVector2D& Extents, const FColor& Color, bool bPersistent = false, float LifeTime = -1, uint8 DepthPriority = 0, const float Thickness = 0.0f);
|
||||
|
||||
static void DrawSolidQuad(const UWorld* World, const FVector& Position, const FQuat& Rotation, const FVector2D& Extents, const FColor& Color, bool bPersistent = false, float LifeTime = -1, uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawShape(const UWorld* World, const FCollisionShape& InShape, const FVector& Location, const FQuat& Rotation, const FVector& Scale, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness);
|
||||
|
||||
static void DrawPrimitiveComponent(const UPrimitiveComponent& PrimitiveComponent, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness);
|
||||
|
||||
static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
|
||||
|
||||
static void DrawSphereOverlapMulti(const UWorld* World, const FVector& Position, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bOverlap, const TArray<AActor*>& OutActors, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
|
||||
|
||||
static void DrawSphereOverlapSingle(const UWorld* World, const FVector& Position, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration = -1.f, const uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawCapsuleCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
|
||||
|
||||
static void DrawCapsuleCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration = -1.f, const uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawSphereCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
|
||||
|
||||
static void DrawSphereCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float LifeTime = -1.f, const uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawHitResults(const UWorld* World, const TArray<FHitResult>& OutHits, const EDrawDebugTrace::Type DrawType, const bool ShowHitIndex, const float HitSize, const FLinearColor HitColor, const float DrawDuration, const uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawHitResultsDiscarded(const UWorld* World, const TArray<FHitResult>& AllHits, const TArray<FHitResult>& KeptHits, const EDrawDebugTrace::Type DrawType, const float HitSize, const FLinearColor DrawColor, const float DrawDuration, const uint8 DepthPriority = 0);
|
||||
|
||||
static void DrawHitResult(const UWorld* World, const FHitResult& Hit, const int HitIndex, const EDrawDebugTrace::Type DrawType, const bool ShowHitIndex, const float HitSize, const FLinearColor HitColor, const float DrawDuration, const uint8 DepthPriority = 0);
|
||||
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 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);
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugGizmo.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM(Flags)
|
||||
enum class ECogDebug_GizmoFlags : uint8
|
||||
{
|
||||
None = 0,
|
||||
NoTranslationAxis = 1 << 0,
|
||||
NoTranslationPlane = 1 << 1,
|
||||
NoRotation = 1 << 2,
|
||||
NoScaleAxis = 1 << 3,
|
||||
NoScaleUniform = 1 << 4,
|
||||
|
||||
NoTranslation = NoTranslationAxis | NoTranslationPlane,
|
||||
NoScale = NoScaleAxis | NoScaleUniform,
|
||||
};
|
||||
ENUM_CLASS_FLAGS(ECogDebug_GizmoFlags);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogDebug_GizmoType : uint8
|
||||
{
|
||||
MoveAxis,
|
||||
MovePlane,
|
||||
Rotate,
|
||||
ScaleAxis,
|
||||
ScaleUniform,
|
||||
MAX,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogDebug_GizmoAxis : uint8
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
MAX,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogDebug_GizmoElementType : uint8
|
||||
{
|
||||
MoveX,
|
||||
MoveY,
|
||||
MoveZ,
|
||||
MoveXY,
|
||||
MoveXZ,
|
||||
MoveYZ,
|
||||
RotateX,
|
||||
RotateY,
|
||||
RotateZ,
|
||||
ScaleXYZ,
|
||||
ScaleX,
|
||||
ScaleY,
|
||||
ScaleZ,
|
||||
MAX,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct FCogDebug_GizmoElement
|
||||
{
|
||||
ECogDebug_GizmoType Type;
|
||||
ECogDebug_GizmoAxis AxisType;
|
||||
FVector Axis;
|
||||
FVector Direction;
|
||||
FQuat Rotation;
|
||||
FVector Location;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebug_Gizmo
|
||||
{
|
||||
bool Draw(const char* Id, const APlayerController& InPlayerController, FTransform& InOutTransform, ECogDebug_GizmoFlags Flags = ECogDebug_GizmoFlags::None);
|
||||
|
||||
ECogDebug_GizmoElementType DraggedElementType = ECogDebug_GizmoElementType::MAX;
|
||||
FVector2D CursorOffset = FVector2D::ZeroVector;
|
||||
FTransform InitialTransform = FTransform::Identity;
|
||||
};
|
||||
@@ -1,88 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
|
||||
class UObject;
|
||||
class AActor;
|
||||
class UWorld;
|
||||
|
||||
struct COGDEBUG_API FCogDebugSettings
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
static bool IsDebugActiveForObject(const UObject* WorldContextObject);
|
||||
|
||||
static bool IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection);
|
||||
|
||||
static AActor* GetSelection();
|
||||
|
||||
static void SetSelection(UWorld* World, AActor* Value);
|
||||
|
||||
static bool GetIsFilteringBySelection();
|
||||
|
||||
static void SetIsFilteringBySelection(UWorld* World, bool Value);
|
||||
|
||||
static bool GetDebugPersistent(bool bPersistent);
|
||||
|
||||
static float GetDebugDuration(bool bPersistent);
|
||||
|
||||
static float GetDebugTextDuration(bool bPersistent);
|
||||
|
||||
static int GetCircleSegments();
|
||||
|
||||
static int GetDebugSegments();
|
||||
|
||||
static float GetDebugThickness(float Thickness);
|
||||
|
||||
static float GetDebugServerThickness(float Thickness);
|
||||
|
||||
static uint8 GetDebugDepthPriority(float DepthPriority);
|
||||
|
||||
static FColor ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent = true);
|
||||
|
||||
static FColor ModulateServerColor(const FColor& Color);
|
||||
|
||||
static bool IsSecondarySkeletonBone(FName BoneName);
|
||||
|
||||
static void Reset();
|
||||
|
||||
static bool Persistent;
|
||||
|
||||
static bool TextShadow;
|
||||
|
||||
static bool Fade2D;
|
||||
|
||||
static float Duration;
|
||||
|
||||
static int DepthPriority;
|
||||
|
||||
static int Segments;
|
||||
|
||||
static float Thickness;
|
||||
|
||||
static float ServerThickness;
|
||||
|
||||
static float ServerColorMultiplier;
|
||||
|
||||
static float ArrowSize;
|
||||
|
||||
static float AxesScale;
|
||||
|
||||
static float GradientColorIntensity;
|
||||
|
||||
static float GradientColorSpeed;
|
||||
|
||||
static float TextSize;
|
||||
|
||||
static TArray<FString> SecondaryBoneWildcards;
|
||||
|
||||
private:
|
||||
|
||||
static bool IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection);
|
||||
|
||||
static TWeakObjectPtr<AActor> Selection;
|
||||
|
||||
static bool bIsFilteringBySelection;
|
||||
};
|
||||
@@ -2,53 +2,53 @@ using UnrealBuildTool;
|
||||
|
||||
public class CogEngine : ModuleRules
|
||||
{
|
||||
public CogEngine(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
public CogEngine(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CogCommon",
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CogDebug",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CogCommon",
|
||||
"CogImgui",
|
||||
"CogWindow",
|
||||
"Core",
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
"NetCore",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
#include "CogEngineCollisionTester.h"
|
||||
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogDebug.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ACogEngineCollisionTester::ACogEngineCollisionTester(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
|
||||
StartComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Start"));
|
||||
RootComponent = StartComponent;
|
||||
|
||||
EndComponent = CreateDefaultSubobject<USceneComponent>(TEXT("End"));
|
||||
EndComponent->SetupAttachment(RootComponent);
|
||||
EndComponent->SetRelativeLocation(FVector(1000, 0, 0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool ACogEngineCollisionTester::ShouldTickIfViewportsOnly() const
|
||||
{
|
||||
if (GetWorld() != nullptr && GetWorld()->WorldType == EWorldType::Editor && TickInEditor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogEngineCollisionTester::Tick(float DeltaSeconds)
|
||||
{
|
||||
Query();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogEngineCollisionTester::Query() const
|
||||
{
|
||||
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);
|
||||
|
||||
const FCollisionResponseTemplate* Profile = UCollisionProfile::Get()->GetProfileByIndex(ProfileIndex);
|
||||
const FName ProfileName = Profile != nullptr ? Profile->Name : FName();
|
||||
|
||||
FCollisionShape QueryShape;
|
||||
if (Type == ECogEngine_CollisionQueryType::Overlap || Type == ECogEngine_CollisionQueryType::Sweep)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
HasHits = GetWorld()->OverlapMultiByObjectType(Overlaps, QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::Profile:
|
||||
{
|
||||
HasHits = GetWorld()->OverlapMultiByProfile(Overlaps, QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugDrawOverlapParams DrawParams;
|
||||
FCogDebug::GetDebugDrawOverlapSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawOverlap(GetWorld(), QueryShape, QueryStart, QueryRotation, Overlaps, DrawParams);
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugDrawLineTraceParams DrawParams;
|
||||
FCogDebug::GetDebugDrawLineTraceSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawLineTrace(GetWorld(), QueryStart, QueryEnd, HasHits, Hits, DrawParams);
|
||||
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;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryBy::ObjectType:
|
||||
{
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery;
|
||||
|
||||
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::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;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugDrawSweepParams DrawParams;
|
||||
FCogDebug::GetDebugDrawSweepSettings(DrawParams);
|
||||
FCogDebugDrawHelper::DrawSweep(GetWorld(), QueryShape, QueryStart, QueryEnd, QueryRotation, HasHits, Hits, DrawParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
#include "CogEngineWindow_CollisionTester.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "imgui.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionTester::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_CollisionTester>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionTester::RenderHelp()
|
||||
{
|
||||
ImGui::Text("This window is used to test a collision query.");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionTester::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionTester::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
ACogEngineCollisionTester* CollisionTester = Cast<ACogEngineCollisionTester>(GetSelection());
|
||||
|
||||
//-------------------------------------------------
|
||||
// Menu
|
||||
//-------------------------------------------------
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
|
||||
|
||||
if (ImGui::ArrowButton("SelectPrev", ImGuiDir_Left))
|
||||
{
|
||||
}
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::SetTooltip("Select previous collision tester");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::ArrowButton("SelectNext", ImGuiDir_Right))
|
||||
{
|
||||
}
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::SetTooltip("Select next collision tester");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(1);
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Spawn"))
|
||||
{
|
||||
const FActorSpawnParameters SpawnInfo;
|
||||
const FTransform Transform = GetSelection() ? GetSelection()->GetActorTransform() : FTransform::Identity;
|
||||
ACogEngineCollisionTester* Actor = GetWorld()->SpawnActor<ACogEngineCollisionTester>(ACogEngineCollisionTester::StaticClass(), Transform, SpawnInfo);
|
||||
FCogDebug::SetSelection(GetWorld(), Actor);
|
||||
}
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::SetTooltip("Spawn a new collision tester");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
const bool Disable = CollisionTester == nullptr;
|
||||
if (Disable)
|
||||
{
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
if (ImGui::MenuItem("Delete"))
|
||||
{
|
||||
GetWorld()->DestroyActor(CollisionTester);
|
||||
CollisionTester = nullptr;
|
||||
}
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::SetTooltip("Delete selected collision tester");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (Disable)
|
||||
{
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
if (CollisionTester == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Spawn or select a Collision Tester actor");
|
||||
return;
|
||||
}
|
||||
|
||||
const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
|
||||
if (CollisionProfile == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("No CollisionProfile");
|
||||
return;
|
||||
}
|
||||
|
||||
if (const APlayerController* LocalPlayerController = GetLocalPlayerController())
|
||||
{
|
||||
FTransform Transform = CollisionTester->EndComponent->GetComponentTransform();
|
||||
if (EndGizmo.Draw("CollisionTesterEndGizmo", *LocalPlayerController, Transform, ECogDebug_GizmoFlags::NoRotation | ECogDebug_GizmoFlags::NoScale))
|
||||
{
|
||||
CollisionTester->EndComponent->SetWorldTransform(Transform);
|
||||
}
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::ComboboxEnum("Type", CollisionTester->Type);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::ComboboxEnum("Mode", CollisionTester->Mode);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::ComboboxEnum("By", CollisionTester->By);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Channel
|
||||
//-------------------------------------------------
|
||||
if (CollisionTester->By == ECogEngine_CollisionQueryBy::Channel)
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ECollisionChannel Channel = CollisionTester->Channel.GetValue();
|
||||
if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel))
|
||||
{
|
||||
CollisionTester->Channel = Channel;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------
|
||||
// Profile
|
||||
//-------------------------------------------------
|
||||
else if (CollisionTester->By == ECogEngine_CollisionQueryBy::Profile)
|
||||
{
|
||||
const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(CollisionTester->ProfileIndex);
|
||||
const FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*SelectedProfileName.ToString()), ImGuiComboFlags_HeightLargest))
|
||||
{
|
||||
for (int i = 0; i < CollisionProfile->GetNumOfProfiles(); ++i)
|
||||
{
|
||||
const FCollisionResponseTemplate* Profile = CollisionProfile->GetProfileByIndex(i);
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Profile->Name.ToString()), false))
|
||||
{
|
||||
CollisionTester->ProfileIndex = i;
|
||||
CollisionTester->ObjectTypesToQuery = 0;
|
||||
SelectedProfile = CollisionProfile->GetProfileByIndex(CollisionTester->ProfileIndex);
|
||||
|
||||
if (Profile->CollisionEnabled != ECollisionEnabled::NoCollision)
|
||||
{
|
||||
for (int j = 0; j < ECC_MAX; ++j)
|
||||
{
|
||||
const ECollisionResponse Response = Profile->ResponseToChannels.GetResponse((ECollisionChannel)j);
|
||||
if (Response != ECR_Ignore)
|
||||
{
|
||||
CollisionTester->ObjectTypesToQuery |= ECC_TO_BITFIELD(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Complex", &CollisionTester->TraceComplex);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Shape
|
||||
//-------------------------------------------------
|
||||
|
||||
if (CollisionTester->Type != ECogEngine_CollisionQueryType::LineTrace)
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::ComboboxEnum("Shape", CollisionTester->Shape);
|
||||
|
||||
switch (CollisionTester->Shape)
|
||||
{
|
||||
case ECogEngine_CollisionQueryShape::Sphere:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogImguiHelper::DragDouble("Sphere Radius", &CollisionTester->ShapeExtent.X, 1.0f, 0, FLT_MAX, "%.1f");
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryShape::Box:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogImguiHelper::DragFVector("Box Extent", CollisionTester->ShapeExtent, 1.0f, 0, FLT_MAX, "%.1f");
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryShape::Capsule:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogImguiHelper::DragDouble("Capsule Radius", &CollisionTester->ShapeExtent.X, 1.0f, 0, FLT_MAX, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogImguiHelper::DragDouble("Capsule Half Height", &CollisionTester->ShapeExtent.Z, 1.0f, 0, FLT_MAX, "%.1f");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
//-------------------------------------------------
|
||||
// Channels
|
||||
//-------------------------------------------------
|
||||
if (CollisionTester->By == ECogEngine_CollisionQueryBy::Profile)
|
||||
{
|
||||
ImGui::BeginDisabled();
|
||||
FCogWindowWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery);
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
else if (CollisionTester->By == ECogEngine_CollisionQueryBy::ObjectType)
|
||||
{
|
||||
FCogWindowWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
#include "CogEngineWindow_CollisionViewer.h"
|
||||
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogEngineCollisionTester.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Engine/World.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionViewer::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_CollisionViewer>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionViewer::RenderHelp()
|
||||
{
|
||||
ImGui::Text("This window is used to inspect collisions by performing a collision query with the selected channels. "
|
||||
"The query can be configured in the options. "
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionViewer::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionViewer::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
const APlayerController* PlayerController = GetLocalPlayerController();
|
||||
if (PlayerController == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Profile
|
||||
//-------------------------------------------------
|
||||
|
||||
const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
|
||||
if (CollisionProfile == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Menu
|
||||
//-------------------------------------------------
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
//-------------------------------------------------
|
||||
// Query Mode
|
||||
//-------------------------------------------------
|
||||
ImGui::Combo("Query", &Config->QueryType,
|
||||
"Sphere\0"
|
||||
"Raycast Crosshair\0"
|
||||
"Raycast Cursor\0"
|
||||
"\0"
|
||||
);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Distance
|
||||
//-------------------------------------------------
|
||||
ImGui::SliderFloat("Distance", &Config->QueryDistance, 0.0f, 20000.0f, "%0.f");
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Thickness
|
||||
//-------------------------------------------------
|
||||
if (Config->QueryType == 1 || Config->QueryType == 2)
|
||||
{
|
||||
ImGui::SliderFloat("Thickness", &Config->QueryThickness, 0.0f, 1000.0f, "%0.f");
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Use Complex Collisions
|
||||
//-------------------------------------------------
|
||||
ImGui::Checkbox("Use Complex Collisions", &Config->UseComplexCollisions);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Show Names
|
||||
//-------------------------------------------------
|
||||
ImGui::Checkbox("Show Actors Names", &Config->ShowActorsNames);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Profile
|
||||
//-------------------------------------------------
|
||||
const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex);
|
||||
FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom");
|
||||
|
||||
if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*SelectedProfileName.ToString()), ImGuiComboFlags_HeightLargest))
|
||||
{
|
||||
for (int i = 0; i < CollisionProfile->GetNumOfProfiles(); ++i)
|
||||
{
|
||||
const FCollisionResponseTemplate* Profile = CollisionProfile->GetProfileByIndex(i);
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Profile->Name.ToString()), false))
|
||||
{
|
||||
Config->ProfileIndex = i;
|
||||
Config->ObjectTypesToQuery = 0;
|
||||
SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex);
|
||||
|
||||
if (Profile->CollisionEnabled != ECollisionEnabled::NoCollision)
|
||||
{
|
||||
for (int j = 0; j < ECC_MAX; ++j)
|
||||
{
|
||||
ECollisionResponse Response = Profile->ResponseToChannels.GetResponse((ECollisionChannel)j);
|
||||
if (Response != ECR_Ignore)
|
||||
{
|
||||
Config->ObjectTypesToQuery |= ECC_TO_BITFIELD(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
FCogWindowWidgets::CollisionProfileChannels(Config->ObjectTypesToQuery);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Perform Query
|
||||
//-------------------------------------------------
|
||||
if (Config->ObjectTypesToQuery == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FVector QueryStart;
|
||||
FVector QueryEnd;
|
||||
float QueryRadius = 0.0f;
|
||||
|
||||
switch (Config->QueryType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
FVector Location = FVector::ZeroVector;
|
||||
if (APawn* Pawn = PlayerController->GetPawn())
|
||||
{
|
||||
Location = Pawn->GetActorLocation();
|
||||
}
|
||||
|
||||
QueryRadius = Config->QueryDistance;
|
||||
QueryStart = Location;
|
||||
QueryEnd = QueryStart;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
FVector Location;
|
||||
FRotator Rotation;
|
||||
PlayerController->GetPlayerViewPoint(Location, Rotation);
|
||||
QueryStart = Location;
|
||||
QueryEnd = QueryStart + Rotation.Vector() * Config->QueryDistance;
|
||||
QueryRadius = Config->QueryThickness;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
FVector Direction;
|
||||
UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToFVector2D(ImGui::GetMousePos()), QueryStart, Direction);
|
||||
QueryEnd = QueryStart + Direction * Config->QueryDistance;
|
||||
QueryRadius = Config->QueryThickness;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const FName TraceTag(TEXT("FCogWindow_Collision"));
|
||||
FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), Config->UseComplexCollisions);
|
||||
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = Config->ObjectTypesToQuery;
|
||||
|
||||
FCollisionShape QueryShape;
|
||||
QueryShape.SetSphere(QueryRadius);
|
||||
|
||||
TArray<FHitResult> HitResults;
|
||||
UWorld* World = GetWorld();
|
||||
World->SweepMultiByObjectType(
|
||||
HitResults,
|
||||
QueryStart,
|
||||
QueryEnd,
|
||||
FQuat::Identity,
|
||||
QueryObjectParams,
|
||||
QueryShape,
|
||||
QueryParams);
|
||||
|
||||
FCogDebugDrawSweepParams DrawParams;
|
||||
FCogDebug::GetDebugDrawSweepSettings(DrawParams);
|
||||
DrawParams.DrawHitNormals = false;
|
||||
DrawParams.DrawHitImpactNormals = false;
|
||||
DrawParams.DrawHitImpactPoints = false;
|
||||
DrawParams.DrawHitLocation = false;
|
||||
DrawParams.DrawHitPrimitives = true;
|
||||
DrawParams.DrawHitPrimitiveActorsName = Config->ShowActorsNames;
|
||||
FCogDebugDrawHelper::DrawSweep(GetWorld(), QueryShape, QueryStart, QueryEnd, FQuat::Identity, false, HitResults, DrawParams);
|
||||
}
|
||||
@@ -1,409 +0,0 @@
|
||||
#include "CogEngineWindow_Collisions.h"
|
||||
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Engine/World.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Collisions::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
|
||||
SetAsset(GetAsset<UCogEngineDataAsset>());
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_Collisions>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Collisions::RenderHelp()
|
||||
{
|
||||
ImGui::Text("This window is used to inspect collisions by performing a collision query with the selected channels. "
|
||||
"The query can be configured in the options. "
|
||||
"The displayed collision channels can be configured in the '%s' data asset. "
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Collisions::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Collisions::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
const APlayerController* PlayerController = GetLocalPlayerController();
|
||||
if (PlayerController == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Profile
|
||||
//-------------------------------------------------
|
||||
|
||||
const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
|
||||
if (CollisionProfile == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Menu
|
||||
//-------------------------------------------------
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
//-------------------------------------------------
|
||||
// Query Mode
|
||||
//-------------------------------------------------
|
||||
ImGui::Combo("Query", &Config->QueryType,
|
||||
"Sphere\0"
|
||||
"Raycast Crosshair\0"
|
||||
"Raycast Cursor\0"
|
||||
"\0"
|
||||
);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Distance
|
||||
//-------------------------------------------------
|
||||
ImGui::SliderFloat("Distance", &Config->QueryDistance, 0.0f, 20000.0f, "%0.f");
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Thickness
|
||||
//-------------------------------------------------
|
||||
if (Config->QueryType == 1 || Config->QueryType == 2)
|
||||
{
|
||||
ImGui::SliderFloat("Thickness", &Config->QueryThickness, 0.0f, 1000.0f, "%0.f");
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Use Complex Collisions
|
||||
//-------------------------------------------------
|
||||
ImGui::Checkbox("Use Complex Collisions", &Config->UseComplexCollisions);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Show Names
|
||||
//-------------------------------------------------
|
||||
ImGui::Checkbox("Show Actors Names", &Config->ShowActorsNames);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Show Query
|
||||
//-------------------------------------------------
|
||||
ImGui::Checkbox("Show Query", &Config->ShowQuery);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Profile
|
||||
//-------------------------------------------------
|
||||
const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex);
|
||||
FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom");
|
||||
|
||||
if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*SelectedProfileName.ToString()), ImGuiComboFlags_HeightLargest))
|
||||
{
|
||||
for (int i = 0; i < CollisionProfile->GetNumOfProfiles(); ++i)
|
||||
{
|
||||
const FCollisionResponseTemplate* Profile = CollisionProfile->GetProfileByIndex(i);
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Profile->Name.ToString()), false))
|
||||
{
|
||||
Config->ProfileIndex = i;
|
||||
Config->ObjectTypesToQuery = 0;
|
||||
SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex);
|
||||
|
||||
if (Profile->CollisionEnabled != ECollisionEnabled::NoCollision)
|
||||
{
|
||||
for (int j = 0; j < ECC_MAX; ++j)
|
||||
{
|
||||
ECollisionResponse Response = Profile->ResponseToChannels.GetResponse((ECollisionChannel)j);
|
||||
if (Response != ECR_Ignore)
|
||||
{
|
||||
Config->ObjectTypesToQuery |= ECC_TO_BITFIELD(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
//-------------------------------------------------
|
||||
// Query Filtering
|
||||
//-------------------------------------------------
|
||||
for (int ChannelIndex = 0; ChannelIndex < (int32)ECC_MAX; ++ChannelIndex)
|
||||
{
|
||||
const FChannel& Channel = Channels[ChannelIndex];
|
||||
if (Channel.IsValid == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::PushID(ChannelIndex);
|
||||
|
||||
ImColor Color = FCogImguiHelper::ToImColor(Channel.Color);
|
||||
ImGui::ColorEdit4("Color", (float*)&Color.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
|
||||
ImGui::SameLine();
|
||||
|
||||
bool IsCollisionActive = (Config->ObjectTypesToQuery & ECC_TO_BITFIELD(ChannelIndex)) > 0;
|
||||
const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex);
|
||||
if (ImGui::Checkbox(TCHAR_TO_ANSI(*ChannelName.ToString()), &IsCollisionActive))
|
||||
{
|
||||
if (IsCollisionActive)
|
||||
{
|
||||
Config->ObjectTypesToQuery |= ECC_TO_BITFIELD(ChannelIndex);
|
||||
Config->ProfileIndex = INDEX_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Config->ObjectTypesToQuery &= ~ECC_TO_BITFIELD(ChannelIndex);
|
||||
Config->ProfileIndex = INDEX_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Perform Query
|
||||
//-------------------------------------------------
|
||||
if (Config->ObjectTypesToQuery == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FVector QueryStart;
|
||||
FVector QueryEnd;
|
||||
float QueryRadius = 0.0f;
|
||||
|
||||
switch (Config->QueryType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
FVector Location = FVector::ZeroVector;
|
||||
if (APawn* Pawn = PlayerController->GetPawn())
|
||||
{
|
||||
Location = Pawn->GetActorLocation();
|
||||
}
|
||||
|
||||
QueryRadius = Config->QueryDistance;
|
||||
QueryStart = Location;
|
||||
QueryEnd = QueryStart;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
FVector Location;
|
||||
FRotator Rotation;
|
||||
PlayerController->GetPlayerViewPoint(Location, Rotation);
|
||||
QueryStart = Location;
|
||||
QueryEnd = QueryStart + Rotation.Vector() * Config->QueryDistance;
|
||||
QueryRadius = Config->QueryThickness;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
FVector Direction;
|
||||
UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToFVector2D(ImGui::GetMousePos()), QueryStart, Direction);
|
||||
QueryEnd = QueryStart + Direction * Config->QueryDistance;
|
||||
QueryRadius = Config->QueryThickness;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const FName TraceTag(TEXT("FCogWindow_Collision"));
|
||||
FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), Config->UseComplexCollisions);
|
||||
|
||||
FCollisionObjectQueryParams QueryObjectParams;
|
||||
QueryObjectParams.ObjectTypesToQuery = Config->ObjectTypesToQuery;
|
||||
|
||||
FCollisionShape QueryShape;
|
||||
QueryShape.SetSphere(QueryRadius);
|
||||
|
||||
TArray<FHitResult> QueryHits;
|
||||
UWorld* World = GetWorld();
|
||||
World->SweepMultiByObjectType(
|
||||
QueryHits,
|
||||
QueryStart,
|
||||
QueryEnd,
|
||||
FQuat::Identity,
|
||||
QueryObjectParams,
|
||||
QueryShape,
|
||||
QueryParams);
|
||||
|
||||
if (Config->ShowQuery)
|
||||
{
|
||||
FCogDebugDrawHelper::DrawCapsuleCastMulti(World, QueryStart, QueryEnd, FQuat::Identity, 0.0f, QueryRadius, EDrawDebugTrace::ForOneFrame, false, QueryHits, FLinearColor::White, FLinearColor::Red, FCogDebugSettings::GetDebugDuration(true));
|
||||
}
|
||||
|
||||
TSet<const AActor*> AlreadyDrawnActors;
|
||||
TSet<const UPrimitiveComponent*> AlreadyDrawnComponents;
|
||||
|
||||
for (const FHitResult& HitResult : QueryHits)
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
// Don't draw same primitives multiple times (for bones)
|
||||
//-------------------------------------------------------
|
||||
const UPrimitiveComponent* PrimitiveComponent = HitResult.GetComponent();
|
||||
if (AlreadyDrawnComponents.Contains(PrimitiveComponent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AlreadyDrawnComponents.Add(PrimitiveComponent);
|
||||
|
||||
ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
|
||||
FColor Color = Channels[CollisionObjectType].Color;
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Draw Name
|
||||
//-------------------------------------------------------
|
||||
if (Config->ShowActorsNames)
|
||||
{
|
||||
const AActor* Actor = HitResult.GetActor();
|
||||
if (Actor != nullptr)
|
||||
{
|
||||
if (AlreadyDrawnActors.Contains(Actor) == false)
|
||||
{
|
||||
FColor TextColor = Color.WithAlpha(255);
|
||||
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::TextShadow, FCogDebugSettings::TextSize);
|
||||
AlreadyDrawnActors.Add(Actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Draw Shape
|
||||
//-------------------------------------------------------
|
||||
FCollisionShape Shape = PrimitiveComponent->GetCollisionShape();
|
||||
switch (Shape.ShapeType)
|
||||
{
|
||||
case ECollisionShape::Box:
|
||||
{
|
||||
FVector Location;
|
||||
FVector Extent;
|
||||
FQuat Rotation;
|
||||
|
||||
if (const UBoxComponent* BoxComponent = Cast<UBoxComponent>(PrimitiveComponent))
|
||||
{
|
||||
Location = BoxComponent->GetComponentLocation();
|
||||
Extent = BoxComponent->GetScaledBoxExtent();
|
||||
Rotation = BoxComponent->GetComponentQuat();
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimitiveComponent->Bounds.GetBox().GetCenterAndExtents(Location, Extent);
|
||||
Extent += FVector::OneVector;
|
||||
Rotation = FQuat::Identity;
|
||||
}
|
||||
|
||||
DrawDebugSolidBox(
|
||||
World,
|
||||
Location,
|
||||
Extent,
|
||||
Rotation,
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebugSettings::GetDebugDepthPriority(0));
|
||||
|
||||
DrawDebugBox(
|
||||
World,
|
||||
Location,
|
||||
Extent,
|
||||
Rotation,
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebugSettings::GetDebugDepthPriority(0),
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECollisionShape::Sphere:
|
||||
{
|
||||
if (const USphereComponent* SphereComponent = Cast<USphereComponent>(PrimitiveComponent))
|
||||
{
|
||||
FCogDebugDrawHelper::DrawSphere(
|
||||
World,
|
||||
SphereComponent->GetComponentLocation(),
|
||||
SphereComponent->GetScaledSphereRadius(),
|
||||
FCogDebugSettings::GetCircleSegments(),
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebugSettings::GetDebugDepthPriority(0),
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ECollisionShape::Capsule:
|
||||
{
|
||||
if (const UCapsuleComponent* CapsuleComponent = Cast<UCapsuleComponent>(PrimitiveComponent))
|
||||
{
|
||||
DrawDebugCapsule(World,
|
||||
CapsuleComponent->GetComponentLocation(),
|
||||
CapsuleComponent->GetScaledCapsuleHalfHeight(),
|
||||
CapsuleComponent->GetScaledCapsuleRadius(),
|
||||
CapsuleComponent->GetComponentQuat(),
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
FCogDebugSettings::GetDebugDepthPriority(0),
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Collisions::SetAsset(const UCogEngineDataAsset* Value)
|
||||
{
|
||||
Asset = Value;
|
||||
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (FChannel& Channel : Channels)
|
||||
{
|
||||
Channel.IsValid = false;
|
||||
}
|
||||
|
||||
for (const FCogCollisionChannel& AssetChannel : Asset->Channels)
|
||||
{
|
||||
FChannel& Channel = Channels[(uint8)AssetChannel.Channel];
|
||||
Channel.IsValid = true;
|
||||
Channel.Color = AssetChannel.Color.ToFColor(true);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "CogEngineWindow_DebugSettings.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_DebugSettings::RenderHelp()
|
||||
@@ -21,22 +23,8 @@ void FCogEngineWindow_DebugSettings::Initialize()
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_DebugSettings>();
|
||||
|
||||
FCogDebugSettings::Persistent = Config->Persistent;
|
||||
FCogDebugSettings::TextShadow = Config->TextShadow;
|
||||
FCogDebugSettings::Fade2D = Config->Fade2D;
|
||||
FCogDebugSettings::Duration = Config->Duration;
|
||||
FCogDebugSettings::DepthPriority = Config->DepthPriority;
|
||||
FCogDebugSettings::Segments = Config->Segments;
|
||||
FCogDebugSettings::Thickness = Config->Thickness;
|
||||
FCogDebugSettings::ServerThickness = Config->ServerThickness;
|
||||
FCogDebugSettings::ServerColorMultiplier = Config->ServerColorMultiplier;
|
||||
FCogDebugSettings::ArrowSize = Config->ArrowSize;
|
||||
FCogDebugSettings::AxesScale = Config->AxesScale;
|
||||
FCogDebugSettings::GradientColorIntensity = Config->GradientColorIntensity;
|
||||
FCogDebugSettings::GradientColorSpeed = Config->GradientColorSpeed;
|
||||
FCogDebugSettings::TextSize = Config->TextSize;
|
||||
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection);
|
||||
FCogDebug::Settings = Config->Data;
|
||||
FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -52,20 +40,14 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig()
|
||||
{
|
||||
Super::PreSaveConfig();
|
||||
|
||||
Config->Persistent = FCogDebugSettings::Persistent;
|
||||
Config->TextShadow = FCogDebugSettings::TextShadow;
|
||||
Config->Fade2D = FCogDebugSettings::Fade2D;
|
||||
Config->Duration = FCogDebugSettings::Duration;
|
||||
Config->DepthPriority = FCogDebugSettings::DepthPriority;
|
||||
Config->Segments = FCogDebugSettings::Segments;
|
||||
Config->Thickness = FCogDebugSettings::Thickness;
|
||||
Config->ServerThickness = FCogDebugSettings::ServerThickness;
|
||||
Config->ServerColorMultiplier = FCogDebugSettings::ServerColorMultiplier;
|
||||
Config->ArrowSize = FCogDebugSettings::ArrowSize;
|
||||
Config->AxesScale = FCogDebugSettings::AxesScale;
|
||||
Config->GradientColorIntensity = FCogDebugSettings::GradientColorIntensity;
|
||||
Config->GradientColorSpeed = FCogDebugSettings::GradientColorSpeed;
|
||||
Config->TextSize = FCogDebugSettings::TextSize;
|
||||
Config->Data = FCogDebug::Settings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void RenderCollisionChannelColor(const UCollisionProfile& CollisionProfile, FColor& Color, ECollisionChannel Channel, ImGuiColorEditFlags ColorEditFlags)
|
||||
{
|
||||
const FString ChannelName = CollisionProfile.ReturnChannelNameFromContainerIndex(Channel).ToString();
|
||||
FCogImguiHelper::ColorEdit4(StringCast<ANSICHAR>(*ChannelName).Get(), Color, ColorEditFlags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -75,117 +57,310 @@ void FCogEngineWindow_DebugSettings::RenderContent()
|
||||
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
FCogDebugSettings::Reset();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
{
|
||||
FCogDebug::Reset();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
Config->bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
||||
if (ImGui::Checkbox("Filter by selection", &Config->bIsFilteringBySelection))
|
||||
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
FCogDebugSettings& Settings = FCogDebug::Settings;
|
||||
|
||||
if (ImGui::CollapsingHeader("General", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
|
||||
Config->Data.bIsFilteringBySelection = FCogDebug::GetIsFilteringBySelection();
|
||||
if (ImGui::Checkbox("Filter by selection", &Config->Data.bIsFilteringBySelection))
|
||||
{
|
||||
FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Persistent", &Settings.Persistent);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Make debug draw always persist");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Text Shadow", &Settings.TextShadow);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Show a shadow below debug text.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Fade 2D", &Settings.Fade2D);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Does the 2D debug is fading out.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Duration", &Settings.Duration, 0.01f, 0.0f, 100.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The duration of debug elements.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Thickness", &Settings.Thickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness of debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Thickness", &Settings.ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Color Mult", &Settings.ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Depth Priority", &Settings.DepthPriority, 0.1f, 0, 100);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The depth priority of debug elements.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Segments", &Settings.Segments, 0.1f, 4, 20.0f);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The number of segments used for circular shapes.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Axes Scale", &Settings.AxesScale, 0.1f, 0, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The scaling debug axis.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Arrow Size", &Settings.ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of debug arrows.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Intensity", &Settings.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Speed", &Settings.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The speed of the gradient color change.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of the debug texts.");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Persistent", &FCogDebugSettings::Persistent);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
if (ImGui::CollapsingHeader("Gizmo"))
|
||||
{
|
||||
ImGui::SetTooltip("Make debug draw always persist");
|
||||
ImGui::SeparatorText("General");
|
||||
|
||||
ImGui::Checkbox("Use Local Space", &Settings.GizmoUseLocalSpace);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The scale of the gizmo.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Z Low", &Settings.GizmoZLow, 0.5f, 0, 1000);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Z High", &Settings.GizmoZHigh, 0.5f, 0, 1000);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Thickness Z Low", &Settings.GizmoThicknessZLow, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Thickness Z High", &Settings.GizmoThicknessZHigh, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Mouse Max Distance", &Settings.GizmoCursorSelectionThreshold, 0.1f, 0.0f, 50.0f, "%.1f");
|
||||
|
||||
ImGui::SeparatorText("Translation");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Translation Snap Enable", &Settings.GizmoTranslationSnapEnable);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Translation Snap", &Settings.GizmoTranslationSnapValue, 0.1f, 0.0f, 1000.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Translation Axis Length", &Settings.GizmoTranslationAxisLength, 0.1f, 0.1f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Translation Plane Offset", &Settings.GizmoTranslationPlaneOffset, 0.1f, 0.0f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Translation Plane Extent", &Settings.GizmoTranslationPlaneExtent, 0.1f, 0.0f, 100.0f, "%.1f");
|
||||
|
||||
ImGui::SeparatorText("Rotation");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Rotation Snap Enable", &Settings.GizmoRotationSnapEnable);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Rotation Snap", &Settings.GizmoRotationSnapValue, 0.1f, 0.0f, 360.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Rotation Speed", &Settings.GizmoRotationSpeed, 0.01f, 0.01f, 100.0f, "%.2f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Rotation Radius", &Settings.GizmoRotationRadius, 0.1f, 0.1f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Rotation Segments", &Settings.GizmoRotationSegments, 0.5f, 2, 12);
|
||||
|
||||
ImGui::SeparatorText("Scale");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Scale Snap Enable", &Settings.GizmoScaleSnapEnable);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Scale Snap", &Settings.GizmoScaleSnapValue, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Scale Box Offset", &Settings.GizmoScaleBoxOffset, 0.0f, 0.0f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Scale Box Extent", &Settings.GizmoScaleBoxExtent, 0.1f, 0.0f, 100.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Scale Speed", &Settings.GizmoScaleSpeed, 0.01f, 0.01f, 100.0f, "%.2f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Scale Min", &Settings.GizmoScaleMin, 0.001f, 0.001f, 1.0f, "%.3f");
|
||||
|
||||
ImGui::SeparatorText("Ground Raycast");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Ground Raycast Length", &Settings.GizmoGroundRaycastLength, 10.0f, 0.0f, 1000000.0f, "%.0f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ECollisionChannel Channel = Settings.GizmoGroundRaycastChannel.GetValue();
|
||||
if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel))
|
||||
{
|
||||
Settings.GizmoGroundRaycastChannel = Channel;
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Ground Raycast Circle Radius", &Settings.GizmoGroundRaycastCircleRadius, 0.1f, 0.1f, 1000.0f, "%.1f");
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Ground Raycast Color", Settings.GizmoGroundRaycastColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Ground Raycast Circle Color", Settings.GizmoGroundRaycastCircleColor, ColorEditFlags);
|
||||
|
||||
ImGui::SeparatorText("Axis Colors");
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZLow X", Settings.GizmoAxisColorsZLowX, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZLow Y", Settings.GizmoAxisColorsZLowY, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZLow Z", Settings.GizmoAxisColorsZLowZ, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZLow W", Settings.GizmoAxisColorsZLowW, ColorEditFlags);
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZHigh X", Settings.GizmoAxisColorsZHighX, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZHigh Y", Settings.GizmoAxisColorsZHighY, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZHigh Z", Settings.GizmoAxisColorsZHighZ, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors ZHigh W", Settings.GizmoAxisColorsZHighW, ColorEditFlags);
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors Selection X", Settings.GizmoAxisColorsSelectionX, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors Selection Y", Settings.GizmoAxisColorsSelectionY, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors Selection Z", Settings.GizmoAxisColorsSelectionZ, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Axis Colors Selection W", Settings.GizmoAxisColorsSelectionW, ColorEditFlags);
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Text Color", Settings.GizmoTextColor, ColorEditFlags);
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Text Shadow", &FCogDebugSettings::TextShadow);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
if (ImGui::CollapsingHeader("Collision Channels"))
|
||||
{
|
||||
ImGui::SetTooltip("Show a shadow below debug text.");
|
||||
if (const UCollisionProfile* CollisionProfile = UCollisionProfile::Get())
|
||||
{
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorWorldStatic, ECC_WorldStatic, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorWorldDynamic, ECC_WorldDynamic, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorPawn, ECC_Pawn, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorVisibility, ECC_Visibility, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorCamera, ECC_Camera, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorPhysicsBody, ECC_PhysicsBody, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorVehicle, ECC_Vehicle, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorDestructible, ECC_Destructible, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel1, ECC_EngineTraceChannel1, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel2, ECC_EngineTraceChannel2, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel3, ECC_EngineTraceChannel3, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel4, ECC_EngineTraceChannel4, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel5, ECC_EngineTraceChannel5, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel6, ECC_EngineTraceChannel6, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel1, ECC_GameTraceChannel1, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel2, ECC_GameTraceChannel2, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel3, ECC_GameTraceChannel3, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel4, ECC_GameTraceChannel4, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel5, ECC_GameTraceChannel5, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel6, ECC_GameTraceChannel6, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel7, ECC_GameTraceChannel7, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel8, ECC_GameTraceChannel8, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel9, ECC_GameTraceChannel9, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel10, ECC_GameTraceChannel10, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel11, ECC_GameTraceChannel11, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel12, ECC_GameTraceChannel12, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel13, ECC_GameTraceChannel13, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel14, ECC_GameTraceChannel14, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel15, ECC_GameTraceChannel15, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel16, ECC_GameTraceChannel16, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel17, ECC_GameTraceChannel17, ColorEditFlags);
|
||||
RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel18, ECC_GameTraceChannel18, ColorEditFlags);
|
||||
}
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Fade 2D", &FCogDebugSettings::Fade2D);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
if (ImGui::CollapsingHeader("Collision Query"))
|
||||
{
|
||||
ImGui::SetTooltip("Does the 2D debug is fading out.");
|
||||
}
|
||||
ImGui::Checkbox("Draw Hit Primitives", &Settings.CollisionQueryDrawHitPrimitives);
|
||||
ImGui::Checkbox("Draw Hit Primitive Actors Name", &Settings.CollisionQueryDrawHitPrimitiveActorsName);
|
||||
ImGui::Checkbox("Prim Hit Primitive Actors Name Shadow", &Settings.CollisionQueryHitPrimitiveActorsNameShadow);
|
||||
ImGui::Checkbox("Draw Hit Shapes", &Settings.CollisionQueryDrawHitShapes);
|
||||
ImGui::Checkbox("Draw Hit Location", &Settings.CollisionQueryDrawHitLocation);
|
||||
ImGui::Checkbox("Draw Hit Impact Points", &Settings.CollisionQueryDrawHitImpactPoints);
|
||||
ImGui::Checkbox("Draw Hit Normals", &Settings.CollisionQueryDrawHitNormals);
|
||||
ImGui::Checkbox("Draw Hit Impact Normals", &Settings.CollisionQueryDrawHitImpactNormals);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Duration", &FCogDebugSettings::Duration, 0.01f, 0.0f, 100.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The duration of debug elements.");
|
||||
}
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Primitive Actors Name Size", &Settings.CollisionQueryHitPrimitiveActorsNameSize);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Thickness", &FCogDebugSettings::Thickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness of debug lines.");
|
||||
}
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Hit Point Size", &Settings.CollisionQueryHitPointSize);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Thickness", &FCogDebugSettings::ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Color Mult", &FCogDebugSettings::ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Depth Priority", &FCogDebugSettings::DepthPriority, 0.1f, 0, 100);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The depth priority of debug elements.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Segments", &FCogDebugSettings::Segments, 0.1f, 4, 20.0f);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The number of segments used for circular shapes.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Axes Scale", &FCogDebugSettings::AxesScale, 0.1f, 0, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The scaling debug axis.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Arrow Size", &FCogDebugSettings::ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of debug arrows.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Intensity", &FCogDebugSettings::GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Speed", &FCogDebugSettings::GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The speed of the gradient color change.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Text Size", &FCogDebugSettings::TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of the debug texts.");
|
||||
FCogImguiHelper::ColorEdit4("Hit Color", Settings.CollisionQueryHitColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("No Hit Color", Settings.CollisionQueryNoHitColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Normal Color", Settings.CollisionQueryNormalColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Impact Normal Color", Settings.CollisionQueryImpactNormalColor, ColorEditFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CogEngineWindow_LogCategories.h"
|
||||
|
||||
#include "CogDebugHelper.h"
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogDebugLog.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
@@ -74,12 +74,12 @@ void FCogEngineWindow_LogCategories::RenderContent()
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
bool bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
||||
bool bIsFilteringBySelection = FCogDebug::GetIsFilteringBySelection();
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2);
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
if (ImGui::Checkbox("Filter", &bIsFilteringBySelection))
|
||||
{
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection);
|
||||
FCogDebug::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection);
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CogEngineWindow_Selection.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogEngineReplicator.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogImguiInputHelper.h"
|
||||
@@ -168,7 +169,7 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DeltaTime);
|
||||
|
||||
if (FCogDebugSettings::GetSelection() == nullptr)
|
||||
if (FCogDebug::GetSelection() == nullptr)
|
||||
{
|
||||
SetGlobalSelection(GetLocalPlayerPawn());
|
||||
}
|
||||
@@ -263,7 +264,7 @@ bool FCogEngineWindow_Selection::DrawSelectionCombo()
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, Actor == LocalPlayerPawn ? IM_COL32(255, 255, 0, 255) : IM_COL32(255, 255, 255, 255));
|
||||
|
||||
bool bIsSelected = Actor == FCogDebugSettings::GetSelection();
|
||||
bool bIsSelected = Actor == FCogDebug::GetSelection();
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetActorName(*Actor)), bIsSelected))
|
||||
{
|
||||
SetGlobalSelection(Actor);
|
||||
@@ -415,7 +416,7 @@ void FCogEngineWindow_Selection::TickSelectionMode()
|
||||
// Prioritize another actor than the selected actor unless we only touch the selected actor.
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
TArray<AActor*> IgnoreList;
|
||||
IgnoreList.Add(FCogDebugSettings::GetSelection());
|
||||
IgnoreList.Add(FCogDebug::GetSelection());
|
||||
|
||||
FHitResult HitResult;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
@@ -614,7 +615,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, floa
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
AActor* GlobalSelection = FCogDebugSettings::GetSelection();
|
||||
AActor* GlobalSelection = FCogDebug::GetSelection();
|
||||
|
||||
//-----------------------------------
|
||||
// Selection
|
||||
@@ -666,7 +667,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, floa
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const
|
||||
{
|
||||
FCogDebugSettings::SetSelection(GetWorld(), Value);
|
||||
FCogDebug::SetSelection(GetWorld(), Value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CogEngineWindow_Skeleton.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Components/SkeletalMeshComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
@@ -79,7 +79,7 @@ void FCogEngineWindow_Skeleton::RefreshSkeleton()
|
||||
CurrentBoneInfo.Name = ReferenceSkeleton.GetBoneName(BoneIndex);
|
||||
const FTransform Transform = ComponentSpaceTransforms[BoneIndex] * WorldTransform;
|
||||
CurrentBoneInfo.LastLocation = Transform.GetLocation();
|
||||
CurrentBoneInfo.IsSecondaryBone = FCogDebugSettings::IsSecondarySkeletonBone(CurrentBoneInfo.Name);
|
||||
CurrentBoneInfo.IsSecondaryBone = FCogDebug::IsSecondarySkeletonBone(CurrentBoneInfo.Name);
|
||||
CurrentBoneInfo.ShowBone = !(HideSecondaryBones && CurrentBoneInfo.IsSecondaryBone);
|
||||
|
||||
const int32 ParentIndex = ReferenceSkeleton.GetParentIndex(BoneIndex);
|
||||
@@ -314,13 +314,13 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
|
||||
if (ShowBones)
|
||||
{
|
||||
::DrawDebugLine(World, ParentLocation, BoneLocation, IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1, FCogDebugSettings::GetDebugThickness(IsHovered ? 0.5f : 0.0f));
|
||||
::DrawDebugPoint(World, BoneLocation, FCogDebugSettings::GetDebugThickness(IsHovered ? 6.0f : 4.0f), IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1);
|
||||
::DrawDebugLine(World, ParentLocation, BoneLocation, IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1, FCogDebug::GetDebugThickness(IsHovered ? 0.5f : 0.0f));
|
||||
::DrawDebugPoint(World, BoneLocation, FCogDebug::GetDebugThickness(IsHovered ? 6.0f : 4.0f), IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1);
|
||||
}
|
||||
|
||||
if (ShowNames || BoneInfo.ShowName || IsHovered)
|
||||
{
|
||||
::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebugSettings::TextSize);
|
||||
::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebug::Settings.TextSize);
|
||||
}
|
||||
|
||||
if (ShowAxes || BoneInfo.ShowAxes)
|
||||
@@ -329,11 +329,11 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
World,
|
||||
BoneLocation,
|
||||
BoneRotation,
|
||||
10.0f * FCogDebugSettings::AxesScale,
|
||||
10.0f * FCogDebug::Settings.AxesScale,
|
||||
false,
|
||||
0.0f,
|
||||
1,
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
FCogDebug::GetDebugThickness(0.0f));
|
||||
}
|
||||
|
||||
if (ShowVelocities || BoneInfo.ShowLocalVelocity)
|
||||
@@ -344,35 +344,35 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
World,
|
||||
BoneLocation,
|
||||
BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(),
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebugSettings::ModulateDebugColor(World, FColor::Cyan),
|
||||
FCogDebugSettings::GetDebugPersistent(true),
|
||||
FCogDebugSettings::GetDebugDuration(true),
|
||||
FCogDebug::Settings.ArrowSize,
|
||||
FCogDebug::ModulateDebugColor(World, FColor::Cyan),
|
||||
FCogDebug::GetDebugPersistent(true),
|
||||
FCogDebug::GetDebugDuration(true),
|
||||
0,
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
FCogDebug::GetDebugThickness(0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
if (ShowTrajectories || BoneInfo.ShowTrajectory)
|
||||
{
|
||||
const FColor Color = FCogDebugSettings::ModulateDebugColor(World, FColor::Yellow);
|
||||
const FColor Color = FCogDebug::ModulateDebugColor(World, FColor::Yellow);
|
||||
DrawDebugLine(
|
||||
World,
|
||||
BoneInfo.LastLocation,
|
||||
BoneLocation,
|
||||
Color,
|
||||
FCogDebugSettings::GetDebugPersistent(true),
|
||||
FCogDebugSettings::GetDebugDuration(true),
|
||||
FCogDebug::GetDebugPersistent(true),
|
||||
FCogDebug::GetDebugDuration(true),
|
||||
0,
|
||||
FCogDebugSettings::GetDebugThickness(0.0f));
|
||||
FCogDebug::GetDebugThickness(0.0f));
|
||||
|
||||
DrawDebugPoint(
|
||||
World,
|
||||
BoneLocation,
|
||||
FCogDebugSettings::GetDebugThickness(2.0f),
|
||||
FCogDebug::GetDebugThickness(2.0f),
|
||||
Color,
|
||||
FCogDebugSettings::GetDebugPersistent(true),
|
||||
FCogDebugSettings::GetDebugDuration(true),
|
||||
FCogDebug::GetDebugPersistent(true),
|
||||
FCogDebug::GetDebugDuration(true),
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "CogEngineWindow_Transform.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Transform::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
Config = GetConfig<UCogEngineConfig_Transform>();
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Transform::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to modify the transform of the selected actor."
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Transform::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
AActor* Selection = GetSelection();
|
||||
if (Selection == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("No Selection");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Drag Speed Location", &Config->LocationSpeed, 0.1f, 0.1f, 100.0f);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Drag Speed Rotation", &Config->RotationSpeed, 0.1f, 0.1f, 100.0f);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Drag Speed Scale", &Config->ScaleSpeed, 0.1f, 0.1f, 100.0f);
|
||||
|
||||
ImGui::SeparatorText("Gizmo");
|
||||
FCogDebugSettings& Settings = FCogDebug::Settings;
|
||||
ImGui::Checkbox("Local Space Gizmo", &Settings.GizmoUseLocalSpace);
|
||||
RenderSnap("##Location", "Snap Location", &Settings.GizmoTranslationSnapEnable, &Settings.GizmoTranslationSnapValue);
|
||||
RenderSnap("##Rotation", "Snap Rotation", &Settings.GizmoRotationSnapEnable, &Settings.GizmoRotationSnapValue);
|
||||
RenderSnap("##Scale", "Snap Scale", &Settings.GizmoScaleSnapEnable, &Settings.GizmoScaleSnapValue);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
FTransform Transform = Selection->GetActorTransform();
|
||||
if (RenderTransform(Transform))
|
||||
{
|
||||
Selection->SetActorTransform(Transform);
|
||||
}
|
||||
|
||||
if (const APlayerController* LocalPlayerController = GetLocalPlayerController())
|
||||
{
|
||||
if (Gizmo.Draw("Transform", *LocalPlayerController, Transform))
|
||||
{
|
||||
Selection->SetActorTransform(Transform);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogEngineWindow_Transform::RenderComponent(const char* Label, double* Value, float Speed, double Min, double Max, double Reset)
|
||||
{
|
||||
ImGui::PushItemWidth(-1);
|
||||
bool Result = FCogImguiHelper::DragDouble(Label, Value, Speed, Min, Max, "%.2f");
|
||||
|
||||
if (ImGui::IsItemActive() && ImGui::TempInputIsActive(ImGui::GetActiveID()))
|
||||
{
|
||||
Result = false;
|
||||
}
|
||||
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::Text("%.2f", *Value);
|
||||
ImGui::TextDisabled("Reset [RMB]");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
*Value = Reset;
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_Transform::RenderSnap(const char* CheckboxLabel, const char* InputLabel, bool* SnapEnable, float* Snap)
|
||||
{
|
||||
ImGui::Checkbox(CheckboxLabel, SnapEnable);
|
||||
|
||||
ImGui::SameLine();
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat(InputLabel, Snap, 0.1f, 0.1f, 1000.0f, "%.1f");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogEngineWindow_Transform::RenderLocation(FTransform& InOutTransform)
|
||||
{
|
||||
ImGui::PushID("Location");
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Location");
|
||||
|
||||
FVector Location = InOutTransform.GetTranslation();
|
||||
bool Result = false;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##X", &Location.X, Config->LocationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetTranslation(Location);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Y", &Location.Y, Config->LocationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetTranslation(Location);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Z", &Location.Z, Config->LocationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetTranslation(Location);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogEngineWindow_Transform::RenderRotation(FTransform& InOutTransform)
|
||||
{
|
||||
ImGui::PushID("Rotation");
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Rotation");
|
||||
|
||||
FRotator Rotation = InOutTransform.GetRotation().Rotator();
|
||||
bool Result = false;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##X", &Rotation.Yaw, Config->RotationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetRotation(Rotation.Quaternion());
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Y", &Rotation.Pitch, Config->RotationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetRotation(Rotation.Quaternion());
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Z", &Rotation.Roll, Config->RotationSpeed, 0.0, 0.0, 0.0))
|
||||
{
|
||||
InOutTransform.SetRotation(Rotation.Quaternion());
|
||||
Result = true;
|
||||
}
|
||||
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogEngineWindow_Transform::RenderScale(FTransform& InOutTransform)
|
||||
{
|
||||
ImGui::PushID("Scale");
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Scale");
|
||||
|
||||
FVector Scale = InOutTransform.GetScale3D();
|
||||
bool Result = false;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##X", &Scale.X, Config->ScaleSpeed, 0.01, 1000.0, 1.0))
|
||||
{
|
||||
InOutTransform.SetScale3D(Scale);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Y", &Scale.Y, Config->ScaleSpeed, 0.01, 1000.0, 1.0))
|
||||
{
|
||||
InOutTransform.SetScale3D(Scale);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (RenderComponent("##Z", &Scale.Z, Config->ScaleSpeed, 0.01, 1000.0, 1.0))
|
||||
{
|
||||
InOutTransform.SetScale3D(Scale);
|
||||
Result = true;
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogEngineWindow_Transform::RenderTransform(FTransform& InOutTransform)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(1.0f, 1.0f));
|
||||
|
||||
bool Result = false;
|
||||
|
||||
if (ImGui::BeginTable("Pools", 4, ImGuiTableFlags_SizingFixedFit))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 5);
|
||||
ImGui::TableSetupColumn("X", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Y", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Z", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
Result |= RenderLocation(InOutTransform);
|
||||
Result |= RenderRotation(InOutTransform);
|
||||
Result |= RenderScale(InOutTransform);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/HitResult.h"
|
||||
#include "CogEngineCollisionTester.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogEngine_CollisionQueryType : uint8
|
||||
{
|
||||
Overlap,
|
||||
LineTrace,
|
||||
Sweep,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogEngine_CollisionQueryMode : uint8
|
||||
{
|
||||
Single,
|
||||
Multi,
|
||||
Test,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogEngine_CollisionQueryBy : uint8
|
||||
{
|
||||
Channel,
|
||||
ObjectType,
|
||||
Profile,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UENUM()
|
||||
enum class ECogEngine_CollisionQueryShape : uint8
|
||||
{
|
||||
Sphere,
|
||||
Box,
|
||||
Capsule,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS()
|
||||
class COGENGINE_API ACogEngineCollisionTester : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
ACogEngineCollisionTester(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual void Tick(float DeltaSeconds) override;
|
||||
|
||||
virtual bool ShouldTickIfViewportsOnly() const override;
|
||||
|
||||
void Query() const;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool TickInEditor = false;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
ECogEngine_CollisionQueryType Type = ECogEngine_CollisionQueryType::LineTrace;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
ECogEngine_CollisionQueryMode Mode = ECogEngine_CollisionQueryMode::Multi;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
ECogEngine_CollisionQueryBy By = ECogEngine_CollisionQueryBy::Channel;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
ECogEngine_CollisionQueryShape Shape = ECogEngine_CollisionQueryShape::Sphere;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool TraceComplex = false;
|
||||
|
||||
UPROPERTY()
|
||||
int32 ObjectTypesToQuery = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TEnumAsByte<ECollisionChannel> Channel = ECC_WorldStatic;
|
||||
|
||||
UPROPERTY()
|
||||
int32 ProfileIndex = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector ShapeExtent = FVector(100, 100, 100);
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitLocations = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitImpactPoints = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitShapes = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitNormals = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitImpactNormals = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitPrimitives = true;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawHitActorsNames = false;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float HitPointSize = 5.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FColor NoHitColor = FColor::Red;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FColor HitColor = FColor::Green;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FColor NormalColor = FColor::Yellow;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FColor ImpactNormalColor = FColor::Cyan;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
USceneComponent* StartComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
USceneComponent* EndComponent = nullptr;
|
||||
};
|
||||
@@ -5,19 +5,6 @@
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "CogEngineDataAsset.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogCollisionChannel
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TEnumAsByte<ECollisionChannel> Channel = ECollisionChannel::ECC_WorldStatic;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FLinearColor Color = FLinearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogEngineSpawnEntry
|
||||
@@ -59,7 +46,4 @@ public:
|
||||
|
||||
UPROPERTY(Category = "Spawns", EditAnywhere, meta = (TitleProperty = "Name"))
|
||||
TArray<FCogEngineSpawnGroup> SpawnGroups;
|
||||
|
||||
UPROPERTY(Category = "Collisions", EditAnywhere, meta = (TitleProperty = "Channel"))
|
||||
TArray<FCogCollisionChannel> Channels;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugGizmo.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindowConfig.h"
|
||||
#include "Engine/HitResult.h"
|
||||
#include "CogEngineCollisionTester.h"
|
||||
#include "CogEngineWindow_CollisionTester.generated.h"
|
||||
|
||||
class UCogEngineConfig_CollisionViewer;
|
||||
class UPrimitiveComponent;
|
||||
struct FCollisionShape;
|
||||
|
||||
enum class ECogDebug_GizmoTransformSpace : uint8;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COGENGINE_API FCogEngineWindow_CollisionTester : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
struct FChannel
|
||||
{
|
||||
bool IsValid = false;
|
||||
FColor Color;
|
||||
};
|
||||
|
||||
FChannel Channels[ECC_MAX];
|
||||
|
||||
TObjectPtr<UCogEngineConfig_CollisionTester> Config = nullptr;
|
||||
|
||||
FCogDebug_Gizmo EndGizmo;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class UCogEngineConfig_CollisionTester : public UCogWindowConfig
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector LocationStart;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector LocationEnd;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FRotator Rotation;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector Scale;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogEngine_CollisionQueryType Type;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogEngine_CollisionQueryMode Mode;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogEngine_CollisionQueryBy By;
|
||||
|
||||
UPROPERTY(Config)
|
||||
ECogEngine_CollisionQueryShape Shape;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool TraceComplex;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int32 ObjectTypesToQuery;
|
||||
|
||||
UPROPERTY(Config)
|
||||
TEnumAsByte<ECollisionChannel> Channel;
|
||||
|
||||
UPROPERTY(Config)
|
||||
int32 ProfileIndex;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector ShapeExtent;
|
||||
|
||||
UCogEngineConfig_CollisionTester()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
|
||||
Type = ECogEngine_CollisionQueryType::LineTrace;
|
||||
By = ECogEngine_CollisionQueryBy::Channel;
|
||||
Mode = ECogEngine_CollisionQueryMode::Multi;
|
||||
Channel = ECC_WorldStatic;
|
||||
TraceComplex = false;
|
||||
Shape = ECogEngine_CollisionQueryShape::Sphere;
|
||||
ShapeExtent = FVector(50.0f, 50.0f, 50.0f);
|
||||
|
||||
ObjectTypesToQuery = 0;
|
||||
ProfileIndex = 0;
|
||||
}
|
||||
};
|
||||
+5
-15
@@ -4,13 +4,13 @@
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindowConfig.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "CogEngineWindow_Collisions.generated.h"
|
||||
#include "CogEngineWindow_CollisionViewer.generated.h"
|
||||
|
||||
class UCogEngineConfig_Collisions;
|
||||
class UCogEngineConfig_CollisionViewer;
|
||||
class UCogEngineDataAsset;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COGENGINE_API FCogEngineWindow_Collisions : public FCogWindow
|
||||
class COGENGINE_API FCogEngineWindow_CollisionViewer : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
@@ -26,24 +26,18 @@ protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void SetAsset(const UCogEngineDataAsset* Value);
|
||||
|
||||
struct FChannel
|
||||
{
|
||||
bool IsValid = false;
|
||||
FColor Color;
|
||||
};
|
||||
|
||||
FChannel Channels[ECC_MAX];
|
||||
|
||||
TObjectPtr<const UCogEngineDataAsset> Asset = nullptr;
|
||||
|
||||
TObjectPtr<UCogEngineConfig_Collisions> Config = nullptr;
|
||||
TObjectPtr<UCogEngineConfig_CollisionViewer> Config = nullptr;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class UCogEngineConfig_Collisions : public UCogWindowConfig
|
||||
class UCogEngineConfig_CollisionViewer : public UCogWindowConfig
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -70,9 +64,6 @@ public:
|
||||
UPROPERTY(Config)
|
||||
bool ShowActorsNames = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowQuery = false;
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
@@ -84,6 +75,5 @@ public:
|
||||
QueryThickness = 0.0f;
|
||||
UseComplexCollisions = false;
|
||||
ShowActorsNames = false;
|
||||
ShowQuery = false;
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindowConfig.h"
|
||||
#include "CogEngineWindow_DebugSettings.generated.h"
|
||||
@@ -27,7 +28,6 @@ protected:
|
||||
private:
|
||||
|
||||
TWeakObjectPtr<UCogEngineConfig_DebugSettings> Config = nullptr;
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -39,68 +39,11 @@ class UCogEngineConfig_DebugSettings : public UCogWindowConfig
|
||||
public:
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bIsFilteringBySelection = 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)
|
||||
float GradientColorIntensity = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float GradientColorSpeed = 2.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float TextSize = 1.0f;
|
||||
FCogDebugSettings Data;
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
|
||||
bIsFilteringBySelection = true;
|
||||
Persistent = false;
|
||||
TextShadow = true;
|
||||
Fade2D = true;
|
||||
Duration = 3.0f;
|
||||
DepthPriority = 0;
|
||||
Segments = 12;
|
||||
Thickness = 0.0f;
|
||||
ServerThickness = 2.0f;
|
||||
ServerColorMultiplier = 0.8f;
|
||||
ArrowSize = 10.0f;
|
||||
AxesScale = 1.0f;
|
||||
GradientColorIntensity = 0.0f;
|
||||
GradientColorSpeed = 2.0f;
|
||||
TextSize = 1.0f;
|
||||
Data = FCogDebugSettings();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugGizmo.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindowConfig.h"
|
||||
#include "CogEngineWindow_Transform.generated.h"
|
||||
|
||||
class UCogEngineConfig_Transform;
|
||||
|
||||
class COGENGINE_API FCogEngineWindow_Transform : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
bool RenderComponent(const char* Label, double* Value, float Speed, double Min, double Max, double Reset);
|
||||
|
||||
void RenderSnap(const char* CheckboxLabel, const char* InputLabel, bool* SnapEnable, float* Snap);
|
||||
|
||||
bool RenderLocation(FTransform& InOutTransform);
|
||||
|
||||
bool RenderRotation(FTransform& InOutTransform);
|
||||
|
||||
bool RenderScale(FTransform& InOutTransform);
|
||||
|
||||
bool RenderTransform(FTransform& InOutTransform);
|
||||
|
||||
private:
|
||||
|
||||
FCogDebug_Gizmo Gizmo;
|
||||
|
||||
TWeakObjectPtr<UCogEngineConfig_Transform> Config = nullptr;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class UCogEngineConfig_Transform : public UCogWindowConfig
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowGizmo = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float LocationSpeed = 10.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RotationSpeed = 1.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float ScaleSpeed = 0.1f;
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
ShowGizmo = true;
|
||||
LocationSpeed = 10.0f;
|
||||
RotationSpeed = 1.0f;
|
||||
ScaleSpeed = 0.1f;
|
||||
}
|
||||
};
|
||||
@@ -145,4 +145,87 @@ void FCogImguiHelper::SetFlags(int32& Value, int32 Flags, bool EnableFlags)
|
||||
{
|
||||
Value &= ~Flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragDouble(const char* Label, double* Value, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
return ImGui::DragScalar(Label, ImGuiDataType_Double, Value, Speed, &Min, &Max, Format, Flags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragFVector(const char* Label, FVector& Vector, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 3, Speed, &Min, &Max, Format, Flags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragFVector(const char* Label, FVector& Vector, const FVector& ResetVector, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
bool Result = ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 3, Speed, &Min, &Max, Format, Flags);
|
||||
|
||||
if (ImGui::BeginPopupContextItem(Label))
|
||||
{
|
||||
if (ImGui::Button("Reset"))
|
||||
{
|
||||
Vector = ResetVector;
|
||||
Result = true;
|
||||
|
||||
if (ImGuiWindow* Window = GetCurrentWindow())
|
||||
{
|
||||
const ImGuiID ID = Window->GetID(Label);
|
||||
ImGui::MarkItemEdited(ID);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragFRotator(const char* Label, FRotator& Rotator, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Rotator.Pitch, 3, Speed, &Min, &Max, Format, Flags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragFRotator(const char* Label, FRotator& Rotator, const FRotator& ResetRotator, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
bool Result = ImGui::DragScalarN(Label, ImGuiDataType_Double, &Rotator.Pitch, 3, Speed, &Min, &Max, Format, Flags);
|
||||
|
||||
if (ImGui::BeginPopupContextItem(Label))
|
||||
{
|
||||
if (ImGui::Button("Reset"))
|
||||
{
|
||||
Rotator = ResetRotator;
|
||||
Result = true;
|
||||
|
||||
if (ImGuiWindow* Window = GetCurrentWindow())
|
||||
{
|
||||
const ImGuiID ID = Window->GetID(Label);
|
||||
ImGui::MarkItemEdited(ID);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::DragFVector2D(const char* Label, FVector2D& Vector, float Speed, double Min, double Max, const char* Format, ImGuiSliderFlags Flags)
|
||||
{
|
||||
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 2, Speed, &Min, &Max, Format, Flags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogImguiHelper::ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags)
|
||||
{
|
||||
FLinearColor Linear(Color);
|
||||
const bool Result = ImGui::ColorEdit4(Label, &Linear.R, Flags);
|
||||
Color = Linear.ToFColor(true);
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -122,17 +122,17 @@ FReply SCogImguiWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterE
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
||||
{
|
||||
return HandleKeyEvent(MyGeometry, KeyEvent, true);
|
||||
return HandleKeyEvent(KeyEvent, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
||||
{
|
||||
return HandleKeyEvent(MyGeometry, KeyEvent, false);
|
||||
return HandleKeyEvent(KeyEvent, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down)
|
||||
FReply SCogImguiWidget::HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down)
|
||||
{
|
||||
if (Context->GetEnableInput() == false)
|
||||
{
|
||||
@@ -187,31 +187,34 @@ FReply SCogImguiWidget::OnAnalogValueChanged(const FGeometry& MyGeometry, const
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||
{
|
||||
if (Context->GetEnableInput() == false)
|
||||
{
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::OnMouseButtonDown | %s | Unhandled | EnableInput == false"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"));
|
||||
return FReply::Unhandled();
|
||||
}
|
||||
const uint32 MouseButton = FCogImguiInputHelper::ToImGuiMouseButton(MouseEvent.GetEffectingButton());
|
||||
ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse);
|
||||
ImGui::GetIO().AddMouseButtonEvent(MouseButton, true);
|
||||
return HandleMouseButtonEvent(MouseEvent, true);
|
||||
}
|
||||
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::OnMouseButtonDown | Window:%s | Handled"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"));
|
||||
return FReply::Handled();
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||
{
|
||||
return HandleMouseButtonEvent(MouseEvent, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||
{
|
||||
return HandleMouseButtonEvent(MouseEvent, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FReply SCogImguiWidget::HandleMouseButtonEvent(const FPointerEvent& MouseEvent, bool Down)
|
||||
{
|
||||
if (Context->GetEnableInput() == false)
|
||||
{
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::OnMouseButtonUp | Window:%s | Unhandled | EnableInput == false"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"));
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::HandleMouseButtonEvent | %s | Unhandled | EnableInput == false | Down:%d"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"), Down);
|
||||
return FReply::Unhandled();
|
||||
}
|
||||
const uint32 MouseButton = FCogImguiInputHelper::ToImGuiMouseButton(MouseEvent.GetEffectingButton());
|
||||
ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse);
|
||||
ImGui::GetIO().AddMouseButtonEvent(MouseButton, false);
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::OnMouseButtonUp | Window:%s | Handled"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"));
|
||||
ImGui::GetIO().AddMouseButtonEvent(MouseButton, Down);
|
||||
|
||||
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::HandleMouseButtonEvent | Window:%s | Handled | Down:%d"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"), Down);
|
||||
return FReply::Handled();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,4 +57,18 @@ public:
|
||||
static FSlateRenderTransform RoundTranslation(const FSlateRenderTransform& Transform);
|
||||
|
||||
static void SetFlags(int32& Value, int32 Flags, bool EnableFlags);
|
||||
|
||||
static bool DragDouble(const char* Label, double* Value, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool DragFVector(const char* Label, FVector& Vector, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool DragFVector(const char* Label, FVector& Vector, const FVector& ResetVector, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool DragFRotator(const char* Label, FRotator& Rotator, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool DragFRotator(const char* Label, FRotator& Rotator, const FRotator& ResetRotator, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool DragFVector2D(const char* Label, FVector2D& Vector, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||
|
||||
static bool ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags = 0);
|
||||
};
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
|
||||
virtual FReply OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent) override;
|
||||
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||
virtual FReply OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||
virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||
@@ -53,7 +54,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down);
|
||||
FReply HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down);
|
||||
FReply HandleMouseButtonEvent(const FPointerEvent& MouseEvent, bool Down);
|
||||
|
||||
void RefreshVisibility();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CogWindow.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebug.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "CogWindowManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
@@ -136,7 +137,7 @@ void FCogWindow::RenderHelp()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow::RenderTick(float DeltaTime)
|
||||
{
|
||||
SetSelection(FCogDebugSettings::GetSelection());
|
||||
SetSelection(FCogDebug::GetSelection());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CogWindowWidgets.h"
|
||||
|
||||
#include "CogDebug.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogImguiKeyInfo.h"
|
||||
#include "CogImguiInputHelper.h"
|
||||
@@ -610,4 +611,109 @@ bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray<float>& Values, float& Va
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
return IsPressed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindowWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Channel)
|
||||
{
|
||||
FColor ChannelColors[ECC_MAX];
|
||||
FCogDebug::GetDebugChannelColors(ChannelColors);
|
||||
|
||||
FName SelectedChannelName;
|
||||
const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
|
||||
if (CollisionProfile != nullptr)
|
||||
{
|
||||
SelectedChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(Channel);
|
||||
}
|
||||
|
||||
bool Result = false;
|
||||
if (ImGui::BeginCombo(Label, TCHAR_TO_ANSI(*SelectedChannelName.ToString()), ImGuiComboFlags_HeightLarge))
|
||||
{
|
||||
for (int32 ChannelIndex = 0; ChannelIndex < (int32)ECC_OverlapAll_Deprecated; ++ChannelIndex)
|
||||
{
|
||||
FColor Color = ChannelColors[ChannelIndex];
|
||||
if (Color == FColor::Transparent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::PushID(ChannelIndex);
|
||||
|
||||
const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex);
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Color", Color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ChannelName.IsValid())
|
||||
{
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*ChannelName.ToString())))
|
||||
{
|
||||
Channel = (ECollisionChannel)ChannelIndex;
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindowWidgets::CollisionProfileChannel(const UCollisionProfile& CollisionProfile, const int32 ChannelIndex, FColor& ChannelColor, int32& Channels)
|
||||
{
|
||||
bool Result = false;
|
||||
|
||||
FCogImguiHelper::ColorEdit4("Color", ChannelColor, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
|
||||
ImGui::SameLine();
|
||||
|
||||
bool IsCollisionActive = (Channels & ECC_TO_BITFIELD(ChannelIndex)) > 0;
|
||||
const FName ChannelName = CollisionProfile.ReturnChannelNameFromContainerIndex(ChannelIndex);
|
||||
if (ImGui::Checkbox(TCHAR_TO_ANSI(*ChannelName.ToString()), &IsCollisionActive))
|
||||
{
|
||||
Result = true;
|
||||
|
||||
if (IsCollisionActive)
|
||||
{
|
||||
Channels |= ECC_TO_BITFIELD(ChannelIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Channels &= ~ECC_TO_BITFIELD(ChannelIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindowWidgets::CollisionProfileChannels(int32& Channels)
|
||||
{
|
||||
const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
|
||||
if (CollisionProfile == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FColor ChannelColors[ECC_MAX];
|
||||
FCogDebug::GetDebugChannelColors(ChannelColors);
|
||||
|
||||
bool Result = false;
|
||||
|
||||
for (int32 ChannelIndex = 0; ChannelIndex < (int32)ECC_OverlapAll_Deprecated; ++ChannelIndex)
|
||||
{
|
||||
FColor Color = ChannelColors[ChannelIndex];
|
||||
if (Color == FColor::Transparent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::PushID(ChannelIndex);
|
||||
Result |= CollisionProfileChannel(*CollisionProfile, ChannelIndex, Color, Channels);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -80,6 +80,12 @@ public:
|
||||
|
||||
static bool DeleteArrayItemButton();
|
||||
|
||||
static bool ComboCollisionChannel(const char* Label, ECollisionChannel& Channel);
|
||||
|
||||
static bool CollisionProfileChannel(const UCollisionProfile& CollisionProfile, int32 ChannelIndex, FColor& ChannelColor, int32& Channels);
|
||||
|
||||
static bool CollisionProfileChannels(int32& Channels);
|
||||
|
||||
};
|
||||
|
||||
template<typename EnumType>
|
||||
|
||||
@@ -154,7 +154,7 @@ void UCogSampleAreaComponent::TickComponent(float DeltaTime, enum ELevelTick Tic
|
||||
#if ENABLE_COG
|
||||
|
||||
const AActor* AreaInstigator = UCogSampleFunctionLibrary_Gameplay::GetInstigator(GetOwner());
|
||||
if (FCogDebugLog::IsLogCategoryActive(LogCogArea) && FCogDebugSettings::IsDebugActiveForObject(AreaInstigator))
|
||||
if (FCogDebugLog::IsLogCategoryActive(LogCogArea) && FCogDebug::IsDebugActiveForObject(AreaInstigator))
|
||||
{
|
||||
TArray<USceneComponent*, TInlineAllocator<8>> Components;
|
||||
GetOwner()->GetComponents<USceneComponent>(Components);
|
||||
|
||||
@@ -224,7 +224,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E
|
||||
const ACharacter* Character = GetCharacterOwner();
|
||||
const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent();
|
||||
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(GetPawnOwner()))
|
||||
if (FCogDebug::IsDebugActiveForObject(GetPawnOwner()))
|
||||
{
|
||||
FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input X", GetPendingInputVector().X);
|
||||
FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input Y", GetPendingInputVector().Y);
|
||||
@@ -241,7 +241,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E
|
||||
const FVector DebugLocation = Character->GetActorLocation();
|
||||
const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight();
|
||||
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(GetPawnOwner()))
|
||||
if (FCogDebug::IsDebugActiveForObject(GetPawnOwner()))
|
||||
{
|
||||
const FRotator Rotation = Character->GetActorRotation();
|
||||
const FVector Forward = Character->GetActorForwardVector();
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
#if ENABLE_COG
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogDebug.h"
|
||||
|
||||
#define COG_LOG_ABILITY(Verbosity, Ability, Format, ...) \
|
||||
if (Ability != nullptr) \
|
||||
{ \
|
||||
AActor* Actor = Ability->GetAvatarActorFromActorInfo(); \
|
||||
if (FCogDebugSettings::IsDebugActiveForObject(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
||||
if (FCogDebug::IsDebugActiveForObject(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
||||
{ \
|
||||
COG_LOG(LogCogAbility, Verbosity, TEXT("%s - %s - %s - %s"), \
|
||||
*GetNameSafe(Actor), \
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#include "CogDebugPlot.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogEngineModule.h"
|
||||
#include "CogEngineWindow_Collisions.h"
|
||||
#include "CogEngineWindow_CollisionTester.h"
|
||||
#include "CogEngineWindow_CollisionViewer.h"
|
||||
#include "CogEngineWindow_CommandBindings.h"
|
||||
#include "CogEngineWindow_DebugSettings.h"
|
||||
#include "CogEngineWindow_ImGui.h"
|
||||
@@ -40,6 +41,7 @@
|
||||
#include "CogEngineWindow_Spawns.h"
|
||||
#include "CogEngineWindow_Stats.h"
|
||||
#include "CogEngineWindow_TimeScale.h"
|
||||
#include "CogEngineWindow_Transform.h"
|
||||
#include "CogImguiModule.h"
|
||||
#include "CogInputDataAsset.h"
|
||||
#include "CogInputWindow_Actions.h"
|
||||
@@ -128,7 +130,9 @@ void ACogSampleGameState::InitializeCog()
|
||||
//---------------------------------------
|
||||
// Engine
|
||||
//---------------------------------------
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_Collisions>("Engine.Collision");
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_CollisionTester>("Engine.Collision Tester");
|
||||
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_CollisionViewer>("Engine.Collision Viewer");
|
||||
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_CommandBindings>("Engine.Command Bindings");
|
||||
|
||||
@@ -171,6 +175,8 @@ void ACogSampleGameState::InitializeCog()
|
||||
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
|
||||
|
||||
CogWindowManager->AddWindow<FCogEngineWindow_Transform>("Engine.Transform");
|
||||
|
||||
//---------------------------------------
|
||||
// Abilities
|
||||
//---------------------------------------
|
||||
|
||||
@@ -198,7 +198,7 @@ bool UCogSampleGameplayAbility::IsCostGameplayEffectIsZero(const UGameplayEffect
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
// The Cost in the Data is positive, but UCogSampleModifierCalculation_Cost negates it.
|
||||
// Therefore a cost less than zero is an actual cost, and a cost of 0 or greater can be ignored
|
||||
// Therefore, a cost less than zero is an actual cost, and a cost of 0 or greater can be ignored
|
||||
//----------------------------------------------------------------------------------------------
|
||||
if (CostValue < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user