1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-10 03:28:43 +02:00

Store a RuntimeTexturePacker packed texture region's source region

This commit is contained in:
Ell 2022-11-14 11:49:47 +01:00
parent 6ac2ba6151
commit db02dfcfde
3 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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();

View file

@ -58,6 +58,11 @@ namespace MLEM.Textures {
/// The name of this texture region. By default, this name is <see cref="string.Empty"/>.
/// </summary>
public string Name = string.Empty;
/// <summary>
/// A <see cref="TextureRegion"/> that this texture region was created from.
/// This value is set in the various constructors that accept another <see cref="TextureRegion"/> to create sub-regions from, as well as by MLEM.Data's <c>RuntimeTexturePacker</c>.
/// </summary>
public TextureRegion Source;
/// <summary>
/// Creates a new texture region from a texture and a rectangle which defines the region's area
@ -116,7 +121,9 @@ namespace MLEM.Textures {
/// <param name="region">The texture region to create a sub-region of</param>
/// <param name="uv">The top left corner of this area</param>
/// <param name="size">The size of this area</param>
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;
}
/// <summary>
/// Returns a new <see cref="TextureRegion"/> that has the same <see cref="Texture"/>, <see cref="Pivot"/> and <see cref="Size"/> as this texture, but the returned region's <see cref="Position"/> will be offset by <paramref name="offset"/>.