mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
abstract block vertex consumer
This commit is contained in:
parent
7ced54d5dd
commit
2b6e702c7c
@ -31,6 +31,7 @@ import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.camera.Camera
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.entities.BlockEntityRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.entities.renderer.RenderedBlockEntity
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
@ -377,7 +378,7 @@ class SolidSectionMesherTest {
|
||||
}
|
||||
val state = BlockState(block, 0)
|
||||
state.model = object : TestModel(this, null) {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
assertEquals(light.size, 7)
|
||||
for ((index, entry) in light.withIndex()) {
|
||||
assertEquals(required[index], entry.toInt() and 0xFF)
|
||||
@ -395,7 +396,7 @@ class SolidSectionMesherTest {
|
||||
}
|
||||
val state = BlockState(block, 0)
|
||||
state.model = object : TestModel(this, null) {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
assertEquals(neighbours.size, 6)
|
||||
for ((index, entry) in neighbours.withIndex()) {
|
||||
assertEquals(required[index], entry)
|
||||
@ -437,7 +438,7 @@ class SolidSectionMesherTest {
|
||||
init {
|
||||
this.model = object : BlockRender {
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
entities.add(TestQueue.RenderedEntity(Vec3i(position), state, true)).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
|
||||
return true
|
||||
@ -460,7 +461,7 @@ class SolidSectionMesherTest {
|
||||
return this.properties
|
||||
}
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
queue.blocks.add(TestQueue.RenderedBlock(Vec3i(position), state, tints?.getOrNull(0))).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
return true
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.entity.sign.Wal
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesher.SolidSectionMesher.Companion.SELF_LIGHT_INDEX
|
||||
@ -56,10 +57,12 @@ class SignBlockEntityRenderer(
|
||||
return STANDING_ROTATIONS[rotation]
|
||||
}
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
state.model?.render(position, offset, mesh, random, state, neighbours, light, tints, entity) // render wood part
|
||||
if (entity !is SignBlockEntity) return true
|
||||
|
||||
if (mesh !is ChunkMeshes) return true // TODO
|
||||
|
||||
renderText(state, entity, offset, mesh.textMesh!!, light[SELF_LIGHT_INDEX].toInt())
|
||||
|
||||
return true
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.chunk.mesh
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.element.FaceVertexData
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.AbstractVertexConsumer
|
||||
|
||||
interface BlockVertexConsumer : AbstractVertexConsumer {
|
||||
|
||||
fun addVertex(position: FloatArray, uv: Vec2, texture: ShaderTexture, tintColor: Int, light: Int)
|
||||
fun addVertex(x: Float, y: Float, z: Float, u: Float, v: Float, textureId: Float, lightTint: Float)
|
||||
|
||||
|
||||
fun addQuad(offset: FloatArray, positions: FaceVertexData, uvData: FaceVertexData, textureId: Float, lightTint: Float) {
|
||||
ensureSize(ChunkMesh.ChunkMeshStruct.FLOATS_PER_VERTEX * order.size)
|
||||
|
||||
order.iterate { position, uv ->
|
||||
val vertexOffset = position * Vec3.length
|
||||
val uvOffset = uv * Vec2.length
|
||||
addVertex(
|
||||
x = offset[0] + positions[vertexOffset], y = offset[1] + positions[vertexOffset + 1], z = offset[2] + positions[vertexOffset + 2],
|
||||
u = uvData[uvOffset],
|
||||
v = uvData[uvOffset + 1],
|
||||
textureId = textureId,
|
||||
lightTint = lightTint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(transparency: TextureTransparencies): BlockVertexConsumer = this
|
||||
}
|
@ -16,18 +16,17 @@ package de.bixilon.minosoft.gui.rendering.chunk.mesh
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.element.FaceVertexData
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
|
||||
class ChunkMesh(context: RenderContext, initialCacheSize: Int, onDemand: Boolean = false) : Mesh(context, ChunkMeshStruct, initialCacheSize = initialCacheSize, onDemand = onDemand), Comparable<ChunkMesh> {
|
||||
class ChunkMesh(context: RenderContext, initialCacheSize: Int, onDemand: Boolean = false) : Mesh(context, ChunkMeshStruct, initialCacheSize = initialCacheSize, onDemand = onDemand), BlockVertexConsumer, Comparable<ChunkMesh> {
|
||||
var distance: Float = 0.0f // Used for sorting
|
||||
|
||||
override val order = context.system.quadOrder
|
||||
|
||||
fun addVertex(position: FloatArray, uv: Vec2, texture: ShaderTexture, tintColor: Int, light: Int) {
|
||||
override fun addVertex(position: FloatArray, uv: Vec2, texture: ShaderTexture, tintColor: Int, light: Int) {
|
||||
data.ensureSize(ChunkMeshStruct.FLOATS_PER_VERTEX)
|
||||
val transformedUV = texture.transformUV(uv).array
|
||||
data.add(position)
|
||||
@ -38,7 +37,7 @@ class ChunkMesh(context: RenderContext, initialCacheSize: Int, onDemand: Boolean
|
||||
)
|
||||
}
|
||||
|
||||
inline fun addVertex(x: Float, y: Float, z: Float, u: Float, v: Float, textureId: Float, lightTint: Float) {
|
||||
override inline fun addVertex(x: Float, y: Float, z: Float, u: Float, v: Float, textureId: Float, lightTint: Float) {
|
||||
data.add(
|
||||
x, y, z,
|
||||
u, v,
|
||||
@ -52,22 +51,6 @@ class ChunkMesh(context: RenderContext, initialCacheSize: Int, onDemand: Boolean
|
||||
return 0
|
||||
}
|
||||
|
||||
fun addQuad(offset: FloatArray, positions: FaceVertexData, uvData: FaceVertexData, textureId: Float, lightTint: Float) {
|
||||
data.ensureSize(ChunkMeshStruct.FLOATS_PER_VERTEX * order.size)
|
||||
|
||||
order.iterate { position, uv ->
|
||||
val vertexOffset = position * Vec3.length
|
||||
val uvOffset = uv * Vec2.length
|
||||
addVertex(
|
||||
x = offset[0] + positions[vertexOffset], y = offset[1] + positions[vertexOffset + 1], z = offset[2] + positions[vertexOffset + 2],
|
||||
u = uvData[uvOffset],
|
||||
v = uvData[uvOffset + 1],
|
||||
textureId = textureId,
|
||||
lightTint = lightTint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class ChunkMeshStruct(
|
||||
val position: Vec3,
|
||||
val uv: Vec2,
|
||||
|
@ -13,11 +13,15 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.chunk.mesh
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.entities.BlockEntityRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.of
|
||||
import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
|
||||
@ -26,7 +30,7 @@ class ChunkMeshes(
|
||||
val chunkPosition: Vec2i,
|
||||
val sectionHeight: Int,
|
||||
smallMesh: Boolean = false,
|
||||
) {
|
||||
) : BlockVertexConsumer {
|
||||
val center: Vec3 = Vec3(Vec3i.of(chunkPosition, sectionHeight, Vec3i(8, 8, 8)))
|
||||
var opaqueMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 3000 else 100000)
|
||||
var translucentMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 3000 else 10000, onDemand = true)
|
||||
@ -130,4 +134,15 @@ class ChunkMeshes(
|
||||
maxPosition.z = z
|
||||
}
|
||||
}
|
||||
|
||||
override val order get() = Broken()
|
||||
override fun ensureSize(floats: Int) = Unit
|
||||
override fun addVertex(position: FloatArray, uv: Vec2, texture: ShaderTexture, tintColor: Int, light: Int) = Broken()
|
||||
override fun addVertex(x: Float, y: Float, z: Float, u: Float, v: Float, textureId: Float, lightTint: Float) = Broken()
|
||||
|
||||
override fun get(transparency: TextureTransparencies) = when (transparency) {
|
||||
TextureTransparencies.OPAQUE -> opaqueMesh
|
||||
TextureTransparencies.TRANSPARENT -> transparentMesh
|
||||
TextureTransparencies.TRANSLUCENT -> translucentMesh
|
||||
}!!
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ interface ChatComponentRenderer<T : ChatComponent> {
|
||||
.translateAssign(Vec3(0, 0, -1))
|
||||
|
||||
val primitives = calculatePrimitiveCount(text)
|
||||
mesh.data.ensureSize(primitives * mesh.order.size * ChunkMesh.ChunkMeshStruct.FLOATS_PER_VERTEX)
|
||||
mesh.ensureSize(primitives * mesh.order.size * ChunkMesh.ChunkMeshStruct.FLOATS_PER_VERTEX)
|
||||
|
||||
val consumer = WorldGUIConsumer(mesh, matrix, light)
|
||||
return render3d(context, properties, maxSize, consumer, text, null)
|
||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
@ -32,7 +32,7 @@ import de.bixilon.minosoft.gui.rendering.models.loader.legacy.ModelChooser
|
||||
import java.util.*
|
||||
|
||||
class BlockModelPrototype(val model: DirectBlockModel) : BlockRender {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = prototype()
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = prototype()
|
||||
override fun getParticleTexture(random: Random?, position: Vec3i) = prototype()
|
||||
override fun getProperties(direction: Directions) = prototype()
|
||||
override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = prototype()
|
||||
|
@ -14,14 +14,12 @@
|
||||
package de.bixilon.minosoft.gui.rendering.models.block.state.baked
|
||||
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesher.SolidSectionMesher.Companion.SELF_LIGHT_INDEX
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.element.FaceVertexData
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.Shades.Companion.shade
|
||||
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.tint.TintUtil
|
||||
|
||||
@ -44,23 +42,16 @@ class BakedFace(
|
||||
return TintUtil.calculateTint(tint, shade)
|
||||
}
|
||||
|
||||
fun render(offset: FloatArray, mesh: ChunkMeshes, light: ByteArray, tints: IntArray?) {
|
||||
fun render(offset: FloatArray, mesh: BlockVertexConsumer, light: ByteArray, tints: IntArray?) {
|
||||
val tint = color(tints?.getOrNull(tintIndex) ?: 0)
|
||||
val lightTint = ((light[lightIndex].toInt() shl 24) or tint).buffer()
|
||||
val textureId = this.texture.shaderId.buffer()
|
||||
|
||||
|
||||
val mesh = mesh.mesh(texture)
|
||||
val mesh = mesh[texture.transparency]
|
||||
mesh.addQuad(offset, this.positions, this.uv, textureId, lightTint)
|
||||
}
|
||||
|
||||
private fun ChunkMeshes.mesh(texture: Texture): ChunkMesh {
|
||||
return when (texture.transparency) {
|
||||
TextureTransparencies.OPAQUE -> opaqueMesh
|
||||
TextureTransparencies.TRANSPARENT -> transparentMesh
|
||||
TextureTransparencies.TRANSLUCENT -> translucentMesh
|
||||
}!!
|
||||
}
|
||||
|
||||
fun IntArray.getOrNull(index: Int): Int? {
|
||||
return if (index >= 0 && index < size) get(index) else null
|
||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
@ -46,7 +46,7 @@ class BakedModel(
|
||||
|
||||
override fun getParticleTexture(random: Random?, position: Vec3i) = particle
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
var rendered = false
|
||||
|
||||
for ((directionIndex, faces) in faces.withIndex()) {
|
||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
@ -36,7 +36,7 @@ class BuiltModel(
|
||||
val dynamic: Array<BlockRender>,
|
||||
) : BlockRender {
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
var rendered = model.render(position, offset, mesh, random, state, neighbours, light, tints, entity)
|
||||
|
||||
for (dynamic in this.dynamic) {
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.SideProperties
|
||||
import de.bixilon.minosoft.gui.rendering.models.item.ItemRender
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
@ -27,7 +27,7 @@ import java.util.*
|
||||
interface BlockRender : ItemRender {
|
||||
fun getParticleTexture(random: Random?, position: Vec3i): Texture? = null
|
||||
|
||||
fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean
|
||||
fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean
|
||||
|
||||
fun getProperties(direction: Directions): SideProperties? = null
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
@ -38,7 +38,7 @@ interface PickedBlockRender : BlockRender {
|
||||
default?.render(gui, offset, consumer, options, size, stack)
|
||||
}
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
return pick(state, neighbours)?.render(position, offset, mesh, random, state, neighbours, light, tints, entity) ?: false
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPositionUtil.positionHash
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
@ -62,7 +62,7 @@ class WeightedBlockRender(
|
||||
return getModel(random, position).getParticleTexture(random, position)
|
||||
}
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
return getModel(random, position).render(position, offset, mesh, random, state, neighbours, light, tints, entity)
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.BlockVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
@ -26,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
||||
import java.util.*
|
||||
|
||||
interface PropertyOnlyBlockRender : BlockRender {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = false
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: BlockVertexConsumer, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = false
|
||||
|
||||
override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = Unit
|
||||
}
|
||||
|
@ -17,4 +17,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.RenderOrder
|
||||
|
||||
interface AbstractVertexConsumer {
|
||||
val order: RenderOrder
|
||||
|
||||
fun ensureSize(floats: Int) = Unit
|
||||
}
|
||||
|
@ -135,6 +135,10 @@ abstract class Mesh(
|
||||
order.iterate { position, uv -> vertexConsumer.invoke(positions[position], texturePositions[uv]) }
|
||||
}
|
||||
|
||||
override fun ensureSize(floats: Int) {
|
||||
data.ensureSize(floats)
|
||||
}
|
||||
|
||||
enum class MeshStates {
|
||||
PREPARING,
|
||||
FINISHED,
|
||||
|
Loading…
x
Reference in New Issue
Block a user