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 1.7 by greg, Sat Jan 5 09:41:26 1991 UTC vs.
Revision 2.4 by schorsch, Sun Jul 27 22:12:03 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 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_instance.c - routines for creating octrees for other octrees.
9 < *
10 < *     11/11/88
5 > *  o_instance.c - routines for creating octrees for other octrees
6   */
7  
8   #include  "standard.h"
9  
10   #include  "object.h"
11  
12 + #include  "octree.h"
13 +
14   #include  "instance.h"
15  
16 + #include  "mesh.h"
17 +
18   #include  "plocate.h"
19  
20   /*
# Line 41 | Line 40 | static char SCCSid[] = "$SunId$ LBL";
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;
52        register INSTANCE  *in;
53          int  vloc, vout;
54          register int  i, j;
55                                        /* get octree arguments */
56        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]) +
60 <                                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 66 | Line 63 | CUBE  *cu;
63                          if (i & 1<<j)
64                                  v1[j] += cu->cusize;
65                  }
66 <                multp3(v2, v1, in->x.b.xfm);
67 <                if (j = plocate(v2, cumin, cumax))
66 >                multp3(v2, v1, fxf->b.xfm);
67 >                if ( (j = plocate(v2, cumin, cumax)) )
68                          vout++;
69                  vloc &= j;
70          }
# Line 83 | 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);
88 <                if (j = plocate(vert[i], cumin, cumax))
87 >                multp3(vert[i], v1, fxf->f.xfm);
88 >                if ( (j = plocate(vert[i], cumin, cumax)) )
89                          vloc &= j;
90                  else
91                          return(O_HIT);  /* vertex inside */
# Line 106 | 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