mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-05 07:49:17 +07:00
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:
@ -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.
|
/** 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. */
|
* 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 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
|
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 unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
|
||||||
val unitImageLayerGroup = UnitImageLayerGroupClass().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 { isTransform = false; setSize(groupSize, groupSize);
|
||||||
val cityButtonLayerGroup = Group().apply { setSize(groupSize, groupSize);
|
|
||||||
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
|
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
|
||||||
|
|
||||||
val circleCrosshairFogLayerGroup = ActionlessGroup().apply { isTransform = false; setSize(groupSize, groupSize) }
|
val circleCrosshairFogLayerGroup = ActionlessGroup().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||||
|
@ -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
|
tileGroup.cityButtonLayerGroup.isTransform = false // to save on rendering time to improve framerate
|
||||||
if (scale < 1 && scale > 0.5f)
|
if (scale < 1 && scale > 0.5f)
|
||||||
for (tileGroup in tileGroups.values) {
|
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)
|
tileGroup.cityButtonLayerGroup.setScale(scale)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user