From 4a469a9394940cd7fe62a7494d8137be364b95bb Mon Sep 17 00:00:00 2001 From: Bixilon Date: Thu, 30 Mar 2023 13:43:20 +0200 Subject: [PATCH] model rendering: make random seed on demand --- .../models/block/state/render/WeightedBlockRender.kt | 8 ++++---- .../world/preparer/cull/SolidCullSectionPreparer.kt | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt index e8b27ccc3..80939916d 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt @@ -30,8 +30,9 @@ class WeightedBlockRender( ) : BlockRender { - private fun getModel(random: Random?): BlockRender { + private fun getModel(random: Random?, position: BlockPosition): BlockRender { if (random == null) return models.first().model + random.setSeed(position.positionHash) var weightLeft = abs(random.nextLong() % totalWeight) @@ -46,12 +47,11 @@ class WeightedBlockRender( } override fun getParticleTexture(random: Random?, position: Vec3i): AbstractTexture? { - random?.setSeed(position.positionHash) - return getModel(random).getParticleTexture(random, position) + return getModel(random, position).getParticleTexture(random, position) } override fun render(position: BlockPosition, mesh: WorldMesh, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - return getModel(random).render(position, mesh, random, state, neighbours, light, tints) + return getModel(random, position).render(position, mesh, random, state, neighbours, light, tints) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt index ffd2e7547..922050a9a 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt @@ -32,7 +32,6 @@ import de.bixilon.minosoft.data.world.chunk.chunk.Chunk import de.bixilon.minosoft.data.world.chunk.light.SectionLight import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours import de.bixilon.minosoft.data.world.positions.BlockPosition -import de.bixilon.minosoft.data.world.positions.BlockPositionUtil.positionHash import de.bixilon.minosoft.gui.rendering.RenderContext import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender import de.bixilon.minosoft.gui.rendering.world.entities.BlockEntityRenderer @@ -131,8 +130,6 @@ class SolidCullSectionPreparer( light[O_UP] = (light[O_UP].toInt() or 0xF0).toByte() } - random?.setSeed(position.positionHash) - val tints = tintColorCalculator.getAverageBlockTint(chunk, neighbourChunks, state, x, y, z) var rendered = model.render(position, mesh, random, state, neighbourBlocks, light, tints)