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

Comparing ray/src/ot/bbox.c (file contents):
Revision 2.4 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.7 by greg, Fri Sep 16 15:09:21 2016 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   #include  "copyright.h"
9  
10   #include  "standard.h"
11
11   #include  "object.h"
13
12   #include  "octree.h"
15
13   #include  "otypes.h"
17
14   #include  "face.h"
19
15   #include  "cone.h"
21
16   #include  "instance.h"
23
17   #include  "mesh.h"
18 + #include  "oconv.h"
19  
20  
21 < add2bbox(o, bbmin, bbmax)               /* expand bounding box to fit object */
22 < register OBJREC  *o;
23 < FVECT  bbmin, bbmax;
21 > static void point2bbox(FVECT  p, FVECT  bbmin, FVECT  bbmax);
22 > static void circle2bbox(FVECT  cent, FVECT  norm, double  rad, FVECT  bbmin, FVECT  bbmax);
23 >
24 >
25 > void
26 > add2bbox(               /* expand bounding box to fit object */
27 >        register OBJREC  *o,
28 >        FVECT  bbmin,
29 >        FVECT  bbmax
30 > )
31   {
32          CONE  *co;
33          FACE  *fo;
# Line 60 | Line 61 | FVECT  bbmin, bbmax;
61          case OBJ_TUBE:
62          case OBJ_RING:
63                  co = getcone(o, 0);
64 +                if (co == NULL)
65 +                        break;
66                  if (o->otype != OBJ_RING)
67                          circle2bbox(CO_P0(co), co->ad, CO_R0(co), bbmin, bbmax);
68                  circle2bbox(CO_P1(co), co->ad, CO_R1(co), bbmin, bbmax);
# Line 92 | Line 95 | FVECT  bbmin, bbmax;
95   }
96  
97  
98 < point2bbox(p, bbmin, bbmax)             /* expand bounding box to fit point */
99 < register FVECT  p, bbmin, bbmax;
98 > static void
99 > point2bbox(             /* expand bounding box to fit point */
100 >        register FVECT  p,
101 >        register FVECT  bbmin,
102 >        register FVECT  bbmax
103 > )
104   {
105          register int  i;
106  
# Line 106 | Line 113 | register FVECT  p, bbmin, bbmax;
113   }
114  
115  
116 < circle2bbox(cent, norm, rad, bbmin, bbmax)      /* expand bbox to fit circle */
117 < FVECT  cent, norm;
118 < double  rad;
119 < FVECT  bbmin, bbmax;
116 > static void
117 > circle2bbox(    /* expand bbox to fit circle */
118 >        FVECT  cent,
119 >        FVECT  norm,
120 >        double  rad,
121 >        FVECT  bbmin,
122 >        FVECT  bbmax
123 > )
124   {
125 <        FVECT  v1, v2;
126 <        register int  i, j;
125 >        double  d, r;
126 >        register int  i;
127  
128          for (i = 0; i < 3; i++) {
129 <                v1[0] = v1[1] = v1[2] = 0;
130 <                v1[i] = 1.0;
131 <                fcross(v2, norm, v1);
132 <                if (normalize(v2) == 0.0)
133 <                        continue;
134 <                for (j = 0; j < 3; j++)
135 <                        v1[j] = cent[j] + rad*v2[j];
125 <                point2bbox(v1, bbmin, bbmax);
126 <                for (j = 0; j < 3; j++)
127 <                        v1[j] = cent[j] - rad*v2[j];
128 <                point2bbox(v1, bbmin, bbmax);
129 >                r = sqrt(1. - norm[i]*norm[i]);
130 >                d = cent[i] + r*rad;
131 >                if (d > bbmax[i])
132 >                        bbmax[i] = d;
133 >                d = cent[i] - r*rad;
134 >                if (d < bbmin[i])
135 >                        bbmin[i] = d;
136          }
137   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines