From 52b769a98e8d865df658fd63556882ede4f2ab33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Wed, 12 Aug 2026 00:25:03 +0200 Subject: [PATCH] Defer animation start so arrows don't start halfway materialized Took 13 minutes --- cockatrice/src/game_graphics/board/arrow_item.cpp | 12 +++++++++++- cockatrice/src/game_graphics/board/arrow_item.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game_graphics/board/arrow_item.cpp b/cockatrice/src/game_graphics/board/arrow_item.cpp index ab6162217..7de4b632c 100644 --- a/cockatrice/src/game_graphics/board/arrow_item.cpp +++ b/cockatrice/src/game_graphics/board/arrow_item.cpp @@ -178,7 +178,12 @@ void ArrowItem::startDrawAnimation() strokeDurationMs = qBound(kMinStrokeDurationMs, centerLine.length() * kMsPerPixel, kMaxStrokeDurationMs); glowFadeDurationMs = kGlowFadeDurationMs; - animationClock.start(); + // The clock is started on the first animationEvent() tick so that t=0 + // corresponds to the first rendered frame. Starting it here would count + // the time spent before the item's first paint (event-loop delays, bursts + // of arrows created together), making the arrow appear already partway + // drawn when it first shows up. + animationStarted = false; drawProgress = 0.0; glowAlpha = 1.0; update(); @@ -189,6 +194,11 @@ void ArrowItem::startDrawAnimation() bool ArrowItem::animationEvent() { + if (!animationStarted) { + animationClock.start(); + animationStarted = true; + } + const qint64 elapsed = animationClock.elapsed(); if (elapsed >= strokeDurationMs + glowFadeDurationMs) { drawProgress = 1.0; diff --git a/cockatrice/src/game_graphics/board/arrow_item.h b/cockatrice/src/game_graphics/board/arrow_item.h index ea142d536..8ac1646d3 100644 --- a/cockatrice/src/game_graphics/board/arrow_item.h +++ b/cockatrice/src/game_graphics/board/arrow_item.h @@ -33,6 +33,7 @@ private: qreal glowFadeDurationMs = 0; qreal drawProgress = 1.0; qreal glowAlpha = 0.0; + bool animationStarted = false; static constexpr qreal glowExtent = 12.0;