Add Vlog on server debug shape

Add more debug recolor option
This commit is contained in:
Arnaud Jamin
2024-05-16 10:59:53 -04:00
parent 4cc44207a4
commit 1690b802ed
5 changed files with 238 additions and 94 deletions
@@ -3,8 +3,10 @@
#include "CogCommonDebugFilteredActorInterface.h" #include "CogCommonDebugFilteredActorInterface.h"
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "CogDebugReplicator.h" #include "CogDebugReplicator.h"
#include "imgui.h"
#include "Engine/World.h" #include "Engine/World.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "Kismet/KismetMathLibrary.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
TWeakObjectPtr<AActor> FCogDebug::Selection; TWeakObjectPtr<AActor> FCogDebug::Selection;
@@ -19,7 +21,7 @@ void FCogDebug::Reset()
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject) bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject)
{ {
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (World == nullptr) if (World == nullptr)
{ {
return true; return true;
@@ -188,21 +190,49 @@ FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, b
return Color; return Color;
} }
const float Time = World->GetTimeSeconds(); switch (Settings.RecolorMode)
const FLinearColor BaseColor(Color);
FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV();
ComplementaryColor.R = ComplementaryColor.R - 180.0f;
if (ComplementaryColor.R < 0.0f)
{ {
ComplementaryColor.R = 360.0f - ComplementaryColor.R; case ECogDebugRecolorMode::None:
{
return Color;
}
case ECogDebugRecolorMode::Color:
{
return UKismetMathLibrary::LinearColorLerp(Color, Settings.RecolorColor, Settings.RecolorIntensity).ToFColor(true);
}
case ECogDebugRecolorMode::HueOverTime:
{
const FLinearColor BaseColor(Color);
FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV();
ComplementaryColor.R = ComplementaryColor.R - 180.0f;
if (ComplementaryColor.R < 0.0f)
{
ComplementaryColor.R = 360.0f - ComplementaryColor.R;
}
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
const FLinearColor NewColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.RecolorTimeSpeed * World->GetTimeSeconds()));
const FLinearColor BlendColor = BaseColor * (1.0f - Settings.RecolorIntensity) + NewColor * Settings.RecolorIntensity;
return BlendColor.ToFColor(true);
}
case ECogDebugRecolorMode::HueOverFrames:
{
const FLinearColor BaseColor(Color);
const float Factor = (Settings.RecolorFrameCycle > 0) ? (GFrameCounter % Settings.RecolorFrameCycle) / (float)Settings.RecolorFrameCycle : 0.0f;
const FLinearColor NewColor(Factor * 360.0f, 1.0f, 1.0f);
const FLinearColor BlendColor = BaseColor * (1.0f - Settings.RecolorIntensity) + NewColor.HSVToLinearRGB() * Settings.RecolorIntensity;
return BlendColor.ToFColor(true);
}
default:
{
return Color;
}
} }
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.GradientColorSpeed * Time));
const FLinearColor FBlendColor = BaseColor * (1.0f - Settings.GradientColorIntensity) + GradientColor * Settings.GradientColorIntensity;
return FBlendColor.ToFColor(true);
} }
@@ -285,7 +315,7 @@ void FCogDebug::GetDebugDrawOverlapSettings(FCogDebugDrawOverlapParams& Params)
Params.DepthPriority = Settings.DepthPriority; Params.DepthPriority = Settings.DepthPriority;
Params.Thickness = Settings.Thickness; Params.Thickness = Settings.Thickness;
GetDebugChannelColors(Params.ChannelColors); GetDebugChannelColors(Params.ChannelColors);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -4,6 +4,8 @@
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "DrawDebugHelpers.h" #include "DrawDebugHelpers.h"
DEFINE_LOG_CATEGORY(LogCogServerVLOG);
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority) FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{ {
@@ -20,20 +22,25 @@ FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Si
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPoint(UWorld* World) const void FCogDebugShape::DrawPoint(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 1) if (ShapeData.Num() == 1)
{ {
const FVector Location = ShapeData[0];
const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness);
DrawDebugPoint( DrawDebugPoint(
World, World,
ShapeData[0], Location,
FCogDebug::GetDebugServerThickness(Thickness), ServerThickness,
FCogDebug::ModulateServerColor(Color), FCogDebug::ModulateServerColor(Color),
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
UE_VLOG_LOCATION(World, LogCogServerVLOG, Verbose, Location, ServerThickness, Color, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -56,21 +63,28 @@ FCogDebugShape FCogDebugShape::MakeSegment(const FVector& StartLocation, const F
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawSegment(UWorld* World) const void FCogDebugShape::DrawSegment(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 2) if (ShapeData.Num() == 2)
{ {
const FVector Start = ShapeData[0];
const FVector End = ShapeData[1];
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness);
DrawDebugLine( DrawDebugLine(
World, World,
ShapeData[0], Start,
ShapeData[1], End,
FCogDebug::ModulateServerColor(Color), ServerColor,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness)); ServerThickness);
UE_VLOG_SEGMENT_THICK(World, LogCogServerVLOG, Verbose, Start, End, ServerColor, ServerThickness, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -94,22 +108,29 @@ FCogDebugShape FCogDebugShape::MakeArrow(const FVector& StartLocation, const FVe
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawArrow(UWorld* World) const void FCogDebugShape::DrawArrow(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 3) if (ShapeData.Num() == 3)
{ {
const FVector Start = ShapeData[0];
const FVector End = ShapeData[1];
const float Size = ShapeData[2].X;
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
DrawDebugDirectionalArrow( DrawDebugDirectionalArrow(
World, World,
ShapeData[0], Start,
ShapeData[1], End,
ShapeData[2].X, Size,
FCogDebug::ModulateServerColor(Color), ServerColor,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Start, End, ServerColor, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -133,21 +154,30 @@ FCogDebugShape FCogDebugShape::MakeAxes(const FVector& Location, const FRotator&
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawAxes(UWorld* World) const void FCogDebugShape::DrawAxes(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 3) if (ShapeData.Num() == 3)
{ {
const FVector Location = ShapeData[0];
const FRotator Rotation(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z);
const float Scale = ShapeData[2].X;
DrawDebugCoordinateSystem( DrawDebugCoordinateSystem(
World, World,
ShapeData[0], Location,
FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), Rotation,
ShapeData[2].X, Scale,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
const FRotationMatrix Matrix(Rotation);
UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::X) * Scale, FColor::Red, TEXT(""));
UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::Y) * Scale, FColor::Green, TEXT(""));
UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::Z) * Scale, FColor::Blue, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -171,22 +201,27 @@ FCogDebugShape FCogDebugShape::MakeBox(const FVector& Center, const FRotator& Ro
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBox(UWorld* World) const void FCogDebugShape::DrawBox(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 3) if (ShapeData.Num() == 3)
{ {
const FVector Location = ShapeData[0];
const FVector Extent = ShapeData[1];
const FRotator Rotation(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z);
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
DrawDebugBox( DrawDebugBox(
World, World, Location, Extent, FQuat(Rotation),
ShapeData[0], ServerColor,
ShapeData[1],
FQuat(FRotator(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z)),
FCogDebug::ModulateServerColor(Color),
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
const FBox Box(-Extent, Extent);
UE_VLOG_OBOX(World, LogCogServerVLOG, Verbose, Box, FRotationTranslationMatrix(Rotation, Location), ServerColor, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -209,21 +244,29 @@ FCogDebugShape FCogDebugShape::MakeSolidBox(const FVector& Center, const FRotato
} }
void FCogDebugShape::DrawSolidBox(UWorld* World) const void FCogDebugShape::DrawSolidBox(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 12) if (ShapeData.Num() == 12)
{ {
const FVector Location = ShapeData[0];
const FVector Extent = ShapeData[1];
const FRotator Rotation(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z);
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
DrawDebugSolidBox( DrawDebugSolidBox(
World, World,
ShapeData[0], Location,
ShapeData[1], Extent,
FQuat(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z)), FQuat(Rotation),
FCogDebug::ModulateServerColor(Color), ServerColor,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority)); FCogDebug::GetDebugDepthPriority(DepthPriority));
const FBox Box(-Extent, Extent);
UE_VLOG_OBOX(World, LogCogServerVLOG, Verbose, Box, FRotationTranslationMatrix(Rotation, Location), ServerColor, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -247,26 +290,33 @@ FCogDebugShape FCogDebugShape::MakeCone(const FVector& Location, const FVector&
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCone(UWorld* World) const void FCogDebugShape::DrawCone(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 3 && ShapeData[2].X > 0) if (ShapeData.Num() == 3 && ShapeData[2].X > 0)
{ {
const FVector Location = ShapeData[0];
const FVector Direction = ShapeData[1];
const float Length = ShapeData[2].X;
const float DefaultConeAngle = 0.25f; // ~ 15 degrees const float DefaultConeAngle = 0.25f; // ~ 15 degrees
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
DrawDebugCone( DrawDebugCone(
World, World,
ShapeData[0], Location,
ShapeData[1], Direction,
ShapeData[2].X, Length,
DefaultConeAngle, DefaultConeAngle,
DefaultConeAngle, DefaultConeAngle,
FCogDebug::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebug::ModulateServerColor(Color), ServerColor,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness)); FCogDebug::GetDebugServerThickness(Thickness));
UE_VLOG_CONE(World, LogCogServerVLOG, Verbose, Location, Direction, Length, DefaultConeAngle, ServerColor, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -289,7 +339,7 @@ FCogDebugShape FCogDebugShape::MakeCylinder(const FVector& Center, const float R
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCylinder(UWorld* World) const void FCogDebugShape::DrawCylinder(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -329,23 +379,33 @@ FCogDebugShape FCogDebugShape::MakeCircle(const FVector& Center, const FRotator&
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicle(UWorld* World) const void FCogDebugShape::DrawCircle(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
if (ShapeData.Num() == 3) if (ShapeData.Num() == 3)
{ {
const FVector Location = ShapeData[0];
const FRotator Rotation (ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z);
const FRotationTranslationMatrix Matrix(Rotation, Location);
const float Radius = ShapeData[2].X;
const FColor ServerColor = FCogDebug::ModulateServerColor(Color);
const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness);
DrawDebugCircle( DrawDebugCircle(
World, World,
FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]), Matrix,
ShapeData[2].X, Radius,
FCogDebug::GetCircleSegments(), FCogDebug::GetCircleSegments(),
FCogDebug::ModulateServerColor(Color), ServerColor,
FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugPersistent(bPersistent),
FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDuration(bPersistent),
FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugDepthPriority(DepthPriority),
FCogDebug::GetDebugServerThickness(Thickness), ServerThickness,
false); false);
UE_VLOG_CIRCLE_THICK(World, LogCogServerVLOG, Verbose, Location, Matrix.GetUnitAxis(EAxis::X), Radius, ServerColor, ServerThickness, TEXT(""));
} }
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -369,7 +429,7 @@ FCogDebugShape FCogDebugShape::MakeCircleArc(const FVector& Center, const FRotat
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicleArc(UWorld* World) const void FCogDebugShape::DrawCircleArc(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -410,7 +470,7 @@ FCogDebugShape FCogDebugShape::MakeCapsule(const FVector& Center, const FQuat& R
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCapsule(UWorld* World) const void FCogDebugShape::DrawCapsule(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -451,7 +511,7 @@ FCogDebugShape FCogDebugShape::MakeFlatCapsule(const FVector2D& Start, const FVe
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawFlatCapsule(UWorld* World) const void FCogDebugShape::DrawFlatCapsule(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -491,7 +551,7 @@ FCogDebugShape FCogDebugShape::MakeBone(const FVector& BoneLocation, const FVect
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBone(UWorld* World) const void FCogDebugShape::DrawBone(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -535,7 +595,7 @@ FCogDebugShape FCogDebugShape::MakePolygon(const TArray<FVector>& Verts, const F
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPolygon(UWorld* World) const void FCogDebugShape::DrawPolygon(const UWorld* World) const
{ {
#if ENABLE_COG #if ENABLE_COG
@@ -564,7 +624,7 @@ void FCogDebugShape::DrawPolygon(UWorld* World) const
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::Draw(UWorld* World) const void FCogDebugShape::Draw(const UWorld* World) const
{ {
switch (Type) switch (Type)
{ {
@@ -573,8 +633,8 @@ void FCogDebugShape::Draw(UWorld* World) const
case ECogDebugShape::Bone: DrawBone(World); break; case ECogDebugShape::Bone: DrawBone(World); break;
case ECogDebugShape::Box: DrawBox(World); break; case ECogDebugShape::Box: DrawBox(World); break;
case ECogDebugShape::Capsule: DrawCapsule(World); break; case ECogDebugShape::Capsule: DrawCapsule(World); break;
case ECogDebugShape::Circle: DrawCicle(World); break; case ECogDebugShape::Circle: DrawCircle(World); break;
case ECogDebugShape::CircleArc: DrawCicleArc(World); break; case ECogDebugShape::CircleArc: DrawCircleArc(World); break;
case ECogDebugShape::Cone: DrawCone(World); break; case ECogDebugShape::Cone: DrawCone(World); break;
case ECogDebugShape::Cylinder: DrawCylinder(World); break; case ECogDebugShape::Cylinder: DrawCylinder(World); break;
case ECogDebugShape::FlatCapsule: DrawFlatCapsule(World); break; case ECogDebugShape::FlatCapsule: DrawFlatCapsule(World); break;
+20 -2
View File
@@ -12,6 +12,15 @@ struct FCogDebugDrawLineTraceParams;
struct FCogDebugDrawOverlapParams; struct FCogDebugDrawOverlapParams;
struct FCogDebugDrawSweepParams; struct FCogDebugDrawSweepParams;
UENUM()
enum ECogDebugRecolorMode : uint8
{
None,
Color,
HueOverTime,
HueOverFrames,
};
USTRUCT() USTRUCT()
struct FCogDebugSettings struct FCogDebugSettings
{ {
@@ -54,10 +63,19 @@ struct FCogDebugSettings
float AxesScale = 1.0f; float AxesScale = 1.0f;
UPROPERTY(Config) UPROPERTY(Config)
float GradientColorIntensity = 0.0f; TEnumAsByte<ECogDebugRecolorMode> RecolorMode = None;
UPROPERTY(Config) UPROPERTY(Config)
float GradientColorSpeed = 2.0f; float RecolorIntensity = 0.0f;
UPROPERTY(Config)
FColor RecolorColor = FColor(255, 0, 0, 255);
UPROPERTY(Config)
float RecolorTimeSpeed = 2.0f;
UPROPERTY(Config)
int32 RecolorFrameCycle = 6;
UPROPERTY(Config) UPROPERTY(Config)
float TextSize = 1.0f; float TextSize = 1.0f;
@@ -2,6 +2,8 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
DECLARE_LOG_CATEGORY_EXTERN(LogCogServerVLOG, Verbose, All);
enum class ECogDebugShape : uint8 enum class ECogDebugShape : uint8
{ {
Invalid, Invalid,
@@ -58,22 +60,22 @@ struct COGDEBUG_API FCogDebugShape
static FCogDebugShape MakeFlatCapsule(const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority); static FCogDebugShape MakeFlatCapsule(const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakePolygon(const TArray<FVector>& Verts, const FColor& Color, const bool bPersistent, const uint8 DepthPriority); static FCogDebugShape MakePolygon(const TArray<FVector>& Verts, const FColor& Color, const bool bPersistent, const uint8 DepthPriority);
void DrawPoint(UWorld* World) const; void DrawPoint(const UWorld* World) const;
void DrawSegment(UWorld* World) const; void DrawSegment(const UWorld* World) const;
void DrawBone(UWorld* World) const; void DrawBone(const UWorld* World) const;
void DrawArrow(UWorld* World) const; void DrawArrow(const UWorld* World) const;
void DrawAxes(UWorld* World) const; void DrawAxes(const UWorld* World) const;
void DrawBox(UWorld* World) const; void DrawBox(const UWorld* World) const;
void DrawSolidBox(UWorld* World) const; void DrawSolidBox(const UWorld* World) const;
void DrawCone(UWorld* World) const; void DrawCone(const UWorld* World) const;
void DrawCylinder(UWorld* World) const; void DrawCylinder(const UWorld* World) const;
void DrawCicle(UWorld* World) const; void DrawCircle(const UWorld* World) const;
void DrawCicleArc(UWorld* World) const; void DrawCircleArc(const UWorld* World) const;
void DrawCapsule(UWorld* World) const; void DrawCapsule(const UWorld* World) const;
void DrawFlatCapsule(UWorld* World) const; void DrawFlatCapsule(const UWorld* World) const;
void DrawPolygon(UWorld* World) const; void DrawPolygon(const UWorld* World) const;
void Draw(UWorld* World) const; void Draw(const UWorld* World) const;
}; };
FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape); FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape);
@@ -166,21 +166,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
ImGui::SetTooltip("The size of debug arrows."); ImGui::SetTooltip("The size of debug arrows.");
} }
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gradient Intensity", &Settings.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
}
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gradient Speed", &Settings.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("The speed of the gradient color change.");
}
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f"); ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{ {
@@ -188,6 +174,54 @@ void FCogEngineWindow_DebugSettings::RenderContent()
} }
} }
if (ImGui::CollapsingHeader("Recolor", ImGuiTreeNodeFlags_DefaultOpen))
{
FCogWindowWidgets::SetNextItemToShortWidth();
ECogDebugRecolorMode Mode = Settings.RecolorMode;
if (FCogWindowWidgets::ComboboxEnum("Recolor mode", Mode))
{
Settings.RecolorMode = Mode;
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("How the debug element should be recolored.");
}
if (Settings.RecolorMode != ECogDebugRecolorMode::None)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("How much the debug elements color should be changed.");
}
}
if (Settings.RecolorMode == ECogDebugRecolorMode::Color)
{
FCogImguiHelper::ColorEdit4("Recolor Color", Settings.RecolorColor, ColorEditFlags);
}
else if (Settings.RecolorMode == HueOverTime)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("The speed of the recolor.");
}
}
else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
{
ImGui::SetTooltip("How many frames are used to perform a full hue cycle.");
}
}
}
if (ImGui::CollapsingHeader("Gizmo")) if (ImGui::CollapsingHeader("Gizmo"))
{ {
ImGui::SeparatorText("General"); ImGui::SeparatorText("General");