From 9068f249c6680ddaf195b9e08beb6c218faaa565 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Mon, 31 Jul 2023 23:07:56 +0200 Subject: [PATCH] rename section preparer to mesher --- .../minosoft/gui/rendering/chunk/ChunkMesher.kt | 12 ++++++------ .../renderer/sign/SignBlockEntityRenderer.kt | 2 +- ...FluidSectionPreparer.kt => FluidSectionMesher.kt} | 7 +++---- ...SolidSectionPreparer.kt => SolidSectionMesher.kt} | 6 +++--- .../rendering/models/block/state/baked/BakedFace.kt | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) rename src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/{FluidSectionPreparer.kt => FluidSectionMesher.kt} (97%) rename src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/{SolidSectionPreparer.kt => SolidSectionMesher.kt} (97%) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/ChunkMesher.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/ChunkMesher.kt index 92279eecb..53ad5b1f7 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/ChunkMesher.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/ChunkMesher.kt @@ -15,17 +15,17 @@ package de.bixilon.minosoft.gui.rendering.chunk import de.bixilon.kutil.concurrent.pool.runnable.InterruptableRunnable import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh +import de.bixilon.minosoft.gui.rendering.chunk.preparer.FluidSectionMesher +import de.bixilon.minosoft.gui.rendering.chunk.preparer.SolidSectionMesher import de.bixilon.minosoft.gui.rendering.chunk.queue.meshing.tasks.MeshPrepareTask import de.bixilon.minosoft.gui.rendering.chunk.util.ChunkRendererUtil.smallMesh -import de.bixilon.minosoft.gui.rendering.world.preparer.FluidSectionPreparer -import de.bixilon.minosoft.gui.rendering.world.preparer.SolidSectionPreparer import de.bixilon.minosoft.util.chunk.ChunkUtil class ChunkMesher( private val renderer: ChunkRenderer, ) { - private val solidSectionPreparer = SolidSectionPreparer(renderer.context) - private val fluidSectionPreparer = FluidSectionPreparer(renderer.context) + private val solid = SolidSectionMesher(renderer.context) + private val fluid = FluidSectionMesher(renderer.context) private fun mesh(item: WorldQueueItem): ChunkMesh? { if (item.section.blocks.isEmpty) { @@ -39,10 +39,10 @@ class ChunkMesher( } val sectionNeighbours = ChunkUtil.getDirectNeighbours(neighbours, item.chunk, item.section.sectionHeight) val mesh = ChunkMesh(renderer.context, item.chunkPosition, item.sectionHeight, item.section.smallMesh) - solidSectionPreparer.prepareSolid(item.chunkPosition, item.sectionHeight, item.chunk, item.section, neighbours, sectionNeighbours, mesh) + solid.mesh(item.chunkPosition, item.sectionHeight, item.chunk, item.section, neighbours, sectionNeighbours, mesh) if (item.section.blocks.fluidCount > 0) { - fluidSectionPreparer.prepareFluid(item.chunkPosition, item.sectionHeight, item.chunk, item.section, neighbours, sectionNeighbours, mesh) + fluid.mesh(item.chunkPosition, item.sectionHeight, item.chunk, item.section, neighbours, sectionNeighbours, mesh) } return mesh diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt index 354de47dd..3bf359c99 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt @@ -33,12 +33,12 @@ import de.bixilon.minosoft.gui.rendering.RenderContext import de.bixilon.minosoft.gui.rendering.chunk.entities.MeshedEntityRenderer import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh import de.bixilon.minosoft.gui.rendering.chunk.mesh.SingleChunkMesh +import de.bixilon.minosoft.gui.rendering.chunk.preparer.SolidSectionMesher.Companion.SELF_LIGHT_INDEX import de.bixilon.minosoft.gui.rendering.font.renderer.component.ChatComponentRenderer import de.bixilon.minosoft.gui.rendering.font.renderer.element.TextRenderProperties import de.bixilon.minosoft.gui.rendering.models.block.element.ModelElement.Companion.BLOCK_SIZE import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rotateAssign import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.toVec3 -import de.bixilon.minosoft.gui.rendering.world.preparer.SolidSectionPreparer.Companion.SELF_LIGHT_INDEX import java.util.* class SignBlockEntityRenderer( diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionPreparer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionMesher.kt similarity index 97% rename from src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionPreparer.kt rename to src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionMesher.kt index eec76ae6b..c8cbc260d 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionPreparer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/FluidSectionMesher.kt @@ -11,7 +11,7 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.gui.rendering.world.preparer +package de.bixilon.minosoft.gui.rendering.chunk.preparer import de.bixilon.kotlinglm.func.cos import de.bixilon.kotlinglm.func.sin @@ -33,7 +33,6 @@ import de.bixilon.minosoft.data.world.chunk.ChunkSection import de.bixilon.minosoft.data.world.chunk.chunk.Chunk import de.bixilon.minosoft.data.world.positions.BlockPositionUtil.positionHash import de.bixilon.minosoft.gui.rendering.RenderContext -import de.bixilon.minosoft.gui.rendering.chunk.ChunkMesher import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh import de.bixilon.minosoft.gui.rendering.chunk.mesh.SingleChunkMesh import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture @@ -48,7 +47,7 @@ import de.bixilon.minosoft.util.KUtil.isTrue import java.util.* import kotlin.math.atan2 -class FluidSectionPreparer( +class FluidSectionMesher( val context: RenderContext, ) { private val water = context.connection.registries.fluid[WaterFluid] @@ -56,7 +55,7 @@ class FluidSectionPreparer( // ToDo: Should this be combined with the solid renderer (but we'd need to render faces twice, because of cullface) - fun prepareFluid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbourChunks: Array, neighbours: Array, mesh: ChunkMesh) { + fun mesh(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbourChunks: Array, neighbours: Array, mesh: ChunkMesh) { val blocks = section.blocks val random = Random(0L) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionPreparer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionMesher.kt similarity index 97% rename from src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionPreparer.kt rename to src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionMesher.kt index ab20353af..aaa213a42 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionPreparer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/preparer/SolidSectionMesher.kt @@ -11,7 +11,7 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.gui.rendering.world.preparer +package de.bixilon.minosoft.gui.rendering.chunk.preparer import de.bixilon.kotlinglm.vec2.Vec2i import de.bixilon.kotlinglm.vec3.Vec3i @@ -39,7 +39,7 @@ import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition import java.util.* -class SolidSectionPreparer( +class SolidSectionMesher( val context: RenderContext, ) { private val profile = context.connection.profiles.block.rendering @@ -52,7 +52,7 @@ class SolidSectionPreparer( profile.performance::fastBedrock.observe(this, true) { this.fastBedrock = it } } - fun prepareSolid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbourChunks: Array, neighbours: Array, mesh: ChunkMesh) { + fun mesh(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbourChunks: Array, neighbours: Array, mesh: ChunkMesh) { val random = if (profile.antiMoirePattern) Random(0L) else null diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedFace.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedFace.kt index 4402130cd..b95cebddc 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedFace.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedFace.kt @@ -18,12 +18,12 @@ import de.bixilon.minosoft.data.direction.Directions import de.bixilon.minosoft.data.text.formatting.color.RGBColor import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh import de.bixilon.minosoft.gui.rendering.chunk.mesh.SingleChunkMesh +import de.bixilon.minosoft.gui.rendering.chunk.preparer.SolidSectionMesher.Companion.SELF_LIGHT_INDEX import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rgb -import de.bixilon.minosoft.gui.rendering.world.preparer.SolidSectionPreparer.Companion.SELF_LIGHT_INDEX class BakedFace( val positions: FloatArray,