--- ray/src/rt/raytrace.c 1994/01/13 10:43:34 2.12 +++ ray/src/rt/raytrace.c 1994/12/20 20:18:22 2.16 @@ -34,6 +34,8 @@ OBJREC Lamb = { {0, 5, NULL, Lambfa}, NULL, }; /* a Lambertian surface */ +static OBJREC Aftplane; /* aft clipping plane object */ + static int raymove(), checkset(), checkhit(); #define MAXLOOP 128 /* modifier loop detection */ @@ -67,6 +69,7 @@ double rw; r->rweight = ro->rweight * rw; r->crtype = ro->crtype | (r->rtype = rt); VCOPY(r->rorg, ro->rop); + r->rmax = 0.0; } rayclear(r); return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); @@ -78,8 +81,16 @@ register RAY *r; { r->rno = raynum++; r->newcset = r->clipset; - r->ro = NULL; - r->rot = FHUGE; + if (r->rmax > FTINY) { + r->ro = &Aftplane; + r->rot = r->rmax; + r->rop[0] = r->rorg[0] + r->rot*r->rdir[0]; + r->rop[1] = r->rorg[1] + r->rot*r->rdir[1]; + r->rop[2] = r->rorg[2] + r->rot*r->rdir[2]; + } else { + r->ro = NULL; + r->rot = FHUGE; + } 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); @@ -95,10 +106,13 @@ RAY *r; if (localhit(r, &thescene)) gotmat = raycont(r); - else if (sourcehit(r)) + else if (r->ro == &Aftplane) { + r->ro = NULL; + r->rot = FHUGE; + } else if (sourcehit(r)) gotmat = rayshade(r, r->ro->omod); - if (!gotmat) + if (r->ro != NULL && !gotmat) objerror(r->ro, USER, "material not found"); if (trace != NULL) @@ -156,7 +170,7 @@ int mod; if (irr_ignore(m->otype)) { depth--; raytrans(r); - return; + return(1); } if (!islight(m->otype)) m = &Lamb; @@ -207,19 +221,24 @@ double coef; coef = 1.0; else if (coef < 0.0) coef = 0.0; + /* compute foreground and background */ + foremat = backmat = -1; /* foreground */ copystruct(&fr, r); if (fore != OVOID && coef > FTINY) foremat = rayshade(&fr, fore); - else - foremat = 0; /* background */ copystruct(&br, r); if (back != OVOID && coef < 1.0-FTINY) backmat = rayshade(&br, back); - else - backmat = foremat; /* check */ + if (foremat < 0) + if (backmat < 0) + foremat = backmat = 0; + else + foremat = backmat; + else if (backmat < 0) + backmat = foremat; if ((foremat==0) != (backmat==0)) objerror(r->ro, USER, "mixing material with non-material"); /* mix perturbations */ @@ -373,7 +392,8 @@ register CUBE *scene; return(0); } cxset[0] = 0; - return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT); + return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT && + r->ro != &Aftplane); }