From 9a31e8f3d9f1b5202aea9b8a485b1e2132c70ee7 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Sat, 31 Jan 2009 11:53:07 +0000 Subject: [PATCH] Backport: Allow snow flakes to completely exit the screen before removing them. Also create the flakes off-screen as well. CCBUG: 182561 svn path=/branches/KDE/4.2/kdebase/workspace/; revision=919042 --- effects/data/snow.vert | 2 +- effects/snow.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/effects/data/snow.vert b/effects/data/snow.vert index 48cb854335..06b8462c49 100644 --- a/effects/data/snow.vert +++ b/effects/data/snow.vert @@ -42,6 +42,6 @@ void main() else yCoord = float(height)*0.5; vec2 vertex = vec2( xCoord, yCoord ); - vertex = (vertex)*rotation + vec2( float(x), 0.0 ) + vec2(hSpeed, vSpeed)*float(frames); + vertex = (vertex)*rotation + vec2( float(x), float(-height) ) + vec2(hSpeed, vSpeed)*float(frames); gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex, gl_Vertex.zw); } diff --git a/effects/snow.cpp b/effects/snow.cpp index 377ad20125..477c99d600 100644 --- a/effects/snow.cpp +++ b/effects/snow.cpp @@ -98,7 +98,7 @@ void SnowEffect::prePaintScreen( ScreenPrePaintData& data, int time ) int size = 0; while ( size < mMinFlakeSize ) size = random() % mMaxFlakeSize; - SnowFlake flake = SnowFlake( random() % (displayWidth() - size), -1 * size, size, size, mMaxVSpeed, mMaxHSpeed ); + SnowFlake flake = SnowFlake( random() % (displayWidth() - size), -size, size, size, mMaxVSpeed, mMaxHSpeed ); flakes.append( flake ); // calculation of next time of snowflake @@ -356,9 +356,9 @@ SnowFlake::SnowFlake(int x, int y, int width, int height, int maxVSpeed, int max if(rotationSpeed == 0) rotationSpeed = 0.5; rect = QRect(x, y, width, height); frameCounter = 0; - maxFrames = displayHeight() / vSpeed; + maxFrames = (displayHeight() + 2*height) / vSpeed; if( hSpeed > 0 ) - maxFrames = qMin( maxFrames, (displayWidth() - x)/hSpeed ); + maxFrames = qMin( maxFrames, (displayWidth() + width - x)/hSpeed ); else if( hSpeed < 0 ) maxFrames = qMin( maxFrames, (x + width)/(-hSpeed) ); }