mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
wip fluid culling
This commit is contained in:
parent
14b0d11943
commit
f5ae8978b9
@ -15,7 +15,6 @@ package de.bixilon.minosoft.data.registries.blocks.types.wood
|
||||
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.registries.blocks.light.CustomLightProperties
|
||||
import de.bixilon.minosoft.data.registries.blocks.light.LightProperties
|
||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.PropertyBlockState
|
||||
@ -26,16 +25,13 @@ import de.bixilon.minosoft.data.registries.blocks.types.fluid.water.Waterloggabl
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.properties.LightedBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.properties.item.BlockWithItem
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.special.FullBlock
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.properties.transparency.TransparentBlock
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.item.items.Item
|
||||
import de.bixilon.minosoft.data.registries.item.items.tool.properties.requirement.ToolRequirement
|
||||
import de.bixilon.minosoft.data.registries.item.items.tool.shears.ShearsItem
|
||||
import de.bixilon.minosoft.data.registries.item.items.tool.shears.ShearsRequirement
|
||||
import de.bixilon.minosoft.data.registries.item.items.tool.sword.SwordItem
|
||||
import de.bixilon.minosoft.data.registries.item.items.tool.sword.SwordRequirement
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.BakedFace
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.CustomBlockCulling
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||
|
||||
abstract class LeavesBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), CustomBlockCulling, FullBlock, BlockStateBuilder, ToolRequirement, WaterloggableBlock, BlockWithItem<Item>, LightedBlock {
|
||||
override val hardness get() = 0.2f
|
||||
@ -47,7 +43,7 @@ abstract class LeavesBlock(identifier: ResourceLocation, settings: BlockSettings
|
||||
|
||||
override fun getLightProperties(blockState: BlockState) = LIGHT_PROPERTIES
|
||||
|
||||
override fun shouldCull(state: BlockState, face: BakedFace, directions: Directions, neighbour: BlockState): Boolean {
|
||||
override fun shouldCull(state: BlockState, properties: FaceProperties, directions: Directions, neighbour: BlockState): Boolean {
|
||||
return neighbour.block != this
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@ import de.bixilon.minosoft.data.registries.shapes.voxel.AbstractVoxelShape
|
||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||
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.mesh.ChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.SingleChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.FaceCulling
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.getMesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||
@ -96,14 +96,8 @@ class FluidSectionMesher(
|
||||
if (fluid.matches(neighbour)) {
|
||||
return true
|
||||
}
|
||||
val model = neighbour.model ?: return false
|
||||
random.setSeed(neighbourPosition.positionHash)
|
||||
/*
|
||||
val size = model.getTouchingFaceProperties(random, direction.inverted)
|
||||
return size?.canCull(FLUID_FACE_PROPERTY, false) ?: false
|
||||
|
||||
*/
|
||||
return false
|
||||
return FaceCulling.canCull(blockState, model.properties, direction, neighbour)
|
||||
}
|
||||
|
||||
val topBlock = if (y == ProtocolDefinition.SECTION_MAX_Y) {
|
||||
|
@ -28,6 +28,10 @@ data class ElementRotation(
|
||||
val rescale: Boolean = false,
|
||||
) {
|
||||
|
||||
fun apply(positions: FloatArray) {
|
||||
// TODO("Can not rotate yet!")
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private val ORIGIN = Vec3(0.5f)
|
||||
|
@ -33,10 +33,9 @@ data class ModelElement(
|
||||
|
||||
fun positions(direction: Directions): FloatArray {
|
||||
val positions = BakingUtil.positions(direction, from, to)
|
||||
if (rotation == null) return positions
|
||||
rotation?.apply(positions)
|
||||
|
||||
|
||||
TODO("Can not rotate positions yet!")
|
||||
return positions
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -15,9 +15,9 @@ package de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull
|
||||
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.BakedFace
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||
|
||||
interface CustomBlockCulling {
|
||||
|
||||
fun shouldCull(state: BlockState, face: BakedFace, directions: Directions, neighbour: BlockState): Boolean
|
||||
fun shouldCull(state: BlockState, properties: FaceProperties, directions: Directions, neighbour: BlockState): Boolean
|
||||
}
|
||||
|
@ -22,14 +22,17 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparenci
|
||||
|
||||
object FaceCulling {
|
||||
|
||||
fun canCull(state: BlockState, face: BakedFace, direction: Directions, neighbour: BlockState?): Boolean {
|
||||
inline fun canCull(state: BlockState, face: BakedFace, direction: Directions, neighbour: BlockState?): Boolean {
|
||||
return canCull(state, face.properties, direction, neighbour)
|
||||
}
|
||||
|
||||
fun canCull(state: BlockState, properties: FaceProperties?, direction: Directions, neighbour: BlockState?): Boolean {
|
||||
if (neighbour == null) return false
|
||||
if (!face.touchingSide) return false
|
||||
if (properties == null) return false
|
||||
|
||||
val model = neighbour.model ?: return false
|
||||
val neighbourProperties = model.getProperties(direction) ?: return false // not touching side
|
||||
|
||||
val properties = face.properties ?: return false
|
||||
|
||||
if (!properties.isCoveredBy(neighbourProperties)) return false
|
||||
|
||||
@ -39,7 +42,7 @@ object FaceCulling {
|
||||
}
|
||||
|
||||
if (state.block is CustomBlockCulling) {
|
||||
return state.block.shouldCull(state, face, direction, neighbour)
|
||||
return state.block.shouldCull(state, properties, direction, neighbour)
|
||||
}
|
||||
|
||||
if (neighbourProperties.transparency == null) return false // can not determinate it
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.models.fluid
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||
|
||||
@ -21,6 +22,7 @@ interface FluidModel {
|
||||
val tint: TintProvider? get() = null
|
||||
val still: Texture?
|
||||
val flowing: Texture?
|
||||
val properties: FaceProperties
|
||||
|
||||
fun load(context: RenderContext)
|
||||
}
|
||||
|
@ -13,15 +13,20 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.models.fluid.fluids
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||
import de.bixilon.minosoft.gui.rendering.models.fluid.FluidModel
|
||||
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.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
|
||||
|
||||
class LavaFluidModel : FluidModel {
|
||||
override var still: Texture? = null
|
||||
override var flowing: Texture? = null
|
||||
override var properties = FaceProperties(Vec2.EMPTY, Vec2(1.0f), TextureTransparencies.OPAQUE) // TODO: determinate by texture
|
||||
|
||||
override fun load(context: RenderContext) {
|
||||
still = context.textures.staticTextures.createTexture(STILL)
|
||||
|
@ -13,19 +13,24 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.models.fluid.fluids
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||
import de.bixilon.minosoft.gui.rendering.models.fluid.FluidModel
|
||||
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.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||
import de.bixilon.minosoft.gui.rendering.tint.WaterTintProvider
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
|
||||
|
||||
class WaterFluidModel : FluidModel {
|
||||
override val tint: TintProvider = WaterTintProvider
|
||||
|
||||
override var still: Texture? = null
|
||||
override var flowing: Texture? = null
|
||||
override var properties = FaceProperties(Vec2.EMPTY, Vec2(1.0f), TextureTransparencies.TRANSLUCENT) // TODO: determinate by texture
|
||||
|
||||
override fun load(context: RenderContext) {
|
||||
still = context.textures.staticTextures.createTexture(STILL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user