mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Fix now unsupported behaviour in ConvexPolygonClipper
This commit is contained in:
@@ -104,7 +104,7 @@ namespace osu.Framework.Tests.Polygons
|
||||
|
||||
private static Vector2[] clip(SimpleConvexPolygon poly1, SimpleConvexPolygon poly2)
|
||||
{
|
||||
var clipper = new ConvexPolygonClipper<SimpleConvexPolygon, SimpleConvexPolygon>(ref poly1, ref poly2);
|
||||
var clipper = new ConvexPolygonClipper<SimpleConvexPolygon, SimpleConvexPolygon>(poly1, poly2);
|
||||
|
||||
Span<Vector2> buffer = stackalloc Vector2[clipper.GetClipBufferSize()];
|
||||
|
||||
|
||||
@@ -300,12 +300,12 @@ namespace osu.Framework.Tests.Polygons
|
||||
}
|
||||
|
||||
private Span<Vector2> clip(SimpleConvexPolygon clipPolygon, SimpleConvexPolygon subjectPolygon)
|
||||
=> new ConvexPolygonClipper<SimpleConvexPolygon, SimpleConvexPolygon>(ref clipPolygon, ref subjectPolygon).Clip();
|
||||
=> new ConvexPolygonClipper<SimpleConvexPolygon, SimpleConvexPolygon>(clipPolygon, subjectPolygon).Clip();
|
||||
|
||||
private Span<Vector2> clip<TClip, TSubject>(TClip clipPolygon, TSubject subjectPolygon)
|
||||
where TClip : IConvexPolygon
|
||||
where TSubject : IConvexPolygon
|
||||
=> new ConvexPolygonClipper<TClip, TSubject>(ref clipPolygon, ref subjectPolygon).Clip();
|
||||
=> new ConvexPolygonClipper<TClip, TSubject>(clipPolygon, subjectPolygon).Clip();
|
||||
|
||||
private void assertPolygonEquals(IPolygon expected, IPolygon actual, bool reverse)
|
||||
=> Assert.That(Vector2Extensions.GetOrientation(actual.GetVertices()),
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace osu.Framework.Utils
|
||||
this.subjectPolygon = subjectPolygon;
|
||||
}
|
||||
|
||||
public ConvexPolygonClipper(TClip clipPolygon, TSubject subjectPolygon)
|
||||
{
|
||||
this.clipPolygon = clipPolygon;
|
||||
this.subjectPolygon = subjectPolygon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the minimum buffer size required to clip the two polygons.
|
||||
/// </summary>
|
||||
@@ -46,7 +52,7 @@ namespace osu.Framework.Utils
|
||||
/// </summary>
|
||||
/// <param name="buffer">The buffer to contain the clipped vertices. Must have a length of <see cref="GetClipBufferSize"/>.</param>
|
||||
/// <returns>A clockwise-ordered set of vertices representing the result of clipping <see cref="subjectPolygon"/> by <see cref="clipPolygon"/>.</returns>
|
||||
public Span<Vector2> Clip(in Span<Vector2> buffer)
|
||||
public Span<Vector2> Clip(Span<Vector2> buffer)
|
||||
{
|
||||
if (buffer.Length < GetClipBufferSize())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user