ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raytrace.c
(Generate patch)

Comparing ray/src/rt/raytrace.c (file contents):
Revision 2.12 by greg, Thu Jan 13 10:43:34 1994 UTC vs.
Revision 2.17 by greg, Wed Dec 21 09:10:23 1994 UTC

# Line 34 | Line 34 | OBJREC  Lamb = {
34          {0, 5, NULL, Lambfa}, NULL,
35   };                                      /* a Lambertian surface */
36  
37 + OBJREC  Aftplane;                       /* aft clipping plane object */
38 +
39   static int  raymove(), checkset(), checkhit();
40  
41   #define  MAXLOOP        128             /* modifier loop detection */
# Line 67 | Line 69 | double  rw;
69                  r->rweight = ro->rweight * rw;
70                  r->crtype = ro->crtype | (r->rtype = rt);
71                  VCOPY(r->rorg, ro->rop);
72 +                r->rmax = 0.0;
73          }
74          rayclear(r);
75          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
# Line 95 | Line 98 | RAY  *r;
98  
99          if (localhit(r, &thescene))
100                  gotmat = raycont(r);
101 <        else if (sourcehit(r))
101 >        else if (r->ro == &Aftplane) {
102 >                r->ro = NULL;
103 >                r->rot = FHUGE;
104 >        } else if (sourcehit(r))
105                  gotmat = rayshade(r, r->ro->omod);
106  
107 <        if (!gotmat)
107 >        if (r->ro != NULL && !gotmat)
108                  objerror(r->ro, USER, "material not found");
109  
110          if (trace != NULL)
# Line 125 | Line 131 | register RAY  *r;
131  
132          if (rayorigin(&tr, r, TRANS, 1.0) == 0) {
133                  VCOPY(tr.rdir, r->rdir);
134 +                if (r->rmax > FTINY)
135 +                        tr.rmax = r->rmax - r->rot;
136                  rayvalue(&tr);
137                  copycolor(r->rcol, tr.rcol);
138                  r->rt = r->rot + tr.rt;
# Line 156 | Line 164 | int  mod;
164                          if (irr_ignore(m->otype)) {
165                                  depth--;
166                                  raytrans(r);
167 <                                return;
167 >                                return(1);
168                          }
169                          if (!islight(m->otype))
170                                  m = &Lamb;
# Line 207 | Line 215 | double  coef;
215                  coef = 1.0;
216          else if (coef < 0.0)
217                  coef = 0.0;
218 +                                        /* compute foreground and background */
219 +        foremat = backmat = -1;
220                                          /* foreground */
221          copystruct(&fr, r);
222          if (fore != OVOID && coef > FTINY)
223                  foremat = rayshade(&fr, fore);
214        else
215                foremat = 0;
224                                          /* background */
225          copystruct(&br, r);
226          if (back != OVOID && coef < 1.0-FTINY)
227                  backmat = rayshade(&br, back);
220        else
221                backmat = foremat;
228                                          /* check */
229 +        if (foremat < 0)
230 +                if (backmat < 0)
231 +                        foremat = backmat = 0;
232 +                else
233 +                        foremat = backmat;
234 +        else if (backmat < 0)
235 +                backmat = foremat;
236          if ((foremat==0) != (backmat==0))
237                  objerror(r->ro, USER, "mixing material with non-material");
238                                          /* mix perturbations */
# Line 348 | Line 361 | register CUBE  *scene;
361          }
362          if (sflags == 0)
363                  error(CONSISTENCY, "zero ray direction in localhit");
364 +                                        /* start off assuming nothing hit */
365 +        if (r->rmax > FTINY) {          /* except aft plane if one */
366 +                r->ro = &Aftplane;
367 +                r->rot = r->rmax;
368 +                for (i = 0; i < 3; i++)
369 +                        r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
370 +        }
371 +                                        /* find global cube entrance point */
372          t = 0.0;
373          if (!incube(scene, curpos)) {
374                                          /* find distance to entry */
# Line 365 | Line 386 | register CUBE  *scene;
386                                  t = dt; /* farthest face is the one */
387                  }
388                  t += FTINY;             /* fudge to get inside cube */
389 +                if (t >= r->rot)        /* clipped already */
390 +                        return(0);
391                                          /* advance position */
392                  for (i = 0; i < 3; i++)
393                          curpos[i] += r->rdir[i]*t;
# Line 373 | Line 396 | register CUBE  *scene;
396                          return(0);
397          }
398          cxset[0] = 0;
399 <        return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT);
399 >        return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT &&
400 >                        r->ro != &Aftplane);
401   }
402  
403  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines