mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-23 13:49:45 +00:00
Apply the baked transform to vertices written directly into BakedTransformCapture (#2164)
While a direct capture is active, Tessellator.instance is the capture itself, so RenderBlocks.renderBlockAsItem writes its vertices directly instead of going through interceptDraw. Its own rotate/translate was therefore never baked into the cached block mesh, which left held and dropped blocks off-center (e.g. the snow golem's pumpkin). Co-authored-by: Eclipse-Sol <[email protected]>
This commit is contained in:
1 parent
9081f4c3e8
commit
2f4ac2a9b7
1 file changed
+24
@@ -59,6 +59,30 @@ public final class BakedTransformCapture extends DirectTessellator {
|
||||
}
|
||||
}
|
||||
|
||||
// While capturing, Tessellator.instance is this tessellator, so vanilla code (e.g. RenderBlocks.renderBlockAsItem)
|
||||
// writes vertices directly instead of going through interceptDraw; bake the transform in here as well.
|
||||
@Override
|
||||
public void addVertex(double x, double y, double z) {
|
||||
final Matrix4fc direct = transform == null ? delta.deltaOrNull(deltaMatrix) : null;
|
||||
if (direct == null) {
|
||||
super.addVertex(x, y, z);
|
||||
return;
|
||||
}
|
||||
scratch.set((float) (x + xOffset), (float) (y + yOffset), (float) (z + zOffset)).mulPosition(direct);
|
||||
super.addVertex(scratch.x - xOffset, scratch.y - yOffset, scratch.z - zOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNormal(float nx, float ny, float nz) {
|
||||
final Matrix4fc direct = transform == null ? delta.deltaOrNull(deltaMatrix) : null;
|
||||
if (direct == null) {
|
||||
super.setNormal(nx, ny, nz);
|
||||
return;
|
||||
}
|
||||
scratch.set(nx, ny, nz).mulDirection(direct).normalize();
|
||||
super.setNormal(scratch.x, scratch.y, scratch.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long writeVertexData(VertexFormat format, int[] rawBuffer, int rawBufferIndex) {
|
||||
if (transform != null) {
|
||||
|
||||
Reference in new issue
Block a user