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