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.77 by greg, Fri Feb 22 19:42:27 2019 UTC vs.
Revision 2.84 by greg, Sun Jan 31 20:55:04 2021 UTC

# Line 68 | Line 68 | rayorigin(             /* start new ray from old one */
68                  r->gecc = seccg;
69                  r->slights = NULL;
70          } else {                                /* spawned ray */
71 <                if (ro->rot >= FHUGE) {
71 >                if (ro->rot >= FHUGE*.99) {
72                          memset(r, 0, sizeof(RAY));
73                          return(-1);             /* illegal continuation */
74                  }
# Line 146 | Line 146 | rayclear(                      /* clear a ray for (re)evaluation */
146          r->ro = NULL;
147          r->rox = NULL;
148          r->rxt = r->rmt = r->rot = FHUGE;
149 +        VCOPY(r->rop, r->rorg);
150 +        r->ron[0] = -r->rdir[0]; r->ron[1] = -r->rdir[1]; r->ron[2] = -r->rdir[2];
151 +        r->rod = 1.0;
152          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
153 +        r->rflips = 0;
154          r->uv[0] = r->uv[1] = 0.0;
155          setcolor(r->pcol, 1.0, 1.0, 1.0);
156          setcolor(r->mcol, 0.0, 0.0, 0.0);
# Line 229 | Line 233 | rayshade(              /* shade ray r with material mod */
233          int     tst_irrad = do_irrad && !(r->crtype & ~(PRIMARY|TRANS));
234          OBJREC  *m;
235  
236 <        r->rxt = r->rmt = r->rot;       /* preset effective ray length */
236 >        r->rxt = r->rot;                /* preset effective ray length */
237          for ( ; mod != OVOID; mod = m->omod) {
238                  m = objptr(mod);
239                  /****** unnecessary test since modifier() is always called
# Line 509 | Line 513 | flipsurface(                   /* reverse surface orientation */
513          r->pert[0] = -r->pert[0];
514          r->pert[1] = -r->pert[1];
515          r->pert[2] = -r->pert[2];
516 +        r->rflips++;
517   }
518  
519 +
520 + int
521 + rayreject(              /* check if candidate hit is worse than current */
522 +        OBJREC *o,
523 +        RAY *r,
524 +        double t
525 + )
526 + {
527 +        OBJREC  *mnew, *mray;
528 +
529 +        if ((t <= FTINY) | (t > r->rot + FTINY))
530 +                return(1);
531 +        if (t < r->rot - FTINY)         /* is new hit significantly closer? */
532 +                return(0);
533 +                                        /* coincident point, so decide... */
534 +        if (o == r->ro)
535 +                return(1);              /* shouldn't happen */
536 +        if (r->ro == NULL)
537 +                return(0);              /* ditto */
538 +        if ((mnew = findmaterial(o)) == NULL)
539 +                return(1);              /* new has no material */
540 +        if ((mray = findmaterial(r->ro)) == NULL)
541 +                return(0);              /* old has no material(!) */
542 +        if (istransp(mnew->otype))
543 +                return(1);              /* new is transparent */
544 +        if (istransp(mray->otype))
545 +                return(0);              /* old is transparent */
546 +                        /* weakest priority to later modifier definition */
547 +        return (r->ro->omod >= o->omod);
548 + }
549  
550   void
551   rayhit(                 /* standard ray hit test */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines