mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
fix tests
This commit is contained in:
parent
d3dfcb2a92
commit
fce6bc27c9
@ -23,6 +23,7 @@ import de.bixilon.minosoft.data.registries.blocks.light.OpaqueProperty
|
||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.AdvancedBlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockStateFlags
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.manager.SimpleStateManager
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.TestBlock
|
||||
@ -110,7 +111,8 @@ object LightTestingUtil {
|
||||
|
||||
fun createBlock(name: String, luminance: Int, lightProperties: LightProperties): Block {
|
||||
val block = TestBlock(minosoft(name), BlockSettings(Versions.AUTOMATIC))
|
||||
val state = AdvancedBlockState(block, properties = emptyMap(), collisionShape = AbstractVoxelShape.EMPTY, outlineShape = AbstractVoxelShape.EMPTY, luminance = luminance, lightProperties = lightProperties, solidRenderer = true)
|
||||
val state = AdvancedBlockState(block, properties = emptyMap(), collisionShape = AbstractVoxelShape.EMPTY, outlineShape = AbstractVoxelShape.EMPTY, luminance = luminance, lightProperties = lightProperties)
|
||||
state.flags += BlockStateFlags.FULLY_OPAQUE
|
||||
block::states.forceSet(SimpleStateManager(state))
|
||||
|
||||
return block
|
||||
|
@ -50,7 +50,6 @@ import de.bixilon.minosoft.protocol.network.session.play.SessionTestUtil
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import org.testng.Assert.assertEquals
|
||||
import org.testng.annotations.Test
|
||||
import java.util.*
|
||||
|
||||
@Test(groups = ["mesher"], dependsOnGroups = ["rendering", "block"])
|
||||
class SolidSectionMesherTest {
|
||||
@ -414,11 +413,11 @@ class SolidSectionMesherTest {
|
||||
val state = BlockState(block, 0)
|
||||
state.model = object : TestModel(this, null) {
|
||||
override fun render(props: WorldRenderProps, state: BlockState, entity: BlockEntity?, tints: IntArray?): Boolean {
|
||||
assertEquals(light.size, 7)
|
||||
for ((index, entry) in light.withIndex()) {
|
||||
assertEquals(props.light.size, 7)
|
||||
for ((index, entry) in props.light.withIndex()) {
|
||||
assertEquals(required[index], entry.toInt() and 0xFF)
|
||||
}
|
||||
return super.render(position, offset, mesh, random, state, neighbours, light, tints, entity)
|
||||
return super.render(props, state, entity, tints)
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,11 +431,11 @@ class SolidSectionMesherTest {
|
||||
val state = BlockState(block, 0)
|
||||
state.model = object : TestModel(this, null) {
|
||||
override fun render(props: WorldRenderProps, state: BlockState, entity: BlockEntity?, tints: IntArray?): Boolean {
|
||||
assertEquals(neighbours.size, 6)
|
||||
for ((index, entry) in neighbours.withIndex()) {
|
||||
assertEquals(props.neighbours.size, 6)
|
||||
for ((index, entry) in props.neighbours.withIndex()) {
|
||||
assertEquals(required[index], entry)
|
||||
}
|
||||
return super.render(position, offset, mesh, random, state, neighbours, light, tints, entity)
|
||||
return super.render(props, state, entity, tints)
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,7 +473,7 @@ class SolidSectionMesherTest {
|
||||
this.model = object : BlockRender {
|
||||
|
||||
override fun render(props: WorldRenderProps, state: BlockState, entity: BlockEntity?, tints: IntArray?): Boolean {
|
||||
entities.add(TestQueue.RenderedEntity(Vec3i(position), state, true)).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
entities.add(TestQueue.RenderedEntity(Vec3i(props.position), state, true)).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
|
||||
return true
|
||||
}
|
||||
@ -501,7 +500,7 @@ class SolidSectionMesherTest {
|
||||
}
|
||||
|
||||
override fun render(props: WorldRenderProps, state: BlockState, entity: BlockEntity?, tints: IntArray?): Boolean {
|
||||
queue.blocks.add(TestQueue.RenderedBlock(Vec3i(position), state, tints?.getOrNull(0))).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
queue.blocks.add(TestQueue.RenderedBlock(Vec3i(props.position), state, tints?.getOrNull(0))).let { if (!it) throw IllegalArgumentException("Twice!!!") }
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,14 @@ import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.getFieldOrNull
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
import de.bixilon.minosoft.gui.rendering.light.ao.AmbientOcclusionUtil
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.BakedFace
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.Shades
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.PrimitiveTypes
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshOrder
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.uv.PackedUV
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.uv.UnpackedUV
|
||||
import de.bixilon.minosoft.test.IT.OBJENESIS
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -60,21 +62,22 @@ class BakedFaceTest {
|
||||
}
|
||||
|
||||
fun mixed() {
|
||||
// TODO: negative uv is not supported anymore
|
||||
val face = BakedFace(floatArrayOf(0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f), UnpackedUV(floatArrayOf(-1f, -2f, -3f, -4f, -5f, -6f, -7f, -8f)), Shades.UP, -1, null, texture())
|
||||
|
||||
val mesh = mesh()
|
||||
|
||||
face.render(floatArrayOf(0.0f, 0.0f, 0.0f), mesh, byteArrayOf(0, 0, 0, 0, 0, 0, 0), null)
|
||||
face.render(floatArrayOf(0.0f, 0.0f, 0.0f), mesh, byteArrayOf(0, 0, 0, 0, 0, 0, 0), null, AmbientOcclusionUtil.EMPTY)
|
||||
|
||||
val texture = 0.buffer()
|
||||
val lightTint = 0xFFFFFF.buffer()
|
||||
|
||||
val data = mesh.opaqueMesh!!.data.toArray()
|
||||
val expected = floatArrayOf(
|
||||
0f, 1f, 2f, -1f, -2f, texture, lightTint,
|
||||
9f, 10f, 11f, -7f, -8f, texture, lightTint,
|
||||
6f, 7f, 8f, -5f, -6f, texture, lightTint,
|
||||
3f, 4f, 5f, -3f, -4f, texture, lightTint,
|
||||
0f, 1f, 2f, PackedUV.pack(-1f, -2f), texture, lightTint,
|
||||
9f, 10f, 11f, PackedUV.pack(-7f, -8f), texture, lightTint,
|
||||
6f, 7f, 8f, PackedUV.pack(-5f, -6f), texture, lightTint,
|
||||
3f, 4f, 5f, PackedUV.pack(-3f, -4f), texture, lightTint,
|
||||
)
|
||||
|
||||
|
||||
@ -86,17 +89,17 @@ class BakedFaceTest {
|
||||
|
||||
val mesh = mesh()
|
||||
|
||||
face.render(floatArrayOf(0.0f, 0.0f, 0.0f), mesh, byteArrayOf(0, 0, 0, 0, 0, 0, 0), null)
|
||||
face.render(floatArrayOf(0.0f, 0.0f, 0.0f), mesh, byteArrayOf(0, 0, 0, 0, 0, 0, 0), null, AmbientOcclusionUtil.EMPTY)
|
||||
|
||||
val texture = 0.buffer()
|
||||
val lightTint = 0xFFFFFF.buffer()
|
||||
|
||||
val data = mesh.opaqueMesh!!.data.toArray()
|
||||
val expected = floatArrayOf(
|
||||
0f, 0f, 0f, 0f, 0f, texture, lightTint,
|
||||
0f, 0f, 1f, 1f, 0f, texture, lightTint,
|
||||
0f, 1f, 1f, 1f, 1f, texture, lightTint,
|
||||
0f, 1f, 0f, 0f, 1f, texture, lightTint,
|
||||
0f, 0f, 0f, PackedUV.pack(0f, 0f), texture, lightTint,
|
||||
0f, 0f, 1f, PackedUV.pack(1f, 0f), texture, lightTint,
|
||||
0f, 1f, 1f, PackedUV.pack(1f, 1f), texture, lightTint,
|
||||
0f, 1f, 0f, PackedUV.pack(0f, 1f), texture, lightTint,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user