1 |
– |
/* Copyright (c) 1988 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. |
6 |
|
* |
11 |
|
|
12 |
|
#include "object.h" |
13 |
|
|
14 |
+ |
#include "octree.h" |
15 |
+ |
|
16 |
|
#include "instance.h" |
17 |
|
|
18 |
|
#include "plocate.h" |
52 |
|
int vloc, vout; |
53 |
|
register int i, j; |
54 |
|
/* get octree arguments */ |
55 |
< |
in = getinstance(o, GET_BOUNDS); |
55 |
> |
in = getinstance(o, IO_BOUNDS); |
56 |
|
/* check if cube vertex in octree */ |
57 |
|
for (j = 0; j < 3; j++) |
58 |
|
cumax[j] = (cumin[j] = in->obj->scube.cuorg[j]) + |
65 |
|
if (i & 1<<j) |
66 |
|
v1[j] += cu->cusize; |
67 |
|
} |
68 |
< |
multp3(v2, v1, in->b.xfm); |
68 |
> |
multp3(v2, v1, in->x.b.xfm); |
69 |
|
if (j = plocate(v2, cumin, cumax)) |
70 |
|
vout++; |
71 |
|
vloc &= j; |
72 |
|
} |
73 |
|
if (vout == 0) /* all inside */ |
74 |
< |
return(2); |
74 |
> |
return(O_IN); |
75 |
|
if (vout < 8) /* some inside */ |
76 |
< |
return(1); |
76 |
> |
return(O_HIT); |
77 |
|
if (vloc) /* all to one side */ |
78 |
< |
return(0); |
78 |
> |
return(O_MISS); |
79 |
|
/* octree vertices in cube? */ |
80 |
|
for (j = 0; j < 3; j++) |
81 |
|
cumax[j] = (cumin[j] = cu->cuorg[j]) + cu->cusize; |
86 |
|
if (i & 1<<j) |
87 |
|
v1[j] += in->obj->scube.cusize; |
88 |
|
} |
89 |
< |
multp3(vert[i], v1, in->f.xfm); |
89 |
> |
multp3(vert[i], v1, in->x.f.xfm); |
90 |
|
if (j = plocate(vert[i], cumin, cumax)) |
91 |
|
vloc &= j; |
92 |
|
else |
93 |
< |
return(1); /* vertex inside */ |
93 |
> |
return(O_HIT); /* vertex inside */ |
94 |
|
} |
95 |
|
if (vloc) /* all to one side */ |
96 |
< |
return(0); |
96 |
> |
return(O_MISS); |
97 |
|
/* check edges */ |
98 |
|
for (i = 0; i < 4; i++) |
99 |
|
for (j = 0; j < 3; j++) { |
101 |
|
VCOPY(v1, vert[vstart[i]]); |
102 |
|
VCOPY(v2, vert[vstart[i] ^ 1<<j]); |
103 |
|
if (clip(v1, v2, cumin, cumax)) |
104 |
< |
return(1); /* edge inside */ |
104 |
> |
return(O_HIT); /* edge inside */ |
105 |
|
} |
106 |
|
|
107 |
< |
return(0); /* no intersection */ |
107 |
> |
return(O_MISS); /* no intersection */ |
108 |
|
} |