From a594d796ad5f56bfba453419f9bd78dd6980db8c Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 23 Jul 2024 11:31:34 -0400 Subject: [PATCH] Batch optimizations --- core/src/mindustry/ClientLauncher.java | 2 +- core/src/mindustry/entities/effect/ParticleEffect.java | 4 ++-- core/src/mindustry/graphics/Drawf.java | 2 +- core/src/mindustry/graphics/LightRenderer.java | 2 +- core/src/mindustry/type/Weather.java | 2 +- .../src/mindustry/world/blocks/distribution/ItemBridge.java | 6 ++++-- core/src/mindustry/world/blocks/storage/CoreBlock.java | 2 +- gradle.properties | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index 2a7b133588..2e8d7396c1 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -70,7 +70,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform }); UI.loadColors(); - batch = new SortedSpriteBatch(); + batch = new SpriteBatch(); assets = new AssetManager(); assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader()); diff --git a/core/src/mindustry/entities/effect/ParticleEffect.java b/core/src/mindustry/entities/effect/ParticleEffect.java index 4da451b08f..65e376babc 100644 --- a/core/src/mindustry/entities/effect/ParticleEffect.java +++ b/core/src/mindustry/entities/effect/ParticleEffect.java @@ -79,7 +79,7 @@ public class ParticleEffect extends Effect{ float x = rv.x, y = rv.y; Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len, cap); - Drawf.light(ox + x, oy + y, len * lightScl, lightColor, lightOpacity * Draw.getColor().a); + Drawf.light(ox + x, oy + y, len * lightScl, lightColor, lightOpacity * Draw.getColorAlpha()); } }else{ rand.setSeed(e.id); @@ -89,7 +89,7 @@ public class ParticleEffect extends Effect{ float x = rv.x, y = rv.y; Draw.rect(tex, ox + x, oy + y, rad, rad / tex.ratio(), realRotation + offset + e.time * spin); - Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a); + Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColorAlpha()); } } } diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 44cbc6b38e..db7db61dd5 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -480,7 +480,7 @@ public class Drawf{ /** Draws a sprite that should be light-wise correct, when rotated. Provided sprite must be symmetrical in shape. */ public static void spinSprite(TextureRegion region, float x, float y, float r){ - float a = Draw.getColor().a; + float a = Draw.getColorAlpha(); r = Mathf.mod(r, 90f); Draw.rect(region, x, y, r); Draw.alpha(r / 90f*a); diff --git a/core/src/mindustry/graphics/LightRenderer.java b/core/src/mindustry/graphics/LightRenderer.java index a0cab5c03e..7c30b94796 100644 --- a/core/src/mindustry/graphics/LightRenderer.java +++ b/core/src/mindustry/graphics/LightRenderer.java @@ -70,7 +70,7 @@ public class LightRenderer{ float rot = Mathf.angleExact(x2 - x, y2 - y); TextureRegion ledge = Core.atlas.find("circle-end"), lmid = Core.atlas.find("circle-mid"); - float color = Draw.getColor().toFloatBits(); + float color = Draw.getColorPacked(); float u = lmid.u; float v = lmid.v2; float u2 = lmid.u2; diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index d8b7618ccc..e70e0af9af 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -161,7 +161,7 @@ public class Weather extends UnlockableContent{ Core.camera.bounds(Tmp.r2); int total = (int)(Tmp.r1.area() / density * intensity); Lines.stroke(stroke); - float alpha = Draw.getColor().a; + float alpha = Draw.getColorAlpha(); Draw.color(color); for(int i = 0; i < total; i++){ diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 2663365fc2..0ec2e16bcd 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -238,13 +238,15 @@ public class ItemBridge extends Block{ Lines.stroke(2.5f); Lines.line(tx + Tmp.v2.x, ty + Tmp.v2.y, ox - Tmp.v2.x, oy - Tmp.v2.y); + float color = (linked ? Pal.place : Pal.accent).toFloatBits(); + //draw foreground colors - Draw.color(linked ? Pal.place : Pal.accent); + Draw.color(color); Lines.stroke(1f); Lines.line(tx + Tmp.v2.x, ty + Tmp.v2.y, ox - Tmp.v2.x, oy - Tmp.v2.y); Lines.square(ox, oy, 2f, 45f); - Draw.mixcol(Draw.getColor(), 1f); + Draw.mixcol(color); Draw.color(); Draw.rect(arrowRegion, x, y, rel * 90); Draw.mixcol(); diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index c3d50f69d7..15a80f0c6e 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -292,7 +292,7 @@ public class CoreBlock extends StorageBlock{ protected void drawLandingThrusters(float x, float y, float rotation, float frame){ float length = thrusterLength * (frame - 1f) - 1f/4f; - float alpha = Draw.getColor().a; + float alpha = Draw.getColorAlpha(); //two passes for consistent lighting for(int j = 0; j < 2; j++){ diff --git a/gradle.properties b/gradle.properties index 827c8445c4..f4f892e59f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=96cd86d08a +archash=8055a9104d