From d2f247ad4fadd32bf66ac8e276f7df29ac95c122 Mon Sep 17 00:00:00 2001 From: mriegger Date: Mon, 21 Jun 2021 16:28:51 -0700 Subject: [PATCH 1/6] Fix for incomplete arcs being drawn --- .../Code/Source/AtomDebugDisplayViewportInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index 620d5d1fb8..0eadb188f0 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -1160,7 +1160,7 @@ namespace AZ::AtomBridge // Draw 3 axis aligned circles const float stepAngle = DegToRad(11.25f); const float startAngle = DegToRad(0.0f); - const float stopAngle = DegToRad(360.0f) + startAngle; + const float stopAngle = DegToRad(360.0f) + stepAngle; SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for azis line + 1 for spare const AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( From 8d04154fb9324a23337a4dd52bc1b67ac7b989a1 Mon Sep 17 00:00:00 2001 From: mriegger Date: Mon, 21 Jun 2021 18:05:54 -0700 Subject: [PATCH 2/6] Changing it so that the Draw functions always stop at exactly maxAngle --- .../AtomDebugDisplayViewportInterface.cpp | 12 ++++++------ .../Source/AtomDebugDisplayViewportInterface.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index 0eadb188f0..4407e02b9f 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -802,7 +802,7 @@ namespace AZ::AtomBridge constexpr float sweepAngleDegrees = 360.0f; const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; + const float stopAngle = DegToRad(sweepAngleDegrees); SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); AZ::Vector3 pos = AZ::Vector3(center.GetX(), center.GetY(), z); @@ -832,7 +832,7 @@ namespace AZ::AtomBridge // Draw axis aligned arc const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; + const float stopAngle = DegToRad(sweepAngleDegrees); SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateAxisAlignedArc( @@ -861,7 +861,7 @@ namespace AZ::AtomBridge // Draw arbitraty axis arc const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; + const float stopAngle = DegToRad(sweepAngleDegrees); SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( @@ -904,7 +904,7 @@ namespace AZ::AtomBridge { // Draw circle with single radius. const float step = DegToRad(10.0f); - const float maxAngle = DegToRad(360.0f) + step; + const float maxAngle = DegToRad(360.0f); SingleColorStaticSizeLineHelper<40> lines; // hard code 40 lines until DegToRad is constexpr. AZ::Vector3 radiusV3 = AZ::Vector3(radius); @@ -1134,7 +1134,7 @@ namespace AZ::AtomBridge // This matches Cry behavior, the DrawWireSphere above may need modifying to use the same approach. // Draw 3 axis aligned circles const float step = DegToRad(10.0f); - const float maxAngle = DegToRad(360.0f) + step; + const float maxAngle = DegToRad(360.0f); SingleColorStaticSizeLineHelper<40*3> lines; // hard code to 40 lines * 3 circles until DegToRad is constexpr. // Z Axis @@ -1160,7 +1160,7 @@ namespace AZ::AtomBridge // Draw 3 axis aligned circles const float stepAngle = DegToRad(11.25f); const float startAngle = DegToRad(0.0f); - const float stopAngle = DegToRad(360.0f) + stepAngle; + const float stopAngle = DegToRad(360.0f); SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for azis line + 1 for spare const AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.h b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.h index 69d0fc6d96..1f9d514c2f 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.h +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.h @@ -332,6 +332,15 @@ namespace AZ::AtomBridge p0 = p1; ++segmentIndex; } + // Complete the arc by drawing the last bit + sinCos.SetElement(circleAxis1, sinf(maxAngle)); + sinCos.SetElement(circleAxis2, cosf(maxAngle)); + p1 = position + radiusV3 * sinCos; + p1 = ToWorldSpacePosition(p1); + if (filterFunc(p0, p1, segmentIndex)) + { + lines.AddLineSegment(p0, p1); + } } template @@ -369,5 +378,13 @@ namespace AZ::AtomBridge p0 = p1; ++segmentIndex; } + // Complete the arc by drawing the last bit + AZ::SinCos(maxAngle, sinVF, cosVF); + p1 = position + radiusV3 * (cosVF * a + sinVF * b); + p1 = ToWorldSpacePosition(p1); + if (filterFunc(p0, p1, segmentIndex)) + { + lines.AddLineSegment(p0, p1); + } } } // namespace AZ::AtomBridge From 6dfa9d269cb102ea6d37c374acedee8886b79d4d Mon Sep 17 00:00:00 2001 From: mriegger Date: Tue, 22 Jun 2021 10:19:21 -0700 Subject: [PATCH 3/6] Fixing mistakes --- .../Code/Source/AtomDebugDisplayViewportInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index 4407e02b9f..3610e671f1 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -802,7 +802,7 @@ namespace AZ::AtomBridge constexpr float sweepAngleDegrees = 360.0f; const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees); + const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); AZ::Vector3 pos = AZ::Vector3(center.GetX(), center.GetY(), z); @@ -832,7 +832,7 @@ namespace AZ::AtomBridge // Draw axis aligned arc const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees); + const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateAxisAlignedArc( @@ -861,7 +861,7 @@ namespace AZ::AtomBridge // Draw arbitraty axis arc const float stepAngle = DegToRad(angularStepDegrees); const float startAngle = DegToRad(startAngleDegrees); - const float stopAngle = DegToRad(sweepAngleDegrees); + const float stopAngle = DegToRad(sweepAngleDegrees) + startAngle; SingleColorDynamicSizeLineHelper lines(1+static_cast(sweepAngleDegrees/angularStepDegrees)); AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( From 026b1df29a57c68bca61b5bb1b7a987354b5de52 Mon Sep 17 00:00:00 2001 From: mriegger Date: Tue, 22 Jun 2021 10:34:13 -0700 Subject: [PATCH 4/6] removing small issue --- .../Code/Source/AtomDebugDisplayViewportInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index 3610e671f1..e8c559fc51 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -1160,7 +1160,7 @@ namespace AZ::AtomBridge // Draw 3 axis aligned circles const float stepAngle = DegToRad(11.25f); const float startAngle = DegToRad(0.0f); - const float stopAngle = DegToRad(360.0f); + const float stopAngle = DegToRad(360.0f) + startAngle; SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for azis line + 1 for spare const AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( From 6a19196d33ed76943bb5cba65cbcdbc588a3e5e5 Mon Sep 17 00:00:00 2001 From: mriegger Date: Tue, 22 Jun 2021 12:40:40 -0700 Subject: [PATCH 5/6] fix typo in comment --- .../Code/Source/AtomDebugDisplayViewportInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index e8c559fc51..ccafbf2820 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -1161,7 +1161,7 @@ namespace AZ::AtomBridge const float stepAngle = DegToRad(11.25f); const float startAngle = DegToRad(0.0f); const float stopAngle = DegToRad(360.0f) + startAngle; - SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for azis line + 1 for spare + SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for axis line + 1 for spare const AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( lines, From cca2b489d73adf5d23395af78698ce9556914f9a Mon Sep 17 00:00:00 2001 From: mriegger Date: Tue, 22 Jun 2021 13:53:31 -0700 Subject: [PATCH 6/6] better formatting and changes from feedback --- .../Code/Source/AtomDebugDisplayViewportInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp index ccafbf2820..1233f3846c 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/AtomDebugDisplayViewportInterface.cpp @@ -1160,8 +1160,8 @@ namespace AZ::AtomBridge // Draw 3 axis aligned circles const float stepAngle = DegToRad(11.25f); const float startAngle = DegToRad(0.0f); - const float stopAngle = DegToRad(360.0f) + startAngle; - SingleColorDynamicSizeLineHelper lines(2+static_cast(360.0f/11.25f)); // num disk segments + 1 for axis line + 1 for spare + const float stopAngle = DegToRad(360.0f); + SingleColorDynamicSizeLineHelper lines(2 + static_cast(360.0f / 11.25f)); // num disk segments + 1 for axis line + 1 for spare const AZ::Vector3 radiusV3 = AZ::Vector3(radius); CreateArbitraryAxisArc( lines,