Fix optimized stitcher ignoring maximum atlas size
This commit is contained in:
parent
d2680cf29d
commit
7e9ace3fc6
|
|
@ -1,8 +1,10 @@
|
|||
package org.embeddedt.modernfix.common.mixin.perf.faster_texture_stitching;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.client.renderer.texture.Stitcher;
|
||||
import net.minecraft.client.renderer.texture.StitcherException;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.embeddedt.modernfix.platform.ModernFixPlatformHooks;
|
||||
|
|
@ -17,6 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Mixin(Stitcher.class)
|
||||
@ClientOnlyMixin
|
||||
|
|
@ -28,6 +31,8 @@ public class StitcherMixin {
|
|||
@Shadow private int storageY;
|
||||
|
||||
@Shadow @Final private static Comparator<Stitcher.Holder> HOLDER_COMPARATOR;
|
||||
@Shadow @Final private int maxWidth;
|
||||
@Shadow @Final private int maxHeight;
|
||||
private List<StbStitcher.LoadableSpriteInfo> loadableSpriteInfos;
|
||||
|
||||
/**
|
||||
|
|
@ -48,6 +53,13 @@ public class StitcherMixin {
|
|||
Pair<Pair<Integer, Integer>, List<StbStitcher.LoadableSpriteInfo>> packingInfo = StbStitcher.packRects(aholder);
|
||||
this.storageX = packingInfo.getFirst().getFirst();
|
||||
this.storageY = packingInfo.getFirst().getSecond();
|
||||
|
||||
// Detect an oversized atlas generated in the previous step.
|
||||
if(this.storageX > this.maxWidth || this.storageY > this.maxHeight) {
|
||||
ModernFix.LOGGER.error("Requested atlas size {}x{} exceeds maximum of {}x{}", this.storageX, this.storageY, this.maxWidth, this.maxHeight);
|
||||
throw new StitcherException(aholder[0].spriteInfo, Stream.of(aholder).map(arg -> arg.spriteInfo).collect(ImmutableList.toImmutableList()));
|
||||
}
|
||||
|
||||
this.loadableSpriteInfos = packingInfo.getSecond();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user