Mercurial > hg > dmlib
changeset 106:93fbce0e6591
Added a new inline function, dmClip10() to clamp values between 0.0 and 1.0.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Oct 2012 09:19:08 +0300 |
parents | d5d27f262227 |
children | 1c2ff205fa0e |
files | dmlib.h efu.c |
diffstat | 2 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dmlib.h Wed Oct 03 09:16:26 2012 +0300 +++ b/dmlib.h Wed Oct 03 09:19:08 2012 +0300 @@ -278,6 +278,12 @@ #endif +static inline DMFloat dmClip10(const DMFloat a) +{ + return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); +} + + /* Global variables */ extern char *dmProgName,
--- a/efu.c Wed Oct 03 09:16:26 2012 +0300 +++ b/efu.c Wed Oct 03 09:19:08 2012 +0300 @@ -175,12 +175,6 @@ typedef Uint8 DMBlockMap[QHEIGHT][QWIDTH]; -static DMFloat dmClip(DMFloat a) -{ - return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); -} - - void dmMakeBumpMap(DMBlockMap map, DMFloat q, DMFloat m) { int x, y; @@ -188,7 +182,7 @@ for (x = 0; x < QWIDTH; x++) { DMFloat f = 0.40f + dmPerlinNoise2D(x, y, 1.1f, q, 2); - map[y][x] = (int) (dmClip(f) * m); + map[y][x] = (int) (dmClip10(f) * m); } }