Unsafe writers for StructTypes

- Bump flywheel build
This commit is contained in:
Jozufozu 2021-12-02 19:26:33 -08:00
parent e1d8415b09
commit 85b1b86883
41 changed files with 345 additions and 105 deletions

View file

@ -19,7 +19,7 @@ parchment_version = 2021.10.31
# dependency versions
registrate_version = MC1.17.1-1.0.14
flywheel_version = 1.17-0.3.0.17
flywheel_version = 1.17-0.3.0.19
jei_version = 8.2.0.36
# curseforge information

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
public class CutoutRotatingInstance extends SingleRotatingInstance {

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;

View file

@ -4,6 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
import com.simibubi.create.foundation.render.AllMaterialSpecs;

View file

@ -7,6 +7,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.AxisDirection;

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
public class ShaftlessLargeCogInstance extends SingleRotatingInstance {

View file

@ -2,17 +2,18 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import net.minecraft.world.level.block.state.BlockState;
public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntity> {
protected RotatingData rotatingModel;
public SingleRotatingInstance(MaterialManager modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
public void init() {
rotatingModel = setup(getModel().createInstance());

View file

@ -1,24 +1,23 @@
package com.simibubi.create.content.contraptions.relays.belt;
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.mojang.math.Quaternion;
import com.simibubi.create.content.contraptions.base.KineticData;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
public class BeltData extends KineticData {
private float qX;
private float qY;
private float qZ;
private float qW;
private float sourceU;
private float sourceV;
private float minU;
private float minV;
private float maxU;
private float maxV;
private byte scrollMult;
float qX;
float qY;
float qZ;
float qW;
float sourceU;
float sourceV;
float minU;
float minV;
float maxU;
float maxV;
byte scrollMult;
public BeltData setRotation(Quaternion q) {
this.qX = q.i();

View file

@ -0,0 +1,24 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.StructWriter;
import com.simibubi.create.foundation.render.AllInstanceFormats;
public class BeltType implements StructType<BeltData> {
@Override
public BeltData create() {
return new BeltData();
}
@Override
public VertexFormat format() {
return AllInstanceFormats.BELT;
}
@Override
public StructWriter<BeltData> getWriter(VecBuffer backing) {
return new UnsafeBeltWriter(backing, this);
}
}

View file

@ -1,18 +1,19 @@
package com.simibubi.create.content.contraptions.base;
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.materials.BasicData;
import com.mojang.math.Vector3f;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.core.BlockPos;
public class KineticData extends BasicData {
private float x;
private float y;
private float z;
private float rotationalSpeed;
private float rotationOffset;
float x;
float y;
float z;
float rotationalSpeed;
float rotationOffset;
public KineticData setPosition(BlockPos pos) {
return setPosition(pos.getX(), pos.getY(), pos.getZ());

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.contraptions.base;
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.mojang.math.Vector3f;
@ -6,9 +6,9 @@ import com.mojang.math.Vector3f;
import net.minecraft.core.Direction;
public class RotatingData extends KineticData {
private byte rotationAxisX;
private byte rotationAxisY;
private byte rotationAxisZ;
byte rotationAxisX;
byte rotationAxisY;
byte rotationAxisZ;
public RotatingData setRotationAxis(Direction.Axis axis) {
Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis);

View file

@ -0,0 +1,24 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.StructWriter;
import com.simibubi.create.foundation.render.AllInstanceFormats;
public class RotatingType implements StructType<RotatingData> {
@Override
public RotatingData create() {
return new RotatingData();
}
@Override
public VertexFormat format() {
return AllInstanceFormats.ROTATING;
}
@Override
public StructWriter<RotatingData> getWriter(VecBuffer backing) {
return new UnsafeRotatingWriter(backing, this);
}
}

View file

@ -0,0 +1,42 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeBeltWriter extends UnsafeBufferWriter<BeltData> {
public UnsafeBeltWriter(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(BeltData d) {
long addr = writePointer;
MemoryUtil.memPutByte(addr, d.blockLight);
MemoryUtil.memPutByte(addr + 1, d.skyLight);
MemoryUtil.memPutByte(addr + 2, d.r);
MemoryUtil.memPutByte(addr + 3, d.g);
MemoryUtil.memPutByte(addr + 4, d.b);
MemoryUtil.memPutByte(addr + 5, d.a);
MemoryUtil.memPutFloat(addr + 6, d.x);
MemoryUtil.memPutFloat(addr + 10, d.y);
MemoryUtil.memPutFloat(addr + 14, d.z);
MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed);
MemoryUtil.memPutFloat(addr + 22, d.rotationOffset);
MemoryUtil.memPutFloat(addr + 26, d.qX);
MemoryUtil.memPutFloat(addr + 30, d.qY);
MemoryUtil.memPutFloat(addr + 34, d.qZ);
MemoryUtil.memPutFloat(addr + 38, d.qW);
MemoryUtil.memPutFloat(addr + 42, d.sourceU);
MemoryUtil.memPutFloat(addr + 46, d.sourceV);
MemoryUtil.memPutFloat(addr + 50, d.minU);
MemoryUtil.memPutFloat(addr + 54, d.minV);
MemoryUtil.memPutFloat(addr + 58, d.maxU);
MemoryUtil.memPutFloat(addr + 62, d.maxV);
MemoryUtil.memPutByte(addr + 66, d.scrollMult);
advance();
}
}

View file

@ -0,0 +1,34 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeRotatingWriter extends UnsafeBufferWriter<RotatingData> {
public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(RotatingData d) {
long addr = writePointer;
MemoryUtil.memPutByte(addr, d.blockLight);
MemoryUtil.memPutByte(addr + 1, d.skyLight);
MemoryUtil.memPutByte(addr + 2, d.r);
MemoryUtil.memPutByte(addr + 3, d.g);
MemoryUtil.memPutByte(addr + 4, d.b);
MemoryUtil.memPutByte(addr + 5, d.a);
MemoryUtil.memPutFloat(addr + 6, d.x);
MemoryUtil.memPutFloat(addr + 10, d.y);
MemoryUtil.memPutFloat(addr + 14, d.z);
MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed);
MemoryUtil.memPutFloat(addr + 22, d.rotationOffset);
MemoryUtil.memPutByte(addr + 26, d.rotationAxisX);
MemoryUtil.memPutByte(addr + 27, d.rotationAxisY);
MemoryUtil.memPutByte(addr + 28, d.rotationAxisZ);
advance();
}
}

View file

@ -6,6 +6,7 @@ import com.mojang.math.Quaternion;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.content.contraptions.components.actors.flwdata.ActorData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper;

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.contraptions.components.actors;
package com.simibubi.create.content.contraptions.components.actors.flwdata;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.instancing.InstanceData;
@ -8,24 +8,23 @@ import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
public class ActorData extends InstanceData {
private float x;
private float y;
private float z;
private byte blockLight;
private byte skyLight;
private float rotationOffset;
private byte rotationAxisX;
private byte rotationAxisY;
private byte rotationAxisZ;
private float qX;
private float qY;
private float qZ;
private float qW;
private byte rotationCenterX = 64;
private byte rotationCenterY = 64;
private byte rotationCenterZ = 64;
private float speed;
float x;
float y;
float z;
byte blockLight;
byte skyLight;
float rotationOffset;
byte rotationAxisX;
byte rotationAxisY;
byte rotationAxisZ;
float qX;
float qY;
float qZ;
float qW;
byte rotationCenterX = 64;
byte rotationCenterY = 64;
byte rotationCenterZ = 64;
float speed;
public ActorData setPosition(BlockPos pos) {
this.x = pos.getX();

View file

@ -0,0 +1,24 @@
package com.simibubi.create.content.contraptions.components.actors.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.StructWriter;
import com.simibubi.create.foundation.render.AllInstanceFormats;
public class ActorType implements StructType<ActorData> {
@Override
public ActorData create() {
return new ActorData();
}
@Override
public VertexFormat format() {
return AllInstanceFormats.BELT;
}
@Override
public StructWriter<ActorData> getWriter(VecBuffer backing) {
return new UnsafeActorWriter(backing, this);
}
}

View file

@ -0,0 +1,36 @@
package com.simibubi.create.content.contraptions.components.actors.flwdata;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeActorWriter extends UnsafeBufferWriter<ActorData> {
public UnsafeActorWriter(VecBuffer backingBuffer, StructType<ActorData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(ActorData d) {
long addr = writePointer;
MemoryUtil.memPutFloat(addr, d.x);
MemoryUtil.memPutFloat(addr + 4, d.y);
MemoryUtil.memPutFloat(addr + 8, d.z);
MemoryUtil.memPutByte(addr + 12, d.blockLight);
MemoryUtil.memPutByte(addr + 13, d.skyLight);
MemoryUtil.memPutFloat(addr + 14, d.rotationOffset);
MemoryUtil.memPutByte(addr + 18, d.rotationAxisX);
MemoryUtil.memPutByte(addr + 19, d.rotationAxisY);
MemoryUtil.memPutByte(addr + 20, d.rotationAxisZ);
MemoryUtil.memPutFloat(addr + 21, d.qX);
MemoryUtil.memPutFloat(addr + 25, d.qY);
MemoryUtil.memPutFloat(addr + 29, d.qZ);
MemoryUtil.memPutFloat(addr + 33, d.qW);
MemoryUtil.memPutByte(addr + 37, d.rotationCenterX);
MemoryUtil.memPutByte(addr + 38, d.rotationCenterY);
MemoryUtil.memPutByte(addr + 39, d.rotationCenterZ);
MemoryUtil.memPutFloat(addr + 40, d.speed);
advance();
}
}

View file

@ -8,7 +8,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;

View file

@ -12,7 +12,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.foundation.render.AllMaterialSpecs;

View file

@ -5,7 +5,7 @@ import static net.minecraft.world.level.block.state.properties.BlockStatePropert
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import net.minecraft.core.BlockPos;

View file

@ -16,7 +16,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
public class MillStoneCogInstance extends SingleRotatingInstance {

View file

@ -5,7 +5,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -37,7 +37,7 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
transformPole(renderedHeadOffset);
transformHead(renderedHeadOffset);
}
@Override
protected Instancer<RotatingData> getModel() {
return materialManager.defaultSolid()

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;

View file

@ -1,11 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import java.util.List;
import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
import com.mojang.math.Matrix4f;
import net.minecraft.resources.ResourceLocation;
@ -18,8 +15,8 @@ public class ContraptionProgram extends WorldProgram {
protected int uLightVolume;
public ContraptionProgram(ResourceLocation name, int handle, List<IProgramExtension> extensions) {
super(name, handle, extensions);
public ContraptionProgram(ResourceLocation name, int handle) {
super(name, handle);
uLightBoxSize = getUniformLocation("uLightBoxSize");
uLightBoxMin = getUniformLocation("uLightBoxMin");
uModel = getUniformLocation("uModel");

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;

View file

@ -13,7 +13,8 @@ import com.mojang.math.Quaternion;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.BeltData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.Iterate;

View file

@ -8,7 +8,7 @@ import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.BlockPos;

View file

@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.Direction;

View file

@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.BlockPos;

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
public class CopperBacktankInstance extends SingleRotatingInstance {

View file

@ -11,7 +11,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.FlapData;
import com.simibubi.create.content.logistics.block.flap.FlapData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.animation.InterpolatedValue;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.logistics.block;
package com.simibubi.create.content.logistics.block.flap;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.instancing.InstanceData;
@ -9,25 +9,21 @@ import net.minecraft.core.BlockPos;
public class FlapData extends InstanceData implements IFlatLight<FlapData> {
private float x;
private float y;
private float z;
private byte blockLight;
private byte skyLight;
private float segmentOffsetX;
private float segmentOffsetY;
private float segmentOffsetZ;
private float pivotX;
private float pivotY;
private float pivotZ;
private float horizontalAngle;
private float intensity;
private float flapScale;
private float flapness;
float x;
float y;
float z;
byte blockLight;
byte skyLight;
float segmentOffsetX;
float segmentOffsetY;
float segmentOffsetZ;
float pivotX;
float pivotY;
float pivotZ;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
public FlapData setPosition(BlockPos pos) {
return setPosition(pos.getX(), pos.getY(), pos.getZ());

View file

@ -0,0 +1,24 @@
package com.simibubi.create.content.logistics.block.flap;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.StructWriter;
import com.simibubi.create.foundation.render.AllInstanceFormats;
public class FlapType implements StructType<FlapData> {
@Override
public FlapData create() {
return new FlapData();
}
@Override
public VertexFormat format() {
return AllInstanceFormats.FLAP;
}
@Override
public StructWriter<FlapData> getWriter(VecBuffer backing) {
return new UnsafeFlapWriter(backing, this);
}
}

View file

@ -0,0 +1,35 @@
package com.simibubi.create.content.logistics.block.flap;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeFlapWriter extends UnsafeBufferWriter<FlapData> {
public UnsafeFlapWriter(VecBuffer backingBuffer, StructType<FlapData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(FlapData d) {
long addr = writePointer;
MemoryUtil.memPutFloat(addr, d.x);
MemoryUtil.memPutFloat(addr + 4, d.y);
MemoryUtil.memPutFloat(addr + 8, d.z);
MemoryUtil.memPutByte(addr + 12, d.blockLight);
MemoryUtil.memPutByte(addr + 13, d.skyLight);
MemoryUtil.memPutFloat(addr + 14, d.segmentOffsetX);
MemoryUtil.memPutFloat(addr + 18, d.segmentOffsetY);
MemoryUtil.memPutFloat(addr + 22, d.segmentOffsetZ);
MemoryUtil.memPutFloat(addr + 26, d.pivotX);
MemoryUtil.memPutFloat(addr + 30, d.pivotY);
MemoryUtil.memPutFloat(addr + 34, d.pivotZ);
MemoryUtil.memPutFloat(addr + 38, d.horizontalAngle);
MemoryUtil.memPutFloat(addr + 42, d.intensity);
MemoryUtil.memPutFloat(addr + 46, d.flapScale);
MemoryUtil.memPutFloat(addr + 50, d.flapness);
advance();
}
}

View file

@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.FlapData;
import com.simibubi.create.content.logistics.block.flap.FlapData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;

View file

@ -12,7 +12,7 @@ import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color;

View file

@ -1,15 +1,17 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.backend.material.MaterialSpec;
import com.jozufozu.flywheel.backend.struct.BasicStructType;
import com.jozufozu.flywheel.backend.struct.StructType;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.event.GatherContextEvent;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.components.actors.ActorData;
import com.simibubi.create.content.contraptions.relays.belt.BeltData;
import com.simibubi.create.content.logistics.block.FlapData;
import com.simibubi.create.content.contraptions.components.actors.flwdata.ActorType;
import com.simibubi.create.content.contraptions.base.flwdata.BeltType;
import com.simibubi.create.content.logistics.block.flap.FlapType;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingType;
import com.simibubi.create.content.contraptions.components.actors.flwdata.ActorData;
import com.simibubi.create.content.contraptions.base.flwdata.BeltData;
import com.simibubi.create.content.logistics.block.flap.FlapData;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
@ -21,15 +23,10 @@ public class AllMaterialSpecs {
// noop, make sure the static field are loaded.
}
public static final StructType<RotatingData> ROTATING_TYPE = new BasicStructType<>(RotatingData::new, AllInstanceFormats.ROTATING);
public static final StructType<BeltData> BELTS_TYPE = new BasicStructType<>(BeltData::new, AllInstanceFormats.BELT);
public static final StructType<ActorData> ACTORS_TYPE = new BasicStructType<>(ActorData::new, AllInstanceFormats.ACTOR);
public static final StructType<FlapData> FLAPS_TYPE = new BasicStructType<>(FlapData::new, AllInstanceFormats.FLAP);
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, ROTATING_TYPE);
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, BELTS_TYPE);
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, ACTORS_TYPE);
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, FLAPS_TYPE);
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, new RotatingType());
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, new BeltType());
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, new ActorType());
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, new FlapType());
public static void flwInit(GatherContextEvent event) {
event.getBackend().register(ROTATING);

View file

@ -3,7 +3,7 @@ package com.simibubi.create.foundation.render;
import java.util.stream.Stream;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
import com.jozufozu.flywheel.backend.GameStateRegistry;
import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline;
import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate;
import com.jozufozu.flywheel.backend.pipeline.OneShotTemplate;
@ -30,7 +30,7 @@ public class CreateContexts {
public static void flwInit(GatherContextEvent event) {
Backend backend = event.getBackend();
SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE);
GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE);
FileResolution header = Resolver.INSTANCE.findShader(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
IShaderPipeline<ContraptionProgram> instancing = new WorldShaderPipeline<>(ContraptionProgram::new, InstancingTemplate.INSTANCE, header);