Skip to content

Commit

Permalink
Merge pull request CaffeineMC#1669 from PepperCode1/1.19.3/dev
Browse files Browse the repository at this point in the history
 Fix face culling precision errors
  • Loading branch information
IMS212 authored Apr 28, 2023
2 parents 14481aa + bd017ff commit d50082f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class ChunkCameraContext {
public final int blockX, blockY, blockZ;
public final float deltaX, deltaY, deltaZ;
public final float posX, posY, posZ;
public final double posX, posY, posZ;

public ChunkCameraContext(double x, double y, double z) {
this.blockX = (int) x;
Expand All @@ -15,9 +15,9 @@ public ChunkCameraContext(double x, double y, double z) {
this.deltaY = (float) Math.round((y - this.blockY) * 0x1p14f) * 0x1p-14f;
this.deltaZ = (float) Math.round((z - this.blockZ) * 0x1p14f) * 0x1p-14f;

this.posX = (float) x;
this.posY = (float) y;
this.posZ = (float) z;
this.posX = x;
this.posY = y;
this.posZ = z;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class ChunkRenderBounds {
public static final ChunkRenderBounds ALWAYS_FALSE = new ChunkRenderBounds(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY,
Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);

public final float minX, minY, minZ;
public final float maxX, maxY, maxZ;
public final double minX, minY, minZ;
public final double maxX, maxY, maxZ;

public ChunkRenderBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
public ChunkRenderBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
Expand Down Expand Up @@ -51,14 +51,14 @@ public void add(float x, float y, float z, ModelQuadFacing facing) {
}

public ChunkRenderBounds build(ChunkSectionPos origin) {
float minX = origin.getMinX() + this.minX;
float maxX = origin.getMinX() + this.maxX;
double minX = origin.getMinX() + (double) this.minX;
double maxX = origin.getMinX() + (double) this.maxX;

float minY = origin.getMinY() + this.minY;
float maxY = origin.getMinY() + this.maxY;
double minY = origin.getMinY() + (double) this.minY;
double maxY = origin.getMinY() + (double) this.maxY;

float minZ = origin.getMinZ() + this.minZ;
float maxZ = origin.getMinZ() + this.maxZ;
double minZ = origin.getMinZ() + (double) this.minZ;
double maxZ = origin.getMinZ() + (double) this.maxZ;

return new ChunkRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
Expand Down

0 comments on commit d50082f

Please sign in to comment.