Skip to content

Commit 619ac98

Browse files
committed
Correctly calculate buffer positions in vertex buffer writer
This should fix certain memory corruption-related crashes, e.g. with Mekanism pipes.
1 parent d0d3ade commit 619ac98

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/embeddedt/embeddium/impl/mixin/core/render/immediate/consumer/BufferBuilderMixin.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ public abstract class BufferBuilderMixin implements VertexBufferWriter {
2525

2626
@Shadow
2727
private int vertices;
28+
29+
@Shadow
30+
private int elementsToFill;
31+
2832
@Shadow
2933
@Final
3034
private int vertexSize;
3135

3236
@Shadow
3337
private long vertexPointer;
38+
3439
@Unique
3540
private VertexFormatDescription embeddiumFormat;
3641

@@ -61,8 +66,8 @@ public void push(MemoryStack stack, long src, int count, VertexFormatDescription
6166
}
6267

6368
this.vertices += count;
64-
// TODO - probably not needed?
65-
this.vertexPointer = dst;
69+
this.vertexPointer = dst + length - this.vertexSize;
70+
this.elementsToFill = 0;
6671
}
6772

6873
@Unique

0 commit comments

Comments
 (0)