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.16 by greg, Tue Dec 20 20:18:22 1994 UTC vs.
Revision 2.21 by greg, Thu Nov 2 17:38:02 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 34 | Line 34 | OBJREC  Lamb = {
34          {0, 5, NULL, Lambfa}, NULL,
35   };                                      /* a Lambertian surface */
36  
37 < static OBJREC  Aftplane;                /* aft clipping plane object */
37 > OBJREC  Aftplane;                       /* aft clipping plane object */
38  
39   static int  raymove(), checkset(), checkhit();
40  
# Line 81 | Line 81 | register RAY  *r;
81   {
82          r->rno = raynum++;
83          r->newcset = r->clipset;
84 <        if (r->rmax > FTINY) {
85 <                r->ro = &Aftplane;
86 <                r->rot = r->rmax;
87 <                r->rop[0] = r->rorg[0] + r->rot*r->rdir[0];
88 <                r->rop[1] = r->rorg[1] + r->rot*r->rdir[1];
89 <                r->rop[2] = r->rorg[2] + r->rot*r->rdir[2];
90 <        } else {
91 <                r->ro = NULL;
92 <                r->rot = FHUGE;
93 <        }
84 >        r->ro = NULL;
85 >        r->rot = FHUGE;
86          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
87          setcolor(r->pcol, 1.0, 1.0, 1.0);
88          setcolor(r->rcol, 0.0, 0.0, 0.0);
# Line 139 | 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 201 | Line 195 | int  mod;
195                          error(USER, errmsg);
196                  }
197                  ******/
198 <                if ((*ofun[m->otype].funp)(m, r))
199 <                        objerror(r->ro, USER, "conflicting materials");
198 >                if ((*ofun[m->otype].funp)(m, r)) {
199 >                        sprintf(errmsg, "conflicting material \"%s\"",
200 >                                        m->oname);
201 >                        objerror(r->ro, USER, errmsg);
202 >                }
203          }
204          depth--;                        /* end here */
205   }
# Line 263 | Line 260 | double  coef;
260  
261  
262   double
263 + raydist(r, flags)               /* compute (cumulative) ray distance */
264 + register RAY  *r;
265 + register int  flags;
266 + {
267 +        double  sum = 0.0;
268 +
269 +        while (r != NULL && r->crtype&flags) {
270 +                sum += r->rot;
271 +                r = r->parent;
272 +        }
273 +        return(sum);
274 + }
275 +
276 +
277 + double
278   raynormal(norm, r)              /* compute perturbed normal for ray */
279   FVECT  norm;
280   register RAY  *r;
# Line 367 | Line 379 | register CUBE  *scene;
379          }
380          if (sflags == 0)
381                  error(CONSISTENCY, "zero ray direction in localhit");
382 +                                        /* start off assuming nothing hit */
383 +        if (r->rmax > FTINY) {          /* except aft plane if one */
384 +                r->ro = &Aftplane;
385 +                r->rot = r->rmax;
386 +                for (i = 0; i < 3; i++)
387 +                        r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
388 +        }
389 +                                        /* find global cube entrance point */
390          t = 0.0;
391          if (!incube(scene, curpos)) {
392                                          /* find distance to entry */
# Line 384 | Line 404 | register CUBE  *scene;
404                                  t = dt; /* farthest face is the one */
405                  }
406                  t += FTINY;             /* fudge to get inside cube */
407 +                if (t >= r->rot)        /* clipped already */
408 +                        return(0);
409                                          /* advance position */
410                  for (i = 0; i < 3; i++)
411                          curpos[i] += r->rdir[i]*t;
# Line 392 | Line 414 | register CUBE  *scene;
414                          return(0);
415          }
416          cxset[0] = 0;
417 <        return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT &&
418 <                        r->ro != &Aftplane);
417 >        raymove(curpos, cxset, sflags, r, scene);
418 >        return(r->ro != NULL & r->ro != &Aftplane);
419   }
420  
421  
# Line 448 | Line 470 | register CUBE  *cu;
470                  }
471                  /*NOTREACHED*/
472          }
473 <        if (isfull(cu->cutree) && checkhit(r, cu, cxs))
473 >        if (isfull(cu->cutree)) {
474 >                if (checkhit(r, cu, cxs))
475 >                        return(RAYHIT);
476 >        } else if (r->ro == &Aftplane && incube(cu, r->rop))
477                  return(RAYHIT);
478                                          /* advance to next cube */
479          if (dirf&0x11) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines