From 8267376d32ad4de090f2970c1a9c6578e45db87c Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 12 Jun 2022 13:11:20 -0400 Subject: [PATCH] Experimental test for atlas OOM --- core/src/mindustry/graphics/MultiPacker.java | 6 ++--- core/src/mindustry/type/UnitType.java | 28 ++++++++++++++++++++ gradle.properties | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/graphics/MultiPacker.java b/core/src/mindustry/graphics/MultiPacker.java index bb10f9dcdd..6343739906 100644 --- a/core/src/mindustry/graphics/MultiPacker.java +++ b/core/src/mindustry/graphics/MultiPacker.java @@ -102,10 +102,10 @@ public class MultiPacker implements Disposable{ //main page can be massive, but 8192 throws GL_OUT_OF_MEMORY on some GPUs and I can't deal with it yet. main(4096), - environment(4096, 2048), - editor(4096, 2048), + environment(2048, 2048), + editor(2048, 2048), rubble(4096, 2048), - ui(4096); + ui(2048); public static final PageType[] all = values(); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 17a333f122..9ba49a26a5 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -884,6 +884,34 @@ public class UnitType extends UnlockableContent{ } } } + + //TODO test + if(sample instanceof Tankc){ + PixmapRegion pix = Core.atlas.getPixmap(treadRegion); + + for(int r = 0; r < treadRects.length; r++){ + Rect treadRect = treadRects[r]; + //slice is always 1 pixel wide + Pixmap slice = pix.crop((int)(treadRect.x + pix.width/2f), (int)(treadRect.y + pix.height/2f), 1, (int)treadRect.height); + int frames = treadFrames; + for(int i = 0; i < frames; i++){ + int pullOffset = treadPullOffset; + Pixmap frame = new Pixmap(slice.width, slice.height); + for(int y = 0; y < slice.height; y++){ + int idx = y + i; + if(idx >= slice.height){ + idx -= slice.height; + idx += pullOffset; + idx = Mathf.mod(idx, slice.height); + } + + frame.setRaw(0, y, slice.getRaw(0, idx)); + } + + packer.add(PageType.main, name + "-treads" + r + "-" + i, frame); + } + } + } } /** @return the time required to build this unit, as a value that takes into account reconstructors */ diff --git a/gradle.properties b/gradle.properties index 0eeb3fce98..828bd49f46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=f826256196 +archash=89f5cbe7ab