From 73c5be6f5f475210422ef3b040231bed7870548f Mon Sep 17 00:00:00 2001 From: jal Date: Fri, 28 May 2010 21:49:38 +0200 Subject: [PATCH] convert to float the input of RGBTOGRAY macro, or it can cause rounding errors in byte vectors. --- libs/mathlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/mathlib.h b/libs/mathlib.h index c2e2ed75..d206d330 100644 --- a/libs/mathlib.h +++ b/libs/mathlib.h @@ -77,7 +77,7 @@ extern const vec3_t g_vec3_axis_z; #define FLOAT_SNAP(f,snap) ( (float)( floor( (f) / (snap) + 0.5 ) * (snap) ) ) #define FLOAT_TO_INTEGER(f) ( (float)( floor( (f) + 0.5 ) ) ) -#define RGBTOGRAY(x) ( (x)[0] * 0.2989f + (x)[1] * 0.5870f + (x)[2] * 0.1140f ) +#define RGBTOGRAY(x) ( (float)((x)[0]) * 0.2989f + (float)((x)[1]) * 0.5870f + (float)((x)[2]) * 0.1140f ) #define Q_rint(in) ((vec_t)floor(in+0.5)) -- 2.39.2