diff --git a/source/simulation2/components/CCmpSelectable.cpp b/source/simulation2/components/CCmpSelectable.cpp index 9777a9fb54..0cd66a166c 100644 --- a/source/simulation2/components/CCmpSelectable.cpp +++ b/source/simulation2/components/CCmpSelectable.cpp @@ -505,13 +505,11 @@ void CCmpSelectable::UpdateTexturedLineOverlay(const SOverlayDescriptor* overlay else { const float radius = (buildingOverlay ? fpSize0_fixed.ToFloat() : overlayDescriptor->m_Radius) + overlay.m_Thickness / 3.f; - float stepAngle; - unsigned numSteps; - SimRender::AngularStepFromChordLen(TERRAIN_TILE_SIZE / 3.f, radius, stepAngle, numSteps); - for (unsigned i = 0; i < numSteps; ++i) + u32 numSteps = ceilf(float(2 * M_PI) * radius / (TERRAIN_TILE_SIZE / 3.f)); + for (u32 i = 0; i < numSteps; ++i) { - float angle = i * stepAngle; + float angle = i * float(2 * M_PI) / numSteps; float px = origin.X + radius * sinf(angle); float pz = origin.Y + radius * cosf(angle); diff --git a/source/simulation2/helpers/Geometry.cpp b/source/simulation2/helpers/Geometry.cpp index d8e54f3d08..d32b44d1ce 100644 --- a/source/simulation2/helpers/Geometry.cpp +++ b/source/simulation2/helpers/Geometry.cpp @@ -31,11 +31,6 @@ CFixedVector2D Geometry::GetHalfBoundingBox(const CFixedVector2D& u, const CFixe ); } -float Geometry::ChordToCentralAngle(const float chordLength, const float radius) -{ - return acosf(1.f - SQR(chordLength)/(2.f*SQR(radius))); // cfr. law of cosines -} - fixed Geometry::DistanceToSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize, bool countInsideAsZero) { /* diff --git a/source/simulation2/helpers/Geometry.h b/source/simulation2/helpers/Geometry.h index 6256e4f86a..0eb62f6c96 100644 --- a/source/simulation2/helpers/Geometry.h +++ b/source/simulation2/helpers/Geometry.h @@ -91,15 +91,6 @@ fixed DistanceToSquareSquared(const CFixedVector2D& point, CFixedVector2D NearestPointOnSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); -/** - * Given a circle of radius @p radius, and a chord of length @p chordLength - * on this circle, computes the central angle formed by - * connecting the chord's endpoints to the center of the circle. - * - * @param radius Radius of the circle; must be strictly positive. - */ -float ChordToCentralAngle(const float chordLength, const float radius); - bool TestRaySquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); bool TestRayAASquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& halfSize); diff --git a/source/simulation2/helpers/Render.cpp b/source/simulation2/helpers/Render.cpp index 060daf0929..583f2209a2 100644 --- a/source/simulation2/helpers/Render.cpp +++ b/source/simulation2/helpers/Render.cpp @@ -561,13 +561,6 @@ void SimRender::ConstructDashedLine(const std::vector& keyPoints, SDa } -void SimRender::AngularStepFromChordLen(const float maxChordLength, const float radius, float& out_stepAngle, unsigned& out_numSteps) -{ - float maxAngle = Geometry::ChordToCentralAngle(maxChordLength, radius); - out_numSteps = ceilf(float(2*M_PI)/maxAngle); - out_stepAngle = float(2*M_PI)/out_numSteps; -} - // TODO: this serves a similar purpose to SplitLine above, but is more general. Also, SplitLine seems to be implemented more // efficiently, might be nice to take some cues from it void SimRender::SubdividePoints(std::vector& points, float maxSegmentLength, bool closed) diff --git a/source/simulation2/helpers/Render.h b/source/simulation2/helpers/Render.h index 8aac666f18..7e65caafe6 100644 --- a/source/simulation2/helpers/Render.h +++ b/source/simulation2/helpers/Render.h @@ -179,20 +179,6 @@ void InterpolatePointsRNS(std::vector& points, bool closed, float off void ConstructDashedLine(const std::vector& linePoints, SDashedLine& dashedLineOut, const float dashLength, const float blankLength); -/** - * Computes angular step parameters @p out_stepAngle and @p out_numSteps, given a @p maxChordLength on a circle of radius @p radius. - * The resulting values satisfy @p out_numSteps * @p out_stepAngle = 2*PI. - * - * This function is used to find the angular step parameters when drawing a circle outline approximated by several connected chords; - * it returns the step angle and number of steps such that the length of each resulting chord is less than or equal to @p maxChordLength. - * By stating that each chord cannot be longer than a particular length, a certain level of visual smoothness of the resulting circle - * outline can be guaranteed independently of the radius of the outline. - * - * @param radius Radius of the circle. Must be strictly positive. - * @param maxChordLength Desired maximum length of individual chords. Must be strictly positive. - */ -void AngularStepFromChordLen(const float maxChordLength, const float radius, float& out_stepAngle, unsigned& out_numSteps); - /** * Subdivides a list of @p points into segments of maximum length @p maxSegmentLength that are of equal size between every two * control points. The resulting subdivided list of points is written back to @p points.