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

Comparing ray/src/rt/o_cone.c (file contents):
Revision 2.7 by greg, Mon Oct 25 22:57:45 2010 UTC vs.
Revision 2.10 by greg, Sun Jan 31 18:08:04 2021 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include  "cone.h"
14  
15  
16 < extern int
16 > int
17   o_cone(                 /* intersect ray with cone */
18          OBJREC  *o,
19 <        register RAY  *r
19 >        RAY  *r
20   )
21   {
22          FVECT  rox, rdx;
23          double  a, b, c;
24          double  root[2];
25          int  nroots, rn;
26 <        register CONE  *co;
27 <        register int  i;
26 >        CONE  *co;
27 >        int  i;
28  
29                                                  /* get cone structure */
30          co = getcone(o, 1);
31 +        if (co == NULL)
32 +                objerror(o, INTERNAL, "unexpected illegal");
33  
34          /*
35           *     To intersect a ray with a cone, we transform the
# Line 68 | Line 70 | o_cone(                        /* intersect ray with cone */
70  
71          } else { /* OBJ_RING */
72  
73 <                if (rdx[2] <= FTINY && rdx[2] >= -FTINY)
73 >                if ((rdx[2] <= FTINY) & (rdx[2] >= -FTINY))
74                          return(0);                      /* parallel */
75                  root[0] = -rox[2]/rdx[2];
76 <                if (root[0] <= FTINY || root[0] >= r->rot)
77 <                        return(0);                      /* distance check */
76 >                if (rayreject(o, r, root[0]))
77 >                        return(0);                      /* have better */
78                  b = root[0]*rdx[0] + rox[0];
79                  c = root[0]*rdx[1] + rox[1];
80                  a = b*b + c*c;
# Line 92 | Line 94 | o_cone(                        /* intersect ray with cone */
94          for (rn = 0; rn < nroots; rn++) {       /* check real roots */
95                  if (root[rn] <= FTINY)
96                          continue;               /* too small */
97 <                if (root[rn] >= r->rot)
97 >                if (root[rn] > r->rot + FTINY)
98                          break;                  /* too big */
99                                                  /* check endpoints */
100                  VSUM(rox, r->rorg, r->rdir, root[rn]);
# Line 102 | Line 104 | o_cone(                        /* intersect ray with cone */
104                          continue;               /* before p0 */
105                  if (b > co->al)
106                          continue;               /* after p1 */
107 +                if (rayreject(o, r, root[rn]))
108 +                        break;                  /* previous hit better */
109                  r->ro = o;
110                  r->rot = root[rn];
111                  VCOPY(r->rop, rox);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines