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
This commit is contained in:
Lucas Murray 2009-01-31 11:53:07 +00:00
parent 7c1e1b758e
commit 9a31e8f3d9
2 changed files with 4 additions and 4 deletions

View file

@ -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);
}

View file

@ -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) );
}