From 22d87dcb8ff154811e3ac0576d20029ead5407d3 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 19 Jan 2025 19:57:36 -0500 Subject: [PATCH] debug logging work --- .../client/ui/menu/debug/ImGuiFluidMonitor.java | 16 +++++++++++++++- .../server/fluid/manager/ServerFluidChunk.java | 17 +++++++++++++++++ .../fluid/manager/ServerFluidManager.java | 17 +++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiFluidMonitor.java b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiFluidMonitor.java index da18a165..cc6caa5b 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiFluidMonitor.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiFluidMonitor.java @@ -36,13 +36,14 @@ public class ImGuiFluidMonitor { public void exec() { if(ImGui.collapsingHeader("Server Data")){ ServerFluidManager fluidManager = Globals.playerManager.getPlayerRealm(Globals.clientPlayer).getServerWorldData().getServerFluidManager(); - //audio engine details + //server engine details ImGui.text("Fluids Debug"); ImGui.text("State: " + (fluidManager.getSimulate() ? "on" : "off")); if(ImGui.button("Toggle Simulation")){ fluidManager.setSimulate(!fluidManager.getSimulate()); } ImGui.text("Broadcast Size (This Frame): " + fluidManager.getBroadcastSize()); + ImGui.text("Active Chunk Count (This Frame): " + fluidManager.getActiveChunkCount()); ImGui.text("Normalization Ratio: " + ServerFluidChunk.getNormalizationRatio()); ImGui.text("Mass: " + ServerFluidChunk.getMassCount()); @@ -129,6 +130,19 @@ public class ImGuiFluidMonitor { System.out.println("\n\n\n"); + System.out.println("Divergence"); + for(int y = 0; y < 3; y++){ + System.out.println("Layer " + y); + for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){ + for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){ + System.out.print(chunk.getDivergence(x, y, z) + ", "); + } + System.out.println(); + } + } + System.out.println("\n\n\n"); + + System.out.println("Pressure"); for(int y = 0; y < 3; y++){ System.out.println("Layer " + y); diff --git a/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java b/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java index c447c0cd..3ad9af5a 100644 --- a/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java +++ b/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java @@ -116,6 +116,11 @@ public class ServerFluidChunk { */ FloatBuffer pressureCache; + /** + * The divergence cache + */ + FloatBuffer divergenceCache; + /** * The array of all adjacent weight buffers for the fluid sim */ @@ -285,6 +290,7 @@ public class ServerFluidChunk { this.velocityY = this.bVelocityY[CENTER_BUFF].asFloatBuffer(); this.velocityZ = this.bVelocityZ[CENTER_BUFF].asFloatBuffer(); this.bounds = this.bBounds[CENTER_BUFF].asFloatBuffer(); + this.divergenceCache = this.bDivergenceCache[CENTER_BUFF].asFloatBuffer(); this.pressureCache = this.bPressureCache[CENTER_BUFF].asFloatBuffer(); } @@ -574,6 +580,17 @@ public class ServerFluidChunk { return pressureCache.get(this.IX(x,y,z)); } + /** + * Gets the divergence at a point + * @param x The x coordinate + * @param y The y coordinate + * @param z The z coordinate + * @return The divergence + */ + public float getDivergence(int x, int y, int z){ + return divergenceCache.get(this.IX(x,y,z)); + } + /** * Gets the inddex into the buffer * @param x The x position diff --git a/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java b/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java index 2c130c96..30fba418 100644 --- a/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java +++ b/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java @@ -110,6 +110,12 @@ public class ServerFluidManager { * The number of chunks broadcast this frame */ int broadcastSize = 0; + + @Exclude + /** + * The number of chunks active this frame + */ + int activeChunkCount = 0; /** @@ -319,6 +325,9 @@ public class ServerFluidManager { this.serverFluidSimulator.simulate(this.simulationQueue,this.broadcastQueue); } } + + //set active chunk size + this.activeChunkCount = this.simulationQueue.size(); //clear both queues while(this.simulationQueue.size() > 0){ @@ -440,5 +449,13 @@ public class ServerFluidManager { return broadcastSize; } + /** + * The number of chunks active this frame + * @return The number of chunks active this frame + */ + public int getActiveChunkCount(){ + return this.activeChunkCount; + } + }