From bebc05d4fa6796d93aa1bf5acf1274a17b05ac74 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Sun, 23 Mar 2025 01:12:53 -0400 Subject: [PATCH] Improve Collision Tester Properly filter trace and objects type --- Plugins/Cog/Source/Cog/Private/CogHelper.cpp | 10 +- Plugins/Cog/Source/Cog/Private/CogWidgets.cpp | 93 ++-- Plugins/Cog/Source/Cog/Public/CogHelper.h | 3 + Plugins/Cog/Source/Cog/Public/CogWidgets.h | 12 +- .../Cog/Source/CogDebug/Private/CogDebug.cpp | 6 - .../Source/CogDebug/Private/CogDebugDraw.cpp | 4 +- .../CogDebug/Private/CogDebugDrawHelper.cpp | 5 +- .../Source/CogDebug/Private/CogDebugGizmo.cpp | 230 ++++---- .../Cog/Source/CogDebug/Public/CogDebugDraw.h | 2 +- .../CogDebug/Public/CogDebugDrawHelper.h | 2 +- .../Source/CogDebug/Public/CogDebugSettings.h | 57 +- .../Private/CogEngineCollisionTester.cpp | 489 ++++++++++-------- .../CogEngineWindow_CollisionTester.cpp | 27 +- .../CogEngineWindow_CollisionViewer.cpp | 2 +- .../Private/CogEngineWindow_DebugSettings.cpp | 17 +- .../Public/CogEngineCollisionTester.h | 19 +- .../Public/CogEngineWindow_CollisionTester.h | 4 +- 17 files changed, 563 insertions(+), 419 deletions(-) diff --git a/Plugins/Cog/Source/Cog/Private/CogHelper.cpp b/Plugins/Cog/Source/Cog/Private/CogHelper.cpp index 9019cd4..0c1e722 100644 --- a/Plugins/Cog/Source/Cog/Private/CogHelper.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogHelper.cpp @@ -89,4 +89,12 @@ bool FCogHelper::ComputeBoundingBoxScreenPosition(const APlayerController* Playe Max.Y = FMath::Min(DisplaySize.y * 2, Max.Y); return true; -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogHelper::IsTraceChannelHidden(const UCollisionProfile& InCollisionProfile, const ECollisionChannel InCollisionChannel) +{ + + + return false; +} diff --git a/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp b/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp index 58431b5..71c5a4e 100644 --- a/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp @@ -823,36 +823,32 @@ bool FCogWidgets::MultiChoiceButtonsFloat(TArray& InValues, float& InValu } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Channel) +bool FCogWidgets::ComboTraceChannel(const char* Label, ECollisionChannel& Channel) { FColor ChannelColors[ECC_MAX]; FCogDebug::GetDebugChannelColors(ChannelColors); - FName SelectedChannelName; const UCollisionProfile* CollisionProfile = UCollisionProfile::Get(); - if (CollisionProfile != nullptr) - { - SelectedChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(Channel); - } + if (CollisionProfile == nullptr) + { return false; } + const FName SelectedChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(Channel); + bool Result = false; if (ImGui::BeginCombo(Label, TCHAR_TO_ANSI(*SelectedChannelName.ToString()), ImGuiComboFlags_HeightLarge)) { for (int32 ChannelIndex = 0; ChannelIndex < static_cast(ECC_OverlapAll_Deprecated); ++ChannelIndex) { - FColor Color = ChannelColors[ChannelIndex]; - if (Color == FColor::Transparent) - { - continue; - } - + if (CollisionProfile->ConvertToTraceType(static_cast(ChannelIndex)) == TraceTypeQuery_MAX) + { continue; } + ImGui::PushID(ChannelIndex); - const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex); - + FColor Color = ChannelColors[ChannelIndex]; FCogImguiHelper::ColorEdit4("Color", Color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); ImGui::SameLine(); + const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex); if (ChannelName.IsValid()) { if (ImGui::Selectable(TCHAR_TO_ANSI(*ChannelName.ToString()))) @@ -871,26 +867,26 @@ bool FCogWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Ch } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWidgets::CollisionProfileChannel(const UCollisionProfile& CollisionProfile, const int32 ChannelIndex, FColor& ChannelColor, int32& Channels) +bool FCogWidgets::CollisionProfileChannel(const UCollisionProfile& InCollisionProfile, const int32 InChannelIndex, FColor& InChannelColor, int32& InChannels) { bool Result = false; - FCogImguiHelper::ColorEdit4("Color", ChannelColor, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); + FCogImguiHelper::ColorEdit4("Color", InChannelColor, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); ImGui::SameLine(); - bool IsCollisionActive = (Channels & ECC_TO_BITFIELD(ChannelIndex)) > 0; - const FName ChannelName = CollisionProfile.ReturnChannelNameFromContainerIndex(ChannelIndex); + bool IsCollisionActive = (InChannels & ECC_TO_BITFIELD(InChannelIndex)) > 0; + const FName ChannelName = InCollisionProfile.ReturnChannelNameFromContainerIndex(InChannelIndex); if (ImGui::Checkbox(TCHAR_TO_ANSI(*ChannelName.ToString()), &IsCollisionActive)) { Result = true; if (IsCollisionActive) { - Channels |= ECC_TO_BITFIELD(ChannelIndex); + InChannels |= ECC_TO_BITFIELD(InChannelIndex); } else { - Channels &= ~ECC_TO_BITFIELD(ChannelIndex); + InChannels &= ~ECC_TO_BITFIELD(InChannelIndex); } } @@ -898,14 +894,23 @@ bool FCogWidgets::CollisionProfileChannel(const UCollisionProfile& CollisionProf } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWidgets::CollisionProfileChannels(int32& Channels) +bool FCogWidgets::CollisionProfileChannels(int32& OutChannels) +{ + bool Result = false; + ImGui::SeparatorText("Trace Type"); + Result |= CollisionTraceChannels(OutChannels); + ImGui::SeparatorText("Object Type"); + Result |= CollisionObjectTypeChannels(OutChannels); + return Result; +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogWidgets::CollisionTraceChannels(int32& OutChannels) { const UCollisionProfile* CollisionProfile = UCollisionProfile::Get(); if (CollisionProfile == nullptr) - { - return false; - } - + { return false; } + FColor ChannelColors[ECC_MAX]; FCogDebug::GetDebugChannelColors(ChannelColors); @@ -913,14 +918,38 @@ bool FCogWidgets::CollisionProfileChannels(int32& Channels) for (int32 ChannelIndex = 0; ChannelIndex < static_cast(ECC_OverlapAll_Deprecated); ++ChannelIndex) { - FColor Color = ChannelColors[ChannelIndex]; - if (Color == FColor::Transparent) - { - continue; - } - + if (CollisionProfile->ConvertToTraceType(static_cast(ChannelIndex)) == TraceTypeQuery_MAX) + { continue; } + ImGui::PushID(ChannelIndex); - Result |= CollisionProfileChannel(*CollisionProfile, ChannelIndex, Color, Channels); + FColor Color = ChannelColors[ChannelIndex]; + Result |= CollisionProfileChannel(*CollisionProfile, ChannelIndex, Color, OutChannels); + ImGui::PopID(); + } + + return Result; +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogWidgets::CollisionObjectTypeChannels(int32& OutChannels) +{ + const UCollisionProfile* CollisionProfile = UCollisionProfile::Get(); + if (CollisionProfile == nullptr) + { return false; } + + FColor ChannelColors[ECC_MAX]; + FCogDebug::GetDebugChannelColors(ChannelColors); + + bool Result = false; + + for (int32 ChannelIndex = 0; ChannelIndex < static_cast(ECC_OverlapAll_Deprecated); ++ChannelIndex) + { + if (CollisionProfile->ConvertToObjectType(static_cast(ChannelIndex)) == TraceTypeQuery_MAX) + { continue; } + + ImGui::PushID(ChannelIndex); + FColor Color = ChannelColors[ChannelIndex]; + Result |= CollisionProfileChannel(*CollisionProfile, ChannelIndex, Color, OutChannels); ImGui::PopID(); } diff --git a/Plugins/Cog/Source/Cog/Public/CogHelper.h b/Plugins/Cog/Source/Cog/Public/CogHelper.h index d53371d..4e9a5b2 100644 --- a/Plugins/Cog/Source/Cog/Public/CogHelper.h +++ b/Plugins/Cog/Source/Cog/Public/CogHelper.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "Templates/SubclassOf.h" +class UCollisionProfile; class COG_API FCogHelper { @@ -22,6 +23,8 @@ public: template static FProperty* FindProperty(TCLass* Instance, TMember TCLass::*PointerToMember); + + static bool IsTraceChannelHidden(const UCollisionProfile& InCollisionProfile, ECollisionChannel InCollisionChannel); }; //---------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/Cog/Public/CogWidgets.h b/Plugins/Cog/Source/Cog/Public/CogWidgets.h index 507dd1f..4fd4daa 100644 --- a/Plugins/Cog/Source/Cog/Public/CogWidgets.h +++ b/Plugins/Cog/Source/Cog/Public/CogWidgets.h @@ -56,7 +56,7 @@ public: static bool MultiChoiceButtonsInt(TArray& Values, int32& Value, const ImVec2& Size = ImVec2(0, 0), bool InInline = true); static bool MultiChoiceButtonsFloat(TArray& InValues, float& InValue, const ImVec2& InSize = ImVec2(0, 0), bool InInline = true, float InTolerance = UE_SMALL_NUMBER); - + static void SliderWithReset(const char* Name, float* Value, float Min, float Max, const float& ResetValue, const char* Format); static void HelpMarker(const char* Text); @@ -114,11 +114,15 @@ public: static bool DeleteArrayItemButton(); - static bool ComboCollisionChannel(const char* Label, ECollisionChannel& Channel); + static bool ComboTraceChannel(const char* Label, ECollisionChannel& Channel); - static bool CollisionProfileChannel(const UCollisionProfile& CollisionProfile, int32 ChannelIndex, FColor& ChannelColor, int32& Channels); + static bool CollisionProfileChannels(int32& OutChannels); - static bool CollisionProfileChannels(int32& Channels); + static bool CollisionTraceChannels(int32& OutChannels); + + static bool CollisionObjectTypeChannels(int32& OutChannels); + + static bool CollisionProfileChannel(const UCollisionProfile& InCollisionProfile, int32 InChannelIndex, FColor& InChannelColor, int32& InChannels); static bool MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TSubclassOf& ActorClass, const FCogWindowActorContextMenuFunction& ContextMenuFunction = nullptr); diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp index ce96a85..9214cd4 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp @@ -291,12 +291,6 @@ void FCogDebug::GetDebugChannelColors(FColor ChannelColors[ECC_MAX]) ChannelColors[ECC_PhysicsBody] = Settings.ChannelColorPhysicsBody; ChannelColors[ECC_Vehicle] = Settings.ChannelColorVehicle; ChannelColors[ECC_Destructible] = Settings.ChannelColorDestructible; - ChannelColors[ECC_EngineTraceChannel1] = Settings.ChannelColorEngineTraceChannel1; - ChannelColors[ECC_EngineTraceChannel2] = Settings.ChannelColorEngineTraceChannel2; - ChannelColors[ECC_EngineTraceChannel3] = Settings.ChannelColorEngineTraceChannel3; - ChannelColors[ECC_EngineTraceChannel4] = Settings.ChannelColorEngineTraceChannel4; - ChannelColors[ECC_EngineTraceChannel5] = Settings.ChannelColorEngineTraceChannel5; - ChannelColors[ECC_EngineTraceChannel6] = Settings.ChannelColorEngineTraceChannel6; ChannelColors[ECC_GameTraceChannel1] = Settings.ChannelColorGameTraceChannel1; ChannelColors[ECC_GameTraceChannel2] = Settings.ChannelColorGameTraceChannel2; ChannelColors[ECC_GameTraceChannel3] = Settings.ChannelColorGameTraceChannel3; diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp index 8cfa2d1..a78e10f 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp @@ -702,7 +702,7 @@ void FCogDebugDraw::Sweep(const FLogCategoryBase& LogCategory, const UObject* Wo } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings) +void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } @@ -711,7 +711,7 @@ void FCogDebugDraw::Overlap(const FLogCategoryBase& LogCategory, const UObject* if (World == nullptr) { return; } - FCogDebugDrawHelper::DrawOverlap(World, Shape, Location, Rotation, OverlapResults, Settings); + FCogDebugDrawHelper::DrawOverlap(World, Shape, Location, Rotation, HasHits, OverlapResults, Settings); const FColor Color = OverlapResults.Num() > 0 ? Settings.HitColor diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp index 3dcebe4..7dc0d4e 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp @@ -459,11 +459,12 @@ void FCogDebugDrawHelper::DrawOverlap( const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, - TArray& OverlapResults, + const bool HasHits, + const TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings ) { - const FColor Color = OverlapResults.Num() > 0 ? Settings.HitColor : Settings.NoHitColor; + const FColor Color = HasHits ? Settings.HitColor : Settings.NoHitColor; DrawShape(World, Shape, Location, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness); if (Settings.DrawHitPrimitives) diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugGizmo.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugGizmo.cpp index 281b157..7e79ccc 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugGizmo.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugGizmo.cpp @@ -3,12 +3,12 @@ #include "CogDebug.h" #include "CogDebugDrawHelper.h" #include "CogImguiHelper.h" +#include "DrawDebugHelpers.h" +#include "imgui.h" #include "Components/PrimitiveComponent.h" #include "Components/SceneComponent.h" -#include "DrawDebugHelpers.h" #include "Engine/World.h" #include "GameFramework/PlayerController.h" -#include "imgui.h" #include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -78,7 +78,7 @@ float ScreenDistanceToArc(const APlayerController& InPlayerController, const FVe FVector P0 = Center + Radius * (AxisZ * FMath::Sin(CurrentAngle) + AxisY * FMath::Cos(CurrentAngle)); - FVector2D ScreenP0; + FVector2D ScreenP0; UGameplayStatics::ProjectWorldToScreen(&InPlayerController, P0, ScreenP0); float MinDistanceSqr = FLT_MAX; @@ -163,14 +163,14 @@ void DrawGizmoText(const ImVec2& Position, ImU32 Color, const char* Text) bool RenderComponent(const char* Label, double* Value, double Reset) { ImGui::TableNextColumn(); - ImGui::PushItemWidth(-1); + ImGui::PushItemWidth(-1); bool Result = FCogImguiHelper::DragDouble(Label, Value, 0.1f, 0.0f, 0.0f, "%.1f"); - if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) - { + if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) + { *Value = Reset; Result = true; - } - ImGui::PopItemWidth(); + } + ImGui::PopItemWidth(); return Result; } @@ -240,7 +240,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont const float GizmoScale = Settings.GizmoScale * ScaleToKeepGizmoScreenSizeConstant; const FQuat RotX = Settings.GizmoUseLocalSpace ? InOutTransform.GetRotation() : FQuat(FVector(0.0f, 0.0f, 1.0f), 0.0f); - const FQuat RotY = RotX * FQuat(FVector(0.0f, 0.0f,-1.0f), UE_HALF_PI); + 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 = Settings.GizmoUseLocalSpace ? RotX.GetAxisX() : FVector::XAxisVector; @@ -255,9 +255,9 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont const ImVec2 ImMousePos = ImGui::GetMousePos() - Viewport->Pos; const FVector2D MousePos = FCogImguiHelper::ToFVector2D(ImMousePos); - const FColor GizmoAxisColorsZLow[] = { Settings.GizmoAxisColorsZLowX, Settings.GizmoAxisColorsZLowY, Settings.GizmoAxisColorsZLowZ, Settings.GizmoAxisColorsZLowW }; - const FColor GizmoAxisColorsZHigh[] = { Settings.GizmoAxisColorsZHighX, Settings.GizmoAxisColorsZHighY, Settings.GizmoAxisColorsZHighZ, Settings.GizmoAxisColorsZHighW }; - const FColor GizmoAxisColorsSelection[] = { Settings.GizmoAxisColorsSelectionX, Settings.GizmoAxisColorsSelectionY, Settings.GizmoAxisColorsSelectionZ, Settings.GizmoAxisColorsSelectionW }; + const FColor GizmoAxisColorsZLow[] = {Settings.GizmoAxisColorsZLowX, Settings.GizmoAxisColorsZLowY, Settings.GizmoAxisColorsZLowZ, Settings.GizmoAxisColorsZLowW}; + const FColor GizmoAxisColorsZHigh[] = {Settings.GizmoAxisColorsZHighX, Settings.GizmoAxisColorsZHighY, Settings.GizmoAxisColorsZHighZ, Settings.GizmoAxisColorsZHighW}; + const FColor GizmoAxisColorsSelection[] = {Settings.GizmoAxisColorsSelectionX, Settings.GizmoAxisColorsSelectionY, Settings.GizmoAxisColorsSelectionZ, Settings.GizmoAxisColorsSelectionW}; FCogDebug_GizmoElement GizmoElements[static_cast(ECogDebug_GizmoElementType::MAX)]; for (FCogDebug_GizmoElement& GizmoElement : GizmoElements) @@ -267,35 +267,35 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationAxis) == false) { - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveX)] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoTranslationAxisLength * GizmoScale }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveY)] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoTranslationAxisLength * GizmoScale }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveZ)] = { ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoTranslationAxisLength * GizmoScale }; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveX)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoTranslationAxisLength * GizmoScale}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveY)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoTranslationAxisLength * GizmoScale}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveZ)] = {ECogDebug_GizmoType::MoveAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoTranslationAxisLength * GizmoScale}; } if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoTranslationPlane) == false) { - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveXY)] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + ((UnitAxisX + UnitAxisY) * Settings.GizmoTranslationPlaneOffset * GizmoScale) }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveXZ)] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + ((UnitAxisX + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale) }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveYZ)] = { ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + ((UnitAxisY + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale) }; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveXY)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + ((UnitAxisX + UnitAxisY) * Settings.GizmoTranslationPlaneOffset * GizmoScale)}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveXZ)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + ((UnitAxisX + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale)}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::MoveYZ)] = {ECogDebug_GizmoType::MovePlane, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + ((UnitAxisY + UnitAxisZ) * Settings.GizmoTranslationPlaneOffset * GizmoScale)}; } if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoRotation) == false) { - GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateX)] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, FVector::ZeroVector }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateY)] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, FVector::ZeroVector }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateZ)] = { ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, FVector::ZeroVector }; + GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateX)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, FVector::ZeroVector}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateY)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, FVector::ZeroVector}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::RotateZ)] = {ECogDebug_GizmoType::Rotate, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, FVector::ZeroVector}; } if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoScaleUniform) == false) { - GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleXYZ)] = { ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter }; + GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleXYZ)] = {ECogDebug_GizmoType::ScaleUniform, ECogDebug_GizmoAxis::MAX, FVector::OneVector, FVector::OneVector, RotX, GizmoCenter}; } if (EnumHasAnyFlags(Flags, ECogDebug_GizmoFlags::NoScaleAxis) == false) { - GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleX)] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoScaleBoxOffset * GizmoScale }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleY)] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoScaleBoxOffset * GizmoScale }; - GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleZ)] = { ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoScaleBoxOffset * GizmoScale }; + GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleX)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::X, FVector::XAxisVector, UnitAxisX, RotX, GizmoCenter + UnitAxisX * Settings.GizmoScaleBoxOffset * GizmoScale}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleY)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Y, FVector::YAxisVector, UnitAxisY, RotY, GizmoCenter + UnitAxisY * Settings.GizmoScaleBoxOffset * GizmoScale}; + GizmoElements[static_cast(ECogDebug_GizmoElementType::ScaleZ)] = {ECogDebug_GizmoType::ScaleAxis, ECogDebug_GizmoAxis::Z, FVector::ZAxisVector, UnitAxisZ, RotZ, GizmoCenter + UnitAxisZ * Settings.GizmoScaleBoxOffset * GizmoScale}; } ECogDebug_GizmoElementType HoveredElementType = ECogDebug_GizmoElementType::MAX; @@ -340,7 +340,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont break; } - default:; + default: ; } if (DistanceToMouse < Settings.GizmoCursorSelectionThreshold && DistanceToMouse < MinDistanceToMouse) @@ -394,7 +394,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont break; } - default: + default: break; } } @@ -409,7 +409,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont const FRotationTranslationMatrix Matrix(FRotator(90.0f, 0, 0), GroundHit.ImpactPoint); FCogDebugDrawHelper::DrawArc(World, Matrix, Settings.GizmoGroundRaycastCircleRadius, Settings.GizmoGroundRaycastCircleRadius, 0.0f, 360.0f, 24, Settings.GizmoGroundRaycastCircleColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow); } - DrawDebugLine(World, GizmoCenter, Bottom, Settings.GizmoGroundRaycastColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow); + DrawDebugLine(World, GizmoCenter, Bottom, Settings.GizmoGroundRaycastColor, false, 0.0f, Settings.GizmoZLow, ThicknessZLow); } if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) @@ -418,7 +418,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont } else if (DraggedElementType != ECogDebug_GizmoElementType::MAX) { - if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) + if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { InOutTransform = InitialTransform; DraggedElementType = ECogDebug_GizmoElementType::MAX; @@ -429,7 +429,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont switch (DraggedElement.Type) { - case ECogDebug_GizmoType::MoveAxis: + case ECogDebug_GizmoType::MoveAxis: { const FVector CursorOnLine = GetMouseCursorOnLine(InPlayerController, InitialTransform.GetTranslation(), DraggedElement.Direction, MousePos - CursorOffset); const float Delta = FVector::DotProduct(DraggedElement.Direction, CursorOnLine - InitialTransform.GetTranslation()); @@ -472,8 +472,8 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont DrawGizmoText(FCogImguiHelper::ToImVec2(Center2D), FCogImguiHelper::ToImU32(Settings.GizmoTextColor), StringCast(*Text).Get()); //DrawDebugPoint(World, InitialTransform.GetTranslation(), 5.0f, FColor::White); - //DrawDebugLine(World, InitialTransform.GetTranslation(), InitialTransform.GetTranslation() + WorldDeltaU, FColor::White); - //DrawDebugLine(World, InitialTransform.GetTranslation() + WorldDeltaU, InitialTransform.GetTranslation() + WorldDeltaU + WorldDeltaV, FColor::White); + //DrawDebugLine(World, InitialTransform.GetTranslation(), InitialTransform.GetTranslation() + WorldDeltaU, FColor::White); + //DrawDebugLine(World, InitialTransform.GetTranslation() + WorldDeltaU, InitialTransform.GetTranslation() + WorldDeltaU + WorldDeltaV, FColor::White); break; } @@ -485,7 +485,7 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont const float NormalizedAngle = FRotator::NormalizeAxis(DragAmount * Settings.GizmoRotationSpeed); const float SnappedAngle = FMath::GridSnap(NormalizedAngle, Settings.GizmoRotationSnapEnable ? Settings.GizmoRotationSnapValue : 0.0f); const FQuat RotDelta(-DraggedElement.Axis, FMath::DegreesToRadians(SnappedAngle)); - const FQuat NewRot = (Settings.GizmoUseLocalSpace) ? InitialTransform.GetRotation() * RotDelta : RotDelta * InitialTransform.GetRotation(); + const FQuat NewRot = (Settings.GizmoUseLocalSpace) ? InitialTransform.GetRotation() * RotDelta : RotDelta * InitialTransform.GetRotation(); InOutTransform.SetRotation(NewRot); Result = true; @@ -526,84 +526,136 @@ bool FCogDebug_Gizmo::Draw(const char* Id, const APlayerController& InPlayerCont break; } - default: + default: break; } - } } else if (HoveredElementType != ECogDebug_GizmoElementType::MAX) { - if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) + if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { - DraggedElementType = HoveredElementType; + DraggedElementType = HoveredElementType; CursorOffset = MousePos - Center2D; InitialTransform = InOutTransform; } - //else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) - //{ - // ImGui::OpenPopup(Id); - //} + else if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) + { + if (Settings.GizmoSupportContextMenu) + { + ImGui::OpenPopup(Id); + } + } } - //if (ImGui::BeginPopup(Id)) - //{ - // FVector Translation = InOutTransform.GetTranslation(); - // FRotator Rotation = InOutTransform.GetRotation().Rotator(); - // FVector Scale = InOutTransform.GetScale3D(); + if (Settings.GizmoSupportContextMenu) + { + if (ImGui::BeginPopup(Id)) + { + FVector Translation = InOutTransform.GetTranslation(); + FRotator Rotation = InOutTransform.GetRotation().Rotator(); + FVector Scale = InOutTransform.GetScale3D(); - // ImGui::Checkbox("Local Space", &Settings.GizmoUseLocalSpace); + ImGui::Checkbox("Local Space", &Settings.GizmoUseLocalSpace); - // ImGui::Separator(); + ImGui::Separator(); - // ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(1.0f, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(1.0f, 1.0f)); - // if (ImGui::BeginTable("Pools", 6, ImGuiTableFlags_SizingFixedFit)) - // { - // ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 5); - // ImGui::TableSetupColumn("X", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); - // ImGui::TableSetupColumn("Y", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); - // ImGui::TableSetupColumn("Z", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); - // ImGui::TableSetupColumn("SnapEnable", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); - // ImGui::TableSetupColumn("Snap", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 3); + if (ImGui::BeginTable("Pools", 6, ImGuiTableFlags_SizingFixedFit)) + { + ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 5); + ImGui::TableSetupColumn("X", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); + ImGui::TableSetupColumn("Y", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); + ImGui::TableSetupColumn("Z", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); + ImGui::TableSetupColumn("SnapEnable", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 4); + ImGui::TableSetupColumn("Snap", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 3); - // ImGui::PushID("Location"); - // ImGui::TableNextRow(); - // ImGui::TableNextColumn(); - // ImGui::Text("Location"); - // if (RenderComponent("##X", &Translation.X, 0.0)) { InOutTransform.SetTranslation(Translation); } - // if (RenderComponent("##Y", &Translation.Y, 0.0)) { InOutTransform.SetTranslation(Translation); } - // if (RenderComponent("##Z", &Translation.Z, 0.0)) { InOutTransform.SetTranslation(Translation); } - // RenderSnap(&Settings.GizmoTranslationSnapEnable, &Settings.GizmoTranslationSnapValue); - // ImGui::PopID(); + ImGui::PushID("Location"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("Location"); + + bool Translate = false; + Translate |= RenderComponent("##X", &Translation.X, 0.0); + Translate |= RenderComponent("##Y", &Translation.Y, 0.0); + Translate |= RenderComponent("##Z", &Translation.Z, 0.0); + if (Translate) + { + if (Settings.GizmoTranslationSnapEnable) + { + Translation.X = FMath::GridSnap(Translation.X, Settings.GizmoTranslationSnapValue); + Translation.Y = FMath::GridSnap(Translation.Y, Settings.GizmoTranslationSnapValue); + Translation.Z = FMath::GridSnap(Translation.Z, Settings.GizmoTranslationSnapValue); + } + + InOutTransform.SetTranslation(Translation); + Result = true; + } + + RenderSnap(&Settings.GizmoTranslationSnapEnable, &Settings.GizmoTranslationSnapValue); + ImGui::PopID(); - // ImGui::PushID("Rotation"); - // ImGui::TableNextRow(); - // ImGui::TableNextColumn(); - // ImGui::Text("Rotation"); - // if (RenderComponent("##X", &Rotation.Yaw, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); } - // if (RenderComponent("##Y", &Rotation.Pitch, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); } - // if (RenderComponent("##Z", &Rotation.Roll, 0.0)) { InOutTransform.SetRotation(Rotation.Quaternion()); } - // RenderSnap(&Settings.GizmoRotationSnapEnable, &Settings.GizmoRotationSnapValue); - // ImGui::PopID(); + ImGui::PushID("Rotation"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("Rotation"); - // ImGui::PushID("Scale"); - // ImGui::TableNextRow(); - // ImGui::TableNextColumn(); - // ImGui::Text("Scale"); - // if (RenderComponent("##X", &Scale.X, 0.0)) { InOutTransform.SetScale3D(Scale); } - // if (RenderComponent("##Y", &Scale.Y, 0.0)) { InOutTransform.SetScale3D(Scale); } - // if (RenderComponent("##Z", &Scale.Z, 0.0)) { InOutTransform.SetScale3D(Scale); } - // RenderSnap(&Settings.GizmoScaleSnapEnable, &Settings.GizmoScaleSnapValue); - // ImGui::PopID(); + bool Rotate = false; + Rotate |= RenderComponent("##X", &Rotation.Yaw, 0.0); + Rotate |= RenderComponent("##Y", &Rotation.Pitch, 0.0); + Rotate |= RenderComponent("##Z", &Rotation.Roll, 0.0); - // ImGui::EndTable(); - // } + if (Rotate) + { + if (Settings.GizmoRotationSnapEnable) + { + Rotation.Yaw = FMath::GridSnap(Rotation.Yaw, Settings.GizmoRotationSnapValue); + Rotation.Pitch = FMath::GridSnap(Rotation.Pitch, Settings.GizmoRotationSnapValue); + Rotation.Roll = FMath::GridSnap(Rotation.Roll, Settings.GizmoRotationSnapValue); + } + + InOutTransform.SetRotation(Rotation.Quaternion()); + Result = true; + } + + RenderSnap(&Settings.GizmoRotationSnapEnable, &Settings.GizmoRotationSnapValue); + ImGui::PopID(); - // ImGui::PopStyleVar(); + ImGui::PushID("Scale"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("Scale"); - // ImGui::EndPopup(); - //} + bool Rescale = false; + Rescale |= RenderComponent("##X", &Scale.X, 1.0); + Rescale |= RenderComponent("##Y", &Scale.Y, 1.0); + Rescale |= RenderComponent("##Z", &Scale.Z, 1.0); + + if (Rescale) + { + if (Settings.GizmoScaleSnapEnable) + { + Scale.X = FMath::GridSnap(Scale.X, Settings.GizmoScaleSnapValue); + Scale.Y = FMath::GridSnap(Scale.Y, Settings.GizmoScaleSnapValue); + Scale.Z = FMath::GridSnap(Scale.Z, Settings.GizmoScaleSnapValue); + } + + InOutTransform.SetScale3D(Scale); + Result = true; + } + + RenderSnap(&Settings.GizmoScaleSnapEnable, &Settings.GizmoScaleSnapValue); + ImGui::PopID(); + + ImGui::EndTable(); + } + + ImGui::PopStyleVar(); + + ImGui::EndPopup(); + } + } return Result; } diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h index 7ac28f5..5016a91 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h @@ -59,7 +59,7 @@ struct COGDEBUG_API FCogDebugDraw static void Sweep(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Start, const FVector& End, const FQuat& Rotation, const bool HasHits, TArray& HitResults, const FCogDebugDrawSweepParams& Settings); - static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings); + static void Overlap(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings); static void ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape); diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugDrawHelper.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugDrawHelper.h index a5eb401..28b8f76 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugDrawHelper.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugDrawHelper.h @@ -64,7 +64,7 @@ public: static void DrawPrimitiveComponent(const UPrimitiveComponent& PrimitiveComponent, const int32 BodyIndex, const FColor& Color, const bool Persistent, const float LifeTime, const uint8 DepthPriority, const float Thickness, const bool DrawName = true, const bool DrawNameShadow = true, const float DrawNameSize = 1.0f); - static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings); + static void DrawOverlap(const UWorld* World, const FCollisionShape& Shape, const FVector& Location, const FQuat& Rotation, const bool HasHits, const TArray& OverlapResults, const FCogDebugDrawOverlapParams& Settings); static void DrawHitResult(const UWorld* World, const FHitResult& HitResult, const FCogDebugDrawLineTraceParams& Settings); diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugSettings.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugSettings.h index 37e3661..9a53406 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugSettings.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugSettings.h @@ -86,6 +86,9 @@ struct FCogDebugSettings UPROPERTY(Config) float GizmoScale = 1.0f; + UPROPERTY(Config) + bool GizmoSupportContextMenu = true; + UPROPERTY(Config) bool GizmoUseLocalSpace = false; @@ -276,76 +279,58 @@ struct FCogDebugSettings FColor ChannelColorDestructible = FColor(255, 255, 0, 0); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel1 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel1 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel2 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel2 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel3 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel3 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel4 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel4 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel5 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel5 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorEngineTraceChannel6 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel6 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel1 = FColor(255, 105, 0, 5); + FColor ChannelColorGameTraceChannel7 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel2 = FColor(255, 30, 0, 5); + FColor ChannelColorGameTraceChannel8 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel3 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel9 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel4 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel10 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel5 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel11 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel6 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel12 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel7 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel13 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel8 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel14 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel9 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel15 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel10 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel16 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel11 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel17 = FColor(255, 255, 255, 5); UPROPERTY(Config) - FColor ChannelColorGameTraceChannel12 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel13 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel14 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel15 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel16 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel17 = FColor(0, 0, 0, 0); - - UPROPERTY(Config) - FColor ChannelColorGameTraceChannel18 = FColor(0, 0, 0, 0); + FColor ChannelColorGameTraceChannel18 = FColor(255, 255, 255, 5); UPROPERTY(Config) TArray SecondaryBoneWildcards = { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineCollisionTester.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineCollisionTester.cpp index c81c475..78c4fdd 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineCollisionTester.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineCollisionTester.cpp @@ -14,10 +14,10 @@ ACogEngineCollisionTester::ACogEngineCollisionTester(const FObjectInitializer& O PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; - StartComponent = CreateDefaultSubobject(TEXT("Start")); + StartComponent = CreateDefaultSubobject(TEXT("Start")); RootComponent = StartComponent; - EndComponent = CreateDefaultSubobject(TEXT("End")); + EndComponent = CreateDefaultSubobject(TEXT("End")); EndComponent->SetupAttachment(RootComponent); EndComponent->SetRelativeLocation(FVector(1000, 0, 0)); } @@ -29,7 +29,7 @@ bool ACogEngineCollisionTester::ShouldTickIfViewportsOnly() const { return true; } - + return false; } @@ -42,11 +42,13 @@ void ACogEngineCollisionTester::Tick(float DeltaSeconds) //-------------------------------------------------------------------------------------------------------------------------- void ACogEngineCollisionTester::Query() const { + const UWorld* World = GetWorld(); + FVector QueryStart = StartComponent->GetComponentLocation(); FVector QueryEnd = EndComponent->GetComponentLocation(); FQuat QueryRotation = StartComponent->GetComponentQuat(); bool HasHits = false; - + static const FName TraceTag(TEXT("FCogWindow_Collision")); const FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), TraceComplex); @@ -58,243 +60,284 @@ void ACogEngineCollisionTester::Query() const { switch (Shape) { - case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(ShapeExtent.X); break; - case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(ShapeExtent.X, ShapeExtent.Z); break; - case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(FVector3f(ShapeExtent)); break; + case ECogEngine_CollisionQueryShape::Sphere: QueryShape.SetSphere(ShapeExtent.X); + break; + case ECogEngine_CollisionQueryShape::Capsule: QueryShape.SetCapsule(ShapeExtent.X, ShapeExtent.Z); + break; + case ECogEngine_CollisionQueryShape::Box: QueryShape.SetBox(FVector3f(ShapeExtent)); + break; } } switch (Type) { - case ECogEngine_CollisionQueryType::Overlap: - { - TArray Overlaps; - switch (By) - { - case ECogEngine_CollisionQueryBy::Channel: - { - HasHits = GetWorld()->OverlapMultiByChannel(Overlaps, QueryStart, QueryRotation, Channel, QueryShape, QueryParams); - break; - } + case ECogEngine_CollisionQueryType::Overlap: + { + TArray Overlaps; + switch (By) + { + case ECogEngine_CollisionQueryBy::Channel: + { + switch (OverlapMode) + { + case ECogEngine_CollisionQueryOverlapMode::AnyTest: + HasHits = World->OverlapAnyTestByChannel(QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams); + break; - case ECogEngine_CollisionQueryBy::ObjectType: - { - FCollisionObjectQueryParams QueryObjectParams; - QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; - HasHits = GetWorld()->OverlapMultiByObjectType(Overlaps, QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams); - break; - } + case ECogEngine_CollisionQueryOverlapMode::BlockingTest: + HasHits = World->OverlapBlockingTestByChannel(QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams); + break; - case ECogEngine_CollisionQueryBy::Profile: - { - HasHits = GetWorld()->OverlapMultiByProfile(Overlaps, QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams); - break; - } - } + case ECogEngine_CollisionQueryOverlapMode::Multi: + HasHits = World->OverlapMultiByChannel(Overlaps, QueryStart, QueryRotation, TraceChannel, QueryShape, QueryParams); + break; + } + break; + } - FCogDebugDrawOverlapParams DrawParams; - FCogDebug::GetDebugDrawOverlapSettings(DrawParams); - FCogDebugDrawHelper::DrawOverlap(GetWorld(), QueryShape, QueryStart, QueryRotation, Overlaps, DrawParams); - break; - } + case ECogEngine_CollisionQueryBy::ObjectType: + { + FCollisionObjectQueryParams QueryObjectParams; + QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; - case ECogEngine_CollisionQueryType::LineTrace: - { - TArray Hits; - switch (By) - { - case ECogEngine_CollisionQueryBy::Channel: - { - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->LineTraceSingleByChannel(Hit, QueryStart, QueryEnd, Channel, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->LineTraceMultiByChannel(Hits, QueryStart, QueryEnd, Channel, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->LineTraceTestByChannel(QueryStart, QueryEnd, Channel, QueryParams); - break; - } - } + switch (OverlapMode) + { + case ECogEngine_CollisionQueryOverlapMode::AnyTest: + HasHits = World->OverlapAnyTestByObjectType(QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams); + break; - break; - } + case ECogEngine_CollisionQueryOverlapMode::BlockingTest: + break; - case ECogEngine_CollisionQueryBy::ObjectType: - { - FCollisionObjectQueryParams QueryObjectParams; - QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; + case ECogEngine_CollisionQueryOverlapMode::Multi: + HasHits = World->OverlapMultiByObjectType(Overlaps, QueryStart, QueryRotation, QueryObjectParams, QueryShape, QueryParams); + break; + } + break; + } - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->LineTraceSingleByObjectType(Hit, QueryStart, QueryEnd, QueryObjectParams, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->LineTraceMultiByObjectType(Hits, QueryStart, QueryEnd, QueryObjectParams, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->LineTraceTestByObjectType(QueryStart, QueryEnd, QueryObjectParams, QueryParams); - break; - } - } - break; - } + case ECogEngine_CollisionQueryBy::Profile: + { + switch (OverlapMode) + { + case ECogEngine_CollisionQueryOverlapMode::AnyTest: + HasHits = World->OverlapAnyTestByProfile(QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams); + break; - case ECogEngine_CollisionQueryBy::Profile: - { - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->LineTraceSingleByProfile(Hit, QueryStart, QueryEnd, ProfileName, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->LineTraceMultiByProfile(Hits, QueryStart, QueryEnd, ProfileName, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->LineTraceTestByProfile(QueryStart, QueryEnd, ProfileName, QueryParams); - break; - } - } - break; - } - } + case ECogEngine_CollisionQueryOverlapMode::BlockingTest: + HasHits = World->OverlapBlockingTestByProfile(QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams); + break; - FCogDebugDrawLineTraceParams DrawParams; - FCogDebug::GetDebugDrawLineTraceSettings(DrawParams); - FCogDebugDrawHelper::DrawLineTrace(GetWorld(), QueryStart, QueryEnd, HasHits, Hits, DrawParams); - break; - } + case ECogEngine_CollisionQueryOverlapMode::Multi: + HasHits = World->OverlapMultiByProfile(Overlaps, QueryStart, QueryRotation, ProfileName, QueryShape, QueryParams); + break; + } + break; + } + } - case ECogEngine_CollisionQueryType::Sweep: - { - TArray Hits; - switch (By) - { - case ECogEngine_CollisionQueryBy::Channel: - { - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->SweepSingleByChannel(Hit, QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->SweepMultiByChannel(Hits, QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->SweepTestByChannel(QueryStart, QueryEnd, QueryRotation, Channel, QueryShape, QueryParams); - break; - } - } - break; - } + FCogDebugDrawOverlapParams DrawParams; + FCogDebug::GetDebugDrawOverlapSettings(DrawParams); + FCogDebugDrawHelper::DrawOverlap(World, QueryShape, QueryStart, QueryRotation, HasHits, Overlaps, DrawParams); + break; + } - case ECogEngine_CollisionQueryBy::ObjectType: - { - FCollisionObjectQueryParams QueryObjectParams; - QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; + case ECogEngine_CollisionQueryType::LineTrace: + { + TArray Hits; + switch (By) + { + case ECogEngine_CollisionQueryBy::Channel: + { + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->LineTraceSingleByChannel(Hit, QueryStart, QueryEnd, TraceChannel, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->LineTraceMultiByChannel(Hits, QueryStart, QueryEnd, TraceChannel, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->LineTraceTestByChannel(QueryStart, QueryEnd, TraceChannel, QueryParams); + break; + } + } + break; + } - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->SweepSingleByObjectType(Hit, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->SweepMultiByObjectType(Hits, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->SweepTestByObjectType(QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); - break; - } - } - break; - } + case ECogEngine_CollisionQueryBy::ObjectType: + { + FCollisionObjectQueryParams QueryObjectParams; + QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; - case ECogEngine_CollisionQueryBy::Profile: - { - switch (Mode) - { - case ECogEngine_CollisionQueryMode::Single: - { - FHitResult Hit; - HasHits = GetWorld()->SweepSingleByProfile(Hit, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); - if (HasHits) - { - Hits.Add(Hit); - } - break; - } - case ECogEngine_CollisionQueryMode::Multi: - { - HasHits = GetWorld()->SweepMultiByProfile(Hits, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); - break; - } - case ECogEngine_CollisionQueryMode::Test: - { - HasHits = GetWorld()->SweepTestByProfile(QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); - break; - } - } - break; - } - } + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->LineTraceSingleByObjectType(Hit, QueryStart, QueryEnd, QueryObjectParams, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->LineTraceMultiByObjectType(Hits, QueryStart, QueryEnd, QueryObjectParams, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->LineTraceTestByObjectType(QueryStart, QueryEnd, QueryObjectParams, QueryParams); + break; + } + } + break; + } - FCogDebugDrawSweepParams DrawParams; - FCogDebug::GetDebugDrawSweepSettings(DrawParams); - FCogDebugDrawHelper::DrawSweep(GetWorld(), QueryShape, QueryStart, QueryEnd, QueryRotation, HasHits, Hits, DrawParams); - break; - } + case ECogEngine_CollisionQueryBy::Profile: + { + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->LineTraceSingleByProfile(Hit, QueryStart, QueryEnd, ProfileName, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->LineTraceMultiByProfile(Hits, QueryStart, QueryEnd, ProfileName, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->LineTraceTestByProfile(QueryStart, QueryEnd, ProfileName, QueryParams); + break; + } + } + break; + } + } + + FCogDebugDrawLineTraceParams DrawParams; + FCogDebug::GetDebugDrawLineTraceSettings(DrawParams); + FCogDebugDrawHelper::DrawLineTrace(World, QueryStart, QueryEnd, HasHits, Hits, DrawParams); + break; + } + + case ECogEngine_CollisionQueryType::Sweep: + { + TArray Hits; + switch (By) + { + case ECogEngine_CollisionQueryBy::Channel: + { + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->SweepSingleByChannel(Hit, QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->SweepMultiByChannel(Hits, QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->SweepTestByChannel(QueryStart, QueryEnd, QueryRotation, TraceChannel, QueryShape, QueryParams); + break; + } + } + break; + } + + case ECogEngine_CollisionQueryBy::ObjectType: + { + FCollisionObjectQueryParams QueryObjectParams; + QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; + + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->SweepSingleByObjectType(Hit, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->SweepMultiByObjectType(Hits, QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->SweepTestByObjectType(QueryStart, QueryEnd, QueryRotation, QueryObjectParams, QueryShape, QueryParams); + break; + } + } + break; + } + + case ECogEngine_CollisionQueryBy::Profile: + { + switch (TraceMode) + { + case ECogEngine_CollisionQueryTraceMode::Single: + { + FHitResult Hit; + HasHits = World->SweepSingleByProfile(Hit, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); + if (HasHits) + { + Hits.Add(Hit); + } + break; + } + case ECogEngine_CollisionQueryTraceMode::Multi: + { + HasHits = World->SweepMultiByProfile(Hits, QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); + break; + } + case ECogEngine_CollisionQueryTraceMode::Test: + { + HasHits = World->SweepTestByProfile(QueryStart, QueryEnd, QueryRotation, ProfileName, QueryShape, QueryParams); + break; + } + } + break; + } + } + + FCogDebugDrawSweepParams DrawParams; + FCogDebug::GetDebugDrawSweepSettings(DrawParams); + FCogDebugDrawHelper::DrawSweep(World, QueryShape, QueryStart, QueryEnd, QueryRotation, HasHits, Hits, DrawParams); + break; + } } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp index b876d00..09f3d49 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp @@ -103,14 +103,27 @@ void FCogEngineWindow_CollisionTester::RenderContent() if (const APlayerController* LocalPlayerController = GetLocalPlayerController()) { StartGizmo.Draw("CollisionTesterStartGizmo", *LocalPlayerController, *CollisionTester->StartComponent); - EndGizmo.Draw("CollisionTesterEndGizmo", *LocalPlayerController, *CollisionTester->EndComponent, ECogDebug_GizmoFlags::NoRotation | ECogDebug_GizmoFlags::NoScale); + + if (CollisionTester->Type != ECogEngine_CollisionQueryType::Overlap) + { + EndGizmo.Draw("CollisionTesterEndGizmo", *LocalPlayerController, *CollisionTester->EndComponent, ECogDebug_GizmoFlags::NoRotation | ECogDebug_GizmoFlags::NoScale); + } } FCogWidgets::SetNextItemToShortWidth(); FCogWidgets::ComboboxEnum("Type", CollisionTester->Type); - FCogWidgets::SetNextItemToShortWidth(); - FCogWidgets::ComboboxEnum("Mode", CollisionTester->Mode); + if (CollisionTester->Type == ECogEngine_CollisionQueryType::Overlap) + { + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Mode", CollisionTester->OverlapMode); + } + else + { + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Mode", CollisionTester->TraceMode); + } + FCogWidgets::SetNextItemToShortWidth(); FCogWidgets::ComboboxEnum("By", CollisionTester->By); @@ -121,10 +134,10 @@ void FCogEngineWindow_CollisionTester::RenderContent() if (CollisionTester->By == ECogEngine_CollisionQueryBy::Channel) { FCogWidgets::SetNextItemToShortWidth(); - ECollisionChannel Channel = CollisionTester->Channel.GetValue(); - if (FCogWidgets::ComboCollisionChannel("Channel", Channel)) + ECollisionChannel Channel = CollisionTester->TraceChannel.GetValue(); + if (FCogWidgets::ComboTraceChannel("Channel", Channel)) { - CollisionTester->Channel = Channel; + CollisionTester->TraceChannel = Channel; } } //------------------------------------------------- @@ -215,6 +228,6 @@ void FCogEngineWindow_CollisionTester::RenderContent() else if (CollisionTester->By == ECogEngine_CollisionQueryBy::ObjectType) { ImGui::Separator(); - FCogWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery); + FCogWidgets::CollisionObjectTypeChannels(CollisionTester->ObjectTypesToQuery); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp index 0aad8fe..f5954be 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp @@ -132,7 +132,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent() } ImGui::Separator(); - FCogWidgets::CollisionProfileChannels(Config->ObjectTypesToQuery); + FCogWidgets::CollisionObjectTypeChannels(Config->ObjectTypesToQuery); //------------------------------------------------- // Perform Query diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index 0c2c091..4b4231f 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -41,6 +41,9 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig() //-------------------------------------------------------------------------------------------------------------------------- void RenderCollisionChannelColor(const UCollisionProfile& CollisionProfile, FColor& Color, ECollisionChannel Channel, ImGuiColorEditFlags ColorEditFlags) { + if (CollisionProfile.ConvertToObjectType(Channel) == TraceTypeQuery_MAX && CollisionProfile.ConvertToTraceType(Channel) == TraceTypeQuery_MAX) + { return; } + const FString ChannelName = CollisionProfile.ReturnChannelNameFromContainerIndex(Channel).ToString(); FCogImguiHelper::ColorEdit4(StringCast(*ChannelName).Get(), Color, ColorEditFlags); } @@ -169,8 +172,11 @@ void FCogEngineWindow_DebugSettings::RenderContent() ImGui::Checkbox("Use Local Space", &Settings.GizmoUseLocalSpace); + ImGui::Checkbox("Support Context Menu", &Settings.GizmoSupportContextMenu); + ImGui::SetItemTooltip("Does right clicking on the gizmo displays a context menu ?"); + FCogWidgets::SetNextItemToShortWidth(); - ImGui::DragFloat("Gizmo Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f"); + ImGui::DragFloat("Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f"); ImGui::SetItemTooltip("The scale of the gizmo."); FCogWidgets::SetNextItemToShortWidth(); @@ -249,7 +255,7 @@ void FCogEngineWindow_DebugSettings::RenderContent() FCogWidgets::SetNextItemToShortWidth(); ECollisionChannel Channel = Settings.GizmoGroundRaycastChannel.GetValue(); - if (FCogWidgets::ComboCollisionChannel("Channel", Channel)) + if (FCogWidgets::ComboTraceChannel("Channel", Channel)) { Settings.GizmoGroundRaycastChannel = Channel; } @@ -292,12 +298,7 @@ void FCogEngineWindow_DebugSettings::RenderContent() RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorPhysicsBody, ECC_PhysicsBody, ColorEditFlags); RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorVehicle, ECC_Vehicle, ColorEditFlags); RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorDestructible, ECC_Destructible, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel1, ECC_EngineTraceChannel1, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel2, ECC_EngineTraceChannel2, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel3, ECC_EngineTraceChannel3, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel4, ECC_EngineTraceChannel4, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel5, ECC_EngineTraceChannel5, ColorEditFlags); - RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorEngineTraceChannel6, ECC_EngineTraceChannel6, ColorEditFlags); + RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel1, ECC_GameTraceChannel1, ColorEditFlags); RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel2, ECC_GameTraceChannel2, ColorEditFlags); RenderCollisionChannelColor(*CollisionProfile, Settings.ChannelColorGameTraceChannel3, ECC_GameTraceChannel3, ColorEditFlags); diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h index 1815977..f557c36 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h @@ -17,13 +17,22 @@ enum class ECogEngine_CollisionQueryType : uint8 //-------------------------------------------------------------------------------------------------------------------------- UENUM() -enum class ECogEngine_CollisionQueryMode : uint8 +enum class ECogEngine_CollisionQueryTraceMode : uint8 { Single, Multi, Test, }; +//-------------------------------------------------------------------------------------------------------------------------- +UENUM() +enum class ECogEngine_CollisionQueryOverlapMode : uint8 +{ + AnyTest, + BlockingTest, + Multi, +}; + //-------------------------------------------------------------------------------------------------------------------------- UENUM() enum class ECogEngine_CollisionQueryBy : uint8 @@ -49,7 +58,6 @@ class COGENGINE_API ACogEngineCollisionTester : public AActor GENERATED_BODY() public: - ACogEngineCollisionTester(const FObjectInitializer& ObjectInitializer); virtual void Tick(float DeltaSeconds) override; @@ -65,7 +73,10 @@ public: ECogEngine_CollisionQueryType Type = ECogEngine_CollisionQueryType::LineTrace; UPROPERTY(EditAnywhere) - ECogEngine_CollisionQueryMode Mode = ECogEngine_CollisionQueryMode::Multi; + ECogEngine_CollisionQueryTraceMode TraceMode = ECogEngine_CollisionQueryTraceMode::Multi; + + UPROPERTY(EditAnywhere) + ECogEngine_CollisionQueryOverlapMode OverlapMode = ECogEngine_CollisionQueryOverlapMode::Multi; UPROPERTY(EditAnywhere) ECogEngine_CollisionQueryBy By = ECogEngine_CollisionQueryBy::Channel; @@ -80,7 +91,7 @@ public: int32 ObjectTypesToQuery = 0; UPROPERTY(EditAnywhere) - TEnumAsByte Channel = ECC_WorldStatic; + TEnumAsByte TraceChannel = ECC_Visibility; UPROPERTY() int32 ProfileIndex = 0; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h index 15ac7c4..24c4628 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h @@ -68,7 +68,7 @@ public: ECogEngine_CollisionQueryType Type; UPROPERTY(Config) - ECogEngine_CollisionQueryMode Mode; + ECogEngine_CollisionQueryTraceMode Mode; UPROPERTY(Config) ECogEngine_CollisionQueryBy By; @@ -97,7 +97,7 @@ public: Type = ECogEngine_CollisionQueryType::LineTrace; By = ECogEngine_CollisionQueryBy::Channel; - Mode = ECogEngine_CollisionQueryMode::Multi; + Mode = ECogEngine_CollisionQueryTraceMode::Multi; Channel = ECC_WorldStatic; TraceComplex = false; Shape = ECogEngine_CollisionQueryShape::Sphere;