Clamp macros for floats

git-svn-id: https://svn.eduke32.com/eduke32@4431 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-04-12 08:45:08 +00:00
parent e760d590be
commit 82f5a3f39c

View file

@ -524,6 +524,18 @@ CLAMP_DECL int32_t clamp2(int32_t in, int32_t min, int32_t max)
return in >= max ? max : (in <= min ? min : in);
}
// Clamp <in> to [<min>..<max>]. The case in <= min is handled first.
CLAMP_DECL float fclamp(float in, float min, float max)
{
return in <= min ? min : (in >= max ? max : in);
}
// Clamp <in> to [<min>..<max>]. The case in >= max is handled first.
CLAMP_DECL float fclamp2(float in, float min, float max)
{
return in >= max ? max : (in <= min ? min : in);
}
#define BMAX_PATH 256