Make wrap() functions really wrap.

Before, if a value was over one of the limits, it would be set to the
other limit. For most usecases, that was fine, however for the starfield
this would cause stars to become aligned to each other after a while.
This commit is contained in:
Guus Sliepen 2011-08-27 23:30:44 +02:00
parent 1abf5d8c67
commit 6bfba4064b
1 changed files with 6 additions and 6 deletions

View File

@ -73,25 +73,25 @@ static inline void limitFloat(float *in, float low, float high)
static inline void wrapChar(signed char *in, signed char low, signed char high)
{
if (*in < low)
*in = high;
*in += high - low;
if (*in > high)
*in = low;
*in -= high - low;
}
static inline void wrapInt(int *in, int low, int high)
{
if (*in < low)
*in = high;
*in += high - low;
if (*in > high)
*in = low;
*in -= high - low;
}
static inline void wrapFloat(float *in, float low, float high)
{
if (*in < low)
*in = high;
*in += high - low;
if (*in > high)
*in = low;
*in -= high - low;
}
static inline int rrand(int min, int max)