summaryrefslogtreecommitdiff
path: root/test/raytracer
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 12:34:43 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 12:34:43 +0000
commit6c196ec8a41d6ed506c133c8b33dba9684f9a7a6 (patch)
tree4e1422ea2a810520d0d9b0fbb78c0014ba9f8443 /test/raytracer
parent93d89c2b5e8497365be152fb53cb6cd4c5764d34 (diff)
Updated raytracer test. Added SPASS test.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1271 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/raytracer')
-rw-r--r--test/raytracer/Makefile4
-rw-r--r--test/raytracer/arrays.h6
-rw-r--r--test/raytracer/config.h13
-rw-r--r--test/raytracer/eval.c70
-rw-r--r--test/raytracer/eval.h2
-rw-r--r--test/raytracer/gmllexer.c102
-rw-r--r--test/raytracer/gmlparser.c2
-rw-r--r--test/raytracer/intersect.c2
-rw-r--r--test/raytracer/light.c18
-rw-r--r--test/raytracer/matrix.c12
-rw-r--r--test/raytracer/matrix.h3
-rw-r--r--test/raytracer/object.c17
-rw-r--r--test/raytracer/object.h10
-rw-r--r--test/raytracer/point.h8
-rw-r--r--test/raytracer/render.c2
-rw-r--r--test/raytracer/simplify.c24
16 files changed, 136 insertions, 159 deletions
diff --git a/test/raytracer/Makefile b/test/raytracer/Makefile
index 2812909..dea57af 100644
--- a/test/raytracer/Makefile
+++ b/test/raytracer/Makefile
@@ -1,5 +1,5 @@
CC=../../ccomp
-CFLAGS=-U__GNUC__ -stdlib ../../runtime -dclight -dasm
+CFLAGS=-stdlib ../../runtime -dparse -dclight -dasm -fstruct-passing -fstruct-assign
LIBS=
TIME=xtime -mintime 2.0
@@ -11,7 +11,7 @@ render: $(OBJS)
$(CC) $(CFLAGS) -o render $(OBJS) $(LIBS)
clean:
- rm -f *.o *.light.c *.s *.ppm render
+ rm -f *.o *.parsed.c *.light.c *.s *.ppm render
include .depend
diff --git a/test/raytracer/arrays.h b/test/raytracer/arrays.h
index 47634f6..fe65af0 100644
--- a/test/raytracer/arrays.h
+++ b/test/raytracer/arrays.h
@@ -18,14 +18,8 @@ struct array * copy_array(int eltsize, struct array * arr, int extrasize);
#define get_array(ty,arr,idx) (data_array(ty,arr)[idx])
-#define get_array_large(dst,ty,arr,idx) \
- ASSIGN(dst, data_array(ty,arr)[idx])
-
#define set_array(ty,arr,idx,newval) (data_array(ty,arr)[idx] = (newval))
-#define set_array_large(ty,arr,idx,newval) \
- ASSIGN(data_array(ty,arr)[idx], newval)
-
#define extend_array(ty,arr) \
if ((arr)->size >= (arr)->capacity) grow_array(sizeof(ty), (arr)); \
(arr)->size++
diff --git a/test/raytracer/config.h b/test/raytracer/config.h
index ed5b847..49361dc 100644
--- a/test/raytracer/config.h
+++ b/test/raytracer/config.h
@@ -1,9 +1,9 @@
#include <math.h>
+#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#ifdef SINGLE_PRECISION
typedef float flt;
@@ -11,17 +11,6 @@ typedef float flt;
typedef double flt;
#endif
-#if 0
-extern void abord(void);
-
-#define assert(cond) \
- if (!(cond)) { fprintf(stderr, "%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); }
-
-#endif
-
-#define ASSIGN(lv,rv) memcpy(&(lv), &(rv), sizeof(rv))
-
void arena_init(void);
void arena_clear(void);
void * arena_alloc(int size);
-
diff --git a/test/raytracer/eval.c b/test/raytracer/eval.c
index 4d3f3dc..7c3cb93 100644
--- a/test/raytracer/eval.c
+++ b/test/raytracer/eval.c
@@ -38,7 +38,7 @@ static int lookup(struct array * env, char * name, /*out*/ struct value * res)
for (i = env->size - 1; i >= 0; i--) {
struct binding * b = &get_array(struct binding, env, i);
if (name == b->name) {
- ASSIGN(*res, b->val);
+ *res = b->val;
return 1;
}
}
@@ -55,7 +55,7 @@ static void assign(struct array * env, char * name, struct value * newval)
b = &get_array(struct binding, env, i);
if (! b->mutable) break;
if (name == b->name) {
- ASSIGN(b->val, *newval);
+ b->val = *newval;
return;
}
}
@@ -63,7 +63,7 @@ static void assign(struct array * env, char * name, struct value * newval)
b = &get_array(struct binding, env, env->size - 1);
b->name = name;
b->mutable = 1;
- ASSIGN(b->val, *newval);
+ b->val = *newval;
}
/* Take an immutable copy of an environment */
@@ -173,22 +173,11 @@ static void print_value(struct value * s)
static struct value main_stack[MAIN_STACK_SIZE];
static struct value surface_stack[SURFACE_STACK_SIZE];
-/* Error handling functions */
-#define ERRORFUN(name, msg) \
- static void name(void) { fprintf(stderr, msg); exit(2); }
-
-ERRORFUN(stack_overflow, "Stack overflow\n")
-ERRORFUN(stack_underflow, "Stack underflow\n")
-ERRORFUN(type_error, "Type error\n")
-ERRORFUN(division_by_zero, "Division by zero\n")
-ERRORFUN(bound_error, "Out-of-bound array access\n")
-ERRORFUN(negative_sqrt, "Square root of negative number\n")
-
/* Macros for stack checking and type checking */
-#define push() if (--sp < bos) stack_overflow()
-#define can_pop(n) if (sp + (n) > tos) stack_underflow()
-#define check(n,ty) if (sp[n].tag != ty) type_error()
+#define push() if (--sp < bos) goto stack_overflow
+#define can_pop(n) if (sp + (n) > tos) goto stack_underflow
+#define check(n,ty) if (sp[n].tag != ty) goto type_error
/* Execute the given token list in the given environment */
@@ -238,7 +227,7 @@ static struct value * execute_list(struct array * code,
struct array * a = new_array(struct value, sz);
int j;
a->size = sz;
- for (j = 0; j < sz; j++) set_array_large(struct value, a, j, sp[-1-j]);
+ for (j = 0; j < sz; j++) set_array(struct value, a, j, sp[-1-j]);
push();
sp[0].tag = Arr; sp[0].u.arr = a;
break;
@@ -287,7 +276,7 @@ static struct value * execute_list(struct array * code,
can_pop(1);
check(0, Clos);
sp[0].tag = Obj;
- sp[0].u.obj = cone(&sp[0].u.clos);
+ sp[0].u.obj = cone(sp[0].u.clos);
break;
case Op_cos:
can_pop(1);
@@ -298,13 +287,13 @@ static struct value * execute_list(struct array * code,
can_pop(1);
check(0, Clos);
sp[0].tag = Obj;
- sp[0].u.obj = cube(&sp[0].u.clos);
+ sp[0].u.obj = cube(sp[0].u.clos);
break;
case Op_cylinder:
can_pop(1);
check(0, Clos);
sp[0].tag = Obj;
- sp[0].u.obj = cylinder(&sp[0].u.clos);
+ sp[0].u.obj = cylinder(sp[0].u.clos);
break;
case Op_difference:
can_pop(2);
@@ -317,7 +306,7 @@ static struct value * execute_list(struct array * code,
can_pop(2);
check(1, I);
check(0, I);
- if (sp[0].u.i == 0) division_by_zero();
+ if (sp[0].u.i == 0) goto division_by_zero;
sp[1].u.i = sp[1].u.i / sp[0].u.i;
sp += 1;
break;
@@ -365,8 +354,8 @@ static struct value * execute_list(struct array * code,
check(0, I);
a = sp[1].u.arr;
idx = sp[0].u.i;
- if (idx < 0 || idx >= a->size) bound_error();
- get_array_large(sp[1], struct value, a, idx);
+ if (idx < 0 || idx >= a->size) goto bound_error;
+ sp[1] = get_array(struct value, a, idx);
sp++;
break;
}
@@ -439,7 +428,7 @@ static struct value * execute_list(struct array * code,
can_pop(2);
check(1, I);
check(0, I);
- if (sp[0].u.i == 0) division_by_zero();
+ if (sp[0].u.i == 0) goto division_by_zero;
sp[1].u.i = sp[1].u.i % sp[0].u.i;
sp += 1;
break;
@@ -471,7 +460,7 @@ static struct value * execute_list(struct array * code,
can_pop(1);
check(0, Clos);
sp[0].tag = Obj;
- sp[0].u.obj = plane(&sp[0].u.clos);
+ sp[0].u.obj = plane(sp[0].u.clos);
break;
case Op_point: {
struct point * p;
@@ -562,7 +551,7 @@ static struct value * execute_list(struct array * code,
can_pop(1);
check(0, Clos);
sp[0].tag = Obj;
- sp[0].u.obj = sphere(&sp[0].u.clos);
+ sp[0].u.obj = sphere(sp[0].u.clos);
break;
case Op_spotlight:
can_pop(5);
@@ -579,7 +568,7 @@ static struct value * execute_list(struct array * code,
case Op_sqrt:
can_pop(1);
check(0, R);
- if (sp[0].u.r < 0) negative_sqrt();
+ if (sp[0].u.r < 0) goto negative_sqrt;
sp[0].u.r = sqrt(sp[0].u.r);
break;
case Op_subi:
@@ -627,11 +616,32 @@ static struct value * execute_list(struct array * code,
}
}
return sp;
+ /* Error handling */
+ stack_overflow:
+ fprintf(stderr, "Stack overflow\n");
+ goto print_context;
+ stack_underflow:
+ fprintf(stderr, "Stack underflow\n");
+ goto print_context;
+ type_error:
+ fprintf(stderr, "Type error\n");
+ goto print_context;
+ division_by_zero:
+ fprintf(stderr, "Division by zero\n");
+ goto print_context;
+ bound_error:
+ fprintf(stderr, "Out-of-bound array access\n");
+ goto print_context;
+ negative_sqrt:
+ fprintf(stderr, "Square root of negative number\n");
+ print_context:
+ fprintf(stderr, "(operation: %s, PC: %d)\n", operator_names[t->tag], i);
+ exit(2);
}
/* Evaluate a surface function */
-void surface_function(struct closure * clos, int face, flt u, flt v,
+void surface_function(struct closure clos, int face, flt u, flt v,
/*out*/ struct surface_characteristics * sc)
{
struct value * sp;
@@ -643,7 +653,7 @@ void surface_function(struct closure * clos, int face, flt u, flt v,
sp[0].tag = R;
sp[0].u.i = v;
sp =
- execute_list(clos->code, clos->env, surface_stack,
+ execute_list(clos.code, clos.env, surface_stack,
surface_stack + SURFACE_STACK_SIZE, sp);
if (sp != surface_stack + SURFACE_STACK_SIZE - 4 ||
sp[0].tag != R ||
diff --git a/test/raytracer/eval.h b/test/raytracer/eval.h
index 610b5d9..88facfe 100644
--- a/test/raytracer/eval.h
+++ b/test/raytracer/eval.h
@@ -14,5 +14,5 @@ struct surface_characteristics {
void execute_program(struct array * toklist);
-void surface_function(struct closure * clos, int face, flt u, flt v,
+void surface_function(struct closure clos, int face, flt u, flt v,
/*out*/ struct surface_characteristics * sc);
diff --git a/test/raytracer/gmllexer.c b/test/raytracer/gmllexer.c
index 04f8df8..a8594dd 100644
--- a/test/raytracer/gmllexer.c
+++ b/test/raytracer/gmllexer.c
@@ -1,14 +1,10 @@
/* Lexer for GML */
#include "config.h"
+#include <ctype.h>
#include "gmllexer.h"
#include "gml.h"
-#define isdigit(c) (c >= '0' && c <= '9')
-#define isalpha(c) ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
-#define isalnum(c) (isdigit(c) || isalpha(c))
-#define isprint(c) (c >= ' ' && c <= 126)
-
struct lexeme current_lexeme;
struct bucket {
@@ -91,7 +87,7 @@ static void get_binder(void)
current_lexeme.kind = BINDER;
}
-static int get_number(int firstchar)
+static void get_number(int firstchar)
{
int c, pos, is_real;
@@ -102,7 +98,7 @@ static int get_number(int firstchar)
if (c == '-') {
STORE_BUFFER(pos, c);
c = getchar();
- if (! isdigit(c)) return -1;
+ if (! isdigit(c)) goto bad_number;
}
/* Decimal number */
do {
@@ -114,7 +110,7 @@ static int get_number(int firstchar)
is_real = 1;
STORE_BUFFER(pos, c);
c = getchar();
- if (! isdigit(c)) return -1;
+ if (! isdigit(c)) goto bad_number;
do {
STORE_BUFFER(pos, c);
c = getchar();
@@ -129,7 +125,7 @@ static int get_number(int firstchar)
STORE_BUFFER(pos, c);
c = getchar();
}
- if (! isdigit(c)) return -1;
+ if (! isdigit(c)) goto bad_number;
do {
STORE_BUFFER(pos, c);
c = getchar();
@@ -145,23 +141,29 @@ static int get_number(int firstchar)
current_lexeme.kind = INTEGER;
current_lexeme.u.i = atoi(buffer);
}
- return 0;
+ return;
+ bad_number:
+ fprintf(stderr, "Illegal number\n");
+ exit(2);
}
-static int get_string(void)
+static void get_string()
{
int c, pos;
pos = 0;
while (1) {
c = getchar();
if (c == '"') break;
- if (! isprint(c)) return -1;
+ if (! isprint(c)) goto bad_string;
STORE_BUFFER(pos, c);
}
buffer[pos] = 0;
current_lexeme.kind = STRING;
current_lexeme.u.s = strdup(buffer);
- return 0;
+ return;
+ bad_string:
+ fprintf(stderr, "Illegal string literal\n");
+ exit(2);
}
void get_lexeme(void)
@@ -169,49 +171,39 @@ void get_lexeme(void)
int c;
if (current_lexeme.kind != NONE) return;
- while (1) {
- c = getchar();
- switch (c) {
- case EOF:
- current_lexeme.kind = END_OF_FILE; break;
- case ' ': case '\n': case '\t': case '\r': case 11:
- continue;
- case '%':
- do { c = getchar(); } while (c != '\n' && c != EOF);
- continue;
- case '/':
- get_binder(); break;
- case '-': case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (get_number(c) == -1) {
- fprintf(stderr, "Bad number\n");
- exit(2);
- }
- break;
- case '"':
- if (get_string() == -1) {
- fprintf(stderr, "Bad string literal\n");
- exit(2);
- }
- break;
- case '{':
- current_lexeme.kind = LBRACE; break;
- case '}':
- current_lexeme.kind = RBRACE; break;
- case '[':
- current_lexeme.kind = LBRACKET; break;
- case ']':
- current_lexeme.kind = RBRACKET; break;
- default:
- if (isalpha(c)) {
- get_ident(c);
- } else {
- fprintf(stderr, "Illegal character `%c'\n", c);
- exit(2);
- }
- break;
+ again:
+ c = getchar();
+ switch (c) {
+ case EOF:
+ current_lexeme.kind = END_OF_FILE; break;
+ case ' ': case '\n': case '\t': case '\r': case 11:
+ goto again;
+ case '%':
+ do { c = getchar(); } while (c != '\n' && c != EOF);
+ goto again;
+ case '/':
+ get_binder(); break;
+ case '-': case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ get_number(c); break;
+ case '"':
+ get_string(); break;
+ case '{':
+ current_lexeme.kind = LBRACE; break;
+ case '}':
+ current_lexeme.kind = RBRACE; break;
+ case '[':
+ current_lexeme.kind = LBRACKET; break;
+ case ']':
+ current_lexeme.kind = RBRACKET; break;
+ default:
+ if (isalpha(c)) {
+ get_ident(c);
+ } else {
+ fprintf(stderr, "Illegal character `%c'\n", c);
+ exit(2);
}
- return;
+ break;
}
}
diff --git a/test/raytracer/gmlparser.c b/test/raytracer/gmlparser.c
index b0a6cbc..dc05105 100644
--- a/test/raytracer/gmlparser.c
+++ b/test/raytracer/gmlparser.c
@@ -82,7 +82,7 @@ static struct array * parse_tokenlist(void)
int i = 0;
while (parse_token(&t)) {
extend_array(struct tok, a);
- set_array_large(struct tok, a, i, t);
+ set_array(struct tok, a, i, t);
i++;
}
return a;
diff --git a/test/raytracer/intersect.c b/test/raytracer/intersect.c
index c8a2126..3b2d7b0 100644
--- a/test/raytracer/intersect.c
+++ b/test/raytracer/intersect.c
@@ -9,7 +9,7 @@
/* Operations on interval lists */
-#define POS_INFTY 1e300
+#define POS_INFTY HUGE_VAL
struct intervlist {
flt beg;
diff --git a/test/raytracer/light.c b/test/raytracer/light.c
index 1c90104..60d979a 100644
--- a/test/raytracer/light.c
+++ b/test/raytracer/light.c
@@ -10,8 +10,8 @@ struct light * dirlight(struct point * dir, struct point * c)
{
struct light * l = arena_alloc(sizeof(struct light));
l->kind = Directional;
- ASSIGN(l->u.directional.dir, *dir);
- ASSIGN(l->u.directional.col, *c);
+ l->u.directional.dir = *dir;
+ l->u.directional.col = *c;
return l;
}
@@ -19,8 +19,8 @@ struct light * pointlight(struct point * orig, struct point * c)
{
struct light * l = arena_alloc(sizeof(struct light));
l->kind = Pointlight;
- ASSIGN(l->u.point.orig, *orig);
- ASSIGN(l->u.point.col, *c);
+ l->u.point.orig = *orig;
+ l->u.point.col = *c;
return l;
}
@@ -30,9 +30,9 @@ struct light * spotlight(struct point * pos, struct point * at,
struct light * l = arena_alloc(sizeof(struct light));
struct vector uv;
l->kind = Spot;
- ASSIGN(l->u.spot.orig, *pos);
- ASSIGN(l->u.spot.at, *at);
- ASSIGN(l->u.spot.col, *c);
+ l->u.spot.orig = *pos;
+ l->u.spot.at = *at;
+ l->u.spot.col = *c;
l->u.spot.cutoff = cutoff;
l->u.spot.exponent = exp;
between(at, pos, &uv);
@@ -81,9 +81,7 @@ static void color_from_light(struct object * scene,
/* Intensity of light source at object */
switch (light->kind) {
case Directional:
- i.x = light->u.directional.col.x;
- i.y = light->u.directional.col.y;
- i.z = light->u.directional.col.z;
+ i = light->u.directional.col;
break;
case Pointlight:
att = 100.0 / (99.0 + dist2(pt, &light->u.point.orig));
diff --git a/test/raytracer/matrix.c b/test/raytracer/matrix.c
index 8814346..5c85c7b 100644
--- a/test/raytracer/matrix.c
+++ b/test/raytracer/matrix.c
@@ -3,12 +3,6 @@
#include "vector.h"
#include "matrix.h"
-struct matrix matrix_identity = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
-};
-
void apply_to_point(struct matrix * m, struct point * p,
/*out*/ struct point * r)
{
@@ -25,7 +19,13 @@ void apply_to_vect(struct matrix * m, struct vector * v,
r->dz = m->zx * v->dx + m->zy * v->dy + m->zz * v->dz;
}
+static struct matrix matrix_identity = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+};
+struct matrix * mid = &matrix_identity;
struct matrix * mtranslate(flt sx, flt sy, flt sz)
{
diff --git a/test/raytracer/matrix.h b/test/raytracer/matrix.h
index 4b9f434..5ab63b3 100644
--- a/test/raytracer/matrix.h
+++ b/test/raytracer/matrix.h
@@ -8,8 +8,7 @@ void apply_to_point(struct matrix * m, struct point * p,
/*out*/ struct point * r);
void apply_to_vect(struct matrix * m, struct vector * v,
/*out*/ struct vector * r);
-extern struct matrix matrix_identity;
-#define mid (&matrix_identity)
+extern struct matrix * mid;
struct matrix * mtranslate(flt sx, flt sy, flt sz);
struct matrix * mscale(flt sx, flt sy, flt sz);
struct matrix * mrotatex(flt a);
diff --git a/test/raytracer/object.c b/test/raytracer/object.c
index 3dd6e77..c7e5f53 100644
--- a/test/raytracer/object.c
+++ b/test/raytracer/object.c
@@ -6,30 +6,30 @@
#include "object.h"
#include "matrix.h"
-static struct object * new_object(int kind, struct closure * c)
+static struct object * new_object(int kind, struct closure c)
{
struct object * o = arena_alloc(sizeof(struct object));
o->kind = kind;
- ASSIGN(o->surf, *c);
+ o->surf = c;
o->world2obj = o->obj2world = mid;
o->max_scale_applied = 1.0;
o->radius = BS_NOT_COMPUTED;
return o;
}
-struct object * cone(struct closure * c)
+struct object * cone(struct closure c)
{ return new_object(Cone, c); }
-struct object * cube(struct closure * c)
+struct object * cube(struct closure c)
{ return new_object(Cube, c); }
-struct object * cylinder(struct closure * c)
+struct object * cylinder(struct closure c)
{ return new_object(Cylinder, c); }
-struct object * plane(struct closure * c)
+struct object * plane(struct closure c)
{ return new_object(Plane, c); }
-struct object * sphere(struct closure * c)
+struct object * sphere(struct closure c)
{ return new_object(Sphere, c); }
static struct object * transform(struct object * o,
@@ -47,7 +47,7 @@ static struct object * transform(struct object * o,
no->o2 = transform(o->o2, t, tinv, scale);
break;
default:
- ASSIGN(no->surf, o->surf);
+ no->surf = o->surf;
no->world2obj = mcompose(o->world2obj, tinv);
no->obj2world = mcompose(t, o->obj2world);
no->max_scale_applied = o->max_scale_applied * scale;
@@ -212,3 +212,4 @@ void normal_vector(struct object * obj, struct point * p, int face,
product(&tang_world1, &tang_world2, n);
vnormalize(n, n);
}
+
diff --git a/test/raytracer/object.h b/test/raytracer/object.h
index d890bda..b5edd58 100644
--- a/test/raytracer/object.h
+++ b/test/raytracer/object.h
@@ -12,11 +12,11 @@ struct object {
flt radius;
};
-struct object * cone(struct closure * c);
-struct object * cube(struct closure * c);
-struct object * cylinder(struct closure * c);
-struct object * plane(struct closure * c);
-struct object * sphere(struct closure * c);
+struct object * cone(struct closure c);
+struct object * cube(struct closure c);
+struct object * cylinder(struct closure c);
+struct object * plane(struct closure c);
+struct object * sphere(struct closure c);
struct object * orotatex(struct object * o1, flt a);
struct object * orotatey(struct object * o1, flt a);
diff --git a/test/raytracer/point.h b/test/raytracer/point.h
index b8d6ff0..64bf582 100644
--- a/test/raytracer/point.h
+++ b/test/raytracer/point.h
@@ -2,7 +2,6 @@ struct point {
flt x, y, z;
};
-#if 0
static inline flt dist2(struct point * p1, struct point * p2)
{
flt dx = p2->x - p1->x;
@@ -10,9 +9,4 @@ static inline flt dist2(struct point * p1, struct point * p2)
flt dz = p2->z - p1->z;
return dx * dx + dy * dy + dz * dz;
}
-#else
-#define dist2(p1,p2) \
- (((p2)->x - (p1)->x) * ((p2)->x - (p1)->x) + \
- ((p2)->y - (p1)->y) * ((p2)->y - (p1)->y) + \
- ((p2)->z - (p1)->z) * ((p2)->z - (p1)->z))
-#endif
+
diff --git a/test/raytracer/render.c b/test/raytracer/render.c
index 3678cb6..9d73280 100644
--- a/test/raytracer/render.c
+++ b/test/raytracer/render.c
@@ -45,7 +45,7 @@ static void render_ray(struct point * amb,
point_along(p, v, t, &inter_w);
apply_to_point(bobj->world2obj, &inter_w, &inter_o);
surface_coords(bobj, &inter_o, &face, &surf_u, &surf_v);
- surface_function(&bobj->surf, face, surf_u, surf_v, &sc);
+ surface_function(bobj->surf, face, surf_u, surf_v, &sc);
/* Construct the vectors on figure 4 */
normal_vector(bobj, &inter_w, face, &n);
dotprod = dotproduct(v, &n);
diff --git a/test/raytracer/simplify.c b/test/raytracer/simplify.c
index 7a4a545..d8cbe64 100644
--- a/test/raytracer/simplify.c
+++ b/test/raytracer/simplify.c
@@ -7,7 +7,7 @@
#include "object.h"
#include "simplify.h"
-#define INFINITE_RADIUS 1e300
+#define INFINITE_RADIUS HUGE_VAL
static flt cone_radius = 1.0;
static flt cube_radius = 0.86602540378443859659; /* sqrt(3)/2 */
@@ -44,11 +44,11 @@ static inline void union_bs(struct object * t1, struct object * t2,
if (dd2 <= rr2) {
/* take the biggest sphere */
if (t1->radius <= t2->radius) {
- ASSIGN(obj->center, t2->center);
+ obj->center = t2->center;
obj->radius = t2->radius;
set_infinite(t2);
} else {
- ASSIGN(obj->center, t1->center);
+ obj->center = t1->center;
obj->radius = t1->radius;
set_infinite(t1);
}
@@ -67,12 +67,12 @@ static inline void intersection_bs(struct object * t1, struct object * t2,
flt dd2, rr, rr2, rpr, rpr2, diff, d, te1, te2, te3, te4, te, alpha;
if (t1->radius >= INFINITE_RADIUS) {
- ASSIGN(obj->center, t2->center);
+ obj->center = t2->center;
obj->radius = t2->radius;
return;
}
if (t2->radius >= INFINITE_RADIUS) {
- ASSIGN(obj->center, t1->center);
+ obj->center = t1->center;
obj->radius = t1->radius;
return;
}
@@ -83,11 +83,11 @@ static inline void intersection_bs(struct object * t1, struct object * t2,
if (dd2 <= rr2) {
/* take the smallest sphere */
if (t2->radius <= t1->radius) {
- ASSIGN(obj->center, t2->center);
+ obj->center = t2->center;
obj->radius = t2->radius;
set_infinite(t2);
} else {
- ASSIGN(obj->center, t1->center);
+ obj->center = t1->center;
obj->radius = t1->radius;
set_infinite(t1);
}
@@ -96,19 +96,19 @@ static inline void intersection_bs(struct object * t1, struct object * t2,
rpr = t1->radius + t2->radius;
rpr2 = rpr * rpr;
if (dd2 > rpr2) {
- ASSIGN(obj->center, origin);
+ obj->center = origin;
obj->radius = 0.0;
return;
}
diff = t1->radius * t1->radius - t2->radius * t2->radius;
if (dd2 <= diff) {
- ASSIGN(obj->center, t2->center);
+ obj->center = t2->center;
obj->radius = t2->radius;
set_infinite(t2);
return;
}
if (dd2 <= -diff) {
- ASSIGN(obj->center, t1->center);
+ obj->center = t1->center;
obj->radius = t1->radius;
set_infinite(t1);
return;
@@ -128,7 +128,7 @@ static inline void intersection_bs(struct object * t1, struct object * t2,
static inline void difference_bs(struct object * t1, struct object * t2,
struct object * obj)
{
- ASSIGN(obj->center, t1->center);
+ obj->center = t1->center;
obj->radius = t1->radius;
set_infinite(t1);
}
@@ -150,7 +150,7 @@ void compute_bounding_spheres(struct object * obj)
obj->radius = obj->max_scale_applied * cylinder_radius;
break;
case Plane:
- ASSIGN(obj->center, plane_center);
+ obj->center = plane_center;
obj->radius = INFINITE_RADIUS;
break;
case Sphere: