--- ray/src/rt/raytrace.c 1989/07/19 18:46:59 1.5 +++ ray/src/rt/raytrace.c 1990/03/27 11:40:05 1.10 @@ -22,7 +22,7 @@ extern double minweight; /* minimum ray weight */ long nrays = 0L; /* number of rays traced */ -#define MAXLOOP 1024 /* modifier loop detection */ +#define MAXLOOP 128 /* modifier loop detection */ #define RAYHIT (-1) /* return value for intercepted ray */ @@ -59,25 +59,36 @@ double rw; r->pert[0] = r->pert[1] = r->pert[2] = 0.0; setcolor(r->pcol, 1.0, 1.0, 1.0); setcolor(r->rcol, 0.0, 0.0, 0.0); + r->rt = 0.0; return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); } rayvalue(r) /* compute a ray's value */ -register RAY *r; +RAY *r; { extern int (*trace)(); if (localhit(r, &thescene) || sourcehit(r)) - rayshade(r, r->ro->omod); + raycont(r); if (trace != NULL) (*trace)(r); /* trace execution */ } +raycont(r) /* check for clipped object and continue */ +register RAY *r; +{ + if (r->clipset != NULL && inset(r->clipset, r->ro->omod)) + raytrans(r); + else + rayshade(r, r->ro->omod); +} + + raytrans(r) /* transmit ray as is */ -RAY *r; +register RAY *r; { RAY tr; @@ -85,6 +96,7 @@ RAY *r; VCOPY(tr.rdir, r->rdir); rayvalue(&tr); copycolor(r->rcol, tr.rcol); + r->rt = r->rot + tr.rt; } } @@ -95,12 +107,6 @@ int mod; { static int depth = 0; register OBJREC *m; - /* check for clipped surface */ - if (r->clipset != NULL && r->rot < FHUGE && - inset(r->clipset, mod)) { - raytrans(r); - return; - } /* check for infinite loop */ if (depth++ >= MAXLOOP) objerror(r->ro, USER, "possible modifier loop"); @@ -206,7 +212,7 @@ register RAY *r; * still fraught with problems since reflected rays and similar * directions calculated from the surface normal may spawn rays behind * the surface. The only solution is to curb textures at high - * incidence (Rdot << 1). + * incidence (namely, keep DOT(rdir,pert) < Rdot). */ for (i = 0; i < 3; i++)