StructType doesn't need #asBatched and #asInstanced
- More organized this way - BatchingTransformer function moved into Batched
This commit is contained in:
parent
94a160699c
commit
5f46560fb2
5 changed files with 46 additions and 59 deletions
|
@ -1,11 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.base.flwdata;
|
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.BatchingTransformer;
|
|
||||||
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.backend.gl.attrib.VertexFormat;
|
||||||
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.util.RenderMath;
|
import com.jozufozu.flywheel.util.RenderMath;
|
||||||
import com.mojang.math.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||||
|
@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
|
public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
|
||||||
|
@ -38,29 +37,26 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchingTransformer<BeltData> getTransformer() {
|
public void transform(BeltData d, ModelTransformer.Params b) {
|
||||||
return (d, sbb) -> {
|
float spriteHeight = d.maxV - d.minV;
|
||||||
|
double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset;
|
||||||
|
scroll = scroll - Math.floor(scroll);
|
||||||
|
scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult);
|
||||||
|
|
||||||
float spriteHeight = d.maxV - d.minV;
|
float finalScroll = (float) scroll;
|
||||||
double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset;
|
b.shiftUV((builder, u, v) -> {
|
||||||
scroll = scroll - Math.floor(scroll);
|
float targetU = u - d.sourceU + d.minU;
|
||||||
scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult);
|
float targetV = v - d.sourceV + d.minV
|
||||||
|
+ finalScroll;
|
||||||
|
builder.uv(targetU, targetV);
|
||||||
|
});
|
||||||
|
|
||||||
float finalScroll = (float) scroll;
|
b.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
|
||||||
sbb.shiftUV((builder, u, v) -> {
|
.multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW))
|
||||||
float targetU = u - d.sourceU + d.minU;
|
.unCentre()
|
||||||
float targetV = v - d.sourceV + d.minV
|
.light(d.getPackedLight());
|
||||||
+ finalScroll;
|
if (KineticDebugger.isActive()) {
|
||||||
builder.uv(targetU, targetV);
|
b.color(d.r, d.g, d.b, d.a);
|
||||||
});
|
}
|
||||||
|
|
||||||
sbb.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
|
|
||||||
.multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW))
|
|
||||||
.unCentre()
|
|
||||||
.light(d.getPackedLight());
|
|
||||||
if (KineticDebugger.isActive()) {
|
|
||||||
sbb.color(d.r, d.g, d.b, d.a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.base.flwdata;
|
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.BatchingTransformer;
|
|
||||||
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.backend.gl.attrib.VertexFormat;
|
||||||
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.util.RenderMath;
|
import com.jozufozu.flywheel.util.RenderMath;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||||
|
@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class RotatingType implements Instanced<RotatingData>, Batched<RotatingData> {
|
public class RotatingType implements Instanced<RotatingData>, Batched<RotatingData> {
|
||||||
|
@ -38,19 +37,17 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchingTransformer<RotatingData> getTransformer() {
|
public void transform(RotatingData d, ModelTransformer.Params b) {
|
||||||
return (d, b) -> {
|
float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360);
|
||||||
float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360);
|
|
||||||
|
|
||||||
Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ));
|
Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ));
|
||||||
b.light(d.getPackedLight())
|
b.light(d.getPackedLight())
|
||||||
.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
|
.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
|
||||||
.multiply(axis.rotationDegrees(angle))
|
.multiply(axis.rotationDegrees(angle))
|
||||||
.unCentre();
|
.unCentre();
|
||||||
|
|
||||||
if (KineticDebugger.isActive()) {
|
if (KineticDebugger.isActive()) {
|
||||||
b.color(d.r, d.g, d.b, d.a);
|
b.color(d.r, d.g, d.b, d.a);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.components.actors.flwdata;
|
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.BatchingTransformer;
|
|
||||||
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.backend.gl.attrib.VertexFormat;
|
||||||
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.simibubi.create.foundation.render.AllInstanceFormats;
|
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
|
|
||||||
|
@ -33,9 +33,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchingTransformer<ActorData> getTransformer() {
|
public void transform(ActorData d, ModelTransformer.Params b) {
|
||||||
return (d, sbb) -> {
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package com.simibubi.create.content.logistics.block.flap;
|
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.BatchingTransformer;
|
|
||||||
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.backend.gl.attrib.VertexFormat;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
import com.simibubi.create.foundation.render.AllInstanceFormats;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
|
public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
|
||||||
|
@ -35,18 +33,16 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchingTransformer<FlapData> getTransformer() {
|
public void transform(FlapData d, ModelTransformer.Params b) {
|
||||||
return (d, sbb) -> {
|
b.translate(d.x, d.y, d.z)
|
||||||
sbb.translate(d.x, d.y, d.z)
|
.centre()
|
||||||
.centre()
|
.rotateY(-d.horizontalAngle)
|
||||||
.rotateY(-d.horizontalAngle)
|
.unCentre()
|
||||||
.unCentre()
|
.translate(d.pivotX, d.pivotY, d.pivotZ)
|
||||||
.translate(d.pivotX, d.pivotY, d.pivotZ)
|
.rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale))
|
||||||
.rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale))
|
.translateBack(d.pivotX, d.pivotY, d.pivotZ)
|
||||||
.translateBack(d.pivotX, d.pivotY, d.pivotZ)
|
.translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ)
|
||||||
.translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ)
|
.light(d.getPackedLight());
|
||||||
.light(d.getPackedLight());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getFlapAngle(float flapness, float intensity, float scale) {
|
private static float getFlapAngle(float flapness, float intensity, float scale) {
|
||||||
|
|
Loading…
Reference in a new issue