From ed6acba51f4241534fbe1ff1c79b89fbed0db415 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:36:45 +0200 Subject: [PATCH] CubeMesh - Remove 'SetName' and add constructor with 'name' parameter --- PCK-Studio/Rendering/CubeMesh.cs | 14 ++++++-------- PCK-Studio/Rendering/CubeMeshCollection.cs | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/PCK-Studio/Rendering/CubeMesh.cs b/PCK-Studio/Rendering/CubeMesh.cs index 24466eac..24e6222a 100644 --- a/PCK-Studio/Rendering/CubeMesh.cs +++ b/PCK-Studio/Rendering/CubeMesh.cs @@ -55,7 +55,11 @@ namespace PckStudio.Rendering internal static VertexBufferLayout VertexBufferLayout { get; } = new VertexBufferLayout().Add(ShaderDataType.Float3).Add(ShaderDataType.Float2); - public CubeMesh(Cube cube) : this(nameof(CubeMesh), cube, true) + public CubeMesh(Cube cube) : this(nameof(CubeMesh), cube) + { + } + + public CubeMesh(string name, Cube cube) : this(name, cube, true) { } @@ -65,12 +69,6 @@ namespace PckStudio.Rendering _cube = cube; } - public CubeMesh SetName(string name) - { - _ = name ?? throw new ArgumentNullException(nameof(name)); - return new CubeMesh(name, _cube, Visible); - } - public CubeMesh SetCube(Cube cube) { _ = cube ?? throw new ArgumentNullException(nameof(cube)); @@ -83,7 +81,7 @@ namespace PckStudio.Rendering public override BoundingBox GetBounds(Matrix4 transform) { - return _cube.GetBoundingBox(transform); + return _cube.GetBoundingBox(Transform * transform); } internal override IEnumerable GetVertices() diff --git a/PCK-Studio/Rendering/CubeMeshCollection.cs b/PCK-Studio/Rendering/CubeMeshCollection.cs index d164bc8a..166a6d4e 100644 --- a/PCK-Studio/Rendering/CubeMeshCollection.cs +++ b/PCK-Studio/Rendering/CubeMeshCollection.cs @@ -33,7 +33,7 @@ namespace PckStudio.Rendering internal static void AddSkinBox(this CubeMeshCollection cubeMeshes, SkinBOX skinBox, float inflate = 0f) { var cube = skinBox.ToCube(inflate, cubeMeshes.FlipZMapping); - cubeMeshes.Add(new CubeMesh(cube).SetName(skinBox.Type)); + cubeMeshes.Add(new CubeMesh(skinBox.Type, cube)); } } @@ -117,7 +117,7 @@ namespace PckStudio.Rendering internal void AddNamed(string name, Vector3 position, Vector3 size, Vector2 uv, float inflate = 0f, bool mirrorTexture = false) { var cube = new Cube(position, size, uv, inflate, mirrorTexture, FlipZMapping); - Add(new CubeMesh(cube).SetName(name)); + Add(new CubeMesh(name, cube)); } internal void AddSubCollection(string name, Vector3 translation, Vector3 pivot, Vector3 rotation = default)