Make the BatchingEngine not jittery

- Stop having threads compete for a single BufferBuilder
 - ...by skirting around minecraft's BufferSource
 - Begin work on making vertex writing sane
This commit is contained in:
Jozufozu 2021-12-21 22:47:30 -08:00
parent 5f46560fb2
commit aa96a28f0b
3 changed files with 7 additions and 15 deletions

View file

@ -4,9 +4,7 @@ import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialGroup;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
@ -103,7 +101,6 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
return "glue";
}
@Override
public void buffer(VertexConsumer buffer) {
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
Vec3 extension = diff.normalize()
@ -162,11 +159,6 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
return 8;
}
@Override
public VertexFormat format() {
return Formats.UNLIT_MODEL;
}
@Override
public ModelReader getReader() {
return this;

View file

@ -62,7 +62,7 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
RenderLayer renderLayer = event.getLayer();
if (renderLayer != null) {
for (RenderedContraption renderer : visible) {
renderer.engine.render(event, event.buffers.bufferSource());
renderer.engine.render(event);
}
}
}

View file

@ -1,8 +1,7 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.util.BufferBuilderReader;
import com.jozufozu.flywheel.util.BlockFormatReader;
import com.jozufozu.flywheel.util.ModelReader;
import com.jozufozu.flywheel.util.RenderMath;
import com.jozufozu.flywheel.util.transform.Rotate;
import com.jozufozu.flywheel.util.transform.Scale;
import com.jozufozu.flywheel.util.transform.TStack;
@ -63,12 +62,9 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
// Temporary
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
private final Vector4f pos = new Vector4f();
private final Vector3f normal = new Vector3f();
private final Vector4f lightPos = new Vector4f();
public SuperByteBuffer(BufferBuilder buf) {
template = new BufferBuilderReader(buf);
template = new BlockFormatReader(buf);
transforms = new PoseStack();
transforms.pushPose();
}
@ -107,6 +103,10 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
WORLD_LIGHT_CACHE.clear();
}
final Vector4f pos = new Vector4f();
final Vector3f normal = new Vector3f();
final Vector4f lightPos = new Vector4f();
float f = .5f;
int vertexCount = template.getVertexCount();
for (int i = 0; i < vertexCount; i++) {