Add different debug modes (off, detail, detail_wireframe)
This commit is contained in:
@@ -221,7 +221,7 @@ public class LodBufferBuilder
|
||||
adjData[1][z] = lodDim.getData(adjPos);
|
||||
}
|
||||
LodConfig.CLIENT.lodTemplate.get().template.addLodToBuffer(currentBuffer, playerBlockPos, lodData, adjData,
|
||||
posToRender, renderer.debugging);
|
||||
posToRender, renderer.previousDebugMode);
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
*/
|
||||
package com.seibel.lod.builders.lodTemplates;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.objects.LevelPos.LevelPos;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -35,7 +33,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
public abstract class AbstractLodTemplate
|
||||
{
|
||||
public abstract void addLodToBuffer(BufferBuilder buffer, BlockPos playerBlockPos, short[] data, short[][][] adjData,
|
||||
LevelPos levelPos, boolean debugging);
|
||||
LevelPos levelPos, DebugMode debugging);
|
||||
|
||||
/**
|
||||
* add the given position and color to the buffer
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.seibel.lod.builders.lodTemplates;
|
||||
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.enums.ShadingMode;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.objects.DataPoint;
|
||||
@@ -47,7 +48,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
|
||||
@Override
|
||||
public void addLodToBuffer(BufferBuilder buffer, BlockPos playerBlockPos, short[] data, short[][][] adjData,
|
||||
LevelPos levelPos, boolean debugging)
|
||||
LevelPos levelPos, DebugMode debugging)
|
||||
{
|
||||
AxisAlignedBB bbox;
|
||||
|
||||
@@ -63,7 +64,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
levelPos.posZ * width);
|
||||
|
||||
int color = DataPoint.getColor(data);
|
||||
if (LodConfig.CLIENT.debugMode.get())
|
||||
if (debugging != DebugMode.OFF)
|
||||
{
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[levelPos.detailLevel].getRGB();
|
||||
}
|
||||
@@ -75,21 +76,6 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void addLodToBuffer(BufferBuilder buffer,
|
||||
* LodQuadTreeDimension lodDim, LodQuadTreeNode lod, double xOffset, double
|
||||
* yOffset, double zOffset, boolean debugging) { AxisAlignedBB bbox;
|
||||
*
|
||||
* bbox = generateBoundingBox( lod.getLodDataPoint().height,
|
||||
* lod.getLodDataPoint().depth, lod.width, xOffset, yOffset, zOffset);
|
||||
*
|
||||
* Color color = lod.getLodDataPoint().color;
|
||||
*
|
||||
* if (bbox != null) { addBoundingBoxToBuffer(buffer, bbox, color); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
private AxisAlignedBB generateBoundingBox(int height, int depth, int width, double xOffset, double yOffset, double zOffset)
|
||||
{
|
||||
// don't add an LOD if it is empty
|
||||
@@ -121,25 +107,14 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
// the side colors are different because
|
||||
// when using fast lighting in Minecraft the north/south
|
||||
// and east/west sides are different in a similar way
|
||||
/*
|
||||
int northSouthDarkenAmount = -25;
|
||||
int eastWestDarkenAmount = -50;
|
||||
int bottomDarkenAmount = -75;
|
||||
|
||||
northSouthColor = ColorUtil.applyShade(c,northSouthDarkenAmount);
|
||||
eastWestColor = ColorUtil.applyShade(c,eastWestDarkenAmount);
|
||||
bottomColor = ColorUtil.applyShade(c,bottomDarkenAmount);*/
|
||||
/*
|
||||
float northSouthDarkenAmount = 0.80f;
|
||||
float eastWestDarkenAmount = 0.60f;
|
||||
float bottomDarkenAmount = 0.40f;*/
|
||||
/**TODO OPTIMIZE THIS STEP*/
|
||||
topColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.UP, true));
|
||||
bottomColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.DOWN, true));
|
||||
northColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.NORTH, true));
|
||||
southColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.SOUTH, true));
|
||||
westColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.WEST, true));
|
||||
eastColor = ColorUtil.applyShade(c, Minecraft.getInstance().level.getShade(Direction.EAST, true));
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
topColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.UP, true));
|
||||
bottomColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.DOWN, true));
|
||||
northColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.NORTH, true));
|
||||
southColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.SOUTH, true));
|
||||
westColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.WEST, true));
|
||||
eastColor = ColorUtil.applyShade(c, mc.level.getShade(Direction.EAST, true));
|
||||
}
|
||||
|
||||
// apply the user specified saturation and brightness
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.seibel.lod.builders.lodTemplates;
|
||||
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.objects.LevelPos.LevelPos;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -35,7 +36,7 @@ public class DynamicLodTemplate extends AbstractLodTemplate
|
||||
{
|
||||
@Override
|
||||
public void addLodToBuffer(BufferBuilder buffer, BlockPos playerBlockPos, short[] data, short[][][] adjData,
|
||||
LevelPos levelPos, boolean debugging)
|
||||
LevelPos levelPos, DebugMode debugging)
|
||||
{
|
||||
System.err.println("DynamicLodTemplate not implemented!");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.seibel.lod.builders.lodTemplates;
|
||||
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.objects.LevelPos.LevelPos;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -33,7 +34,7 @@ public class TriangularLodTemplate extends AbstractLodTemplate
|
||||
{
|
||||
@Override
|
||||
public void addLodToBuffer(BufferBuilder buffer, BlockPos playerBlockPos, short[] data, short[][][] adjData,
|
||||
LevelPos levelPos, boolean debugging)
|
||||
LevelPos levelPos, DebugMode debugging)
|
||||
{
|
||||
System.err.println("DynamicLodTemplate not implemented!");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of the LOD Mod, licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.enums;
|
||||
|
||||
/**
|
||||
* off, detail, detail wireframe
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 8-28-2021
|
||||
*/
|
||||
public enum DebugMode
|
||||
{
|
||||
OFF,
|
||||
|
||||
/** LOD colors are based on their detail */
|
||||
SHOW_DETAIL,
|
||||
|
||||
/** LOD colors are based on their detail, and draws in wireframe. */
|
||||
SHOW_DETAIL_WIREFRAME;
|
||||
|
||||
/** used when cycling through the different modes */
|
||||
private DebugMode next;
|
||||
static
|
||||
{
|
||||
OFF.next = SHOW_DETAIL;
|
||||
SHOW_DETAIL.next = SHOW_DETAIL_WIREFRAME;
|
||||
SHOW_DETAIL_WIREFRAME.next = OFF;
|
||||
}
|
||||
|
||||
/** returns the next debug mode */
|
||||
public DebugMode getNext()
|
||||
{
|
||||
return this.next;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||
import com.seibel.lod.ModInfo;
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.enums.DistanceCalculatorType;
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.FogDistance;
|
||||
@@ -56,7 +57,7 @@ public class LodConfig
|
||||
|
||||
public ForgeConfigSpec.EnumValue<FogDrawOverride> fogDrawOverride;
|
||||
|
||||
public ForgeConfigSpec.BooleanValue debugMode;
|
||||
public ForgeConfigSpec.EnumValue<DebugMode> debugMode;
|
||||
|
||||
public ForgeConfigSpec.EnumValue<LodTemplate> lodTemplate;
|
||||
|
||||
@@ -111,10 +112,11 @@ public class LodConfig
|
||||
|
||||
debugMode = builder
|
||||
.comment("\n\n"
|
||||
+ " If false the LODs will draw with their normal colors. \n"
|
||||
+ " If true LODs colors will be based on their detail \n"
|
||||
+ " level. \n")
|
||||
.define("debugMode", false);
|
||||
+ " This can be changed using the F4 key. \n"
|
||||
+ " " + DebugMode.OFF.toString() + ": LODs will draw with their normal colors. \n"
|
||||
+ " " + DebugMode.SHOW_DETAIL.toString() + ": LOD colors will be based on their detail. \n"
|
||||
+ " " + DebugMode.SHOW_DETAIL_WIREFRAME.toString() + ": LOD colors will be based on their detail, drawn with wireframe. \n")
|
||||
.defineEnum("debugMode", DebugMode.OFF);
|
||||
|
||||
lodTemplate = builder
|
||||
.comment("\n\n"
|
||||
|
||||
@@ -259,7 +259,7 @@ public class ClientProxy
|
||||
//f4 is key 293, the 1 action mean that the key just got pressed
|
||||
if(event.getKey() == 293 && event.getAction() == 1)
|
||||
{
|
||||
LodConfig.CLIENT.debugMode.set(!LodConfig.CLIENT.debugMode.get());
|
||||
LodConfig.CLIENT.debugMode.set(LodConfig.CLIENT.debugMode.get().getNext());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.builders.LodBufferBuilder;
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.enums.FogDistance;
|
||||
import com.seibel.lod.enums.FogDrawOverride;
|
||||
import com.seibel.lod.enums.FogQuality;
|
||||
@@ -98,7 +99,7 @@ public class LodRenderer
|
||||
* If true the LODs colors will be replaced with
|
||||
* a checkerboard, this can be used for debugging.
|
||||
*/
|
||||
public boolean debugging = false;
|
||||
public DebugMode previousDebugMode = DebugMode.OFF;
|
||||
|
||||
private Minecraft mc;
|
||||
private GameRenderer gameRender;
|
||||
@@ -216,9 +217,9 @@ public class LodRenderer
|
||||
}
|
||||
|
||||
// did the user change the debug setting?
|
||||
if (LodConfig.CLIENT.debugMode.get() != debugging)
|
||||
if (LodConfig.CLIENT.debugMode.get() != previousDebugMode)
|
||||
{
|
||||
debugging = LodConfig.CLIENT.debugMode.get();
|
||||
previousDebugMode = LodConfig.CLIENT.debugMode.get();
|
||||
regen = true;
|
||||
}
|
||||
|
||||
@@ -275,19 +276,15 @@ public class LodRenderer
|
||||
//===========================//
|
||||
|
||||
// set the required open GL settings
|
||||
if(LodConfig.CLIENT.debugMode.get()){
|
||||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
|
||||
}else{
|
||||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
|
||||
}
|
||||
//GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
|
||||
//GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (LodConfig.CLIENT.debugMode.get() == DebugMode.SHOW_DETAIL_WIREFRAME)
|
||||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
|
||||
else
|
||||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
//GL11.glEnable(GL11.GL_BLEND);
|
||||
//GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// disable the lights Minecraft uses
|
||||
GL11.glDisable(GL11.GL_LIGHT0);
|
||||
|
||||
Reference in New Issue
Block a user