Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void write(
private boolean debugMode = false;
private boolean promiscuous = false;
private boolean clearAllOnKey = false;
private boolean hideObstructedLines = false;

private Colour cuboidGridColor = ConfiguredColour.CUBOIDGRID.getDefault();
private Colour cuboidEdgeColor = ConfiguredColour.CUBOIDBOX.getDefault();
Expand Down Expand Up @@ -143,6 +144,10 @@ public void setClearAllOnKey(boolean clearAllOnKey) {
this.clearAllOnKey = clearAllOnKey;
}

public boolean isHideObstructedLines() {
return this.hideObstructedLines;
}

private static Path getConfigFile() {
return FabricLoader.getInstance().getConfigDir().resolve(CUIConfiguration.CONFIG_FILE_NAME);
}
Expand All @@ -168,6 +173,7 @@ public static CUIConfiguration create() {
configArray.put("debugMode", config.debugMode);
configArray.put("promiscuous", config.promiscuous);
configArray.put("clearAllOnKey", config.clearAllOnKey);
configArray.put("hideObstructedLines", config.hideObstructedLines);

configArray.put("cuboidGridColor", config.cuboidGridColor);
configArray.put("cuboidEdgeColor", config.cuboidEdgeColor);
Expand Down Expand Up @@ -203,6 +209,7 @@ public void configChanged() {
debugMode = (Boolean) configArray.get("debugMode");
promiscuous = (Boolean) configArray.get("promiscuous");
clearAllOnKey = (Boolean) configArray.get("clearAllOnKey");
hideObstructedLines = (Boolean) configArray.get("hideObstructedLines");

cuboidGridColor = (Colour) configArray.get("cuboidGridColor");
cuboidEdgeColor = (Colour) configArray.get("cuboidEdgeColor");
Expand All @@ -223,7 +230,7 @@ public void configChanged() {

public Object getDefaultValue(String text) {
return switch (text) {
case "debugMode", "promiscuous", "clearAllOnKey" -> false;
case "debugMode", "promiscuous", "clearAllOnKey", "hideObstructedLines" -> false;
case "cuboidGridColor" -> ConfiguredColour.CUBOIDGRID.getDefault();
case "cuboidEdgeColor" -> ConfiguredColour.CUBOIDBOX.getDefault();
case "cuboidFirstPointColor" -> ConfiguredColour.CUBOIDPOINT1.getDefault();
Expand Down Expand Up @@ -266,6 +273,7 @@ public Object getDefaultValue(String text) {
case "debugMode" -> "worldeditcui.options.debugMode";
case "promiscuous" -> "worldeditcui.options.compat.spammy";
case "clearAllOnKey" -> "worldeditcui.options.extra.clearall";
case "hideObstructedLines" -> "worldeditcui.options.extra.hideObstructedLines";
case "cuboidGridColor" -> "worldeditcui.color.cuboidgrid";
case "cuboidEdgeColor" -> "worldeditcui.color.cuboidedge";
case "cuboidFirstPointColor" -> "worldeditcui.color.cuboidpoint1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public void onRender(final float partialTicks) {
}
final ProfilerFiller profiler = Profiler.get();
profiler.push("worldeditcui");
this.ctx.init(new Vector3(this.minecraft.gameRenderer.mainCamera().position()), partialTicks, sink);
this.ctx.init(
new Vector3(this.minecraft.gameRenderer.mainCamera().position()),
partialTicks,
sink,
this.controller.getConfiguration().isHideObstructedLines()
);
final GpuBufferSlice fogStart = RenderSystem.getShaderFog();
RenderSystem.setShaderFog(this.minecraft.gameRenderer.fogRenderer.getBuffer(FogRenderer.FogMode.NONE));
final Matrix4fStack poseStack = RenderSystem.getModelViewStack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public final class CUIRenderContext implements RenderSink {
private Vector3 cameraPos;
private float dt;
private RenderSink delegateSink;
private boolean hideObstructedLines;

public Vector3 cameraPos() {
return this.cameraPos;
Expand Down Expand Up @@ -54,10 +55,11 @@ public void withCameraAt(final Vector3 pos, final Consumer<CUIRenderContext> act
}
}

void init(final Vector3 cameraPos, final float dt, final RenderSink sink) {
void init(final Vector3 cameraPos, final float dt, final RenderSink sink, final boolean hideObstructedLines) {
this.cameraPos = cameraPos;
this.dt = dt;
this.delegateSink = sink;
this.hideObstructedLines = hideObstructedLines;
}

/**
Expand All @@ -66,6 +68,7 @@ void init(final Vector3 cameraPos, final float dt, final RenderSink sink) {
void reset() {
this.cameraPos = null;
this.delegateSink = null;
this.hideObstructedLines = false;
}

// RenderSink delegation
Expand All @@ -84,6 +87,9 @@ public CUIRenderContext color(final Colour colour) {

@Override
public boolean apply(final LineStyle line, final RenderStyle.RenderType type) {
if (this.hideObstructedLines && line.renderType == RenderStyle.RenderType.HIDDEN) {
return false;
}
return this.delegateSink.apply(line, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public enum RenderType
/**
* Render type for "hidden" lines (under world geometry)
*/
HIDDEN(CompareOp.GREATER_THAN),
HIDDEN(CompareOp.LESS_THAN),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So while it looks fine to me IMO, is there a reason these are being changed? We had a fair few reports that alongside MC's render sink system the lines became hard to see in a lot of cases, and the changes being done to this PR here revert that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick response.

As stated here in the official Minecraft 26.2 changelog under the technical changes section, "Rendering now uses a reversed depth buffer" which means the CompareOps also had to be reversed in this case. You can test it out by swapping them back around. The lines in front of the terrain will then become less opaque while the ones hidden behind other objects will keep their full opacity.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already accounted for in the 26.2 update (or at least, using the values that visually appeared identical to the 26.1 values). However it does visually appear fine with the ones in this change, so I'm happy to approve it -- just mildly concerned we'll have people asking us to fix things again


/**
* Render type for visible lines (over world geometry)
*/
VISIBLE(CompareOp.LESS_THAN_OR_EQUAL);
VISIBLE(CompareOp.GREATER_THAN_OR_EQUAL);

final CompareOp depthTest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static Map<RenderStyle.RenderType, BatchedRenderSink.VariantSet> createV
private static BatchedRenderSink.RenderTarget createQuadsTarget(final String idSuffix, final CompareOp depthTest) {
final RenderPipeline pipeline = RenderPipeline.builder(QUADS_SNIPPET)
.withLocation(Identifier.fromNamespaceAndPath("worldeditcui", "pipeline/quads_" + idSuffix))
.withDepthStencilState(new DepthStencilState(depthTest, true))
.withDepthStencilState(new DepthStencilState(depthTest, false))
.build();
if (IRIS_LOADED) {
IrisPipelineIntegration.registerQuads(pipeline);
Expand All @@ -105,7 +105,7 @@ private static BatchedRenderSink.RenderTarget createQuadsTarget(final String idS
private static BatchedRenderSink.RenderTarget createLinesTarget(final String idSuffix, final CompareOp depthTest) {
final RenderPipeline pipeline = RenderPipeline.builder(LINES_SNIPPET)
.withLocation(Identifier.fromNamespaceAndPath("worldeditcui", "pipeline/lines_" + idSuffix))
.withDepthStencilState(new DepthStencilState(depthTest, true))
.withDepthStencilState(new DepthStencilState(depthTest, false))
.build();
if (IRIS_LOADED) {
IrisPipelineIntegration.registerLines(pipeline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"worldeditcui.options.extra.title": "Advanced Options",
"worldeditcui.options.extra.clearall": "Clear displayed regions",
"worldeditcui.options.extra.clearall.tooltip": "Clear all displayed regions when %s (%s) is pressed",
"worldeditcui.options.extra.hideObstructedLines": "Hide obstructed lines",
"worldeditcui.options.extra.hideObstructedLines.tooltip": "Do not render selection lines behind blocks or other world geometry",
"worldeditcui.options.done": "Done",
"worldeditcui.options.debugMode": "Debug Mode",
"worldeditcui.options.debugMode.tooltip": "Enable advanced Debug Mode"
Expand Down
Loading