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.22 by greg, Wed Dec 6 12:07:50 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 61 | Line 61 | double  rw;
61                          r->rlvl++;
62                          r->rsrc = -1;
63                          r->clipset = ro->clipset;
64 +                        r->rmax = 0.0;
65                  } else {
66                          r->rsrc = ro->rsrc;
67                          r->clipset = ro->newcset;
68 +                        r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
69                  }
70                  r->revf = ro->revf;
71                  r->rweight = ro->rweight * rw;
72                  r->crtype = ro->crtype | (r->rtype = rt);
73                  VCOPY(r->rorg, ro->rop);
72                r->rmax = 0.0;
74          }
75          rayclear(r);
76          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
# Line 81 | Line 82 | register RAY  *r;
82   {
83          r->rno = raynum++;
84          r->newcset = r->clipset;
85 <        if (r->rmax > FTINY) {
86 <                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 <        }
85 >        r->ro = NULL;
86 >        r->rot = FHUGE;
87          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
88          setcolor(r->pcol, 1.0, 1.0, 1.0);
89          setcolor(r->rcol, 0.0, 0.0, 0.0);
# Line 201 | Line 194 | int  mod;
194                          error(USER, errmsg);
195                  }
196                  ******/
197 <                if ((*ofun[m->otype].funp)(m, r))
198 <                        objerror(r->ro, USER, "conflicting materials");
197 >                if ((*ofun[m->otype].funp)(m, r)) {
198 >                        sprintf(errmsg, "conflicting material \"%s\"",
199 >                                        m->oname);
200 >                        objerror(r->ro, USER, errmsg);
201 >                }
202          }
203          depth--;                        /* end here */
204   }
# Line 263 | Line 259 | double  coef;
259  
260  
261   double
262 + raydist(r, flags)               /* compute (cumulative) ray distance */
263 + register RAY  *r;
264 + register int  flags;
265 + {
266 +        double  sum = 0.0;
267 +
268 +        while (r != NULL && r->crtype&flags) {
269 +                sum += r->rot;
270 +                r = r->parent;
271 +        }
272 +        return(sum);
273 + }
274 +
275 +
276 + double
277   raynormal(norm, r)              /* compute perturbed normal for ray */
278   FVECT  norm;
279   register RAY  *r;
# Line 367 | Line 378 | register CUBE  *scene;
378          }
379          if (sflags == 0)
380                  error(CONSISTENCY, "zero ray direction in localhit");
381 +                                        /* start off assuming nothing hit */
382 +        if (r->rmax > FTINY) {          /* except aft plane if one */
383 +                r->ro = &Aftplane;
384 +                r->rot = r->rmax;
385 +                for (i = 0; i < 3; i++)
386 +                        r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
387 +        }
388 +                                        /* find global cube entrance point */
389          t = 0.0;
390          if (!incube(scene, curpos)) {
391                                          /* find distance to entry */
# Line 384 | Line 403 | register CUBE  *scene;
403                                  t = dt; /* farthest face is the one */
404                  }
405                  t += FTINY;             /* fudge to get inside cube */
406 +                if (t >= r->rot)        /* clipped already */
407 +                        return(0);
408                                          /* advance position */
409                  for (i = 0; i < 3; i++)
410                          curpos[i] += r->rdir[i]*t;
# Line 392 | Line 413 | register CUBE  *scene;
413                          return(0);
414          }
415          cxset[0] = 0;
416 <        return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT &&
417 <                        r->ro != &Aftplane);
416 >        raymove(curpos, cxset, sflags, r, scene);
417 >        return(r->ro != NULL & r->ro != &Aftplane);
418   }
419  
420  
# Line 448 | Line 469 | register CUBE  *cu;
469                  }
470                  /*NOTREACHED*/
471          }
472 <        if (isfull(cu->cutree) && checkhit(r, cu, cxs))
472 >        if (isfull(cu->cutree)) {
473 >                if (checkhit(r, cu, cxs))
474 >                        return(RAYHIT);
475 >        } else if (r->ro == &Aftplane && incube(cu, r->rop))
476                  return(RAYHIT);
477                                          /* advance to next cube */
478          if (dirf&0x11) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines