1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-25 17:59:24 +01:00

Improved RuntimeTexturePacker speed when using many distinct texture sizes

This commit is contained in:
Ell 2023-01-30 22:38:15 +01:00
parent d450ec3082
commit ca9c8e6cfd
2 changed files with 10 additions and 1 deletions

View file

@ -12,6 +12,10 @@ Jump to version:
## 6.2.0 (In Development)
### MLEM.Data
Improvements
- Improved RuntimeTexturePacker speed when using many distinct texture sizes
## 6.1.0
### MLEM

View file

@ -238,7 +238,12 @@ namespace MLEM.Data {
size.X += request.Padding * 2;
size.Y += request.Padding * 2;
var pos = this.firstPossiblePosForSize.TryGetValue(size, out var first) ? first : Point.Zero;
// initialize our search position from the cache, or use default (zero)
if (!this.firstPossiblePosForSize.TryGetValue(size, out var pos)) {
// if our size hasn't been recordet yet, check if a size has been recorded that is smaller in both axes, before which our size definitely won't fit
pos = this.firstPossiblePosForSize.OrderByDescending(s => s.Key.X * s.Key.Y).FirstOrDefault(s => s.Key.X <= size.X && s.Key.Y <= size.Y).Value;
}
var lowestY = int.MaxValue;
while (true) {
var intersected = false;