Organization, renaming, and fixing a dumb crash
This commit is contained in:
parent
de451553dd
commit
2300ef2088
196 changed files with 659 additions and 602 deletions
|
@ -20,16 +20,15 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.CrumblingRenderer;
|
||||
import com.jozufozu.flywheel.backend.core.WorldTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.core.context.WorldContext;
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||
import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||
import com.jozufozu.flywheel.core.CrumblingRenderer;
|
||||
import com.jozufozu.flywheel.core.WorldContext;
|
||||
import com.jozufozu.flywheel.core.WorldTileRenderer;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.util.WorldAttached;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
|
||||
|
@ -141,8 +140,11 @@ public class Backend {
|
|||
return programSpecRegistry.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
||||
*/
|
||||
public static boolean isFlywheelWorld(World world) {
|
||||
return world == Minecraft.getInstance().world || (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel());
|
||||
return (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) || world == Minecraft.getInstance().world;
|
||||
}
|
||||
|
||||
public static boolean available() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
package com.jozufozu.flywheel.backend;
|
||||
|
||||
/**
|
||||
* A marker interface custom worlds can override to indicate
|
||||
* that tiles inside the world should render with Flywheel.
|
||||
*
|
||||
* <code>Minecraft.getInstance().world</code> will always support Flywheel.
|
||||
* <code>Minecraft.getInstance().world</code> is special cased and will support Flywheel by default.
|
||||
*/
|
||||
public interface IFlywheelWorld {
|
||||
default boolean supportsFlywheel() {
|
|
@ -4,13 +4,13 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.IMultiProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.backend.loading.Shader;
|
||||
import com.jozufozu.flywheel.backend.loading.ShaderTransformer;
|
||||
import com.jozufozu.flywheel.core.shader.IMultiProgram;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
|
|
@ -30,14 +30,14 @@ import com.google.common.collect.Lists;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry;
|
||||
import com.jozufozu.flywheel.backend.gl.GlObject;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlShader;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.backend.loading.Shader;
|
||||
import com.jozufozu.flywheel.backend.loading.ShaderLoadingException;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
||||
public class FirstNonnullMultiProgram<P extends GlProgram> {
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
import com.jozufozu.flywheel.util.AttribUtil;
|
||||
|
||||
public class IndexedModel extends BufferedModel {
|
||||
|
||||
protected GlPrimitiveType eboIndexType;
|
||||
protected GlBuffer ebo;
|
||||
|
||||
public IndexedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices, ByteBuffer indices, GlPrimitiveType indexType) {
|
||||
super(modelFormat, buf, vertices);
|
||||
|
||||
ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER);
|
||||
this.eboIndexType = indexType;
|
||||
|
||||
int indicesSize = vertexCount * indexType.getSize();
|
||||
|
||||
ebo.bind();
|
||||
|
||||
ebo.alloc(indicesSize);
|
||||
ebo.getBuffer(0, indicesSize)
|
||||
.put(indices)
|
||||
.flush();
|
||||
|
||||
ebo.unbind();
|
||||
}
|
||||
|
||||
public void render() {
|
||||
vbo.bind();
|
||||
ebo.bind();
|
||||
|
||||
AttribUtil.enableArrays(getAttributeCount());
|
||||
format.vertexAttribPointers(0);
|
||||
|
||||
GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0);
|
||||
|
||||
AttribUtil.disableArrays(getAttributeCount());
|
||||
|
||||
ebo.unbind();
|
||||
vbo.unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
super.delete();
|
||||
ebo.delete();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
||||
/**
|
||||
* A Callback for when a shader is called. Used to define shader uniforms.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ShaderCallback<P extends GlProgram> {
|
||||
|
||||
void call(P program);
|
||||
|
||||
default ShaderCallback<P> andThen(ShaderCallback<P> other) {
|
||||
return program -> {
|
||||
call(program);
|
||||
other.call(program);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -13,27 +13,28 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public enum GlPrimitiveType {
|
||||
public enum GlNumericType {
|
||||
FLOAT(4, "float", GL11.GL_FLOAT),
|
||||
UBYTE(1, "ubyte", GL11.GL_UNSIGNED_BYTE),
|
||||
BYTE(1, "byte", GL11.GL_BYTE),
|
||||
USHORT(2, "ushort", GL11.GL_UNSIGNED_SHORT),
|
||||
SHORT(2, "short", GL11.GL_SHORT),
|
||||
UINT(4, "uint", GL11.GL_UNSIGNED_INT),
|
||||
INT(4, "int", GL11.GL_INT);
|
||||
INT(4, "int", GL11.GL_INT),
|
||||
;
|
||||
|
||||
private static final GlPrimitiveType[] VALUES = values();
|
||||
private static final Map<String, GlPrimitiveType> NAME_LOOKUP = Arrays.stream(VALUES)
|
||||
.collect(Collectors.toMap(GlPrimitiveType::getDisplayName, type -> type));
|
||||
private static final GlNumericType[] VALUES = values();
|
||||
private static final Map<String, GlNumericType> NAME_LOOKUP = Arrays.stream(VALUES)
|
||||
.collect(Collectors.toMap(GlNumericType::getDisplayName, type -> type));
|
||||
|
||||
private final int size;
|
||||
private final String displayName;
|
||||
private final int glConstant;
|
||||
private final int glEnum;
|
||||
|
||||
GlPrimitiveType(int bytes, String name, int glEnum) {
|
||||
GlNumericType(int bytes, String name, int glEnum) {
|
||||
this.size = bytes;
|
||||
this.displayName = name;
|
||||
this.glConstant = glEnum;
|
||||
this.glEnum = glEnum;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
|
@ -44,12 +45,12 @@ public enum GlPrimitiveType {
|
|||
return this.displayName;
|
||||
}
|
||||
|
||||
public int getGlConstant() {
|
||||
return this.glConstant;
|
||||
public int getGlEnum() {
|
||||
return this.glEnum;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GlPrimitiveType byName(String name) {
|
||||
public static GlNumericType byName(String name) {
|
||||
return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.jozufozu.flywheel.backend.gl;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public enum GlPrimitive {
|
||||
POINTS(GL11.GL_POINTS),
|
||||
LINES(GL11.GL_LINES),
|
||||
LINE_LOOP(GL11.GL_LINE_LOOP),
|
||||
LINE_STRIP(GL11.GL_LINE_STRIP),
|
||||
TRIANGLES(GL11.GL_TRIANGLES),
|
||||
TRIANGLE_STRIP(GL11.GL_TRIANGLE_STRIP),
|
||||
TRIANGLE_FAN(GL11.GL_TRIANGLE_FAN),
|
||||
QUADS(GL11.GL_QUADS),
|
||||
QUAD_STRIP(GL11.GL_QUAD_STRIP),
|
||||
POLYGON(GL11.GL_POLYGON),
|
||||
;
|
||||
|
||||
public final int glEnum;
|
||||
|
||||
GlPrimitive(int glEnum) {
|
||||
this.glEnum = glEnum;
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
package com.jozufozu.flywheel.backend.gl.attrib;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
|
||||
public class CommonAttributes {
|
||||
|
||||
public static final VertexAttribSpec VEC4 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 4);
|
||||
public static final VertexAttribSpec VEC3 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 3);
|
||||
public static final VertexAttribSpec VEC2 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 2);
|
||||
public static final VertexAttribSpec FLOAT = new VertexAttribSpec(GlPrimitiveType.FLOAT, 1);
|
||||
public static final VertexAttribSpec VEC4 = new VertexAttribSpec(GlNumericType.FLOAT, 4);
|
||||
public static final VertexAttribSpec VEC3 = new VertexAttribSpec(GlNumericType.FLOAT, 3);
|
||||
public static final VertexAttribSpec VEC2 = new VertexAttribSpec(GlNumericType.FLOAT, 2);
|
||||
public static final VertexAttribSpec FLOAT = new VertexAttribSpec(GlNumericType.FLOAT, 1);
|
||||
|
||||
public static final VertexAttribSpec QUATERNION = new VertexAttribSpec(GlPrimitiveType.FLOAT, 4);
|
||||
public static final VertexAttribSpec NORMAL = new VertexAttribSpec(GlPrimitiveType.BYTE, 3, true);
|
||||
public static final VertexAttribSpec UV = new VertexAttribSpec(GlPrimitiveType.FLOAT, 2);
|
||||
public static final VertexAttribSpec QUATERNION = new VertexAttribSpec(GlNumericType.FLOAT, 4);
|
||||
public static final VertexAttribSpec NORMAL = new VertexAttribSpec(GlNumericType.BYTE, 3, true);
|
||||
public static final VertexAttribSpec UV = new VertexAttribSpec(GlNumericType.FLOAT, 2);
|
||||
|
||||
public static final VertexAttribSpec RGBA = new VertexAttribSpec(GlPrimitiveType.UBYTE, 4, true);
|
||||
public static final VertexAttribSpec RGB = new VertexAttribSpec(GlPrimitiveType.UBYTE, 3, true);
|
||||
public static final VertexAttribSpec LIGHT = new VertexAttribSpec(GlPrimitiveType.UBYTE, 2, true);
|
||||
public static final VertexAttribSpec RGBA = new VertexAttribSpec(GlNumericType.UBYTE, 4, true);
|
||||
public static final VertexAttribSpec RGB = new VertexAttribSpec(GlNumericType.UBYTE, 3, true);
|
||||
public static final VertexAttribSpec LIGHT = new VertexAttribSpec(GlNumericType.UBYTE, 2, true);
|
||||
|
||||
public static final VertexAttribSpec NORMALIZED_BYTE = new VertexAttribSpec(GlPrimitiveType.BYTE, 1, true);
|
||||
public static final VertexAttribSpec NORMALIZED_BYTE = new VertexAttribSpec(GlNumericType.BYTE, 1, true);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.gl.attrib;
|
|||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
|
||||
public enum MatrixAttributes implements IAttribSpec {
|
||||
MAT3(3, 3),
|
||||
|
@ -20,14 +20,14 @@ public enum MatrixAttributes implements IAttribSpec {
|
|||
@Override
|
||||
public void vertexAttribPointer(int stride, int index, int pointer) {
|
||||
for (int i = 0; i < rows; i++) {
|
||||
long attribPointer = pointer + (long) i * cols * GlPrimitiveType.FLOAT.getSize();
|
||||
GL20.glVertexAttribPointer(index + i, cols, GlPrimitiveType.FLOAT.getGlConstant(), false, stride, attribPointer);
|
||||
long attribPointer = pointer + (long) i * cols * GlNumericType.FLOAT.getSize();
|
||||
GL20.glVertexAttribPointer(index + i, cols, GlNumericType.FLOAT.getGlEnum(), false, stride, attribPointer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return GlPrimitiveType.FLOAT.getSize() * rows * cols;
|
||||
return GlNumericType.FLOAT.getSize() * rows * cols;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,21 +2,21 @@ package com.jozufozu.flywheel.backend.gl.attrib;
|
|||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
|
||||
public class VertexAttribSpec implements IAttribSpec {
|
||||
|
||||
private final GlPrimitiveType type;
|
||||
private final GlNumericType type;
|
||||
private final int count;
|
||||
private final int size;
|
||||
private final int attributeCount;
|
||||
private final boolean normalized;
|
||||
|
||||
public VertexAttribSpec(GlPrimitiveType type, int count) {
|
||||
public VertexAttribSpec(GlNumericType type, int count) {
|
||||
this(type, count, false);
|
||||
}
|
||||
|
||||
public VertexAttribSpec(GlPrimitiveType type, int count, boolean normalized) {
|
||||
public VertexAttribSpec(GlNumericType type, int count, boolean normalized) {
|
||||
this.type = type;
|
||||
this.count = count;
|
||||
this.size = type.getSize() * count;
|
||||
|
@ -26,7 +26,7 @@ public class VertexAttribSpec implements IAttribSpec {
|
|||
|
||||
@Override
|
||||
public void vertexAttribPointer(int stride, int index, int pointer) {
|
||||
GL20.glVertexAttribPointer(index, count, type.getGlConstant(), normalized, stride, pointer);
|
||||
GL20.glVertexAttribPointer(index, count, type.getGlEnum(), normalized, stride, pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.lwjgl.opengl.EXTDrawInstanced;
|
|||
import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||
import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned;
|
||||
|
||||
public enum DrawInstanced implements GlVersioned {
|
||||
|
@ -15,8 +17,13 @@ public enum DrawInstanced implements GlVersioned {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawArraysInstanced(int mode, int first, int count, int primcount) {
|
||||
GL31.glDrawArraysInstanced(mode, first, count, primcount);
|
||||
public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) {
|
||||
GL31.glDrawArraysInstanced(mode.glEnum, first, count, primcount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) {
|
||||
GL31.glDrawElementsInstanced(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount);
|
||||
}
|
||||
},
|
||||
ARB_DRAW_INSTANCED {
|
||||
|
@ -26,8 +33,13 @@ public enum DrawInstanced implements GlVersioned {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawArraysInstanced(int mode, int first, int count, int primcount) {
|
||||
ARBDrawInstanced.glDrawArraysInstancedARB(mode, first, count, primcount);
|
||||
public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) {
|
||||
ARBDrawInstanced.glDrawArraysInstancedARB(mode.glEnum, first, count, primcount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) {
|
||||
ARBDrawInstanced.glDrawElementsInstancedARB(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount);
|
||||
}
|
||||
},
|
||||
EXT_DRAW_INSTANCED {
|
||||
|
@ -37,8 +49,13 @@ public enum DrawInstanced implements GlVersioned {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawArraysInstanced(int mode, int first, int count, int primcount) {
|
||||
EXTDrawInstanced.glDrawArraysInstancedEXT(mode, first, count, primcount);
|
||||
public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) {
|
||||
EXTDrawInstanced.glDrawArraysInstancedEXT(mode.glEnum, first, count, primcount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) {
|
||||
EXTDrawInstanced.glDrawElementsInstancedEXT(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount);
|
||||
}
|
||||
},
|
||||
UNSUPPORTED {
|
||||
|
@ -46,12 +63,14 @@ public enum DrawInstanced implements GlVersioned {
|
|||
public boolean supported(GLCapabilities caps) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawArraysInstanced(int mode, int first, int count, int primcount) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
|
||||
public abstract void drawArraysInstanced(int mode, int first, int count, int primcount);
|
||||
|
||||
public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,8 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* A general interface providing information about any type of thing that could use
|
||||
* Flywheel's instanced rendering. Right now, that's only {@link InstancedTileRenderer},
|
||||
* but there could be an entity equivalent in the future.
|
||||
* A general interface providing information about any type of thing that could use Flywheel's instanced rendering.
|
||||
* Right now, that's only {@link InstancedTileRenderer}, but there could be an entity equivalent in the future.
|
||||
*/
|
||||
public interface IInstance {
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
|
||||
public interface IInstanceFactory<D extends InstanceData> {
|
||||
D create(Instancer<? super D> owner);
|
||||
}
|
|
@ -1,7 +1,14 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
|
||||
/**
|
||||
* Something (a TileEntity or Entity) that can be rendered using the instancing API.
|
||||
*/
|
||||
public interface IInstanceRendered {
|
||||
default boolean shouldRenderAsTE() {
|
||||
|
||||
/**
|
||||
* @return true if there are parts of the renderer that cannot be implemented with Flywheel.
|
||||
*/
|
||||
default boolean shouldRenderNormally() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
* <ul>
|
||||
* <li>
|
||||
* You'd like to change something about the instance every now and then.
|
||||
* eg. adding or removing parts, snapping to a different rotation.
|
||||
* eg. adding or removing parts, snapping to a different rotation, etc.
|
||||
* </li>
|
||||
* <li>
|
||||
* Your TileEntity does animate, but the animation doesn't have
|
||||
|
|
|
@ -4,12 +4,12 @@ import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
|||
|
||||
public abstract class InstanceData {
|
||||
|
||||
protected final InstancedModel<?> owner;
|
||||
protected final Instancer<?> owner;
|
||||
|
||||
boolean dirty;
|
||||
boolean removed;
|
||||
|
||||
protected InstanceData(InstancedModel<?> owner) {
|
||||
protected InstanceData(Instancer<?> owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
|
||||
public interface InstanceFactory<D extends InstanceData> {
|
||||
D create(InstancedModel<? super D> owner);
|
||||
}
|
|
@ -10,7 +10,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class InstancedTileRenderRegistry {
|
||||
public static final InstancedTileRenderRegistry instance = new InstancedTileRenderRegistry();
|
||||
private static final InstancedTileRenderRegistry INSTANCE = new InstancedTileRenderRegistry();
|
||||
|
||||
public static InstancedTileRenderRegistry getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private final Map<TileEntityType<?>, IRendererFactory<?>> renderers = Maps.newHashMap();
|
||||
|
||||
|
|
|
@ -8,14 +8,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.core.context.WorldContext;
|
||||
import com.jozufozu.flywheel.backend.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.backend.core.shader.ShaderCallback;
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.core.WorldContext;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -130,7 +129,7 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
|||
* @param viewProjection How do we get from camera space to clip space?
|
||||
* @param callback Provide additional uniforms or state here.
|
||||
*/
|
||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, ShaderCallback<P> callback) {
|
||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> callback) {
|
||||
for (RenderMaterial<P, ?> material : materials.values()) {
|
||||
material.render(layer, viewProjection, camX, camY, camZ, callback);
|
||||
}
|
||||
|
@ -268,7 +267,7 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
|||
}
|
||||
|
||||
private <T extends TileEntity> TileEntityInstance<? super T> createInternal(T tile) {
|
||||
TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.instance.create(this, tile);
|
||||
TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.getInstance().create(this, tile);
|
||||
|
||||
if (renderer != null) {
|
||||
renderer.updateLight();
|
||||
|
@ -302,7 +301,7 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
|||
|
||||
if (world.isAirBlock(tile.getPos())) return false;
|
||||
|
||||
if (world == Minecraft.getInstance().world) {
|
||||
if (Backend.isFlywheelWorld(world)) {
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
IBlockReader existingChunk = world.getExistingChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
@ -310,6 +309,6 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
|||
return existingChunk != null;
|
||||
}
|
||||
|
||||
return world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,25 +4,23 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.core.BufferedModel;
|
||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.core.BufferedModel;
|
||||
import com.jozufozu.flywheel.util.AttribUtil;
|
||||
|
||||
public class InstancedModel<D extends InstanceData> {
|
||||
public class Instancer<D extends InstanceData> {
|
||||
|
||||
public final InstancedTileRenderer<?> renderer;
|
||||
|
||||
protected final BufferedModel model;
|
||||
|
||||
protected final VertexFormat instanceFormat;
|
||||
protected final InstanceFactory<D> factory;
|
||||
protected final IInstanceFactory<D> factory;
|
||||
protected GlVertexArray vao;
|
||||
protected GlBuffer instanceVBO;
|
||||
protected int glBufferSize = -1;
|
||||
|
@ -34,7 +32,7 @@ public class InstancedModel<D extends InstanceData> {
|
|||
boolean anyToRemove;
|
||||
boolean anyToUpdate;
|
||||
|
||||
public InstancedModel(BufferedModel model, InstancedTileRenderer<?> renderer, VertexFormat instanceFormat, InstanceFactory<D> factory) {
|
||||
public Instancer(BufferedModel model, InstancedTileRenderer<?> renderer, VertexFormat instanceFormat, IInstanceFactory<D> factory) {
|
||||
this.model = model;
|
||||
this.factory = factory;
|
||||
this.instanceFormat = instanceFormat;
|
||||
|
@ -65,7 +63,7 @@ public class InstancedModel<D extends InstanceData> {
|
|||
renderSetup();
|
||||
|
||||
if (glInstanceCount > 0)
|
||||
Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, model.getVertexCount(), glInstanceCount);
|
||||
model.drawInstances(glInstanceCount);
|
||||
|
||||
vao.unbind();
|
||||
}
|
|
@ -11,9 +11,9 @@ public class MaterialSpec<D extends InstanceData> {
|
|||
private final ResourceLocation programSpec;
|
||||
private final VertexFormat modelFormat;
|
||||
private final VertexFormat instanceFormat;
|
||||
private final InstanceFactory<D> instanceFactory;
|
||||
private final IInstanceFactory<D> instanceFactory;
|
||||
|
||||
public MaterialSpec(ResourceLocation name, ResourceLocation programSpec, VertexFormat modelFormat, VertexFormat instanceFormat, InstanceFactory<D> instanceFactory) {
|
||||
public MaterialSpec(ResourceLocation name, ResourceLocation programSpec, VertexFormat modelFormat, VertexFormat instanceFormat, IInstanceFactory<D> instanceFactory) {
|
||||
this.name = name;
|
||||
this.programSpec = programSpec;
|
||||
this.modelFormat = modelFormat;
|
||||
|
@ -33,7 +33,7 @@ public class MaterialSpec<D extends InstanceData> {
|
|||
return instanceFormat;
|
||||
}
|
||||
|
||||
public InstanceFactory<D> getInstanceFactory() {
|
||||
public IInstanceFactory<D> getInstanceFactory() {
|
||||
return instanceFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,12 @@ import org.lwjgl.opengl.GL11;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.jozufozu.flywheel.backend.RenderWork;
|
||||
import com.jozufozu.flywheel.backend.core.BufferedModel;
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.backend.core.shader.ShaderCallback;
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.BufferedModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.util.BufferBuilderReader;
|
||||
import com.jozufozu.flywheel.util.RenderUtil;
|
||||
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
||||
|
@ -39,7 +40,7 @@ import net.minecraft.util.math.vector.Matrix4f;
|
|||
public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
||||
|
||||
protected final InstancedTileRenderer<P> renderer;
|
||||
protected final Cache<Object, InstancedModel<D>> models;
|
||||
protected final Cache<Object, Instancer<D>> models;
|
||||
protected final MaterialSpec<D> spec;
|
||||
|
||||
public RenderMaterial(InstancedTileRenderer<P> renderer, MaterialSpec<D> spec) {
|
||||
|
@ -48,7 +49,7 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
|||
|
||||
this.models = CacheBuilder.newBuilder()
|
||||
.removalListener(notification -> {
|
||||
InstancedModel<?> model = (InstancedModel<?>) notification.getValue();
|
||||
Instancer<?> model = (Instancer<?>) notification.getValue();
|
||||
RenderWork.enqueue(model::delete);
|
||||
})
|
||||
.build();
|
||||
|
@ -58,7 +59,7 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
|||
render(layer, projection, camX, camY, camZ, null);
|
||||
}
|
||||
|
||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, ShaderCallback<P> setup) {
|
||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> setup) {
|
||||
if (!(layer == RenderType.getCutoutMipped())) return;
|
||||
|
||||
P program = renderer.context.getProgram(this.spec.getProgramSpec());
|
||||
|
@ -77,33 +78,33 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
|||
}
|
||||
|
||||
protected void makeRenderCalls() {
|
||||
runOnAll(InstancedModel::render);
|
||||
runOnAll(Instancer::render);
|
||||
}
|
||||
|
||||
public void runOnAll(Consumer<InstancedModel<D>> f) {
|
||||
for (InstancedModel<D> model : models.asMap().values()) {
|
||||
public void runOnAll(Consumer<Instancer<D>> f) {
|
||||
for (Instancer<D> model : models.asMap().values()) {
|
||||
f.accept(model);
|
||||
}
|
||||
}
|
||||
|
||||
public InstancedModel<D> getModel(PartialModel partial, BlockState referenceState) {
|
||||
public Instancer<D> getModel(PartialModel partial, BlockState referenceState) {
|
||||
return get(partial, () -> buildModel(partial.get(), referenceState));
|
||||
}
|
||||
|
||||
public InstancedModel<D> getModel(PartialModel partial, BlockState referenceState, Direction dir) {
|
||||
public Instancer<D> getModel(PartialModel partial, BlockState referenceState, Direction dir) {
|
||||
return getModel(partial, referenceState, dir, RenderUtil.rotateToFace(dir));
|
||||
}
|
||||
|
||||
public InstancedModel<D> getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier<MatrixStack> modelTransform) {
|
||||
public Instancer<D> getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier<MatrixStack> modelTransform) {
|
||||
return get(Pair.of(dir, partial),
|
||||
() -> buildModel(partial.get(), referenceState, modelTransform.get()));
|
||||
}
|
||||
|
||||
public InstancedModel<D> getModel(BlockState toRender) {
|
||||
public Instancer<D> getModel(BlockState toRender) {
|
||||
return get(toRender, () -> buildModel(toRender));
|
||||
}
|
||||
|
||||
public InstancedModel<D> get(Object key, Supplier<InstancedModel<D>> supplier) {
|
||||
public Instancer<D> get(Object key, Supplier<Instancer<D>> supplier) {
|
||||
try {
|
||||
return models.get(key, supplier::get);
|
||||
} catch (ExecutionException e) {
|
||||
|
@ -112,16 +113,16 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
|||
}
|
||||
}
|
||||
|
||||
private InstancedModel<D> buildModel(BlockState renderedState) {
|
||||
private Instancer<D> buildModel(BlockState renderedState) {
|
||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
return buildModel(dispatcher.getModelForState(renderedState), renderedState);
|
||||
}
|
||||
|
||||
private InstancedModel<D> buildModel(IBakedModel model, BlockState renderedState) {
|
||||
private Instancer<D> buildModel(IBakedModel model, BlockState renderedState) {
|
||||
return buildModel(model, renderedState, new MatrixStack());
|
||||
}
|
||||
|
||||
private InstancedModel<D> buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
||||
private Instancer<D> buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
||||
BufferBuilderReader reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms));
|
||||
|
||||
VertexFormat format = spec.getModelFormat();
|
||||
|
@ -145,9 +146,9 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
|||
|
||||
to.rewind();
|
||||
|
||||
BufferedModel bufferedModel = new BufferedModel(format, to, vertexCount);
|
||||
BufferedModel bufferedModel = new BufferedModel(GlPrimitive.QUADS, format, to, vertexCount);
|
||||
|
||||
return new InstancedModel<>(bufferedModel, renderer, spec.getInstanceFormat(), spec.getInstanceFactory());
|
||||
return new Instancer<>(bufferedModel, renderer, spec.getInstanceFormat(), spec.getInstanceFactory());
|
||||
}
|
||||
|
||||
private static final Direction[] dirs;
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.materials.IFlatLight;
|
||||
import com.jozufozu.flywheel.backend.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.IFlatLight;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package com.jozufozu.flywheel.backend.light;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CoordinateConsumer {
|
||||
void consume(int x, int y, int z);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.loading;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ProcessingStage {
|
||||
public interface IProcessingStage {
|
||||
|
||||
void process(Shader shader);
|
||||
}
|
|
@ -3,17 +3,17 @@ package com.jozufozu.flywheel.backend.loading;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
|
||||
public class LayoutTag {
|
||||
|
||||
public static final Pattern pattern = Pattern.compile("Layout\\((\\w+)(?:\\s*,\\s*(\\w*))?\\)");
|
||||
|
||||
final GlPrimitiveType type;
|
||||
final GlNumericType type;
|
||||
final boolean normalized;
|
||||
|
||||
public LayoutTag(Matcher matcher) {
|
||||
type = GlPrimitiveType.byName(matcher.group(1));
|
||||
type = GlNumericType.byName(matcher.group(1));
|
||||
normalized = Boolean.parseBoolean(matcher.group(2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
|||
import com.jozufozu.flywheel.backend.ShaderLoader;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||
|
||||
public abstract class ProgramTemplate implements ProcessingStage {
|
||||
public abstract class ProgramTemplate implements IProcessingStage {
|
||||
|
||||
protected final ShaderLoader loader;
|
||||
protected Map<ShaderType, ShaderTemplate> templates = new EnumMap<>(ShaderType.class);
|
||||
|
|
|
@ -4,12 +4,12 @@ import java.util.LinkedList;
|
|||
|
||||
public class ShaderTransformer {
|
||||
|
||||
private final LinkedList<ProcessingStage> stages = new LinkedList<>();
|
||||
private final LinkedList<IProcessingStage> stages = new LinkedList<>();
|
||||
|
||||
public ShaderTransformer() {
|
||||
}
|
||||
|
||||
public ShaderTransformer pushStage(ProcessingStage stage) {
|
||||
public ShaderTransformer pushStage(IProcessingStage stage) {
|
||||
if (stage != null) {
|
||||
stages.addLast(stage);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class ShaderTransformer {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ShaderTransformer prependStage(ProcessingStage stage) {
|
||||
public ShaderTransformer prependStage(IProcessingStage stage) {
|
||||
if (stage != null) {
|
||||
stages.addFirst(stage);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class ShaderTransformer {
|
|||
|
||||
public void transformSource(Shader shader) {
|
||||
|
||||
for (ProcessingStage stage : this.stages) {
|
||||
for (IProcessingStage stage : this.stages) {
|
||||
stage.process(shader);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.util.AttribUtil;
|
||||
|
@ -13,8 +14,8 @@ public class BufferedArrayModel extends BufferedModel {
|
|||
|
||||
protected GlVertexArray vao;
|
||||
|
||||
public BufferedArrayModel(VertexFormat format, ByteBuffer data, int vertices) {
|
||||
super(format, data, vertices);
|
||||
public BufferedArrayModel(GlPrimitive primitiveMode, VertexFormat format, ByteBuffer data, int vertices) {
|
||||
super(primitiveMode, format, data, vertices);
|
||||
|
||||
vao = new GlVertexArray();
|
||||
|
||||
|
@ -23,14 +24,14 @@ public class BufferedArrayModel extends BufferedModel {
|
|||
// bind the model's vbo to our vao
|
||||
vbo.bind();
|
||||
getFormat().vertexAttribPointers(0);
|
||||
vbo.unbind();
|
||||
|
||||
// enable all the attribute arrays in our vao. we only need to do this once
|
||||
AttribUtil.enableArrays(getAttributeCount());
|
||||
vbo.unbind();
|
||||
vao.unbind();
|
||||
}
|
||||
|
||||
public void render() {
|
||||
public void draw() {
|
||||
if (vertexCount <= 0 || deleted) return;
|
||||
|
||||
vao.bind();
|
|
@ -1,16 +1,11 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import static org.lwjgl.opengl.GL20.GL_COLOR_ARRAY;
|
||||
import static org.lwjgl.opengl.GL20.GL_INDEX_ARRAY;
|
||||
import static org.lwjgl.opengl.GL20.GL_NORMAL_ARRAY;
|
||||
import static org.lwjgl.opengl.GL20.GL_QUADS;
|
||||
import static org.lwjgl.opengl.GL20.GL_TEXTURE_COORD_ARRAY;
|
||||
import static org.lwjgl.opengl.GL20.GL_VERTEX_ARRAY;
|
||||
import static org.lwjgl.opengl.GL20.glDisableClientState;
|
||||
import static org.lwjgl.opengl.GL20.glDrawArrays;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
|
@ -18,13 +13,15 @@ import com.jozufozu.flywheel.util.AttribUtil;
|
|||
|
||||
public class BufferedModel {
|
||||
|
||||
protected final GlPrimitive primitiveMode;
|
||||
protected final ByteBuffer data;
|
||||
protected final VertexFormat format;
|
||||
protected final int vertexCount;
|
||||
protected GlBuffer vbo;
|
||||
protected boolean deleted;
|
||||
|
||||
public BufferedModel(VertexFormat format, ByteBuffer data, int vertices) {
|
||||
public BufferedModel(GlPrimitive primitiveMode, VertexFormat format, ByteBuffer data, int vertices) {
|
||||
this.primitiveMode = primitiveMode;
|
||||
this.data = data;
|
||||
this.format = format;
|
||||
this.vertexCount = vertices;
|
||||
|
@ -61,28 +58,30 @@ public class BufferedModel {
|
|||
/**
|
||||
* Renders this model, checking first if there is anything to render.
|
||||
*/
|
||||
public void render() {
|
||||
public void draw() {
|
||||
if (vertexCount <= 0 || deleted) return;
|
||||
|
||||
// TODO: minecraft sometimes leaves its state dirty on launch. this is a hack
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
vbo.bind();
|
||||
|
||||
AttribUtil.enableArrays(getAttributeCount());
|
||||
format.vertexAttribPointers(0);
|
||||
|
||||
glDrawArrays(GL_QUADS, 0, vertexCount);
|
||||
glDrawArrays(primitiveMode.glEnum, 0, vertexCount);
|
||||
|
||||
AttribUtil.disableArrays(getAttributeCount());
|
||||
|
||||
vbo.unbind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws many instances of this model, assuming the appropriate state is already bound.
|
||||
*/
|
||||
public void drawInstances(int instanceCount) {
|
||||
if (vertexCount <= 0 || deleted) return;
|
||||
|
||||
Backend.compat.drawInstanced.drawArraysInstanced(primitiveMode, 0, vertexCount, instanceCount);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (deleted) return;
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import static org.lwjgl.opengl.GL20.glUniform2f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
|
||||
public class CrumblingProgram extends WorldProgram {
|
||||
protected final int uTextureScale;
|
|
@ -1,6 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.context.WorldContext;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitiveType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
|
@ -42,7 +42,7 @@ public class FullscreenQuad {
|
|||
|
||||
GL20.glEnableVertexAttribArray(0);
|
||||
|
||||
GL20.glVertexAttribPointer(0, 4, GlPrimitiveType.FLOAT.getGlConstant(), false, 4 * 4, 0);
|
||||
GL20.glVertexAttribPointer(0, 4, GlNumericType.FLOAT.getGlEnum(), false, 4 * 4, 0);
|
||||
|
||||
vao.unbind();
|
||||
vbo.unbind();
|
69
src/main/java/com/jozufozu/flywheel/core/IndexedModel.java
Normal file
69
src/main/java/com/jozufozu/flywheel/core/IndexedModel.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.gl.GlNumericType;
|
||||
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
||||
import com.jozufozu.flywheel.util.AttribUtil;
|
||||
|
||||
public class IndexedModel extends BufferedModel {
|
||||
|
||||
protected int elementCount;
|
||||
protected GlNumericType eboIndexType;
|
||||
protected GlBuffer ebo;
|
||||
|
||||
public IndexedModel(GlPrimitive primitiveMode, VertexFormat modelFormat, ByteBuffer buf, int vertices, ByteBuffer indices, int elementCount, GlNumericType indexType) {
|
||||
super(primitiveMode, modelFormat, buf, vertices);
|
||||
|
||||
this.ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER);
|
||||
this.eboIndexType = indexType;
|
||||
this.elementCount = elementCount;
|
||||
|
||||
int indicesSize = elementCount * indexType.getSize();
|
||||
|
||||
ebo.bind();
|
||||
|
||||
ebo.alloc(indicesSize);
|
||||
ebo.getBuffer(0, indicesSize)
|
||||
.put(indices)
|
||||
.flush();
|
||||
|
||||
ebo.unbind();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
vbo.bind();
|
||||
ebo.bind();
|
||||
|
||||
AttribUtil.enableArrays(getAttributeCount());
|
||||
format.vertexAttribPointers(0);
|
||||
|
||||
GL20.glDrawElements(primitiveMode.glEnum, vertexCount, eboIndexType.getGlEnum(), 0);
|
||||
|
||||
AttribUtil.disableArrays(getAttributeCount());
|
||||
|
||||
ebo.unbind();
|
||||
vbo.unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInstances(int instanceCount) {
|
||||
if (vertexCount <= 0 || deleted) return;
|
||||
|
||||
ebo.bind();
|
||||
Backend.compat.drawInstanced.drawElementsInstanced(primitiveMode, 0, eboIndexType, 0, instanceCount);
|
||||
ebo.unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
super.delete();
|
||||
ebo.delete();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.context;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
@ -12,12 +12,6 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.jozufozu.flywheel.backend.ResourceUtil;
|
||||
import com.jozufozu.flywheel.backend.ShaderContext;
|
||||
import com.jozufozu.flywheel.backend.ShaderLoader;
|
||||
import com.jozufozu.flywheel.backend.core.CrumblingProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.IMultiProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.StateSensitiveMultiProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||
import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate;
|
||||
|
@ -26,6 +20,11 @@ import com.jozufozu.flywheel.backend.loading.ProgramTemplate;
|
|||
import com.jozufozu.flywheel.backend.loading.Shader;
|
||||
import com.jozufozu.flywheel.backend.loading.ShaderLoadingException;
|
||||
import com.jozufozu.flywheel.backend.loading.ShaderTransformer;
|
||||
import com.jozufozu.flywheel.core.shader.ExtensibleGlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.IMultiProgram;
|
||||
import com.jozufozu.flywheel.core.shader.StateSensitiveMultiProgram;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
package com.jozufozu.flywheel.backend.core;
|
||||
package com.jozufozu.flywheel.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.context.WorldContext;
|
||||
import com.jozufozu.flywheel.backend.core.shader.ShaderCallback;
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -52,7 +51,7 @@ public class WorldTileRenderer<P extends WorldProgram> extends InstancedTileRend
|
|||
|
||||
@Override
|
||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ,
|
||||
ShaderCallback<P> callback) {
|
||||
IProgramCallback<P> callback) {
|
||||
BlockPos originCoordinate = getOriginCoordinate();
|
||||
|
||||
camX -= originCoordinate.getX();
|
|
@ -1,21 +1,21 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.util;
|
||||
package com.jozufozu.flywheel.core.instancing;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
public class ConditionalInstance<D extends InstanceData> {
|
||||
|
||||
final InstancedModel<D> model;
|
||||
final Instancer<D> model;
|
||||
Condition condition;
|
||||
|
||||
@Nullable
|
||||
private D instance;
|
||||
|
||||
public ConditionalInstance(InstancedModel<D> model, Condition condition) {
|
||||
public ConditionalInstance(Instancer<D> model, Condition condition) {
|
||||
this.model = model;
|
||||
this.condition = condition;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.util;
|
||||
package com.jozufozu.flywheel.core.instancing;
|
||||
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
|
@ -6,20 +6,20 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
public class InstanceGroup<D extends InstanceData> extends AbstractCollection<D> {
|
||||
public class GroupInstance<D extends InstanceData> extends AbstractCollection<D> {
|
||||
|
||||
final InstancedModel<D> model;
|
||||
final Instancer<D> model;
|
||||
final List<D> backing;
|
||||
|
||||
public InstanceGroup(InstancedModel<D> model) {
|
||||
public GroupInstance(Instancer<D> model) {
|
||||
this.model = model;
|
||||
|
||||
this.backing = new ArrayList<>();
|
||||
}
|
||||
|
||||
public InstanceGroup(InstancedModel<D> model, int size) {
|
||||
public GroupInstance(Instancer<D> model, int size) {
|
||||
this.model = model;
|
||||
|
||||
this.backing = new ArrayList<>(size);
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.util;
|
||||
package com.jozufozu.flywheel.core.instancing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -7,11 +7,11 @@ import java.util.Optional;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
public class SelectInstance<D extends InstanceData> {
|
||||
|
||||
final List<InstancedModel<D>> models;
|
||||
final List<Instancer<D>> models;
|
||||
|
||||
ModelSelector selector;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class SelectInstance<D extends InstanceData> {
|
|||
this.selector = selector;
|
||||
}
|
||||
|
||||
public SelectInstance<D> addModel(InstancedModel<D> model) {
|
||||
public SelectInstance<D> addModel(Instancer<D> model) {
|
||||
models.add(model);
|
||||
return this;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package com.jozufozu.flywheel.backend.core.materials;
|
||||
package com.jozufozu.flywheel.core.materials;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
public class BasicData extends InstanceData implements IFlatLight<BasicData> {
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class BasicData extends InstanceData implements IFlatLight<BasicData> {
|
|||
protected byte b = (byte) 0xFF;
|
||||
protected byte a = (byte) 0xFF;
|
||||
|
||||
public BasicData(InstancedModel<?> owner) {
|
||||
public BasicData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.materials;
|
||||
package com.jozufozu.flywheel.core.materials;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.core.materials;
|
||||
package com.jozufozu.flywheel.core.materials;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.util.RenderUtil;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
@ -10,7 +10,7 @@ public class ModelData extends BasicData {
|
|||
|
||||
private float[] matrices = empty;
|
||||
|
||||
public ModelData(InstancedModel<?> owner) {
|
||||
public ModelData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.core.materials;
|
||||
package com.jozufozu.flywheel.core.materials;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
|
@ -22,7 +22,7 @@ public class OrientedData extends BasicData {
|
|||
private float qW;
|
||||
|
||||
|
||||
public OrientedData(InstancedModel<?> owner) {
|
||||
public OrientedData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -7,10 +7,10 @@ import java.util.List;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
|
||||
/**
|
||||
* A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and
|
|
@ -1,10 +1,10 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
||||
/**
|
||||
* Used to define shader uniforms.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IProgramCallback<P extends GlProgram> {
|
||||
|
||||
void call(P program);
|
||||
|
||||
default IProgramCallback<P> andThen(IProgramCallback<P> other) {
|
||||
return program -> {
|
||||
call(program);
|
||||
other.call(program);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -6,11 +6,11 @@ import java.util.List;
|
|||
|
||||
import com.jozufozu.flywheel.backend.ShaderContext;
|
||||
import com.jozufozu.flywheel.backend.ShaderLoader;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.IContextCondition;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.ProgramState;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.core.shader.spec.IContextCondition;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramState;
|
||||
import com.jozufozu.flywheel.util.Pair;
|
||||
|
||||
public class StateSensitiveMultiProgram<P extends GlProgram> implements IMultiProgram<P> {
|
|
@ -1,12 +1,12 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.UnitExtensionInstance;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.core.shader.extension.UnitExtensionInstance;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader;
|
||||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import static org.lwjgl.opengl.GL20.glUniform1f;
|
||||
import static org.lwjgl.opengl.GL20.glUniform3f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.extension;
|
||||
package com.jozufozu.flywheel.core.shader.extension;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.extension;
|
||||
package com.jozufozu.flywheel.core.shader.extension;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.extension;
|
||||
package com.jozufozu.flywheel.core.shader.extension;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.gamestate;
|
||||
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.core.shader.GlFog;
|
||||
import com.jozufozu.flywheel.core.shader.GlFog;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.gamestate;
|
||||
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry;
|
||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.gamestate;
|
||||
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.IBooleanStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.gamestate;
|
||||
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.spec.IBooleanStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||
|
||||
public interface IBooleanStateProvider extends IGameStateProvider {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
|
@ -1,9 +1,9 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.util.CodecUtil;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.serialization.Codec;
|
|
@ -1,14 +1,14 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.WorldFog;
|
||||
import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.FogStateProvider;
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.NormalDebugStateProvider;
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.RainbowDebugStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.WorldFog;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.FogStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.NormalDebugStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.RainbowDebugStateProvider;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.core.shader.spec;
|
||||
package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider;
|
||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.light;
|
||||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import static com.jozufozu.flywheel.util.RenderUtil.isPowerOf2;
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class GridAlignedBB {
|
|||
return this.minX < maxX && this.maxX > minX && this.minY < maxY && this.maxY > minY && this.minZ < maxZ && this.maxZ > minZ;
|
||||
}
|
||||
|
||||
public void forEachContained(CoordinateConsumer func) {
|
||||
public void forEachContained(ICoordinateConsumer func) {
|
||||
if (empty()) return;
|
||||
|
||||
for (int x = minX; x < maxX; x++) {
|
|
@ -0,0 +1,6 @@
|
|||
package com.jozufozu.flywheel.light;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ICoordinateConsumer {
|
||||
void consume(int x, int y, int z);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.light;
|
||||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
|
@ -7,7 +7,7 @@ import net.minecraft.world.LightType;
|
|||
* Anything can implement this, implementors should call {@link LightUpdater#startListening}
|
||||
* appropriately to make sure they get the updates they want.
|
||||
*/
|
||||
public interface LightUpdateListener {
|
||||
public interface ILightUpdateListener {
|
||||
|
||||
/**
|
||||
* Called when a light updates in a chunk the implementor cares about.
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.light;
|
||||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.LongConsumer;
|
||||
|
@ -33,11 +33,11 @@ public class LightUpdater {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private final Long2ObjectMap<WeakHashSet<LightUpdateListener>> sections;
|
||||
private final WeakHashMap<LightUpdateListener, LongRBTreeSet> listenersToSections;
|
||||
private final Long2ObjectMap<WeakHashSet<ILightUpdateListener>> sections;
|
||||
private final WeakHashMap<ILightUpdateListener, LongRBTreeSet> listenersToSections;
|
||||
|
||||
private final Long2ObjectMap<WeakHashSet<LightUpdateListener>> chunks;
|
||||
private final WeakHashMap<LightUpdateListener, LongRBTreeSet> listenersToChunks;
|
||||
private final Long2ObjectMap<WeakHashSet<ILightUpdateListener>> chunks;
|
||||
private final WeakHashMap<ILightUpdateListener, LongRBTreeSet> listenersToChunks;
|
||||
|
||||
public LightUpdater() {
|
||||
sections = new Long2ObjectOpenHashMap<>();
|
||||
|
@ -51,12 +51,12 @@ public class LightUpdater {
|
|||
* Add a listener associated with the given {@link BlockPos}.
|
||||
* <p>
|
||||
* When a light update occurs in the chunk the position is contained in,
|
||||
* {@link LightUpdateListener#onLightUpdate} will be called.
|
||||
* {@link ILightUpdateListener#onLightUpdate} will be called.
|
||||
*
|
||||
* @param pos The position in the world that the listener cares about.
|
||||
* @param listener The object that wants to receive light update notifications.
|
||||
*/
|
||||
public void startListening(BlockPos pos, LightUpdateListener listener) {
|
||||
public void startListening(BlockPos pos, ILightUpdateListener listener) {
|
||||
LongRBTreeSet sections = clearSections(listener);
|
||||
LongRBTreeSet chunks = clearChunks(listener);
|
||||
|
||||
|
@ -73,12 +73,12 @@ public class LightUpdater {
|
|||
* Add a listener associated with the given {@link GridAlignedBB}.
|
||||
* <p>
|
||||
* When a light update occurs in any chunk spanning the given volume,
|
||||
* {@link LightUpdateListener#onLightUpdate} will be called.
|
||||
* {@link ILightUpdateListener#onLightUpdate} will be called.
|
||||
*
|
||||
* @param volume The volume in the world that the listener cares about.
|
||||
* @param listener The object that wants to receive light update notifications.
|
||||
*/
|
||||
public void startListening(GridAlignedBB volume, LightUpdateListener listener) {
|
||||
public void startListening(GridAlignedBB volume, ILightUpdateListener listener) {
|
||||
LongRBTreeSet sections = clearSections(listener);
|
||||
LongRBTreeSet chunks = clearSections(listener);
|
||||
|
||||
|
@ -104,14 +104,14 @@ public class LightUpdater {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dispatch light updates to all registered {@link LightUpdateListener}s.
|
||||
* Dispatch light updates to all registered {@link ILightUpdateListener}s.
|
||||
*
|
||||
* @param world The world in which light was updated.
|
||||
* @param type The type of light that changed.
|
||||
* @param sectionPos A long representing the section position where light changed.
|
||||
*/
|
||||
public void onLightUpdate(IBlockDisplayReader world, LightType type, long sectionPos) {
|
||||
WeakHashSet<LightUpdateListener> set = sections.get(sectionPos);
|
||||
WeakHashSet<ILightUpdateListener> set = sections.get(sectionPos);
|
||||
|
||||
if (set == null || set.isEmpty()) return;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class LightUpdater {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dispatch light updates to all registered {@link LightUpdateListener}s
|
||||
* Dispatch light updates to all registered {@link ILightUpdateListener}s
|
||||
* when the server sends lighting data for an entire chunk.
|
||||
*
|
||||
* @param world The world in which light was updated.
|
||||
|
@ -130,22 +130,22 @@ public class LightUpdater {
|
|||
|
||||
long chunkPos = SectionPos.asLong(chunkX, 0, chunkZ);
|
||||
|
||||
WeakHashSet<LightUpdateListener> set = chunks.get(chunkPos);
|
||||
WeakHashSet<ILightUpdateListener> set = chunks.get(chunkPos);
|
||||
|
||||
if (set == null || set.isEmpty()) return;
|
||||
|
||||
set.removeIf(listener -> listener.onLightPacket(world, chunkX, chunkZ));
|
||||
}
|
||||
|
||||
private LongRBTreeSet clearChunks(LightUpdateListener listener) {
|
||||
private LongRBTreeSet clearChunks(ILightUpdateListener listener) {
|
||||
return clear(listener, listenersToChunks, chunks);
|
||||
}
|
||||
|
||||
private LongRBTreeSet clearSections(LightUpdateListener listener) {
|
||||
private LongRBTreeSet clearSections(ILightUpdateListener listener) {
|
||||
return clear(listener, listenersToSections, sections);
|
||||
}
|
||||
|
||||
private LongRBTreeSet clear(LightUpdateListener listener, WeakHashMap<LightUpdateListener, LongRBTreeSet> listeners, Long2ObjectMap<WeakHashSet<LightUpdateListener>> lookup) {
|
||||
private LongRBTreeSet clear(ILightUpdateListener listener, WeakHashMap<ILightUpdateListener, LongRBTreeSet> listeners, Long2ObjectMap<WeakHashSet<ILightUpdateListener>> lookup) {
|
||||
LongRBTreeSet set = listeners.get(listener);
|
||||
|
||||
if (set == null) {
|
||||
|
@ -153,7 +153,7 @@ public class LightUpdater {
|
|||
listeners.put(listener, set);
|
||||
} else {
|
||||
set.forEach((LongConsumer) l -> {
|
||||
WeakHashSet<LightUpdateListener> listeningSections = lookup.get(l);
|
||||
WeakHashSet<ILightUpdateListener> listeningSections = lookup.get(l);
|
||||
|
||||
if (listeningSections != null) listeningSections.remove(listener);
|
||||
});
|
||||
|
@ -164,16 +164,16 @@ public class LightUpdater {
|
|||
return set;
|
||||
}
|
||||
|
||||
private void addToSection(long sectionPos, LightUpdateListener listener) {
|
||||
private void addToSection(long sectionPos, ILightUpdateListener listener) {
|
||||
getOrCreate(sections, sectionPos).add(listener);
|
||||
}
|
||||
|
||||
private void addToChunk(long chunkPos, LightUpdateListener listener) {
|
||||
private void addToChunk(long chunkPos, ILightUpdateListener listener) {
|
||||
getOrCreate(chunks, chunkPos).add(listener);
|
||||
}
|
||||
|
||||
private WeakHashSet<LightUpdateListener> getOrCreate(Long2ObjectMap<WeakHashSet<LightUpdateListener>> sections, long chunkPos) {
|
||||
WeakHashSet<LightUpdateListener> set = sections.get(chunkPos);
|
||||
private WeakHashSet<ILightUpdateListener> getOrCreate(Long2ObjectMap<WeakHashSet<ILightUpdateListener>> sections, long chunkPos) {
|
||||
WeakHashSet<ILightUpdateListener> set = sections.get(chunkPos);
|
||||
|
||||
if (set == null) {
|
||||
set = new WeakHashSet<>();
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.backend.light;
|
||||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -8,8 +8,8 @@ public class AttribUtil {
|
|||
enableArrays(0, count);
|
||||
}
|
||||
|
||||
public static void enableArrays(int start, int end) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
public static void enableArrays(int fromInclusive, int toExclusive) {
|
||||
for (int i = fromInclusive; i < toExclusive; i++) {
|
||||
GL20.glEnableVertexAttribArray(i);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ public class AttribUtil {
|
|||
disableArrays(0, count);
|
||||
}
|
||||
|
||||
public static void disableArrays(int start, int end) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
public static void disableArrays(int fromInclusive, int toExclusive) {
|
||||
for (int i = fromInclusive; i < toExclusive; i++) {
|
||||
GL20.glDisableVertexAttribArray(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
@ -98,7 +98,7 @@ public class AllBlockPartials {
|
|||
GOGGLES = get("goggles"),
|
||||
|
||||
EJECTOR_TOP = get("weighted_ejector/top"),
|
||||
|
||||
|
||||
COPPER_BACKTANK_SHAFT = get("copper_backtank/block_shaft_input"),
|
||||
COPPER_BACKTANK_COGS = get("copper_backtank/block_cogs"),
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.compat.jei.category.animations;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.compat.jei.category.animations;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
|
@ -13,7 +13,7 @@ public class HalfShaftInstance extends SingleRotatingInstance {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
protected Instancer<RotatingData> getModel() {
|
||||
Direction dir = getShaftDirection();
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, dir);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.materials.BasicData;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.core.materials.BasicData;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -15,7 +15,7 @@ public class KineticData extends BasicData {
|
|||
private float rotationalSpeed;
|
||||
private float rotationOffset;
|
||||
|
||||
protected KineticData(InstancedModel<?> owner) {
|
||||
protected KineticData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
@ -11,7 +11,7 @@ public class RotatingData extends KineticData {
|
|||
private byte rotationAxisY;
|
||||
private byte rotationAxisZ;
|
||||
|
||||
public RotatingData(InstancedModel<?> owner) {
|
||||
public RotatingData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class ShaftlessCogInstance extends SingleRotatingInstance {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
protected Instancer<RotatingData> getModel() {
|
||||
return renderer.getMaterial(AllMaterialSpecs.ROTATING).getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntit
|
|||
return blockState;
|
||||
}
|
||||
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
protected Instancer<RotatingData> getModel() {
|
||||
return getRotatingMaterial().getModel(getRenderedBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
|
@ -28,7 +28,7 @@ public class ActorData extends InstanceData {
|
|||
|
||||
private float speed;
|
||||
|
||||
public ActorData(InstancedModel<?> owner) {
|
||||
public ActorData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||
|
@ -19,7 +19,7 @@ public class DrillInstance extends SingleRotatingInstance {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
protected Instancer<RotatingData> getModel() {
|
||||
BlockState referenceState = tile.getBlockState();
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing);
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.components.clock;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class CuckooClockTileEntity extends KineticTileEntity {
|
|||
super(type);
|
||||
animationType = Animation.NONE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
|
||||
super.fromTag(state, compound, clientPacket);
|
||||
|
@ -51,7 +51,7 @@ public class CuckooClockTileEntity extends KineticTileEntity {
|
|||
animationProgress.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(CompoundNBT compound, boolean clientPacket) {
|
||||
if (clientPacket && sendAnimationUpdate)
|
||||
|
@ -150,10 +150,10 @@ public class CuckooClockTileEntity extends KineticTileEntity {
|
|||
animationProgress.lastValue = 0;
|
||||
animationProgress.value = 0;
|
||||
sendAnimationUpdate = true;
|
||||
|
||||
|
||||
if (animation == Animation.CREEPER)
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.CUCKOO, world, pos, 10);
|
||||
|
||||
|
||||
sendData();
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ public class CuckooClockTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderAsTE() {
|
||||
public boolean shouldRenderNormally() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.crafter;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
|
@ -20,7 +20,7 @@ public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
protected Instancer<RotatingData> getModel() {
|
||||
Direction facing = blockState.get(MechanicalCrafterBlock.HORIZONTAL_FACING);
|
||||
|
||||
Supplier<MatrixStack> ms = () -> {
|
||||
|
|
|
@ -4,7 +4,7 @@ import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlo
|
|||
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
|
|
@ -285,7 +285,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
|
|||
Pointing pointing = getBlockState().get(MechanicalCrafterBlock.POINTING);
|
||||
groupedItems.mergeOnto(targetingCrafter.groupedItems, pointing);
|
||||
groupedItems = new GroupedItems();
|
||||
|
||||
|
||||
float pitch = targetingCrafter.groupedItems.grid.size() * 1/16f + .5f;
|
||||
AllSoundEvents.CRAFTER_CLICK.playOnServer(world, pos, 1, pitch);
|
||||
|
||||
|
@ -335,12 +335,12 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
|
|||
|
||||
int prev = countDown;
|
||||
countDown -= getCountDownSpeed();
|
||||
|
||||
|
||||
if (countDown < 1000 && prev >= 1000) {
|
||||
AllSoundEvents.CRAFTER_CLICK.playOnServer(world, pos, 1, 2);
|
||||
AllSoundEvents.CRAFTER_CRAFT.playOnServer(world, pos);
|
||||
}
|
||||
|
||||
|
||||
if (countDown < 0) {
|
||||
countDown = 0;
|
||||
if (!runLogic)
|
||||
|
@ -513,7 +513,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderAsTE() {
|
||||
public boolean shouldRenderNormally() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.components.crank;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.simibubi.create.content.contraptions.components.crank;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.backend.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedModel;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -33,7 +33,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
|
|||
|
||||
facing = blockState.get(BlockStateProperties.FACING);
|
||||
Direction opposite = facing.getOpposite();
|
||||
InstancedModel<ModelData> model = getTransformMaterial().getModel(renderedHandle, blockState, opposite);
|
||||
Instancer<ModelData> model = getTransformMaterial().getModel(renderedHandle, blockState, opposite);
|
||||
crank = model.createInstance();
|
||||
|
||||
rotateCrank();
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.crank;
|
|||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
|
|
|
@ -77,7 +77,7 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderAsTE() {
|
||||
public boolean shouldRenderNormally() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.crank;
|
|||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.DyeHelper;
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.deployer;
|
|||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.backend.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.simibubi.create.content.contraptions.components.deployer;
|
|||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.backend.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
|
|
|
@ -4,7 +4,7 @@ import static com.simibubi.create.content.contraptions.base.DirectionalAxisKinet
|
|||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue