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.6 by greg, Wed Nov 21 18:51:04 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines