From 54b65734700e978c3c0dab4932622d171f3ced52 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 9 May 2022 22:54:47 +0900 Subject: [PATCH] [client] Change location of sun vector negation Moving the negation into the calculation of the sun angle prevents -0 getting into the vector (not that it makes much difference other than minor confusion when reading the light data). --- libs/client/cl_light.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/client/cl_light.c b/libs/client/cl_light.c index 5af325739..0bc3e8287 100644 --- a/libs/client/cl_light.c +++ b/libs/client/cl_light.c @@ -91,10 +91,12 @@ static vec4f_t sun_vector (const vec_t *ang) { // ang is yaw, pitch (maybe roll, but ignored + // negative as the vector points *to* the sun, but ang specifies the + // direction from the sun vec4f_t vec = { - ecos (ang[1]) * ecos (ang[0]), - ecos (ang[1]) * esin (ang[0]), - esin (ang[1]), + -ecos (ang[1]) * ecos (ang[0]), + -ecos (ang[1]) * esin (ang[0]), + -esin (ang[1]), 0, }; return vec; @@ -120,7 +122,7 @@ parse_sun (lightingdata_t *ldata, plitem_t *entity) } VectorSet (1, 1, 1, light.color); light.color[3] = sunlight; - light.position = -sun_vector (sunangle); + light.position = sun_vector (sunangle); light.direction = light.position; light.direction[3] = 1; light.attenuation = (vec4f_t) { 0, 0, 1, 0 };