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()
.map(pos -> pos.add(renderedPosition))
.collect(Collectors.toList()))
.colored(0x999999)
.disableNormals()
.lineWidth(1 / 32f)
.withFaceTexture(AllSpecialTextures.CHECKERED);

View file

@ -124,6 +124,13 @@ public class SchematicHandler {
if (!active && !present)
return;
if (active) {
ms.push();
currentTool.getTool()
.renderTool(ms, buffer, light, overlay);
ms.pop();
}
ms.push();
transformation.applyGLTransformations(ms);
renderer.render(ms, buffer);
@ -132,12 +139,6 @@ public class SchematicHandler {
.renderOnSchematic(ms, buffer, light, overlay);
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) {

View file

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

View file

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

View file

@ -21,8 +21,6 @@ public class RotateTool extends PlacementToolBase {
@Override
public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
super.renderOnSchematic(ms, buffer, light, overlay);
AxisAlignedBB bounds = schematicHandler.getBounds();
double height = bounds.getYSize() + Math.max(20, bounds.getYSize());
Vec3d center = bounds.getCenter()
@ -32,12 +30,14 @@ public class RotateTool extends PlacementToolBase {
Vec3d end = center.add(0, height / 2, 0);
line.getParams()
.colored(0x4d80e4)
.disableCull()
.disableNormals()
.colored(0xdddddd)
.lineWidth(1 / 16f);
line.set(start, end)
.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);
}
outline.getParams()
.colored(0x6886c5)
.withFaceTexture(AllSpecialTextures.CHECKERED)
.lineWidth(1 / 32f)
.disableCull();
outline.render(ms, buffer);
outline.getParams()
.withFaceTextures(null, null);
.clearTextures();
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.vertex.IVertexBuilder;
import com.simibubi.create.AllSpecialTextures;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -40,6 +41,9 @@ public class AABBOutline extends Outline {
Vec3d XyZ = new Vec3d(bb.maxX, bb.minY, bb.maxZ);
Vec3d xYZ = new Vec3d(bb.minX, 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;
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,
Vec3d p3, Vec3d p4, boolean noCull) {
if (!params.faceTexture.isPresent())
return;
ResourceLocation faceTexture = params.faceTexture.get().getLocation();
ResourceLocation faceTexture = params.faceTexture.get()
.getLocation();
if (direction == params.getHighlightedFace() && params.hightlightedFaceTexture.isPresent())
faceTexture = params.hightlightedFaceTexture.get().getLocation();
faceTexture = params.hightlightedFaceTexture.get()
.getLocation();
RenderType translucentType =
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);
//TODO noCull has no effect
public void renderAACuboidLine(MatrixStack ms, IRenderTypeBuffer buffer, Vec3d start, Vec3d end, boolean noCull) {
ResourceLocation tex = AllSpecialTextures.BLANK.getLocation();
IVertexBuilder builder =