mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Finally safe vertex formats
- true to false for Pepper - IBufferedModel -> BufferedModel - VertexFormat -> BufferLayout - Use ImmutableList in BufferLayout - LayoutItem naming consistency - Try to reduce usage of raw BufferLayouts - Move vertex interfaces to api package - #createWriter and #createReader in VertexType - Some documentation
This commit is contained in:
parent
b8034b4b2e
commit
97490e51ca
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata;
|
||||
import com.jozufozu.flywheel.api.struct.Batched;
|
||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||
import com.jozufozu.flywheel.util.RenderMath;
|
||||
@ -22,13 +22,13 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat format() {
|
||||
public BufferLayout getLayout() {
|
||||
return AllInstanceFormats.BELT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructWriter<BeltData> getWriter(VecBuffer backing) {
|
||||
return new UnsafeBeltWriter(backing, this);
|
||||
return new BeltWriterUnsafe(backing, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
|
||||
public class UnsafeBeltWriter extends UnsafeKineticWriter<BeltData> {
|
||||
public UnsafeBeltWriter(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
|
||||
public class BeltWriterUnsafe extends KineticWriterUnsafe<BeltData> {
|
||||
public BeltWriterUnsafe(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
|
||||
super(backingBuffer, vertexType);
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.materials.UnsafeBasicWriter;
|
||||
import com.jozufozu.flywheel.core.materials.BasicWriterUnsafe;
|
||||
|
||||
public abstract class UnsafeKineticWriter<D extends KineticData> extends UnsafeBasicWriter<D> {
|
||||
public UnsafeKineticWriter(VecBuffer backingBuffer, StructType<D> vertexType) {
|
||||
public abstract class KineticWriterUnsafe<D extends KineticData> extends BasicWriterUnsafe<D> {
|
||||
public KineticWriterUnsafe(VecBuffer backingBuffer, StructType<D> vertexType) {
|
||||
super(backingBuffer, vertexType);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata;
|
||||
import com.jozufozu.flywheel.api.struct.Batched;
|
||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||
import com.jozufozu.flywheel.util.RenderMath;
|
||||
@ -22,13 +22,13 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat format() {
|
||||
public BufferLayout getLayout() {
|
||||
return AllInstanceFormats.ROTATING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructWriter<RotatingData> getWriter(VecBuffer backing) {
|
||||
return new UnsafeRotatingWriter(backing, this);
|
||||
return new RotatingWriterUnsafe(backing, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
|
||||
public class UnsafeRotatingWriter extends UnsafeKineticWriter<RotatingData> {
|
||||
public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
|
||||
public class RotatingWriterUnsafe extends KineticWriterUnsafe<RotatingData> {
|
||||
public RotatingWriterUnsafe(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
|
||||
super(backingBuffer, vertexType);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors.flwdata;
|
||||
import com.jozufozu.flywheel.api.struct.Batched;
|
||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||
@ -18,7 +18,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat format() {
|
||||
public BufferLayout getLayout() {
|
||||
return AllInstanceFormats.ACTOR;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.simibubi.create.content.contraptions.components.structureMovement.glue;
|
||||
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalVertexListUnsafe;
|
||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriter;
|
||||
import com.jozufozu.flywheel.core.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
||||
import com.simibubi.create.AllStitchedTextures;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
@ -21,10 +21,10 @@ public class GlueModel implements Model {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private final PosTexNormalVertexListUnsafe reader;
|
||||
private final VertexList reader;
|
||||
|
||||
private GlueModel() {
|
||||
PosTexNormalWriter writer = new PosTexNormalWriter(MemoryTracker.create(size()));
|
||||
PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size()));
|
||||
createGlueModel(writer);
|
||||
reader = writer.intoReader();
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class GlueModel implements Model {
|
||||
return reader;
|
||||
}
|
||||
|
||||
public static void createGlueModel(PosTexNormalWriter buffer) {
|
||||
public static void createGlueModel(PosTexNormalWriterUnsafe buffer) {
|
||||
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
|
||||
Vec3 extension = diff.normalize()
|
||||
.scale(1 / 32f - 1 / 128f);
|
||||
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.flap;
|
||||
import com.jozufozu.flywheel.api.struct.Batched;
|
||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||
@ -18,7 +18,7 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat format() {
|
||||
public BufferLayout getLayout() {
|
||||
return AllInstanceFormats.FLAP;
|
||||
}
|
||||
|
||||
|
@ -1,33 +1,33 @@
|
||||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
import com.jozufozu.flywheel.core.layout.CommonItems;
|
||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||
|
||||
public class AllInstanceFormats {
|
||||
|
||||
public static VertexFormat ROTATING = kineticInstance()
|
||||
.addAttributes(CommonAttributes.NORMAL)
|
||||
public static BufferLayout ROTATING = kineticInstance()
|
||||
.addItems(CommonItems.NORMAL)
|
||||
.build();
|
||||
|
||||
public static VertexFormat BELT = kineticInstance()
|
||||
.addAttributes(CommonAttributes.QUATERNION, CommonAttributes.UV, CommonAttributes.VEC4,
|
||||
CommonAttributes.NORMALIZED_BYTE)
|
||||
public static BufferLayout BELT = kineticInstance()
|
||||
.addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4,
|
||||
CommonItems.NORMALIZED_BYTE)
|
||||
.build();
|
||||
|
||||
public static VertexFormat ACTOR = VertexFormat.builder()
|
||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.FLOAT,
|
||||
CommonAttributes.NORMAL, CommonAttributes.QUATERNION, CommonAttributes.NORMAL,
|
||||
CommonAttributes.FLOAT)
|
||||
public static BufferLayout ACTOR = BufferLayout.builder()
|
||||
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT,
|
||||
CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL,
|
||||
CommonItems.FLOAT)
|
||||
.build();
|
||||
|
||||
public static VertexFormat FLAP = VertexFormat.builder()
|
||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.VEC3, CommonAttributes.VEC3,
|
||||
CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT)
|
||||
public static BufferLayout FLAP = BufferLayout.builder()
|
||||
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3,
|
||||
CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT)
|
||||
.build();
|
||||
|
||||
private static VertexFormat.Builder kineticInstance() {
|
||||
return VertexFormat.builder()
|
||||
.addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA)
|
||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT);
|
||||
private static BufferLayout.Builder kineticInstance() {
|
||||
return BufferLayout.builder()
|
||||
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
||||
.addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
||||
import com.jozufozu.flywheel.core.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.util.transform.Rotate;
|
||||
import com.jozufozu.flywheel.util.transform.Scale;
|
||||
import com.jozufozu.flywheel.util.transform.TStack;
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
struct Vertex {
|
||||
vec3 pos;
|
||||
vec3 normal;
|
||||
vec2 texCoords;
|
||||
vec4 color;
|
||||
vec2 texCoords;
|
||||
vec2 modelLight;
|
||||
vec3 normal;
|
||||
};
|
||||
|
||||
#use "flywheel:block.frag"
|
||||
|
Loading…
Reference in New Issue
Block a user