improve entity sorting

This commit is contained in:
Moritz Zwerger 2023-11-06 13:50:07 +01:00
parent f105977d4b
commit e4c150f407
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 5 additions and 1 deletions

View File

@ -32,7 +32,7 @@ abstract class EntityRenderFeature(val renderer: EntityRenderer<*>) : Comparable
abstract fun draw() abstract fun draw()
open fun compareByDistance(other: EntityRenderFeature): Int { open fun compareByDistance(other: EntityRenderFeature): Int {
return other.renderer.distance.compareTo(renderer.distance) return renderer.distance.compareTo(other.renderer.distance)
} }
override fun compareTo(other: EntityRenderFeature): Int { override fun compareTo(other: EntityRenderFeature): Int {

View File

@ -108,6 +108,10 @@ open class BillboardTextFeature(
renderer.renderer.queue += { mesh.unload() } renderer.renderer.queue += { mesh.unload() }
} }
override fun compareByDistance(other: EntityRenderFeature): Int {
return -super.compareByDistance(other)
}
private companion object { private companion object {
val PROPERTIES = TextRenderProperties(allowNewLine = false) val PROPERTIES = TextRenderProperties(allowNewLine = false)
val MAX_SIZE = Vec2(150.0f, PROPERTIES.lineHeight) val MAX_SIZE = Vec2(150.0f, PROPERTIES.lineHeight)