Fixed outliners' culling issue

This commit is contained in:
simibubi 2020-05-27 13:12:57 +02:00
parent 68b656c6be
commit 8d8f96c778
8 changed files with 33 additions and 23 deletions

View file

@ -35,6 +35,7 @@ public class TerrainZapperRenderHandler {
CreateClient.outliner.showCluster("terrainZapper", shape.stream() CreateClient.outliner.showCluster("terrainZapper", shape.stream()
.map(pos -> pos.add(renderedPosition)) .map(pos -> pos.add(renderedPosition))
.collect(Collectors.toList())) .collect(Collectors.toList()))
.colored(0x999999)
.disableNormals() .disableNormals()
.lineWidth(1 / 32f) .lineWidth(1 / 32f)
.withFaceTexture(AllSpecialTextures.CHECKERED); .withFaceTexture(AllSpecialTextures.CHECKERED);

View file

@ -124,6 +124,13 @@ public class SchematicHandler {
if (!active && !present) if (!active && !present)
return; return;
if (active) {
ms.push();
currentTool.getTool()
.renderTool(ms, buffer, light, overlay);
ms.pop();
}
ms.push(); ms.push();
transformation.applyGLTransformations(ms); transformation.applyGLTransformations(ms);
renderer.render(ms, buffer); renderer.render(ms, buffer);
@ -132,12 +139,6 @@ public class SchematicHandler {
.renderOnSchematic(ms, buffer, light, overlay); .renderOnSchematic(ms, buffer, light, overlay);
ms.pop(); ms.pop();
if (active) {
ms.push();
currentTool.getTool()
.renderTool(ms, buffer, light, overlay);
ms.pop();
}
} }
public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {

View file

@ -69,8 +69,6 @@ public class DeployTool extends PlacementToolBase {
.translateBack(origin); .translateBack(origin);
AABBOutline outline = schematicHandler.getOutline(); AABBOutline outline = schematicHandler.getOutline();
outline.getParams()
.withFaceTexture(AllSpecialTextures.CHECKERED);
outline.render(ms, buffer); outline.render(ms, buffer);
outline.getParams() outline.getParams()
.clearTextures(); .clearTextures();

View file

@ -49,11 +49,11 @@ public class FlipTool extends PlacementToolBase {
@Override @Override
public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderOnSchematic(ms, buffer, light, overlay);
if (!schematicSelected || !selectedFace.getAxis() if (!schematicSelected || !selectedFace.getAxis()
.isHorizontal()) .isHorizontal()) {
super.renderOnSchematic(ms, buffer, light, overlay);
return; return;
}
Direction facing = selectedFace.rotateY(); Direction facing = selectedFace.rotateY();
AxisAlignedBB bounds = schematicHandler.getBounds(); AxisAlignedBB bounds = schematicHandler.getBounds();
@ -68,13 +68,16 @@ public class FlipTool extends PlacementToolBase {
.mul(boundsSize)); .mul(boundsSize));
outline.setBounds(bounds); outline.setBounds(bounds);
AllSpecialTextures tex = AllSpecialTextures.HIGHLIGHT_CHECKERED; AllSpecialTextures tex = AllSpecialTextures.CHECKERED;
outline.getParams() outline.getParams()
.lineWidth(1 / 16f) .lineWidth(1 / 16f)
.disableCull()
.disableNormals() .disableNormals()
.colored(0x4d80e4) .colored(0xdddddd)
.withFaceTextures(tex, tex); .withFaceTextures(tex, tex);
outline.render(ms, buffer); outline.render(ms, buffer);
super.renderOnSchematic(ms, buffer, light, overlay);
} }
} }

View file

@ -21,8 +21,6 @@ public class RotateTool extends PlacementToolBase {
@Override @Override
public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderOnSchematic(ms, buffer, light, overlay);
AxisAlignedBB bounds = schematicHandler.getBounds(); AxisAlignedBB bounds = schematicHandler.getBounds();
double height = bounds.getYSize() + Math.max(20, bounds.getYSize()); double height = bounds.getYSize() + Math.max(20, bounds.getYSize());
Vec3d center = bounds.getCenter() Vec3d center = bounds.getCenter()
@ -32,12 +30,14 @@ public class RotateTool extends PlacementToolBase {
Vec3d end = center.add(0, height / 2, 0); Vec3d end = center.add(0, height / 2, 0);
line.getParams() line.getParams()
.colored(0x4d80e4)
.disableCull() .disableCull()
.disableNormals() .disableNormals()
.colored(0xdddddd)
.lineWidth(1 / 16f); .lineWidth(1 / 16f);
line.set(start, end) line.set(start, end)
.render(ms, buffer); .render(ms, buffer);
super.renderOnSchematic(ms, buffer, light, overlay);
} }
} }

View file

@ -139,10 +139,13 @@ public abstract class SchematicToolBase implements ISchematicTool {
AllKeys.ctrlDown() ? AllSpecialTextures.HIGHLIGHT_CHECKERED : AllSpecialTextures.CHECKERED); AllKeys.ctrlDown() ? AllSpecialTextures.HIGHLIGHT_CHECKERED : AllSpecialTextures.CHECKERED);
} }
outline.getParams() outline.getParams()
.colored(0x6886c5)
.withFaceTexture(AllSpecialTextures.CHECKERED)
.lineWidth(1 / 32f)
.disableCull(); .disableCull();
outline.render(ms, buffer); outline.render(ms, buffer);
outline.getParams() outline.getParams()
.withFaceTextures(null, null); .clearTextures();
ms.pop(); ms.pop();
} }

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility.outliner;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllSpecialTextures;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -41,6 +42,9 @@ public class AABBOutline extends Outline {
Vec3d xYZ = new Vec3d(bb.minX, bb.maxY, bb.maxZ); Vec3d xYZ = new Vec3d(bb.minX, bb.maxY, bb.maxZ);
Vec3d XYZ = new Vec3d(bb.maxX, bb.maxY, bb.maxZ); Vec3d XYZ = new Vec3d(bb.maxX, bb.maxY, bb.maxZ);
// Buffers with no Culling only seem to work right with when this line is present
buffer.getBuffer(RenderType.getEntityCutout(AllSpecialTextures.BLANK.getLocation()));
Vec3d start = xyz; Vec3d start = xyz;
renderAACuboidLine(ms, buffer, start, Xyz, noCull); renderAACuboidLine(ms, buffer, start, Xyz, noCull);
renderAACuboidLine(ms, buffer, start, xYz, noCull); renderAACuboidLine(ms, buffer, start, xYz, noCull);
@ -70,15 +74,16 @@ public class AABBOutline extends Outline {
} }
//TODO noCull has no effect
protected void renderFace(MatrixStack ms, IRenderTypeBuffer buffer, Direction direction, Vec3d p1, Vec3d p2, protected void renderFace(MatrixStack ms, IRenderTypeBuffer buffer, Direction direction, Vec3d p1, Vec3d p2,
Vec3d p3, Vec3d p4, boolean noCull) { Vec3d p3, Vec3d p4, boolean noCull) {
if (!params.faceTexture.isPresent()) if (!params.faceTexture.isPresent())
return; return;
ResourceLocation faceTexture = params.faceTexture.get().getLocation(); ResourceLocation faceTexture = params.faceTexture.get()
.getLocation();
if (direction == params.getHighlightedFace() && params.hightlightedFaceTexture.isPresent()) if (direction == params.getHighlightedFace() && params.hightlightedFaceTexture.isPresent())
faceTexture = params.hightlightedFaceTexture.get().getLocation(); faceTexture = params.hightlightedFaceTexture.get()
.getLocation();
RenderType translucentType = RenderType translucentType =
noCull ? RenderType.getEntityTranslucent(faceTexture) : RenderType.getEntityTranslucentCull(faceTexture); noCull ? RenderType.getEntityTranslucent(faceTexture) : RenderType.getEntityTranslucentCull(faceTexture);

View file

@ -31,7 +31,6 @@ public abstract class Outline {
public abstract void render(MatrixStack ms, IRenderTypeBuffer buffer); public abstract void render(MatrixStack ms, IRenderTypeBuffer buffer);
//TODO noCull has no effect
public void renderAACuboidLine(MatrixStack ms, IRenderTypeBuffer buffer, Vec3d start, Vec3d end, boolean noCull) { public void renderAACuboidLine(MatrixStack ms, IRenderTypeBuffer buffer, Vec3d start, Vec3d end, boolean noCull) {
ResourceLocation tex = AllSpecialTextures.BLANK.getLocation(); ResourceLocation tex = AllSpecialTextures.BLANK.getLocation();
IVertexBuilder builder = IVertexBuilder builder =