From 238bf2d57412c3307e665c5f882f51edb5567f18 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 26 Jan 2024 12:34:01 +0300 Subject: [PATCH] feat: Shape.CreateCopy --- Engine.Physics2D/Primitives/Shape.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine.Physics2D/Primitives/Shape.cs b/Engine.Physics2D/Primitives/Shape.cs index 08570d2..dc9e2aa 100644 --- a/Engine.Physics2D/Primitives/Shape.cs +++ b/Engine.Physics2D/Primitives/Shape.cs @@ -11,6 +11,8 @@ public record Shape(IList Vertices) : IEnumerable { public Vector2D this[Index index] => Vertices[index]; + public static Shape CreateCopy(Shape shape) => new(new List(shape.Vertices)); + public static Triangle GetSuperTriangle(Shape shape) { float minX = float.MaxValue, minY = float.MaxValue; @@ -90,6 +92,7 @@ public record Shape(IList Vertices) : IEnumerable public static class ShapeExtensions { + public static Shape CreateCopy(Shape shape) => Shape.CreateCopy(shape); public static Triangle ToSuperTriangle(this Shape shape) => Shape.GetSuperTriangle(shape); public static void ToLines(this Shape shape, IList lines) => Shape.GetLines(shape, lines); public static List ToLines(this Shape shape) => Shape.GetLines(shape);