X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fbumps.c;h=2f510f5a9b5a5b15487a21ddb4e457a5e953b223;hp=c9f00bb40b9c12ddfc6412d98af59ca3217bd335;hb=07faf451b99879183ed7e909e43a0e065be1ee7f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439 diff --git a/hacks/bumps.c b/hacks/bumps.c index c9f00bb4..2f510f5a 100644 --- a/hacks/bumps.c +++ b/hacks/bumps.c @@ -346,7 +346,7 @@ static void InitBumpMap_2(Display *dpy, SBumps *pBumps) while( nSoften-- ) softenMultiplier *= 1.0f + ( 1.0f / 3.0f ); /* Softening takes the max height down, so scale up to compensate. */ maxHeight = pBumps->SpotLight.nLightRadius * softenMultiplier; - nAverager = ( 3 * 0xFFFF ) / maxHeight; + nAverager = maxHeight ? ( 3 * 0xFFFF ) / maxHeight : 0; pBump = pBumps->aBumpMap; if( bInvert ) /* Funny, it's actually the 'else' that inverts the bump map... */ @@ -361,7 +361,7 @@ static void InitBumpMap_2(Display *dpy, SBumps *pBumps) pColor = pBumps->xColors; for( iWidth=pBumps->iWinWidth; iWidth; --iWidth, ++pColor, ++pBump ) - *pBump = ( ( pColor->red + pColor->green + pColor->blue ) / nAverager ); + *pBump = ( nAverager ? ( pColor->red + pColor->green + pColor->blue ) / nAverager : 0 ); } } else @@ -376,7 +376,7 @@ static void InitBumpMap_2(Display *dpy, SBumps *pBumps) pColor = pBumps->xColors; for( iWidth=pBumps->iWinWidth; iWidth; --iWidth, ++pColor, ++pBump ) - *pBump = ( maxHeight - ( ( pColor->red + pColor->green + pColor->blue ) / nAverager ) ); + *pBump = ( maxHeight - ( nAverager ? ( pColor->red + pColor->green + pColor->blue ) / nAverager : 0 ) ); } }