diff --git a/doc/snippets/MagnumAnimation.cpp b/doc/snippets/MagnumAnimation.cpp index 54e2ac3ab..6f8c95e2b 100644 --- a/doc/snippets/MagnumAnimation.cpp +++ b/doc/snippets/MagnumAnimation.cpp @@ -37,9 +37,9 @@ using namespace Magnum::Math::Literals; int main() { { -Vector3 a, b; Float t{}; { +Vector3 a, b; /* [ease] */ auto lerpBounceIn = Animation::ease(); @@ -303,8 +303,11 @@ const Animation::Track jump{{ Vector2 position = jump.at(2.2f); // y = 0.775 /* [Track-usage] */ +static_cast(position); +} { +const Animation::Track jump; /* [Track-performance-hint] */ std::size_t hint = 0; Vector2 position = jump.at(2.2f, hint); // y = 0.775, hint = 2 @@ -313,6 +316,7 @@ static_cast(position); } { +const Animation::Track jump; /* [Track-performance-strict] */ std::size_t hint = 0; Vector2 position = jump.atStrict(2.2f, hint); // y = 0.775, hint = 2 @@ -320,9 +324,6 @@ Vector2 position = jump.atStrict(2.2f, hint); // y = 0.775, hint = 2 static_cast(position); } -static_cast(position); -} - { /* [Track-performance-cache] */ struct Keyframe { diff --git a/src/Magnum/Animation/Player.hpp b/src/Magnum/Animation/Player.hpp index 19af2387c..7321f1daa 100644 --- a/src/Magnum/Animation/Player.hpp +++ b/src/Magnum/Animation/Player.hpp @@ -255,14 +255,17 @@ template Containers::Optional> playe } template std::pair Player::elapsed(const T time) const { + const K duration = _duration.size(); + /* Get the elapsed time. This is an immutable query, so make copies of the (otherwise to be modified) internal state. */ - T startTime = _startTime; - T pauseTime = _stopPauseTime; - State state = _state; - const K duration = _duration.size(); - const Containers::Optional> elapsed = Implementation::playerElapsed(duration, _playCount, _scaler, time, startTime, pauseTime, state); - if(elapsed) return *elapsed; + { + T startTime = _startTime; + T pauseTime = _stopPauseTime; + State state = _state; + const Containers::Optional> elapsed = Implementation::playerElapsed(duration, _playCount, _scaler, time, startTime, pauseTime, state); + if(elapsed) return *elapsed; + } /* If not advancing, the animation can be paused -- calculate the iteration index and keyframe at which it was paused if the duration is nonzero. If diff --git a/src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp b/src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp index 51ae4cd06..28dde1fcb 100644 --- a/src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp +++ b/src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp @@ -118,17 +118,17 @@ void AbstractGlyphCacheTest::setImage() { GlyphCacheFeatures doFeatures() const override { return {}; } void doSetImage(const Vector2i& offset, const ImageView2D& image) override { - this->offset = offset; - this->size = image.size(); + imageOffset = offset; + imageSize = image.size(); } - Vector2i offset, size; + Vector2i imageOffset, imageSize; } cache{{100, 200}}; cache.setImage({80, 175}, ImageView2D{{}, {20, 25}, nullptr}); - CORRADE_COMPARE(cache.offset, (Vector2i{80, 175})); - CORRADE_COMPARE(cache.size, (Vector2i{20, 25})); + CORRADE_COMPARE(cache.imageOffset, (Vector2i{80, 175})); + CORRADE_COMPARE(cache.imageSize, (Vector2i{20, 25})); } void AbstractGlyphCacheTest::setImageOutOfBounds() {