First Submit

This commit is contained in:
Arnaud Jamin
2023-10-02 01:32:41 -04:00
parent c34574e841
commit 1aabdb5c4e
445 changed files with 93851 additions and 0 deletions
@@ -0,0 +1,48 @@
using UnrealBuildTool;
public class CogDebug : ModuleRules
{
public CogDebug(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
}
);
PrivateIncludePaths.AddRange(
new string[] {
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CogImgui"
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"NetCore",
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
}
);
}
}
@@ -0,0 +1,520 @@
#include "CogDebugDraw.h"
#include "CogDebugDrawHelper.h"
#include "CogDebugShape.h"
#include "CogDebugHelper.h"
#include "CogDebugDrawImGui.h"
#include "CogImguiHelper.h"
#include "CogDebugLogCategoryManager.h"
#include "CogDebugModule.h"
#include "CogDebugReplicator.h"
#include "Engine/SkeletalMesh.h"
#include "VisualLogger/VisualLogger.h"
#if ENABLE_COG
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector2D& Location, const FColor& Color, bool Persistent)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
FCogDebugDrawImGui::AddText(
FCogImguiHelper::ToImVec2(Location),
Text,
FCogImguiHelper::ToImU32(Color),
true,
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::Fade2D);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& SegmentStart, const FVector2D& SegmentEnd, const FColor& Color, bool Persistent)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
FCogDebugDrawImGui::AddLine(
FCogImguiHelper::ToImVec2(SegmentStart),
FCogImguiHelper::ToImVec2(SegmentEnd),
FCogImguiHelper::ToImU32(Color),
FCogDebugSettings::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::Fade2D);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Location, float Radius, const FColor& Color, bool Persistent)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
FCogDebugDrawImGui::AddCircle(
FCogImguiHelper::ToImVec2(Location),
Radius,
FCogImguiHelper::ToImU32(Color),
FCogDebugSettings::GetDebugSegments(),
FCogDebugSettings::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::Fade2D);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Min, const FVector2D& Max, const FColor& Color, bool Persistent)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const ImVec2 ImMin = FCogImguiHelper::ToImVec2(Min);
const ImVec2 ImMax = FCogImguiHelper::ToImVec2(Max);
FCogDebugDrawImGui::AddRect(
ImMin,
ImMax,
FCogImguiHelper::ToImU32(Color),
0.0f,
FCogDebugSettings::GetDebugThickness(0),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::Fade2D);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector& Location, const FColor& Color, const bool Persistent)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_LOCATION(WorldContextObject, LogCategory, Verbose, Location, 10.0f, NewColor, TEXT("%s"), *Text);
::DrawDebugString(
WorldContextObject->GetWorld(),
Location,
*Text,
nullptr,
NewColor,
FCogDebugSettings::GetDebugTextDuration(Persistent),
FCogDebugSettings::TextShadow,
FCogDebugSettings::TextSize);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Point(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, const float Size, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
::DrawDebugPoint(
WorldContextObject->GetWorld(),
Location,
Size,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebugSettings::DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& SegmentStart, const FVector& SegmentEnd, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
::DrawDebugLine(
WorldContextObject->GetWorld(),
SegmentStart,
SegmentEnd,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSegment(SegmentStart, SegmentEnd, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& BoneLocation, const FVector& ParentLocation, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_SEGMENT(WorldContextObject, LogCategory, Verbose, BoneLocation, ParentLocation, NewColor, TEXT_EMPTY);
::DrawDebugLine(
WorldContextObject->GetWorld(),
BoneLocation,
ParentLocation,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
::DrawDebugPoint(
WorldContextObject->GetWorld(),
BoneLocation,
FCogDebugSettings::GetDebugThickness(4.0f),
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBone(BoneLocation, ParentLocation, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& SegmentStart, const FVector& SegmentEnd, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, SegmentStart, SegmentEnd, NewColor, TEXT_EMPTY);
::DrawDebugDirectionalArrow(
WorldContextObject->GetWorld(),
SegmentStart,
SegmentEnd,
FCogDebugSettings::ArrowSize,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebugSettings::ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& AxisLoc, const FRotator& AxisRot, float Scale, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
FRotationMatrix R(AxisRot);
UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::X) * Scale, FColor::Red, TEXT_EMPTY);
UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::Y) * Scale, FColor::Green, TEXT_EMPTY);
UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::Z) * Scale, FColor::Blue, TEXT_EMPTY);
::DrawDebugCoordinateSystem(
WorldContextObject->GetWorld(),
AxisLoc,
AxisRot,
Scale * FCogDebugSettings::AxesScale,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebugSettings::ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, float Radius, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), 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);
::DrawDebugCircle(
WorldContextObject->GetWorld(),
Matrix,
Radius,
FCogDebugSettings::GetCircleSegments(),
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0),
false);
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircle(Center, Matrix.Rotator(), Radius, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
//TODO : Add VLOG
FCogDebugDrawHelper::DrawArc(
WorldContextObject->GetWorld(),
Matrix,
InnerRadius,
OuterRadius,
Angle,
FCogDebugSettings::GetCircleSegments(),
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCircleArc(Matrix.GetOrigin(), Matrix.Rotator(), InnerRadius, OuterRadius, Angle, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
// TODO : Add VLOG
FCogDebugDrawHelper::DrawFlatCapsule(
WorldContextObject->GetWorld(),
Start,
End,
Radius,
Z,
FCogDebugSettings::GetCircleSegments(),
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeFlatCapsule(Start, End, Radius, Z, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Sphere(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, float Radius, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Location, 0.0f, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
FCogDebugDrawHelper::DrawSphere(
WorldContextObject->GetWorld(),
Location,
Radius,
FCogDebugSettings::GetDebugSegments(),
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Location, FQuat::Identity, Radius, 0.0f, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const FVector& Extent, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_OBOX(WorldContextObject, LogCategory, Verbose, FBox(-Extent, Extent), FQuatRotationTranslationMatrix::Make(Rotation, Center), NewColor, TEXT_EMPTY);
::DrawDebugBox(
WorldContextObject->GetWorld(),
Center,
Extent,
Rotation,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeBox(Center, FRotator(Rotation), Extent, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const FVector& Extent, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), 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.
// We don't use "DrawDebugSolidBox" because it produced weird result, with color being darker than what is intended
const float NeededThickness = FMath::Min3(Extent.X, Extent.Y, Extent.Z) * 10.f;
::DrawDebugBox(
WorldContextObject->GetWorld(),
Center,
Extent,
Rotation,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
NeededThickness);
ReplicateShape(WorldContextObject, FCogDebugShape::MakeSolidBox(Center, FRotator(Rotation), Extent, NewColor, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Frustrum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
FCogDebugDrawHelper::DrawFrustum(
WorldContextObject->GetWorld(),
Matrix,
Angle,
AspectRatio,
NearPlane,
FarPlane,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
// TODO: Replicate Shape
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const float HalfHeight, const float Radius, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FColor NewColor = FCogDebugSettings::ModulateDebugColor(WorldContextObject->GetWorld(), Color, Persistent);
UE_VLOG_CAPSULE(WorldContextObject, LogCategory, Verbose, Center, HalfHeight, Radius, FQuat::Identity, NewColor, TEXT_EMPTY);
DrawDebugCapsule(
WorldContextObject->GetWorld(),
Center,
HalfHeight,
Radius,
Rotation,
NewColor,
FCogDebugSettings::GetDebugPersistent(Persistent),
FCogDebugSettings::GetDebugDuration(Persistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugThickness(0));
ReplicateShape(WorldContextObject, FCogDebugShape::MakeCapsule(Center, Rotation, Radius, HalfHeight, NewColor, 0.0f, Persistent, DepthPriority));
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Points(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray<FVector>& Points, float Radius, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
int32 index = 0;
for (const FVector& Point : Points)
{
const FLinearColor Color = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : index / (float)(Points.Num() - 1));
Sphere(LogCategory, WorldContextObject, Point, Radius, Color.ToFColor(true), Persistent, DepthPriority);
index++;
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Path(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray<FVector>& Points, float PointSize, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority)
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
if (Points.Num() == 0)
{
return;
}
FVector LastPoint = Points[0];
int32 Index = 0;
for (const FVector& Position : Points)
{
const FLinearColor LinearColor = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / (float)(Points.Num() - 1));
FColor Color = LinearColor.ToFColor(true);
Point(LogCategory, WorldContextObject, Position, PointSize, Color, Persistent, DepthPriority);
if (Index > 0)
{
Segment(LogCategory, WorldContextObject, LastPoint, Position, Color, Persistent, DepthPriority);
}
Index++;
LastPoint = Position;
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeletalMeshComponent* Skeleton, const FColor& Color, bool DrawSecondaryBones, uint8 DepthPriority)
{
if (Skeleton == nullptr)
{
return;
}
if (FCogDebugLogCategoryManager::IsLogCategoryActive(LogCategory))
{
const FReferenceSkeleton& ReferenceSkeleton = Skeleton->GetSkeletalMeshAsset()->GetRefSkeleton();
const FTransform WorldTransform = Skeleton->GetComponentTransform();
const TArray<FTransform>& ComponentSpaceTransforms = Skeleton->GetComponentSpaceTransforms();
for (int32 BoneIndex = 0; BoneIndex < ComponentSpaceTransforms.Num(); ++BoneIndex)
{
if (DrawSecondaryBones == false)
{
FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex);
if (FCogDebugSettings::IsSecondarySkeletonBone(BoneName))
{
continue;
}
}
const FTransform Transform = ComponentSpaceTransforms[BoneIndex] * WorldTransform;
const FVector BoneLocation = Transform.GetLocation();
const FRotator BoneRotation = FRotator(Transform.GetRotation());
const int32 ParentIndex = ReferenceSkeleton.GetParentIndex(BoneIndex);
FVector ParentLocation;
if (ParentIndex >= 0)
{
ParentLocation = (ComponentSpaceTransforms[ParentIndex] * WorldTransform).GetLocation();
}
else
{
ParentLocation = WorldTransform.GetLocation();
}
Bone(LogCategory, Skeleton->GetOwner(), BoneLocation, ParentLocation, Color, false, DepthPriority);
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDraw::ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape)
{
const UWorld* World = WorldContextObject != nullptr ? WorldContextObject->GetWorld() : nullptr;
const ENetMode NetMode = World->GetNetMode();
if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer)
{
for (const TObjectPtr<ACogDebugReplicator>& Replicator : FCogDebugModule::Get().GetRemoteReplicators())
{
Replicator->ReplicatedShapes.Add(Shape);
}
}
}
#endif //ENABLE_COG
@@ -0,0 +1,191 @@
#include "CogDebugDrawBlueprint.h"
#include "CogDebugDraw.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::String(*LogCategoryPtr, WorldContextObject, Text, Location, Color.ToFColor(true), Persistent);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Size, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Point(*LogCategoryPtr, WorldContextObject, Location, Size, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Segment(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Arrow(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Axis(*LogCategoryPtr, WorldContextObject, Location, Rotation, Scale, Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Sphere(*LogCategoryPtr, WorldContextObject, Location, Radius, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Box(*LogCategoryPtr, WorldContextObject, Center, Extent, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::SolidBox(*LogCategoryPtr, WorldContextObject, Center, Extent, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Capsule(*LogCategoryPtr, WorldContextObject, Center, HalfHeight, Radius, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Circle(*LogCategoryPtr, WorldContextObject, Matrix, Radius, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::CircleArc(*LogCategoryPtr, WorldContextObject, Matrix, InnerRadius, OuterRadius, Angle, Color.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray<FVector>& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Points(*LogCategoryPtr, WorldContextObject, Points, Radius, StartColor.ToFColor(true), EndColor.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray<FVector>& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Path(*LogCategoryPtr, WorldContextObject, Points, PointSize, StartColor.ToFColor(true), EndColor.ToFColor(true), Persistent, DepthPriority);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::String2D(*LogCategoryPtr, WorldContextObject, Text, Location, Color.ToFColor(true), Persistent);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Segment2D(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Circle2D(*LogCategoryPtr, WorldContextObject, Location, Radius, Color.ToFColor(true), Persistent);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugLogRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
FCogDebugDraw::Rect2D(*LogCategoryPtr, WorldContextObject, Min, Max, Color.ToFColor(true), Persistent);
}
#endif //ENABLE_COG
}
@@ -0,0 +1,448 @@
#include "CogDebugDrawHelper.h"
#include "Components/LineBatchComponent.h"
namespace
{
//----------------------------------------------------------------------------------------------------------------------
ULineBatchComponent* GetDebugLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground)
{
return (InWorld ? (bDepthIsForeground ? InWorld->ForegroundLineBatcher : ((bPersistentLines || (LifeTime > 0.f)) ? InWorld->PersistentLineBatcher : InWorld->LineBatcher)) : nullptr);
}
//----------------------------------------------------------------------------------------------------------------------
static float GetLineLifeTime(ULineBatchComponent* LineBatcher, float LifeTime, bool bPersistent)
{
return bPersistent ? -1.0f : ((LifeTime > 0.f) ? LifeTime : LineBatcher->DefaultLifeTime);
}
}
//--------------------------------------------------------------------------------------------------------------------------
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)
{
if (GEngine->GetNetMode(InWorld) == NM_DedicatedServer)
{
return;
}
ULineBatchComponent* const LineBatcher = GetDebugLineBatcher(InWorld, bPersistentLines, LifeTime, (DepthPriority == SDPG_Foreground));
if (LineBatcher == nullptr)
{
return;
}
const float LineLifeTime = GetLineLifeTime(LineBatcher, LifeTime, bPersistentLines);
const float AngleRad = FMath::DegreesToRadians(Angle);
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);
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));
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));
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));
int32 Count = Segments;
while (Count--)
{
CurrentAngle += AngleStep;
FVector NextVertex = Center + OuterRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * 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));
Count = Segments;
while (Segments--)
{
CurrentAngle += AngleStep;
FVector NextVertex = Center + InnerRadius * (AxisY * -FMath::Sin(CurrentAngle) + DirectionNorm * FMath::Cos(CurrentAngle));
Lines.Emplace(FBatchedLine(PrevVertex, NextVertex, Color, LineLifeTime, Thickness, DepthPriority));
PrevVertex = NextVertex;
}
}
LineBatcher->DrawLines(Lines);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawSphere(
const UWorld* InWorld,
const FVector& Center,
const float Radius,
const int32 Segments,
const FColor& Color,
const bool bPersistentLines,
const float LifeTime,
const uint8 DepthPriority,
const float Thickness)
{
if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
{
DrawCircle(InWorld, Center, FVector::XAxisVector, FVector::YAxisVector, Color, Radius, Segments, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawCircle(InWorld, Center, FVector::XAxisVector, FVector::ZAxisVector, Color, Radius, Segments, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawCircle(InWorld, Center, FVector::YAxisVector, FVector::ZAxisVector, Color, Radius, Segments, bPersistentLines, LifeTime, DepthPriority, Thickness);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawFlatCapsule(
const UWorld* InWorld,
const FVector2D& Start,
const FVector2D& End,
const float Radius,
const float Z,
const float Segments,
const FColor& Color,
const bool bPersistentLines,
const float LifeTime,
const uint8 DepthPriority,
const float Thickness)
{
FVector2D Forward = (End - Start).GetSafeNormal();
FVector2D Right = FVector2D(-Forward.Y, Forward.X);
::DrawDebugLine(InWorld, FVector(Start - Right * Radius, Z), FVector(End - Right * Radius, Z), Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
::DrawDebugLine(InWorld, FVector(Start + Right * Radius, Z), FVector(End + Right * Radius, Z), Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
::DrawDebugCircle(InWorld, FRotationTranslationMatrix(FRotator(90, 0, 0), FVector(Start, Z)), Radius, Segments, Color, bPersistentLines, LifeTime, DepthPriority, Thickness, false);
::DrawDebugCircle(InWorld, FRotationTranslationMatrix(FRotator(90, 0, 0), FVector(End, Z)), Radius, Segments, Color, bPersistentLines, LifeTime, DepthPriority, Thickness, false);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawRaycastSingle(
const UWorld* World,
const FVector& Start,
const FVector& End,
const EDrawDebugTrace::Type DrawType,
const bool bHit,
const FHitResult& Hit,
const float HitSize,
const FLinearColor DrawColor,
const FLinearColor DrawHitColor,
const float DrawDuration,
const uint8 DepthPriority /*= 0*/
)
{
if (DrawType != EDrawDebugTrace::None)
{
bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
if (bHit && Hit.bBlockingHit)
{
::DrawDebugLine(World, Start, Hit.ImpactPoint, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
::DrawDebugLine(World, Hit.ImpactPoint, End, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
DrawHitResult(World, Hit, 0, DrawType, false, HitSize, DrawHitColor, DrawTime, DepthPriority);
}
else
{
::DrawDebugLine(World, Start, End, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawSphereOverlapMulti(
const UWorld* World,
const FVector& Position,
const float Radius,
const EDrawDebugTrace::Type DrawType,
const bool bOverlap,
const TArray<AActor*>& OutActors,
const FLinearColor DrawColor,
const FLinearColor DrawHitColor,
const float DrawDuration /*= 0*/
)
{
if (DrawType == EDrawDebugTrace::None)
return;
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
DrawSphereOverlapSingle(World, Position, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawSphereOverlapSingle(
const UWorld* World,
const FVector& Position,
const float Radius,
const FColor& DrawColor,
const bool DrawPersistent,
const float DrawTime /*= -1.f*/,
const uint8 DepthPriority /*= 0*/
)
{
::DrawDebugSphere(World, Position, Radius, 16, DrawColor, DrawPersistent, DrawTime, DepthPriority);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawCapsuleCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration /*= 0*/)
{
if (DrawType == EDrawDebugTrace::None)
return;
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
if (bHit && OutHits.Last().bBlockingHit)
{
FVector const BlockingHitPoint = OutHits.Last().Location;
DrawCapsuleCastSingle(World, Start, BlockingHitPoint, Rotation, HalfHeight, Radius, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
DrawCapsuleCastSingle(World, Start, End, Rotation, HalfHeight, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
}
else
{
DrawCapsuleCastSingle(World, Start, End, Rotation, HalfHeight, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawCapsuleCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration /*= -1.f*/, const uint8 DepthPriority /*= 0*/)
{
::DrawDebugCapsule(World, Start, HalfHeight, Radius, Rotation, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
::DrawDebugLine(World, Start, End, DrawColor, DrawPersistent, DrawDuration, DepthPriority, 0.5f);
::DrawDebugCapsule(World, End, HalfHeight, Radius, Rotation, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawSphereCastMulti(
const UWorld* World,
const FVector& Start,
const FVector& End,
const float Radius,
const EDrawDebugTrace::Type DrawType,
const bool bHit,
const TArray<FHitResult>& OutHits,
const FLinearColor DrawColor,
const FLinearColor DrawHitColor,
const float DrawDuration /*= 0*/
)
{
if (DrawType == EDrawDebugTrace::None)
return;
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
if (bHit && OutHits.Last().bBlockingHit)
{
FVector const BlockingHitPoint = OutHits.Last().Location;
DrawSphereCastSingle(World, Start, BlockingHitPoint, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
DrawSphereCastSingle(World, BlockingHitPoint, End, Radius, DrawHitColor.ToFColor(true), DrawPersistent, DrawTime);
}
else
{
DrawSphereCastSingle(World, Start, End, Radius, DrawColor.ToFColor(true), DrawPersistent, DrawTime);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawSphereCastSingle(
const UWorld* World,
const FVector& Start,
const FVector& End,
const float Radius,
const FColor& DrawColor,
const bool DrawPersistent,
const float DrawDuration /*= -1.f*/,
const uint8 DepthPriority /*= 0*/
)
{
FVector const TraceVec = End - Start;
float const Dist = TraceVec.Size();
FVector const Center = Start + TraceVec * 0.5f;
float const HalfHeight = (Dist * 0.5f) + Radius;
FQuat const CapsuleRot = FRotationMatrix::MakeFromZ(TraceVec).ToQuat();
::DrawDebugCapsule(World, Center, HalfHeight, Radius, CapsuleRot, DrawColor, DrawPersistent, DrawDuration, DepthPriority);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawHitResults(
const UWorld* World,
const TArray<FHitResult>& OutHits,
const EDrawDebugTrace::Type DrawType,
const bool ShowHitIndex,
const float HitSize,
const FLinearColor HitColor,
const float DrawDuration,
const uint8 DepthPriority /*= 0*/
)
{
if (DrawType == EDrawDebugTrace::None)
return;
for (int32 i = 0; i < OutHits.Num(); ++i)
{
DrawHitResult(World, OutHits[i], i, DrawType, ShowHitIndex, HitSize, HitColor, DrawDuration, DepthPriority);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawHitResultsDiscarded(
const UWorld* World,
const TArray<FHitResult>& AllHits,
const TArray<FHitResult>& KeptHits,
const EDrawDebugTrace::Type DrawType,
const float HitSize,
const FLinearColor DrawColor,
const float DrawDuration,
const uint8 DepthPriority /*= 0*/
)
{
if (DrawType == EDrawDebugTrace::None)
return;
for (int32 i = 0; i < AllHits.Num(); ++i)
{
const FHitResult& PhysicHit = AllHits[i];
if (!KeptHits.ContainsByPredicate([&](const FHitResult& Hit)
{
return Hit.GetActor() == PhysicHit.GetActor() && Hit.Component == PhysicHit.Component && Hit.Distance == PhysicHit.Distance;
}))
{
DrawHitResult(World, PhysicHit, i, DrawType, false, HitSize, DrawColor, DrawDuration, DepthPriority);
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawHitResult(
const UWorld* World,
const FHitResult& Hit,
const int HitIndex,
const EDrawDebugTrace::Type DrawType,
const bool ShowHitIndex,
const float HitSize,
const FLinearColor HitColor,
const float DrawDuration,
const uint8 DepthPriority /*= 0*/
)
{
if (DrawType == EDrawDebugTrace::None)
return;
const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent;
const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f;
::DrawDebugSphere(World, Hit.ImpactPoint, HitSize, 12, HitColor.ToFColor(true), DrawPersistent, DrawTime, DepthPriority);
if (ShowHitIndex)
{
::DrawDebugString(World, Hit.ImpactPoint, FString::Printf(TEXT("%d"), HitIndex), nullptr, HitColor.ToFColor(true), DrawTime, true, 1.0f);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawHelper::DrawFrustum(
const UWorld* World,
const FMatrix& Matrix,
const float Angle,
const float AspectRatio,
const float NearPlane,
const float FarPlane,
const FColor& Color,
const bool bPersistentLines,
const float LifeTime,
const uint8 DepthPriority,
const float Thickness)
{
FVector Direction(1, 0, 0);
FVector LeftVector(0, 1, 0);
FVector UpVector(0, 0, 1);
FVector Verts[8];
const float HozHalfAngleInRadians = FMath::DegreesToRadians(Angle * 0.5f);
float HozLength = 0.0f;
float VertLength = 0.0f;
if (Angle > 0.0f)
{
HozLength = NearPlane * FMath::Tan(HozHalfAngleInRadians);
VertLength = HozLength / AspectRatio;
}
else
{
const float OrthoWidth = (Angle == 0.0f) ? 1000.0f : -Angle;
HozLength = OrthoWidth * 0.5f;
VertLength = HozLength / AspectRatio;
}
// near plane verts
Verts[0] = (Direction * NearPlane) + (UpVector * VertLength) + (LeftVector * HozLength);
Verts[1] = (Direction * NearPlane) + (UpVector * VertLength) - (LeftVector * HozLength);
Verts[2] = (Direction * NearPlane) - (UpVector * VertLength) - (LeftVector * HozLength);
Verts[3] = (Direction * NearPlane) - (UpVector * VertLength) + (LeftVector * HozLength);
if (Angle > 0.0f)
{
HozLength = FarPlane * FMath::Tan(HozHalfAngleInRadians);
VertLength = HozLength / AspectRatio;
}
// far plane verts
Verts[4] = (Direction * FarPlane) + (UpVector * VertLength) + (LeftVector * HozLength);
Verts[5] = (Direction * FarPlane) + (UpVector * VertLength) - (LeftVector * HozLength);
Verts[6] = (Direction * FarPlane) - (UpVector * VertLength) - (LeftVector * HozLength);
Verts[7] = (Direction * FarPlane) - (UpVector * VertLength) + (LeftVector * HozLength);
for (int32 X = 0; X < 8; ++X)
{
Verts[X] = Matrix.TransformPosition(Verts[X]);
}
DrawDebugLine(World, Verts[0], Verts[1], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[1], Verts[2], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[2], Verts[3], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[3], Verts[0], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[4], Verts[5], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[5], Verts[6], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[6], Verts[7], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[7], Verts[4], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[0], Verts[4], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[1], Verts[5], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[2], Verts[6], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, Verts[3], Verts[7], Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
}
@@ -0,0 +1,196 @@
#include "CogDebugDrawImGui.h"
#include "imgui_internal.h"
//--------------------------------------------------------------------------------------------------------------------------
TArray<FCogDebugDrawImGui::FLine> FCogDebugDrawImGui::Lines;
TArray<FCogDebugDrawImGui::FTriangle> FCogDebugDrawImGui::Triangles;
TArray<FCogDebugDrawImGui::FTriangle> FCogDebugDrawImGui::TrianglesFilled;
TArray<FCogDebugDrawImGui::FRectangle> FCogDebugDrawImGui::Rectangles;
TArray<FCogDebugDrawImGui::FRectangle> FCogDebugDrawImGui::RectanglesFilled;
TArray<FCogDebugDrawImGui::FQuad> FCogDebugDrawImGui::Quads;
TArray<FCogDebugDrawImGui::FQuad> FCogDebugDrawImGui::QuadsFilled;
TArray<FCogDebugDrawImGui::FCircle> FCogDebugDrawImGui::Circles;
TArray<FCogDebugDrawImGui::FCircle> FCogDebugDrawImGui::CirclesFilled;
TArray<FCogDebugDrawImGui::FText> FCogDebugDrawImGui::Texts;
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddLine(const ImVec2& P1, const ImVec2& P2, ImU32 Color, float Thickness /*= 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FLine Line;
Line.P1 = P1;
Line.P2 = P2;
Line.Color = Color;
Line.Thickness = Thickness;
Line.Time = ImGui::GetCurrentContext()->Time;
Line.Duration = Duration;
Line.FadeColor = FadeColor;
Lines.Add_GetRef(Line);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddRect(const ImVec2& Min, const ImVec2& Max, ImU32 Color, float Rounding /*= 0.0f*/, float Thickness /*= 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FRectangle Rectangle;
Rectangle.Min = Min;
Rectangle.Max = Max;
Rectangle.Color = Color;
Rectangle.Rounding = Rounding;
Rectangle.Thickness = Thickness;
Rectangle.Time = ImGui::GetCurrentContext()->Time;
Rectangle.Duration = Duration;
Rectangle.FadeColor = FadeColor;
Rectangles.Add_GetRef(Rectangle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddRectFilled(const ImVec2& Min, const ImVec2& Max, ImU32 Color, float Rounding /*= 0.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FRectangle Rectangle;
Rectangle.Min = Min;
Rectangle.Max = Max;
Rectangle.Color = Color;
Rectangle.Rounding = Rounding;
Rectangle.Thickness = 0.0f;
Rectangle.Time = ImGui::GetCurrentContext()->Time;
Rectangle.Duration = Duration;
Rectangle.FadeColor = FadeColor;
RectanglesFilled.Add_GetRef(Rectangle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddQuad(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, const ImVec2& P4, ImU32 Color, float Thickness/* = 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FQuad Quad;
Quad.P1 = P1;
Quad.P2 = P2;
Quad.P3 = P3;
Quad.P4 = P4;
Quad.Color = Color;
Quad.Thickness = Thickness;
Quad.Time = ImGui::GetCurrentContext()->Time;
Quad.Duration = Duration;
Quad.FadeColor = FadeColor;
Quads.Add_GetRef(Quad);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddQuadFilled(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, const ImVec2& P4, ImU32 Color, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FQuad Quad;
Quad.P1 = P1;
Quad.P2 = P2;
Quad.P3 = P3;
Quad.P4 = P4;
Quad.Color = Color;
Quad.Thickness = 0.0f;
Quad.Time = ImGui::GetCurrentContext()->Time;
Quad.Duration = Duration;
Quad.FadeColor = FadeColor;
QuadsFilled.Add_GetRef(Quad);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddTriangle(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, ImU32 Color, float Thickness/* = 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FTriangle Triangle;
Triangle.P1 = P1;
Triangle.P2 = P2;
Triangle.P3 = P3;
Triangle.Color = Color;
Triangle.Thickness = Thickness;
Triangle.Time = ImGui::GetCurrentContext()->Time;
Triangle.Duration = Duration;
Triangle.FadeColor = FadeColor;
Triangles.Add_GetRef(Triangle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddTriangleFilled(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, ImU32 Color, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FTriangle Triangle;
Triangle.P1 = P1;
Triangle.P2 = P2;
Triangle.P3 = P3;
Triangle.Color = Color;
Triangle.Thickness = 0.0f;
Triangle.Time = ImGui::GetCurrentContext()->Time;
Triangle.Duration = Duration;
Triangle.FadeColor = FadeColor;
TrianglesFilled.Add_GetRef(Triangle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddCircle(const ImVec2& Center, float Radius, ImU32 Color, int Segments /*= 0*/, float Thickness /*= 1.0f*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FCircle Circle;
Circle.Center = Center;
Circle.Radius = Radius > 0.0f ? Radius : 1.0f;
Circle.Color = Color;
Circle.Segments = Segments;
Circle.Thickness = Thickness;
Circle.Time = ImGui::GetCurrentContext()->Time;
Circle.Duration = Duration;
Circle.FadeColor = FadeColor;
Circles.Add_GetRef(Circle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddCircleFilled(const ImVec2& Center, float Radius, ImU32 Color, int Segments /*= 0*/, float Duration /*= 0.0f*/, bool FadeColor /*= false*/)
{
FCircle Circle;
Circle.Center = Center;
Circle.Radius = Radius > 0.0f ? Radius : 1.0f;
Circle.Color = Color;
Circle.Segments = Segments;
Circle.Thickness = 0.0f;
Circle.Time = ImGui::GetCurrentContext()->Time;
Circle.Duration = Duration;
Circle.FadeColor = FadeColor;
CirclesFilled.Add_GetRef(Circle);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::AddText(const ImVec2& Pos, const FString& Text, ImU32 Color, bool AddShadow /*= false*/, float Duration/* = 0.0f*/, bool FadeColor /*= false*/)
{
if (AddShadow)
{
FText ShadowTextElement;
ShadowTextElement.Pos = Pos + ImVec2(1, 1);
ShadowTextElement.Text = Text;
float Alpha = ImGui::ColorConvertU32ToFloat4(Color).w; // Keep original Alpha and set to black
ShadowTextElement.Color = ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, Alpha));
ShadowTextElement.Time = ImGui::GetCurrentContext()->Time;
ShadowTextElement.Duration = Duration;
ShadowTextElement.FadeColor = FadeColor;
Texts.Add_GetRef(ShadowTextElement);
}
FText TextElement;
TextElement.Pos = Pos;
TextElement.Text = Text;
TextElement.Color = Color;
TextElement.Time = ImGui::GetCurrentContext()->Time;
TextElement.Duration = Duration;
TextElement.FadeColor = FadeColor;
Texts.Add_GetRef(TextElement);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugDrawImGui::Draw()
{
ImDrawList* DrawList = ImGui::GetBackgroundDrawList();
double Time = ImGui::GetCurrentContext()->Time;
DrawShapes(Lines, [DrawList](const FLine& Line, const ImColor Color) { DrawList->AddLine(Line.P1, Line.P2, Color, Line.Thickness); });
DrawShapes(Rectangles, [DrawList](const FRectangle& Rectangle, const ImColor Color) { DrawList->AddRect(Rectangle.Min, Rectangle.Max, Color, Rectangle.Rounding, Rectangle.Thickness); });
DrawShapes(RectanglesFilled, [DrawList](const FRectangle& Rectangle, const ImColor Color) { DrawList->AddRectFilled(Rectangle.Min, Rectangle.Max, Color, Rectangle.Rounding); });
DrawShapes(Quads, [DrawList](const FQuad& Quad, const ImColor Color) { DrawList->AddQuad(Quad.P1, Quad.P2, Quad.P3, Quad.P4, Color, Quad.Thickness); });
DrawShapes(QuadsFilled, [DrawList](const FQuad& Quad, const ImColor Color) { DrawList->AddQuadFilled(Quad.P1, Quad.P2, Quad.P3, Quad.P4, Color); });
DrawShapes(Triangles, [DrawList](const FTriangle& Triangle, const ImColor Color) { DrawList->AddTriangle(Triangle.P1, Triangle.P2, Triangle.P3, Color, Triangle.Thickness); });
DrawShapes(TrianglesFilled, [DrawList](const FTriangle& Triangle, const ImColor Color) { DrawList->AddTriangleFilled(Triangle.P1, Triangle.P2, Triangle.P3, Color); });
DrawShapes(Circles, [DrawList](const FCircle& Circle, const ImColor Color) { DrawList->AddCircle(Circle.Center, Circle.Radius, Color, Circle.Segments, Circle.Thickness); });
DrawShapes(CirclesFilled, [DrawList](const FCircle& Circle, const ImColor Color) { DrawList->AddCircleFilled(Circle.Center, Circle.Radius, Color, Circle.Segments); });
DrawShapes(Texts, [DrawList](const FText& Text, const ImColor Color) { DrawList->AddText(Text.Pos, Color, TCHAR_TO_ANSI(*Text.Text)); });
}
@@ -0,0 +1,50 @@
#include "CogDebugHelper.h"
//--------------------------------------------------------------------------------------------------------------------------
FColor FCogDebugHelper::GetAutoColor(FName Name, const FColor& UserColor)
{
if (UserColor != FColor::Transparent)
{
return UserColor;
}
else
{
uint32 Hash = GetTypeHash(Name.ToString());
FMath::RandInit(Hash);
const uint8 Hue = (uint8)(FMath::FRand() * 255);
const uint8 Saturation = 255;
const uint8 Value = FMath::Rand() > 0.5f ? 200 : 255;
return FLinearColor::MakeFromHSV8(Hue, Saturation, Value).ToFColor(true);
}
}
//--------------------------------------------------------------------------------------------------------------------------
const char* FCogDebugHelper::VerbosityToString(ELogVerbosity::Type Verbosity)
{
switch (Verbosity & ELogVerbosity::VerbosityMask)
{
case ELogVerbosity::NoLogging: return "No Logging";
case ELogVerbosity::Fatal: return "Fatal";
case ELogVerbosity::Error: return "Error";
case ELogVerbosity::Warning: return "Warning";
case ELogVerbosity::Display: return "Display";
case ELogVerbosity::Log: return "Log";
case ELogVerbosity::Verbose: return "Verbose";
case ELogVerbosity::VeryVerbose: return "Very Verbose";
}
return "None";
}
//--------------------------------------------------------------------------------------------------------------------------
FString FCogDebugHelper::ShortenEnumName(FString EnumNameString)
{
int32 ScopeIndex = EnumNameString.Find(TEXT("::"), ESearchCase::CaseSensitive);
if (ScopeIndex != INDEX_NONE)
{
return EnumNameString.Mid(ScopeIndex + 2);
}
return EnumNameString;
}
@@ -0,0 +1,54 @@
#include "CogDebugLogBlueprint.h"
#include "CogDebugLogCategoryManager.h"
#include "CogDebugLogMacros.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugLogBlueprint::Log(FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const AActor* Actor, const FString& Text)
{
#if ENABLE_COG
const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory();
if (LogCategoryPtr == nullptr)
{
COG_LOG(LogCogNone, ELogVerbosity::Warning, TEXT("Blueprint Log - Invalid Log Category: %s"), *Text);
return;
}
if (Actor != nullptr)
{
COG_LOG_ACTOR_NO_CONTEXT(*LogCategoryPtr, (ELogVerbosity::Type)Verbosity, Actor, TEXT("%s"), *Text);
}
else
{
COG_LOG(*LogCategoryPtr, (ELogVerbosity::Type)Verbosity, TEXT("%s"), *Text);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
bool UCogDebugLogBlueprint::IsLogActive(FCogLogCategory LogCategory, const AActor* Actor)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
{
if (FCogDebugLogCategoryManager::IsLogCategoryActive(*LogCategoryPtr) == false)
{
return false;
}
if (FCogDebugSettings::IsDebugActiveForActor(Actor) == false)
{
return false;
}
return true;
}
#endif //ENABLE_COG
return false;
}
@@ -0,0 +1,31 @@
#include "CogDebugLogCategory.h"
#include "CogDebugLogCategoryManager.h"
//--------------------------------------------------------------------------------------------------------------------------
FLogCategoryBase* FCogLogCategory::GetLogCategory() const
{
#if NO_LOGGING
return nullptr;
#else
if (Name.IsNone() || Name.IsValid() == false)
{
return nullptr;
}
if (LogCategory == nullptr)
{
if (FCogDebugLogCategoryInfo* CategoryInfo = FCogDebugLogCategoryManager::GetLogCategories().Find(Name))
{
LogCategory = CategoryInfo->LogCategory;
}
}
return LogCategory;
#endif //NO_LOGGING
}
@@ -0,0 +1,122 @@
#include "CogDebugLogCategoryManager.h"
#include "CogDebugModule.h"
#include "CogDebugReplicator.h"
#include "Engine/Engine.h"
#include "Engine/World.h"
#include "GameFramework/PlayerController.h"
//--------------------------------------------------------------------------------------------------------------------------
DEFINE_LOG_CATEGORY(LogCogNone);
DEFINE_LOG_CATEGORY(LogCogServerDebug);
TMap<FName, FCogDebugLogCategoryInfo> FCogDebugLogCategoryManager::LogCategories;
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory)
{
LogCategories.Add(LogCategory.GetCategoryName(), FCogDebugLogCategoryInfo{ &LogCategory, ELogVerbosity::NumVerbosity });
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugLogCategoryManager::IsVerbosityActive(ELogVerbosity::Type Verbosity)
{
return Verbosity >= ELogVerbosity::Verbose;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugLogCategoryManager::IsLogCategoryActive(const FLogCategoryBase& LogCategory)
{
return IsVerbosityActive(LogCategory.GetVerbosity());
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugLogCategoryManager::IsLogCategoryActive(FName CategoryName)
{
if (FLogCategoryBase* LogCategory = FindLogCategory(CategoryName))
{
return IsVerbosityActive(LogCategory->GetVerbosity());
}
return false;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::SetLogCategoryActive(FLogCategoryBase& LogCategory, bool Value)
{
LogCategory.SetVerbosity(Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::OnServerVerbosityChanged(FName CategoryName, ELogVerbosity::Type Verbosity)
{
if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName))
{
LogCategoryInfo->ServerVerbosity = Verbosity;
}
}
//--------------------------------------------------------------------------------------------------------------------------
ELogVerbosity::Type FCogDebugLogCategoryManager::GetServerVerbosity(FName CategoryName)
{
if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName))
{
return LogCategoryInfo->ServerVerbosity;
}
return ELogVerbosity::NoLogging;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::SetServerVerbosity(FName CategoryName, ELogVerbosity::Type Verbosity)
{
if (ACogDebugReplicator* Replicator = FCogDebugModule::Get().GetLocalReplicator())
{
Replicator->Server_SetCategoryVerbosity(CategoryName, (ECogLogVerbosity)Verbosity);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::SetServerVerbosityActive(FName CategoryName, bool Value)
{
SetServerVerbosity(CategoryName, Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugLogCategoryManager::IsServerVerbosityActive(FName CategoryName)
{
return IsVerbosityActive(GetServerVerbosity(CategoryName));
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugLogCategoryInfo* FCogDebugLogCategoryManager::FindLogCategoryInfo(FName CategoryName)
{
return LogCategories.Find(CategoryName);
}
//--------------------------------------------------------------------------------------------------------------------------
FLogCategoryBase* FCogDebugLogCategoryManager::FindLogCategory(FName CategoryName)
{
if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName))
{
return LogCategoryInfo->LogCategory;
}
else
{
return nullptr;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::DeactivateAllLogCateories(UWorld& World)
{
FString ToggleStr = TEXT("Log LogCogNone Only");
GEngine->Exec(&World, *ToggleStr);
if (APlayerController* PlayerController = World.GetFirstPlayerController())
{
PlayerController->ServerExec(ToggleStr);
}
}
@@ -0,0 +1,48 @@
#include "CogDebugModule.h"
#define LOCTEXT_NAMESPACE "FCogDebugModule"
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugModule::StartupModule()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugModule::ShutdownModule()
{
}
//--------------------------------------------------------------------------------------------------------------------------
ACogDebugReplicator* FCogDebugModule::GetLocalReplicator()
{
return LocalReplicator;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugModule::SetLocalReplicator(ACogDebugReplicator* Value)
{
LocalReplicator = Value;
}
//--------------------------------------------------------------------------------------------------------------------------
ACogDebugReplicator* FCogDebugModule::GetRemoteReplicator(const APlayerController* PlayerController)
{
for (ACogDebugReplicator* Replicator : RemoteReplicators)
{
if (Replicator->GetPlayerController() == PlayerController)
{
return Replicator;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugModule::AddRemoteReplicator(ACogDebugReplicator* Value)
{
RemoteReplicators.Add(Value);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FCogDebugModule, CogDebug)
@@ -0,0 +1,528 @@
#include "CogDebugPlot.h"
#include "CogDebugFilteredActorInterface.h"
#include "CogDebugDraw.h"
#include "CogDebugHelper.h"
#include "CogImguiHelper.h"
FCogDebugPlotEvent FCogDebugPlot::DefaultEvent;
TArray<FCogDebugPlotEntry> FCogDebugPlot::Plots;
bool FCogDebugPlot::IsVisible = false;
bool FCogDebugPlot::Pause = false;
FName FCogDebugPlot::LastAddedEventPlotName = NAME_None;
int32 FCogDebugPlot::LastAddedEventIndex = INDEX_NONE;
//--------------------------------------------------------------------------------------------------------------------------
// FCogPlotEvent
//--------------------------------------------------------------------------------------------------------------------------
float FCogDebugPlotEvent::GetActualEndTime(const FCogDebugPlotEntry& Plot) const
{
const float ActualEndTime = EndTime == 0.0f ? Plot.Time : EndTime;
return ActualEndTime;
}
//--------------------------------------------------------------------------------------------------------------------------
uint64 FCogDebugPlotEvent::GetActualEndFrame(const FCogDebugPlotEntry& Plot) const
{
const float ActualEndFame = EndFrame == 0.0f ? Plot.Frame : EndFrame;
return ActualEndFame;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, bool Value)
{
if (FCogDebugPlot::IsVisible)
{
AddParam(Name, FString::Printf(TEXT("%s"), Value ? TEXT("True") : TEXT("False")));
}
return *this;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, int Value)
{
if (FCogDebugPlot::IsVisible)
{
AddParam(Name, FString::Printf(TEXT("%d"), Value));
}
return *this;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, float Value)
{
if (FCogDebugPlot::IsVisible)
{
AddParam(Name, FString::Printf(TEXT("%0.2f"), Value));
}
return *this;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, FName Value)
{
if (FCogDebugPlot::IsVisible)
{
AddParam(Name, Value.ToString());
}
return *this;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEvent::AddParam(const FName Name, const FString& Value)
{
if (FCogDebugPlot::IsVisible)
{
if (Name == "Name")
{
DisplayName = Value;
}
else
{
FCogDebugPlotEventParams& Param = Params.AddDefaulted_GetRef();
Param.Name = Name;
Param.Value = Value;
}
}
return *this;
}
//--------------------------------------------------------------------------------------------------------------------------
// FCogPlotEntry
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlotEntry::AddPoint(float X, float Y)
{
if (Values.Capacity == 0)
{
Values.reserve(2000);
}
if (Values.size() < Values.Capacity)
{
Values.push_back(ImVec2(X, Y));
}
else
{
Values[ValueOffset] = ImVec2(X, Y);
ValueOffset = (ValueOffset + 1) % Values.size();
}
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEntry::AddEvent(
const FCogDebugPlotEntry& OwnwePlot,
FString OwnerName,
bool IsInstant,
const FName EventId,
const int32 Row,
const FColor& Color)
{
if (Events.Max() < 200)
{
Events.Reserve(200);
}
//-----------------------------------------------------------------------
// We currently having two events with the same name at the same time.
// So we stop the current one if any exist.
//-----------------------------------------------------------------------
StopEvent(EventId);
FCogDebugPlotEvent* Event = nullptr;
int32 AddedIndex = 0;
if (Events.Num() < Events.Max())
{
Event = &Events.AddDefaulted_GetRef();
AddedIndex = Events.Num() - 1;
}
else
{
Event = &Events[EventOffset];
AddedIndex = EventOffset;
EventOffset = (EventOffset + 1) % Events.Num();
}
Event->Id = EventId;
Event->OwnerName = OwnerName;
Event->DisplayName = EventId.ToString();
Event->StartTime = OwnwePlot.Time;
Event->EndTime = IsInstant ? OwnwePlot.Time : 0.0f;
Event->StartFrame = OwnwePlot.Frame;
Event->EndFrame = IsInstant ? OwnwePlot.Frame : 0.0f;
Event->Row = (Row == FCogDebugPlot::AutoRow) ? OwnwePlot.FindFreeRow() : Row;
MaxRow = FMath::Max(Event->Row, MaxRow);
const FColor BorderColor = FCogDebugHelper::GetAutoColor(EventId, Color).WithAlpha(200);
const FColor FillColor = BorderColor.WithAlpha(100);
Event->BorderColor = FCogImguiHelper::ToImColor(BorderColor);
Event->FillColor = FCogImguiHelper::ToImColor(FillColor);
FCogDebugPlot::LastAddedEventPlotName = OwnwePlot.Name;
FCogDebugPlot::LastAddedEventIndex = AddedIndex;
return *Event;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlotEntry::StopEvent(const FName EventId)
{
FCogDebugPlotEvent* Event = FindLastEventByName(EventId);
if (Event == nullptr)
{
return FCogDebugPlot::DefaultEvent;
}
if (Event->EndTime == 0.0f)
{
Event->EndTime = Time;
Event->EndFrame = Frame;
}
return *Event;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlotEntry::UpdateTime(const UWorld* World)
{
Time = World ? World->GetTimeSeconds() : 0.0;
Frame = GFrameCounter;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent* FCogDebugPlotEntry::GetLastEvent()
{
if (Events.Num() == 0)
{
return nullptr;
}
int32 Index = Events.Num() - 1;
if (EventOffset != 0)
{
Index = (Index + EventOffset) % Events.Num();
}
return &Events[Index];
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent* FCogDebugPlotEntry::FindLastEventByName(FName EventId)
{
for (int32 i = Events.Num() - 1; i >= 0; --i)
{
//--------------------------------------------------
// The array cycle so we must offset the index
//--------------------------------------------------
int32 Index = i;
if (EventOffset != 0)
{
Index = (i + EventOffset) % Events.Num();
}
if (Events[Index].Id == EventId)
{
return &Events[Index];
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------------------------------
int32 FCogDebugPlotEntry::FindFreeRow() const
{
static float InstantTimeThreshold = 1.0f;
static float TotalTimeThreshold = 10.0f;
TSet<int32> OccupiedRows;
for (int32 i = Events.Num() - 1; i >= 0; --i)
{
int32 Index = i;
if (EventOffset != 0)
{
Index = (i + EventOffset) % Events.Num();
}
const FCogDebugPlotEvent& Event = Events[Index];
if (Event.EndTime != 0.0f && Time > Event.EndTime + TotalTimeThreshold)
{
break;
}
if (Event.StartTime == Event.EndTime && Time > Event.EndTime + InstantTimeThreshold)
{
continue;
}
if (Event.EndTime != 0.0f)
{
continue;
}
OccupiedRows.Add(Event.Row);
}
int32 FreeRow = 0;
while (true)
{
if (OccupiedRows.Contains(FreeRow) == false)
{
break;
}
FreeRow++;
}
return FreeRow;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlotEntry::AssignAxis(int32 Row, ImAxis YAxis)
{
CurrentRow = Row;
CurrentYAxis = YAxis;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlotEntry::ResetAxis()
{
CurrentRow = INDEX_NONE;
CurrentYAxis = ImAxis_COUNT;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlotEntry::Clear()
{
FCogDebugPlot::ResetLastAddedEvent();
MaxRow = 0;
if (Values.size() > 0)
{
Values.shrink(0);
ValueOffset = 0;
}
if (Events.Num() > 0)
{
Events.Empty();
Events.Shrink();
EventOffset = 0;
}
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugPlotEntry::FindValue(float x, float& y) const
{
y = 0.0f;
bool FoundAfter = false;
bool FoundBefore = false;
for (int32 i = Values.size() - 1; i >= 0; --i)
{
//--------------------------------------------------
// The array cycle so we must offset the index
//--------------------------------------------------
int32 Index = i;
if (ValueOffset != 0)
{
Index = (i + ValueOffset) % Values.size();
}
ImVec2 Point = Values[Index];
if (Point.x > x)
{
FoundAfter = true;
}
if (Point.x < x)
{
FoundBefore = true;
}
if (FoundAfter && FoundBefore)
{
y = Point.y;
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------------------------------
// FCogPlot
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlot::Reset()
{
Plots.Empty();
Pause = false;
ResetLastAddedEvent();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlot::Clear()
{
for (FCogDebugPlotEntry& Entry : FCogDebugPlot::Plots)
{
Entry.Clear();
}
ResetLastAddedEvent();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlot::ResetLastAddedEvent()
{
LastAddedEventPlotName = NAME_None;
LastAddedEventIndex = INDEX_NONE;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent* FCogDebugPlot::GetLastAddedEvent()
{
FCogDebugPlotEntry* Plot = FindPlot(LastAddedEventPlotName);
if (Plot == nullptr)
{
return nullptr;
}
return Plot->GetLastEvent();
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEntry* FCogDebugPlot::FindPlot(const FName Name)
{
FCogDebugPlotEntry* Plot = Plots.FindByPredicate([Name](const FCogDebugPlotEntry& P) { return P.Name == Name; });
return Plot;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObject, const FName PlotName, bool IsEventPlot)
{
//----------------------------------------------------------
// When not visible, we don't go further for performances.
//----------------------------------------------------------
if (IsVisible == false)
{
return nullptr;
}
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
if (World == nullptr)
{
return nullptr;
}
//---------------------------------------------------------------------------------
// Cast to ICogActorFilteringDebugInterface to know if we should filter
//---------------------------------------------------------------------------------
if (Cast<ICogDebugFilteredActorInterface>(WorldContextObject))
{
if (WorldContextObject != FCogDebugSettings::GetSelection())
{
return nullptr;
}
}
FCogDebugPlotEntry* EntryPtr = FindPlot(PlotName);
if (EntryPtr == nullptr)
{
EntryPtr = &Plots.AddDefaulted_GetRef();
EntryPtr->Name = PlotName;
EntryPtr->IsEventPlot = IsEventPlot;
Plots.Sort([](const FCogDebugPlotEntry& A, const FCogDebugPlotEntry& B) { return A.Name.ToString().Compare(B.Name.ToString()) < 0; });
}
if (EntryPtr->CurrentYAxis == ImAxis_COUNT)
{
return nullptr;
}
const float Time = World->GetTimeSeconds();
if (Time < EntryPtr->Time)
{
EntryPtr->Clear();
}
EntryPtr->Time = World->GetTimeSeconds();
EntryPtr->Frame = GFrameCounter;
return EntryPtr;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugPlot::PlotValue(const UObject* WorldContextObject, const FName PlotName, const float Value)
{
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, false);
if (Plot == nullptr)
{
return;
}
Plot->AddPoint(Plot->Time, Value);
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlot::PlotEvent(const UObject* WorldContextObject, const FName PlotName, const FName EventId, bool IsInstant, const int32 Row, const FColor& Color)
{
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, true);
if (Plot == nullptr)
{
ResetLastAddedEvent();
return DefaultEvent;
}
FCogDebugPlotEvent& Event = Plot->AddEvent(*Plot, GetNameSafe(WorldContextObject), IsInstant, EventId, Row, Color);
return Event;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlot::PlotEventInstant(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row, const FColor& Color)
{
FCogDebugPlotEvent& Event = PlotEvent(WorldContextObject, PlotName, EventId, true, Row, Color);
return Event;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlot::PlotEventStart(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row, const FColor& Color)
{
FCogDebugPlotEvent& Event = PlotEvent(WorldContextObject, PlotName, EventId, false, Row, Color);
return Event;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlot::PlotEventStop(const UObject* WorldContextObject, const FName PlotName, const FName EventId)
{
FCogDebugPlotEntry* Plot = RegisterPlot(WorldContextObject, PlotName, true);
if (Plot == nullptr)
{
return DefaultEvent;
}
FCogDebugPlotEvent& Event = Plot->StopEvent(EventId);
return Event;
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugPlotEvent& FCogDebugPlot::PlotEventToggle(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const bool ToggleValue, const int32 Row, const FColor& Color)
{
if (ToggleValue)
{
return PlotEventStart(WorldContextObject, PlotName, EventId, Row, Color);
}
else
{
return PlotEventStop(WorldContextObject, PlotName, EventId);
}
}
@@ -0,0 +1,12 @@
#include "CogDebugPlotBlueprint.h"
#include "CogDebugDefines.h"
#include "CogDebugPlot.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugPlotBlueprint::Plot(const UObject* Owner, const FName Name, const float Value)
{
#if ENABLE_COG
FCogDebugPlot::PlotValue(Owner, Name, Value);
#endif //ENABLE_COG
}
@@ -0,0 +1,263 @@
#include "CogDebugReplicator.h"
#include "CogDebugDraw.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/WorldSettings.h"
#include "Net/Core/PushModel/PushModel.h"
#include "Net/UnrealNetwork.h"
//--------------------------------------------------------------------------------------------------------------------------
// FCogReplicatorNetPack
//--------------------------------------------------------------------------------------------------------------------------
class FCogReplicatorNetState : public INetDeltaBaseState
{
public:
virtual bool IsStateEqual(INetDeltaBaseState* OtherState) override
{
FCogReplicatorNetState* Other = static_cast<FCogReplicatorNetState*>(OtherState);
return (ShapesRepCounter == Other->ShapesRepCounter);
}
int32 ShapesRepCounter = 0;
};
//--------------------------------------------------------------------------------------------------------------------------
// FCogReplicatorNetPack
//--------------------------------------------------------------------------------------------------------------------------
bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
{
if (DeltaParms.bUpdateUnmappedObjects || Owner == nullptr)
{
return true;
}
if (DeltaParms.Writer)
{
const bool bIsOwnerClient = !Owner->bHasAuthority;
if (bIsOwnerClient)
{
return false;
}
FCogReplicatorNetState* OldState = static_cast<FCogReplicatorNetState*>(DeltaParms.OldState);
FCogReplicatorNetState* NewState = new FCogReplicatorNetState();
check(DeltaParms.NewState);
*DeltaParms.NewState = TSharedPtr<INetDeltaBaseState>(NewState);
//------------------------------------------------------------------------------------------------------------------
// Find delta to replicate
//------------------------------------------------------------------------------------------------------------------
{
const bool bMissingOldState = (OldState == nullptr);
const bool bShapesChanged = (SavedShapes != Owner->ReplicatedShapes);
NewState->ShapesRepCounter = (bMissingOldState ? 0 : OldState->ShapesRepCounter) + (bShapesChanged ? 1 : 0);
if (bShapesChanged)
{
SavedShapes = Owner->ReplicatedShapes;
Owner->ReplicatedShapes.Empty();
}
}
//------------------------------------------------------------------------------------------------------------------
// Write
//------------------------------------------------------------------------------------------------------------------
{
const bool bMissingOldState = (OldState == nullptr);
const uint8 ShouldUpdateShapes = bMissingOldState || (OldState->ShapesRepCounter != NewState->ShapesRepCounter);
FBitWriter& Writer = *DeltaParms.Writer;
Writer.WriteBit(ShouldUpdateShapes);
if (ShouldUpdateShapes)
{
Writer << SavedShapes;
}
}
}
else if (DeltaParms.Reader)
{
//------------------------------------------------------------------------------------------------------------------
// Read
//------------------------------------------------------------------------------------------------------------------
FBitReader& Reader = *DeltaParms.Reader;
const uint8 ShouldUpdateShapes = Reader.ReadBit();
if (ShouldUpdateShapes)
{
Reader << Owner->ReplicatedShapes;
}
}
return true;
}
//--------------------------------------------------------------------------------------------------------------------------
// ACogDebugReplicator
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::Create(APlayerController* Controller)
{
if (Controller->GetWorld()->GetNetMode() != NM_Client)
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = Controller;
Controller->GetWorld()->SpawnActor<ACogDebugReplicator>(SpawnInfo);
}
}
//--------------------------------------------------------------------------------------------------------------------------
ACogDebugReplicator::ACogDebugReplicator(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
#if !UE_BUILD_SHIPPING
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bAllowTickOnDedicatedServer = true;
PrimaryActorTick.bTickEvenWhenPaused = true;
PrimaryActorTick.bStartWithTickEnabled = true;
PrimaryActorTick.TickGroup = TG_PrePhysics;
bHasAuthority = false;
bIsLocal = false;
bReplicates = true;
bOnlyRelevantToOwner = true;
ReplicatedData.Owner = this;
#endif // !UE_BUILD_SHIPPING
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::BeginPlay()
{
Super::BeginPlay();
UWorld* World = GetWorld();
check(World);
const ENetMode NetMode = World->GetNetMode();
bHasAuthority = NetMode != NM_Client;
bIsLocal = NetMode != NM_DedicatedServer;
OwnerPlayerController = Cast<APlayerController>(GetOwner());
if (OwnerPlayerController->IsLocalController())
{
FCogDebugModule::Get().SetLocalReplicator(this);
Server_RequestAllCategoriesVerbosity();
}
else
{
FCogDebugModule::Get().AddRemoteReplicator(this);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
FDoRepLifetimeParams Params;
Params.bIsPushBased = true;
DOREPLIFETIME_WITH_PARAMS_FAST(ACogDebugReplicator, ReplicatedData, Params);
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{
#if !UE_BUILD_SHIPPING
Super::TickActor(DeltaTime, TickType, ThisTickFunction);
if (OwnerPlayerController)
{
if (GetWorld()->GetNetMode() == NM_Client)
{
for (FCogDebugShape ReplicatedShape : ReplicatedShapes)
{
ReplicatedShape.Draw(GetWorld());
}
}
}
#endif // !UE_BUILD_SHIPPING
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::Server_SetCategoryVerbosity_Implementation(FName LogCategoryName, ECogLogVerbosity Verbosity)
{
#if !UE_BUILD_SHIPPING
ENetMode NetMode = GetWorld()->GetNetMode();
if (NetMode == NM_DedicatedServer || NetMode == NM_DedicatedServer)
{
if (FCogDebugLogCategoryInfo* LogCategoryInfo = FCogDebugLogCategoryManager::FindLogCategoryInfo(LogCategoryName))
{
LogCategoryInfo->LogCategory->SetVerbosity((ELogVerbosity::Type)Verbosity);
TArray<FCogServerCategoryData> CategoriesData;
CategoriesData.Add({ LogCategoryName, Verbosity });
NetMulticast_SendCategoriesVerbosity(CategoriesData);
}
}
#endif // !UE_BUILD_SHIPPING
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::NetMulticast_SendCategoriesVerbosity_Implementation(const TArray<FCogServerCategoryData>& Categories)
{
#if !UE_BUILD_SHIPPING
if (GetWorld()->GetNetMode() == NM_Client)
{
for (const FCogServerCategoryData& Category : Categories)
{
FCogDebugLogCategoryManager::OnServerVerbosityChanged(Category.LogCategoryName, (ELogVerbosity::Type)Category.Verbosity);
}
}
#endif // !UE_BUILD_SHIPPING
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::Client_SendCategoriesVerbosity_Implementation(const TArray<FCogServerCategoryData>& Categories)
{
#if !UE_BUILD_SHIPPING
if (GetWorld()->GetNetMode() == NM_Client)
{
for (const FCogServerCategoryData& Category : Categories)
{
FCogDebugLogCategoryManager::OnServerVerbosityChanged(Category.LogCategoryName, (ELogVerbosity::Type)Category.Verbosity);
}
}
#endif // !UE_BUILD_SHIPPING
}
//--------------------------------------------------------------------------------------------------------------------------
void ACogDebugReplicator::Server_RequestAllCategoriesVerbosity_Implementation()
{
#if !UE_BUILD_SHIPPING
ENetMode NetMode = GetWorld()->GetNetMode();
if (NetMode == NM_DedicatedServer || NetMode == NM_DedicatedServer)
{
TArray<FCogServerCategoryData> CategoriesData;
for (auto& Entry : FCogDebugLogCategoryManager::GetLogCategories())
{
FCogDebugLogCategoryInfo& CategoryInfo = Entry.Value;
if (CategoryInfo.LogCategory != nullptr)
{
CategoriesData.Add(
{
CategoryInfo.LogCategory->GetCategoryName(),
(ECogLogVerbosity)CategoryInfo.LogCategory->GetVerbosity()
});
}
}
Client_SendCategoriesVerbosity(CategoriesData);
}
#endif // !UE_BUILD_SHIPPING
}
@@ -0,0 +1,202 @@
#include "CogDebugSettings.h"
//--------------------------------------------------------------------------------------------------------------------------
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
bool FCogDebugSettings::FilterBySelection = true;
bool FCogDebugSettings::Persistent = false;
bool FCogDebugSettings::TextShadow = true;
bool FCogDebugSettings::Fade2D = true;
float FCogDebugSettings::Duration = 3.0f;
int FCogDebugSettings::DepthPriority = 0;
int FCogDebugSettings::Segments = 12;
float FCogDebugSettings::Thickness = 0.0f;
float FCogDebugSettings::ServerThickness = 2.0f;
float FCogDebugSettings::ServerColorMultiplier = 0.8f;
float FCogDebugSettings::ArrowSize = 10.0f;
float FCogDebugSettings::AxesScale = 1.0f;
float FCogDebugSettings::GradientColorIntensity = 0.0f;
float FCogDebugSettings::GradientColorSpeed = 2.0f;
float FCogDebugSettings::TextSize = 1.0f;
TArray<FString> FCogDebugSettings::SecondaryBoneWildcards =
{
"interaction",
"center_of_mass",
"ik_*",
"index_*",
"middle_*",
"pinky_*",
"ring_*",
"thumb_*",
"wrist_*",
"*_bck_*",
"*_fwd_*",
"*_in_*",
"*_out_*",
"*_pec_*",
"*_scap_*",
"*_bicep_*",
"*_tricep_*",
"*ankle*",
"*knee*",
"*corrective*",
"*twist*",
"*latissimus*",
};
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugSettings::Reset()
{
FilterBySelection = true;
Persistent = false;
TextShadow = true;
Fade2D = true;
Duration = 3.0f;
DepthPriority = 0;
Segments = 12;
Thickness = 0.0f;
ServerThickness = 2.0f;
ServerColorMultiplier = 0.8f;
ArrowSize = 10.0f;
AxesScale = 1.0f;
GradientColorIntensity = 0.0f;
GradientColorSpeed = 2.0f;
TextSize = 1.0f;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsDebugActiveForActor(const AActor* Actor)
{
const AActor* SelectionPtr = Selection.Get();
if (Actor == nullptr || SelectionPtr == nullptr)
{
return true;
}
if (Cast<ICogDebugFilteredActorInterface>(Actor))
{
return (SelectionPtr == Actor || FilterBySelection == false);
}
return true;
}
//--------------------------------------------------------------------------------------------------------------------------
AActor* FCogDebugSettings::GetSelection()
{
return Selection.Get();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugSettings::SetSelection(AActor* Value)
{
Selection = Value;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::GetDebugPersistent(bool bPersistent)
{
return Persistent && bPersistent;
}
//--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugDuration(bool bPersistent)
{
return bPersistent == false ? 0.0f : Duration;
}
//--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugTextDuration(bool bPersistent)
{
if (bPersistent)
{
return Persistent ? 100 : Duration;
}
else
{
return 0.0f;
}
}
//--------------------------------------------------------------------------------------------------------------------------
int FCogDebugSettings::GetDebugSegments()
{
return Segments;
}
//--------------------------------------------------------------------------------------------------------------------------
int FCogDebugSettings::GetCircleSegments()
{
return (Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
}
//--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugThickness(float InThickness)
{
return (Thickness + InThickness);
}
//--------------------------------------------------------------------------------------------------------------------------
float FCogDebugSettings::GetDebugServerThickness(float InThickness)
{
return (ServerThickness + InThickness);
}
//--------------------------------------------------------------------------------------------------------------------------
uint8 FCogDebugSettings::GetDebugDepthPriority(float InDepthPriority)
{
return (DepthPriority + InDepthPriority);
}
//--------------------------------------------------------------------------------------------------------------------------
FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent)
{
if (bPersistent == false)
{
return Color;
}
const float Time = World->GetTimeSeconds();
const FLinearColor BaseColor(Color);
FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV();
ComplementaryColor.R = ComplementaryColor.R - 180.0f;
if (ComplementaryColor.R < 0.0f)
{
ComplementaryColor.R = 360.0f - ComplementaryColor.R;
}
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(GradientColorSpeed * Time));
const FLinearColor FBlendColor = BaseColor * (1.0f - FCogDebugSettings::GradientColorIntensity) + GradientColor * GradientColorIntensity;
return FBlendColor.ToFColor(true);
}
//--------------------------------------------------------------------------------------------------------------------------
FColor FCogDebugSettings::ModulateServerColor(const FColor& Color)
{
FColor ServerColor(
Color.R * ServerColorMultiplier,
Color.G * ServerColorMultiplier,
Color.B * ServerColorMultiplier,
Color.A);
return ServerColor;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogDebugSettings::IsSecondarySkeletonBone(FName BoneName)
{
FString BoneString = BoneName.ToString().ToLower();
for (const FString& Wildcard : SecondaryBoneWildcards)
{
if (BoneString.MatchesWildcard(Wildcard))
{
return true;
}
}
return false;
}
@@ -0,0 +1,628 @@
#include "CogDebugShape.h"
#include "CogDebugDrawHelper.h"
#include "DrawDebugHelpers.h"
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Location);
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Point;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Size;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPoint(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 1)
{
DrawDebugPoint(
World,
ShapeData[0],
FCogDebugSettings::GetDebugServerThickness(Thickness),
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeSegment(const FVector& StartLocation, const FVector& EndLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(StartLocation);
NewElement.ShapeData.Add(EndLocation);
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Segment;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawSegment(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 2)
{
DrawDebugLine(
World,
ShapeData[0],
ShapeData[1],
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeArrow(const FVector& StartLocation, const FVector& EndLocation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(StartLocation);
NewElement.ShapeData.Add(EndLocation);
NewElement.ShapeData.Add(FVector(HeadSize, 0, 0));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Arrow;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawArrow(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
DrawDebugDirectionalArrow(
World,
ShapeData[0],
ShapeData[1],
ShapeData[2].X,
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeAxes(const FVector& Location, const FRotator& Rotation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Location);
NewElement.ShapeData.Add(FVector(Rotation.Pitch, Rotation.Yaw, Rotation.Roll));
NewElement.ShapeData.Add(FVector(HeadSize, 0, 0));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Axes;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawAxes(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
DrawDebugCoordinateSystem(
World,
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Rotation.Pitch, Rotation.Yaw, Rotation.Roll));
NewElement.ShapeData.Add(Extent);
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Box;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBox(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
DrawDebugBox(
World,
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),
FCogDebugSettings::GetDebugServerThickness(Thickness));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeSolidBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Rotation.Pitch, Rotation.Yaw, Rotation.Roll));
NewElement.ShapeData.Add(Extent);
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::SolidBox;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
return NewElement;
}
void FCogDebugShape::DrawSolidBox(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 12)
{
DrawDebugSolidBox(
World,
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCone(const FVector& Location, const FVector& Direction, const float Length, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Location);
NewElement.ShapeData.Add(Direction);
NewElement.ShapeData.Add(FVector(Length, 0, 0));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Cone;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCone(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3 && ShapeData[2].X > 0)
{
const float DefaultConeAngle = 0.25f; // ~ 15 degrees
DrawDebugCone(
World,
ShapeData[0],
ShapeData[1],
ShapeData[2].X,
DefaultConeAngle,
DefaultConeAngle,
FCogDebugSettings::GetCircleSegments(),
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCylinder(const FVector& Center, const float Radius, const float HalfHeight, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Radius, 0, HalfHeight));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Cylinder;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCylinder(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 2)
{
DrawDebugCylinder(
World,
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCircle(const FVector& Center, const FRotator& Rotation, const float Radius, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Rotation.Pitch, Rotation.Yaw, Rotation.Roll));
NewElement.ShapeData.Add(FVector(Radius, 0, 0));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Circle;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicle(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
DrawDebugCircle(
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),
false);
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCircleArc(const FVector& Center, const FRotator& Rotation, const float InnerRadius, const float OuterRadius, const float Angle, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Rotation.Pitch, Rotation.Yaw, Rotation.Roll));
NewElement.ShapeData.Add(FVector(InnerRadius, OuterRadius, Angle));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::CircleArc;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicleArc(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
FCogDebugDrawHelper::DrawArc(
World,
FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]),
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCapsule(const FVector& Center, const FQuat& Rotation, const float Radius, const float HalfHeight, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(Center);
NewElement.ShapeData.Add(FVector(Radius, HalfHeight, 0));
NewElement.ShapeData.Add(Rotation.Euler());
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Capsule;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCapsule(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 3)
{
DrawDebugCapsule(
World,
ShapeData[0],
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape 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)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(FVector(Start.X, Start.Y, 0));
NewElement.ShapeData.Add(FVector(End.X, End.Y, 0));
NewElement.ShapeData.Add(FVector(Radius, Z, 0));
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::FlatCapsule;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawFlatCapsule(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() > 0)
{
FCogDebugDrawHelper::DrawFlatCapsule(
World,
FVector2D(ShapeData[0].X, ShapeData[0].Y),
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));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeBone(const FVector& BoneLocation, const FVector& ParentLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData.Add(BoneLocation);
NewElement.ShapeData.Add(ParentLocation);
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Bone;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = Thickness;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBone(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() == 2)
{
DrawDebugLine(
World,
ShapeData[0],
ShapeData[1],
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
FCogDebugSettings::GetDebugServerThickness(Thickness));
DrawDebugPoint(
World,
ShapeData[0],
FCogDebugSettings::GetDebugServerThickness(Thickness) + 4.0f,
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakePolygon(const TArray<FVector>& Verts, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
NewElement.ShapeData = Verts;
NewElement.Color = Color;
NewElement.Type = ECogDebugShape::Polygon;
NewElement.bPersistent = bPersistent;
NewElement.DepthPriority = DepthPriority;
NewElement.Thickness = 0.0f;
return NewElement;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPolygon(UWorld* World)
{
#if ENABLE_COG
if (ShapeData.Num() > 0)
{
FVector MidPoint = FVector::ZeroVector;
TArray<int32> Indices;
for (int32 Idx = 0; Idx < ShapeData.Num(); Idx++)
{
Indices.Add(Idx);
MidPoint += ShapeData[Idx];
}
DrawDebugMesh(
World,
ShapeData,
Indices,
FCogDebugSettings::ModulateServerColor(Color),
FCogDebugSettings::GetDebugPersistent(bPersistent),
FCogDebugSettings::GetDebugDuration(bPersistent),
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::Draw(UWorld* World)
{
switch (Type)
{
case ECogDebugShape::Arrow: DrawArrow(World); break;
case ECogDebugShape::Axes: DrawAxes(World); break;
case ECogDebugShape::Bone: DrawBone(World); break;
case ECogDebugShape::Box: DrawBox(World); break;
case ECogDebugShape::Capsule: DrawCapsule(World); break;
case ECogDebugShape::Circle: DrawCicle(World); break;
case ECogDebugShape::CircleArc: DrawCicleArc(World); break;
case ECogDebugShape::Cone: DrawCone(World); break;
case ECogDebugShape::Cylinder: DrawCylinder(World); break;
case ECogDebugShape::FlatCapsule: DrawFlatCapsule(World); break;
case ECogDebugShape::Point: DrawPoint(World); break;
case ECogDebugShape::Polygon: DrawPolygon(World); break;
case ECogDebugShape::Segment: DrawSegment(World); break;
default: break;
}
}
//--------------------------------------------------------------------------------------------------------------------------
FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape)
{
Ar << Shape.ShapeData;
Ar << Shape.Color;
Ar << Shape.bPersistent;
Ar << Shape.DepthPriority;
Ar << Shape.Thickness;
uint8 TypeNum = static_cast<uint8>(Shape.Type);
Ar << TypeNum;
Shape.Type = static_cast<ECogDebugShape>(TypeNum);
return Ar;
}
@@ -0,0 +1,29 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugAllegianceInterface.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
UENUM(BlueprintType)
enum class ECogAllegiance : uint8
{
Ally,
Enemy
};
//--------------------------------------------------------------------------------------------------------------------------
UINTERFACE(MinimalAPI, Blueprintable)
class UCogAllegianceInterface : public UInterface
{
GENERATED_BODY()
};
//--------------------------------------------------------------------------------------------------------------------------
class ICogAllegianceInterface
{
GENERATED_BODY()
public:
virtual ECogAllegiance GetAllegiance(const AActor* OtherActor) const = 0;
};
@@ -0,0 +1,7 @@
#pragma once
#include "CoreMinimal.h"
#ifndef ENABLE_COG
#define ENABLE_COG (ENABLE_DRAW_DEBUG && !NO_LOGGING)
#endif
@@ -0,0 +1,58 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogMacros.h"
class USkeletalMeshComponent;
struct FCogDebugShape;
#if ENABLE_COG
struct COGDEBUG_API FCogDebugDraw
{
static void String2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector2D& Location, const FColor& Color, bool Persistent);
static void Segment2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& SegmentStart, const FVector2D& SegmentEnd, const FColor& Color, bool Persistent);
static void Circle2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Location, float Radius, const FColor& Color, const bool Persistent);
static void Rect2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Min, const FVector2D& Max, const FColor& Color, const bool Persistent);
static void String(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector& Location, const FColor& Color, const bool Persistent);
static void Point(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, float Size, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Segment(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& SegmentStart, const FVector& SegmentEnd, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Bone(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& BoneLocation, const FVector& ParentLocation, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Arrow(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& SegmentStart, const FVector& SegmentEnd, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Axis(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& AxisLoc, const FRotator& AxisRot, float Scale, const bool Persistent, const uint8 DepthPriority = 0U);
static void Circle(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, float Radius, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void CircleArc(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FColor& Color, bool Persistent, const uint8 DepthPriority = 0U);
static void FlatCapsule(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Sphere(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, float Radius, const FColor& Color, bool Persistent, const uint8 DepthPriority = 0U);
static void Box(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const FVector& Extent, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void SolidBox(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const FVector& Extent, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Capsule(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Center, const float HalfHeight, const float Radius, const FQuat& Rotation, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Points(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray<FVector>& Points, float Radius, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority = 0U);
static void Path(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray<FVector>& Points, float PointSize, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority = 0U);
static void Frustrum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U);
static void Skeleton(const FLogCategoryBase& LogCategory, const USkeletalMeshComponent* Skeleton, const FColor& Color, bool DrawSecondaryBones = false, const uint8 DepthPriority = 1);
static void ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape);
};
#endif //ENABLE_COG
@@ -0,0 +1,66 @@
#pragma once
#include "CoreMinimal.h"
#include "Kismet/KismetSystemLibrary.h"
#include "CogDebugDrawBlueprint.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(meta = (ScriptName = "CogDebugDrawBlueprint"))
class COGDEBUG_API UCogDebugDrawBlueprint : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float size, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray<FVector>& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray<FVector>& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent);
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject"))
static void DebugLogRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent);
};
@@ -0,0 +1,40 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
namespace EDrawDebugTrace { enum Type; }
class COGDEBUG_API FCogDebugDrawHelper
{
public:
static void DrawArc(const UWorld* InWorld, const FMatrix& Matrix, const float InnterRadius, const float OuterRadius, const float ArcAngle, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
static void DrawSphere(const UWorld* InWorld, const FVector& Center, const float Radius, const int32 Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
static void DrawFrustum(const UWorld* World, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.f, const uint8 DepthPriority = 0U, const float Thickness = 0.0f);
static void DrawFlatCapsule(const UWorld* InWorld, const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const float Segments, const FColor& Color, const bool bPersistentLines = false, const float LifeTime = -1.0f, const uint8 DepthPriority = 0, const float Thickness = 0.0f);
static void DrawRaycastSingle(const UWorld* World, const FVector& Start, const FVector& End, const EDrawDebugTrace::Type DrawType, const bool bHit, const FHitResult& Hit, const float HitSize, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration, const uint8 DepthPriority = 0);
static void DrawSphereOverlapMulti(const UWorld* World, const FVector& Position, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bOverlap, const TArray<AActor*>& OutActors, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
static void DrawSphereOverlapSingle(const UWorld* World, const FVector& Position, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration = -1.f, const uint8 DepthPriority = 0);
static void DrawCapsuleCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
static void DrawCapsuleCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const FQuat& Rotation, const float HalfHeight, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float DrawDuration = -1.f, const uint8 DepthPriority = 0);
static void DrawSphereCastMulti(const UWorld* World, const FVector& Start, const FVector& End, const float Radius, const EDrawDebugTrace::Type DrawType, const bool bHit, const TArray<FHitResult>& OutHits, const FLinearColor DrawColor, const FLinearColor DrawHitColor, const float DrawDuration = 0);
static void DrawSphereCastSingle(const UWorld* World, const FVector& Start, const FVector& End, const float Radius, const FColor& DrawColor, const bool DrawPersistent, const float LifeTime = -1.f, const uint8 DepthPriority = 0);
static void DrawHitResults(const UWorld* World, const TArray<FHitResult>& OutHits, const EDrawDebugTrace::Type DrawType, const bool ShowHitIndex, const float HitSize, const FLinearColor HitColor, const float DrawDuration, const uint8 DepthPriority = 0);
static void DrawHitResultsDiscarded(const UWorld* World, const TArray<FHitResult>& AllHits, const TArray<FHitResult>& KeptHits, const EDrawDebugTrace::Type DrawType, const float HitSize, const FLinearColor DrawColor, const float DrawDuration, const uint8 DepthPriority = 0);
static void DrawHitResult(const UWorld* World, const FHitResult& Hit, const int HitIndex, const EDrawDebugTrace::Type DrawType, const bool ShowHitIndex, const float HitSize, const FLinearColor HitColor, const float DrawDuration, const uint8 DepthPriority = 0);
};
@@ -0,0 +1,112 @@
#pragma once
#include "CoreMinimal.h"
#include "imgui.h"
class FCogDebugDrawImGui
{
public:
static void AddLine(const ImVec2& P1, const ImVec2& P2, ImU32 Color, float Thickness = 1.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddRect(const ImVec2& Min, const ImVec2& Max, ImU32 Color, float Rounding = 0.0f, float Thickness = 1.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddRectFilled(const ImVec2& Min, const ImVec2& Max, ImU32 Color, float Rounding = 0.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddQuad(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, const ImVec2& P4, ImU32 Color, float Thickness = 1.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddQuadFilled(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, const ImVec2& P4, ImU32 Color, float Duration = 0.0f, bool FadeColor = false);
static void AddTriangle(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, ImU32 Color, float Thickness = 1.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddTriangleFilled(const ImVec2& P1, const ImVec2& P2, const ImVec2& P3, ImU32 Color, float Duration = 0.0f, bool FadeColor = false);
static void AddCircle(const ImVec2& Center, float Radius, ImU32 Color, int Segments = 0, float Thickness = 1.0f, float Duration = 0.0f, bool FadeColor = false);
static void AddCircleFilled(const ImVec2& Center, float Radius, ImU32 Color, int Segments = 0, float Duration = 0.0f, bool FadeColor = false);
static void AddText(const ImVec2& Pos, const FString& Text, ImU32 Color, bool AddShadow = false, float Duration = 0.0f, bool FadeColor = false);
static void Draw();
private:
struct FShape
{
ImU32 Color = 0;
float Duration = 0.0f;
double Time = 0.0f;
bool FadeColor = false;
};
struct FLine : FShape
{
ImVec2 P1 = ImVec2(0, 0);
ImVec2 P2 = ImVec2(0, 0);
float Thickness = 0.0f;
};
struct FRectangle : FShape
{
ImVec2 Min = ImVec2(0, 0);
ImVec2 Max = ImVec2(0, 0);
float Rounding = 0.0f;
float Thickness = 0.0f;
};
struct FQuad : FShape
{
ImVec2 P1 = ImVec2(0, 0);
ImVec2 P2 = ImVec2(0, 0);
ImVec2 P3 = ImVec2(0, 0);
ImVec2 P4 = ImVec2(0, 0);
float Thickness = 0.0f;
};
struct FTriangle : FShape
{
ImVec2 P1 = ImVec2(0, 0);
ImVec2 P2 = ImVec2(0, 0);
ImVec2 P3 = ImVec2(0, 0);
float Thickness = 0.0f;
};
struct FCircle : FShape
{
ImVec2 Center = ImVec2(0, 0);
float Radius = 0.0f;
int Segments = 12;
float Thickness = 0.0f;
};
struct FText : FShape
{
ImVec2 Pos = ImVec2(0, 0);
FString Text;
ImU32 Color = 0;
};
//----------------------------------------------------------------------------------------------------------------------
static TArray<FLine> Lines;
static TArray<FTriangle> Triangles;
static TArray<FTriangle> TrianglesFilled;
static TArray<FRectangle> Rectangles;
static TArray<FRectangle> RectanglesFilled;
static TArray<FQuad> Quads;
static TArray<FQuad> QuadsFilled;
static TArray<FCircle> Circles;
static TArray<FCircle> CirclesFilled;
static TArray<FText> Texts;
//----------------------------------------------------------------------------------------------------------------------
template<typename TShape, typename TDrawFunction>
static void DrawShapes(TArray<TShape>& Shapes, TDrawFunction DrawFunction)
{
ImDrawList* ImDrawList = ImGui::GetBackgroundDrawList();
const double Time = ImGui::GetCurrentContext()->Time;
for (int32 i = 0; i < Shapes.Num(); i++)
{
const TShape& Shape = Shapes[i];
const double ElapsedTime = Time - Shape.Time;
const float Fade = Shape.FadeColor && Shape.Duration > 0.0f ? 1.0f - (ElapsedTime / Shape.Duration) : 1.0f;
ImColor Color(Shape.Color);
Color.Value.w = Fade * Color.Value.w;
DrawFunction(Shape, Color);
if (ElapsedTime < 0 || ElapsedTime > Shape.Duration)
{
Shapes.RemoveAtSwap(i--);
}
}
}
};
@@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugFilteredActorInterface.generated.h"
UINTERFACE(MinimalAPI, Blueprintable)
class UCogDebugFilteredActorInterface : public UInterface
{
GENERATED_BODY()
};
class ICogDebugFilteredActorInterface
{
GENERATED_BODY()
virtual bool IsActorFilteringDebug() const { return true; }
};
@@ -0,0 +1,29 @@
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "imgui.h"
class COGDEBUG_API FCogDebugHelper
{
public:
static FColor GetAutoColor(FName Name, const FColor& UserColor);
static const char* VerbosityToString(ELogVerbosity::Type Verbosity);
static FString ShortenEnumName(FString EnumNameString);
template<typename EnumType>
static FString GetValueAsStringShort(const EnumType EnumeratorValue)
{
FString EnumNameString = UEnum::GetValueAsString(EnumeratorValue);
return ShortenEnumName(EnumNameString);
}
template<typename EnumType>
static FName GetValueAsNameShort(const EnumType EnumeratorValue)
{
return FName(GetValueAsStringShort(EnumeratorValue));
}
};
@@ -0,0 +1,35 @@
#pragma once
#include "CoreMinimal.h"
#include "Kismet/KismetSystemLibrary.h"
#include "Logging/LogVerbosity.h"
#include "CogDebugLogBlueprint.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
UENUM()
enum class ECogLogVerbosity : uint8
{
Fatal = ELogVerbosity::Fatal,
Error = ELogVerbosity::Error,
Warning = ELogVerbosity::Warning,
Display = ELogVerbosity::Display,
Log = ELogVerbosity::Log,
Verbose = ELogVerbosity::Verbose,
VeryVerbose = ELogVerbosity::VeryVerbose
};
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(meta = (ScriptName = "CogLogBlueprint"))
class COGDEBUG_API UCogDebugLogBlueprint : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Log", meta = (DevelopmentOnly))
static void Log(FCogLogCategory LogCategory, ECogLogVerbosity Verbosity = ECogLogVerbosity::Verbose, const AActor* Actor = nullptr, const FString& Text = FString(""));
UFUNCTION(BlueprintPure, Category = "Log", meta = (DevelopmentOnly, AdvancedDisplay = "ScreenTextColor"))
static bool IsLogActive(FCogLogCategory LogCategory, const AActor* Actor = nullptr);
};
@@ -0,0 +1,26 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogCategory.generated.h"
struct FCogLogCategory;
//--------------------------------------------------------------------------------------------------------------------------
USTRUCT(BlueprintType)
struct COGDEBUG_API FCogLogCategory
{
GENERATED_USTRUCT_BODY()
FCogLogCategory() {}
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName Name;
FString GetName() const { return Name.ToString(); }
FLogCategoryBase* GetLogCategory() const;
private:
mutable FLogCategoryBase* LogCategory = nullptr;
};
@@ -0,0 +1,53 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "Logging/LogVerbosity.h"
//--------------------------------------------------------------------------------------------------------------------------
DECLARE_LOG_CATEGORY_EXTERN(LogCogNone, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogServerDebug, Verbose, All);
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugLogCategoryInfo
{
FLogCategoryBase* LogCategory = nullptr;
ELogVerbosity::Type ServerVerbosity = ELogVerbosity::NoLogging;
};
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugLogCategoryManager
{
static void AddLogCategory(FLogCategoryBase& LogCategory);
static bool IsVerbosityActive(ELogVerbosity::Type Verbosity);
static bool IsLogCategoryActive(const FLogCategoryBase& LogCategory);
static bool IsLogCategoryActive(FName CategoryName);
static void SetLogCategoryActive(FLogCategoryBase& LogCategory, bool Value);
static FLogCategoryBase* FindLogCategory(FName LogCategory);
static FCogDebugLogCategoryInfo* FindLogCategoryInfo(FName LogCategory);
static TMap<FName, FCogDebugLogCategoryInfo>& GetLogCategories() { return LogCategories; }
static void SetServerVerbosityActive(FName LogCategory, bool Value);
static bool IsServerVerbosityActive(FName LogCategory);
static ELogVerbosity::Type GetServerVerbosity(FName LogCategory);
static void SetServerVerbosity(FName LogCategory, ELogVerbosity::Type Verbosity);
static void OnServerVerbosityChanged(FName LogCategory, ELogVerbosity::Type Verbosity);
static void DeactivateAllLogCateories(UWorld& World);
private:
static TMap<FName, FCogDebugLogCategoryInfo> LogCategories;
};
@@ -0,0 +1,52 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "CogDebugSettings.h"
#include "Templates/IsArrayOrRefOfType.h"
#if !ENABLE_COG
#define COG_LOG(LogCategory, Verbosity, Format, ...) (0)
#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) (0)
#define COG_LOG_ACTOR(LogCategory, Verbosity, Actor, Format, ...) (0)
#define COG_LOG_ACTOR_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) (0)
#else //!ENABLE_COG
//--------------------------------------------------------------------------------------------------------------------------
#define COG_LOG_ACTIVE_FOR_ACTOR(Actor) (FCogDebugSettings::IsDebugActiveForActor(Actor))
//--------------------------------------------------------------------------------------------------------------------------
#define COG_LOG(LogCategory, Verbosity, Format, ...) \
{ \
static_assert(TIsArrayOrRefOfType<decltype(Format), TCHAR>::Value, "Formatting string must be a TCHAR array."); \
if ((LogCategory).IsSuppressed(Verbosity) == false) \
{ \
FMsg::Logf_Internal(nullptr, 0, (LogCategory).GetCategoryName(), Verbosity, Format, ##__VA_ARGS__); \
} \
} \
//--------------------------------------------------------------------------------------------------------------------------
#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) \
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), ANSI_TO_TCHAR(__FUNCTION__), *FString::Printf(Format, ##__VA_ARGS__)); \
//--------------------------------------------------------------------------------------------------------------------------
#define COG_LOG_ACTOR(LogCategory, Verbosity, Actor, Format, ...) \
if (COG_LOG_ACTIVE_FOR_ACTOR(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
{ \
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s - %s"), \
*GetNameSafe(Actor), \
ANSI_TO_TCHAR(__FUNCTION__), \
*FString::Printf(Format, ##__VA_ARGS__)); \
} \
//--------------------------------------------------------------------------------------------------------------------------
#define COG_LOG_ACTOR_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) \
if (COG_LOG_ACTIVE_FOR_ACTOR(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
{ \
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), *GetNameSafe(Actor), *FString::Printf(Format, ##__VA_ARGS__)); \
} \
#endif //!ENABLE_COG
@@ -0,0 +1,34 @@
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class ACogDebugReplicator;
class APlayerController;
class COGDEBUG_API FCogDebugModule : public IModuleInterface
{
public:
static inline FCogDebugModule& Get() { return FModuleManager::LoadModuleChecked<FCogDebugModule>("CogDebug"); }
virtual void StartupModule() override;
virtual void ShutdownModule() override;
ACogDebugReplicator* GetLocalReplicator();
void SetLocalReplicator(ACogDebugReplicator* Value);
ACogDebugReplicator* GetRemoteReplicator(const APlayerController* PlayerController);
TArray<TObjectPtr<ACogDebugReplicator>> GetRemoteReplicators() const { return RemoteReplicators; }
void AddRemoteReplicator(ACogDebugReplicator* Value);
private:
TObjectPtr<ACogDebugReplicator> LocalReplicator;
TArray<TObjectPtr<ACogDebugReplicator>> RemoteReplicators;
};
@@ -0,0 +1,123 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "imgui.h"
#include "implot.h"
#ifdef ENABLE_COG
struct FCogDebugPlotEntry;
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugPlotEventParams
{
FName Name;
FString Value;
};
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugPlotEvent
{
float GetActualEndTime(const FCogDebugPlotEntry& Plot) const;
uint64 GetActualEndFrame(const FCogDebugPlotEntry& Plot) const;
FCogDebugPlotEvent& AddParam(const FName Name, bool Value);
FCogDebugPlotEvent& AddParam(const FName Name, int Value);
FCogDebugPlotEvent& AddParam(const FName Name, float Value);
FCogDebugPlotEvent& AddParam(const FName Name, FName Value);
FCogDebugPlotEvent& AddParam(const FName Name, const FString& Value);
FName Id;
float StartTime = 0.0f;
float EndTime = 0.0f;
uint64 StartFrame = 0;
uint64 EndFrame = 0;
ImU32 BorderColor;
ImU32 FillColor;
int32 Row;
FString OwnerName;
FString DisplayName;
TArray<FCogDebugPlotEventParams> Params;
};
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugPlotEntry
{
void AssignAxis(int32 AssignedRow, ImAxis CurrentYAxis);
void AddPoint(float X, float Y);
bool FindValue(float Time, float& Value) const;
void ResetAxis();
void Clear();
FCogDebugPlotEvent& AddEvent(const FCogDebugPlotEntry& OwnwePlot, FString OwnerName, bool IsInstant, const FName EventId, const int32 Row, const FColor& Color);
FCogDebugPlotEvent& StopEvent(const FName EventId);
void UpdateTime(const UWorld* World);
int32 FindFreeRow() const;
FCogDebugPlotEvent* GetLastEvent();
FCogDebugPlotEvent* FindLastEventByName(FName EventId);
FName Name;
bool IsEventPlot = false;
int32 CurrentRow = INDEX_NONE;
ImAxis CurrentYAxis = ImAxis_COUNT;
float Time = 0;
uint64 Frame = 0;
//--------------------------
// Values
//--------------------------
int32 ValueOffset = 0;
ImVector<ImVec2> Values;
bool ShowValuesMarkers = false;
//--------------------------
// Events
//--------------------------
int32 EventOffset = 0;
TArray<FCogDebugPlotEvent> Events;
int32 MaxRow = 1;
};
//--------------------------------------------------------------------------------------------------------------------------
class COGDEBUG_API FCogDebugPlot
{
public:
static const int32 AutoRow = -1;
static void PlotValue(const UObject* WorldContextObject, const FName PlotName, const float Value);
static FCogDebugPlotEvent& PlotEvent(const UObject* WorldContextObject, const FName PlotName, const FName EventId, bool IsInstant, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
static FCogDebugPlotEvent& PlotEventInstant(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
static FCogDebugPlotEvent& PlotEventStart(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
static FCogDebugPlotEvent& PlotEventStop(const UObject* WorldContextObject, const FName PlotName, const FName EventId);
static FCogDebugPlotEvent& PlotEventToggle(const UObject* WorldContextObject, const FName PlotName, const FName EventId, const bool ToggleValue, const int32 Row = AutoRow, const FColor& Color = FColor::Transparent);
static void Reset();
static void Clear();
static FCogDebugPlotEntry* FindPlot(const FName Name);
static TArray<FCogDebugPlotEntry> Plots;
static bool IsVisible;
static bool Pause;
private:
friend struct FCogDebugPlotEntry;
static void ResetLastAddedEvent();
static FCogDebugPlotEntry* RegisterPlot(const UObject* Owner, const FName PlotName, bool IsEventPlot);
FCogDebugPlotEventParams* PlotEventAddParam(const FName Name);
static FCogDebugPlotEvent* GetLastAddedEvent();
static FName LastAddedEventPlotName;
static int32 LastAddedEventIndex;
static FCogDebugPlotEvent DefaultEvent;
};
#endif //ENABLE_COG
@@ -0,0 +1,16 @@
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CogDebugPlotBlueprint.generated.h"
UCLASS(meta = (ScriptName = "CogDebugPlot"))
class COGDEBUG_API UCogDebugPlotBlueprint : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly))
static void Plot(const UObject* Owner, const FName Name, const float Value);
};
@@ -0,0 +1,96 @@
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CogDebugShape.h"
#include "CogDebugLogBlueprint.h"
#include "UObject/Class.h"
#include "UObject/ObjectMacros.h"
#include "CogDebugReplicator.generated.h"
class ACogDebugReplicator;
class APlayerController;
//--------------------------------------------------------------------------------------------------------------------------
USTRUCT()
struct FCogServerCategoryData
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
FName LogCategoryName;
UPROPERTY()
ECogLogVerbosity Verbosity = ECogLogVerbosity::Fatal;
};
//--------------------------------------------------------------------------------------------------------------------------
USTRUCT()
struct FCogReplicatorNetPack
{
GENERATED_USTRUCT_BODY()
ACogDebugReplicator* Owner = nullptr;
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms);
private:
TArray<FCogDebugShape> SavedShapes;
};
//--------------------------------------------------------------------------------------------------------------------------
template<>
struct TStructOpsTypeTraits<FCogReplicatorNetPack> : public TStructOpsTypeTraitsBase2<FCogReplicatorNetPack>
{
enum
{
WithNetDeltaSerializer = true,
};
};
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(NotBlueprintable, NotBlueprintType, notplaceable, noteditinlinenew, hidedropdown, Transient)
class COGDEBUG_API ACogDebugReplicator : public AActor
{
GENERATED_UCLASS_BODY()
public:
static void Create(APlayerController* Controller);
virtual void BeginPlay() override;
virtual void TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction) override;
APlayerController* GetPlayerController() const { return OwnerPlayerController.Get(); }
bool IsLocal() const { return bIsLocal; }
TArray<FCogDebugShape> ReplicatedShapes;
UFUNCTION(Server, Reliable)
void Server_RequestAllCategoriesVerbosity();
UFUNCTION(Server, Reliable)
void Server_SetCategoryVerbosity(FName LogCategoryName, ECogLogVerbosity Verbosity);
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_SendCategoriesVerbosity(const TArray<FCogServerCategoryData>& Categories);
UFUNCTION(Client, Reliable)
void Client_SendCategoriesVerbosity(const TArray<FCogServerCategoryData>& Categories);
protected:
friend FCogReplicatorNetPack;
TObjectPtr<APlayerController> OwnerPlayerController;
uint32 bHasAuthority : 1;
uint32 bIsLocal : 1;
private:
UPROPERTY(Replicated)
FCogReplicatorNetPack ReplicatedData;
};
@@ -0,0 +1,45 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogMacros.h"
struct COGDEBUG_API FCogDebugSettings
{
public:
//----------------------------------------------------------------------------------------------------------------------
static bool IsDebugActiveForActor(const AActor* Actor);
static AActor* GetSelection();
static void SetSelection(AActor* Value);
static bool GetDebugPersistent(bool bPersistent);
static float GetDebugDuration(bool bPersistent);
static float GetDebugTextDuration(bool bPersistent);
static int GetCircleSegments();
static int GetDebugSegments();
static float GetDebugThickness(float Thickness);
static float GetDebugServerThickness(float Thickness);
static uint8 GetDebugDepthPriority(float DepthPriority);
static FColor ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent = true);
static FColor ModulateServerColor(const FColor& Color);
static bool IsSecondarySkeletonBone(FName BoneName);
static void Reset();
//----------------------------------------------------------------------------------------------------------------------
static TWeakObjectPtr<AActor> Selection;
static bool FilterBySelection;
static bool Persistent;
static bool TextShadow;
static bool Fade2D;
static float Duration;
static int DepthPriority;
static int Segments;
static float Thickness;
static float ServerThickness;
static float ServerColorMultiplier;
static float ArrowSize;
static float AxesScale;
static float GradientColorIntensity;
static float GradientColorSpeed;
static float TextSize;
static TArray<FString> SecondaryBoneWildcards;
};
@@ -0,0 +1,80 @@
#pragma once
#include "CoreMinimal.h"
enum class ECogDebugShape : uint8
{
Invalid,
Arrow,
Axes,
Bone,
Box,
Capsule,
Circle,
CircleArc,
Cone,
Cylinder,
FlatCapsule,
Point,
Polygon,
Segment,
SolidBox
};
struct COGDEBUG_API FCogDebugShape
{
ECogDebugShape Type = ECogDebugShape::Invalid;
TArray<FVector> ShapeData;
FColor Color;
bool bPersistent = false;
float Thickness = 0.0f;
uint8 DepthPriority = 0;
FCogDebugShape() {}
bool operator==(const FCogDebugShape& Other) const
{
return (Type == Other.Type)
&& (Color == Other.Color)
&& (ShapeData == Other.ShapeData)
&& (bPersistent == Other.bPersistent)
&& (Thickness == Other.Thickness)
&& (DepthPriority == Other.DepthPriority);
}
static FCogDebugShape MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeSegment(const FVector& StartLocation, const FVector& EndLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeBone(const FVector& BoneLocation, const FVector& ParentLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeArrow(const FVector& StartLocation, const FVector& EndLocation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeAxes(const FVector& Location, const FRotator& Rotation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeSolidBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeCone(const FVector& Location, const FVector& Direction, const float Length, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeCylinder(const FVector& Center, const float Radius, const float HalfHeight, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeCircle(const FVector& Center, const FRotator& Rotation, const float Radius, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeCircleArc(const FVector& Center, const FRotator& Rotation, const float InnerRadius, const float OuterRadius, const float Angle, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority);
static FCogDebugShape MakeCapsule(const FVector& Center, const FQuat& Rotation, const float Radius, const float HalfHeight, 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);
void DrawPoint(UWorld* World);
void DrawSegment(UWorld* World);
void DrawBone(UWorld* World);
void DrawArrow(UWorld* World);
void DrawAxes(UWorld* World);
void DrawBox(UWorld* World);
void DrawSolidBox(UWorld* World);
void DrawCone(UWorld* World);
void DrawCylinder(UWorld* World);
void DrawCicle(UWorld* World);
void DrawCicleArc(UWorld* World);
void DrawCapsule(UWorld* World);
void DrawFlatCapsule(UWorld* World);
void DrawPolygon(UWorld* World);
void Draw(UWorld* World);
};
FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape);