mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Minor fixes part 2
This commit is contained in:
parent
fd6c930a65
commit
18977da884
4 changed files with 68 additions and 68 deletions
|
@ -54,7 +54,7 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
|||
.unCentre();
|
||||
|
||||
superBuffer
|
||||
.transform(matrices.contraptionStack)
|
||||
.transform(m)
|
||||
.light(matrices.entityMatrix,
|
||||
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
|
||||
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid()));
|
||||
|
|
|
@ -641,7 +641,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
|||
}
|
||||
|
||||
@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 final ContraptionRotationState NONE = new ContraptionRotationState();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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.glEnable;
|
||||
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
|
||||
|
@ -11,7 +12,6 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
@ -247,7 +247,7 @@ public class ContraptionRenderDispatcher {
|
|||
MatrixStack ms = new MatrixStack();
|
||||
Random random = new Random();
|
||||
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
|
||||
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
|
||||
ForgeHooksClient.setRenderLayer(layer);
|
||||
BlockModelRenderer.enableCache();
|
||||
|
|
|
@ -37,106 +37,106 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
|||
.addAttributes(ContraptionAttributes.class)
|
||||
.build();
|
||||
|
||||
private final ContraptionLighter<?> lighter;
|
||||
public final ContraptionKineticRenderer kinetics;
|
||||
private final ContraptionLighter<?> lighter;
|
||||
public final ContraptionKineticRenderer kinetics;
|
||||
|
||||
private final Map<RenderType, IndexedModel> renderLayers = new HashMap<>();
|
||||
|
||||
private Matrix4f model;
|
||||
private AxisAlignedBB lightBox;
|
||||
private AxisAlignedBB lightBox;
|
||||
|
||||
public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) {
|
||||
super(contraption, renderWorld);
|
||||
this.lighter = contraption.makeLighter();
|
||||
this.kinetics = new ContraptionKineticRenderer(this);
|
||||
public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) {
|
||||
super(contraption, renderWorld);
|
||||
this.lighter = contraption.makeLighter();
|
||||
this.kinetics = new ContraptionKineticRenderer(this);
|
||||
|
||||
buildLayers();
|
||||
if (Backend.canUseInstancing()) {
|
||||
buildInstancedTiles();
|
||||
buildActors();
|
||||
}
|
||||
}
|
||||
buildLayers();
|
||||
if (Backend.canUseInstancing()) {
|
||||
buildInstancedTiles();
|
||||
buildActors();
|
||||
}
|
||||
}
|
||||
|
||||
public ContraptionLighter<?> getLighter() {
|
||||
return lighter;
|
||||
}
|
||||
public ContraptionLighter<?> getLighter() {
|
||||
return lighter;
|
||||
}
|
||||
|
||||
public void doRenderLayer(RenderType layer, ContraptionProgram shader) {
|
||||
public void doRenderLayer(RenderType layer, ContraptionProgram shader) {
|
||||
IndexedModel structure = renderLayers.get(layer);
|
||||
if (structure != null) {
|
||||
setup(shader);
|
||||
structure.render();
|
||||
teardown();
|
||||
}
|
||||
}
|
||||
if (structure != null) {
|
||||
setup(shader);
|
||||
structure.render();
|
||||
teardown();
|
||||
}
|
||||
}
|
||||
|
||||
public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) {
|
||||
kinetics.beginFrame(info);
|
||||
public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) {
|
||||
kinetics.beginFrame(info);
|
||||
|
||||
AbstractContraptionEntity entity = contraption.entity;
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
AbstractContraptionEntity entity = contraption.entity;
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStack stack = new MatrixStack();
|
||||
|
||||
double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX;
|
||||
double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY;
|
||||
double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ;
|
||||
stack.translate(x, y, z);
|
||||
double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX;
|
||||
double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY;
|
||||
double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ;
|
||||
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) {
|
||||
if (model == null || lightBox == null) return;
|
||||
shader.bind(model, lightBox);
|
||||
lighter.lightVolume.bind();
|
||||
}
|
||||
void setup(ContraptionProgram shader) {
|
||||
if (model == null || lightBox == null) return;
|
||||
shader.bind(model, lightBox);
|
||||
lighter.lightVolume.bind();
|
||||
}
|
||||
|
||||
void teardown() {
|
||||
lighter.lightVolume.unbind();
|
||||
}
|
||||
void teardown() {
|
||||
lighter.lightVolume.unbind();
|
||||
}
|
||||
|
||||
void invalidate() {
|
||||
void invalidate() {
|
||||
for (IndexedModel buffer : renderLayers.values()) {
|
||||
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()) {
|
||||
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);
|
||||
if (layerModel != null) renderLayers.put(layer, layerModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildInstancedTiles() {
|
||||
Collection<TileEntity> tileEntities = contraption.maybeInstancedTileEntities;
|
||||
if (!tileEntities.isEmpty()) {
|
||||
for (TileEntity te : tileEntities) {
|
||||
if (te instanceof IInstanceRendered) {
|
||||
World world = te.getWorld();
|
||||
BlockPos pos = te.getPos();
|
||||
te.setLocation(renderWorld, pos);
|
||||
kinetics.add(te);
|
||||
private void buildInstancedTiles() {
|
||||
Collection<TileEntity> tileEntities = contraption.maybeInstancedTileEntities;
|
||||
if (!tileEntities.isEmpty()) {
|
||||
for (TileEntity te : tileEntities) {
|
||||
if (te instanceof IInstanceRendered) {
|
||||
World world = te.getWorld();
|
||||
BlockPos pos = te.getPos();
|
||||
te.setLocation(renderWorld, pos);
|
||||
kinetics.add(te);
|
||||
te.setLocation(world, pos);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue