diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java index edca8777d..260f344c7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java @@ -60,7 +60,6 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer pair = bufferBuilder.popData(); - BufferBuilder.DrawState state = pair.getFirst(); - - if (state.getCount() > 0) { - state.getVertexFormat() - .startDrawing(MemoryUtil.memAddress(pair.getSecond())); - RenderSystem.drawArrays(state.getMode(), 0, state.getCount()); - state.getVertexFormat() - .endDrawing(); - } - } +// private static void drawBuffer(final BufferBuilder bufferBuilder) { +// Pair pair = bufferBuilder.popData(); +// BufferBuilder.DrawState state = pair.getFirst(); +// +// if (state.getCount() > 0) { +// state.getVertexFormat() +// .startDrawing(MemoryUtil.memAddress(pair.getSecond())); +// RenderSystem.drawArrays(state.getMode(), 0, state.getCount()); +// state.getVertexFormat() +// .endDrawing(); +// } +// } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java index d3d06894b..7a8e1f082 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java @@ -1,8 +1,9 @@ package com.simibubi.create.content.schematics.client; -import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingAngle; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; +import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; @@ -38,7 +39,8 @@ public class SchematicTransformation { xOrigin = bounds.getXSize() / 2f; zOrigin = bounds.getZSize() / 2f; - int r = -(settings.getRotation().ordinal() * 90); + int r = -(settings.getRotation() + .ordinal() * 90); rotation.start(r); Vec3d vec = fromAnchor(anchor); @@ -47,21 +49,22 @@ public class SchematicTransformation { z.start((float) vec.z); } - public void applyGLTransformations() { - float pt = Minecraft.getInstance().getRenderPartialTicks(); + public void applyGLTransformations(MatrixStack ms) { + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); // Translation - RenderSystem.translated(x.get(pt), y.get(pt), z.get(pt)); - + ms.translate(x.get(pt), y.get(pt), z.get(pt)); Vec3d rotationOffset = getRotationOffset(true); // Rotation & Mirror - - RenderSystem.translated(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z); - RenderSystem.rotatef(rotation.get(pt), 0, 1, 0); - RenderSystem.translated(-rotationOffset.x, 0, -rotationOffset.z); - RenderSystem.scaled(scaleFrontBack.get(pt), 1, scaleLeftRight.get(pt)); - RenderSystem.translated(-xOrigin, 0, -zOrigin); + ms.translate(xOrigin, 0, zOrigin); + MatrixStacker.of(ms) + .translate(rotationOffset) + .rotateY(rotation.get(pt)) + .translateBack(rotationOffset); + ms.scale(scaleFrontBack.get(pt), 1, scaleLeftRight.get(pt)); + ms.translate(-xOrigin, 0, -zOrigin); } @@ -81,7 +84,8 @@ public class SchematicTransformation { } public Vec3d toLocalSpace(Vec3d vec) { - float pt = Minecraft.getInstance().getRenderPartialTicks(); + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); Vec3d rotationOffset = getRotationOffset(true); vec = vec.subtract(x.get(pt), y.get(pt), z.get(pt)); @@ -168,7 +172,8 @@ public class SchematicTransformation { } public float getCurrentRotation() { - float pt = Minecraft.getInstance().getRenderPartialTicks(); + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); return rotation.get(pt); } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java index 4efc02352..bcc3c441a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java @@ -1,13 +1,14 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllKeys; +import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.content.schematics.client.SchematicTransformation; +import com.simibubi.create.foundation.utility.MatrixStacker; +import com.simibubi.create.foundation.utility.outliner.AABBOutline; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.math.AxisAlignedBB; @@ -26,7 +27,9 @@ public class DeployTool extends PlacementToolBase { @Override public void updateSelection() { if (schematicHandler.isActive() && selectionRange == -1) { - selectionRange = (int) (schematicHandler.getBounds().getCenter().length() / 2); + selectionRange = (int) (schematicHandler.getBounds() + .getCenter() + .length() / 2); selectionRange = MathHelper.clamp(selectionRange, 1, 100); } selectIgnoreBlocks = AllKeys.ACTIVATE_TOOL.isPressed(); @@ -40,10 +43,9 @@ public class DeployTool extends PlacementToolBase { if (selectedPos == null) return; - RenderSystem.pushMatrix(); - RenderHelper.disableStandardItemLighting(); - RenderSystem.enableBlend(); - float pt = Minecraft.getInstance().getRenderPartialTicks(); + ms.push(); + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); double x = MathHelper.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); double y = MathHelper.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); double z = MathHelper.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z); @@ -56,17 +58,23 @@ public class DeployTool extends PlacementToolBase { int centerZ = (int) center.z; double xOrigin = bounds.getXSize() / 2f; double zOrigin = bounds.getZSize() / 2f; + Vec3d origin = new Vec3d(xOrigin, 0, zOrigin); - RenderSystem.translated(x - centerX, y, z - centerZ); - RenderSystem.translated(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z); - RenderSystem.rotatef(transformation.getCurrentRotation(), 0, 1, 0); - RenderSystem.translated(-rotationOffset.x, 0, -rotationOffset.z); - RenderSystem.translated(-xOrigin, 0, -zOrigin); + ms.translate(x - centerX, y, z - centerZ); + MatrixStacker.of(ms) + .translate(origin) + .translate(rotationOffset) + .rotateY(transformation.getCurrentRotation()) + .translateBack(rotationOffset) + .translateBack(origin); -// schematicHandler.getOutline().setTextures(AllSpecialTextures.CHECKERED, null); -// schematicHandler.getOutline().render(Tessellator.getInstance().getBuffer());TODO -// schematicHandler.getOutline().setTextures(null, null); - RenderSystem.popMatrix(); + AABBOutline outline = schematicHandler.getOutline(); + outline.getParams() + .withFaceTexture(AllSpecialTextures.CHECKERED); + outline.render(ms, buffer); + outline.getParams() + .clearTextures(); + ms.pop(); } @Override @@ -82,16 +90,20 @@ public class DeployTool extends PlacementToolBase { public boolean handleRightClick() { if (selectedPos == null) return super.handleRightClick(); - Vec3d center = schematicHandler.getBounds().getCenter(); + Vec3d center = schematicHandler.getBounds() + .getCenter(); BlockPos target = selectedPos.add(-((int) center.x), 0, -((int) center.z)); ItemStack item = schematicHandler.getActiveSchematicItem(); if (item != null) { - item.getTag().putBoolean("Deployed", true); - item.getTag().put("Anchor", NBTUtil.writeBlockPos(target)); + item.getTag() + .putBoolean("Deployed", true); + item.getTag() + .put("Anchor", NBTUtil.writeBlockPos(target)); } - schematicHandler.getTransformation().moveTo(target); + schematicHandler.getTransformation() + .moveTo(target); schematicHandler.markDirty(); schematicHandler.deploy(); return true; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java index 9c336c2da..da38da662 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java @@ -1,19 +1,20 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.foundation.utility.ColorHelper; -import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.AllSpecialTextures; +import com.simibubi.create.foundation.utility.outliner.AABBOutline; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; public class FlipTool extends PlacementToolBase { + private AABBOutline outline = new AABBOutline(new AxisAlignedBB(BlockPos.ZERO)); + @Override public void init() { super.init(); @@ -38,67 +39,42 @@ public class FlipTool extends PlacementToolBase { } private void mirror() { - if (schematicSelected && selectedFace.getAxis().isHorizontal()) { - schematicHandler.getTransformation().flip(selectedFace.getAxis()); + if (schematicSelected && selectedFace.getAxis() + .isHorizontal()) { + schematicHandler.getTransformation() + .flip(selectedFace.getAxis()); schematicHandler.markDirty(); } } @Override - public void renderToolLocal(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - super.renderToolLocal(ms, buffer, light, overlay); + public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + super.renderOnSchematic(ms, buffer, light, overlay); - if (!schematicSelected || !selectedFace.getAxis().isHorizontal()) + if (!schematicSelected || !selectedFace.getAxis() + .isHorizontal()) return; - GlStateManager.pushMatrix(); - RenderHelper.disableStandardItemLighting(); - GlStateManager.enableBlend(); - Direction facing = selectedFace.rotateY(); - Axis axis = facing.getAxis(); - Vec3d color = ColorHelper.getRGB(0x4d80e4); AxisAlignedBB bounds = schematicHandler.getBounds(); - Vec3d plane = VecHelper.planeByNormal(new Vec3d(facing.getDirectionVec())); - plane = plane.mul(bounds.getXSize() / 2f + 1, bounds.getYSize() / 2f + 1, bounds.getZSize() / 2f + 1); - Vec3d center = bounds.getCenter(); + Vec3d directionVec = new Vec3d(Direction.getFacingFromAxis(AxisDirection.POSITIVE, facing.getAxis()) + .getDirectionVec()); + Vec3d boundsSize = new Vec3d(bounds.getXSize(), bounds.getYSize(), bounds.getZSize()); + Vec3d vec = boundsSize.mul(directionVec); + bounds = bounds.contract(vec.x, vec.y, vec.z) + .grow(1 - directionVec.x, 1 - directionVec.y, 1 - directionVec.z); + bounds = bounds.offset(directionVec.scale(.5f) + .mul(boundsSize)); - Vec3d v1 = plane.add(center); - plane = plane.mul(-1, 1, -1); - Vec3d v2 = plane.add(center); - plane = plane.mul(1, -1, 1); - Vec3d v3 = plane.add(center); - plane = plane.mul(-1, 1, -1); - Vec3d v4 = plane.add(center); - -// BufferBuilder buffer = Tessellator.getInstance().getBuffer();TODO 1.15 -// buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); -// -// AABBOutline outline = schematicHandler.getOutline(); -// AllSpecialTextures.BLANK.bind(); -// outline.renderAACuboidLine(v1, v2, color, 1, builder); -// outline.renderAACuboidLine(v2, v3, color, 1, builder); -// outline.renderAACuboidLine(v3, v4, color, 1, builder); -// outline.renderAACuboidLine(v4, v1, color, 1, builder); -// -// Tessellator.getInstance().draw(); -// buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); -// -// GlHelper.enableTextureRepeat(); -// GlStateManager.depthMask(false); -// Vec3d uDiff = v2.subtract(v1); -// Vec3d vDiff = v4.subtract(v1); -// float maxU = (float) Math.abs(axis == Axis.X ? uDiff.z : uDiff.x); -// float maxV = (float) Math.abs(axis == Axis.Y ? vDiff.z : vDiff.y); -// -// GlStateManager.enableCull(); -// AllSpecialTextures.HIGHLIGHT_CHECKERED.bind(); -// outline.putQuadUV(v1, v2, v3, v4, 0, 0, maxU, maxV, color, 1, builder); -// outline.putQuadUV(v2, v1, v4, v3, 0, 0, maxU, maxV, color, 1, builder); -// Tessellator.getInstance().draw(); -// GlStateManager.popMatrix(); -// GlHelper.disableTextureRepeat(); + outline.setBounds(bounds); + AllSpecialTextures tex = AllSpecialTextures.HIGHLIGHT_CHECKERED; + outline.getParams() + .lineWidth(1 / 16f) + .disableNormals() + .colored(0x4d80e4) + .withFaceTextures(tex, tex); + outline.render(ms, buffer); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java index c408e542c..182b86d93 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java @@ -14,6 +14,6 @@ public interface ISchematicTool { public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay); public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay); - public void renderToolLocal(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay); + public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay); } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java index db87de1d5..c964548d8 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java @@ -1,39 +1,43 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.foundation.utility.outliner.LineOutline; import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; public class RotateTool extends PlacementToolBase { + private LineOutline line = new LineOutline(); + @Override public boolean handleMouseWheel(double delta) { - schematicHandler.getTransformation().rotate90(delta > 0); + schematicHandler.getTransformation() + .rotate90(delta > 0); schematicHandler.markDirty(); return true; } @Override - public void renderToolLocal(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - super.renderToolLocal(ms, buffer, light, overlay); + public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + super.renderOnSchematic(ms, buffer, light, overlay); -// GlStateManager.pushMatrix();TODO 1.15 -// RenderHelper.disableStandardItemLighting(); -// GlStateManager.enableBlend(); -// -// Vec3d color = ColorHelper.getRGB(0x4d80e4); -// AxisAlignedBB bounds = schematicHandler.getBounds(); -// double height = bounds.getYSize() + Math.max(20, bounds.getYSize()); -// -// Vec3d center = bounds.getCenter().add(schematicHandler.getTransformation().getRotationOffset(false)); -// Vec3d start = center.subtract(0, height / 2, 0); -// Vec3d end = center.add(0, height / 2, 0); -// -// BufferBuilder buffer = Tessellator.getInstance().getBuffer(); -// buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); -// schematicHandler.getOutline().renderAACuboidLine(start, end, color, 1, buffer); -// Tessellator.getInstance().draw(); -// GlStateManager.popMatrix(); + AxisAlignedBB bounds = schematicHandler.getBounds(); + double height = bounds.getYSize() + Math.max(20, bounds.getYSize()); + Vec3d center = bounds.getCenter() + .add(schematicHandler.getTransformation() + .getRotationOffset(false)); + Vec3d start = center.subtract(0, height / 2, 0); + Vec3d end = center.add(0, height / 2, 0); + + line.getParams() + .colored(0x4d80e4) + .disableCull() + .disableNormals() + .lineWidth(1 / 16f); + line.set(start, end) + .render(ms, buffer); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java index d86ba6b5c..a99063f82 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java @@ -4,18 +4,19 @@ import java.util.Arrays; import java.util.List; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; +import com.simibubi.create.AllKeys; +import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.CreateClient; import com.simibubi.create.content.schematics.client.SchematicHandler; import com.simibubi.create.content.schematics.client.SchematicTransformation; import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.outliner.AABBOutline; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -63,7 +64,8 @@ public abstract class SchematicToolBase implements ISchematicTool { return; } - chasingSelectedPos = chasingSelectedPos.add(target.subtract(chasingSelectedPos).scale(1 / 2f)); + chasingSelectedPos = chasingSelectedPos.add(target.subtract(chasingSelectedPos) + .scale(1 / 2f)); } public void updateTargetPos() { @@ -88,8 +90,11 @@ public abstract class SchematicToolBase implements ISchematicTool { // Select location at distance if (selectIgnoreBlocks) { - float pt = Minecraft.getInstance().getRenderPartialTicks(); - selectedPos = new BlockPos(player.getEyePosition(pt).add(player.getLookVec().scale(selectionRange))); + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); + selectedPos = new BlockPos(player.getEyePosition(pt) + .add(player.getLookVec() + .scale(selectionRange))); if (snap) lastChasingSelectedPos = chasingSelectedPos = new Vec3d(selectedPos); return; @@ -102,8 +107,12 @@ public abstract class SchematicToolBase implements ISchematicTool { return; BlockPos hit = new BlockPos(trace.getHitVec()); - boolean replaceable = player.world.getBlockState(hit).getMaterial().isReplaceable(); - if (trace.getFace().getAxis().isVertical() && !replaceable) + boolean replaceable = player.world.getBlockState(hit) + .getMaterial() + .isReplaceable(); + if (trace.getFace() + .getAxis() + .isVertical() && !replaceable) hit = hit.offset(trace.getFace()); selectedPos = hit; if (snap) @@ -111,30 +120,30 @@ public abstract class SchematicToolBase implements ISchematicTool { } @Override - public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (!schematicHandler.isDeployed()) - return; - -// AABBOutline outline = schematicHandler.getOutline(); - if (renderSelectedFace) { -// schematicHandler.getOutline().setTextures(null, -// AllKeys.ctrlDown() ? AllSpecialTextures.HIGHLIGHT_CHECKERED : AllSpecialTextures.CHECKERED); -// outline.highlightFace(selectedFace); - } - - RenderHelper.disableStandardItemLighting(); - RenderSystem.pushMatrix(); - RenderSystem.enableBlend(); -// outline.render(Tessellator.getInstance().getBuffer());TODO - RenderSystem.popMatrix(); -// outline.setTextures(null, null); - - } + public void renderTool(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {} @Override public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {} - + @Override - public void renderToolLocal(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {} + public void renderOnSchematic(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + if (!schematicHandler.isDeployed()) + return; + + ms.push(); + AABBOutline outline = schematicHandler.getOutline(); + if (renderSelectedFace) { + outline.getParams() + .highlightFace(selectedFace) + .withFaceTextures(AllSpecialTextures.CHECKERED, + AllKeys.ctrlDown() ? AllSpecialTextures.HIGHLIGHT_CHECKERED : AllSpecialTextures.CHECKERED); + } + outline.getParams() + .disableCull(); + outline.render(ms, buffer); + outline.getParams() + .withFaceTextures(null, null); + ms.pop(); + } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java index fa4ee3be4..860b05ed9 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java @@ -17,7 +17,7 @@ public class AABBOutline extends Outline { protected AxisAlignedBB bb; public AABBOutline(AxisAlignedBB bb) { - this.bb = bb; + this.setBounds(bb); } @Override @@ -28,8 +28,9 @@ public class AABBOutline extends Outline { public void renderBB(MatrixStack ms, IRenderTypeBuffer buffer, AxisAlignedBB bb) { Vec3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo() .getProjectedView(); - boolean inside = bb.contains(projectedView); - bb = bb.grow(inside ? -1 / 128d : 1 / 128d); + boolean noCull = bb.contains(projectedView); + bb = bb.grow(noCull ? -1 / 128d : 1 / 128d); + noCull |= params.disableCull; Vec3d xyz = new Vec3d(bb.minX, bb.minY, bb.minZ); Vec3d Xyz = new Vec3d(bb.maxX, bb.minY, bb.minZ); @@ -41,34 +42,35 @@ public class AABBOutline extends Outline { Vec3d XYZ = new Vec3d(bb.maxX, bb.maxY, bb.maxZ); Vec3d start = xyz; - renderAACuboidLine(ms, buffer, start, Xyz); - renderAACuboidLine(ms, buffer, start, xYz); - renderAACuboidLine(ms, buffer, start, xyZ); + renderAACuboidLine(ms, buffer, start, Xyz, noCull); + renderAACuboidLine(ms, buffer, start, xYz, noCull); + renderAACuboidLine(ms, buffer, start, xyZ, noCull); start = XyZ; - renderAACuboidLine(ms, buffer, start, xyZ); - renderAACuboidLine(ms, buffer, start, XYZ); - renderAACuboidLine(ms, buffer, start, Xyz); + renderAACuboidLine(ms, buffer, start, xyZ, noCull); + renderAACuboidLine(ms, buffer, start, XYZ, noCull); + renderAACuboidLine(ms, buffer, start, Xyz, noCull); start = XYz; - renderAACuboidLine(ms, buffer, start, xYz); - renderAACuboidLine(ms, buffer, start, Xyz); - renderAACuboidLine(ms, buffer, start, XYZ); + renderAACuboidLine(ms, buffer, start, xYz, noCull); + renderAACuboidLine(ms, buffer, start, Xyz, noCull); + renderAACuboidLine(ms, buffer, start, XYZ, noCull); start = xYZ; - renderAACuboidLine(ms, buffer, start, XYZ); - renderAACuboidLine(ms, buffer, start, xyZ); - renderAACuboidLine(ms, buffer, start, xYz); + renderAACuboidLine(ms, buffer, start, XYZ, noCull); + renderAACuboidLine(ms, buffer, start, xyZ, noCull); + renderAACuboidLine(ms, buffer, start, xYz, noCull); - renderFace(ms, buffer, Direction.NORTH, xYz, XYz, Xyz, xyz, inside); - renderFace(ms, buffer, Direction.SOUTH, XYZ, xYZ, xyZ, XyZ, inside); - renderFace(ms, buffer, Direction.EAST, XYz, XYZ, XyZ, Xyz, inside); - renderFace(ms, buffer, Direction.WEST, xYZ, xYz, xyz, xyZ, inside); - renderFace(ms, buffer, Direction.UP, xYZ, XYZ, XYz, xYz, inside); - renderFace(ms, buffer, Direction.DOWN, xyz, Xyz, XyZ, xyZ, inside); + renderFace(ms, buffer, Direction.NORTH, xYz, XYz, Xyz, xyz, noCull); + renderFace(ms, buffer, Direction.SOUTH, XYZ, xYZ, xyZ, XyZ, noCull); + renderFace(ms, buffer, Direction.EAST, XYz, XYZ, XyZ, Xyz, noCull); + renderFace(ms, buffer, Direction.WEST, xYZ, xYz, xyz, xyZ, noCull); + renderFace(ms, buffer, Direction.UP, xYZ, XYZ, XYz, xYz, noCull); + renderFace(ms, buffer, Direction.DOWN, xyz, Xyz, XyZ, xyZ, noCull); } + //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()) @@ -90,4 +92,8 @@ public class AABBOutline extends Outline { putQuadUV(ms, builder, p1, p2, p3, p4, 0, 0, maxU, maxV, Direction.UP); } + public void setBounds(AxisAlignedBB bb) { + this.bb = bb; + } + } diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java index 5acd6acfe..66ae1715e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java @@ -33,7 +33,7 @@ public class BlockClusterOutline extends Outline { for (MergeEntry edge : cluster.visibleEdges) { Vec3d start = new Vec3d(edge.pos); Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, edge.axis); - renderAACuboidLine(ms, buffer, start, new Vec3d(edge.pos.offset(direction))); + renderAACuboidLine(ms, buffer, start, new Vec3d(edge.pos.offset(direction)), false); } for (MergeEntry face : cluster.visibleFaces.keySet()) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java index 253001782..f5349f278 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java @@ -25,7 +25,7 @@ public class ChasingAABBOutline extends AABBOutline { @Override public void tick() { prevBB = bb; - bb = interpolateBBs(bb, targetBB, .5f); + setBounds(interpolateBBs(bb, targetBB, .5f)); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java new file mode 100644 index 000000000..e0b4b7e36 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java @@ -0,0 +1,24 @@ +package com.simibubi.create.foundation.utility.outliner; + +import com.mojang.blaze3d.matrix.MatrixStack; + +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.util.math.Vec3d; + +public class LineOutline extends Outline { + + private Vec3d start = Vec3d.ZERO; + private Vec3d end = Vec3d.ZERO; + + public LineOutline set(Vec3d start, Vec3d end) { + this.start = start; + this.end = end; + return this; + } + + @Override + public void render(MatrixStack ms, IRenderTypeBuffer buffer) { + renderAACuboidLine(ms, buffer, start, end, params.disableCull); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index 5f45a7c74..aee7c22ee 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -17,6 +17,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; public abstract class Outline { @@ -30,8 +31,11 @@ public abstract class Outline { public abstract void render(MatrixStack ms, IRenderTypeBuffer buffer); - public void renderAACuboidLine(MatrixStack ms, IRenderTypeBuffer buffer, Vec3d start, Vec3d end) { - IVertexBuilder builder = buffer.getBuffer(RenderType.getEntitySolid(AllSpecialTextures.BLANK.getLocation())); + //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 = + buffer.getBuffer(noCull ? RenderType.getCutoutNoCull(tex, true) : RenderType.getEntitySolid(tex)); Vec3d diff = end.subtract(start); if (diff.x + diff.y + diff.z < 0) { @@ -181,6 +185,10 @@ public abstract class Outline { return this; } + public OutlineParams clearTextures() { + return this.withFaceTextures(null, null); + } + public OutlineParams withFaceTextures(AllSpecialTextures texture, AllSpecialTextures highlightTexture) { this.faceTexture = Optional.ofNullable(texture); this.hightlightedFaceTexture = Optional.ofNullable(highlightTexture);