mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
improve performance of solid block culling
This commit is contained in:
parent
f666df8d69
commit
cea55b610a
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger, Lukas Eisenhauer
|
||||
* Copyright (C) 2020-2022 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.
|
||||
*
|
||||
@ -42,6 +42,7 @@ data class BlockState(
|
||||
val fallSoundEvent: ResourceLocation?,
|
||||
val soundEventVolume: Float = 1.0f,
|
||||
val soundEventPitch: Float = 1.0f,
|
||||
val isSolid: Boolean,
|
||||
) {
|
||||
var blockModel: BakedBlockModel? = null
|
||||
|
||||
@ -146,6 +147,7 @@ data class BlockState(
|
||||
fallSoundEvent = data["fall_sound_type"]?.toInt()?.let { registries.soundEventRegistry[it] },
|
||||
soundEventVolume = data["sound_type_volume"]?.toFloat() ?: 1.0f,
|
||||
soundEventPitch = data["sound_type_pitch"]?.toFloat() ?: 1.0f,
|
||||
isSolid = data["solid_render"]?.toBoolean() ?: true, // ToDo: This should normally be false, but pixlyzers default value is true. Might break if the data is missing
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,9 @@ class BakedBlockStateModel(
|
||||
for ((index, faces) in faces.withIndex()) {
|
||||
val direction = Directions.VALUES[index]
|
||||
val neighbour = neighbours[index]
|
||||
if (blockState.isSolid && neighbour?.isSolid == true) {
|
||||
continue
|
||||
}
|
||||
val neighboursModel = neighbour?.blockModel
|
||||
var neighbourProperties: Array<AbstractFaceProperties>? = null
|
||||
if (neighboursModel != null) {
|
||||
@ -55,8 +58,13 @@ class BakedBlockStateModel(
|
||||
neighbourProperties = neighboursModel.getTouchingFaceProperties(random, direction.inverted)
|
||||
}
|
||||
for (face in faces) {
|
||||
if (face.touching && neighbourProperties != null && neighbourProperties.isNotEmpty() && neighbourProperties.canCull(face, neighbour != null && blockState.block.canCull(blockState, neighbour))) {
|
||||
continue
|
||||
if (face.touching) {
|
||||
if (neighbour?.isSolid == true) {
|
||||
continue
|
||||
}
|
||||
if (neighbourProperties != null && neighbourProperties.isNotEmpty() && neighbourProperties.canCull(face, neighbour != null && blockState.block.canCull(blockState, neighbour))) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
tint = tints?.getOrNull(face.tintIndex) ?: -1
|
||||
currentLight = (face.cullFace?.let { light[it.ordinal] } ?: light[SolidCullSectionPreparer.SELF_LIGHT_INDEX]).toInt()
|
||||
|
Loading…
x
Reference in New Issue
Block a user