fix some problematic code.

creating matrix stacks is expensive, apparently
This commit is contained in:
JozsefA 2021-02-17 13:58:24 -08:00
parent a5d6262424
commit 02db3f5a2c
2 changed files with 9 additions and 17 deletions

View File

@ -25,7 +25,7 @@ public class SuperByteBuffer extends TemplateBuffer {
}
// Vertex Position
private MatrixStack transforms;
private final MatrixStack transforms;
// Vertex Texture Coords
private SpriteShiftFunc spriteShiftFunc;
@ -152,7 +152,7 @@ public class SuperByteBuffer extends TemplateBuffer {
.endVertex();
}
transforms = new MatrixStack();
while (!transforms.isEmpty()) transforms.pop();
spriteShiftFunc = null;
shouldColor = false;
shouldLight = false;

View File

@ -45,7 +45,13 @@ public class FastRenderDispatcher {
CreateClient.kineticRenderer.tick();
runQueue(queuedUpdates.get(world), CreateClient.kineticRenderer::update);
ConcurrentHashMap.KeySetView<TileEntity, Boolean> map = queuedUpdates.get(world);
map
.forEach(te -> {
map.remove(te);
CreateClient.kineticRenderer.update(te);
});
}
public static boolean available() {
@ -64,20 +70,6 @@ public class FastRenderDispatcher {
RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers);
}
private static <T> void runQueue(@Nullable ConcurrentHashMap.KeySetView<T, Boolean> changed, Consumer<T> action) {
if (changed == null) return;
if (available()) {
// because of potential concurrency issues, we make a copy of what's in the set at the time we get here
ArrayList<T> tiles = new ArrayList<>(changed);
tiles.forEach(action);
changed.removeAll(tiles);
} else {
changed.clear();
}
}
public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
if (!Backend.canUseInstancing()) return;