--- ray/src/rt/raytrace.c 1991/06/17 08:26:18 1.20 +++ ray/src/rt/raytrace.c 1991/11/12 17:09:44 2.1 @@ -24,9 +24,9 @@ extern double minweight; /* minimum ray weight */ extern int do_irrad; /* compute irradiance? */ long raynum = 0L; /* next unique ray number */ -long nrays = 0L; /* number of calls to rayvalue */ +long nrays = 0L; /* number of calls to localhit */ -static double Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; +static FLOAT Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; OBJREC Lamb = { OVOID, MAT_PLASTIC, "Lambertian", {0, 5, NULL, Lambfa}, NULL, -1, @@ -48,6 +48,7 @@ double rw; r->crtype = r->rtype = rt; r->rsrc = -1; r->clipset = NULL; + r->revf = raytrace; } else { /* spawned ray */ r->rlvl = ro->rlvl; if (rt & RAYREFL) { @@ -58,10 +59,19 @@ double rw; r->rsrc = ro->rsrc; r->clipset = ro->newcset; } + r->revf = ro->revf; r->rweight = ro->rweight * rw; r->crtype = ro->crtype | (r->rtype = rt); VCOPY(r->rorg, ro->rop); } + rayclear(r); + return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); +} + + +rayclear(r) /* clear a ray for (re)evaluation */ +register RAY *r; +{ r->rno = raynum++; r->newcset = r->clipset; r->ro = NULL; @@ -70,16 +80,14 @@ double rw; 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 */ +raytrace(r) /* trace a ray and compute its value */ RAY *r; { extern int (*trace)(); - nrays++; /* increment trace counter */ if (localhit(r, &thescene)) raycont(r); else if (sourcehit(r)) @@ -315,6 +323,7 @@ register CUBE *scene; double t, dt; register int i; + nrays++; /* increment trace counter */ sflags = 0; for (i = 0; i < 3; i++) { curpos[i] = r->rorg[i];