private void SetPoint(RenderedPolygon renderedPolygon, Vector2F point, float size, Color color) { Span <Vector2F> points = stackalloc Vector2F[4]; points[0] = point + new Vector2F(-1f, -1f) * size / 2f; points[1] = point + new Vector2F(1f, -1f) * size / 2f; points[2] = point + new Vector2F(1f, 1f) * size / 2f; points[3] = point + new Vector2F(-1f, 1f) * size / 2f; Engine.Vector2FArrayCache.FromSpan(points); renderedPolygon.CreateVertexesByVector2F(Engine.Vector2FArrayCache); renderedPolygon.OverwriteVertexesColor(color); renderedPolygon.SetDefaultIndexBuffer(); }
private void SetLine(RenderedPolygon renderedPolygon, Vector2F point1, Vector2F point2, Color color) { Span <Vector2F> positions = stackalloc Vector2F[4]; var vec = point2 - point1; var side = new Vector2F(vec.Y, -vec.X).Normal; positions[0] = point1 - side; positions[1] = point1 + side; positions[2] = point2 + side; positions[3] = point2 - side; Engine.Vector2FArrayCache.FromSpan(positions); renderedPolygon.CreateVertexesByVector2F(Engine.Vector2FArrayCache); renderedPolygon.OverwriteVertexesColor(color); renderedPolygon.SetDefaultIndexBuffer(); }