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.Batched;
|
||||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
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.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.jozufozu.flywheel.util.RenderMath;
|
import com.jozufozu.flywheel.util.RenderMath;
|
||||||
@ -22,13 +22,13 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexFormat format() {
|
public BufferLayout getLayout() {
|
||||||
return AllInstanceFormats.BELT;
|
return AllInstanceFormats.BELT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StructWriter<BeltData> getWriter(VecBuffer backing) {
|
public StructWriter<BeltData> getWriter(VecBuffer backing) {
|
||||||
return new UnsafeBeltWriter(backing, this);
|
return new BeltWriterUnsafe(backing, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil;
|
|||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
|
|
||||||
public class UnsafeBeltWriter extends UnsafeKineticWriter<BeltData> {
|
public class BeltWriterUnsafe extends KineticWriterUnsafe<BeltData> {
|
||||||
public UnsafeBeltWriter(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
|
public BeltWriterUnsafe(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
|
||||||
super(backingBuffer, vertexType);
|
super(backingBuffer, vertexType);
|
||||||
}
|
}
|
||||||
|
|
@ -4,10 +4,10 @@ import org.lwjgl.system.MemoryUtil;
|
|||||||
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
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 abstract class KineticWriterUnsafe<D extends KineticData> extends BasicWriterUnsafe<D> {
|
||||||
public UnsafeKineticWriter(VecBuffer backingBuffer, StructType<D> vertexType) {
|
public KineticWriterUnsafe(VecBuffer backingBuffer, StructType<D> vertexType) {
|
||||||
super(backingBuffer, 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.Batched;
|
||||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
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.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.jozufozu.flywheel.util.RenderMath;
|
import com.jozufozu.flywheel.util.RenderMath;
|
||||||
@ -22,13 +22,13 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexFormat format() {
|
public BufferLayout getLayout() {
|
||||||
return AllInstanceFormats.ROTATING;
|
return AllInstanceFormats.ROTATING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StructWriter<RotatingData> getWriter(VecBuffer backing) {
|
public StructWriter<RotatingData> getWriter(VecBuffer backing) {
|
||||||
return new UnsafeRotatingWriter(backing, this);
|
return new RotatingWriterUnsafe(backing, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil;
|
|||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
|
|
||||||
public class UnsafeRotatingWriter extends UnsafeKineticWriter<RotatingData> {
|
public class RotatingWriterUnsafe extends KineticWriterUnsafe<RotatingData> {
|
||||||
public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
|
public RotatingWriterUnsafe(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
|
||||||
super(backingBuffer, 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.Batched;
|
||||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
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.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
@ -18,7 +18,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexFormat format() {
|
public BufferLayout getLayout() {
|
||||||
return AllInstanceFormats.ACTOR;
|
return AllInstanceFormats.ACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.simibubi.create.content.contraptions.components.structureMovement.glue;
|
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.model.Model;
|
||||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalVertexListUnsafe;
|
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe;
|
||||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriter;
|
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||||
import com.jozufozu.flywheel.core.vertex.VertexList;
|
|
||||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
import com.mojang.blaze3d.platform.MemoryTracker;
|
||||||
import com.simibubi.create.AllStitchedTextures;
|
import com.simibubi.create.AllStitchedTextures;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
@ -21,10 +21,10 @@ public class GlueModel implements Model {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PosTexNormalVertexListUnsafe reader;
|
private final VertexList reader;
|
||||||
|
|
||||||
private GlueModel() {
|
private GlueModel() {
|
||||||
PosTexNormalWriter writer = new PosTexNormalWriter(MemoryTracker.create(size()));
|
PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size()));
|
||||||
createGlueModel(writer);
|
createGlueModel(writer);
|
||||||
reader = writer.intoReader();
|
reader = writer.intoReader();
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class GlueModel implements Model {
|
|||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createGlueModel(PosTexNormalWriter buffer) {
|
public static void createGlueModel(PosTexNormalWriterUnsafe buffer) {
|
||||||
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
|
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
|
||||||
Vec3 extension = diff.normalize()
|
Vec3 extension = diff.normalize()
|
||||||
.scale(1 / 32f - 1 / 128f);
|
.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.Batched;
|
||||||
import com.jozufozu.flywheel.api.struct.Instanced;
|
import com.jozufozu.flywheel.api.struct.Instanced;
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
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.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
@ -18,7 +18,7 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexFormat format() {
|
public BufferLayout getLayout() {
|
||||||
return AllInstanceFormats.FLAP;
|
return AllInstanceFormats.FLAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
package com.simibubi.create.foundation.render;
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
import com.jozufozu.flywheel.core.layout.CommonItems;
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||||
|
|
||||||
public class AllInstanceFormats {
|
public class AllInstanceFormats {
|
||||||
|
|
||||||
public static VertexFormat ROTATING = kineticInstance()
|
public static BufferLayout ROTATING = kineticInstance()
|
||||||
.addAttributes(CommonAttributes.NORMAL)
|
.addItems(CommonItems.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static VertexFormat BELT = kineticInstance()
|
public static BufferLayout BELT = kineticInstance()
|
||||||
.addAttributes(CommonAttributes.QUATERNION, CommonAttributes.UV, CommonAttributes.VEC4,
|
.addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4,
|
||||||
CommonAttributes.NORMALIZED_BYTE)
|
CommonItems.NORMALIZED_BYTE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static VertexFormat ACTOR = VertexFormat.builder()
|
public static BufferLayout ACTOR = BufferLayout.builder()
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.FLOAT,
|
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT,
|
||||||
CommonAttributes.NORMAL, CommonAttributes.QUATERNION, CommonAttributes.NORMAL,
|
CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL,
|
||||||
CommonAttributes.FLOAT)
|
CommonItems.FLOAT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static VertexFormat FLAP = VertexFormat.builder()
|
public static BufferLayout FLAP = BufferLayout.builder()
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.VEC3, CommonAttributes.VEC3,
|
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3,
|
||||||
CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT)
|
CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static VertexFormat.Builder kineticInstance() {
|
private static BufferLayout.Builder kineticInstance() {
|
||||||
return VertexFormat.builder()
|
return BufferLayout.builder()
|
||||||
.addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA)
|
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT);
|
.addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.simibubi.create.foundation.render;
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
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.Rotate;
|
||||||
import com.jozufozu.flywheel.util.transform.Scale;
|
import com.jozufozu.flywheel.util.transform.Scale;
|
||||||
import com.jozufozu.flywheel.util.transform.TStack;
|
import com.jozufozu.flywheel.util.transform.TStack;
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
vec3 normal;
|
|
||||||
vec2 texCoords;
|
|
||||||
vec4 color;
|
vec4 color;
|
||||||
|
vec2 texCoords;
|
||||||
vec2 modelLight;
|
vec2 modelLight;
|
||||||
|
vec3 normal;
|
||||||
};
|
};
|
||||||
|
|
||||||
#use "flywheel:block.frag"
|
#use "flywheel:block.frag"
|
||||||
|
Loading…
Reference in New Issue
Block a user