More framerate savers! Now only cityButtonGroups that actually contain a cityButton will be rendered, giving us another massive performance boost!

We're up to 28-29 fps on Android while zoomed!
This commit is contained in:
Yair Morgenstern 2020-11-24 21:38:04 +02:00
parent 323c593d6e
commit f6f95a7c53
2 changed files with 12 additions and 5 deletions

View File

@ -22,11 +22,16 @@ import kotlin.random.Random
/** A lot of the render time was spent on snapshot arrays of the TileGroupMap's groups, in the act() function.
* This class is to avoid the overhead of useless act() calls. */
open class ActionlessGroup:Group(){
open class ActionlessGroup(val checkHit:Boolean=false):Group() {
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? {
if (checkHit)
return super.hit(x, y, touchable)
return null
}
}
open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : ActionlessGroup() {
open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : ActionlessGroup(true) {
val groupSize = 54f
/*
@ -88,8 +93,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
val unitImageLayerGroup = UnitImageLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
val cityButtonLayerGroup = Group().apply { setSize(groupSize, groupSize);
val cityButtonLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize);
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
val circleCrosshairFogLayerGroup = ActionlessGroup().apply { isTransform = false; setSize(groupSize, groupSize) }

View File

@ -468,7 +468,10 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
tileGroup.cityButtonLayerGroup.isTransform = false // to save on rendering time to improve framerate
if (scale < 1 && scale > 0.5f)
for (tileGroup in tileGroups.values) {
tileGroup.cityButtonLayerGroup.isTransform = true
// ONLY set those groups that have active citybuttons as transformable!
// This is massively framerate-improving!
if (tileGroup.cityButtonLayerGroup.hasChildren())
tileGroup.cityButtonLayerGroup.isTransform = true
tileGroup.cityButtonLayerGroup.setScale(scale)
}
}