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

Comparing ray/src/ot/o_cone.c (file contents):
Revision 2.4 by schorsch, Tue Mar 30 16:13:00 2004 UTC vs.
Revision 2.5 by greg, Tue Jun 14 17:10:06 2005 UTC

# Line 29 | Line 29 | static const char      RCSid[] = "$Id$";
29  
30   extern double  mincusize;               /* minimum cube size */
31  
32 < static double findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p);
32 > static int findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p);
33  
34  
35  
# Line 57 | Line 57 | o_cone(                /* determine if cone intersects cube */
57                  p[i] = cu->cuorg[i] + r;
58          r *= ROOT3;                     /* bounding radius for cube */
59  
60 <        if (findcseg(ep0, ep1, co, p) > 0.0) {
60 >        if (findcseg(ep0, ep1, co, p)) {
61                                          /* check min. distance to cone */
62                  if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY))
63                          return(O_MISS);
# Line 92 | Line 92 | o_cone(                /* determine if cone intersects cube */
92   }
93  
94  
95 < static double
95 > static int
96   findcseg(       /* find line segment from cone closest to p */
97          FVECT  ep0,
98          FVECT  ep1,
# Line 104 | Line 104 | findcseg(      /* find line segment from cone closest to p
104          FVECT  v;
105          register int  i;
106                                          /* find direction from axis to point */
107 <        for (i = 0; i < 3; i++)
108 <                v[i] = p[i] - CO_P0(co)[i];
107 >        VSUB(v, p, CO_P0(co));
108          d = DOT(v, co->ad);
109          for (i = 0; i < 3; i++)
110 <                v[i] = v[i] - d*co->ad[i];
111 <        d = normalize(v);
112 <        if (d > 0.0)                    /* find endpoints of segment */
113 <                for (i = 0; i < 3; i++) {
114 <                        ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i];
115 <                        ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i];
116 <                }
117 <        return(d);                      /* return distance from axis */
110 >                v[i] -= d*co->ad[i];
111 >        if (normalize(v) == 0.0)
112 >                return(0);
113 >                                        /* find endpoints of segment */
114 >        for (i = 0; i < 3; i++) {
115 >                ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i];
116 >                ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i];
117 >        }
118 >        return(1);                      /* return distance from axis */
119   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines