diff options
author | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:39:32 -0500 |
---|---|---|
committer | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:40:26 -0500 |
commit | ce39f5c767ae25ed884aa24120e340d154442342 (patch) | |
tree | c98e7215970f6689c3f25420a83d30041d7a36b2 /ray.c | |
parent | 1dca69e545ab815850230a377bc346bb5dc33839 (diff) |
ray.c: Simplify trace_line
This doesn't save any time.
Diffstat (limited to 'ray.c')
-rw-r--r-- | ray.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -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; } } |