Fix camera position off-by-one with immersive portals

This commit is contained in:
James Seibel
2026-06-02 17:39:54 -05:00
parent 44aed79e78
commit c28cf643b3
3 changed files with 11 additions and 7 deletions
@@ -170,15 +170,13 @@ public class RenderBufferHandler implements AutoCloseable
int worldMinY = renderParams.clientLevelWrapper.getMinHeight(); int worldMinY = renderParams.clientLevelWrapper.getMinHeight();
int worldHeight = renderParams.clientLevelWrapper.getMaxHeight(); int worldHeight = renderParams.clientLevelWrapper.getMaxHeight();
DhVec3d cameraPos = MC_RENDER.getCameraExactPosition();
renderParams.mcModelViewMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY); renderParams.mcModelViewMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY);
WORLD_VIEW_JOML_MATRIX WORLD_VIEW_JOML_MATRIX
.setTransposed(JOML_TRANSPOSE_ARRAY) .setTransposed(JOML_TRANSPOSE_ARRAY)
.translate( .translate(
-(float) cameraPos.x, -(float) renderParams.exactCameraPosition.x,
-(float) cameraPos.y, -(float) renderParams.exactCameraPosition.y,
-(float) cameraPos.z); -(float) renderParams.exactCameraPosition.z);
renderParams.dhProjectionMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY); renderParams.dhProjectionMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY);
WORLD_VIEW_PROJ_JOML_MATRIX WORLD_VIEW_PROJ_JOML_MATRIX
@@ -48,8 +48,7 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
public void render(RenderParams renderParams) public void render(RenderParams renderParams)
{ {
this.dhMvmProjMatrixThisFrame = new DhMat4f(renderParams.dhMvmProjMatrix); this.dhMvmProjMatrixThisFrame = new DhMat4f(renderParams.dhMvmProjMatrix);
DhVec3d camPos = MC_RENDER.getCameraExactPosition(); this.camPosFloatThisFrame = new DhVec3f(renderParams.exactCameraPosition);
this.camPosFloatThisFrame = new DhVec3f((float) camPos.x, (float) camPos.y, (float) camPos.z);
this.rendererLists.render(this); this.rendererLists.render(this);
@@ -59,6 +59,13 @@ public interface IMinecraftRenderWrapper extends IBindable
*/ */
float getPartialTickTime(); float getPartialTickTime();
/**
* When other mods are present and
* this method is called outside the render thread
* this may return undesirable positions.
* (Normally this position is used to get
* the position the player's camera).
*/
DhVec3d getCameraExactPosition(); DhVec3d getCameraExactPosition();
Color getFogColor(float partialTicks); Color getFogColor(float partialTicks);