From 6ef88c3bd8bc66e5ff7b3f0588deaf012a8a7db0 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 31 Mar 2021 16:25:59 -0700 Subject: [PATCH] Fix some issues with instance rate limiting --- .../render/backend/instancing/InstancedTileRenderer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java index bcc7f7866..5d126b2f7 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java @@ -30,6 +30,7 @@ public abstract class InstancedTileRenderer

{ protected Map, RenderMaterial> materials = new HashMap<>(); protected int frame; + protected int tick; protected InstancedTileRenderer() { registerMaterials(); @@ -40,6 +41,8 @@ public abstract class InstancedTileRenderer

{ public abstract void registerMaterials(); public void tick(double cameraX, double cameraY, double cameraZ) { + tick++; + // integer camera pos int cX = (int) cameraX; int cY = (int) cameraY; @@ -58,7 +61,7 @@ public abstract class InstancedTileRenderer

{ int dY = pos.getY() - cY; int dZ = pos.getZ() - cZ; - if ((frame % getUpdateDivisor(dX, dY, dZ)) == 0) + if ((tick % getUpdateDivisor(dX, dY, dZ)) == 0) instance.tick(); } } @@ -195,9 +198,9 @@ public abstract class InstancedTileRenderer

{ int dY = worldPos.getY() - cY; int dZ = worldPos.getZ() - cZ; - float dot = dX * lookX + dY * lookY + dZ * lookZ; + float dot = (dX + lookX * 2) * lookX + (dY + lookY * 2) * lookY + (dZ + lookZ * 2) * lookZ; - if (dot < 0) return false; // is it behind the camera? + if (dot < 0) return false; // is it more than 2 blocks behind the camera? return (frame % getUpdateDivisor(dX, dY, dZ)) == 0; }