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 1.1 by greg, Thu Feb 2 10:33:02 1989 UTC vs.
Revision 2.3 by schorsch, Sat Mar 27 12:41:45 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  o_cone.c - routines for intersecting cubes with cones.
6   *
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   */
9  
10   #include  "standard.h"
14
11   #include  "octree.h"
16
12   #include  "object.h"
18
13   #include  "cone.h"
14  
15   #define  ROOT3          1.732050808
# Line 35 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29  
30   extern double  mincusize;               /* minimum cube size */
31  
32 + static double findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p);
33  
34 < o_cone(o, cu)                   /* determine if cone intersects cube */
35 < OBJREC  *o;
36 < register CUBE  *cu;
34 >
35 >
36 > /* XXX o_cone() is extern, but not declared in any header file */
37 > int
38 > o_cone(                 /* determine if cone intersects cube */
39 >        OBJREC  *o,
40 >        register CUBE  *cu
41 > )
42   {
43        double  dist2lseg(), findcseg();
43          CONE  *co;
44          FVECT  ep0, ep1;
45 + #ifdef STRICT
46          FVECT  cumin, cumax;
47          CUBE  cukid;
48 +        register int  j;
49 + #endif
50          double  r;
51          FVECT  p;
52 <        register int  i, j;
52 >        register int  i;
53                                          /* get cone arguments */
54          co = getcone(o, 0);
55                                          /* get cube center */
# Line 59 | Line 61 | register CUBE  *cu;
61          if (findcseg(ep0, ep1, co, p) > 0.0) {
62                                          /* check min. distance to cone */
63                  if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY))
64 <                        return(0);
64 >                        return(O_MISS);
65   #ifdef  STRICT
66                                          /* get cube boundaries */
67                  for (i = 0; i < 3; i++)
68                          cumax[i] = (cumin[i] = cu->cuorg[i]) + cu->cusize;
69                                          /* closest segment intersects? */
70                  if (clip(ep0, ep1, cumin, cumax))
71 <                        return(1);
71 >                        return(O_HIT);
72          }
73                                          /* check sub-cubes */
74          cukid.cusize = cu->cusize * 0.5;
75          if (cukid.cusize < mincusize)
76 <                return(1);              /* cube too small */
76 >                return(O_HIT);          /* cube too small */
77          cukid.cutree = EMPTY;
78  
79          for (j = 0; j < 8; j++) {
# Line 81 | Line 83 | register CUBE  *cu;
83                                  cukid.cuorg[i] += cukid.cusize;
84                  }
85                  if (o_cone(o, &cukid))
86 <                        return(1);      /* sub-cube intersects */
86 >                        return(O_HIT);  /* sub-cube intersects */
87          }
88 <        return(0);                      /* no intersection */
88 >        return(O_MISS);                 /* no intersection */
89   #else
90          }
91 <        return(1);                      /* assume intersection */
91 >        return(O_HIT);                  /* assume intersection */
92   #endif
93   }
94  
95  
96 < double
97 < findcseg(ep0, ep1, co, p)       /* find line segment from cone closest to p */
98 < FVECT  ep0, ep1;
99 < register CONE  *co;
100 < FVECT  p;
96 > static double
97 > findcseg(       /* find line segment from cone closest to p */
98 >        FVECT  ep0,
99 >        FVECT  ep1,
100 >        register CONE  *co,
101 >        FVECT  p
102 > )
103   {
104          double  d;
105          FVECT  v;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines