From 1313ed2761ff5f20c622b6aa9b02f12deb20420c Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 3 Jun 2021 11:37:33 -0400 Subject: [PATCH] Sprite packing fix --- core/assets-raw/sprites/pack.json | 6 +---- core/src/mindustry/core/Renderer.java | 2 +- tools/build.gradle | 35 ++++++++++++--------------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/core/assets-raw/sprites/pack.json b/core/assets-raw/sprites/pack.json index defab56426..fcd452dd9f 100644 --- a/core/assets-raw/sprites/pack.json +++ b/core/assets-raw/sprites/pack.json @@ -4,9 +4,5 @@ flattenPaths: true, maxWidth: 4096, maxHeight: 4096, - fast: true, - - edgePadding: false, - bleed: false, - debug: true + fast: true } diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 83f32408a8..ec10061402 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -385,7 +385,7 @@ public class Renderer implements ApplicationListener{ lines[i + 3] = (byte)255; } Pixmap fullPixmap = new Pixmap(w, h); - Buffers.copy(lines, 0, fullPixmap.getPixels(), lines.length); + Buffers.copy(lines, 0, fullPixmap.pixels, lines.length); Fi file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png"); PixmapIO.writePng(file, fullPixmap); fullPixmap.dispose(); diff --git a/tools/build.gradle b/tools/build.gradle index bfe38ced40..3a1141fb1f 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -212,30 +212,27 @@ task pack(dependsOn: [classes, configurations.runtimeClasspath]){ delete "../core/assets-raw/sprites_out/ui/icons" } - //disabled until the elusive sprite packing bug is fixed - if(false){ - ExecutorService executor = Executors.newFixedThreadPool(16) - long ms = System.currentTimeMillis() + ExecutorService executor = Executors.newFixedThreadPool(16) + long ms = System.currentTimeMillis() - //antialias everything except UI elements - fileTree(dir: new File(rootDir, 'core/assets-raw/sprites_out/').absolutePath, include: "**/*.png").visit{ file -> - if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && file.toString().startsWith("icon-")) || file.toString().contains(".9.png")) return + //antialias everything except UI elements + fileTree(dir: new File(rootDir, 'core/assets-raw/sprites_out/').absolutePath, include: "**/*.png").visit{ file -> + if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && file.toString().startsWith("icon-")) || file.toString().contains(".9.png")) return - executor.submit{ - antialias(file.file) - } + executor.submit{ + antialias(file.file) } - - executor.shutdown() - try{ - executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS) - }catch(InterruptedException e){ - e.printStackTrace() - } - - println "Time taken for AA: ${(System.currentTimeMillis() - ms) / 1000f}" } + executor.shutdown() + try{ + executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS) + }catch(InterruptedException e){ + e.printStackTrace() + } + + println "Time taken for AA: ${(System.currentTimeMillis() - ms) / 1000f}" + println("\n\nPacking normal 4096 sprites...\n\n") //pack normal sprites