Skip to content

Commit 648c18e

Browse files
authored
Merge pull request #6663 from EVAST9919/tighter-approx
Increase `Path` "approximation resolution" during draw process
2 parents 5acb295 + 8779f73 commit 648c18e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

osu.Framework/Graphics/Lines/Path_DrawNode.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ private void updateVertexBuffer()
267267
Line? segmentToDraw = null;
268268
SegmentStartLocation location = SegmentStartLocation.Outside;
269269
SegmentStartLocation modifiedLocation = SegmentStartLocation.Outside;
270+
SegmentStartLocation nextLocation = SegmentStartLocation.End;
270271
SegmentWithThickness? lastDrawnSegment = null;
271272

272273
for (int i = 0; i < segments.Count; i++)
@@ -286,18 +287,24 @@ private void updateVertexBuffer()
286287
Vector2 closest = segmentToDraw.Value.At(progress);
287288

288289
// Expand segment if next end point is located within a line passing through it
289-
if (Precision.AlmostEquals(closest, segments[i].EndPoint, 0.1f))
290+
if (Precision.AlmostEquals(closest, segments[i].EndPoint, 0.01f))
290291
{
291292
if (progress < 0)
292293
{
293294
// expand segment backwards
294295
segmentToDraw = new Line(segments[i].EndPoint, segmentToDraw.Value.EndPoint);
295296
modifiedLocation = SegmentStartLocation.Outside;
297+
nextLocation = SegmentStartLocation.Start;
296298
}
297299
else if (progress > 1)
298300
{
299301
// or forward
300302
segmentToDraw = new Line(segmentToDraw.Value.StartPoint, segments[i].EndPoint);
303+
nextLocation = SegmentStartLocation.End;
304+
}
305+
else
306+
{
307+
nextLocation = SegmentStartLocation.Middle;
301308
}
302309
}
303310
else // Otherwise draw the expanded segment
@@ -307,11 +314,9 @@ private void updateVertexBuffer()
307314
connect(s, lastDrawnSegment, texRect);
308315

309316
lastDrawnSegment = s;
310-
311-
// Figure out at which point within currently drawn segment the new one starts
312-
float p = progressFor(segmentToDraw.Value, segmentToDrawLength, segments[i].StartPoint);
313317
segmentToDraw = segments[i];
314-
location = modifiedLocation = Precision.AlmostEquals(p, 1f) ? SegmentStartLocation.End : Precision.AlmostEquals(p, 0f) ? SegmentStartLocation.Start : SegmentStartLocation.Middle;
318+
location = modifiedLocation = nextLocation;
319+
nextLocation = SegmentStartLocation.End;
315320
}
316321
}
317322
else

0 commit comments

Comments
 (0)