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

Comparing ray/src/ot/o_instance.c (file contents):
Revision 2.2 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 2.3 by greg, Tue Mar 11 17:08:55 2003 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5 < *  o_instance.c - routines for creating octrees for other octrees.
6 < *
7 < *     11/11/88
5 > *  o_instance.c - routines for creating octrees for other octrees
6   */
7  
8   #include  "standard.h"
# Line 15 | Line 13 | static const char      RCSid[] = "$Id$";
13  
14   #include  "instance.h"
15  
16 + #include  "mesh.h"
17 +
18   #include  "plocate.h"
19  
20   /*
# Line 40 | Line 40 | static const char      RCSid[] = "$Id$";
40   */
41  
42  
43 < o_instance(o, cu)                       /* determine if cubes intersect */
44 < OBJREC  *o;
43 > static int
44 > o_cube(cu1, fxf, cu)                    /* determine if cubes intersect */
45 > CUBE  *cu1;
46 > FULLXF  *fxf;
47   CUBE  *cu;
48   {
49          static int  vstart[4] = {0, 3, 5, 6};
50          FVECT  cumin, cumax;
51          FVECT  vert[8];
52          FVECT  v1, v2;
51        register INSTANCE  *in;
53          int  vloc, vout;
54          register int  i, j;
54                                        /* get octree arguments */
55        in = getinstance(o, IO_BOUNDS);
55                                          /* check if cube vertex in octree */
56          for (j = 0; j < 3; j++)
57 <                cumax[j] = (cumin[j] = in->obj->scube.cuorg[j]) +
59 <                                in->obj->scube.cusize;
57 >                cumax[j] = (cumin[j] = cu1->cuorg[j]) + cu1->cusize;
58          vloc = ABOVE | BELOW;
59          vout = 0;
60          for (i = 0; i < 8; i++) {
# Line 65 | Line 63 | CUBE  *cu;
63                          if (i & 1<<j)
64                                  v1[j] += cu->cusize;
65                  }
66 <                multp3(v2, v1, in->x.b.xfm);
66 >                multp3(v2, v1, fxf->b.xfm);
67                  if (j = plocate(v2, cumin, cumax))
68                          vout++;
69                  vloc &= j;
# Line 82 | Line 80 | CUBE  *cu;
80          vloc = ABOVE | BELOW;
81          for (i = 0; i < 8; i++) {
82                  for (j = 0; j < 3; j++) {
83 <                        v1[j] = in->obj->scube.cuorg[j];
83 >                        v1[j] = cu1->cuorg[j];
84                          if (i & 1<<j)
85 <                                v1[j] += in->obj->scube.cusize;
85 >                                v1[j] += cu1->cusize;
86                  }
87 <                multp3(vert[i], v1, in->x.f.xfm);
87 >                multp3(vert[i], v1, fxf->f.xfm);
88                  if (j = plocate(vert[i], cumin, cumax))
89                          vloc &= j;
90                  else
# Line 105 | Line 103 | CUBE  *cu;
103                  }
104  
105          return(O_MISS);                 /* no intersection */
106 + }
107 +
108 +
109 + int
110 + o_instance(o, cu)                       /* determine if instance intersects */
111 + OBJREC  *o;
112 + CUBE  *cu;
113 + {
114 +        INSTANCE  *ins;
115 +                                        /* get octree bounds */
116 +        ins = getinstance(o, IO_BOUNDS);
117 +                                        /* call o_cube to do the work */
118 +        return(o_cube(&ins->obj->scube, &ins->x, cu));
119 + }
120 +
121 +
122 + int
123 + o_mesh(o, cu)                           /* determine if mesh intersects */
124 + OBJREC  *o;
125 + CUBE  *cu;
126 + {
127 +        MESHINST        *mip;
128 +                                        /* get mesh bounds */
129 +        mip = getmeshinst(o, IO_BOUNDS);
130 +                                        /* call o_cube to do the work */
131 +        return(o_cube(&mip->msh->mcube, &mip->x, cu));
132   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines