From ce39f5c767ae25ed884aa24120e340d154442342 Mon Sep 17 00:00:00 2001 From: Morten Hustveit Date: Tue, 2 Dec 2014 15:39:32 -0500 Subject: ray.c: Simplify trace_line This doesn't save any time. --- ray.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'ray.c') diff --git a/ray.c b/ray.c index 1125d19..edbb37a 100644 --- a/ray.c +++ b/ray.c @@ -74,19 +74,16 @@ trace(float s[3], const float d[3], float pixel[3], int n) { static void trace_line(int l, unsigned char *buf) { - static float s[3] = {0, 0, 0}; - float y = l - HEIGHT / 2; + static const float s[3] = {0, 0, 0}; - for(int i = 0; i < WIDTH; ++i) { - float pixel[3]; - memset(pixel, '\0', sizeof(pixel)); + for(int i = 0; i < WIDTH; ++i, buf += 4) { + float pixel[3] = { 0, 0, 0 }; - const float* d = trace_vectors[l][i]; + trace(s, trace_vectors[l][i], pixel, 1); - trace(s, d, pixel, 1); - - for(int j = 0; j < 3; ++j) - buf[i * 4 + j] = MIN(255 * pixel[j], 255); + buf[0] = MIN(pixel[0], 1.0f) * 255; + buf[1] = MIN(pixel[1], 1.0f) * 255; + buf[2] = MIN(pixel[2], 1.0f) * 255; } } -- cgit v1.2.3