mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Improve RuntimeTexturePacker performance by checking against packed textures in the same order as packing
This commit is contained in:
parent
951f4babd5
commit
cb496f613f
2 changed files with 5 additions and 1 deletions
|
@ -58,6 +58,7 @@ Improvements
|
|||
- Premultiply textures when using RawContentManager
|
||||
- Allow enumerating all region names of a DataTextureAtlas
|
||||
- Cache RuntimeTexturePacker texture data while packing to improve performance
|
||||
- Improve RuntimeTexturePacker performance by checking against packed textures in the same order as packing
|
||||
|
||||
Fixes
|
||||
- Fixed SoundEffectReader incorrectly claiming it could read ogg and mp3 files
|
||||
|
|
|
@ -152,9 +152,12 @@ namespace MLEM.Data {
|
|||
if (this.PackedTexture != null)
|
||||
throw new InvalidOperationException("Cannot pack a texture packer that is already packed");
|
||||
|
||||
// we pack larger textures first, so that smaller textures can fit in the gaps that larger ones leave
|
||||
this.textures.Sort((r1, r2) => (r2.Texture.Width * r2.Texture.Height).CompareTo(r1.Texture.Width * r1.Texture.Height));
|
||||
|
||||
// set pack areas for each request
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
foreach (var request in this.textures.OrderByDescending(t => t.Texture.Width * t.Texture.Height))
|
||||
foreach (var request in this.textures)
|
||||
request.PackedArea = this.FindFreeArea(request);
|
||||
stopwatch.Stop();
|
||||
this.LastCalculationTime = stopwatch.Elapsed;
|
||||
|
|
Loading…
Reference in a new issue