ftp.nice.ch/pub/next/graphics/3d/Raytracers.N.bs.tar.gz#/raytracers/ohta/src/intersect.c

This is intersect.c in view mode; [Download] [Up]

#include "ray.h"

struct intersect intersect(r)
struct ray r;
{struct intersect i,imin;
register struct objlist *ol;
register int o;
	imin.obj=0;
	if(fflag)
	{	if(objects[r.obj].flags&SELF)
		{	i=(*objects[r.obj].shape)(r,r.obj);
			if(i.obj)
				imin=i;
		}
		for(ol=candidates[r.obj][dindex(r.l)];ol;ol=ol->next)
		{	if(oflag&&imin.obj&&imin.t<ol->t)
				break;
			i=(*objects[ol->obj].shape)(r,ol->obj);
			if(i.obj&&(!imin.obj||i.t<imin.t))
				imin=i;
		}
	}
	else
		for(o=lights+1;o<maxobj;o++)
		{	i=(*objects[o].shape)(r,o);
			if(i.obj&&(!imin.obj||i.t<imin.t))
				imin=i;
		}
	return imin;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.