Skip to content

Commit

Permalink
SkinRenderer - Fix centering leg0/1
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Aug 5, 2024
1 parent ba7a2fb commit 888dad0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions PCK-Studio/Internal/ModelPartSpecifics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ internal static class ModelPartSpecifics
{
["HEAD"] = new PositioningInfo(),
["BODY"] = new PositioningInfo(),
["ARM0"] = new PositioningInfo(new(-5f, 2f, 0f), new( 6f, 2f, 0f)),
["ARM1"] = new PositioningInfo(new( 5f, 2f, 0f), new(-6f, 2f, 0f)),
["LEG0"] = new PositioningInfo(new(-2f, 12f, 0f), new( 2f, 12f, 0f)),
["LEG1"] = new PositioningInfo(new( 2f, 12f, 0f), new(-2f, 12f, 0f)),
["ARM0"] = new PositioningInfo(new(-5f, 2f, 0f), new(-6f, 2f, 0f)),
["ARM1"] = new PositioningInfo(new( 5f, 2f, 0f), new( 6f, 2f, 0f)),
["LEG0"] = new PositioningInfo(new(-2f, 12f, 0f), new(-2f, 12f, 0f)),
["LEG1"] = new PositioningInfo(new( 2f, 12f, 0f), new( 2f, 12f, 0f)),
};

internal record struct PositioningInfo(Vector3 Translation, Vector3 Pivot);
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Rendering/CubeGroupMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ internal Vector3 GetCenter(int index)
if (!cubes.IndexInRange(index))
throw new IndexOutOfRangeException();

return Vector3.TransformPosition(cubes[index].Center + Offset, Transform);
return (Transform * Matrix4.CreateTranslation(cubes[index].Center)).ExtractTranslation();
}

internal BoundingBox GetCubeBoundingBox(int index)
Expand Down
4 changes: 3 additions & 1 deletion PCK-Studio/Rendering/SkinRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,9 @@ internal void CenterSelectedObject()

CubeGroupMesh cubeMesh = meshStorage[skinBox.Type];
Vector3 center = Cube.FromSkinBox(skinBox).Center;
Camera.FocalPoint = (cubeMesh.Transform * Matrix4.CreateTranslation(center)).Inverted().ExtractTranslation();
Matrix4 camMat = (Matrix4.CreateTranslation(cubeMesh.Translation) * Matrix4.CreateTranslation(center) * Matrix4.CreateScale(-1, 1, 1));
Vector3 camPos = camMat.ExtractTranslation();
Camera.FocalPoint = camPos;
Camera.Distance = skinBox.Size.Length() * 2;
}
}
Expand Down

0 comments on commit 888dad0

Please sign in to comment.