mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
fix test building, properly fail render test if loading fails
This commit is contained in:
parent
bf08ac0f19
commit
1992228032
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering
|
package de.bixilon.minosoft.gui.rendering
|
||||||
|
|
||||||
import de.bixilon.kutil.latch.SimpleLatch
|
import de.bixilon.kutil.latch.SimpleLatch
|
||||||
|
import de.bixilon.kutil.observer.DataObserver
|
||||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.assets.AssetsLoader
|
import de.bixilon.minosoft.assets.AssetsLoader
|
||||||
import de.bixilon.minosoft.gui.rendering.system.dummy.DummyRenderSystem
|
import de.bixilon.minosoft.gui.rendering.system.dummy.DummyRenderSystem
|
||||||
@ -30,10 +31,14 @@ class RenderTestLoader {
|
|||||||
val latch = SimpleLatch(1)
|
val latch = SimpleLatch(1)
|
||||||
connection::assetsManager.forceSet(AssetsLoader.create(connection.profiles.resources, connection.version, latch))
|
connection::assetsManager.forceSet(AssetsLoader.create(connection.profiles.resources, connection.version, latch))
|
||||||
connection.assetsManager.load(latch)
|
connection.assetsManager.load(latch)
|
||||||
|
connection::error.forceSet(DataObserver(null))
|
||||||
RenderTestUtil.rendering = Rendering(connection)
|
RenderTestUtil.rendering = Rendering(connection)
|
||||||
RenderTestUtil.rendering.start(latch, audio = false)
|
RenderTestUtil.rendering.start(latch, audio = false)
|
||||||
latch.dec()
|
latch.dec()
|
||||||
latch.await()
|
while (latch.count > 0) {
|
||||||
|
Thread.sleep(10)
|
||||||
|
connection.error?.let { throw it }
|
||||||
|
}
|
||||||
val context = RenderTestUtil.rendering.context
|
val context = RenderTestUtil.rendering.context
|
||||||
assertTrue(context.window is DummyWindow)
|
assertTrue(context.window is DummyWindow)
|
||||||
assertTrue(context.system is DummyRenderSystem)
|
assertTrue(context.system is DummyRenderSystem)
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.gui.rendering.font.types.FontType
|
|||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
|
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
|
||||||
import org.testng.Assert.assertEquals
|
import org.testng.Assert.assertEquals
|
||||||
|
|
||||||
class DummyComponentConsumer : GUIVertexConsumer {
|
class DummyComponentConsumer : GUIVertexConsumer {
|
||||||
@ -30,11 +30,11 @@ class DummyComponentConsumer : GUIVertexConsumer {
|
|||||||
val quads: MutableList<RendererdQuad> = mutableListOf()
|
val quads: MutableList<RendererdQuad> = mutableListOf()
|
||||||
|
|
||||||
override val order: IntArray get() = IntArray(0)
|
override val order: IntArray get() = IntArray(0)
|
||||||
override fun addVertex(position: Vec2, texture: ShaderIdentifiable?, uv: Vec2, tint: RGBColor, options: GUIVertexOptions?) = Broken()
|
override fun addVertex(position: Vec2, texture: ShaderTexture?, uv: Vec2, tint: RGBColor, options: GUIVertexOptions?) = Broken()
|
||||||
override fun addCache(cache: GUIMeshCache) = Broken()
|
override fun addCache(cache: GUIMeshCache) = Broken()
|
||||||
override fun ensureSize(size: Int) = Unit
|
override fun ensureSize(size: Int) = Unit
|
||||||
|
|
||||||
override fun addQuad(start: Vec2, end: Vec2, texture: ShaderIdentifiable?, uvStart: Vec2, uvEnd: Vec2, tint: RGBColor, options: GUIVertexOptions?) {
|
override fun addQuad(start: Vec2, end: Vec2, texture: ShaderTexture?, uvStart: Vec2, uvEnd: Vec2, tint: RGBColor, options: GUIVertexOptions?) {
|
||||||
quads += RendererdQuad(Vec2(start), Vec2(end))
|
quads += RendererdQuad(Vec2(start), Vec2(end))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@ package de.bixilon.minosoft.gui.rendering.gui.mesh
|
|||||||
|
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2
|
import de.bixilon.kotlinglm.vec2.Vec2
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
|
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||||
import de.bixilon.minosoft.gui.rendering.system.opengl.OpenGLRenderSystem
|
import de.bixilon.minosoft.gui.rendering.system.opengl.OpenGLRenderSystem
|
||||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
|
||||||
|
|
||||||
open class DummyGUIVertexConsumer : GUIVertexConsumer {
|
open class DummyGUIVertexConsumer : GUIVertexConsumer {
|
||||||
override val order: IntArray get() = OpenGLRenderSystem.QUAD_ORDER
|
override val order: IntArray get() = OpenGLRenderSystem.QUAD_ORDER
|
||||||
@ -32,7 +31,7 @@ open class DummyGUIVertexConsumer : GUIVertexConsumer {
|
|||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addVertex(position: Vec2, texture: ShaderIdentifiable?, uv: Vec2, tint: RGBColor, options: GUIVertexOptions?) {
|
override fun addVertex(position: Vec2, texture: ShaderTexture?, uv: Vec2, tint: RGBColor, options: GUIVertexOptions?) {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import de.bixilon.kutil.cast.CastUtil.nullCast
|
|||||||
import de.bixilon.kutil.collections.iterator.async.AsyncIterator.Companion.async
|
import de.bixilon.kutil.collections.iterator.async.AsyncIterator.Companion.async
|
||||||
import de.bixilon.kutil.collections.map.LockMap
|
import de.bixilon.kutil.collections.map.LockMap
|
||||||
import de.bixilon.kutil.latch.AbstractLatch
|
import de.bixilon.kutil.latch.AbstractLatch
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.assets.minecraft.MinecraftAssetsVersion
|
import de.bixilon.minosoft.assets.minecraft.MinecraftAssetsVersion
|
||||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||||
@ -88,7 +89,7 @@ class BlockLoader(private val loader: ModelLoader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun cleanup() {
|
fun cleanup() {
|
||||||
this.cache.clear()
|
this::cache.forceSet(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fixTexturePath(name: ResourceLocation): ResourceLocation {
|
fun fixTexturePath(name: ResourceLocation): ResourceLocation {
|
||||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.models.loader
|
|||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
import de.bixilon.kutil.latch.AbstractLatch
|
import de.bixilon.kutil.latch.AbstractLatch
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.assets.minecraft.MinecraftAssetsVersion
|
import de.bixilon.minosoft.assets.minecraft.MinecraftAssetsVersion
|
||||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
@ -78,7 +79,7 @@ class ItemLoader(private val loader: ModelLoader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun cleanup() {
|
fun cleanup() {
|
||||||
this.cache.clear()
|
this::cache.forceSet(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fixTexturePath(name: ResourceLocation): ResourceLocation {
|
fun fixTexturePath(name: ResourceLocation): ResourceLocation {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.models.loader
|
package de.bixilon.minosoft.gui.rendering.models.loader
|
||||||
|
|
||||||
import de.bixilon.kutil.latch.AbstractLatch
|
import de.bixilon.kutil.latch.AbstractLatch
|
||||||
|
import de.bixilon.kutil.time.TimeUtil.nanos
|
||||||
|
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocationUtil.extend
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocationUtil.extend
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||||
@ -33,21 +35,29 @@ class ModelLoader(
|
|||||||
|
|
||||||
|
|
||||||
fun load(latch: AbstractLatch) {
|
fun load(latch: AbstractLatch) {
|
||||||
|
val start = nanos()
|
||||||
|
|
||||||
DefaultEntityModels.load(this, latch)
|
DefaultEntityModels.load(this, latch)
|
||||||
fluids.load(latch)
|
fluids.load(latch)
|
||||||
block.load(latch)
|
block.load(latch)
|
||||||
item.load(latch)
|
item.load(latch)
|
||||||
skeletal.load(latch)
|
skeletal.load(latch)
|
||||||
|
|
||||||
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Loaded all models!" }
|
val time = nanos() - start
|
||||||
|
|
||||||
|
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Loaded all models in ${time.formatNanos()}!" }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bake(latch: AbstractLatch) {
|
fun bake(latch: AbstractLatch) {
|
||||||
|
val start = nanos()
|
||||||
|
|
||||||
block.bake(latch)
|
block.bake(latch)
|
||||||
item.bake(latch)
|
item.bake(latch)
|
||||||
skeletal.bake(latch)
|
skeletal.bake(latch)
|
||||||
|
|
||||||
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Baked models!" }
|
val time = nanos() - start
|
||||||
|
|
||||||
|
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Baked models in ${time.formatNanos()}!" }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cleanup() {
|
fun cleanup() {
|
||||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.models.loader
|
|||||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||||
import de.bixilon.kutil.collections.map.SynchronizedMap
|
import de.bixilon.kutil.collections.map.SynchronizedMap
|
||||||
import de.bixilon.kutil.latch.AbstractLatch
|
import de.bixilon.kutil.latch.AbstractLatch
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
|
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
|
||||||
@ -45,7 +46,7 @@ class SkeletalLoader(private val loader: ModelLoader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun cleanup() {
|
fun cleanup() {
|
||||||
this.registered.clear()
|
this::registered.forceSet(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(name: ResourceLocation): BakedSkeletalModel? {
|
operator fun get(name: ResourceLocation): BakedSkeletalModel? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user