mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 07:38:46 +00:00
CogDebug: Refactor debug settings for easier serialization
CogDebug: Move DebugGizmo to CogDebug
This commit is contained in:
@@ -4,13 +4,9 @@
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "imgui.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
@@ -242,24 +238,24 @@ void FCogEngineWindow_CollisionTester::RenderContent()
|
||||
case ECogEngine_CollisionQueryShape::Sphere:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Sphere Radius", &Config->SphereRadius, 0.1f, 0, 100.0f, "%.1f");
|
||||
ImGui::DragFloat("Sphere Radius", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f");
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryShape::Box:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat3("Box Extent", &Config->BoxExtent.X, 0.1f, 0, 100.0f, "%.1f");
|
||||
ImGui::DragFloat3("Box Extent", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f");
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_CollisionQueryShape::Capsule:
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Capsule Radius", &Config->CapsuleRadius, 0.1f, 0, 100.0f, "%.1f");
|
||||
ImGui::DragFloat("Capsule Radius", &Config->ShapeExtent.X, 0.1f, 0, 100.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Capsule Half Height", &Config->CapsuleHalfHeight, 0.1f, 0, 100.0f, "%.1f");
|
||||
ImGui::DragFloat("Capsule Half Height", &Config->ShapeExtent.Z, 0.1f, 0, 100.0f, "%.1f");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -343,9 +339,9 @@ void FCogEngineWindow_CollisionTester::Query()
|
||||
{
|
||||
switch (Config->Shape)
|
||||
{
|
||||
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->SphereRadius); break;
|
||||
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->CapsuleRadius, Config->CapsuleHalfHeight); break;
|
||||
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(Config->BoxExtent); break;
|
||||
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->ShapeExtent.X); break;
|
||||
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->ShapeExtent.X, Config->ShapeExtent.Z); break;
|
||||
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(Config->ShapeExtent); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,7 +515,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
||||
GetWorld(),
|
||||
QueryStart,
|
||||
QueryEnd,
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebugSettings::Data.ArrowSize,
|
||||
Color,
|
||||
false,
|
||||
0.0f,
|
||||
@@ -577,7 +573,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
||||
GetWorld(),
|
||||
Hit.Location,
|
||||
Hit.Location + Hit.Normal * 20.0f,
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebugSettings::Data.ArrowSize,
|
||||
FLinearColor(Config->NormalColor).ToFColor(true),
|
||||
false,
|
||||
0.0f,
|
||||
@@ -591,7 +587,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
||||
GetWorld(),
|
||||
Hit.ImpactPoint,
|
||||
Hit.ImpactPoint + Hit.ImpactNormal * 20.0f,
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebugSettings::Data.ArrowSize,
|
||||
FLinearColor(Config->ImpactNormalColor).ToFColor(true),
|
||||
false,
|
||||
0.0f,
|
||||
@@ -605,10 +601,20 @@ void FCogEngineWindow_CollisionTester::Query()
|
||||
}
|
||||
}
|
||||
|
||||
FTransform Transform1(QueryRotation, QueryStart, FVector::OneVector);
|
||||
DrawTransformGizmos(GetWorld(), Transform1);
|
||||
FTransform Transform2(QueryRotation, QueryEnd, FVector::OneVector);
|
||||
DrawTransformGizmos(GetWorld(), Transform2);
|
||||
if (const APlayerController* LocalPlayerController = GetLocalPlayerController())
|
||||
{
|
||||
FVector ScaleStart(Config->ShapeExtent);
|
||||
FTransform TransformStart(QueryRotation, QueryStart, ScaleStart);
|
||||
GizmoStart.Draw(*LocalPlayerController, TransformStart);
|
||||
Config->LocationStart = FVector3f(TransformStart.GetLocation());
|
||||
Config->ShapeExtent = FVector3f(TransformStart.GetScale3D());
|
||||
|
||||
FVector ScaleEnd(Config->ShapeExtent);
|
||||
FTransform TransformEnd(QueryRotation, QueryEnd, ScaleEnd);
|
||||
GizmoEnd.Draw(*LocalPlayerController, TransformEnd);
|
||||
Config->LocationEnd = FVector3f(TransformEnd.GetLocation());
|
||||
Config->ShapeExtent = FVector3f(TransformEnd.GetScale3D());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -638,7 +644,7 @@ void FCogEngineWindow_CollisionTester::DrawPrimitive(const UPrimitiveComponent*
|
||||
if (AlreadyDrawnActors.Contains(Actor) == false)
|
||||
{
|
||||
FColor TextColor = Color.WithAlpha(255);
|
||||
DrawDebugString(GetWorld(), Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::TextShadow, FCogDebugSettings::TextSize);
|
||||
DrawDebugString(GetWorld(), Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::Data.TextShadow, FCogDebugSettings::Data.TextSize);
|
||||
AlreadyDrawnActors.Add(Actor);
|
||||
}
|
||||
}
|
||||
@@ -693,7 +699,7 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
|
||||
case ECollisionShape::Sphere:
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// see UCapsuleComponent::GetScaledCapsuleRadius()
|
||||
// see USphereComponent::GetScaledSphereRadius()
|
||||
//--------------------------------------------------
|
||||
const float RadiusScale = FMath::Min(Scale.X, FMath::Min(Scale.Y, Scale.Z));
|
||||
const float Radius = Shape.Sphere.Radius * RadiusScale;
|
||||
@@ -758,198 +764,3 @@ void FCogEngineWindow_CollisionTester::SetAsset(const UCogEngineDataAsset* Value
|
||||
Channel.Color = AssetChannel.Color.ToFColor(true);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
static void FindSegmentPointDistance(const FVector2D& Segment1, const FVector2D& Segment2, const FVector2D& Point, FVector2D& Projection, float& Time, float& Distance)
|
||||
{
|
||||
const float DistSquared = FVector2D::DistSquared(Segment1, Segment2);
|
||||
if (FMath::IsNearlyZero(DistSquared))
|
||||
{
|
||||
Time = 0.0f;
|
||||
Projection = Segment1;
|
||||
Distance = FVector2D::Distance(Point, Segment1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Time = FMath::Max(0.0f, FMath::Min(1.0f, FVector2D::DotProduct(Point - Segment1, Segment2 - Segment1) / DistSquared));
|
||||
Projection = Segment1 + Time * (Segment2 - Segment1);
|
||||
Distance = FVector2D::Distance(Point, Projection);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
static float FindSegmentPointDistance2(const FVector2D& Segment1, const FVector2D& Segment2, const FVector2D& Point)
|
||||
{
|
||||
FVector2D Projection;
|
||||
float Time, Distance;
|
||||
FindSegmentPointDistance(Segment1, Segment2, Point, Projection, Time, Distance);
|
||||
return Distance;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_CollisionTester::DrawTransformGizmos(const UWorld* InWorld, FTransform& InTransform)
|
||||
{
|
||||
APlayerController* PlayerController = GetLocalPlayerController();
|
||||
if (PlayerController == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||
if (Viewport == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8 ZLow = 0;
|
||||
const uint8 ZHigh = 100;
|
||||
const float ThicknessZLow = 1.0f;
|
||||
const float ThicknessZHigh = 0.0f;
|
||||
const float AxisLength = 50.0f;
|
||||
const float PlaneOffset = 25.0f;
|
||||
const FVector2D PlaneExtent(10.0f, 10.0f);
|
||||
const FVector BoxExtent(2.0f, 2.0f, 2.0f);
|
||||
const float MaxMouseDistance = 5.0f;
|
||||
const float RotationRadius = 15.0f;
|
||||
const int32 RotationSegments = 32;
|
||||
|
||||
const FColor AxisColorsZHigh [] = { FColor(255, 50, 50, 255), FColor(50, 255, 50, 255), FColor(50, 50, 255, 255), FColor(255, 255, 255, 255) };
|
||||
const FColor AxisColorsZLow [] = { FColor(128, 0, 0, 255), FColor(0, 128, 0, 255), FColor(0, 0, 128, 255), FColor(128, 128, 128, 255) };
|
||||
|
||||
const FColor SelectionColor = FColor(255, 255, 0, 255);
|
||||
|
||||
const FVector Center = InTransform.GetTranslation();
|
||||
const FQuat RotX = InTransform.GetRotation();
|
||||
const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f, 1.0f), UE_HALF_PI);
|
||||
const FQuat RotZ = RotX * FQuat(FVector(0.0f, 1.0f, 0.0f), UE_HALF_PI);
|
||||
|
||||
const FVector UnitAxisX = RotX.GetAxisX();
|
||||
const FVector UnitAxisY = RotX.GetAxisY();
|
||||
const FVector UnitAxisZ = RotX.GetAxisZ();
|
||||
|
||||
const FVector AxisX = Center + UnitAxisX * AxisLength;
|
||||
const FVector AxisY = Center + UnitAxisY * AxisLength;
|
||||
const FVector AxisZ = Center + UnitAxisZ * AxisLength;
|
||||
|
||||
const FVector PlaneXY = Center + ((UnitAxisX + UnitAxisY) * PlaneOffset);
|
||||
const FVector PlaneXZ = Center + ((UnitAxisX + UnitAxisZ) * PlaneOffset);
|
||||
const FVector PlaneYZ = Center + ((UnitAxisY + UnitAxisZ) * PlaneOffset);
|
||||
|
||||
const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos;
|
||||
const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos);
|
||||
|
||||
FVector2D ScreenGizmoCenter;
|
||||
if (UGameplayStatics::ProjectWorldToScreen(PlayerController, Center, ScreenGizmoCenter) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FCogEngine_GizmoElement GizmoElements[ECogEngine_GizmoElementType::MAX];
|
||||
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveX] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MoveAxis, ECogEngine_GizmoAxis::X, FQuat::Identity, AxisX };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveY] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MoveAxis, ECogEngine_GizmoAxis::Y, FQuat::Identity, AxisY };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MoveAxis, ECogEngine_GizmoAxis::Z, FQuat::Identity, AxisZ };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveXY] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MovePlane, ECogEngine_GizmoAxis::Z, RotZ, PlaneXY };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveXZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MovePlane, ECogEngine_GizmoAxis::Y, RotY, PlaneXZ };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::MoveYZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::MovePlane, ECogEngine_GizmoAxis::X, RotX, PlaneYZ };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::RotateX] = FCogEngine_GizmoElement { ECogEngine_GizmoType::Rotate, ECogEngine_GizmoAxis::X, RotX, AxisX };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::RotateY] = FCogEngine_GizmoElement { ECogEngine_GizmoType::Rotate, ECogEngine_GizmoAxis::Y, RotY, AxisY };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::RotateZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::Rotate, ECogEngine_GizmoAxis::Z, RotZ, AxisZ };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::ScaleXYZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::ScaleUniform, ECogEngine_GizmoAxis::MAX, RotX, Center };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::ScaleX] = FCogEngine_GizmoElement { ECogEngine_GizmoType::ScaleAxis, ECogEngine_GizmoAxis::X, RotX, AxisX };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::ScaleY] = FCogEngine_GizmoElement { ECogEngine_GizmoType::ScaleAxis, ECogEngine_GizmoAxis::Y, RotY, AxisY };
|
||||
GizmoElements[(int32)ECogEngine_GizmoElementType::ScaleZ] = FCogEngine_GizmoElement { ECogEngine_GizmoType::ScaleAxis, ECogEngine_GizmoAxis::Z, RotZ, AxisZ };
|
||||
|
||||
float MinDistanceToMouse = FLT_MAX;
|
||||
ECogEngine_GizmoElementType ClosestGizmoElementType = ECogEngine_GizmoElementType::MAX;
|
||||
for (uint8 i = (uint8)ECogEngine_GizmoElementType::MoveX; i < (uint8)ECogEngine_GizmoElementType::MAX; ++i)
|
||||
{
|
||||
FCogEngine_GizmoElement& Elm = GizmoElements[i];
|
||||
float DistanceToMouse = FLT_MAX;
|
||||
|
||||
switch (Elm.Type)
|
||||
{
|
||||
case ECogEngine_GizmoType::MoveAxis:
|
||||
{
|
||||
FVector2D ScreenElementLocation;
|
||||
UGameplayStatics::ProjectWorldToScreen(PlayerController, Elm.Location, ScreenElementLocation);
|
||||
DistanceToMouse = FindSegmentPointDistance2(ScreenGizmoCenter, ScreenElementLocation, MousePos);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_GizmoType::MovePlane:
|
||||
{
|
||||
//DistanceToMouse =
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (DistanceToMouse < MaxMouseDistance && DistanceToMouse < MinDistanceToMouse)
|
||||
{
|
||||
ClosestGizmoElementType = (ECogEngine_GizmoElementType)i;
|
||||
MinDistanceToMouse = DistanceToMouse;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8 i = (uint8)ECogEngine_GizmoElementType::MoveX; i < (uint8)ECogEngine_GizmoElementType::MAX; ++i)
|
||||
{
|
||||
const FCogEngine_GizmoElement& Elm = GizmoElements[i];
|
||||
const bool IsClosestToMouse = i == (uint8)ClosestGizmoElementType;
|
||||
|
||||
switch (Elm.Type)
|
||||
{
|
||||
case ECogEngine_GizmoType::MoveAxis:
|
||||
{
|
||||
DrawDebugLine(InWorld, Center, Elm.Location, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZLow, ThicknessZLow);
|
||||
DrawDebugLine(InWorld, Center, Elm.Location, IsClosestToMouse ? SelectionColor : AxisColorsZHigh[(uint8)Elm.Axis], false, 0.0f, ZHigh, ThicknessZHigh);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_GizmoType::MovePlane:
|
||||
{
|
||||
FCogDebugDrawHelper::DrawQuad(InWorld, Elm.Location, Elm.Rotation, PlaneExtent, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZLow, ThicknessZLow);
|
||||
FCogDebugDrawHelper::DrawQuad(InWorld, Elm.Location, Elm.Rotation, PlaneExtent, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZHigh, ThicknessZHigh);
|
||||
FCogDebugDrawHelper::DrawSolidQuad(InWorld, Elm.Location, Elm.Rotation, PlaneExtent, IsClosestToMouse ? SelectionColor : AxisColorsZHigh[(uint8)Elm.Axis], false, 0.0f, ZHigh);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_GizmoType::Rotate:
|
||||
{
|
||||
//FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), Elm.Location);
|
||||
//DrawDebugCircle(InWorld, Matrix, RotationRadius, RotationSegments, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZLow, ThicknessZLow, false);
|
||||
//DrawDebugCircle(InWorld, Matrix, RotationRadius, RotationSegments, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZHigh, ThicknessZHigh, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECogEngine_GizmoType::ScaleUniform:
|
||||
case ECogEngine_GizmoType::ScaleAxis:
|
||||
{
|
||||
DrawDebugBox(InWorld, Elm.Location, BoxExtent, Elm.Rotation, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZLow, ThicknessZLow);
|
||||
DrawDebugBox(InWorld, Elm.Location, BoxExtent, Elm.Rotation, IsClosestToMouse ? SelectionColor : AxisColorsZHigh[(uint8)Elm.Axis], false, 0.0f, ZHigh, ThicknessZHigh);
|
||||
DrawDebugSolidBox(InWorld, Elm.Location, BoxExtent, Elm.Rotation, IsClosestToMouse ? SelectionColor : AxisColorsZLow[(uint8)Elm.Axis], false, 0.0f, ZHigh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
|
||||
{
|
||||
IsDragging = ClosestGizmoElementType != ECogEngine_GizmoElementType::MAX;
|
||||
StartTransform = InTransform;
|
||||
}
|
||||
else if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
IsDragging = false;
|
||||
}
|
||||
|
||||
if (IsDragging)
|
||||
{
|
||||
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 4.0f))
|
||||
{
|
||||
ImVec2 Delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left);
|
||||
FVector WorldOrigin, WorldDirection;
|
||||
UGameplayStatics::DeprojectScreenToWorld(PlayerController, MousePos, WorldOrigin, WorldDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent()
|
||||
if (AlreadyDrawnActors.Contains(Actor) == false)
|
||||
{
|
||||
FColor TextColor = Color.WithAlpha(255);
|
||||
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::TextShadow, FCogDebugSettings::TextSize);
|
||||
DrawDebugString(World, Actor->GetActorLocation(), GetNameSafe(Actor->GetClass()), nullptr, FColor::White, 0.0f, FCogDebugSettings::Data.TextShadow, FCogDebugSettings::Data.TextSize);
|
||||
AlreadyDrawnActors.Add(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,22 +21,8 @@ void FCogEngineWindow_DebugSettings::Initialize()
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_DebugSettings>();
|
||||
|
||||
FCogDebugSettings::Persistent = Config->Persistent;
|
||||
FCogDebugSettings::TextShadow = Config->TextShadow;
|
||||
FCogDebugSettings::Fade2D = Config->Fade2D;
|
||||
FCogDebugSettings::Duration = Config->Duration;
|
||||
FCogDebugSettings::DepthPriority = Config->DepthPriority;
|
||||
FCogDebugSettings::Segments = Config->Segments;
|
||||
FCogDebugSettings::Thickness = Config->Thickness;
|
||||
FCogDebugSettings::ServerThickness = Config->ServerThickness;
|
||||
FCogDebugSettings::ServerColorMultiplier = Config->ServerColorMultiplier;
|
||||
FCogDebugSettings::ArrowSize = Config->ArrowSize;
|
||||
FCogDebugSettings::AxesScale = Config->AxesScale;
|
||||
FCogDebugSettings::GradientColorIntensity = Config->GradientColorIntensity;
|
||||
FCogDebugSettings::GradientColorSpeed = Config->GradientColorSpeed;
|
||||
FCogDebugSettings::TextSize = Config->TextSize;
|
||||
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection);
|
||||
FCogDebugSettings::Data = Config->Data;
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -52,20 +38,7 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig()
|
||||
{
|
||||
Super::PreSaveConfig();
|
||||
|
||||
Config->Persistent = FCogDebugSettings::Persistent;
|
||||
Config->TextShadow = FCogDebugSettings::TextShadow;
|
||||
Config->Fade2D = FCogDebugSettings::Fade2D;
|
||||
Config->Duration = FCogDebugSettings::Duration;
|
||||
Config->DepthPriority = FCogDebugSettings::DepthPriority;
|
||||
Config->Segments = FCogDebugSettings::Segments;
|
||||
Config->Thickness = FCogDebugSettings::Thickness;
|
||||
Config->ServerThickness = FCogDebugSettings::ServerThickness;
|
||||
Config->ServerColorMultiplier = FCogDebugSettings::ServerColorMultiplier;
|
||||
Config->ArrowSize = FCogDebugSettings::ArrowSize;
|
||||
Config->AxesScale = FCogDebugSettings::AxesScale;
|
||||
Config->GradientColorIntensity = FCogDebugSettings::GradientColorIntensity;
|
||||
Config->GradientColorSpeed = FCogDebugSettings::GradientColorSpeed;
|
||||
Config->TextSize = FCogDebugSettings::TextSize;
|
||||
Config->Data = FCogDebugSettings::Data;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -75,117 +48,195 @@ void FCogEngineWindow_DebugSettings::RenderContent()
|
||||
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
FCogDebugSettings::Reset();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
{
|
||||
FCogDebugSettings::Reset();
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Show Advanced Settings", &Config->bShowAdvancedSettings);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
Config->bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
||||
if (ImGui::Checkbox("Filter by selection", &Config->bIsFilteringBySelection))
|
||||
Config->Data.bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
||||
if (ImGui::Checkbox("Filter by selection", &Config->Data.bIsFilteringBySelection))
|
||||
{
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection);
|
||||
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("If checked, only show the debug of the currently selected actor. Otherwise show the debug of all actors.");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Persistent", &FCogDebugSettings::Persistent);
|
||||
FCogDebugData& Data = FCogDebugSettings::Data;
|
||||
|
||||
ImGui::Checkbox("Persistent", &Data.Persistent);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Make debug draw always persist");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Text Shadow", &FCogDebugSettings::TextShadow);
|
||||
ImGui::Checkbox("Text Shadow", &Data.TextShadow);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Show a shadow below debug text.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Fade 2D", &FCogDebugSettings::Fade2D);
|
||||
ImGui::Checkbox("Fade 2D", &Data.Fade2D);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("Does the 2D debug is fading out.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Duration", &FCogDebugSettings::Duration, 0.01f, 0.0f, 100.0f, "%.1f");
|
||||
ImGui::DragFloat("Duration", &Data.Duration, 0.01f, 0.0f, 100.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The duration of debug elements.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Thickness", &FCogDebugSettings::Thickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
ImGui::DragFloat("Thickness", &Data.Thickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness of debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Thickness", &FCogDebugSettings::ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
ImGui::DragFloat("Server Thickness", &Data.ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The thickness the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Server Color Mult", &FCogDebugSettings::ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f");
|
||||
ImGui::DragFloat("Server Color Mult", &Data.ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Depth Priority", &FCogDebugSettings::DepthPriority, 0.1f, 0, 100);
|
||||
ImGui::DragInt("Depth Priority", &Data.DepthPriority, 0.1f, 0, 100);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The depth priority of debug elements.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Segments", &FCogDebugSettings::Segments, 0.1f, 4, 20.0f);
|
||||
ImGui::DragInt("Segments", &Data.Segments, 0.1f, 4, 20.0f);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The number of segments used for circular shapes.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Axes Scale", &FCogDebugSettings::AxesScale, 0.1f, 0, 10.0f, "%.1f");
|
||||
ImGui::DragFloat("Axes Scale", &Data.AxesScale, 0.1f, 0, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The scaling debug axis.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Arrow Size", &FCogDebugSettings::ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f");
|
||||
ImGui::DragFloat("Arrow Size", &Data.ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of debug arrows.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Intensity", &FCogDebugSettings::GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::DragFloat("Gradient Intensity", &Data.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gradient Speed", &FCogDebugSettings::GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
ImGui::DragFloat("Gradient Speed", &Data.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The speed of the gradient color change.");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Text Size", &FCogDebugSettings::TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
|
||||
ImGui::DragFloat("Text Size", &Data.TextSize, 0.1f, 0.1f, 5.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The size of the debug texts.");
|
||||
}
|
||||
|
||||
if (Config->bShowAdvancedSettings)
|
||||
{
|
||||
ImGui::SeparatorText("Gizmo");
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Scale", &Data.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f");
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
ImGui::SetTooltip("The scale of the gizmo.");
|
||||
}
|
||||
|
||||
if (Config->bShowAdvancedSettings)
|
||||
{
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Axis Length", &Data.GizmoAxisLength, 0.1f, 0.1f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Gizmo Z Low", &Data.GizmoZLow, 0.5f, 0, 1000);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Gizmo Z High", &Data.GizmoZHigh, 0.5f, 0, 1000);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Thickness Z Low", &Data.GizmoThicknessZLow, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Thickness Z High", &Data.GizmoThicknessZHigh, 0.1f, 0.0f, 10.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Mouse Max Distance", &Data.GizmoMouseMaxDistance, 0.1f, 0.0f, 50.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Plane Offset", &Data.GizmoPlaneOffset, 0.1f, 0.0f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Plane Extent", &Data.GizmoPlaneExtent, 0.1f, 0.0f, 100.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Scale Box Extent", &Data.GizmoScaleBoxExtent, 0.1f, 0.0f, 100.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Scale Speed", &Data.GizmoScaleSpeed, 0.1f, 0.0f, 100.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Scale Min", &Data.GizmoScaleMin, 0.001f, 0.001f, 1.0f, "%.3f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragFloat("Gizmo Rotation Radius", &Data.GizmoRotationRadius, 0.1f, 0.1f, 500.0f, "%.1f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::DragInt("Gizmo Rotation Segments", &Data.GizmoRotationSegments, 1.0f, 0, 64);
|
||||
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow X", Data.GizmoAxisColorsZLowX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow Y", Data.GizmoAxisColorsZLowY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow Z", Data.GizmoAxisColorsZLowZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZLow W", Data.GizmoAxisColorsZLowW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh X", Data.GizmoAxisColorsZHighX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh Y", Data.GizmoAxisColorsZHighY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh Z", Data.GizmoAxisColorsZHighZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors ZHigh W", Data.GizmoAxisColorsZHighW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection X", Data.GizmoAxisColorsSelectionX, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection Y", Data.GizmoAxisColorsSelectionY, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection Z", Data.GizmoAxisColorsSelectionZ, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::ColorEdit4("Gizmo Axis Colors Selection W", Data.GizmoAxisColorsSelectionW, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
|
||||
if (ShowNames || BoneInfo.ShowName || IsHovered)
|
||||
{
|
||||
::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebugSettings::TextSize);
|
||||
::DrawDebugString(World, BoneLocation, BoneInfo.Name.ToString(), nullptr, IsHovered ? FColor::Red : FColor::White, 0.0f, true, FCogDebugSettings::Data.TextSize);
|
||||
}
|
||||
|
||||
if (ShowAxes || BoneInfo.ShowAxes)
|
||||
@@ -330,7 +330,7 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
World,
|
||||
BoneLocation,
|
||||
BoneRotation,
|
||||
10.0f * FCogDebugSettings::AxesScale,
|
||||
10.0f * FCogDebugSettings::Data.AxesScale,
|
||||
false,
|
||||
0.0f,
|
||||
1,
|
||||
@@ -345,7 +345,7 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
||||
World,
|
||||
BoneLocation,
|
||||
BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(),
|
||||
FCogDebugSettings::ArrowSize,
|
||||
FCogDebugSettings::Data.ArrowSize,
|
||||
FCogDebugSettings::ModulateDebugColor(World, FColor::Cyan),
|
||||
FCogDebugSettings::GetDebugPersistent(true),
|
||||
FCogDebugSettings::GetDebugDuration(true),
|
||||
|
||||
Reference in New Issue
Block a user