CogDebug: improving transform gizmos and collision tester (WIP)

This commit is contained in:
Arnaud Jamin
2023-12-29 03:08:15 -05:00
parent bd29211013
commit 81fc6269ad
34 changed files with 889 additions and 655 deletions
@@ -9,13 +9,13 @@
#if ENABLE_COG #if ENABLE_COG
#include "CogDebugSettings.h" #include "CogDebug.h"
#define IF_COG(expr) { expr; } #define IF_COG(expr) { expr; }
#define COG_LOG_CATEGORY FLogCategoryBase #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, ...) \ #define COG_LOG(LogCategory, Verbosity, Format, ...) \
@@ -1,4 +1,4 @@
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogCommonDebugFilteredActorInterface.h" #include "CogCommonDebugFilteredActorInterface.h"
#include "CogDebugReplicator.h" #include "CogDebugReplicator.h"
@@ -6,17 +6,17 @@
#include "Engine/Engine.h" #include "Engine/Engine.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
TWeakObjectPtr<AActor> FCogDebugSettings::Selection; TWeakObjectPtr<AActor> FCogDebug::Selection;
FCogDebugData FCogDebugSettings::Data = FCogDebugData(); FCogDebugSettings FCogDebug::Settings = FCogDebugSettings();
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugSettings::Reset() void FCogDebug::Reset()
{ {
Data = FCogDebugData(); Settings = FCogDebugSettings();
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject) bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
{ {
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (World == nullptr) if (World == nullptr)
@@ -29,19 +29,19 @@ bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject
return true; return true;
} }
bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), Data.bIsFilteringBySelection); bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), Settings.bIsFilteringBySelection);
return Result; return Result;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection) bool FCogDebug::IsReplicatedDebugActiveForObject(const UObject* WorldContextObject, const AActor* ServerSelection, bool IsServerFilteringBySelection)
{ {
return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection); return IsDebugActiveForObject_Internal(WorldContextObject, ServerSelection, IsServerFilteringBySelection);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection) bool FCogDebug::IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection)
{ {
if (InIsFilteringBySelection == false) if (InIsFilteringBySelection == false)
{ {
@@ -85,13 +85,13 @@ bool FCogDebugSettings::IsDebugActiveForObject_Internal(const UObject* WorldCont
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
AActor* FCogDebugSettings::GetSelection() AActor* FCogDebug::GetSelection()
{ {
return Selection.Get(); return Selection.Get();
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugSettings::SetSelection(UWorld* World, AActor* Value) void FCogDebug::SetSelection(UWorld* World, AActor* Value)
{ {
Selection = Value; Selection = Value;
@@ -105,15 +105,15 @@ void FCogDebugSettings::SetSelection(UWorld* World, AActor* Value)
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::GetIsFilteringBySelection() bool FCogDebug::GetIsFilteringBySelection()
{ {
return Data.bIsFilteringBySelection; return Settings.bIsFilteringBySelection;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value) void FCogDebug::SetIsFilteringBySelection(UWorld* World, bool Value)
{ {
Data.bIsFilteringBySelection = Value; Settings.bIsFilteringBySelection = Value;
if (World != nullptr && World->GetNetMode() == NM_Client) if (World != nullptr && World->GetNetMode() == NM_Client)
{ {
@@ -125,23 +125,23 @@ void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value)
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::GetDebugPersistent(bool bPersistent) bool FCogDebug::GetDebugPersistent(bool bPersistent)
{ {
return Data.Persistent && bPersistent; return Settings.Persistent && bPersistent;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugDuration(bool bPersistent) float FCogDebug::GetDebugDuration(bool bPersistent)
{ {
return bPersistent == false ? 0.0f : Data.Duration; return bPersistent == false ? 0.0f : Settings.Duration;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugTextDuration(bool bPersistent) float FCogDebug::GetDebugTextDuration(bool bPersistent)
{ {
if (bPersistent) if (bPersistent)
{ {
return Data.Persistent ? 100 : Data.Duration; return Settings.Persistent ? 100 : Settings.Duration;
} }
else else
{ {
@@ -150,37 +150,37 @@ float FCogDebugSettings::GetDebugTextDuration(bool bPersistent)
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
int FCogDebugSettings::GetDebugSegments() int FCogDebug::GetDebugSegments()
{ {
return Data.Segments; return Settings.Segments;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
int FCogDebugSettings::GetCircleSegments() int FCogDebug::GetCircleSegments()
{ {
return (Data.Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason return (Settings.Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugThickness(float InThickness) float FCogDebug::GetDebugThickness(float InThickness)
{ {
return (Data.Thickness + InThickness); return (Settings.Thickness + InThickness);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugServerThickness(float InThickness) float FCogDebug::GetDebugServerThickness(float InThickness)
{ {
return (Data.ServerThickness + InThickness); return (Settings.ServerThickness + InThickness);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
uint8 FCogDebugSettings::GetDebugDepthPriority(float InDepthPriority) uint8 FCogDebug::GetDebugDepthPriority(float InDepthPriority)
{ {
return (Data.DepthPriority + InDepthPriority); return (Settings.DepthPriority + InDepthPriority);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent) FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent)
{ {
if (bPersistent == false) if (bPersistent == false)
{ {
@@ -199,30 +199,30 @@ FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor&
ComplementaryColor = ComplementaryColor.HSVToLinearRGB(); ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Data.GradientColorSpeed * Time)); const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.GradientColorSpeed * Time));
const FLinearColor FBlendColor = BaseColor * (1.0f - Data.GradientColorIntensity) + GradientColor * Data.GradientColorIntensity; const FLinearColor FBlendColor = BaseColor * (1.0f - Settings.GradientColorIntensity) + GradientColor * Settings.GradientColorIntensity;
return FBlendColor.ToFColor(true); return FBlendColor.ToFColor(true);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FColor FCogDebugSettings::ModulateServerColor(const FColor& Color) FColor FCogDebug::ModulateServerColor(const FColor& Color)
{ {
FColor ServerColor( FColor ServerColor(
Color.R * Data.ServerColorMultiplier, Color.R * Settings.ServerColorMultiplier,
Color.G * Data.ServerColorMultiplier, Color.G * Settings.ServerColorMultiplier,
Color.B * Data.ServerColorMultiplier, Color.B * Settings.ServerColorMultiplier,
Color.A); Color.A);
return ServerColor; return ServerColor;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsSecondarySkeletonBone(FName BoneName) bool FCogDebug::IsSecondarySkeletonBone(FName BoneName)
{ {
FString BoneString = BoneName.ToString().ToLower(); FString BoneString = BoneName.ToString().ToLower();
for (const FString& Wildcard : Data.SecondaryBoneWildcards) for (const FString& Wildcard : Settings.SecondaryBoneWildcards)
{ {
if (BoneString.MatchesWildcard(Wildcard)) if (BoneString.MatchesWildcard(Wildcard))
{ {
@@ -6,7 +6,7 @@
#include "CogDebugLog.h" #include "CogDebugLog.h"
#include "CogDebugModule.h" #include "CogDebugModule.h"
#include "CogDebugReplicator.h" #include "CogDebugReplicator.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogDebugShape.h" #include "CogDebugShape.h"
#include "CogImguiHelper.h" #include "CogImguiHelper.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
@@ -32,8 +32,8 @@ void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject*
Text, Text,
FCogImguiHelper::ToImU32(Color), FCogImguiHelper::ToImU32(Color),
true, true,
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::Data.Fade2D); FCogDebug::Settings.Fade2D);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -48,9 +48,9 @@ void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject
FCogImguiHelper::ToImVec2(SegmentStart), FCogImguiHelper::ToImVec2(SegmentStart),
FCogImguiHelper::ToImVec2(SegmentEnd), FCogImguiHelper::ToImVec2(SegmentEnd),
FCogImguiHelper::ToImU32(Color), FCogImguiHelper::ToImU32(Color),
FCogDebugSettings::GetDebugThickness(0), FCogDebug::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::Data.Fade2D); FCogDebug::Settings.Fade2D);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -65,10 +65,10 @@ void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject*
FCogImguiHelper::ToImVec2(Location), FCogImguiHelper::ToImVec2(Location),
Radius, Radius,
FCogImguiHelper::ToImU32(Color), FCogImguiHelper::ToImU32(Color),
FCogDebugSettings::GetDebugSegments(), FCogDebug::GetDebugSegments(),
FCogDebugSettings::GetDebugThickness(0), FCogDebug::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::Data.Fade2D); FCogDebug::Settings.Fade2D);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -85,9 +85,9 @@ void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* W
FCogImguiHelper::ToImVec2(Max), FCogImguiHelper::ToImVec2(Max),
FCogImguiHelper::ToImU32(Color), FCogImguiHelper::ToImU32(Color),
0.0f, 0.0f,
FCogDebugSettings::GetDebugThickness(0), FCogDebug::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::Data.Fade2D); FCogDebug::Settings.Fade2D);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -104,7 +104,7 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W
return; 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); UE_VLOG_LOCATION(WorldContextObject, LogCategory, Verbose, Location, 10.0f, NewColor, TEXT("%s"), *Text);
::DrawDebugString( ::DrawDebugString(
@@ -113,9 +113,9 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W
*Text, *Text,
nullptr, nullptr,
NewColor, NewColor,
FCogDebugSettings::GetDebugTextDuration(Persistent), FCogDebug::GetDebugTextDuration(Persistent),
FCogDebugSettings::Data.TextShadow, FCogDebug::Settings.TextShadow,
FCogDebugSettings::Data.TextSize); FCogDebug::Settings.TextSize);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -132,17 +132,17 @@ void FCogDebugDraw::Point(const FLogCategoryBase& LogCategory, const UObject* Wo
return; return;
} }
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent); const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
::DrawDebugPoint( ::DrawDebugPoint(
World, World,
Location, Location,
Size, Size,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebugSettings::Data.DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebug::Settings.DepthPriority));
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -159,7 +159,7 @@ void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject*
return; 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); UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
::DrawDebugLine( ::DrawDebugLine(
@@ -167,10 +167,10 @@ void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject*
SegmentStart, SegmentStart,
SegmentEnd, SegmentEnd,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSegment(SegmentStart, SegmentEnd, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeSegment(SegmentStart, SegmentEnd, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -189,7 +189,7 @@ void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* Wor
return; 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); UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, BoneLocation, ParentLocation, NewColor, TEXT_EMPTY);
::DrawDebugLine( ::DrawDebugLine(
@@ -197,19 +197,19 @@ void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* Wor
BoneLocation, BoneLocation,
ParentLocation, ParentLocation,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
::DrawDebugPoint( ::DrawDebugPoint(
World, World,
BoneLocation, BoneLocation,
FCogDebugSettings::GetDebugThickness(4.0f), FCogDebug::GetDebugThickness(4.0f),
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBone(BoneLocation, ParentLocation, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeBone(BoneLocation, ParentLocation, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -228,21 +228,21 @@ void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* Wo
return; 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); UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
::DrawDebugDirectionalArrow( ::DrawDebugDirectionalArrow(
World, World,
SegmentStart, SegmentStart,
SegmentEnd, SegmentEnd,
FCogDebugSettings::Data.ArrowSize, FCogDebug::Settings.ArrowSize,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebugSettings::Data.ArrowSize, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebug::Settings.ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -268,13 +268,13 @@ void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* Wor
World, World,
AxisLoc, AxisLoc,
AxisRot, AxisRot,
Scale * FCogDebugSettings::Data.AxesScale, Scale * FCogDebug::Settings.AxesScale,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebugSettings::Data.ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebug::Settings.ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -291,7 +291,7 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W
return; return;
} }
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent); const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
const FVector Center = Matrix.GetOrigin(); const FVector Center = Matrix.GetOrigin();
const FVector UpVector = Matrix.GetUnitAxis(EAxis::X); const FVector UpVector = Matrix.GetUnitAxis(EAxis::X);
UE_VLOG_CIRCLE(WorldContextObject, LogCategory, Verbose, Center, UpVector, Radius, NewColor, TEXT_EMPTY); UE_VLOG_CIRCLE(WorldContextObject, LogCategory, Verbose, Center, UpVector, Radius, NewColor, TEXT_EMPTY);
@@ -300,12 +300,12 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W
World, World,
Matrix, Matrix,
Radius, Radius,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0), FCogDebug::GetDebugThickness(0),
false); false);
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircle(Center, Matrix.Rotator(), Radius, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircle(Center, Matrix.Rotator(), Radius, NewColor, 0.0f, Persistent, DepthPriority));
@@ -325,7 +325,7 @@ void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject
return; return;
} }
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent); const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
//TODO : Add VLOG //TODO : Add VLOG
@@ -335,12 +335,12 @@ void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject
InnerRadius, InnerRadius,
OuterRadius, OuterRadius,
Angle, Angle,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircleArc(Matrix.GetOrigin(), Matrix.Rotator(), InnerRadius, OuterRadius, Angle, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircleArc(Matrix.GetOrigin(), Matrix.Rotator(), InnerRadius, OuterRadius, Angle, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -359,7 +359,7 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje
return; return;
} }
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent); const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
// TODO : Add VLOG // TODO : Add VLOG
FCogDebugDrawHelper::DrawFlatCapsule( FCogDebugDrawHelper::DrawFlatCapsule(
@@ -368,12 +368,12 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje
End, End,
Radius, Radius,
Z, Z,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeFlatCapsule(Start, End, Radius, Z, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeFlatCapsule(Start, End, Radius, Z, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -392,19 +392,19 @@ void FCogDebugDraw::Sphere(const FLogCategoryBase& LogCategory, const UObject* W
return; 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); UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Location, 0.0f, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
FCogDebugDrawHelper::DrawSphere( FCogDebugDrawHelper::DrawSphere(
World, World,
Location, Location,
Radius, Radius,
FCogDebugSettings::GetDebugSegments(), FCogDebug::GetDebugSegments(),
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Location, FQuat::Identity, Radius, 0.0f, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Location, FQuat::Identity, Radius, 0.0f, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -423,7 +423,7 @@ void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* Worl
return; 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); UE_VLOG_OBOX(WorldContextObject, LogCategory, Verbose, FBox(-Extent, Extent), FQuatRotationTranslationMatrix::Make(Rotation, Center), NewColor, TEXT_EMPTY);
::DrawDebugBox( ::DrawDebugBox(
@@ -432,10 +432,10 @@ void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* Worl
Extent, Extent,
Rotation, Rotation,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBox(Center, FRotator(Rotation), Extent, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeBox(Center, FRotator(Rotation), Extent, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -454,7 +454,7 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject*
return; 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); 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. // If we make the Box Thick enough, it will be displayed as a filled box.
@@ -467,9 +467,9 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject*
Extent, Extent,
Rotation, Rotation,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
NeededThickness); NeededThickness);
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSolidBox(Center, FRotator(Rotation), Extent, NewColor, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeSolidBox(Center, FRotator(Rotation), Extent, NewColor, Persistent, DepthPriority));
@@ -489,7 +489,7 @@ void FCogDebugDraw::Frustrum(const FLogCategoryBase& LogCategory, const UObject*
return; return;
} }
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(World, Color, Persistent); const FColor NewColor = FCogDebug::ModulateDebugColor(World, Color, Persistent);
FCogDebugDrawHelper::DrawFrustum( FCogDebugDrawHelper::DrawFrustum(
World, World,
@@ -499,10 +499,10 @@ void FCogDebugDraw::Frustrum(const FLogCategoryBase& LogCategory, const UObject*
NearPlane, NearPlane,
FarPlane, FarPlane,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
// TODO: Replicate Shape // TODO: Replicate Shape
} }
@@ -521,7 +521,7 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject*
return; 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); UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Center, HalfHeight, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
DrawDebugCapsule( DrawDebugCapsule(
@@ -531,10 +531,10 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject*
Radius, Radius,
Rotation, Rotation,
NewColor, NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent), FCogDebug::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent), FCogDebug::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0)); FCogDebug::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Center, Rotation, Radius, HalfHeight, NewColor, 0.0f, Persistent, DepthPriority)); ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Center, Rotation, Radius, HalfHeight, NewColor, 0.0f, Persistent, DepthPriority));
} }
@@ -615,7 +615,7 @@ void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeleta
if (DrawSecondaryBones == false) if (DrawSecondaryBones == false)
{ {
FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex); FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex);
if (FCogDebugSettings::IsSecondarySkeletonBone(BoneName)) if (FCogDebug::IsSecondarySkeletonBone(BoneName))
{ {
continue; continue;
} }
@@ -666,7 +666,7 @@ void FCogDebugDraw::ReplicateShape(const UObject* WorldContextObject, const FCog
continue; continue;
} }
if (FCogDebugSettings::IsReplicatedDebugActiveForObject(WorldContextObject, Replicator->GetServerSelection(), Replicator->IsServerFilteringBySelection()) == false) if (FCogDebug::IsReplicatedDebugActiveForObject(WorldContextObject, Replicator->GetServerSelection(), Replicator->IsServerFilteringBySelection()) == false)
{ {
continue; continue;
} }
@@ -26,7 +26,8 @@ void FCogDebugDrawHelper::DrawArc(
const FMatrix& Matrix, const FMatrix& Matrix,
float InnerRadius, float InnerRadius,
float OuterRadius, float OuterRadius,
float Angle, float AngleStart,
float AngleEnd,
int32 Segments, int32 Segments,
const FColor& Color, const FColor& Color,
bool bPersistentLines, bool bPersistentLines,
@@ -46,54 +47,52 @@ void FCogDebugDrawHelper::DrawArc(
} }
const float LineLifeTime = GetLineLifeTime(LineBatcher, LifeTime, bPersistentLines); const float LineLifeTime = GetLineLifeTime(LineBatcher, LifeTime, bPersistentLines);
const float AngleStartRad = FMath::DegreesToRadians(AngleStart);
const float AngleRad = FMath::DegreesToRadians(Angle); const float AngleEndRad = FMath::DegreesToRadians(AngleEnd);
const FVector Center = Matrix.GetOrigin(); const FVector Center = Matrix.GetOrigin();
const FVector Direction = Matrix.GetUnitAxis(EAxis::Z);
// Need at least 4 segments // Need at least 4 segments
Segments = FMath::Max(Segments, 4); Segments = FMath::Max(Segments, 4);
FVector AxisY, AxisZ; const FVector AxisY = Matrix.GetScaledAxis(EAxis::Y);
FVector DirectionNorm = Direction.GetSafeNormal(); const FVector AxisZ = Matrix.GetScaledAxis(EAxis::Z);
DirectionNorm.FindBestAxisVectors(AxisZ, AxisY);
TArray<FBatchedLine> Lines; TArray<FBatchedLine> Lines;
Lines.Empty(Segments * 2 + 2); Lines.Empty(Segments * 2 + 2);
if (InnerRadius != OuterRadius) if (InnerRadius != OuterRadius)
{ {
FVector P0 = Center + InnerRadius * (AxisY * -FMath::Sin(-AngleRad) + DirectionNorm * FMath::Cos(-AngleRad)); const FVector P0 = Center + InnerRadius * (AxisZ * FMath::Sin(AngleStartRad) + AxisY * FMath::Cos(AngleStartRad));
FVector P1 = Center + OuterRadius * (AxisY * -FMath::Sin(-AngleRad) + DirectionNorm * FMath::Cos(-AngleRad)); const FVector P1 = Center + OuterRadius * (AxisZ * FMath::Sin(AngleStartRad) + AxisY * FMath::Cos(AngleStartRad));
Lines.Emplace(FBatchedLine(P0, P1, Color, LineLifeTime, Thickness, DepthPriority)); Lines.Emplace(FBatchedLine(P0, P1, Color, LineLifeTime, Thickness, DepthPriority));
FVector P2 = Center + InnerRadius * (AxisY * -FMath::Sin(AngleRad) + DirectionNorm * FMath::Cos(AngleRad)); const FVector P2 = Center + InnerRadius * (AxisZ * FMath::Sin(AngleEndRad) + AxisY * FMath::Cos(AngleEndRad));
FVector P3 = Center + OuterRadius * (AxisY * -FMath::Sin(AngleRad) + DirectionNorm * FMath::Cos(AngleRad)); const FVector P3 = Center + OuterRadius * (AxisZ * FMath::Sin(AngleEndRad) + AxisY * FMath::Cos(AngleEndRad));
Lines.Emplace(FBatchedLine(P2, P3, Color, LineLifeTime, Thickness, DepthPriority)); Lines.Emplace(FBatchedLine(P2, P3, Color, LineLifeTime, Thickness, DepthPriority));
} }
float CurrentAngle = -AngleRad; float CurrentAngle = AngleStartRad;
const float AngleStep = AngleRad / float(Segments) * 2.f; const float AngleStep = (AngleEndRad - AngleStartRad) / float(Segments);
FVector PrevVertex = Center + OuterRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle)); FVector PrevVertex = Center + OuterRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
int32 Count = Segments; int32 Count = Segments;
while (Count--) while (Count--)
{ {
CurrentAngle += AngleStep; 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)); Lines.Emplace(FBatchedLine(PrevVertex, NextVertex, Color, LineLifeTime, Thickness, DepthPriority));
PrevVertex = NextVertex; PrevVertex = NextVertex;
} }
if (InnerRadius != 0.0f) if (InnerRadius != 0.0f)
{ {
CurrentAngle = -AngleRad; CurrentAngle = AngleStartRad;
PrevVertex = Center + InnerRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle)); PrevVertex = Center + InnerRadius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle));
Count = Segments; Count = Segments;
while (Segments--) while (Segments--)
{ {
CurrentAngle += AngleStep; 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)); Lines.Emplace(FBatchedLine(PrevVertex, NextVertex, Color, LineLifeTime, Thickness, DepthPriority));
PrevVertex = NextVertex; PrevVertex = NextVertex;
} }
@@ -102,6 +101,23 @@ void FCogDebugDrawHelper::DrawArc(
LineBatcher->DrawLines(Lines); 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( void FCogDebugDrawHelper::DrawSphere(
const UWorld* InWorld, const UWorld* InWorld,
@@ -1,7 +1,7 @@
#include "CogDebugGizmo.h" #include "CogDebugGizmo.h"
#include "CogDebug.h"
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "CogDebugSettings.h"
#include "CogImGuiHelper.h" #include "CogImGuiHelper.h"
#include "Components/PrimitiveComponent.h" #include "Components/PrimitiveComponent.h"
#include "Components/SceneComponent.h" #include "Components/SceneComponent.h"
@@ -10,7 +10,29 @@
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float PointDistanceToQuad(const APlayerController& InPlayerController, const FVector2D& Point, const FVector& QuadPosition, const FQuat& QuadRotation, const FVector2D& QuadExtents) 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 U = QuadRotation.GetAxisZ() * QuadExtents.X;
const FVector V = QuadRotation.GetAxisY() * QuadExtents.Y; const FVector V = QuadRotation.GetAxisY() * QuadExtents.Y;
@@ -26,8 +48,8 @@ float PointDistanceToQuad(const APlayerController& InPlayerController, const FVe
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V2, P2); UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V2, P2);
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V3, P3); UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V3, P3);
const FVector B0 = FMath::GetBaryCentric2D(Point, P0, P1, P2); const FVector B0 = FMath::GetBaryCentric2D(Point2D, P0, P1, P2);
const FVector B1 = FMath::GetBaryCentric2D(Point, P0, P2, P3); 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 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 bool Inside1 = B1.X > 0.0f && B1.Y > 0.0f && B1.Z > 0.0f;
@@ -37,7 +59,90 @@ float PointDistanceToQuad(const APlayerController& InPlayerController, const FVe
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransform& InOutTransform) 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 FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerController, FTransform& InOutTransform, ECogDebug_GizmoFlags Flags)
{ {
UWorld* World = InPlayerController.GetWorld(); UWorld* World = InPlayerController.GetWorld();
@@ -52,67 +157,98 @@ void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransfo
FVector2D Center2D; FVector2D Center2D;
if (UGameplayStatics::ProjectWorldToScreen(&InPlayerController, GizmoCenter, Center2D) == false) if (UGameplayStatics::ProjectWorldToScreen(&InPlayerController, GizmoCenter, Center2D) == false)
{ {
if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
{
InOutTransform = InitialTransform;
}
return; return;
} }
const FCogDebugData& Debug = FCogDebugSettings::Data; const ImGuiIO& IO = ImGui::GetIO();
FCogDebugSettings& Settings = FCogDebug::Settings;
FVector CenterProjection, CenterDirection, AxisProjection, AxisDirection; FVector ProjectedGizmoCenter, CenterDirection, AxisProjection, AxisDirection;
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D, CenterProjection, CenterDirection); UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D, ProjectedGizmoCenter, CenterDirection);
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D + FVector2d(0, 1.0f), AxisProjection, AxisDirection); UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D + FVector2d(0, 1.0f), AxisProjection, AxisDirection);
const FVector CameraLocation = InPlayerController.PlayerCameraManager->GetCameraLocation(); const FVector CameraLocation = InPlayerController.PlayerCameraManager->GetCameraLocation();
const float Sc = FVector::Dist(AxisProjection, CenterProjection) * FVector::Dist(CameraLocation, GizmoCenter) / FVector::Dist(CameraLocation, CenterProjection); const float CameraToProjectedGizmoCenter = FVector::Dist(CameraLocation, ProjectedGizmoCenter);
const float Scale = Debug.GizmoScale * Sc; 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 = InOutTransform.GetRotation(); const FQuat RotX = UseLocalSpace ? InOutTransform.GetRotation() : FQuat(FVector(0.0f, 0.0f, 1.0f), 0.0f);
const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f, 1.0f), UE_HALF_PI); const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f,-1.0f), UE_HALF_PI);
const FQuat RotZ = RotX * FQuat(FVector(0.0f, 1.0f, 0.0f), UE_HALF_PI); const FQuat RotZ = RotX * FQuat(FVector(0.0f, 1.0f, 0.0f), UE_HALF_PI);
const FVector UnitAxisX = RotX.GetAxisX(); const FVector UnitAxisX = UseLocalSpace ? RotX.GetAxisX() : FVector::XAxisVector;
const FVector UnitAxisY = RotX.GetAxisY(); const FVector UnitAxisY = UseLocalSpace ? RotX.GetAxisY() : FVector::YAxisVector;
const FVector UnitAxisZ = RotX.GetAxisZ(); const FVector UnitAxisZ = UseLocalSpace ? RotX.GetAxisZ() : FVector::ZAxisVector;
const FVector AxisX = GizmoCenter + UnitAxisX * Debug.GizmoAxisLength * Scale; const FVector AxisX = GizmoCenter + UnitAxisX * Settings.GizmoAxisLength * GizmoScale;
const FVector AxisY = GizmoCenter + UnitAxisY * Debug.GizmoAxisLength * Scale; const FVector AxisY = GizmoCenter + UnitAxisY * Settings.GizmoAxisLength * GizmoScale;
const FVector AxisZ = GizmoCenter + UnitAxisZ * Debug.GizmoAxisLength * Scale; const FVector AxisZ = GizmoCenter + UnitAxisZ * Settings.GizmoAxisLength * GizmoScale;
const FVector PlaneXY = GizmoCenter + ((UnitAxisX + UnitAxisY) * Debug.GizmoPlaneOffset * Scale); const FVector PlaneXY = GizmoCenter + ((UnitAxisX + UnitAxisY) * Settings.GizmoPlaneOffset * GizmoScale);
const FVector PlaneXZ = GizmoCenter + ((UnitAxisX + UnitAxisZ) * Debug.GizmoPlaneOffset * Scale); const FVector PlaneXZ = GizmoCenter + ((UnitAxisX + UnitAxisZ) * Settings.GizmoPlaneOffset * GizmoScale);
const FVector PlaneYZ = GizmoCenter + ((UnitAxisY + UnitAxisZ) * Debug.GizmoPlaneOffset * Scale); const FVector PlaneYZ = GizmoCenter + ((UnitAxisY + UnitAxisZ) * Settings.GizmoPlaneOffset * GizmoScale);
const float AdjustedScaleBoxExtent = Debug.GizmoScaleBoxExtent * Scale; const float ScaleBoxExtent = Settings.GizmoScaleBoxExtent * GizmoScale;
const float AdjustedPlaneExtent = Debug.GizmoPlaneExtent * Scale; const float PlaneExtent = Settings.GizmoPlaneExtent * GizmoScale;
const float AdjustedThicknessZLow = Debug.GizmoThicknessZLow * Scale; const float ThicknessZLow = Settings.GizmoThicknessZLow * ScaleToKeepGizmoScreenSizeConstant;
const float AdjustedThicknessZHigh = Debug.GizmoThicknessZHigh * Scale; const float ThicknessZHigh = Settings.GizmoThicknessZHigh * ScaleToKeepGizmoScreenSizeConstant;
const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos; const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos;
const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos); const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos);
const FColor GizmoAxisColorsZLow[] = { Debug.GizmoAxisColorsZLowX, Debug.GizmoAxisColorsZLowY, Debug.GizmoAxisColorsZLowZ, Debug.GizmoAxisColorsZLowW }; const FColor GizmoAxisColorsZLow[] = { Settings.GizmoAxisColorsZLowX, Settings.GizmoAxisColorsZLowY, Settings.GizmoAxisColorsZLowZ, Settings.GizmoAxisColorsZLowW };
const FColor GizmoAxisColorsZHigh[] = { Debug.GizmoAxisColorsZHighX, Debug.GizmoAxisColorsZHighY, Debug.GizmoAxisColorsZHighZ, Debug.GizmoAxisColorsZHighW }; const FColor GizmoAxisColorsZHigh[] = { Settings.GizmoAxisColorsZHighX, Settings.GizmoAxisColorsZHighY, Settings.GizmoAxisColorsZHighZ, Settings.GizmoAxisColorsZHighW };
const FColor GizmoAxisColorsSelection[] = { Debug.GizmoAxisColorsSelectionX, Debug.GizmoAxisColorsSelectionY, Debug.GizmoAxisColorsSelectionZ, Debug.GizmoAxisColorsSelectionW }; const FColor GizmoAxisColorsSelection[] = { Settings.GizmoAxisColorsSelectionX, Settings.GizmoAxisColorsSelectionY, Settings.GizmoAxisColorsSelectionZ, Settings.GizmoAxisColorsSelectionW };
FCogDebug_GizmoElement GizmoElements[ECogDebug_GizmoElementType::MAX]; FCogDebug_GizmoElement GizmoElements[ECogDebug_GizmoElementType::MAX];
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveX] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, FQuat::Identity, AxisX }; for (FCogDebug_GizmoElement& GizmoElement : GizmoElements)
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveY] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, FQuat::Identity, AxisY }; {
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveZ] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, FQuat::Identity, AxisZ }; GizmoElement.Type = ECogDebug_GizmoType::MAX;
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXY] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, PlaneXY }; }
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, PlaneXZ };
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveYZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, PlaneYZ }; if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationAxis) == false)
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateX] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, AxisX }; {
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateY] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY }; GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveX] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, FQuat::Identity, AxisX };
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateZ] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ }; GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveY] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, FQuat::Identity, AxisY };
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleXYZ] = { ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter }; GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveZ] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, FQuat::Identity, AxisZ };
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleX] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, AxisX }; }
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleY] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY };
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleZ] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ }; if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationPlane) == false)
{
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXY] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, PlaneXY };
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, PlaneXZ };
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveYZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, PlaneYZ };
}
if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoRotation) == false)
{
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateX] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, AxisX };
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateY] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY };
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateZ] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ };
}
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, AxisX };
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleY] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY };
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleZ] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ };
}
ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX; ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX;
if (DraggedElementType != ECogDebug_GizmoElementType::MAX) if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
{ {
HoveredElementType = DraggedElementType; HoveredElementType = DraggedElementType;
} }
else else if (IO.WantCaptureMouse == false)
{ {
float MinDistanceToMouse = FLT_MAX; float MinDistanceToMouse = FLT_MAX;
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i) for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
@@ -124,30 +260,35 @@ void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransfo
{ {
case ECogDebug_GizmoType::MoveAxis: case ECogDebug_GizmoType::MoveAxis:
{ {
FVector2D ElementLocation2D; DistanceToMouse = ScreenDistanceToLine(InPlayerController, MousePos, GizmoCenter, Elm.Location);
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, Elm.Location, ElementLocation2D);
const FVector2D ClosestPoint = FMath::ClosestPointOnSegment2D(MousePos, Center2D, ElementLocation2D);
DistanceToMouse = (ClosestPoint - MousePos).Length();
break; break;
} }
case ECogDebug_GizmoType::MovePlane: case ECogDebug_GizmoType::MovePlane:
{ {
DistanceToMouse = PointDistanceToQuad(InPlayerController, MousePos, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent)); DistanceToMouse = ScreenDistanceToQuad(InPlayerController, MousePos, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent));
break;
}
case ECogDebug_GizmoType::Rotate:
{
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; break;
} }
case ECogDebug_GizmoType::ScaleUniform: case ECogDebug_GizmoType::ScaleUniform:
case ECogDebug_GizmoType::ScaleAxis: case ECogDebug_GizmoType::ScaleAxis:
{ {
FVector2D ElementLocation2D; DistanceToMouse = ScreenDistanceToSphere(InPlayerController, MousePos, Elm.Location, Settings.GizmoScaleBoxExtent);
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, Elm.Location, ElementLocation2D);
DistanceToMouse = FVector2D::Distance(ElementLocation2D, MousePos) - Debug.GizmoScaleBoxExtent;
break; break;
} }
default:;
} }
if (DistanceToMouse < Debug.GizmoMouseMaxDistance && DistanceToMouse < MinDistanceToMouse) if (DistanceToMouse < Settings.GizmoCursorSelectionThreshold && DistanceToMouse < MinDistanceToMouse)
{ {
HoveredElementType = (ECogDebug_GizmoElementType)i; HoveredElementType = (ECogDebug_GizmoElementType)i;
MinDistanceToMouse = DistanceToMouse; MinDistanceToMouse = DistanceToMouse;
@@ -167,90 +308,113 @@ void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransfo
{ {
case ECogDebug_GizmoType::MoveAxis: case ECogDebug_GizmoType::MoveAxis:
{ {
DrawDebugLine(World, GizmoCenter, Elm.Location, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow); DrawDebugLine(World, GizmoCenter, Elm.Location, ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
DrawDebugLine(World, GizmoCenter, Elm.Location, ZHighColor, false, 0.0f, Debug.GizmoZHigh, Debug.GizmoThicknessZHigh); DrawDebugLine(World, GizmoCenter, Elm.Location, ZHighColor, false, 0.0f, Settings.GizmoZHigh, Settings.GizmoThicknessZHigh);
break; break;
} }
case ECogDebug_GizmoType::MovePlane: case ECogDebug_GizmoType::MovePlane:
{ {
FCogDebugDrawHelper::DrawQuad(World, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent), ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow); 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(AdjustedPlaneExtent, AdjustedPlaneExtent), ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh); 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(AdjustedPlaneExtent, AdjustedPlaneExtent), ZLowColor, false, 0.0f, Debug.GizmoZLow); FCogDebugDrawHelper::DrawSolidQuad(World, Elm.Location, Elm.Rotation, FVector2D(PlaneExtent, PlaneExtent), ZLowColor, false, 0.0f, Settings.GizmoZLow);
break; break;
} }
case ECogDebug_GizmoType::Rotate: case ECogDebug_GizmoType::Rotate:
{ {
FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), Elm.Location); FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), GizmoCenter);
DrawDebugCircle(World, Matrix, Debug.GizmoRotationRadius, Debug.GizmoRotationSegments, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow, false); const float RotationGizmoRadius = Settings.GizmoRotationRadius * GizmoScale;
DrawDebugCircle(World, Matrix, Debug.GizmoRotationRadius, Debug.GizmoRotationSegments, ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh, false); 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; break;
} }
case ECogDebug_GizmoType::ScaleUniform: case ECogDebug_GizmoType::ScaleUniform:
case ECogDebug_GizmoType::ScaleAxis: case ECogDebug_GizmoType::ScaleAxis:
{ {
DrawDebugBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow); DrawDebugBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow);
DrawDebugBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh); DrawDebugBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZHighColor, false, 0.0f, Settings.GizmoZHigh, ThicknessZHigh);
DrawDebugSolidBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Debug.GizmoZLow); DrawDebugSolidBox(World, Elm.Location, FVector::OneVector * ScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Settings.GizmoZLow);
break; 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)) if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{ {
DraggedElementType = ECogDebug_GizmoElementType::MAX; DraggedElementType = ECogDebug_GizmoElementType::MAX;
} }
else if (DraggedElementType != ECogDebug_GizmoElementType::MAX) else if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
{ {
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 4.0f)) if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{ {
FVector MouseWorldOrigin, MouseWorldDirection; InOutTransform = InitialTransform;
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, MousePos - CursorOffset, MouseWorldOrigin, MouseWorldDirection); DraggedElementType = ECogDebug_GizmoElementType::MAX;
}
FCogDebug_GizmoElement& DraggedElement = GizmoElements[(uint8)DraggedElementType]; else if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, Settings.GizmoCursorDraggingThreshold))
{
const FCogDebug_GizmoElement& DraggedElement = GizmoElements[(uint8)DraggedElementType];
switch (DraggedElement.Type) switch (DraggedElement.Type)
{ {
case ECogDebug_GizmoType::MoveAxis: case ECogDebug_GizmoType::MoveAxis:
{ {
FVector Pa, Pb; const FVector Point = GetMouseCursorOnLine(InPlayerController, InitialTransform.GetTranslation(), DraggedElement.Direction, MousePos - CursorOffset);
FMath::SegmentDistToSegmentSafe( InOutTransform.SetLocation(Point);
GizmoCenter - DraggedElement.Direction * 10000,
GizmoCenter + DraggedElement.Direction * 10000,
MouseWorldOrigin - MouseWorldDirection * 10000,
MouseWorldOrigin + MouseWorldDirection * 10000,
Pa, Pb);
InOutTransform.SetLocation(Pa);
break; break;
} }
case ECogDebug_GizmoType::MovePlane: case ECogDebug_GizmoType::MovePlane:
{ {
const FPlane Plane(GizmoCenter, DraggedElement.Direction); const FVector Point = GetMouseCursorOnPlane(InPlayerController, InitialTransform.GetTranslation(), DraggedElement.Direction, MousePos - CursorOffset);
const FVector PlaneIntersection = FMath::RayPlaneIntersection(MouseWorldOrigin, MouseWorldDirection, Plane); InOutTransform.SetLocation(Point);
InOutTransform.SetLocation(PlaneIntersection); break;
}
case ECogDebug_GizmoType::Rotate:
{
const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left));
const float DragAmount = DragDelta.X - DragDelta.Y;
const FQuat RotDelta(DraggedElement.Axis, DragAmount * Settings.GizmoScaleSpeed);
FQuat NewRot;
if (UseLocalSpace)
{
NewRot = InitialTransform.GetRotation() * RotDelta;
}
else
{
NewRot = RotDelta * InitialTransform.GetRotation();
}
InOutTransform.SetRotation(NewRot);
break; break;
} }
case ECogDebug_GizmoType::ScaleAxis: case ECogDebug_GizmoType::ScaleAxis:
{ {
FVector Pa, Pb; const FVector Point = GetMouseCursorOnLine(InPlayerController, GizmoCenter, DraggedElement.Direction, MousePos - CursorOffset);
FMath::SegmentDistToSegmentSafe( const float Sign = FMath::Sign(FVector::DotProduct(DraggedElement.Direction, Point - GizmoCenter));
GizmoCenter - DraggedElement.Direction * 10000, const float Delta = (Point - GizmoCenter).Length() * Sign;
GizmoCenter + DraggedElement.Direction * 10000, const FVector NewScale = VectorMax(InitialTransform.GetScale3D() + (DraggedElement.Axis * Delta * Settings.GizmoScaleSpeed), Settings.GizmoScaleMin);
MouseWorldOrigin - MouseWorldDirection * 10000,
MouseWorldOrigin + MouseWorldDirection * 10000,
Pa, Pb);
const float Sign = FMath::Sign(FVector::DotProduct(DraggedElement.Direction, Pa - GizmoCenter));
const float Delta = (Pa - GizmoCenter).Length() * Sign;
FVector NewScale = InitialScale + (DraggedElement.Axis * Delta * Debug.GizmoScaleSpeed);
NewScale.X = FMath::Max(NewScale.X, Debug.GizmoScaleMin);
NewScale.Y = FMath::Max(NewScale.Y, Debug.GizmoScaleMin);
NewScale.Z = FMath::Max(NewScale.Z, Debug.GizmoScaleMin);
InOutTransform.SetScale3D(NewScale); InOutTransform.SetScale3D(NewScale);
break; break;
} }
@@ -258,10 +422,8 @@ void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransfo
case ECogDebug_GizmoType::ScaleUniform: case ECogDebug_GizmoType::ScaleUniform:
{ {
const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left)); const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left));
FVector NewScale = InitialScale + (DraggedElement.Axis * (DragDelta.X - DragDelta.Y) * Debug.GizmoScaleSpeed); const float DragAmount = DragDelta.X - DragDelta.Y;
NewScale.X = FMath::Max(NewScale.X, Debug.GizmoScaleMin); const FVector NewScale = VectorMax(InitialTransform.GetScale3D() + (DraggedElement.Axis * DragAmount * Settings.GizmoScaleSpeed), Settings.GizmoScaleMin);
NewScale.Y = FMath::Max(NewScale.Y, Debug.GizmoScaleMin);
NewScale.Z = FMath::Max(NewScale.Z, Debug.GizmoScaleMin);
InOutTransform.SetScale3D(NewScale); InOutTransform.SetScale3D(NewScale);
break; break;
} }
@@ -272,14 +434,64 @@ void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransfo
} }
} }
else if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) else if (HoveredElementType != ECogDebug_GizmoElementType::MAX)
{ {
DraggedElementType = HoveredElementType; if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
if (HoveredElementType != ECogDebug_GizmoElementType::MAX)
{ {
DraggedElementType = HoveredElementType;
CursorOffset = MousePos - Center2D; CursorOffset = MousePos - Center2D;
InitialScale = InOutTransform.GetScale3D(); InitialTransform = InOutTransform;
}
else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{
ImGui::OpenPopup(Id);
} }
} }
if (ImGui::BeginPopup(Id))
{
ImGui::Checkbox("Local Space", &UseLocalSpace);
ImGui::Separator();
FVector Translation = InOutTransform.GetTranslation();
if (FCogImguiHelper::DragFVector("Translation", Translation, 1.0f, 0.0f, 0.0f, "%.1f"))
{
InOutTransform.SetTranslation(Translation);
}
//if (ImGui::MenuItem("Reset Translation"))
//{
// InOutTransform.SetTranslation(FVector::ZeroVector);
//}
FRotator Rotation = FRotator(InOutTransform.GetRotation());
if (FCogImguiHelper::DragFRotator("Rotation", Rotation, 1.0f, 0.0f, 0.0f, "%.1f"))
{
InOutTransform.SetRotation(Rotation.Quaternion());
}
//if (ImGui::MenuItem("Reset Rotation"))
//{
// InOutTransform.SetRotation(FQuat::Identity);
//}
FVector Scale = InOutTransform.GetScale3D();
if (FCogImguiHelper::DragFVector("Scale", Scale, 1.0f, 0.0f, FLT_MAX, "%.1f"))
{
InOutTransform.SetScale3D(Scale);
}
//if (ImGui::MenuItem("Reset Scale"))
//{
// InOutTransform.SetScale3D(FVector::OneVector);
//}
ImGui::Separator();
ImGui::DragFloat("Gizmo Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f");
ImGui::EndPopup();
}
} }
@@ -41,7 +41,7 @@ bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, FCogL
return false; return false;
} }
if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false) if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
{ {
return false; return false;
} }
@@ -1,6 +1,6 @@
#include "CogDebugMetric.h" #include "CogDebugMetric.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
float FCogDebugMetric::MaxDurationSetting = 0.0f; float FCogDebugMetric::MaxDurationSetting = 0.0f;
@@ -13,7 +13,7 @@ TMap<FName, FCogDebugMetricEntry> FCogDebugMetric::Metrics;
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params) void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params)
{ {
if (FCogDebugSettings::IsDebugActiveForObject(Params.WorldContextObject) == false) if (FCogDebug::IsDebugActiveForObject(Params.WorldContextObject) == false)
{ {
return; return;
} }
@@ -425,7 +425,7 @@ FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObjec
return nullptr; return nullptr;
} }
if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false) if (FCogDebug::IsDebugActiveForObject(WorldContextObject) == false)
{ {
return nullptr; return nullptr;
} }
@@ -81,8 +81,8 @@ void ACogDebugReplicator::BeginPlay()
if (OwnerPlayerController->IsLocalController()) if (OwnerPlayerController->IsLocalController())
{ {
Server_RequestAllCategoriesVerbosity(); Server_RequestAllCategoriesVerbosity();
Server_SetSelection(FCogDebugSettings::GetSelection()); Server_SetSelection(FCogDebug::GetSelection());
Server_SetIsFilteringBySelection(FCogDebugSettings::GetIsFilteringBySelection()); Server_SetIsFilteringBySelection(FCogDebug::GetIsFilteringBySelection());
} }
} }
@@ -31,11 +31,11 @@ void FCogDebugShape::DrawPoint(UWorld* World) const
DrawDebugPoint( DrawDebugPoint(
World, World,
ShapeData[0], ShapeData[0],
FCogDebugSettings::GetDebugServerThickness(Thickness), FCogDebug::GetDebugServerThickness(Thickness),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -70,11 +70,11 @@ void FCogDebugShape::DrawSegment(UWorld* World) const
World, World,
ShapeData[0], ShapeData[0],
ShapeData[1], ShapeData[1],
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -111,11 +111,11 @@ void FCogDebugShape::DrawArrow(UWorld* World) const
ShapeData[0], ShapeData[0],
ShapeData[1], ShapeData[1],
ShapeData[2].X, ShapeData[2].X,
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -152,10 +152,10 @@ void FCogDebugShape::DrawAxes(UWorld* World) const
ShapeData[0], ShapeData[0],
FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z),
ShapeData[2].X, ShapeData[2].X,
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -192,11 +192,11 @@ void FCogDebugShape::DrawBox(UWorld* World) const
ShapeData[0], ShapeData[0],
ShapeData[1], ShapeData[1],
FQuat(FRotator(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z)), FQuat(FRotator(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z)),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -231,10 +231,10 @@ void FCogDebugShape::DrawSolidBox(UWorld* World) const
ShapeData[0], ShapeData[0],
ShapeData[1], ShapeData[1],
FQuat(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z)), FQuat(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z)),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -274,12 +274,12 @@ void FCogDebugShape::DrawCone(UWorld* World) const
ShapeData[2].X, ShapeData[2].X,
DefaultConeAngle, DefaultConeAngle,
DefaultConeAngle, DefaultConeAngle,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #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[0] + FVector(0, 0, ShapeData[1].Z), ShapeData[0] + FVector(0, 0, ShapeData[1].Z),
ShapeData[1].X, ShapeData[1].X,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -355,12 +355,12 @@ void FCogDebugShape::DrawCicle(UWorld* World) const
World, World,
FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]), FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]),
ShapeData[2].X, ShapeData[2].X,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness), FCogDebug::GetDebugServerThickness(Thickness),
false); false);
} }
@@ -399,12 +399,12 @@ void FCogDebugShape::DrawCicleArc(UWorld* World) const
ShapeData[2].X, ShapeData[2].X,
ShapeData[2].Y, ShapeData[2].Y,
ShapeData[2].Z, ShapeData[2].Z,
FCogDebugSettings::GetDebugSegments(), FCogDebug::GetDebugSegments(),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -442,11 +442,11 @@ void FCogDebugShape::DrawCapsule(UWorld* World) const
ShapeData[1].Y, ShapeData[1].Y,
ShapeData[1].X, ShapeData[1].X,
FQuat::MakeFromEuler(ShapeData[2]), FQuat::MakeFromEuler(ShapeData[2]),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -484,12 +484,12 @@ void FCogDebugShape::DrawFlatCapsule(UWorld* World) const
FVector2D(ShapeData[1].X, ShapeData[1].Y), FVector2D(ShapeData[1].X, ShapeData[1].Y),
ShapeData[2].X, ShapeData[2].X,
ShapeData[2].Y, ShapeData[2].Y,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -524,20 +524,20 @@ void FCogDebugShape::DrawBone(UWorld* World) const
World, World,
ShapeData[0], ShapeData[0],
ShapeData[1], ShapeData[1],
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
DrawDebugPoint( DrawDebugPoint(
World, World,
ShapeData[0], ShapeData[0],
FCogDebugSettings::GetDebugServerThickness(Thickness) + 4.0f, FCogDebug::GetDebugServerThickness(Thickness) + 4.0f,
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -578,10 +578,10 @@ void FCogDebugShape::DrawPolygon(UWorld* World) const
World, World,
ShapeData, ShapeData,
Indices, Indices,
FCogDebugSettings::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -2,14 +2,14 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "UObject/WeakObjectPtrTemplates.h" #include "UObject/WeakObjectPtrTemplates.h"
#include "CogDebugSettings.generated.h" #include "CogDebug.generated.h"
class UObject; class UObject;
class AActor; class AActor;
class UWorld; class UWorld;
USTRUCT() USTRUCT()
struct FCogDebugData struct FCogDebugSettings
{ {
GENERATED_BODY() GENERATED_BODY()
@@ -77,7 +77,10 @@ struct FCogDebugData
float GizmoThicknessZHigh = 0.0f; float GizmoThicknessZHigh = 0.0f;
UPROPERTY(Config) UPROPERTY(Config)
float GizmoMouseMaxDistance = 5.0f; float GizmoCursorDraggingThreshold = 4.0f;
UPROPERTY(Config)
float GizmoCursorSelectionThreshold = 10.0f;
UPROPERTY(Config) UPROPERTY(Config)
float GizmoPlaneOffset = 25.0f; float GizmoPlaneOffset = 25.0f;
@@ -98,7 +101,16 @@ struct FCogDebugData
float GizmoRotationRadius = 15.0f; float GizmoRotationRadius = 15.0f;
UPROPERTY(Config) UPROPERTY(Config)
int GizmoRotationSegments = 32; int GizmoRotationSegments = 12;
UPROPERTY(Config)
float GizmoGroundRaycastLength = 100000.0f;
UPROPERTY(Config)
TEnumAsByte<ECollisionChannel> GizmoGroundRaycastChannel = ECollisionChannel::ECC_WorldStatic;
UPROPERTY(Config)
float GizmoGroundRaycastCircleRadius = 10.f;
UPROPERTY(Config) UPROPERTY(Config)
FColor GizmoAxisColorsZHighX = FColor(255, 50, 50, 255); FColor GizmoAxisColorsZHighX = FColor(255, 50, 50, 255);
@@ -136,6 +148,12 @@ struct FCogDebugData
UPROPERTY(Config) UPROPERTY(Config)
FColor GizmoAxisColorsSelectionW = FColor(255, 255, 0, 255); 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) UPROPERTY(Config)
TArray<FString> SecondaryBoneWildcards = { TArray<FString> SecondaryBoneWildcards = {
"interaction", "interaction",
@@ -163,7 +181,7 @@ struct FCogDebugData
}; };
}; };
struct COGDEBUG_API FCogDebugSettings struct COGDEBUG_API FCogDebug
{ {
public: public:
@@ -204,7 +222,7 @@ public:
static void Reset(); static void Reset();
static FCogDebugData Data; static FCogDebugSettings Settings;
private: private:
@@ -12,6 +12,8 @@ class COGDEBUG_API FCogDebugDrawHelper
{ {
public: public:
static void DrawArc(const UWorld* InWorld, 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 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* 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 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 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);
@@ -3,6 +3,22 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "CogDebugGizmo.generated.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() UENUM()
enum class ECogDebug_GizmoType : uint8 enum class ECogDebug_GizmoType : uint8
@@ -59,9 +75,10 @@ struct FCogDebug_GizmoElement
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebug_Gizmo struct COGDEBUG_API FCogDebug_Gizmo
{ {
void Draw(const APlayerController& InPlayerController, FTransform& InOutTransform); void Draw(const char* Id, const APlayerController& InPlayerController, FTransform& InOutTransform, ECogDebug_GizmoFlags Flags = ECogDebug_GizmoFlags::None);
bool UseLocalSpace = false;
ECogDebug_GizmoElementType DraggedElementType = ECogDebug_GizmoElementType::MAX; ECogDebug_GizmoElementType DraggedElementType = ECogDebug_GizmoElementType::MAX;
FVector2D CursorOffset = FVector2D::ZeroVector; FVector2D CursorOffset = FVector2D::ZeroVector;
FVector InitialScale = FVector::OneVector; FTransform InitialTransform = FTransform::Identity;
}; };
@@ -1,14 +1,13 @@
#include "CogEngineWindow_CollisionTester.h" #include "CogEngineWindow_CollisionTester.h"
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogEngineDataAsset.h" #include "CogEngineDataAsset.h"
#include "CogImGuiHelper.h" #include "CogImGuiHelper.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "Components/PrimitiveComponent.h" #include "Components/PrimitiveComponent.h"
#include "Components/SceneComponent.h" #include "Components/SceneComponent.h"
#include "imgui.h" #include "imgui.h"
#include "Kismet/GameplayStatics.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_CollisionTester::Initialize() void FCogEngineWindow_CollisionTester::Initialize()
@@ -25,11 +24,7 @@ void FCogEngineWindow_CollisionTester::Initialize()
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_CollisionTester::RenderHelp() void FCogEngineWindow_CollisionTester::RenderHelp()
{ {
ImGui::Text("This window is used to inspect collisions by performing a collision query with the selected channels. " ImGui::Text("This window is used to test a collision query.");
"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()))
);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -84,35 +79,6 @@ void FCogEngineWindow_CollisionTester::RenderContent()
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::ComboboxEnum("Placement", Config->Placement);
if (Config->Placement == ECogEngine_CollisionQueryPlacement::Selection)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("Location", &Config->LocationStart.X, 1.0f, 0.0f, 0.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("Rotation", &Config->Rotation.Pitch, 1.0f, 0.0f, 0.0f, "%.1f");
}
else if (Config->Placement == ECogEngine_CollisionQueryPlacement::Transform)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("Start Location", &Config->LocationStart.X, 1.0f, 0.0f, 0.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("End Location", &Config->LocationEnd.X, 1.0f, 0.0f, 0.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("Rotation", &Config->Rotation.Pitch, 1.0f, 0.0f, 0.0f, "%.1f");
}
if (Config->Type == ECogEngine_CollisionQueryType::LineTrace || Config->Type == ECogEngine_CollisionQueryType::Sweep)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::SliderFloat("Distance", &Config->QueryLength, 0.0f, 20000.0f, "%0.f");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::ComboboxEnum("Type", Config->Type); FCogWindowWidgets::ComboboxEnum("Type", Config->Type);
@@ -124,31 +90,11 @@ void FCogEngineWindow_CollisionTester::RenderContent()
//------------------------------------------------- //-------------------------------------------------
if (Config->By == ECogEngine_CollisionQueryBy::Channel) if (Config->By == ECogEngine_CollisionQueryBy::Channel)
{ {
const FName SelectedChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(Config->Channel);
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
if (ImGui::BeginCombo("Channel", TCHAR_TO_ANSI(*SelectedChannelName.ToString()), ImGuiComboFlags_HeightLarge)) ECollisionChannel Channel = Config->Channel.GetValue();
if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel))
{ {
for (int32 ChannelIndex = 0; ChannelIndex < (int32)ECC_MAX; ++ChannelIndex) Config->Channel = Channel;
{
const FChannel& Channel = Channels[ChannelIndex];
if (Channel.IsValid == false)
{
continue;
}
ImGui::PushID(ChannelIndex);
const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex);
if (ImGui::Selectable(TCHAR_TO_ANSI(*ChannelName.ToString())))
{
Config->Channel = ChannelIndex;
}
ImGui::PopID();
}
ImGui::EndCombo();
} }
} }
//------------------------------------------------- //-------------------------------------------------
@@ -225,9 +171,14 @@ void FCogEngineWindow_CollisionTester::RenderContent()
} }
} }
ImGui::Checkbox("Multi", &Config->MultiHits);
ImGui::Checkbox("Complex", &Config->TraceComplex);
//------------------------------------------------- //-------------------------------------------------
// Shape // Shape
//------------------------------------------------- //-------------------------------------------------
ImGui::Separator();
if (Config->Type != ECogEngine_CollisionQueryType::LineTrace) if (Config->Type != ECogEngine_CollisionQueryType::LineTrace)
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
@@ -238,33 +189,29 @@ void FCogEngineWindow_CollisionTester::RenderContent()
case ECogEngine_CollisionQueryShape::Sphere: case ECogEngine_CollisionQueryShape::Sphere:
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Sphere Radius", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f"); FCogImguiHelper::DragDouble("Sphere Radius", &Config->ShapeExtent.X, 0.1f, 0, FLT_MAX, "%.1f");
break; break;
} }
case ECogEngine_CollisionQueryShape::Box: case ECogEngine_CollisionQueryShape::Box:
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat3("Box Extent", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f"); FCogImguiHelper::DragFVector("Box Extent", Config->ShapeExtent, 0.1f, 0, FLT_MAX, "%.1f");
break; break;
} }
case ECogEngine_CollisionQueryShape::Capsule: case ECogEngine_CollisionQueryShape::Capsule:
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Capsule Radius", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f"); FCogImguiHelper::DragDouble("Capsule Radius", &Config->ShapeExtent.X, 0.1f, 0, FLT_MAX, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Capsule Half Height", &Config->ShapeExtent.Z, 0.1f, 0, 100.0f, "%.1f"); FCogImguiHelper::DragDouble("Capsule Half Height", &Config->ShapeExtent.Z, 0.1f, 0, FLT_MAX, "%.1f");
break; break;
} }
} }
} }
ImGui::Checkbox("Multi", &Config->MultiHits);
ImGui::Checkbox("Complex", &Config->TraceComplex);
Query(); Query();
} }
@@ -280,54 +227,13 @@ void FCogEngineWindow_CollisionTester::Query()
return; return;
} }
FVector QueryStart = FVector::ZeroVector; FVector QueryStart = Config->LocationStart;
FVector QueryEnd = FVector::ZeroVector; FVector QueryEnd = Config->LocationEnd;
FQuat QueryRotation = FQuat::Identity; FQuat QueryRotation = FQuat(Config->Rotation);
TArray<FHitResult> Hits; TArray<FHitResult> Hits;
TArray<FOverlapResult> Overlaps; TArray<FOverlapResult> Overlaps;
bool HasHits = false; bool HasHits = false;
switch (Config->Placement)
{
case ECogEngine_CollisionQueryPlacement::Selection:
{
if (const AActor* Selection = GetSelection())
{
QueryStart = Selection->GetActorLocation() + FVector(Config->LocationStart);
QueryRotation = Selection->GetActorQuat() * FQuat(FRotator(Config->Rotation));
QueryEnd = QueryStart + Selection->GetActorQuat().GetForwardVector() * Config->QueryLength;
}
break;
}
case ECogEngine_CollisionQueryPlacement::View:
{
FRotator Rotation;
PlayerController->GetPlayerViewPoint(QueryStart, Rotation);
QueryRotation = FQuat(Rotation);
QueryEnd = QueryStart + QueryRotation.GetForwardVector() * Config->QueryLength;
break;
}
case ECogEngine_CollisionQueryPlacement::Cursor:
{
FVector Direction;
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
const ImVec2 ViewportPos = Viewport != nullptr ? Viewport->Pos : ImVec2(0, 0);
UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToFVector2D(ImGui::GetMousePos() - ViewportPos), QueryStart, Direction);
QueryEnd = QueryStart + Direction * Config->QueryLength;
break;
}
case ECogEngine_CollisionQueryPlacement::Transform:
{
QueryStart = FVector(Config->LocationStart);
QueryEnd = FVector(Config->LocationEnd);
QueryRotation = FQuat(FRotator(Config->Rotation));
break;
}
}
static const FName TraceTag(TEXT("FCogWindow_Collision")); static const FName TraceTag(TEXT("FCogWindow_Collision"));
FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), Config->TraceComplex); FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), Config->TraceComplex);
@@ -341,7 +247,7 @@ void FCogEngineWindow_CollisionTester::Query()
{ {
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->ShapeExtent.X); break; case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->ShapeExtent.X); break;
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->ShapeExtent.X, Config->ShapeExtent.Z); break; case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->ShapeExtent.X, Config->ShapeExtent.Z); break;
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(Config->ShapeExtent); break; case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(FVector3f(Config->ShapeExtent)); break;
} }
} }
@@ -515,12 +421,12 @@ void FCogEngineWindow_CollisionTester::Query()
GetWorld(), GetWorld(),
QueryStart, QueryStart,
QueryEnd, QueryEnd,
FCogDebugSettings::Data.ArrowSize, FCogDebug::Settings.ArrowSize,
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
if (bIsUsingShape) if (bIsUsingShape)
@@ -547,7 +453,7 @@ void FCogEngineWindow_CollisionTester::Query()
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0)); FCogDebug::GetDebugDepthPriority(0));
} }
if (Config->DrawHitImpactPoints) if (Config->DrawHitImpactPoints)
@@ -559,7 +465,7 @@ void FCogEngineWindow_CollisionTester::Query()
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0)); FCogDebug::GetDebugDepthPriority(0));
} }
if (bIsUsingShape && Config->DrawHitShapes) if (bIsUsingShape && Config->DrawHitShapes)
@@ -573,12 +479,12 @@ void FCogEngineWindow_CollisionTester::Query()
GetWorld(), GetWorld(),
Hit.Location, Hit.Location,
Hit.Location + Hit.Normal * 20.0f, Hit.Location + Hit.Normal * 20.0f,
FCogDebugSettings::Data.ArrowSize, FCogDebug::Settings.ArrowSize,
FLinearColor(Config->NormalColor).ToFColor(true), FLinearColor(Config->NormalColor).ToFColor(true),
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
if (Config->DrawHitImpactNormals) if (Config->DrawHitImpactNormals)
@@ -587,12 +493,12 @@ void FCogEngineWindow_CollisionTester::Query()
GetWorld(), GetWorld(),
Hit.ImpactPoint, Hit.ImpactPoint,
Hit.ImpactPoint + Hit.ImpactNormal * 20.0f, Hit.ImpactPoint + Hit.ImpactNormal * 20.0f,
FCogDebugSettings::Data.ArrowSize, FCogDebug::Settings.ArrowSize,
FLinearColor(Config->ImpactNormalColor).ToFColor(true), FLinearColor(Config->ImpactNormalColor).ToFColor(true),
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
if (Config->DrawHitPrimitives) if (Config->DrawHitPrimitives)
@@ -605,15 +511,17 @@ void FCogEngineWindow_CollisionTester::Query()
{ {
FVector ScaleStart(Config->ShapeExtent); FVector ScaleStart(Config->ShapeExtent);
FTransform TransformStart(QueryRotation, QueryStart, ScaleStart); FTransform TransformStart(QueryRotation, QueryStart, ScaleStart);
GizmoStart.Draw(*LocalPlayerController, TransformStart); GizmoStart.Draw("Query Start", *LocalPlayerController, TransformStart);
Config->LocationStart = FVector3f(TransformStart.GetLocation()); Config->LocationStart = TransformStart.GetLocation();
Config->ShapeExtent = FVector3f(TransformStart.GetScale3D()); Config->Rotation = FRotator(TransformStart.GetRotation());
Config->ShapeExtent = TransformStart.GetScale3D();
FVector ScaleEnd(Config->ShapeExtent); if (Config->Type != ECogEngine_CollisionQueryType::Overlap)
FTransform TransformEnd(QueryRotation, QueryEnd, ScaleEnd); {
GizmoEnd.Draw(*LocalPlayerController, TransformEnd); FTransform TransformEnd(FRotator::ZeroRotator, QueryEnd, FVector::OneVector);
Config->LocationEnd = FVector3f(TransformEnd.GetLocation()); GizmoEnd.Draw("Query End", *LocalPlayerController, TransformEnd, ECogDebug_GizmoFlags::NoRotation | ECogDebug_GizmoFlags::NoScale);
Config->ShapeExtent = FVector3f(TransformEnd.GetScale3D()); Config->LocationEnd = TransformEnd.GetLocation();
}
} }
} }
@@ -644,7 +552,7 @@ void FCogEngineWindow_CollisionTester::DrawPrimitive(const UPrimitiveComponent*
if (AlreadyDrawnActors.Contains(Actor) == false) if (AlreadyDrawnActors.Contains(Actor) == false)
{ {
FColor TextColor = Color.WithAlpha(255); FColor TextColor = Color.WithAlpha(255);
DrawDebugString(GetWorld(), Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::Data.TextShadow, FCogDebugSettings::Data.TextSize); DrawDebugString(GetWorld(), Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebug::Settings.TextShadow, FCogDebug::Settings.TextSize);
AlreadyDrawnActors.Add(Actor); AlreadyDrawnActors.Add(Actor);
} }
} }
@@ -679,7 +587,7 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0)); FCogDebug::GetDebugDepthPriority(0));
} }
DrawDebugBox( DrawDebugBox(
@@ -690,8 +598,8 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
break; break;
} }
@@ -708,12 +616,12 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
GetWorld(), GetWorld(),
Location, Location,
Radius, Radius,
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
break; break;
} }
@@ -734,8 +642,8 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
break; break;
} }
} }
@@ -1,7 +1,7 @@
#include "CogEngineWindow_CollisionViewer.h" #include "CogEngineWindow_CollisionViewer.h"
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogEngineDataAsset.h" #include "CogEngineDataAsset.h"
#include "CogImguiHelper.h" #include "CogImguiHelper.h"
#include "CogWindowHelper.h" #include "CogWindowHelper.h"
@@ -260,7 +260,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
if (Config->ShowQuery) if (Config->ShowQuery)
{ {
FCogDebugDrawHelper::DrawCapsuleCastMulti(World, QueryStart, QueryEnd, FQuat::Identity, 0.0f, QueryRadius, EDrawDebugTrace::ForOneFrame, false, QueryHits, FLinearColor::White, FLinearColor::Red, FCogDebugSettings::GetDebugDuration(true)); FCogDebugDrawHelper::DrawCapsuleCastMulti(World, QueryStart, QueryEnd, FQuat::Identity, 0.0f, QueryRadius, EDrawDebugTrace::ForOneFrame, false, QueryHits, FLinearColor::White, FLinearColor::Red, FCogDebug::GetDebugDuration(true));
} }
TSet<const AActor*> AlreadyDrawnActors; TSet<const AActor*> AlreadyDrawnActors;
@@ -292,7 +292,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
if (AlreadyDrawnActors.Contains(Actor) == false) if (AlreadyDrawnActors.Contains(Actor) == false)
{ {
FColor TextColor = Color.WithAlpha(255); FColor TextColor = Color.WithAlpha(255);
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::Data.TextShadow, FCogDebugSettings::Data.TextSize); DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebug::Settings.TextShadow, FCogDebug::Settings.TextSize);
AlreadyDrawnActors.Add(Actor); AlreadyDrawnActors.Add(Actor);
} }
} }
@@ -331,7 +331,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0)); FCogDebug::GetDebugDepthPriority(0));
DrawDebugBox( DrawDebugBox(
World, World,
@@ -341,8 +341,8 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
break; break;
} }
@@ -355,12 +355,12 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
World, World,
SphereComponent->GetComponentLocation(), SphereComponent->GetComponentLocation(),
SphereComponent->GetScaledSphereRadius(), SphereComponent->GetScaledSphereRadius(),
FCogDebugSettings::GetCircleSegments(), FCogDebug::GetCircleSegments(),
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
break; break;
} }
@@ -377,8 +377,8 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
Color, Color,
false, false,
0.0f, 0.0f,
FCogDebugSettings::GetDebugDepthPriority(0), FCogDebug::GetDebugDepthPriority(0),
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
break; break;
} }
@@ -1,7 +1,9 @@
#include "CogEngineWindow_DebugSettings.h" #include "CogEngineWindow_DebugSettings.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogImGuiHelper.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "imgui_internal.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_DebugSettings::RenderHelp() void FCogEngineWindow_DebugSettings::RenderHelp()
@@ -21,8 +23,8 @@ void FCogEngineWindow_DebugSettings::Initialize()
Config = GetConfig<UCogEngineConfig_DebugSettings>(); Config = GetConfig<UCogEngineConfig_DebugSettings>();
FCogDebugSettings::Data = Config->Data; FCogDebug::Settings = Config->Data;
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection); FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -38,7 +40,7 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig()
{ {
Super::PreSaveConfig(); Super::PreSaveConfig();
Config->Data = FCogDebugSettings::Data; Config->Data = FCogDebug::Settings;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -52,7 +54,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
{ {
if (ImGui::MenuItem("Reset")) if (ImGui::MenuItem("Reset"))
{ {
FCogDebugSettings::Reset(); FCogDebug::Reset();
} }
ImGui::Checkbox("Show Advanced Settings", &Config->bShowAdvancedSettings); ImGui::Checkbox("Show Advanced Settings", &Config->bShowAdvancedSettings);
@@ -63,109 +65,109 @@ void FCogEngineWindow_DebugSettings::RenderContent()
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
Config->Data.bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection(); Config->Data.bIsFilteringBySelection = FCogDebug::GetIsFilteringBySelection();
if (ImGui::Checkbox("Filter by selection", &Config->Data.bIsFilteringBySelection)) if (ImGui::Checkbox("Filter by selection", &Config->Data.bIsFilteringBySelection))
{ {
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection); FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
} }
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) 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::SetTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
} }
FCogDebugData& Data = FCogDebugSettings::Data; FCogDebugSettings& Settings = FCogDebug::Settings;
ImGui::Checkbox("Persistent", &Data.Persistent); ImGui::Checkbox("Persistent", &Settings.Persistent);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("Make debug draw always persist"); ImGui::SetTooltip("Make debug draw always persist");
} }
ImGui::Checkbox("Text Shadow", &Data.TextShadow); ImGui::Checkbox("Text Shadow", &Settings.TextShadow);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("Show a shadow below debug text."); ImGui::SetTooltip("Show a shadow below debug text.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::Checkbox("Fade 2D", &Data.Fade2D); ImGui::Checkbox("Fade 2D", &Settings.Fade2D);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("Does the 2D debug is fading out."); ImGui::SetTooltip("Does the 2D debug is fading out.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Duration", &Data.Duration, 0.01f, 0.0f, 100.0f, "%.1f"); ImGui::DragFloat("Duration", &Settings.Duration, 0.01f, 0.0f, 100.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The duration of debug elements."); ImGui::SetTooltip("The duration of debug elements.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Thickness", &Data.Thickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::DragFloat("Thickness", &Settings.Thickness, 0.05f, 0.0f, 5.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The thickness of debug lines."); ImGui::SetTooltip("The thickness of debug lines.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Server Thickness", &Data.ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::DragFloat("Server Thickness", &Settings.ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The thickness the server debug lines."); ImGui::SetTooltip("The thickness the server debug lines.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Server Color Mult", &Data.ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f"); ImGui::DragFloat("Server Color Mult", &Settings.ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The color multiplier applied to the server debug lines."); ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Depth Priority", &Data.DepthPriority, 0.1f, 0, 100); ImGui::DragInt("Depth Priority", &Settings.DepthPriority, 0.1f, 0, 100);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The depth priority of debug elements."); ImGui::SetTooltip("The depth priority of debug elements.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Segments", &Data.Segments, 0.1f, 4, 20.0f); ImGui::DragInt("Segments", &Settings.Segments, 0.1f, 4, 20.0f);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The number of segments used for circular shapes."); ImGui::SetTooltip("The number of segments used for circular shapes.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Axes Scale", &Data.AxesScale, 0.1f, 0, 10.0f, "%.1f"); ImGui::DragFloat("Axes Scale", &Settings.AxesScale, 0.1f, 0, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The scaling debug axis."); ImGui::SetTooltip("The scaling debug axis.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Arrow Size", &Data.ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f"); ImGui::DragFloat("Arrow Size", &Settings.ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The size of debug arrows."); ImGui::SetTooltip("The size of debug arrows.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gradient Intensity", &Data.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); ImGui::DragFloat("Gradient Intensity", &Settings.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time."); ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gradient Speed", &Data.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::DragFloat("Gradient Speed", &Settings.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The speed of the gradient color change."); ImGui::SetTooltip("The speed of the gradient color change.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Text Size", &Data.TextSize, 0.1f, 0.1f, 5.0f, "%.1f"); ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The size of the debug texts."); ImGui::SetTooltip("The size of the debug texts.");
@@ -177,7 +179,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Scale", &Data.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f"); ImGui::DragFloat("Gizmo Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
ImGui::SetTooltip("The scale of the gizmo."); ImGui::SetTooltip("The scale of the gizmo.");
@@ -186,57 +188,73 @@ void FCogEngineWindow_DebugSettings::RenderContent()
if (Config->bShowAdvancedSettings) if (Config->bShowAdvancedSettings)
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Axis Length", &Data.GizmoAxisLength, 0.1f, 0.1f, 500.0f, "%.1f"); ImGui::DragFloat("Gizmo Axis Length", &Settings.GizmoAxisLength, 0.1f, 0.1f, 500.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Gizmo Z Low", &Data.GizmoZLow, 0.5f, 0, 1000); ImGui::DragInt("Gizmo Z Low", &Settings.GizmoZLow, 0.5f, 0, 1000);
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Gizmo Z High", &Data.GizmoZHigh, 0.5f, 0, 1000); ImGui::DragInt("Gizmo Z High", &Settings.GizmoZHigh, 0.5f, 0, 1000);
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Thickness Z Low", &Data.GizmoThicknessZLow, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::DragFloat("Gizmo Thickness Z Low", &Settings.GizmoThicknessZLow, 0.1f, 0.0f, 10.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Thickness Z High", &Data.GizmoThicknessZHigh, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::DragFloat("Gizmo Thickness Z High", &Settings.GizmoThicknessZHigh, 0.1f, 0.0f, 10.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Mouse Max Distance", &Data.GizmoMouseMaxDistance, 0.1f, 0.0f, 50.0f, "%.1f"); ImGui::DragFloat("Gizmo Mouse Max Distance", &Settings.GizmoCursorSelectionThreshold, 0.1f, 0.0f, 50.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Plane Offset", &Data.GizmoPlaneOffset, 0.1f, 0.0f, 500.0f, "%.1f"); ImGui::DragFloat("Gizmo Plane Offset", &Settings.GizmoPlaneOffset, 0.1f, 0.0f, 500.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Plane Extent", &Data.GizmoPlaneExtent, 0.1f, 0.0f, 100.0f, "%.1f"); ImGui::DragFloat("Gizmo Plane Extent", &Settings.GizmoPlaneExtent, 0.1f, 0.0f, 100.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Scale Box Extent", &Data.GizmoScaleBoxExtent, 0.1f, 0.0f, 100.0f, "%.1f"); ImGui::DragFloat("Gizmo Scale Box Extent", &Settings.GizmoScaleBoxExtent, 0.1f, 0.0f, 100.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Scale Speed", &Data.GizmoScaleSpeed, 0.1f, 0.0f, 100.0f, "%.1f"); ImGui::DragFloat("Gizmo Scale Speed", &Settings.GizmoScaleSpeed, 0.01f, 0.01f, 100.0f, "%.2f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Scale Min", &Data.GizmoScaleMin, 0.001f, 0.001f, 1.0f, "%.3f"); ImGui::DragFloat("Gizmo Scale Min", &Settings.GizmoScaleMin, 0.001f, 0.001f, 1.0f, "%.3f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Rotation Radius", &Data.GizmoRotationRadius, 0.1f, 0.1f, 500.0f, "%.1f"); ImGui::DragFloat("Gizmo Rotation Radius", &Settings.GizmoRotationRadius, 0.1f, 0.1f, 500.0f, "%.1f");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Gizmo Rotation Segments", &Data.GizmoRotationSegments, 1.0f, 0, 64); ImGui::DragInt("Gizmo Rotation Segments", &Settings.GizmoRotationSegments, 0.5f, 2, 12);
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow X", Data.GizmoAxisColorsZLowX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow Y", Data.GizmoAxisColorsZLowY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::DragFloat("Gizmo Ground Raycast Length", &Settings.GizmoGroundRaycastLength, 10.0f, 0.0f, 1000000.0f, "%.0f");
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow Z", Data.GizmoAxisColorsZLowZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow W", Data.GizmoAxisColorsZLowW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh X", Data.GizmoAxisColorsZHighX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh Y", Data.GizmoAxisColorsZHighY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ECollisionChannel Channel = Settings.GizmoGroundRaycastChannel.GetValue();
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh Z", Data.GizmoAxisColorsZHighZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel))
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh W", Data.GizmoAxisColorsZHighW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); {
Settings.GizmoGroundRaycastChannel = Channel;
}
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection X", Data.GizmoAxisColorsSelectionX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection Y", Data.GizmoAxisColorsSelectionY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::DragFloat("Gizmo Ground Raycast Circle Radius", &Settings.GizmoGroundRaycastCircleRadius, 0.1f, 0.1f, 1000.0f, "%.1f");
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection Z", Data.GizmoAxisColorsSelectionZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection W", Data.GizmoAxisColorsSelectionW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZLow X", Settings.GizmoAxisColorsZLowX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZLow Y", Settings.GizmoAxisColorsZLowY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZLow Z", Settings.GizmoAxisColorsZLowZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZLow W", Settings.GizmoAxisColorsZLowW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZHigh X", Settings.GizmoAxisColorsZHighX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZHigh Y", Settings.GizmoAxisColorsZHighY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZHigh Z", Settings.GizmoAxisColorsZHighZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors ZHigh W", Settings.GizmoAxisColorsZHighW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors Selection X", Settings.GizmoAxisColorsSelectionX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors Selection Y", Settings.GizmoAxisColorsSelectionY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors Selection Z", Settings.GizmoAxisColorsSelectionZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Axis Colors Selection W", Settings.GizmoAxisColorsSelectionW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Ground Raycast Color", Settings.GizmoGroundRaycastColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
FCogImguiHelper::ColorEdit4("Gizmo Ground Raycast Circle Color", Settings.GizmoGroundRaycastCircleColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
} }
} }
@@ -1,7 +1,7 @@
#include "CogEngineWindow_LogCategories.h" #include "CogEngineWindow_LogCategories.h"
#include "CogDebugHelper.h" #include "CogDebugHelper.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "CogDebugLog.h" #include "CogDebugLog.h"
#include "DrawDebugHelpers.h" #include "DrawDebugHelpers.h"
@@ -74,12 +74,12 @@ void FCogEngineWindow_LogCategories::RenderContent()
ImGui::EndMenu(); ImGui::EndMenu();
} }
bool bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection(); bool bIsFilteringBySelection = FCogDebug::GetIsFilteringBySelection();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2);
FCogWindowWidgets::PushStyleCompact(); FCogWindowWidgets::PushStyleCompact();
if (ImGui::Checkbox("Filter", &bIsFilteringBySelection)) if (ImGui::Checkbox("Filter", &bIsFilteringBySelection))
{ {
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection); FCogDebug::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection);
} }
FCogWindowWidgets::PopStyleCompact(); FCogWindowWidgets::PopStyleCompact();
@@ -82,7 +82,7 @@ void FCogEngineWindow_Plots::RenderMenu()
{ {
if (ImGui::BeginMenu("Options")) if (ImGui::BeginMenu("Options"))
{ {
if (ImGui::MenuItem("Clear Data")) if (ImGui::MenuItem("Clear Settings"))
{ {
FCogDebugPlot::Clear(); FCogDebugPlot::Clear();
} }
@@ -1,7 +1,7 @@
#include "CogEngineWindow_Selection.h" #include "CogEngineWindow_Selection.h"
#include "CogDebugDraw.h" #include "CogDebugDraw.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogEngineReplicator.h" #include "CogEngineReplicator.h"
#include "CogImguiHelper.h" #include "CogImguiHelper.h"
#include "CogImguiInputHelper.h" #include "CogImguiInputHelper.h"
@@ -170,7 +170,7 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime)
{ {
Super::RenderTick(DeltaTime); Super::RenderTick(DeltaTime);
if (FCogDebugSettings::GetSelection() == nullptr) if (FCogDebug::GetSelection() == nullptr)
{ {
SetGlobalSelection(GetLocalPlayerPawn()); SetGlobalSelection(GetLocalPlayerPawn());
} }
@@ -265,7 +265,7 @@ bool FCogEngineWindow_Selection::DrawSelectionCombo()
ImGui::PushStyleColor(ImGuiCol_Text, Actor == LocalPlayerPawn ? IM_COL32(255, 255, 0, 255) : IM_COL32(255, 255, 255, 255)); 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)) if (ImGui::Selectable(TCHAR_TO_ANSI(*GetActorName(*Actor)), bIsSelected))
{ {
SetGlobalSelection(Actor); SetGlobalSelection(Actor);
@@ -417,7 +417,7 @@ void FCogEngineWindow_Selection::TickSelectionMode()
// Prioritize another actor than the selected actor unless we only touch the selected actor. // Prioritize another actor than the selected actor unless we only touch the selected actor.
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
TArray<AActor*> IgnoreList; TArray<AActor*> IgnoreList;
IgnoreList.Add(FCogDebugSettings::GetSelection()); IgnoreList.Add(FCogDebug::GetSelection());
FHitResult HitResult; FHitResult HitResult;
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
@@ -616,7 +616,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, floa
ImGui::EndPopup(); ImGui::EndPopup();
} }
AActor* GlobalSelection = FCogDebugSettings::GetSelection(); AActor* GlobalSelection = FCogDebug::GetSelection();
//----------------------------------- //-----------------------------------
// Selection // Selection
@@ -668,7 +668,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, floa
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const
{ {
FCogDebugSettings::SetSelection(GetWorld(), Value); FCogDebug::SetSelection(GetWorld(), Value);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -1,6 +1,6 @@
#include "CogEngineWindow_Skeleton.h" #include "CogEngineWindow_Skeleton.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "Components/LineBatchComponent.h" #include "Components/LineBatchComponent.h"
#include "Components/SkeletalMeshComponent.h" #include "Components/SkeletalMeshComponent.h"
@@ -80,7 +80,7 @@ void FCogEngineWindow_Skeleton::RefreshSkeleton()
CurrentBoneInfo.Name = ReferenceSkeleton.GetBoneName(BoneIndex); CurrentBoneInfo.Name = ReferenceSkeleton.GetBoneName(BoneIndex);
const FTransform Transform = ComponentSpaceTransforms[BoneIndex] * WorldTransform; const FTransform Transform = ComponentSpaceTransforms[BoneIndex] * WorldTransform;
CurrentBoneInfo.LastLocation = Transform.GetLocation(); CurrentBoneInfo.LastLocation = Transform.GetLocation();
CurrentBoneInfo.IsSecondaryBone = FCogDebugSettings::IsSecondarySkeletonBone(CurrentBoneInfo.Name); CurrentBoneInfo.IsSecondaryBone = FCogDebug::IsSecondarySkeletonBone(CurrentBoneInfo.Name);
CurrentBoneInfo.ShowBone = !(HideSecondaryBones && CurrentBoneInfo.IsSecondaryBone); CurrentBoneInfo.ShowBone = !(HideSecondaryBones && CurrentBoneInfo.IsSecondaryBone);
const int32 ParentIndex = ReferenceSkeleton.GetParentIndex(BoneIndex); const int32 ParentIndex = ReferenceSkeleton.GetParentIndex(BoneIndex);
@@ -315,13 +315,13 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
if (ShowBones) if (ShowBones)
{ {
::DrawDebugLine(World, ParentLocation, BoneLocation, IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1, FCogDebugSettings::GetDebugThickness(IsHovered ? 0.5f : 0.0f)); ::DrawDebugLine(World, ParentLocation, BoneLocation, IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1, FCogDebug::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); ::DrawDebugPoint(World, BoneLocation, FCogDebug::GetDebugThickness(IsHovered ? 6.0f : 4.0f), IsHovered ? FColor::Red : FColor::White, false, 0.0f, 1);
} }
if (ShowNames || BoneInfo.ShowName || IsHovered) if (ShowNames || BoneInfo.ShowName || IsHovered)
{ {
::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebugSettings::Data.TextSize); ::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebug::Settings.TextSize);
} }
if (ShowAxes || BoneInfo.ShowAxes) if (ShowAxes || BoneInfo.ShowAxes)
@@ -330,11 +330,11 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
World, World,
BoneLocation, BoneLocation,
BoneRotation, BoneRotation,
10.0f * FCogDebugSettings::Data.AxesScale, 10.0f * FCogDebug::Settings.AxesScale,
false, false,
0.0f, 0.0f,
1, 1,
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
if (ShowVelocities || BoneInfo.ShowLocalVelocity) if (ShowVelocities || BoneInfo.ShowLocalVelocity)
@@ -345,35 +345,35 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
World, World,
BoneLocation, BoneLocation,
BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(), BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(),
FCogDebugSettings::Data.ArrowSize, FCogDebug::Settings.ArrowSize,
FCogDebugSettings::ModulateDebugColor(World, FColor::Cyan), FCogDebug::ModulateDebugColor(World, FColor::Cyan),
FCogDebugSettings::GetDebugPersistent(true), FCogDebug::GetDebugPersistent(true),
FCogDebugSettings::GetDebugDuration(true), FCogDebug::GetDebugDuration(true),
0, 0,
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
} }
} }
if (ShowTrajectories || BoneInfo.ShowTrajectory) if (ShowTrajectories || BoneInfo.ShowTrajectory)
{ {
const FColor Color = FCogDebugSettings::ModulateDebugColor(World, FColor::Yellow); const FColor Color = FCogDebug::ModulateDebugColor(World, FColor::Yellow);
DrawDebugLine( DrawDebugLine(
World, World,
BoneInfo.LastLocation, BoneInfo.LastLocation,
BoneLocation, BoneLocation,
Color, Color,
FCogDebugSettings::GetDebugPersistent(true), FCogDebug::GetDebugPersistent(true),
FCogDebugSettings::GetDebugDuration(true), FCogDebug::GetDebugDuration(true),
0, 0,
FCogDebugSettings::GetDebugThickness(0.0f)); FCogDebug::GetDebugThickness(0.0f));
DrawDebugPoint( DrawDebugPoint(
World, World,
BoneLocation, BoneLocation,
FCogDebugSettings::GetDebugThickness(2.0f), FCogDebug::GetDebugThickness(2.0f),
Color, Color,
FCogDebugSettings::GetDebugPersistent(true), FCogDebug::GetDebugPersistent(true),
FCogDebugSettings::GetDebugDuration(true), FCogDebug::GetDebugDuration(true),
0); 0);
} }
@@ -12,16 +12,6 @@ class UCogEngineDataAsset;
class UPrimitiveComponent; class UPrimitiveComponent;
struct FCollisionShape; struct FCollisionShape;
//--------------------------------------------------------------------------------------------------------------------------
UENUM()
enum class ECogEngine_CollisionQueryPlacement : uint8
{
Selection,
View,
Cursor,
Transform,
};
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
UENUM() UENUM()
enum class ECogEngine_CollisionQueryType : uint8 enum class ECogEngine_CollisionQueryType : uint8
@@ -57,6 +47,9 @@ enum class ECogEngine_CollisionQueryShape : uint8
Capsule, Capsule,
}; };
enum class ECogDebug_GizmoTransformSpace : uint8;
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
class COGENGINE_API FCogEngineWindow_CollisionTester : public FCogWindow class COGENGINE_API FCogEngineWindow_CollisionTester : public FCogWindow
{ {
@@ -69,6 +62,7 @@ public:
protected: protected:
virtual void ResetConfig() override; virtual void ResetConfig() override;
void DoWork(const UCollisionProfile* CollisionProfile);
virtual void RenderHelp() override; virtual void RenderHelp() override;
@@ -117,19 +111,16 @@ class UCogEngineConfig_CollisionTester : public UCogWindowConfig
public: public:
UPROPERTY(Config) UPROPERTY(Config)
ECogEngine_CollisionQueryPlacement Placement; FVector LocationStart;
UPROPERTY(Config) UPROPERTY(Config)
FVector3f LocationStart; FVector LocationEnd;
UPROPERTY(Config) UPROPERTY(Config)
FVector3f LocationEnd; FRotator Rotation;
UPROPERTY(Config) UPROPERTY(Config)
FRotator3f Rotation; FVector Scale;
UPROPERTY(Config)
FRotator3f Scale;
UPROPERTY(Config) UPROPERTY(Config)
ECogEngine_CollisionQueryType Type; ECogEngine_CollisionQueryType Type;
@@ -153,19 +144,13 @@ public:
FName Profile; FName Profile;
UPROPERTY(Config) UPROPERTY(Config)
int32 Channel; TEnumAsByte<ECollisionChannel> Channel;
UPROPERTY(Config) UPROPERTY(Config)
int32 ProfileIndex; int32 ProfileIndex;
UPROPERTY(Config) UPROPERTY(Config)
FVector3f ShapeExtent; FVector ShapeExtent;
UPROPERTY(Config)
int QueryTypeOld;
UPROPERTY(Config)
float QueryLength;
UPROPERTY(Config) UPROPERTY(Config)
bool DrawHitLocations; bool DrawHitLocations;
@@ -212,18 +197,16 @@ public:
{ {
Super::Reset(); Super::Reset();
Placement = ECogEngine_CollisionQueryPlacement::Selection;
Type = ECogEngine_CollisionQueryType::LineTrace; Type = ECogEngine_CollisionQueryType::LineTrace;
By = ECogEngine_CollisionQueryBy::Channel; By = ECogEngine_CollisionQueryBy::Channel;
Shape = ECogEngine_CollisionQueryShape::Sphere; Channel = ECC_WorldStatic;
MultiHits = false; MultiHits = false;
TraceComplex = false; TraceComplex = false;
ShapeExtent = FVector3f(50.0f, 50.0f, 50.0f); Shape = ECogEngine_CollisionQueryShape::Sphere;
ShapeExtent = FVector(50.0f, 50.0f, 50.0f);
ObjectTypesToQuery = 0; ObjectTypesToQuery = 0;
ProfileIndex = 0; ProfileIndex = 0;
QueryTypeOld = 0;
QueryLength = 5000.0f;
DrawHitLocations = true; DrawHitLocations = true;
DrawHitImpactPoints = true; DrawHitImpactPoints = true;
DrawHitShapes = true; DrawHitShapes = true;
@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogWindow.h" #include "CogWindow.h"
#include "CogWindowConfig.h" #include "CogWindowConfig.h"
#include "CogEngineWindow_DebugSettings.generated.h" #include "CogEngineWindow_DebugSettings.generated.h"
@@ -39,7 +39,7 @@ class UCogEngineConfig_DebugSettings : public UCogWindowConfig
public: public:
UPROPERTY(Config) UPROPERTY(Config)
FCogDebugData Data; FCogDebugSettings Data;
UPROPERTY(Config) UPROPERTY(Config)
bool bShowAdvancedSettings = false; bool bShowAdvancedSettings = false;
@@ -47,7 +47,7 @@ public:
virtual void Reset() override virtual void Reset() override
{ {
Super::Reset(); Super::Reset();
Data = FCogDebugData(); Data = FCogDebugSettings();
bShowAdvancedSettings = false; bShowAdvancedSettings = false;
} }
}; };
@@ -146,3 +146,36 @@ void FCogImguiHelper::SetFlags(int32& Value, int32 Flags, bool EnableFlags)
Value &= ~Flags; 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::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::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;
}
@@ -124,17 +124,17 @@ FReply SCogImguiWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterE
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) 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) 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) if (Context->GetEnableInput() == false)
{ {
@@ -189,31 +189,34 @@ FReply SCogImguiWidget::OnAnalogValueChanged(const FGeometry& MyGeometry, const
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) FReply SCogImguiWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{ {
if (Context->GetEnableInput() == false) return HandleMouseButtonEvent(MouseEvent, true);
{ }
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);
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) 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) 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(); return FReply::Unhandled();
} }
const uint32 MouseButton = FCogImguiInputHelper::ToImGuiMouseButton(MouseEvent.GetEffectingButton()); const uint32 MouseButton = FCogImguiInputHelper::ToImGuiMouseButton(MouseEvent.GetEffectingButton());
ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse); ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse);
ImGui::GetIO().AddMouseButtonEvent(MouseButton, false); ImGui::GetIO().AddMouseButtonEvent(MouseButton, Down);
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::OnMouseButtonUp | Window:%s | Handled"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"));
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiWidget::HandleMouseButtonEvent | Window:%s | Handled | Down:%d"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"), Down);
return FReply::Handled(); return FReply::Handled();
} }
@@ -57,4 +57,14 @@ public:
static FSlateRenderTransform RoundTranslation(const FSlateRenderTransform& Transform); static FSlateRenderTransform RoundTranslation(const FSlateRenderTransform& Transform);
static void SetFlags(int32& Value, int32 Flags, bool EnableFlags); 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 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 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 OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
virtual FReply OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent) override; virtual FReply OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) 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 OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseWheel(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; virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
@@ -53,7 +54,8 @@ public:
protected: 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(); void RefreshVisibility();
@@ -1,7 +1,7 @@
#include "CogWindow.h" #include "CogWindow.h"
#include "CogDebugDraw.h" #include "CogDebugDraw.h"
#include "CogDebugSettings.h" #include "CogDebug.h"
#include "CogWindow_Settings.h" #include "CogWindow_Settings.h"
#include "CogWindowManager.h" #include "CogWindowManager.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
@@ -137,7 +137,7 @@ void FCogWindow::RenderHelp()
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogWindow::RenderTick(float DeltaTime) void FCogWindow::RenderTick(float DeltaTime)
{ {
SetSelection(FCogDebugSettings::GetSelection()); SetSelection(FCogDebug::GetSelection());
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -614,22 +614,37 @@ bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray<float>& Values, float& Va
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogWindowWidgets::DragFVector(const char* Label, FVector& Vector, float Speed, float Min, float Max, const char* Format, ImGuiSliderFlags Flags) bool FCogWindowWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Channel)
{ {
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 3, Speed, &Min, &Max, Format, Flags); FName SelectedChannelName;
} const UCollisionProfile* CollisionProfile = UCollisionProfile::Get();
if (CollisionProfile != nullptr)
{
SelectedChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(Channel);
}
//-------------------------------------------------------------------------------------------------------------------------- bool Result = false;
bool FCogWindowWidgets::DragFVector2D(const char* Label, FVector2D& Vector, float Speed, float Min, float Max, const char* Format, ImGuiSliderFlags Flags) if (ImGui::BeginCombo(Label, TCHAR_TO_ANSI(*SelectedChannelName.ToString()), ImGuiComboFlags_HeightLarge))
{ {
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 2, Speed, &Min, &Max, Format, Flags); for (int32 ChannelIndex = 0; ChannelIndex < (int32)ECC_MAX; ++ChannelIndex)
} {
ImGui::PushID(ChannelIndex);
const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex);
if (ChannelName.IsValid())
{
if (ImGui::Selectable(TCHAR_TO_ANSI(*ChannelName.ToString())))
{
Channel = (ECollisionChannel)ChannelIndex;
Result = true;
}
}
ImGui::PopID();
}
ImGui::EndCombo();
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogWindowWidgets::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; return Result;
} }
@@ -20,12 +20,6 @@ public:
static void EndTableTooltip(); static void EndTableTooltip();
static bool DragFVector(const char* Label, FVector& Vector, float Speed = 1.0f, float Min = 0.0f, float Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
static bool DragFVector2D(const char* Label, FVector2D& Vector, float Speed = 1.0f, float Min = 0.0f, float Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
static bool ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags = 0);
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay); static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
static bool ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor); static bool ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor);
@@ -86,6 +80,9 @@ public:
static bool DeleteArrayItemButton(); static bool DeleteArrayItemButton();
static bool ComboCollisionChannel(const char* Label, ECollisionChannel& Channel);
}; };
template<typename EnumType> template<typename EnumType>
+1 -1
View File
@@ -154,7 +154,7 @@ void UCogSampleAreaComponent::TickComponent(float DeltaTime, enum ELevelTick Tic
#if ENABLE_COG #if ENABLE_COG
const AActor* AreaInstigator = UCogSampleFunctionLibrary_Gameplay::GetInstigator(GetOwner()); 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; TArray<USceneComponent*, TInlineAllocator<8>> Components;
GetOwner()->GetComponents<USceneComponent>(Components); GetOwner()->GetComponents<USceneComponent>(Components);
+1 -1
View File
@@ -677,7 +677,7 @@ void ACogSampleCharacter::OnGhostTagNewOrRemoved(const FGameplayTag InTag, int32
void ACogSampleCharacter::OnScaleAttributeChanged(const FOnAttributeChangeData& Data) void ACogSampleCharacter::OnScaleAttributeChanged(const FOnAttributeChangeData& Data)
{ {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// 'Data.NewValue' is not used because it seems to only corresponds to the changes // 'Settings.NewValue' is not used because it seems to only corresponds to the changes
// of the BaseValue which do not account for the temporary modifiers. // of the BaseValue which do not account for the temporary modifiers.
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@@ -224,7 +224,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E
const ACharacter* Character = GetCharacterOwner(); const ACharacter* Character = GetCharacterOwner();
const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent(); 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 X", GetPendingInputVector().X);
FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input Y", GetPendingInputVector().Y); 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 DebugLocation = Character->GetActorLocation();
const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight(); const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight();
if (FCogDebugSettings::IsDebugActiveForObject(GetPawnOwner())) if (FCogDebug::IsDebugActiveForObject(GetPawnOwner()))
{ {
const FRotator Rotation = Character->GetActorRotation(); const FRotator Rotation = Character->GetActorRotation();
const FVector Forward = Character->GetActorForwardVector(); const FVector Forward = Character->GetActorForwardVector();
+2 -2
View File
@@ -5,13 +5,13 @@
#if ENABLE_COG #if ENABLE_COG
#include "CogDebugSettings.h" #include "CogDebug.h"
#define COG_LOG_ABILITY(Verbosity, Ability, Format, ...) \ #define COG_LOG_ABILITY(Verbosity, Ability, Format, ...) \
if (Ability != nullptr) \ if (Ability != nullptr) \
{ \ { \
AActor* Actor = Ability->GetAvatarActorFromActorInfo(); \ 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"), \ COG_LOG(LogCogAbility, Verbosity, TEXT("%s - %s - %s - %s"), \
*GetNameSafe(Actor), \ *GetNameSafe(Actor), \
@@ -197,7 +197,7 @@ bool UCogSampleGameplayAbility::IsCostGameplayEffectIsZero(const UGameplayEffect
const float CostValue = ModSpec.GetEvaluatedMagnitude(); const float CostValue = ModSpec.GetEvaluatedMagnitude();
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// The Cost in the Data is positive, but UCogSampleModifierCalculation_Cost negates it. // The Cost in the Settings 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) if (CostValue < 0)