mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-10 18:03:51 +00:00
Move Cube conversion into SkinBOXExtensions
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
using PckStudio.Rendering;
|
||||
|
||||
namespace PckStudio.Extensions
|
||||
{
|
||||
@@ -62,5 +63,10 @@ namespace PckStudio.Extensions
|
||||
int index = Array.IndexOf(SkinBOX.OverlayTypes, type);
|
||||
return SkinBOX.BaseTypes.IndexInRange(index) ? SkinBOX.BaseTypes[index] : "";
|
||||
}
|
||||
|
||||
internal static Cube ToCube(this SkinBOX skinBOX) => skinBOX.ToCube(0f);
|
||||
|
||||
internal static Cube ToCube(this SkinBOX skinBOX, float inflate, bool flipZMapping = false)
|
||||
=> new Cube(skinBOX.Pos.ToOpenTKVector(), skinBOX.Size.ToOpenTKVector(), skinBOX.UV.ToOpenTKVector(), skinBOX.Scale + inflate, skinBOX.Mirror, flipZMapping);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,6 @@ namespace PckStudio.Rendering
|
||||
Right
|
||||
}
|
||||
|
||||
internal static Cube FromSkinBox(SkinBOX skinBOX) => FromSkinBox(skinBOX, 0f);
|
||||
|
||||
internal static Cube FromSkinBox(SkinBOX skinBOX, float inflate, bool flipZMapping = false)
|
||||
=> new Cube(skinBOX.Pos.ToOpenTKVector(), skinBOX.Size.ToOpenTKVector(), skinBOX.UV.ToOpenTKVector(), skinBOX.Scale + inflate, skinBOX.Mirror, flipZMapping);
|
||||
|
||||
public Cube(Vector3 position, Vector3 size, Vector2 uv, float inflate, bool mirrorTexture, bool flipZMapping)
|
||||
{
|
||||
Position = position;
|
||||
|
||||
@@ -28,6 +28,15 @@ using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
static class CubeMeshCollectionExtensions
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
internal class CubeMeshCollection : GenericMesh<TextureVertex>, ICollection<CubeMesh>
|
||||
{
|
||||
private List<CubeMesh> cubes;
|
||||
@@ -81,12 +90,6 @@ namespace PckStudio.Rendering
|
||||
transform = Matrix4.CreateTranslation(Translation) * Matrix4.CreateScale(1f, -1f, -1f);
|
||||
}
|
||||
|
||||
internal void AddSkinBox(SkinBOX skinBox, float inflate = 0f)
|
||||
{
|
||||
var cube = Cube.FromSkinBox(skinBox, inflate, FlipZMapping);
|
||||
cubes.Add(new CubeMesh(cube).SetName(skinBox.Type));
|
||||
}
|
||||
|
||||
internal override IEnumerable<TextureVertex> GetVertices()
|
||||
=> cubes.Where(c => c.ShouldRender).SelectMany(c => c.GetVertices());
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ namespace PckStudio.Rendering
|
||||
}
|
||||
|
||||
CubeMeshCollection cubeMesh = meshStorage[skinBox.Type];
|
||||
Vector3 center = Cube.FromSkinBox(skinBox).Center;
|
||||
Vector3 center = skinBox.ToCube().Center;
|
||||
Matrix4 camMat = (Matrix4.CreateTranslation(cubeMesh.Translation) * Matrix4.CreateTranslation(center + cubeMesh.Offset) * Matrix4.CreateScale(-1, 1, 1));
|
||||
Vector3 camPos = camMat.ExtractTranslation();
|
||||
Camera.FocalPoint = camPos;
|
||||
@@ -995,7 +995,7 @@ namespace PckStudio.Rendering
|
||||
SkinBOX box = ModelData[SelectedIndex];
|
||||
|
||||
float inflate = autoInflateOverlayParts && box.IsOverlayPart() ? box.Type == "HEADWEAR" ? OverlayScale * 2 : OverlayScale : 0f;
|
||||
Cube cube = Cube.FromSkinBox(box, inflate);
|
||||
Cube cube = box.ToCube(inflate);
|
||||
|
||||
BoundingBox cubeBoundingBox = cube.GetBoundingBox();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user