Skip to content

Commit

Permalink
cleanup + flood fill 2
Browse files Browse the repository at this point in the history
flood fill 2 seems to work fine and cuts texturing time in half from what flood fill 3 did
  • Loading branch information
Goby56 committed Aug 24, 2024
1 parent fb098a0 commit eeb13e3
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/goby56/wakes/config/WakesConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/goby56/wakes/config/YACLIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,22 @@

public class WakesDebugInfo {
public static double nodeLogicTime = 0;
public static double insertionTime = 0;
public static double texturingTime = 0;
public static ArrayList<Long> cullingTime = new ArrayList<>();
public static ArrayList<Long> renderingTime = new ArrayList<>(); // Frames averaged each tick
public static int quadsRendered = 0;
public static int nodeCount = 0;

public static void reset() {
nodeCount = 0;
nodeLogicTime = 0;
insertionTime = 0;
texturingTime = 0;
cullingTime = new ArrayList<>();
renderingTime = new ArrayList<>();
}

public static void show(CallbackInfoReturnable<List<String>> 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()));
}
}
7 changes: 5 additions & 2 deletions src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,7 +16,11 @@ public abstract class DebugHudMixin {
@Inject(at = @At("RETURN"), method = "getLeftText")
protected void getLeftText(CallbackInfoReturnable<List<String>> info) {
if (WakesClient.CONFIG_INSTANCE.showDebugInfo) {
WakesDebugInfo.show(info);
if (WakesClient.CONFIG_INSTANCE.disableMod) {
info.getReturnValue().add("[Wakes] Mod disabled!");
} else {
WakesDebugInfo.show(info);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static <T extends Entity> 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;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/goby56/wakes/render/WakeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -35,9 +36,7 @@ public void afterTranslucent(WorldRenderContext context) {
WakeHandler wakeHandler = WakeHandler.getInstance();
if (wakeHandler == null || wakeHandler.resolutionResetScheduled) return;

long tCulling = System.nanoTime();
ArrayList<Brick> bricks = wakeHandler.getVisible(context.frustum(), Brick.class);
WakesDebugInfo.cullingTime.add(System.nanoTime() - tCulling);

Matrix4f matrix = context.matrixStack().peek().getPositionMatrix();
RenderSystem.enableBlend();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/goby56/wakes/simulation/WakeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit eeb13e3

Please sign in to comment.