Improved animation performance
This commit is contained in:
36
client/player/performance/AnimationPerformance.gd
Normal file
36
client/player/performance/AnimationPerformance.gd
Normal file
@ -0,0 +1,36 @@
|
||||
class_name AnimationPerformance
|
||||
|
||||
const DELAY_INVISIBLE := 1.0
|
||||
const DELAY_VISIBLE := 0.5
|
||||
|
||||
static var quality_budget: Array[int] = [
|
||||
10, # Full animation quality
|
||||
5, # 2.5 ms delay
|
||||
5, # 5.0 ms delay
|
||||
5, # 7.5 ms delay
|
||||
5, # 10.0 ms delay
|
||||
5, # 12.5 ms delay
|
||||
5, # 15 ms delay
|
||||
5, # 17.5 ms delay
|
||||
5, # 20 ms delay
|
||||
]
|
||||
|
||||
static func update_animation_quality(visible_players: Array[Player]):
|
||||
var delay := 0.0
|
||||
var count := 0
|
||||
var index := 0
|
||||
|
||||
for player in visible_players:
|
||||
if index >= quality_budget.size():
|
||||
player.performance.delay_visible = DELAY_VISIBLE
|
||||
player.animation.delay = DELAY_VISIBLE
|
||||
continue
|
||||
|
||||
player.performance.delay_visible = delay
|
||||
player.animation.delay = delay
|
||||
count += 1
|
||||
|
||||
if count >= quality_budget[index]:
|
||||
index += 1
|
||||
delay += 0.025
|
||||
count = 0
|
Reference in New Issue
Block a user