Skip to content

Commit 855acdb

Browse files
committed
solid mesher: minor performance improvement
No clue, but somehow enum ordinals are not greatly optimized
1 parent 9b6080d commit 855acdb

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main/java/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesher.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,28 @@ class SolidSectionMesher(
9898
val min = blocks.minPosition
9999
val max = blocks.maxPosition
100100

101+
val entitiesDetail = ChunkMeshDetails.ENTITIES in details
102+
103+
val nonFullBlocks = ChunkMeshDetails.NON_FULL_BLOCKS in details
104+
val minorVisualImpact = ChunkMeshDetails.MINOR_VISUAL_IMPACT in details
105+
val cullFullOpaque = ChunkMeshDetails.CULL_FULL_OPAQUE in details
106+
107+
val down = ChunkMeshDetails.SIDE_DOWN in details
108+
val up = ChunkMeshDetails.SIDE_UP in details
109+
101110
for (y in min.y..max.y) {
102111
for (x in min.x..max.x) {
103112
for (z in min.z..max.z) {
104113
val inSection = InSectionPosition(x, y, z)
105114
val state = blocks[inSection] ?: continue
106115
if (state.block is FluidBlock) continue // fluids are rendered in a different renderer
107116

108-
if (ChunkMeshDetails.NON_FULL_BLOCKS !in details && BlockStateFlags.FULL_OUTLINE !in state.flags) continue
109-
if (ChunkMeshDetails.MINOR_VISUAL_IMPACT !in details && BlockStateFlags.MINOR_VISUAL_IMPACT in state.flags) continue
110-
if (ChunkMeshDetails.CULL_FULL_OPAQUE in details && areAllNeighboursFullOpaque(inSection, blocks, neighbours)) continue
117+
if (!nonFullBlocks && BlockStateFlags.FULL_OUTLINE !in state.flags) continue
118+
if (!minorVisualImpact && BlockStateFlags.MINOR_VISUAL_IMPACT in state.flags) continue
119+
if (!cullFullOpaque && areAllNeighboursFullOpaque(inSection, blocks, neighbours)) continue
111120

112121
val model = state.block.model ?: state.model
113-
val entity = if (ChunkMeshDetails.ENTITIES in details) section.entities[inSection] else null
122+
val entity = if (entitiesDetail) section.entities[inSection] else null
114123
val entityRenderer = entity?.let { cache.createEntity(inSection, entity) }
115124
if (model == null && entityRenderer == null) continue
116125

@@ -121,8 +130,8 @@ class SolidSectionMesher(
121130
floatOffset.z = (position.z - cameraOffset.z).toFloat()
122131

123132

124-
if (ChunkMeshDetails.SIDE_DOWN in details) setDown(inSection, isLowestSection, neighbourBlocks, neighbours, light, section, chunk)
125-
if (ChunkMeshDetails.SIDE_UP in details) setUp(isHighestSection, inSection, neighbourBlocks, neighbours, light, section, chunk)
133+
if (down) setDown(inSection, isLowestSection, neighbourBlocks, neighbours, light, section, chunk)
134+
if (up) setUp(isHighestSection, inSection, neighbourBlocks, neighbours, light, section, chunk)
126135

127136
// TODO: mesh details (sides)
128137
setZ(neighbourBlocks, inChunk, neighbours, light, neighbourChunks, section, chunk)

0 commit comments

Comments
 (0)