finish bar graph implementation
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
f702e8e7e0
commit
7bf26fb47a
@ -34,6 +34,12 @@ public class ImGuiBarPlot implements ImGuiElement {
|
||||
double[] xs = IntStream.range(0, dataPoints.size()).mapToDouble(v -> (double)v).toArray();
|
||||
double[] ys = dataPoints.stream().map(v -> v.value).mapToDouble(Double::doubleValue).toArray();
|
||||
ImPlot.plotBars(plotTitle, xs, ys, dataPoints.size(), width, 0);
|
||||
int i = 0;
|
||||
for(ImGuiBarPlotDatapoint point : dataPoints){
|
||||
//coordinates are inside the plot itself, not relative to window
|
||||
ImPlot.plotText(point.label, i, 1, true);
|
||||
i++;
|
||||
}
|
||||
ImPlot.endPlot();
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ public class ImGuiWindowMacros {
|
||||
//server sim time graph
|
||||
private static ImGuiWindow serverFrametimeWindow;
|
||||
private static ImGuiBarPlot serverFrametimePlot;
|
||||
private static double serverFrametimeTrackerStorage = 0;
|
||||
|
||||
/**
|
||||
* Initializes imgui windows
|
||||
@ -101,12 +102,19 @@ public class ImGuiWindowMacros {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an amount to a single bar in the server frametime graph
|
||||
* @param valueName The value to add to
|
||||
* @param amountToAdd The amount to add
|
||||
* Starts a tracker for server frametime for a given method
|
||||
*/
|
||||
public static void addToServerFrametimeValue(String valueName, double amountToAdd){
|
||||
serverFrametimePlot.addToDatapoint(valueName, amountToAdd);
|
||||
public static void startServerFrametimeTrackerFlame(double startValue){
|
||||
serverFrametimeTrackerStorage = startValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes tracking a single run of a specific method
|
||||
* @param valueName The name of the method
|
||||
* @param endValue the end time that the method finished on
|
||||
*/
|
||||
public static void clockServerFrametimeTrackerFlame(String valueName, double endValue){
|
||||
serverFrametimePlot.addToDatapoint(valueName, endValue - serverFrametimeTrackerStorage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,6 +7,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.Scene;
|
||||
import electrosphere.entity.types.hitbox.HitboxManager;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindowMacros;
|
||||
import electrosphere.server.datacell.interfaces.DataCellManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -155,10 +156,15 @@ public class Realm {
|
||||
* Tells the data cell manager to simulate all loaded cells
|
||||
*/
|
||||
protected void simulate(){
|
||||
ImGuiWindowMacros.clearServerFrametime();
|
||||
//simulate bullet physics engine step
|
||||
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
||||
collisionEngine.simulatePhysics(Main.deltaFrames);
|
||||
ImGuiWindowMacros.clockServerFrametimeTrackerFlame("physics", System.currentTimeMillis());
|
||||
//main simulation
|
||||
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
||||
dataCellManager.simulate();
|
||||
ImGuiWindowMacros.clockServerFrametimeTrackerFlame("simulate", System.currentTimeMillis());
|
||||
//data cell manager update misc variables (player positions, unload not-in-use cells)
|
||||
if(dataCellManager != null){
|
||||
dataCellManager.unloadPlayerlessChunks();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user