From c7430dd7ed0f0c6fe205464a060daa37d96ff67c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 19 Dec 2020 23:09:26 +0100 Subject: [PATCH] fixed pivot calculation being incorrect for data texture atlases with an offset --- MLEM.Data/DataTextureAtlas.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MLEM.Data/DataTextureAtlas.cs b/MLEM.Data/DataTextureAtlas.cs index 38799b7..939014e 100644 --- a/MLEM.Data/DataTextureAtlas.cs +++ b/MLEM.Data/DataTextureAtlas.cs @@ -5,6 +5,7 @@ using System.Text.RegularExpressions; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; +using MLEM.Extensions; using MLEM.Textures; namespace MLEM.Data { @@ -61,7 +62,7 @@ namespace MLEM.Data { foreach (Match match in Regex.Matches(text, regex)) { var name = match.Groups[1].Value.Trim(); var loc = new Rectangle( - int.Parse(match.Groups[2].Value) + texture.U, int.Parse(match.Groups[3].Value) + texture.V, + int.Parse(match.Groups[2].Value), int.Parse(match.Groups[3].Value), int.Parse(match.Groups[4].Value), int.Parse(match.Groups[5].Value)); var piv = Vector2.Zero; if (match.Groups[6].Success) { @@ -69,7 +70,7 @@ namespace MLEM.Data { float.Parse(match.Groups[6].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.X), float.Parse(match.Groups[7].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.Y)); } - atlas.regions.Add(name, new TextureRegion(texture, loc) { + atlas.regions.Add(name, new TextureRegion(texture, loc.OffsetCopy(texture.Position)) { PivotPixels = piv, Name = name });