mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 15:48:48 +00:00
CogDebug: Refactor debug settings for easier serialization
CogDebug: Move DebugGizmo to CogDebug
This commit is contained in:
Binary file not shown.
@@ -33,7 +33,7 @@ void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject*
|
|||||||
FCogImguiHelper::ToImU32(Color),
|
FCogImguiHelper::ToImU32(Color),
|
||||||
true,
|
true,
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::Fade2D);
|
FCogDebugSettings::Data.Fade2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -50,7 +50,7 @@ void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject
|
|||||||
FCogImguiHelper::ToImU32(Color),
|
FCogImguiHelper::ToImU32(Color),
|
||||||
FCogDebugSettings::GetDebugThickness(0),
|
FCogDebugSettings::GetDebugThickness(0),
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::Fade2D);
|
FCogDebugSettings::Data.Fade2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -68,7 +68,7 @@ void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject*
|
|||||||
FCogDebugSettings::GetDebugSegments(),
|
FCogDebugSettings::GetDebugSegments(),
|
||||||
FCogDebugSettings::GetDebugThickness(0),
|
FCogDebugSettings::GetDebugThickness(0),
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::Fade2D);
|
FCogDebugSettings::Data.Fade2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -87,7 +87,7 @@ void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* W
|
|||||||
0.0f,
|
0.0f,
|
||||||
FCogDebugSettings::GetDebugThickness(0),
|
FCogDebugSettings::GetDebugThickness(0),
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::Fade2D);
|
FCogDebugSettings::Data.Fade2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -114,8 +114,8 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W
|
|||||||
nullptr,
|
nullptr,
|
||||||
NewColor,
|
NewColor,
|
||||||
FCogDebugSettings::GetDebugTextDuration(Persistent),
|
FCogDebugSettings::GetDebugTextDuration(Persistent),
|
||||||
FCogDebugSettings::TextShadow,
|
FCogDebugSettings::Data.TextShadow,
|
||||||
FCogDebugSettings::TextSize);
|
FCogDebugSettings::Data.TextSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -142,7 +142,7 @@ void FCogDebugDraw::Point(const FLogCategoryBase& LogCategory, const UObject* Wo
|
|||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
FCogDebugSettings::GetDebugDepthPriority(DepthPriority));
|
||||||
|
|
||||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebugSettings::DepthPriority));
|
ReplicateShape(WorldContextObject, FCogDebugShape::MakePoint(Location, Size, NewColor, Persistent, FCogDebugSettings::Data.DepthPriority));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -235,14 +235,14 @@ void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* Wo
|
|||||||
World,
|
World,
|
||||||
SegmentStart,
|
SegmentStart,
|
||||||
SegmentEnd,
|
SegmentEnd,
|
||||||
FCogDebugSettings::ArrowSize,
|
FCogDebugSettings::Data.ArrowSize,
|
||||||
NewColor,
|
NewColor,
|
||||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||||
FCogDebugSettings::GetDebugThickness(0));
|
FCogDebugSettings::GetDebugThickness(0));
|
||||||
|
|
||||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebugSettings::ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
|
ReplicateShape(WorldContextObject, FCogDebugShape::MakeArrow(SegmentStart, SegmentEnd, FCogDebugSettings::Data.ArrowSize, NewColor, 0.0f, Persistent, DepthPriority));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -268,13 +268,13 @@ void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* Wor
|
|||||||
World,
|
World,
|
||||||
AxisLoc,
|
AxisLoc,
|
||||||
AxisRot,
|
AxisRot,
|
||||||
Scale * FCogDebugSettings::AxesScale,
|
Scale * FCogDebugSettings::Data.AxesScale,
|
||||||
FCogDebugSettings::GetDebugPersistent(Persistent),
|
FCogDebugSettings::GetDebugPersistent(Persistent),
|
||||||
FCogDebugSettings::GetDebugDuration(Persistent),
|
FCogDebugSettings::GetDebugDuration(Persistent),
|
||||||
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
FCogDebugSettings::GetDebugDepthPriority(DepthPriority),
|
||||||
FCogDebugSettings::GetDebugThickness(0));
|
FCogDebugSettings::GetDebugThickness(0));
|
||||||
|
|
||||||
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebugSettings::ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
|
ReplicateShape(WorldContextObject, FCogDebugShape::MakeAxes(AxisLoc, AxisRot, FCogDebugSettings::Data.ArrowSize, FColor::Red, 0.0f, Persistent, DepthPriority));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1,285 @@
|
|||||||
|
#include "CogDebugGizmo.h"
|
||||||
|
|
||||||
|
#include "CogDebugDrawHelper.h"
|
||||||
|
#include "CogDebugSettings.h"
|
||||||
|
#include "CogImGuiHelper.h"
|
||||||
|
#include "Components/PrimitiveComponent.h"
|
||||||
|
#include "Components/SceneComponent.h"
|
||||||
|
#include "GameFramework/PlayerController.h"
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
float PointDistanceToQuad(const APlayerController& InPlayerController, const FVector2D& Point, const FVector& QuadPosition, const FQuat& QuadRotation, const FVector2D& QuadExtents)
|
||||||
|
{
|
||||||
|
const FVector U = QuadRotation.GetAxisZ() * QuadExtents.X;
|
||||||
|
const FVector V = QuadRotation.GetAxisY() * QuadExtents.Y;
|
||||||
|
|
||||||
|
const FVector V0 = QuadPosition + U + V;
|
||||||
|
const FVector V1 = QuadPosition + U - V;
|
||||||
|
const FVector V2 = QuadPosition - U - V;
|
||||||
|
const FVector V3 = QuadPosition - U + V;
|
||||||
|
|
||||||
|
FVector2D P0, P1, P2, P3;
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V0, P0);
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V1, P1);
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V2, P2);
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, V3, P3);
|
||||||
|
|
||||||
|
const FVector B0 = FMath::GetBaryCentric2D(Point, P0, P1, P2);
|
||||||
|
const FVector B1 = FMath::GetBaryCentric2D(Point, P0, P2, P3);
|
||||||
|
|
||||||
|
const bool Inside0 = B0.X > 0.0f && B0.Y > 0.0f && B0.Z > 0.0f;
|
||||||
|
const bool Inside1 = B1.X > 0.0f && B1.Y > 0.0f && B1.Z > 0.0f;
|
||||||
|
|
||||||
|
const float D = (Inside0 || Inside1) ? 0.0f : FLT_MAX;
|
||||||
|
return D;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogDebug_Gizmo::Draw(const APlayerController& InPlayerController, FTransform& InOutTransform)
|
||||||
|
{
|
||||||
|
UWorld* World = InPlayerController.GetWorld();
|
||||||
|
|
||||||
|
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||||
|
if (Viewport == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FVector GizmoCenter = InOutTransform.GetTranslation();
|
||||||
|
|
||||||
|
FVector2D Center2D;
|
||||||
|
if (UGameplayStatics::ProjectWorldToScreen(&InPlayerController, GizmoCenter, Center2D) == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FCogDebugData& Debug = FCogDebugSettings::Data;
|
||||||
|
|
||||||
|
FVector CenterProjection, CenterDirection, AxisProjection, AxisDirection;
|
||||||
|
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D, CenterProjection, CenterDirection);
|
||||||
|
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, Center2D + FVector2d(0, 1.0f), AxisProjection, AxisDirection);
|
||||||
|
const FVector CameraLocation = InPlayerController.PlayerCameraManager->GetCameraLocation();
|
||||||
|
const float Sc = FVector::Dist(AxisProjection, CenterProjection) * FVector::Dist(CameraLocation, GizmoCenter) / FVector::Dist(CameraLocation, CenterProjection);
|
||||||
|
const float Scale = Debug.GizmoScale * Sc;
|
||||||
|
|
||||||
|
const FQuat RotX = InOutTransform.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 = GizmoCenter + UnitAxisX * Debug.GizmoAxisLength * Scale;
|
||||||
|
const FVector AxisY = GizmoCenter + UnitAxisY * Debug.GizmoAxisLength * Scale;
|
||||||
|
const FVector AxisZ = GizmoCenter + UnitAxisZ * Debug.GizmoAxisLength * Scale;
|
||||||
|
|
||||||
|
const FVector PlaneXY = GizmoCenter + ((UnitAxisX + UnitAxisY) * Debug.GizmoPlaneOffset * Scale);
|
||||||
|
const FVector PlaneXZ = GizmoCenter + ((UnitAxisX + UnitAxisZ) * Debug.GizmoPlaneOffset * Scale);
|
||||||
|
const FVector PlaneYZ = GizmoCenter + ((UnitAxisY + UnitAxisZ) * Debug.GizmoPlaneOffset * Scale);
|
||||||
|
|
||||||
|
const float AdjustedScaleBoxExtent = Debug.GizmoScaleBoxExtent * Scale;
|
||||||
|
const float AdjustedPlaneExtent = Debug.GizmoPlaneExtent * Scale;
|
||||||
|
const float AdjustedThicknessZLow = Debug.GizmoThicknessZLow * Scale;
|
||||||
|
const float AdjustedThicknessZHigh = Debug.GizmoThicknessZHigh * Scale;
|
||||||
|
|
||||||
|
const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos;
|
||||||
|
const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos);
|
||||||
|
|
||||||
|
const FColor GizmoAxisColorsZLow[] = { Debug.GizmoAxisColorsZLowX, Debug.GizmoAxisColorsZLowY, Debug.GizmoAxisColorsZLowZ, Debug.GizmoAxisColorsZLowW };
|
||||||
|
const FColor GizmoAxisColorsZHigh[] = { Debug.GizmoAxisColorsZHighX, Debug.GizmoAxisColorsZHighY, Debug.GizmoAxisColorsZHighZ, Debug.GizmoAxisColorsZHighW };
|
||||||
|
const FColor GizmoAxisColorsSelection[] = { Debug.GizmoAxisColorsSelectionX, Debug.GizmoAxisColorsSelectionY, Debug.GizmoAxisColorsSelectionZ, Debug.GizmoAxisColorsSelectionW };
|
||||||
|
|
||||||
|
FCogDebug_GizmoElement GizmoElements[ECogDebug_GizmoElementType::MAX];
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveX] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, FQuat::Identity, AxisX };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveY] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, FQuat::Identity, AxisY };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveZ] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, FQuat::Identity, AxisZ };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXY] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, PlaneXY };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveXZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, PlaneXZ };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::MoveYZ] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, PlaneYZ };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateX] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, AxisX };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateY] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::RotateZ] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleXYZ] = { ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleX] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, AxisX };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleY] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, AxisY };
|
||||||
|
GizmoElements[(uint8)ECogDebug_GizmoElementType::ScaleZ] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, AxisZ };
|
||||||
|
|
||||||
|
ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX;
|
||||||
|
if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||||
|
{
|
||||||
|
HoveredElementType = DraggedElementType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float MinDistanceToMouse = FLT_MAX;
|
||||||
|
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||||
|
{
|
||||||
|
FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||||
|
float DistanceToMouse = FLT_MAX;
|
||||||
|
|
||||||
|
switch (Elm.Type)
|
||||||
|
{
|
||||||
|
case ECogDebug_GizmoType::MoveAxis:
|
||||||
|
{
|
||||||
|
FVector2D ElementLocation2D;
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, Elm.Location, ElementLocation2D);
|
||||||
|
const FVector2D ClosestPoint = FMath::ClosestPointOnSegment2D(MousePos, Center2D, ElementLocation2D);
|
||||||
|
DistanceToMouse = (ClosestPoint - MousePos).Length();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::MovePlane:
|
||||||
|
{
|
||||||
|
DistanceToMouse = PointDistanceToQuad(InPlayerController, MousePos, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::ScaleUniform:
|
||||||
|
case ECogDebug_GizmoType::ScaleAxis:
|
||||||
|
{
|
||||||
|
FVector2D ElementLocation2D;
|
||||||
|
UGameplayStatics::ProjectWorldToScreen(&InPlayerController, Elm.Location, ElementLocation2D);
|
||||||
|
DistanceToMouse = FVector2D::Distance(ElementLocation2D, MousePos) - Debug.GizmoScaleBoxExtent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DistanceToMouse < Debug.GizmoMouseMaxDistance && DistanceToMouse < MinDistanceToMouse)
|
||||||
|
{
|
||||||
|
HoveredElementType = (ECogDebug_GizmoElementType)i;
|
||||||
|
MinDistanceToMouse = DistanceToMouse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8 i = (uint8)ECogDebug_GizmoElementType::MoveX; i < (uint8)ECogDebug_GizmoElementType::MAX; ++i)
|
||||||
|
{
|
||||||
|
const FCogDebug_GizmoElement& Elm = GizmoElements[i];
|
||||||
|
const bool IsClosestToMouse = i == (uint8)HoveredElementType;
|
||||||
|
const uint8 AxisIndex = (uint8)Elm.AxisType;
|
||||||
|
const FColor ZLowColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZLow[AxisIndex];
|
||||||
|
const FColor ZHighColor = IsClosestToMouse ? GizmoAxisColorsSelection[AxisIndex] : GizmoAxisColorsZHigh[AxisIndex];
|
||||||
|
|
||||||
|
switch (Elm.Type)
|
||||||
|
{
|
||||||
|
case ECogDebug_GizmoType::MoveAxis:
|
||||||
|
{
|
||||||
|
DrawDebugLine(World, GizmoCenter, Elm.Location, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow);
|
||||||
|
DrawDebugLine(World, GizmoCenter, Elm.Location, ZHighColor, false, 0.0f, Debug.GizmoZHigh, Debug.GizmoThicknessZHigh);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::MovePlane:
|
||||||
|
{
|
||||||
|
FCogDebugDrawHelper::DrawQuad(World, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent), ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow);
|
||||||
|
FCogDebugDrawHelper::DrawQuad(World, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent), ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh);
|
||||||
|
FCogDebugDrawHelper::DrawSolidQuad(World, Elm.Location, Elm.Rotation, FVector2D(AdjustedPlaneExtent, AdjustedPlaneExtent), ZLowColor, false, 0.0f, Debug.GizmoZLow);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::Rotate:
|
||||||
|
{
|
||||||
|
FRotationTranslationMatrix Matrix(FRotator(Elm.Rotation), Elm.Location);
|
||||||
|
DrawDebugCircle(World, Matrix, Debug.GizmoRotationRadius, Debug.GizmoRotationSegments, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow, false);
|
||||||
|
DrawDebugCircle(World, Matrix, Debug.GizmoRotationRadius, Debug.GizmoRotationSegments, ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::ScaleUniform:
|
||||||
|
case ECogDebug_GizmoType::ScaleAxis:
|
||||||
|
{
|
||||||
|
DrawDebugBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Debug.GizmoZLow, AdjustedThicknessZLow);
|
||||||
|
DrawDebugBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZHighColor, false, 0.0f, Debug.GizmoZHigh, AdjustedThicknessZHigh);
|
||||||
|
DrawDebugSolidBox(World, Elm.Location, FVector::OneVector * AdjustedScaleBoxExtent, Elm.Rotation, ZLowColor, false, 0.0f, Debug.GizmoZLow);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||||
|
{
|
||||||
|
DraggedElementType = ECogDebug_GizmoElementType::MAX;
|
||||||
|
}
|
||||||
|
else if (DraggedElementType != ECogDebug_GizmoElementType::MAX)
|
||||||
|
{
|
||||||
|
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 4.0f))
|
||||||
|
{
|
||||||
|
FVector MouseWorldOrigin, MouseWorldDirection;
|
||||||
|
UGameplayStatics::DeprojectScreenToWorld(&InPlayerController, MousePos - CursorOffset, MouseWorldOrigin, MouseWorldDirection);
|
||||||
|
|
||||||
|
FCogDebug_GizmoElement& DraggedElement = GizmoElements[(uint8)DraggedElementType];
|
||||||
|
|
||||||
|
switch (DraggedElement.Type)
|
||||||
|
{
|
||||||
|
case ECogDebug_GizmoType::MoveAxis:
|
||||||
|
{
|
||||||
|
FVector Pa, Pb;
|
||||||
|
FMath::SegmentDistToSegmentSafe(
|
||||||
|
GizmoCenter - DraggedElement.Direction * 10000,
|
||||||
|
GizmoCenter + DraggedElement.Direction * 10000,
|
||||||
|
MouseWorldOrigin - MouseWorldDirection * 10000,
|
||||||
|
MouseWorldOrigin + MouseWorldDirection * 10000,
|
||||||
|
Pa, Pb);
|
||||||
|
InOutTransform.SetLocation(Pa);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::MovePlane:
|
||||||
|
{
|
||||||
|
const FPlane Plane(GizmoCenter, DraggedElement.Direction);
|
||||||
|
const FVector PlaneIntersection = FMath::RayPlaneIntersection(MouseWorldOrigin, MouseWorldDirection, Plane);
|
||||||
|
InOutTransform.SetLocation(PlaneIntersection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::ScaleAxis:
|
||||||
|
{
|
||||||
|
FVector Pa, Pb;
|
||||||
|
FMath::SegmentDistToSegmentSafe(
|
||||||
|
GizmoCenter - DraggedElement.Direction * 10000,
|
||||||
|
GizmoCenter + DraggedElement.Direction * 10000,
|
||||||
|
MouseWorldOrigin - MouseWorldDirection * 10000,
|
||||||
|
MouseWorldOrigin + MouseWorldDirection * 10000,
|
||||||
|
Pa, Pb);
|
||||||
|
|
||||||
|
const float Sign = FMath::Sign(FVector::DotProduct(DraggedElement.Direction, Pa - GizmoCenter));
|
||||||
|
const float Delta = (Pa - GizmoCenter).Length() * Sign;
|
||||||
|
FVector NewScale = InitialScale + (DraggedElement.Axis * Delta * Debug.GizmoScaleSpeed);
|
||||||
|
NewScale.X = FMath::Max(NewScale.X, Debug.GizmoScaleMin);
|
||||||
|
NewScale.Y = FMath::Max(NewScale.Y, Debug.GizmoScaleMin);
|
||||||
|
NewScale.Z = FMath::Max(NewScale.Z, Debug.GizmoScaleMin);
|
||||||
|
InOutTransform.SetScale3D(NewScale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECogDebug_GizmoType::ScaleUniform:
|
||||||
|
{
|
||||||
|
const FVector2D DragDelta = FCogImguiHelper::ToFVector2D(ImGui::GetMouseDragDelta(ImGuiMouseButton_Left));
|
||||||
|
FVector NewScale = InitialScale + (DraggedElement.Axis * (DragDelta.X - DragDelta.Y) * Debug.GizmoScaleSpeed);
|
||||||
|
NewScale.X = FMath::Max(NewScale.X, Debug.GizmoScaleMin);
|
||||||
|
NewScale.Y = FMath::Max(NewScale.Y, Debug.GizmoScaleMin);
|
||||||
|
NewScale.Z = FMath::Max(NewScale.Z, Debug.GizmoScaleMin);
|
||||||
|
InOutTransform.SetScale3D(NewScale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
|
||||||
|
{
|
||||||
|
DraggedElementType = HoveredElementType;
|
||||||
|
|
||||||
|
if (HoveredElementType != ECogDebug_GizmoElementType::MAX)
|
||||||
|
{
|
||||||
|
CursorOffset = MousePos - Center2D;
|
||||||
|
InitialScale = InOutTransform.GetScale3D();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,65 +7,12 @@
|
|||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
|
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
|
||||||
bool FCogDebugSettings::bIsFilteringBySelection = true;
|
FCogDebugData FCogDebugSettings::Data = FCogDebugData();
|
||||||
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()
|
void FCogDebugSettings::Reset()
|
||||||
{
|
{
|
||||||
bIsFilteringBySelection = true;
|
Data = FCogDebugData();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -82,7 +29,7 @@ bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), bIsFilteringBySelection);
|
bool Result = IsDebugActiveForObject_Internal(WorldContextObject, Selection.Get(), Data.bIsFilteringBySelection);
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@@ -160,13 +107,13 @@ void FCogDebugSettings::SetSelection(UWorld* World, AActor* Value)
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
bool FCogDebugSettings::GetIsFilteringBySelection()
|
bool FCogDebugSettings::GetIsFilteringBySelection()
|
||||||
{
|
{
|
||||||
return bIsFilteringBySelection;
|
return Data.bIsFilteringBySelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value)
|
void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value)
|
||||||
{
|
{
|
||||||
bIsFilteringBySelection = Value;
|
Data.bIsFilteringBySelection = Value;
|
||||||
|
|
||||||
if (World != nullptr && World->GetNetMode() == NM_Client)
|
if (World != nullptr && World->GetNetMode() == NM_Client)
|
||||||
{
|
{
|
||||||
@@ -180,13 +127,13 @@ void FCogDebugSettings::SetIsFilteringBySelection(UWorld* World, bool Value)
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
bool FCogDebugSettings::GetDebugPersistent(bool bPersistent)
|
bool FCogDebugSettings::GetDebugPersistent(bool bPersistent)
|
||||||
{
|
{
|
||||||
return Persistent && bPersistent;
|
return Data.Persistent && bPersistent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
float FCogDebugSettings::GetDebugDuration(bool bPersistent)
|
float FCogDebugSettings::GetDebugDuration(bool bPersistent)
|
||||||
{
|
{
|
||||||
return bPersistent == false ? 0.0f : Duration;
|
return bPersistent == false ? 0.0f : Data.Duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -194,7 +141,7 @@ float FCogDebugSettings::GetDebugTextDuration(bool bPersistent)
|
|||||||
{
|
{
|
||||||
if (bPersistent)
|
if (bPersistent)
|
||||||
{
|
{
|
||||||
return Persistent ? 100 : Duration;
|
return Data.Persistent ? 100 : Data.Duration;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -205,31 +152,31 @@ float FCogDebugSettings::GetDebugTextDuration(bool bPersistent)
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
int FCogDebugSettings::GetDebugSegments()
|
int FCogDebugSettings::GetDebugSegments()
|
||||||
{
|
{
|
||||||
return Segments;
|
return Data.Segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
int FCogDebugSettings::GetCircleSegments()
|
int FCogDebugSettings::GetCircleSegments()
|
||||||
{
|
{
|
||||||
return (Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
return (Data.Segments * 2) + 2; // because DrawDebugCircle does Segments = FMath::Max((Segments - 2) / 2, 4) for some reason
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
float FCogDebugSettings::GetDebugThickness(float InThickness)
|
float FCogDebugSettings::GetDebugThickness(float InThickness)
|
||||||
{
|
{
|
||||||
return (Thickness + InThickness);
|
return (Data.Thickness + InThickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
float FCogDebugSettings::GetDebugServerThickness(float InThickness)
|
float FCogDebugSettings::GetDebugServerThickness(float InThickness)
|
||||||
{
|
{
|
||||||
return (ServerThickness + InThickness);
|
return (Data.ServerThickness + InThickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
uint8 FCogDebugSettings::GetDebugDepthPriority(float InDepthPriority)
|
uint8 FCogDebugSettings::GetDebugDepthPriority(float InDepthPriority)
|
||||||
{
|
{
|
||||||
return (DepthPriority + InDepthPriority);
|
return (Data.DepthPriority + InDepthPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -252,8 +199,8 @@ FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor&
|
|||||||
|
|
||||||
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
|
ComplementaryColor = ComplementaryColor.HSVToLinearRGB();
|
||||||
|
|
||||||
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(GradientColorSpeed * Time));
|
const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Data.GradientColorSpeed * Time));
|
||||||
const FLinearColor FBlendColor = BaseColor * (1.0f - FCogDebugSettings::GradientColorIntensity) + GradientColor * GradientColorIntensity;
|
const FLinearColor FBlendColor = BaseColor * (1.0f - Data.GradientColorIntensity) + GradientColor * Data.GradientColorIntensity;
|
||||||
return FBlendColor.ToFColor(true);
|
return FBlendColor.ToFColor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,9 +209,9 @@ FColor FCogDebugSettings::ModulateDebugColor(const UWorld* World, const FColor&
|
|||||||
FColor FCogDebugSettings::ModulateServerColor(const FColor& Color)
|
FColor FCogDebugSettings::ModulateServerColor(const FColor& Color)
|
||||||
{
|
{
|
||||||
FColor ServerColor(
|
FColor ServerColor(
|
||||||
Color.R * ServerColorMultiplier,
|
Color.R * Data.ServerColorMultiplier,
|
||||||
Color.G * ServerColorMultiplier,
|
Color.G * Data.ServerColorMultiplier,
|
||||||
Color.B * ServerColorMultiplier,
|
Color.B * Data.ServerColorMultiplier,
|
||||||
Color.A);
|
Color.A);
|
||||||
|
|
||||||
return ServerColor;
|
return ServerColor;
|
||||||
@@ -275,7 +222,7 @@ bool FCogDebugSettings::IsSecondarySkeletonBone(FName BoneName)
|
|||||||
{
|
{
|
||||||
FString BoneString = BoneName.ToString().ToLower();
|
FString BoneString = BoneName.ToString().ToLower();
|
||||||
|
|
||||||
for (const FString& Wildcard : SecondaryBoneWildcards)
|
for (const FString& Wildcard : Data.SecondaryBoneWildcards)
|
||||||
{
|
{
|
||||||
if (BoneString.MatchesWildcard(Wildcard))
|
if (BoneString.MatchesWildcard(Wildcard))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "CogDebugGizmo.generated.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UENUM()
|
||||||
|
enum class ECogDebug_GizmoType : uint8
|
||||||
|
{
|
||||||
|
MoveAxis,
|
||||||
|
MovePlane,
|
||||||
|
Rotate,
|
||||||
|
ScaleAxis,
|
||||||
|
ScaleUniform,
|
||||||
|
MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UENUM()
|
||||||
|
enum class ECogDebug_GizmoAxis : uint8
|
||||||
|
{
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
Z,
|
||||||
|
MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UENUM()
|
||||||
|
enum class ECogDebug_GizmoElementType : uint8
|
||||||
|
{
|
||||||
|
MoveX,
|
||||||
|
MoveY,
|
||||||
|
MoveZ,
|
||||||
|
MoveXY,
|
||||||
|
MoveXZ,
|
||||||
|
MoveYZ,
|
||||||
|
RotateX,
|
||||||
|
RotateY,
|
||||||
|
RotateZ,
|
||||||
|
ScaleXYZ,
|
||||||
|
ScaleX,
|
||||||
|
ScaleY,
|
||||||
|
ScaleZ,
|
||||||
|
MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
struct FCogDebug_GizmoElement
|
||||||
|
{
|
||||||
|
ECogDebug_GizmoType Type;
|
||||||
|
ECogDebug_GizmoAxis AxisType;
|
||||||
|
FVector Axis;
|
||||||
|
FVector Direction;
|
||||||
|
FQuat Rotation;
|
||||||
|
FVector Location;
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
struct COGDEBUG_API FCogDebug_Gizmo
|
||||||
|
{
|
||||||
|
void Draw(const APlayerController& InPlayerController, FTransform& InOutTransform);
|
||||||
|
|
||||||
|
ECogDebug_GizmoElementType DraggedElementType = ECogDebug_GizmoElementType::MAX;
|
||||||
|
FVector2D CursorOffset = FVector2D::ZeroVector;
|
||||||
|
FVector InitialScale = FVector::OneVector;
|
||||||
|
};
|
||||||
@@ -2,11 +2,167 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "UObject/WeakObjectPtrTemplates.h"
|
#include "UObject/WeakObjectPtrTemplates.h"
|
||||||
|
#include "CogDebugSettings.generated.h"
|
||||||
|
|
||||||
class UObject;
|
class UObject;
|
||||||
class AActor;
|
class AActor;
|
||||||
class UWorld;
|
class UWorld;
|
||||||
|
|
||||||
|
USTRUCT()
|
||||||
|
struct FCogDebugData
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool bIsFilteringBySelection = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool Persistent = false;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool TextShadow = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool Fade2D = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float Duration = 3.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int DepthPriority = 0;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int Segments = 12;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float Thickness = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float ServerThickness = 2.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float ServerColorMultiplier = 0.8f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float ArrowSize = 10.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float AxesScale = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GradientColorIntensity = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GradientColorSpeed = 2.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float TextSize = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoScale = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoAxisLength = 50.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int GizmoZLow = 0;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int GizmoZHigh = 100;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoThicknessZLow = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoThicknessZHigh = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoMouseMaxDistance = 5.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoPlaneOffset = 25.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoPlaneExtent = 5.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoScaleBoxExtent = 2.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoScaleSpeed = 0.5f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoScaleMin = 0.001f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float GizmoRotationRadius = 15.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int GizmoRotationSegments = 32;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZHighX = FColor(255, 50, 50, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZHighY = FColor(50, 255, 50, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZHighZ = FColor(50, 50, 255, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZHighW = FColor(255, 255, 255, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZLowX = FColor(128, 0, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZLowY = FColor(0, 128, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZLowZ = FColor(0, 0, 128, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsZLowW = FColor(128, 128, 128, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsSelectionX = FColor(255, 255, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsSelectionY = FColor(255, 255, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsSelectionZ = FColor(255, 255, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FColor GizmoAxisColorsSelectionW = FColor(255, 255, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
TArray<FString> 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*",
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct COGDEBUG_API FCogDebugSettings
|
struct COGDEBUG_API FCogDebugSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -48,41 +204,11 @@ public:
|
|||||||
|
|
||||||
static void Reset();
|
static void Reset();
|
||||||
|
|
||||||
static bool Persistent;
|
static FCogDebugData Data;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static bool IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection);
|
static bool IsDebugActiveForObject_Internal(const UObject* WorldContextObject, const AActor* InSelection, bool InIsFilteringBySelection);
|
||||||
|
|
||||||
static TWeakObjectPtr<AActor> Selection;
|
static TWeakObjectPtr<AActor> Selection;
|
||||||
|
|
||||||
static bool bIsFilteringBySelection;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,13 +4,9 @@
|
|||||||
#include "CogDebugSettings.h"
|
#include "CogDebugSettings.h"
|
||||||
#include "CogEngineDataAsset.h"
|
#include "CogEngineDataAsset.h"
|
||||||
#include "CogImGuiHelper.h"
|
#include "CogImGuiHelper.h"
|
||||||
#include "CogWindowHelper.h"
|
|
||||||
#include "CogWindowWidgets.h"
|
#include "CogWindowWidgets.h"
|
||||||
#include "Components/BoxComponent.h"
|
|
||||||
#include "Components/CapsuleComponent.h"
|
|
||||||
#include "Components/PrimitiveComponent.h"
|
#include "Components/PrimitiveComponent.h"
|
||||||
#include "Components/SceneComponent.h"
|
#include "Components/SceneComponent.h"
|
||||||
#include "Components/SphereComponent.h"
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
@@ -242,24 +238,24 @@ void FCogEngineWindow_CollisionTester::RenderContent()
|
|||||||
case ECogEngine_CollisionQueryShape::Sphere:
|
case ECogEngine_CollisionQueryShape::Sphere:
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECogEngine_CollisionQueryShape::Box:
|
case ECogEngine_CollisionQueryShape::Box:
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECogEngine_CollisionQueryShape::Capsule:
|
case ECogEngine_CollisionQueryShape::Capsule:
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,9 +339,9 @@ void FCogEngineWindow_CollisionTester::Query()
|
|||||||
{
|
{
|
||||||
switch (Config->Shape)
|
switch (Config->Shape)
|
||||||
{
|
{
|
||||||
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->SphereRadius); break;
|
case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(Config->ShapeExtent.X); break;
|
||||||
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->CapsuleRadius, Config->CapsuleHalfHeight); break;
|
case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(Config->ShapeExtent.X, Config->ShapeExtent.Z); break;
|
||||||
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(Config->BoxExtent); break;
|
case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(Config->ShapeExtent); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,7 +515,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
|||||||
GetWorld(),
|
GetWorld(),
|
||||||
QueryStart,
|
QueryStart,
|
||||||
QueryEnd,
|
QueryEnd,
|
||||||
FCogDebugSettings::ArrowSize,
|
FCogDebugSettings::Data.ArrowSize,
|
||||||
Color,
|
Color,
|
||||||
false,
|
false,
|
||||||
0.0f,
|
0.0f,
|
||||||
@@ -577,7 +573,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
|||||||
GetWorld(),
|
GetWorld(),
|
||||||
Hit.Location,
|
Hit.Location,
|
||||||
Hit.Location + Hit.Normal * 20.0f,
|
Hit.Location + Hit.Normal * 20.0f,
|
||||||
FCogDebugSettings::ArrowSize,
|
FCogDebugSettings::Data.ArrowSize,
|
||||||
FLinearColor(Config->NormalColor).ToFColor(true),
|
FLinearColor(Config->NormalColor).ToFColor(true),
|
||||||
false,
|
false,
|
||||||
0.0f,
|
0.0f,
|
||||||
@@ -591,7 +587,7 @@ void FCogEngineWindow_CollisionTester::Query()
|
|||||||
GetWorld(),
|
GetWorld(),
|
||||||
Hit.ImpactPoint,
|
Hit.ImpactPoint,
|
||||||
Hit.ImpactPoint + Hit.ImpactNormal * 20.0f,
|
Hit.ImpactPoint + Hit.ImpactNormal * 20.0f,
|
||||||
FCogDebugSettings::ArrowSize,
|
FCogDebugSettings::Data.ArrowSize,
|
||||||
FLinearColor(Config->ImpactNormalColor).ToFColor(true),
|
FLinearColor(Config->ImpactNormalColor).ToFColor(true),
|
||||||
false,
|
false,
|
||||||
0.0f,
|
0.0f,
|
||||||
@@ -605,10 +601,20 @@ void FCogEngineWindow_CollisionTester::Query()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FTransform Transform1(QueryRotation, QueryStart, FVector::OneVector);
|
if (const APlayerController* LocalPlayerController = GetLocalPlayerController())
|
||||||
DrawTransformGizmos(GetWorld(), Transform1);
|
{
|
||||||
FTransform Transform2(QueryRotation, QueryEnd, FVector::OneVector);
|
FVector ScaleStart(Config->ShapeExtent);
|
||||||
DrawTransformGizmos(GetWorld(), Transform2);
|
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)
|
if (AlreadyDrawnActors.Contains(Actor) == false)
|
||||||
{
|
{
|
||||||
FColor TextColor = Color.WithAlpha(255);
|
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);
|
AlreadyDrawnActors.Add(Actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -693,7 +699,7 @@ void FCogEngineWindow_CollisionTester::DrawShape(const FCollisionShape& Shape, c
|
|||||||
case ECollisionShape::Sphere:
|
case ECollisionShape::Sphere:
|
||||||
{
|
{
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// see UCapsuleComponent::GetScaledCapsuleRadius()
|
// see USphereComponent::GetScaledSphereRadius()
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
const float RadiusScale = FMath::Min(Scale.X, FMath::Min(Scale.Y, Scale.Z));
|
const float RadiusScale = FMath::Min(Scale.X, FMath::Min(Scale.Y, Scale.Z));
|
||||||
const float Radius = Shape.Sphere.Radius * RadiusScale;
|
const float Radius = Shape.Sphere.Radius * RadiusScale;
|
||||||
@@ -758,198 +764,3 @@ void FCogEngineWindow_CollisionTester::SetAsset(const UCogEngineDataAsset* Value
|
|||||||
Channel.Color = AssetChannel.Color.ToFColor(true);
|
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)
|
if (AlreadyDrawnActors.Contains(Actor) == false)
|
||||||
{
|
{
|
||||||
FColor TextColor = Color.WithAlpha(255);
|
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);
|
AlreadyDrawnActors.Add(Actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,22 +21,8 @@ void FCogEngineWindow_DebugSettings::Initialize()
|
|||||||
|
|
||||||
Config = GetConfig<UCogEngineConfig_DebugSettings>();
|
Config = GetConfig<UCogEngineConfig_DebugSettings>();
|
||||||
|
|
||||||
FCogDebugSettings::Persistent = Config->Persistent;
|
FCogDebugSettings::Data = Config->Data;
|
||||||
FCogDebugSettings::TextShadow = Config->TextShadow;
|
FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -52,20 +38,7 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig()
|
|||||||
{
|
{
|
||||||
Super::PreSaveConfig();
|
Super::PreSaveConfig();
|
||||||
|
|
||||||
Config->Persistent = FCogDebugSettings::Persistent;
|
Config->Data = FCogDebugSettings::Data;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -75,117 +48,195 @@ void FCogEngineWindow_DebugSettings::RenderContent()
|
|||||||
|
|
||||||
if (ImGui::BeginMenuBar())
|
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();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config->bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
Config->Data.bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection();
|
||||||
if (ImGui::Checkbox("Filter by selection", &Config->bIsFilteringBySelection))
|
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))
|
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::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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("Make debug draw always persist");
|
ImGui::SetTooltip("Make debug draw always persist");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Checkbox("Text Shadow", &FCogDebugSettings::TextShadow);
|
ImGui::Checkbox("Text Shadow", &Data.TextShadow);
|
||||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("Show a shadow below debug text.");
|
ImGui::SetTooltip("Show a shadow below debug text.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||||
ImGui::Checkbox("Fade 2D", &FCogDebugSettings::Fade2D);
|
ImGui::Checkbox("Fade 2D", &Data.Fade2D);
|
||||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("Does the 2D debug is fading out.");
|
ImGui::SetTooltip("Does the 2D debug is fading out.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The duration of debug elements.");
|
ImGui::SetTooltip("The duration of debug elements.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The thickness of debug lines.");
|
ImGui::SetTooltip("The thickness of debug lines.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The thickness the server debug lines.");
|
ImGui::SetTooltip("The thickness the server debug lines.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
|
ImGui::SetTooltip("The color multiplier applied to the server debug lines.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||||
ImGui::DragInt("Depth Priority", &FCogDebugSettings::DepthPriority, 0.1f, 0, 100);
|
ImGui::DragInt("Depth Priority", &Data.DepthPriority, 0.1f, 0, 100);
|
||||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The depth priority of debug elements.");
|
ImGui::SetTooltip("The depth priority of debug elements.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The number of segments used for circular shapes.");
|
ImGui::SetTooltip("The number of segments used for circular shapes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||||
ImGui::DragFloat("Axes Scale", &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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The scaling debug axis.");
|
ImGui::SetTooltip("The scaling debug axis.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The size of debug arrows.");
|
ImGui::SetTooltip("The size of debug arrows.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
|
ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The speed of the gradient color change.");
|
ImGui::SetTooltip("The speed of the gradient color change.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
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))
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||||
{
|
{
|
||||||
ImGui::SetTooltip("The size of the debug texts.");
|
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)
|
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)
|
if (ShowAxes || BoneInfo.ShowAxes)
|
||||||
@@ -330,7 +330,7 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
|||||||
World,
|
World,
|
||||||
BoneLocation,
|
BoneLocation,
|
||||||
BoneRotation,
|
BoneRotation,
|
||||||
10.0f * FCogDebugSettings::AxesScale,
|
10.0f * FCogDebugSettings::Data.AxesScale,
|
||||||
false,
|
false,
|
||||||
0.0f,
|
0.0f,
|
||||||
1,
|
1,
|
||||||
@@ -345,7 +345,7 @@ void FCogEngineWindow_Skeleton::DrawSkeleton()
|
|||||||
World,
|
World,
|
||||||
BoneLocation,
|
BoneLocation,
|
||||||
BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(),
|
BoneLocation + ParentBodyInstance->GetUnrealWorldVelocity() * World->GetDeltaSeconds(),
|
||||||
FCogDebugSettings::ArrowSize,
|
FCogDebugSettings::Data.ArrowSize,
|
||||||
FCogDebugSettings::ModulateDebugColor(World, FColor::Cyan),
|
FCogDebugSettings::ModulateDebugColor(World, FColor::Cyan),
|
||||||
FCogDebugSettings::GetDebugPersistent(true),
|
FCogDebugSettings::GetDebugPersistent(true),
|
||||||
FCogDebugSettings::GetDebugDuration(true),
|
FCogDebugSettings::GetDebugDuration(true),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "CogDebugGizmo.h"
|
||||||
#include "CogWindow.h"
|
#include "CogWindow.h"
|
||||||
#include "CogWindowConfig.h"
|
#include "CogWindowConfig.h"
|
||||||
#include "Engine/HitResult.h"
|
#include "Engine/HitResult.h"
|
||||||
@@ -56,57 +57,6 @@ enum class ECogEngine_CollisionQueryShape : uint8
|
|||||||
Capsule,
|
Capsule,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UENUM()
|
|
||||||
enum class ECogEngine_GizmoType : uint8
|
|
||||||
{
|
|
||||||
MoveAxis,
|
|
||||||
MovePlane,
|
|
||||||
Rotate,
|
|
||||||
ScaleAxis,
|
|
||||||
ScaleUniform,
|
|
||||||
MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UENUM()
|
|
||||||
enum class ECogEngine_GizmoAxis : uint8
|
|
||||||
{
|
|
||||||
X,
|
|
||||||
Y,
|
|
||||||
Z,
|
|
||||||
MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UENUM()
|
|
||||||
enum class ECogEngine_GizmoElementType : uint8
|
|
||||||
{
|
|
||||||
MoveX,
|
|
||||||
MoveY,
|
|
||||||
MoveZ,
|
|
||||||
MoveXY,
|
|
||||||
MoveXZ,
|
|
||||||
MoveYZ,
|
|
||||||
RotateX,
|
|
||||||
RotateY,
|
|
||||||
RotateZ,
|
|
||||||
ScaleXYZ,
|
|
||||||
ScaleX,
|
|
||||||
ScaleY,
|
|
||||||
ScaleZ,
|
|
||||||
MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
struct FCogEngine_GizmoElement
|
|
||||||
{
|
|
||||||
ECogEngine_GizmoType Type;
|
|
||||||
ECogEngine_GizmoAxis Axis;
|
|
||||||
FQuat Rotation;
|
|
||||||
FVector Location;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
class COGENGINE_API FCogEngineWindow_CollisionTester : public FCogWindow
|
class COGENGINE_API FCogEngineWindow_CollisionTester : public FCogWindow
|
||||||
{
|
{
|
||||||
@@ -132,7 +82,6 @@ protected:
|
|||||||
|
|
||||||
void DrawShape(const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const FVector& Scale, const FColor& Color, bool DrawSolid) const;
|
void DrawShape(const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const FVector& Scale, const FColor& Color, bool DrawSolid) const;
|
||||||
|
|
||||||
void DrawTransformGizmos(const UWorld* InWorld, FTransform& InTransform);
|
|
||||||
|
|
||||||
struct FChannel
|
struct FChannel
|
||||||
{
|
{
|
||||||
@@ -152,6 +101,9 @@ protected:
|
|||||||
|
|
||||||
bool IsDragging = false;
|
bool IsDragging = false;
|
||||||
|
|
||||||
|
FCogDebug_Gizmo GizmoStart;
|
||||||
|
FCogDebug_Gizmo GizmoEnd;
|
||||||
|
|
||||||
FTransform StartTransform;
|
FTransform StartTransform;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -176,6 +128,9 @@ public:
|
|||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
FRotator3f Rotation;
|
FRotator3f Rotation;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FRotator3f Scale;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
ECogEngine_CollisionQueryType Type;
|
ECogEngine_CollisionQueryType Type;
|
||||||
|
|
||||||
@@ -204,16 +159,7 @@ public:
|
|||||||
int32 ProfileIndex;
|
int32 ProfileIndex;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
float SphereRadius;
|
FVector3f ShapeExtent;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
FVector3f BoxExtent;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float CapsuleRadius;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float CapsuleHalfHeight;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
int QueryTypeOld;
|
int QueryTypeOld;
|
||||||
@@ -272,10 +218,7 @@ public:
|
|||||||
Shape = ECogEngine_CollisionQueryShape::Sphere;
|
Shape = ECogEngine_CollisionQueryShape::Sphere;
|
||||||
MultiHits = false;
|
MultiHits = false;
|
||||||
TraceComplex = false;
|
TraceComplex = false;
|
||||||
SphereRadius = 50.0f;
|
ShapeExtent = FVector3f(50.0f, 50.0f, 50.0f);
|
||||||
BoxExtent = FVector3f(50.0f, 50.0f, 50.0f);
|
|
||||||
CapsuleRadius = 50.0f;
|
|
||||||
CapsuleHalfHeight = 50.0f;
|
|
||||||
|
|
||||||
ObjectTypesToQuery = 0;
|
ObjectTypesToQuery = 0;
|
||||||
ProfileIndex = 0;
|
ProfileIndex = 0;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "CogDebugSettings.h"
|
||||||
#include "CogWindow.h"
|
#include "CogWindow.h"
|
||||||
#include "CogWindowConfig.h"
|
#include "CogWindowConfig.h"
|
||||||
#include "CogEngineWindow_DebugSettings.generated.h"
|
#include "CogEngineWindow_DebugSettings.generated.h"
|
||||||
@@ -27,7 +28,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
TWeakObjectPtr<UCogEngineConfig_DebugSettings> Config = nullptr;
|
TWeakObjectPtr<UCogEngineConfig_DebugSettings> Config = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -39,68 +39,15 @@ class UCogEngineConfig_DebugSettings : public UCogWindowConfig
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
bool bIsFilteringBySelection = true;
|
FCogDebugData Data;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
bool Persistent = false;
|
bool bShowAdvancedSettings = false;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
bool TextShadow = true;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
bool Fade2D = true;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float Duration = 3.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
int DepthPriority = 0;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
int Segments = 12;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float Thickness = 0.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float ServerThickness = 2.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float ServerColorMultiplier = 0.8f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float ArrowSize = 10.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float AxesScale = 1.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float GradientColorIntensity = 0.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float GradientColorSpeed = 2.0f;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
float TextSize = 1.0f;
|
|
||||||
|
|
||||||
virtual void Reset() override
|
virtual void Reset() override
|
||||||
{
|
{
|
||||||
Super::Reset();
|
Super::Reset();
|
||||||
|
Data = FCogDebugData();
|
||||||
bIsFilteringBySelection = true;
|
bShowAdvancedSettings = false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -124,17 +124,17 @@ FReply SCogImguiWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterE
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
||||||
{
|
{
|
||||||
return HandleKeyEvent(MyGeometry, KeyEvent);
|
return HandleKeyEvent(MyGeometry, KeyEvent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
||||||
{
|
{
|
||||||
return HandleKeyEvent(MyGeometry, KeyEvent);
|
return HandleKeyEvent(MyGeometry, KeyEvent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down)
|
||||||
{
|
{
|
||||||
if (Context->GetEnableInput() == false)
|
if (Context->GetEnableInput() == false)
|
||||||
{
|
{
|
||||||
@@ -154,8 +154,9 @@ FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEv
|
|||||||
{
|
{
|
||||||
return FReply::Unhandled();
|
return FReply::Unhandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO& IO = ImGui::GetIO();
|
ImGuiIO& IO = ImGui::GetIO();
|
||||||
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), false);
|
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), Down);
|
||||||
IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown());
|
IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown());
|
||||||
IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown());
|
IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown());
|
||||||
IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown());
|
IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown());
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent);
|
FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down);
|
||||||
|
|
||||||
void RefreshVisibility();
|
void RefreshVisibility();
|
||||||
|
|
||||||
|
|||||||
@@ -612,3 +612,24 @@ bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray<float>& Values, float& Va
|
|||||||
|
|
||||||
return IsPressed;
|
return IsPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool FCogWindowWidgets::DragFVector(const char* Label, FVector& Vector, float Speed, float Min, float Max, const char* Format, ImGuiSliderFlags Flags)
|
||||||
|
{
|
||||||
|
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 3, Speed, &Min, &Max, Format, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool FCogWindowWidgets::DragFVector2D(const char* Label, FVector2D& Vector, float Speed, float Min, float Max, const char* Format, ImGuiSliderFlags Flags)
|
||||||
|
{
|
||||||
|
return ImGui::DragScalarN(Label, ImGuiDataType_Double, &Vector.X, 2, Speed, &Min, &Max, Format, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool FCogWindowWidgets::ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags)
|
||||||
|
{
|
||||||
|
FLinearColor Linear(Color);
|
||||||
|
const bool Result = ImGui::ColorEdit4(Label, &Linear.R, Flags);
|
||||||
|
Color = Linear.ToFColor(true);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
@@ -20,6 +20,12 @@ public:
|
|||||||
|
|
||||||
static void EndTableTooltip();
|
static void EndTableTooltip();
|
||||||
|
|
||||||
|
static bool DragFVector(const char* Label, FVector& Vector, float Speed = 1.0f, float Min = 0.0f, float Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||||
|
|
||||||
|
static bool DragFVector2D(const char* Label, FVector2D& Vector, float Speed = 1.0f, float Min = 0.0f, float Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0);
|
||||||
|
|
||||||
|
static bool ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags = 0);
|
||||||
|
|
||||||
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
|
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
|
||||||
|
|
||||||
static bool ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor);
|
static bool ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor);
|
||||||
|
|||||||
Reference in New Issue
Block a user