diff --git a/CHANGELOG.md b/CHANGELOG.md
index e510177..d81b58f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -76,6 +76,7 @@ Improvements
- Made RuntimeTexturePacker restore texture region name and pivot when packing
- Multi-target net452, making MLEM compatible with MonoGame for consoles
- Added trimming and AOT annotations and made MLEM.Data trimmable
+- Store a RuntimeTexturePacker packed texture region's source region
Fixes
- Fixed data texture atlases not allowing most characters in their region names
diff --git a/MLEM.Data/RuntimeTexturePacker.cs b/MLEM.Data/RuntimeTexturePacker.cs
index 4745839..97d6dec 100644
--- a/MLEM.Data/RuntimeTexturePacker.cs
+++ b/MLEM.Data/RuntimeTexturePacker.cs
@@ -203,7 +203,8 @@ namespace MLEM.Data {
var packedArea = request.PackedArea.Shrink(new Point(request.Padding, request.Padding));
request.Result.Invoke(new TextureRegion(this.PackedTexture, packedArea) {
Pivot = request.Texture.Pivot,
- Name = request.Texture.Name
+ Name = request.Texture.Name,
+ Source = request.Texture
});
if (this.disposeTextures)
request.Texture.Texture.Dispose();
diff --git a/MLEM/Textures/TextureRegion.cs b/MLEM/Textures/TextureRegion.cs
index dc117bb..8fdc743 100644
--- a/MLEM/Textures/TextureRegion.cs
+++ b/MLEM/Textures/TextureRegion.cs
@@ -58,6 +58,11 @@ namespace MLEM.Textures {
/// The name of this texture region. By default, this name is .
///
public string Name = string.Empty;
+ ///
+ /// A that this texture region was created from.
+ /// This value is set in the various constructors that accept another to create sub-regions from, as well as by MLEM.Data's RuntimeTexturePacker.
+ ///
+ public TextureRegion Source;
///
/// Creates a new texture region from a texture and a rectangle which defines the region's area
@@ -116,7 +121,9 @@ namespace MLEM.Textures {
/// The texture region to create a sub-region of
/// The top left corner of this area
/// The size of this area
- public TextureRegion(TextureRegion region, Point uv, Point size) : this(region.Texture, region.Position + uv, size) {}
+ public TextureRegion(TextureRegion region, Point uv, Point size) : this(region.Texture, region.Position + uv, size) {
+ this.Source = region;
+ }
///
/// Returns a new that has the same , and as this texture, but the returned region's will be offset by .