foliage debug tooling
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-29 17:03:54 -04:00
parent 4d9759c6ec
commit 782b31954e
4 changed files with 52 additions and 8 deletions

View File

@ -1594,6 +1594,7 @@ Unhashing ivec hashed keys in chunk caches
Unit tests for unhash func
Filter client entity list to terrain
Fix server loading full res chunks from disk as strided chunks
Debugging tooling for foliage manager

View File

@ -176,6 +176,11 @@ public class FoliageCell {
*/
int generationAlertCount = 0;
/**
* If set to true, FoliageCellManager should debug when evaluating this cell
*/
boolean tripDebugFlag = false;
/**
* Private constructor
@ -468,5 +473,34 @@ public class FoliageCell {
}
}
@Override
public String toString(){
return "" +
"worldPos: " + worldPos + "\n" +
"voxelPos: " + voxelPos + "\n" +
"lod: " + lod + "\n" +
"modelEntity: " + modelEntity + "\n" +
"hasRequested: " + hasRequested + "\n" +
"hasGenerated: " + hasGenerated + "\n" +
"homogenous: " + homogenous + "\n" +
"";
}
/**
* Sets whether this cell should trip the debug flag on its next evaluation or not
* @param trip true to debug on next evaluation, false otherwise
*/
public void setTripDebug(boolean trip){
this.tripDebugFlag = trip;
}
/**
* Gets whether this cell should trigger debugging on next evaluation or not
* @return true to debug on next evaluation, false otherwise
*/
public boolean getTripDebug(){
return tripDebugFlag;
}
}

View File

@ -226,17 +226,20 @@ public class FoliageCellManager {
*/
private boolean recursivelyUpdateCells(WorldOctTreeNode<FoliageCell> node, Vector3i absVoxelPos, Map<WorldOctTreeNode<FoliageCell>,Boolean> evaluationMap, int minLeafLod, int distCache){
boolean updated = false;
if(node.getData().getTripDebug()){
node.getData().setTripDebug(false);
}
//breakpoint handling
if(this.breakPoints.size() > 0){
for(Vector3i breakpoint : breakPoints){
if(GeomUtils.approxMinDistanceAABB(breakpoint, node.getMinBound(), node.getMaxBound()) == 0){
System.out.println("Break at " + breakpoint + " " + node.getLevel());
System.out.println(" " + node.getMinBound() + " " + node.getMaxBound());
System.out.println(" Generated: " + node.getData().hasGenerated());
System.out.println(" Homogenous: " + node.getData().isHomogenous());
System.out.println(" Leaf: " + node.isLeaf());
System.out.println(" Cached min dist: " + node.getData().cachedMinDistance);
System.out.println(" Actual min dist: " + GeomUtils.approxMinDistanceAABB(breakpoint, node.getMinBound(), node.getMaxBound()));
LoggerInterface.loggerEngine.WARNING("Break at " + breakpoint + " " + node.getLevel());
LoggerInterface.loggerEngine.WARNING(" " + node.getMinBound() + " " + node.getMaxBound());
LoggerInterface.loggerEngine.WARNING(" Generated: " + node.getData().hasGenerated());
LoggerInterface.loggerEngine.WARNING(" Homogenous: " + node.getData().isHomogenous());
LoggerInterface.loggerEngine.WARNING(" Leaf: " + node.isLeaf());
LoggerInterface.loggerEngine.WARNING(" Cached min dist: " + node.getData().cachedMinDistance);
LoggerInterface.loggerEngine.WARNING(" Actual min dist: " + GeomUtils.approxMinDistanceAABB(breakpoint, node.getMinBound(), node.getMaxBound()));
}
}
}

View File

@ -5,6 +5,7 @@ import org.joml.Vector3i;
import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.client.terrain.cache.ChunkData;
import electrosphere.client.terrain.cells.DrawCell;
import electrosphere.client.terrain.foliage.FoliageCell;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.ui.imgui.ImGuiWindow;
@ -36,7 +37,7 @@ public class ImGuiDrawCell {
drawCellWindow.setCallback(new ImGuiWindowCallback() {
@Override
public void exec() {
if(ImGui.button("Debug camera position")){
if(ImGui.button("Debug DrawCell at camera position")){
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
DrawCell cell = Globals.clientDrawCellManager.getDrawCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
LoggerInterface.loggerEngine.WARNING("" + cell);
@ -62,6 +63,11 @@ public class ImGuiDrawCell {
LoggerInterface.loggerEngine.WARNING("Chunk not in cache! " + cameraWorldPos);
}
}
if(ImGui.button("Debug FoliageCell at camera position")){
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
LoggerInterface.loggerEngine.WARNING("" + cell);
}
if(ImGui.button("Request terrain at camera position")){
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
Globals.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 1);