Improve debug draw collision function to draw each hit bones in a skeletal mesh. Was previously drawing a box around the hit actor for each bone.

This commit is contained in:
Arnaud Jamin
2025-01-08 16:09:47 -05:00
parent b20d196c57
commit 6fe4806b02
8 changed files with 350 additions and 179 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ ManualIPAddress=
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="TraceCustom") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="TraceCustom")
+EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Ignore),(Channel="TraceCustom"))) +EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Ignore),(Channel="TraceCustom")))
+EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap),(Channel="TraceCustom",Response=ECR_Ignore))) +EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore),(Channel="Projectile",Response=ECR_Overlap),(Channel="TraceCustom",Response=ECR_Ignore),(Channel="CharacterMesh",Response=ECR_Overlap)))
+EditProfiles=(Name="BlockAll",CustomResponses=((Channel="Projectile"))) +EditProfiles=(Name="BlockAll",CustomResponses=((Channel="Projectile")))
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Projectile",Response=ECR_Overlap))) +EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Projectile",Response=ECR_Overlap)))
+EditProfiles=(Name="BlockAllDynamic",CustomResponses=((Channel="Projectile"))) +EditProfiles=(Name="BlockAllDynamic",CustomResponses=((Channel="Projectile")))
@@ -338,7 +338,7 @@ void FCogDebug::GetDebugDrawOverlapSettings(FCogDebugDrawOverlapParams& Params)
Params.NoHitColor = Settings.CollisionQueryNoHitColor; Params.NoHitColor = Settings.CollisionQueryNoHitColor;
Params.DrawHitPrimitives = Settings.CollisionQueryDrawHitPrimitives; Params.DrawHitPrimitives = Settings.CollisionQueryDrawHitPrimitives;
Params.DrawHitPrimitiveActorsName = Settings.CollisionQueryDrawHitPrimitiveActorsName; Params.DrawHitPrimitiveActorsName = Settings.CollisionQueryDrawHitPrimitiveActorsName;
Params.HitPrimitiveActorsNameShadow = Settings.CollisionQueryHitPrimitiveActorsNameShadow; Params.DrawHitPrimitiveActorsNameShadow = Settings.CollisionQueryHitPrimitiveActorsNameShadow;
Params.HitPrimitiveActorsNameSize = Settings.CollisionQueryHitPrimitiveActorsNameSize; Params.HitPrimitiveActorsNameSize = Settings.CollisionQueryHitPrimitiveActorsNameSize;
Params.Persistent = false; Params.Persistent = false;
Params.LifeTime = 0.0f; Params.LifeTime = 0.0f;
@@ -1,19 +1,20 @@
#include "CogDebugDraw.h" #include "CogDebugDraw.h"
#include "CogDebug.h"
#include "CogDebugDrawHelper.h" #include "CogDebugDrawHelper.h"
#include "CogDebugDrawImGui.h" #include "CogDebugDrawImGui.h"
#include "CogDebugLog.h" #include "CogDebugLog.h"
#include "CogDebugReplicator.h" #include "CogDebugReplicator.h"
#include "CogDebug.h"
#include "CogDebugShape.h" #include "CogDebugShape.h"
#include "CogImguiHelper.h" #include "CogImguiHelper.h"
#include "Components/BoxComponent.h"
#include "Components/SkeletalMeshComponent.h"
#include "DrawDebugHelpers.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "Engine/SkeletalMesh.h" #include "Engine/SkeletalMesh.h"
#include "VisualLogger/VisualLogger.h"
#include "Engine/World.h" #include "Engine/World.h"
#include "DrawDebugHelpers.h"
#include "ReferenceSkeleton.h" #include "ReferenceSkeleton.h"
#include "Components/SkeletalMeshComponent.h" #include "VisualLogger/VisualLogger.h"
#if ENABLE_COG #if ENABLE_COG
@@ -661,6 +662,8 @@ void FCogDebugDraw::LineTrace(const FLogCategoryBase& LogCategory, const UObject
FCogDebug::Settings.Thickness, FCogDebug::Settings.Thickness,
Settings.Persistent, Settings.Persistent,
Settings.DepthPriority)); Settings.DepthPriority));
ReplicateHitResults(WorldContextObject, HitResults, Settings);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -695,6 +698,8 @@ void FCogDebugDraw::Sweep(const FLogCategoryBase& LogCategory, const UObject* Wo
FCogDebug::Settings.Thickness, FCogDebug::Settings.Thickness,
Settings.Persistent, Settings.Persistent,
Settings.DepthPriority)); Settings.DepthPriority));
ReplicateHitResults(WorldContextObject, HitResults, Settings);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -721,6 +726,8 @@ void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject*
FCogDebug::Settings.Thickness, FCogDebug::Settings.Thickness,
Settings.Persistent, Settings.Persistent,
Settings.DepthPriority)); Settings.DepthPriority));
// TODO: replicate overlap results
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -757,4 +764,112 @@ void FCogDebugDraw::ReplicateShape(const UObject* WorldContextObject, const FCog
} }
} }
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::ReplicateHitResults(const UObject* WorldContextObject, const TArray<FHitResult>& HitResults, const FCogDebugDrawLineTraceParams& Settings)
{
TSet<const UPrimitiveComponent*> AlreadyDrawnPrimitives;
TSet<const AActor*> AlreadyDrawnActors;
for (const FHitResult& HitResult : HitResults)
{
const FColor& HitColor = Settings.HitColor;
if (Settings.DrawHitLocation)
{
ReplicateShape(WorldContextObject,
FCogDebugShape::MakePoint(HitResult.Location,
Settings.HitPointSize,
HitColor,
Settings.Persistent,
Settings.DepthPriority));
}
if (Settings.DrawHitImpactPoints)
{
ReplicateShape(WorldContextObject,
FCogDebugShape::MakePoint(HitResult.ImpactPoint,
Settings.HitPointSize,
HitColor,
Settings.Persistent,
Settings.DepthPriority));
}
if (Settings.DrawHitNormals)
{
ReplicateShape(WorldContextObject,
FCogDebugShape::MakeArrow(HitResult.Location,
HitResult.Location + HitResult.Normal * 20.0f,
FCogDebug::Settings.ArrowSize,
HitColor,
Settings.Thickness,
Settings.Persistent,
Settings.DepthPriority));
}
if (Settings.DrawHitImpactNormals)
{
ReplicateShape(WorldContextObject,
FCogDebugShape::MakeArrow(HitResult.ImpactPoint,
HitResult.Location + HitResult.ImpactNormal * 20.0f,
FCogDebug::Settings.ArrowSize,
HitColor,
Settings.Thickness,
Settings.Persistent,
Settings.DepthPriority));
}
if (Settings.DrawHitPrimitives)
{
const UPrimitiveComponent* PrimitiveComponent = HitResult.GetComponent();
if (PrimitiveComponent == nullptr)
{
continue;
}
if (AlreadyDrawnPrimitives.Contains(PrimitiveComponent))
{
continue;
}
const UBoxComponent* BoxComponent = Cast<UBoxComponent>(PrimitiveComponent);
const FCollisionShape Shape = PrimitiveComponent->GetCollisionShape();
AlreadyDrawnPrimitives.Add(PrimitiveComponent);
const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType];
if (Shape.ShapeType == ECollisionShape::Box && BoxComponent == nullptr)
{
FVector Location;
FVector Extent;
PrimitiveComponent->Bounds.GetBox().GetCenterAndExtents(Location, Extent);
// TODO: this adds padding to prevent Z fight. Maybe add this as a parameter.
Extent += FVector::OneVector;
ReplicateShape(WorldContextObject,
FCogDebugShape::MakeBox(Location,
FRotator::ZeroRotator,
Extent,
PrimitiveColor,
Settings.Thickness,
Settings.Persistent,
Settings.DepthPriority));
}
else
{
ReplicateShape(WorldContextObject,
FCogDebugShape::MakeCollisionShape(Shape,
PrimitiveComponent->GetComponentLocation(),
PrimitiveComponent->GetComponentQuat(),
Shape.GetExtent(),
PrimitiveColor,
Settings.Thickness,
Settings.Persistent,
Settings.DepthPriority));
}
}
}
}
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -6,6 +6,10 @@
#include "DrawDebugHelpers.h" #include "DrawDebugHelpers.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "Engine/OverlapResult.h" #include "Engine/OverlapResult.h"
#include "PhysicsEngine/PhysicsAsset.h"
#include "PhysicsEngine/SkeletalBodySetup.h"
#include "PhysicsEngine/SphylElem.h"
#include "Runtime/Experimental/Chaos/Private/Chaos/PhysicsObjectInternal.h"
namespace namespace
{ {
@@ -307,9 +311,6 @@ void FCogDebugDrawHelper::DrawHitResults(
const TArray<FHitResult>& HitResults, const TArray<FHitResult>& HitResults,
const FCogDebugDrawLineTraceParams& Settings) const FCogDebugDrawLineTraceParams& Settings)
{ {
TSet<const UPrimitiveComponent*> AlreadyDrawnPrimitives;
TSet<const AActor*> AlreadyDrawnActors;
for (const FHitResult& HitResult : HitResults) for (const FHitResult& HitResult : HitResults)
{ {
const FColor& HitColor = Settings.HitColor; const FColor& HitColor = Settings.HitColor;
@@ -374,33 +375,19 @@ void FCogDebugDrawHelper::DrawHitResults(
continue; continue;
} }
if (AlreadyDrawnPrimitives.Contains(PrimitiveComponent))
{
continue;
}
AlreadyDrawnPrimitives.Add(PrimitiveComponent);
const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType(); const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType]; const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType];
DrawPrimitiveComponent(*PrimitiveComponent, PrimitiveColor, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness); DrawPrimitiveComponent(
*PrimitiveComponent,
if (Settings.DrawHitPrimitiveActorsName) HitResult.PhysicsObject->GetBodyIndex(),
{ PrimitiveColor,
const AActor* Actor = PrimitiveComponent->GetOwner(); Settings.Persistent,
if (Actor == nullptr) Settings.LifeTime,
{ Settings.DepthPriority,
continue; Settings.Thickness,
} Settings.DrawHitPrimitiveActorsName,
Settings.DrawHitPrimitiveActorsNameShadow,
if (AlreadyDrawnActors.Contains(Actor)) Settings.HitPrimitiveActorsNameSize);
{
continue;
}
AlreadyDrawnActors.Add(Actor);
const FColor TextColor = PrimitiveColor.WithAlpha(255);
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, TextColor, 0.0f, Settings.HitPrimitiveActorsNameShadow, Settings.HitPrimitiveActorsNameSize);
}
} }
} }
} }
@@ -488,7 +475,17 @@ void FCogDebugDrawHelper::DrawOverlap(
{ {
const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType(); const ECollisionChannel CollisionObjectType = PrimitiveComponent->GetCollisionObjectType();
const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType]; const FColor PrimitiveColor = Settings.ChannelColors[CollisionObjectType];
DrawPrimitiveComponent(*PrimitiveComponent, PrimitiveColor, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness); DrawPrimitiveComponent(
*PrimitiveComponent,
OverlapResult.PhysicsObject->GetBodyIndex(),
PrimitiveColor,
Settings.Persistent,
Settings.LifeTime,
Settings.DepthPriority,
Settings.Thickness,
Settings.DrawHitPrimitiveActorsName,
Settings.DrawHitPrimitiveActorsNameShadow,
Settings.HitPrimitiveActorsNameSize);
} }
} }
} }
@@ -497,11 +494,15 @@ void FCogDebugDrawHelper::DrawOverlap(
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawPrimitiveComponent( void FCogDebugDrawHelper::DrawPrimitiveComponent(
const UPrimitiveComponent& PrimitiveComponent, const UPrimitiveComponent& PrimitiveComponent,
const int32 BodyIndex,
const FColor& Color, const FColor& Color,
const bool Persistent, const bool Persistent,
const float LifeTime, const float LifeTime,
const uint8 DepthPriority, const uint8 DepthPriority,
const float Thickness) const float Thickness,
const bool DrawName,
const bool DrawNameShadow,
const float DrawNameSize)
{ {
const UWorld* World = PrimitiveComponent.GetWorld(); const UWorld* World = PrimitiveComponent.GetWorld();
if (World == nullptr) if (World == nullptr)
@@ -509,46 +510,131 @@ void FCogDebugDrawHelper::DrawPrimitiveComponent(
return; return;
} }
const UBoxComponent* BoxComponent = Cast<UBoxComponent>(&PrimitiveComponent);; if (const USkeletalMeshComponent* SkeletalMeshComponent = Cast<USkeletalMeshComponent>(&PrimitiveComponent))
const FCollisionShape Shape = PrimitiveComponent.GetCollisionShape();
if (Shape.ShapeType == ECollisionShape::Box && BoxComponent == nullptr)
{ {
FVector Location; const UPhysicsAsset* PhysicsAsset = SkeletalMeshComponent->GetPhysicsAsset();
FVector Extent; if (PhysicsAsset->SkeletalBodySetups.IsValidIndex(BodyIndex) == false)
PrimitiveComponent.Bounds.GetBox().GetCenterAndExtents(Location, Extent); {
return;
}
// TODO: this adds padding to prevent Z fight. Maybe add this as a parameter. const USkeletalBodySetup* BodySetup = PhysicsAsset->SkeletalBodySetups[BodyIndex];
Extent += FVector::OneVector; const int32 BoneIndex = SkeletalMeshComponent->GetBoneIndex(BodySetup->BoneName);
const FTransform BoneTransform = SkeletalMeshComponent->GetBoneTransform(BoneIndex);
DrawDebugSolidBox( if (DrawName)
World, {
Location, DrawDebugString(World, BoneTransform.GetLocation(), BodySetup->BoneName.ToString(), nullptr, Color.WithAlpha(255), 0.0f, DrawNameShadow, DrawNameSize);
Extent, }
FQuat::Identity,
Color,
Persistent,
LifeTime,
DepthPriority);
DrawDebugBox( for (const FKSphereElem& Sphere : BodySetup->AggGeom.SphereElems)
World, {
Location, const FTransform transform = Sphere.GetTransform() * BoneTransform;
Extent, DrawSphere(
FQuat::Identity, World,
Color, transform.GetLocation(),
Persistent, Sphere.Radius,
LifeTime, FCogDebug::GetDebugSegments(),
DepthPriority, Color,
Thickness); Persistent,
LifeTime,
DepthPriority,
Thickness);
}
for (const FKBoxElem& Box : BodySetup->AggGeom.BoxElems)
{
const FTransform transform = Box.GetTransform() * BoneTransform;
DrawDebugBox(
World,
transform.GetLocation(),
FVector(Box.X, Box.Y, Box.Z) * 0.5f,
transform.GetRotation(),
Color,
Persistent,
LifeTime,
DepthPriority,
Thickness);
}
for (const FKSphylElem& Sphy : BodySetup->AggGeom.SphylElems)
{
const FTransform transform = Sphy.GetTransform() * BoneTransform;
DrawDebugCapsule(
World,
transform.GetLocation(),
Sphy.Length * 0.5f,
Sphy.Radius,
transform.GetRotation(),
Color,
Persistent,
LifeTime,
DepthPriority,
Thickness);
}
} }
else else
{ {
const FVector Location = PrimitiveComponent.GetComponentLocation(); const AActor* Actor = PrimitiveComponent.GetOwner();
const FQuat Rotation = PrimitiveComponent.GetComponentQuat();
const FVector Scale = PrimitiveComponent.GetComponentScale(); const UBoxComponent* BoxComponent = Cast<UBoxComponent>(&PrimitiveComponent);
DrawShape(World, Shape, Location, Rotation, Scale, Color, Persistent, LifeTime, DepthPriority, Thickness); const FCollisionShape Shape = PrimitiveComponent.GetCollisionShape();
if (Shape.ShapeType == ECollisionShape::Box && BoxComponent == nullptr)
{
FVector Location;
FVector Extent;
PrimitiveComponent.Bounds.GetBox().GetCenterAndExtents(Location, Extent);
if (DrawName)
{
DrawDebugString(World, Location, GetNameSafe(Actor), nullptr, Color.WithAlpha(255), 0.0f, DrawNameShadow, DrawNameSize);
}
// TODO: this adds padding to prevent Z fight. Maybe add this as a parameter.
Extent += FVector::OneVector;
DrawDebugSolidBox(
World,
Location,
Extent,
FQuat::Identity,
Color,
Persistent,
LifeTime,
DepthPriority);
DrawDebugBox(
World,
Location,
Extent,
FQuat::Identity,
Color,
Persistent,
LifeTime,
DepthPriority,
Thickness);
}
else
{
const FVector Location = PrimitiveComponent.GetComponentLocation();
const FQuat Rotation = PrimitiveComponent.GetComponentQuat();
const FVector Scale = PrimitiveComponent.GetComponentScale();
if (DrawName)
{
DrawDebugString(World, Location, GetNameSafe(Actor), nullptr, Color.WithAlpha(255), 0.0f, DrawNameShadow, DrawNameSize);
}
DrawShape(World, Shape, Location, Rotation, Scale, Color, Persistent, LifeTime, DepthPriority, Thickness);
}
} }
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -62,6 +62,8 @@ struct COGDEBUG_API FCogDebugDraw
static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings); static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
static void ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape); static void ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape);
static void ReplicateHitResults(const UObject* WorldContextObject, const TArray<FHitResult>& HitResults, const FCogDebugDrawLineTraceParams& Settings);
}; };
#endif //ENABLE_COG #endif //ENABLE_COG
@@ -17,7 +17,7 @@ struct FCogDebugDrawOverlapParams
FColor NoHitColor = FColor::Red; FColor NoHitColor = FColor::Red;
bool DrawHitPrimitives = true; bool DrawHitPrimitives = true;
bool DrawHitPrimitiveActorsName = false; bool DrawHitPrimitiveActorsName = false;
bool HitPrimitiveActorsNameShadow = true; bool DrawHitPrimitiveActorsNameShadow = true;
float HitPrimitiveActorsNameSize = 1.0f; float HitPrimitiveActorsNameSize = 1.0f;
mutable bool Persistent = false; mutable bool Persistent = false;
float LifeTime = 0.0f; float LifeTime = 0.0f;
@@ -62,7 +62,7 @@ public:
static void DrawShape(const UWorld* World, const FCollisionShape& InShape, const FVector& Location, const FQuat& Rotation, const FVector& Scale, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness); static void DrawShape(const UWorld* World, const FCollisionShape& InShape, const FVector& Location, const FQuat& Rotation, const FVector& Scale, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness);
static void DrawPrimitiveComponent(const UPrimitiveComponent& PrimitiveComponent, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness); static void DrawPrimitiveComponent(const UPrimitiveComponent& PrimitiveComponent, const int32 BodyIndex, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness, const bool DrawName = true, const bool DrawNameShadow = true, const float DrawNameSize = 1.0f);
static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings); static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray<FOverlapResult>& OverlapResults, const FCogDebugDrawOverlapParams& Settings);
@@ -80,98 +80,56 @@ void FCogEngineWindow_DebugSettings::RenderContent()
{ {
FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection); FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
} }
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
{
ImGui::SetTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
}
ImGui::Checkbox("Persistent", &Settings.Persistent); ImGui::Checkbox("Persistent", &Settings.Persistent);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("Make debug draw always persist");
{
ImGui::SetTooltip("Make debug draw always persist");
}
ImGui::Checkbox("Actor Name Use Label", &Settings.ActorNameUseLabel); ImGui::Checkbox("Actor Name Use Label", &Settings.ActorNameUseLabel);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("Use the actor label when displaying the actor name.");
{
ImGui::SetTooltip("Use the actor label when displaying the actor name.");
}
ImGui::Checkbox("Text Shadow", &Settings.TextShadow); ImGui::Checkbox("Text Shadow", &Settings.TextShadow);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("Show a shadow below debug text.");
{
ImGui::SetTooltip("Show a shadow below debug text.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::Checkbox("Fade 2D", &Settings.Fade2D); ImGui::Checkbox("Fade 2D", &Settings.Fade2D);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("Does the 2D debug is fading out.");
{
ImGui::SetTooltip("Does the 2D debug is fading out.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Duration", &Settings.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::SetItemTooltip("The duration of debug elements.");
{
ImGui::SetTooltip("The duration of debug elements.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Thickness", &Settings.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::SetItemTooltip("The thickness of debug lines.");
{
ImGui::SetTooltip("The thickness of debug lines.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Server Thickness", &Settings.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::SetItemTooltip("The thickness the server debug lines.");
{
ImGui::SetTooltip("The thickness the server debug lines.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Server Color Mult", &Settings.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::SetItemTooltip("The color multiplier applied to the server debug lines.");
{
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Depth Priority", &Settings.DepthPriority, 0.1f, 0, 100); ImGui::DragInt("Depth Priority", &Settings.DepthPriority, 0.1f, 0, 100);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("The depth priority of debug elements.");
{
ImGui::SetTooltip("The depth priority of debug elements.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Segments", &Settings.Segments, 0.1f, 4, 20.0f); ImGui::DragInt("Segments", &Settings.Segments, 0.1f, 4, 20.0f);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("The number of segments used for circular shapes.");
{
ImGui::SetTooltip("The number of segments used for circular shapes.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Axes Scale", &Settings.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::SetItemTooltip("The scaling debug axis.");
{
ImGui::SetTooltip("The scaling debug axis.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Arrow Size", &Settings.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::SetItemTooltip("The size of debug arrows.");
{
ImGui::SetTooltip("The size of debug arrows.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); 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)) ImGui::SetItemTooltip("The size of the debug texts.");
{
ImGui::SetTooltip("The size of the debug texts.");
}
} }
if (ImGui::CollapsingHeader("Recolor", ImGuiTreeNodeFlags_DefaultOpen)) if (ImGui::CollapsingHeader("Recolor", ImGuiTreeNodeFlags_DefaultOpen))
@@ -183,19 +141,13 @@ void FCogEngineWindow_DebugSettings::RenderContent()
{ {
Settings.RecolorMode = Mode; Settings.RecolorMode = Mode;
} }
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("How the debug element should be recolored.");
{
ImGui::SetTooltip("How the debug element should be recolored.");
}
if (Settings.RecolorMode != ECogDebugRecolorMode::None) if (Settings.RecolorMode != ECogDebugRecolorMode::None)
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("How much the debug elements color should be changed.");
{
ImGui::SetTooltip("How much the debug elements color should be changed.");
}
} }
if (Settings.RecolorMode == ECogDebugRecolorMode::Color) if (Settings.RecolorMode == ECogDebugRecolorMode::Color)
@@ -206,19 +158,13 @@ void FCogEngineWindow_DebugSettings::RenderContent()
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("The speed of the recolor.");
{
ImGui::SetTooltip("The speed of the recolor.");
}
} }
else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames) else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames)
{ {
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100); ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) ImGui::SetItemTooltip("How many frames are used to perform a full hue cycle.");
{
ImGui::SetTooltip("How many frames are used to perform a full hue cycle.");
}
} }
} }
@@ -230,10 +176,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Gizmo Scale", &Settings.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::SetItemTooltip("The scale of the gizmo.");
{
ImGui::SetTooltip("The scale of the gizmo.");
}
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Z Low", &Settings.GizmoZLow, 0.5f, 0, 1000); ImGui::DragInt("Z Low", &Settings.GizmoZLow, 0.5f, 0, 1000);
@@ -384,23 +327,47 @@ void FCogEngineWindow_DebugSettings::RenderContent()
if (ImGui::CollapsingHeader("Collision Query")) if (ImGui::CollapsingHeader("Collision Query"))
{ {
ImGui::Checkbox("Draw Hit Primitives", &Settings.CollisionQueryDrawHitPrimitives); ImGui::Checkbox("Draw Hit Primitives", &Settings.CollisionQueryDrawHitPrimitives);
ImGui::Checkbox("Draw Hit Primitive Actors Name", &Settings.CollisionQueryDrawHitPrimitiveActorsName); ImGui::SetItemTooltip("Draw the shape of the primitives that have been hit.");
ImGui::Checkbox("Prim Hit Primitive Actors Name Shadow", &Settings.CollisionQueryHitPrimitiveActorsNameShadow);
ImGui::Checkbox("Draw Hit Shapes", &Settings.CollisionQueryDrawHitShapes); ImGui::Checkbox("Draw Hit Primitive Actors Name", &Settings.CollisionQueryDrawHitPrimitiveActorsName);
ImGui::SetItemTooltip("Draw the actor name of the primitives that have been hit.");
ImGui::Checkbox("Prim Hit Primitive Actors Name Shadow", &Settings.CollisionQueryHitPrimitiveActorsNameShadow);
ImGui::SetItemTooltip("Draw the actor name shadow of the primitives that have been hit.");
ImGui::Checkbox("Draw Hit Shapes", &Settings.CollisionQueryDrawHitShapes);
ImGui::SetItemTooltip("Draw the sweep shape at every impact location.");
ImGui::Checkbox("Draw Hit Location", &Settings.CollisionQueryDrawHitLocation); ImGui::Checkbox("Draw Hit Location", &Settings.CollisionQueryDrawHitLocation);
ImGui::SetItemTooltip("Draw the location of hit results.");
ImGui::Checkbox("Draw Hit Impact Points", &Settings.CollisionQueryDrawHitImpactPoints); ImGui::Checkbox("Draw Hit Impact Points", &Settings.CollisionQueryDrawHitImpactPoints);
ImGui::SetItemTooltip("Draw the impact point of hit results.");
ImGui::Checkbox("Draw Hit Normals", &Settings.CollisionQueryDrawHitNormals); ImGui::Checkbox("Draw Hit Normals", &Settings.CollisionQueryDrawHitNormals);
ImGui::SetItemTooltip("Draw the hit normal of hit results.");
ImGui::Checkbox("Draw Hit Impact Normals", &Settings.CollisionQueryDrawHitImpactNormals); ImGui::Checkbox("Draw Hit Impact Normals", &Settings.CollisionQueryDrawHitImpactNormals);
ImGui::SetItemTooltip("Draw the hit impact normal of hit results.");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Primitive Actors Name Size", &Settings.CollisionQueryHitPrimitiveActorsNameSize); ImGui::DragFloat("Primitive Actors Name Size", &Settings.CollisionQueryHitPrimitiveActorsNameSize, 0.1f, 0.5f, 10.0f, "%0.1f");
ImGui::SetItemTooltip("Size of the actor name of the primitives that have been hit.");
FCogWindowWidgets::SetNextItemToShortWidth(); FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Hit Point Size", &Settings.CollisionQueryHitPointSize); ImGui::DragFloat("Hit Point Size", &Settings.CollisionQueryHitPointSize, 0.5f, 0.0f, 100.0f, "%0.1f");
ImGui::SetItemTooltip("Size of the hit result location and impact point.");
FCogImguiHelper::ColorEdit4("Hit Color", Settings.CollisionQueryHitColor, ColorEditFlags); FCogImguiHelper::ColorEdit4("Hit Color", Settings.CollisionQueryHitColor, ColorEditFlags);
ImGui::SetItemTooltip("Color of the collision query when the query has hit.");
FCogImguiHelper::ColorEdit4("No Hit Color", Settings.CollisionQueryNoHitColor, ColorEditFlags); FCogImguiHelper::ColorEdit4("No Hit Color", Settings.CollisionQueryNoHitColor, ColorEditFlags);
ImGui::SetItemTooltip("Color of the collision query when the query has not hit.");
FCogImguiHelper::ColorEdit4("Normal Color", Settings.CollisionQueryNormalColor, ColorEditFlags); FCogImguiHelper::ColorEdit4("Normal Color", Settings.CollisionQueryNormalColor, ColorEditFlags);
ImGui::SetItemTooltip("Color of the hit result normal color.");
FCogImguiHelper::ColorEdit4("Impact Normal Color", Settings.CollisionQueryImpactNormalColor, ColorEditFlags); FCogImguiHelper::ColorEdit4("Impact Normal Color", Settings.CollisionQueryImpactNormalColor, ColorEditFlags);
ImGui::SetItemTooltip("Color of the hit result impact normal color.");
} }
} }
@@ -9,6 +9,7 @@
#include "Engine/World.h" #include "Engine/World.h"
#include "imgui.h" #include "imgui.h"
#include "Misc/CoreMisc.h" #include "Misc/CoreMisc.h"
#include "Misc/Paths.h"
#include "NetImgui_Api.h" #include "NetImgui_Api.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------