home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
gondwana.ecr.mu.oz.au/pub/
/
Graphics.tar
/
Graphics
/
atomart.tar.gz
/
atomart.tar
/
rt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-17
|
952b
|
54 lines
#include <stdio.h>
#include <math.h>
#include "atomart.h"
#include "macro.h"
#include "gram.h"
extern object *oblist;
extern light *lights;
extern hlist *fhlist;
extern int maxhitlevel;
extern pixel backcol;
extern colour ambient;
extern double power();
/*
* trace
*
* returns a list of hits on the first object hit by r
*/
hlist *
trace(r, oblist)
register ray *r;
object *oblist;
{
register object *o;
register hlist *hit, *prevhits, *p, *np;
prevhits = (hlist *)NULL;
for (o = oblist; o != (object *)NULL; o = o->nxt)
if ((hit = o->intersects(r, o)) != (hlist *)NULL) {
if (prevhits == (hlist *)NULL) {
prevhits = hit;
} else {
if (prevhits->t > hit->t) {
for (p = prevhits; p != (hlist *)NULL; p = np) {
np = p->nxt;
release(p)
}
prevhits = hit;
} else {
for (p = hit; p != (hlist *)NULL; p = np) {
np = p->nxt;
release(p)
}
}
}
}
return(prevhits);
}