Minor fixes part 2

This commit is contained in:
PepperBell 2021-05-17 12:07:45 -07:00
parent fd6c930a65
commit 18977da884
4 changed files with 68 additions and 68 deletions

View file

@ -54,7 +54,7 @@ public class DrillRenderer extends KineticTileEntityRenderer {
.unCentre(); .unCentre();
superBuffer superBuffer
.transform(matrices.contraptionStack) .transform(m)
.light(matrices.entityMatrix, .light(matrices.entityMatrix,
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid()));

View file

@ -641,7 +641,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStack); public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks);
public static class ContraptionRotationState { public static class ContraptionRotationState {
public static final ContraptionRotationState NONE = new ContraptionRotationState(); public static final ContraptionRotationState NONE = new ContraptionRotationState();

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render; package com.simibubi.create.content.contraptions.components.structureMovement.render;
import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.glDisable; import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable; import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
@ -11,7 +12,6 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@ -247,7 +247,7 @@ public class ContraptionRenderDispatcher {
MatrixStack ms = new MatrixStack(); MatrixStack ms = new MatrixStack();
Random random = new Random(); Random random = new Random();
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK);
ForgeHooksClient.setRenderLayer(layer); ForgeHooksClient.setRenderLayer(layer);
BlockModelRenderer.enableCache(); BlockModelRenderer.enableCache();

View file

@ -37,106 +37,106 @@ public class RenderedContraption extends ContraptionWorldHolder {
.addAttributes(ContraptionAttributes.class) .addAttributes(ContraptionAttributes.class)
.build(); .build();
private final ContraptionLighter<?> lighter; private final ContraptionLighter<?> lighter;
public final ContraptionKineticRenderer kinetics; public final ContraptionKineticRenderer kinetics;
private final Map<RenderType, IndexedModel> renderLayers = new HashMap<>(); private final Map<RenderType, IndexedModel> renderLayers = new HashMap<>();
private Matrix4f model; private Matrix4f model;
private AxisAlignedBB lightBox; private AxisAlignedBB lightBox;
public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) { public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) {
super(contraption, renderWorld); super(contraption, renderWorld);
this.lighter = contraption.makeLighter(); this.lighter = contraption.makeLighter();
this.kinetics = new ContraptionKineticRenderer(this); this.kinetics = new ContraptionKineticRenderer(this);
buildLayers(); buildLayers();
if (Backend.canUseInstancing()) { if (Backend.canUseInstancing()) {
buildInstancedTiles(); buildInstancedTiles();
buildActors(); buildActors();
} }
} }
public ContraptionLighter<?> getLighter() { public ContraptionLighter<?> getLighter() {
return lighter; return lighter;
} }
public void doRenderLayer(RenderType layer, ContraptionProgram shader) { public void doRenderLayer(RenderType layer, ContraptionProgram shader) {
IndexedModel structure = renderLayers.get(layer); IndexedModel structure = renderLayers.get(layer);
if (structure != null) { if (structure != null) {
setup(shader); setup(shader);
structure.render(); structure.render();
teardown(); teardown();
} }
} }
public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) { public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) {
kinetics.beginFrame(info); kinetics.beginFrame(info);
AbstractContraptionEntity entity = contraption.entity; AbstractContraptionEntity entity = contraption.entity;
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
MatrixStack stack = new MatrixStack(); MatrixStack stack = new MatrixStack();
double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX; double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX;
double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY; double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY;
double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ; double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ;
stack.translate(x, y, z); stack.translate(x, y, z);
entity.doLocalTransforms(pt, new MatrixStack[] { stack }); entity.doLocalTransforms(pt, new MatrixStack[] { stack });
model = stack.peek().getModel(); model = stack.peek().getModel();
AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume()); AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume());
this.lightBox = lightBox.offset(-camX, -camY, -camZ); this.lightBox = lightBox.offset(-camX, -camY, -camZ);
} }
void setup(ContraptionProgram shader) { void setup(ContraptionProgram shader) {
if (model == null || lightBox == null) return; if (model == null || lightBox == null) return;
shader.bind(model, lightBox); shader.bind(model, lightBox);
lighter.lightVolume.bind(); lighter.lightVolume.bind();
} }
void teardown() { void teardown() {
lighter.lightVolume.unbind(); lighter.lightVolume.unbind();
} }
void invalidate() { void invalidate() {
for (IndexedModel buffer : renderLayers.values()) { for (IndexedModel buffer : renderLayers.values()) {
buffer.delete(); buffer.delete();
} }
renderLayers.clear(); renderLayers.clear();
lighter.lightVolume.delete(); lighter.lightVolume.delete();
kinetics.invalidate(); kinetics.invalidate();
} }
private void buildLayers() { private void buildLayers() {
for (IndexedModel buffer : renderLayers.values()) { for (IndexedModel buffer : renderLayers.values()) {
buffer.delete(); buffer.delete();
} }
renderLayers.clear(); renderLayers.clear();
List<RenderType> blockLayers = RenderType.getBlockLayers(); List<RenderType> blockLayers = RenderType.getBlockLayers();
for (RenderType layer : blockLayers) { for (RenderType layer : blockLayers) {
IndexedModel layerModel = buildStructureModel(renderWorld, contraption, layer); IndexedModel layerModel = buildStructureModel(renderWorld, contraption, layer);
if (layerModel != null) renderLayers.put(layer, layerModel); if (layerModel != null) renderLayers.put(layer, layerModel);
} }
} }
private void buildInstancedTiles() { private void buildInstancedTiles() {
Collection<TileEntity> tileEntities = contraption.maybeInstancedTileEntities; Collection<TileEntity> tileEntities = contraption.maybeInstancedTileEntities;
if (!tileEntities.isEmpty()) { if (!tileEntities.isEmpty()) {
for (TileEntity te : tileEntities) { for (TileEntity te : tileEntities) {
if (te instanceof IInstanceRendered) { if (te instanceof IInstanceRendered) {
World world = te.getWorld(); World world = te.getWorld();
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
te.setLocation(renderWorld, pos); te.setLocation(renderWorld, pos);
kinetics.add(te); kinetics.add(te);
te.setLocation(world, pos); te.setLocation(world, pos);
} }
} }