From eeb13e345ccc6e4415656064a467d24abc0eb963 Mon Sep 17 00:00:00 2001 From: Goby56 <60710855+Goby56@users.noreply.github.com> Date: Sat, 24 Aug 2024 10:02:50 +0200 Subject: [PATCH] cleanup + flood fill 2 flood fill 2 seems to work fine and cuts texturing time in half from what flood fill 3 did --- src/main/java/com/goby56/wakes/config/WakesConfig.java | 2 +- .../java/com/goby56/wakes/config/YACLIntegration.java | 2 +- src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java | 9 +-------- src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java | 7 +++++-- .../com/goby56/wakes/render/SplashPlaneRenderer.java | 1 + src/main/java/com/goby56/wakes/render/WakeRenderer.java | 3 +-- .../java/com/goby56/wakes/simulation/WakeHandler.java | 2 -- 7 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/goby56/wakes/config/WakesConfig.java b/src/main/java/com/goby56/wakes/config/WakesConfig.java index 49358fe..bbcd790 100644 --- a/src/main/java/com/goby56/wakes/config/WakesConfig.java +++ b/src/main/java/com/goby56/wakes/config/WakesConfig.java @@ -37,7 +37,7 @@ public class WakesConfig { // Debug public boolean disableMod = false; - public int floodFillDistance = 3; + public int floodFillDistance = 2; public int ticksBeforeFill = 2; public boolean pickBoat = true; public RenderType renderType = RenderType.AUTO; diff --git a/src/main/java/com/goby56/wakes/config/YACLIntegration.java b/src/main/java/com/goby56/wakes/config/YACLIntegration.java index e2d075c..e5c2e97 100644 --- a/src/main/java/com/goby56/wakes/config/YACLIntegration.java +++ b/src/main/java/com/goby56/wakes/config/YACLIntegration.java @@ -117,7 +117,7 @@ public static Screen createScreen(Screen parent) { .enumClass(RenderType.class)) .build()) .option(optionOf(Integer.class, "flood_fill_distance", false) - .binding(3, () -> config.floodFillDistance, val -> config.floodFillDistance = val) + .binding(2, () -> config.floodFillDistance, val -> config.floodFillDistance = val) .controller(opt -> integerSlider(opt, 1, 5)) .build()) .option(optionOf(Integer.class, "ticks_before_fill", false) diff --git a/src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java b/src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java index 88e2fc9..a043668 100644 --- a/src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java +++ b/src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java @@ -7,9 +7,7 @@ public class WakesDebugInfo { public static double nodeLogicTime = 0; - public static double insertionTime = 0; public static double texturingTime = 0; - public static ArrayList cullingTime = new ArrayList<>(); public static ArrayList renderingTime = new ArrayList<>(); // Frames averaged each tick public static int quadsRendered = 0; public static int nodeCount = 0; @@ -17,19 +15,14 @@ public class WakesDebugInfo { public static void reset() { nodeCount = 0; nodeLogicTime = 0; - insertionTime = 0; texturingTime = 0; - cullingTime = new ArrayList<>(); renderingTime = new ArrayList<>(); } public static void show(CallbackInfoReturnable> info) { - int q = WakesDebugInfo.quadsRendered; - info.getReturnValue().add(String.format("[Wakes] Rendering %d quads for %d wake nodes", q, WakesDebugInfo.nodeCount)); + info.getReturnValue().add(String.format("[Wakes] Rendering %d quads for %d wake nodes", WakesDebugInfo.quadsRendered, WakesDebugInfo.nodeCount)); info.getReturnValue().add(String.format("[Wakes] Node logic: %.2fms/t", 10e-6 * WakesDebugInfo.nodeLogicTime)); - info.getReturnValue().add(String.format("[Wakes] Insertion: %.2fms/t", 10e-6 * WakesDebugInfo.insertionTime)); info.getReturnValue().add(String.format("[Wakes] Texturing: %.2fms/t", 10e-6 * WakesDebugInfo.texturingTime)); - info.getReturnValue().add(String.format("[Wakes] Culling: %.3fms/f", 10e-6 * WakesDebugInfo.cullingTime.stream().reduce(0L, Long::sum) / WakesDebugInfo.cullingTime.size())); info.getReturnValue().add(String.format("[Wakes] Rendering: %.3fms/f", 10e-6 * WakesDebugInfo.renderingTime.stream().reduce(0L, Long::sum) / WakesDebugInfo.renderingTime.size())); } } diff --git a/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java b/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java index f1f5e0c..cddc5cb 100644 --- a/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java +++ b/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java @@ -1,7 +1,6 @@ package com.goby56.wakes.mixin; import com.goby56.wakes.WakesClient; -import com.goby56.wakes.simulation.WakeHandler; import com.goby56.wakes.debug.WakesDebugInfo; import net.minecraft.client.gui.hud.DebugHud; import org.spongepowered.asm.mixin.Mixin; @@ -17,7 +16,11 @@ public abstract class DebugHudMixin { @Inject(at = @At("RETURN"), method = "getLeftText") protected void getLeftText(CallbackInfoReturnable> info) { if (WakesClient.CONFIG_INSTANCE.showDebugInfo) { - WakesDebugInfo.show(info); + if (WakesClient.CONFIG_INSTANCE.disableMod) { + info.getReturnValue().add("[Wakes] Mod disabled!"); + } else { + WakesDebugInfo.show(info); + } } } } \ No newline at end of file diff --git a/src/main/java/com/goby56/wakes/render/SplashPlaneRenderer.java b/src/main/java/com/goby56/wakes/render/SplashPlaneRenderer.java index e7f1eac..6f24b24 100644 --- a/src/main/java/com/goby56/wakes/render/SplashPlaneRenderer.java +++ b/src/main/java/com/goby56/wakes/render/SplashPlaneRenderer.java @@ -83,6 +83,7 @@ public static void render(T entity, float yaw, float tickDelt matrices.scale(scalar, scalar, scalar); Matrix4f matrix = matrices.peek().getPositionMatrix(); + // TODO MAKE SPLASH PLANE LOOK MORE LIKE WAKES (SIMULATE AND COLOR EACH PIXEL) Vector3f color = new Vector3f(); int waterCol = BiomeColors.getWaterColor(entity.getWorld(), entity.getBlockPos()); color.x = (float) (waterCol >> 16 & 0xFF) / 255f; diff --git a/src/main/java/com/goby56/wakes/render/WakeRenderer.java b/src/main/java/com/goby56/wakes/render/WakeRenderer.java index 835e5d6..c8c84ff 100644 --- a/src/main/java/com/goby56/wakes/render/WakeRenderer.java +++ b/src/main/java/com/goby56/wakes/render/WakeRenderer.java @@ -27,6 +27,7 @@ Resolution.THIRTYTWO, new WakeTexture(Resolution.THIRTYTWO.res) @Override public void afterTranslucent(WorldRenderContext context) { if (WakesClient.CONFIG_INSTANCE.disableMod) { + WakesDebugInfo.quadsRendered = 0; return; } @@ -35,9 +36,7 @@ public void afterTranslucent(WorldRenderContext context) { WakeHandler wakeHandler = WakeHandler.getInstance(); if (wakeHandler == null || wakeHandler.resolutionResetScheduled) return; - long tCulling = System.nanoTime(); ArrayList bricks = wakeHandler.getVisible(context.frustum(), Brick.class); - WakesDebugInfo.cullingTime.add(System.nanoTime() - tCulling); Matrix4f matrix = context.matrixStack().peek().getPositionMatrix(); RenderSystem.enableBlend(); diff --git a/src/main/java/com/goby56/wakes/simulation/WakeHandler.java b/src/main/java/com/goby56/wakes/simulation/WakeHandler.java index 4ce1a33..dde8548 100644 --- a/src/main/java/com/goby56/wakes/simulation/WakeHandler.java +++ b/src/main/java/com/goby56/wakes/simulation/WakeHandler.java @@ -54,11 +54,9 @@ public void tick() { QuadTree tree = this.trees[i]; if (tree != null) { tree.tick(); - long tInsertion = System.nanoTime(); while (pendingNodes.peek() != null) { tree.insert(pendingNodes.poll()); } - WakesDebugInfo.insertionTime = System.nanoTime() - tInsertion; } } if (this.resolutionResetScheduled) {