From 8d04154fb9324a23337a4dd52bc1b67ac7b989a1 Mon Sep 17 00:00:00 2001 From: mriegger Date: Mon, 21 Jun 2021 18:05:54 -0700 Subject: [PATCH] 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