| 54 |
|
/* get face arguments */ |
| 55 |
|
f = getface(o); |
| 56 |
|
if (f->area == 0.0) /* empty face */ |
| 57 |
< |
return(0); |
| 57 |
> |
return(O_MISS); |
| 58 |
|
/* compute cube boundaries */ |
| 59 |
|
for (j = 0; j < 3; j++) |
| 60 |
< |
cumax[j] = (cumin[j] = cu->cuorg[j]) + cu->cusize; |
| 60 |
> |
cumax[j] = (cumin[j] = cu->cuorg[j]-FTINY) |
| 61 |
> |
+ cu->cusize + 2.0*FTINY; |
| 62 |
|
|
| 63 |
|
vloc = ABOVE | BELOW; /* check vertices */ |
| 64 |
|
for (i = 0; i < f->nv; i++) |
| 65 |
|
if (j = plocate(VERTEX(f,i), cumin, cumax)) |
| 66 |
|
vloc &= j; |
| 67 |
|
else |
| 68 |
< |
return(1); /* vertex inside */ |
| 68 |
> |
return(O_HIT); /* vertex inside */ |
| 69 |
|
|
| 70 |
|
if (vloc) /* all to one side */ |
| 71 |
< |
return(0); |
| 71 |
> |
return(O_MISS); |
| 72 |
|
|
| 73 |
|
for (i = 0; i < f->nv; i++) { /* check edges */ |
| 74 |
|
if ((j = i + 1) >= f->nv) |
| 76 |
|
VCOPY(v1, VERTEX(f,i)); /* clip modifies */ |
| 77 |
|
VCOPY(v2, VERTEX(f,j)); /* the vertices! */ |
| 78 |
|
if (clip(v1, v2, cumin, cumax)) |
| 79 |
< |
return(1); /* edge inside */ |
| 79 |
> |
return(O_HIT); /* edge inside */ |
| 80 |
|
} |
| 81 |
|
/* see if cube cuts plane */ |
| 82 |
|
for (j = 0; j < 3; j++) |
| 88 |
|
v2[j] = cumin[j]; |
| 89 |
|
} |
| 90 |
|
if ((d1 = DOT(v1, f->norm) - f->offset) > FTINY) |
| 91 |
< |
return(0); |
| 91 |
> |
return(O_MISS); |
| 92 |
|
if ((d2 = DOT(v2, f->norm) - f->offset) < -FTINY) |
| 93 |
< |
return(0); |
| 93 |
> |
return(O_MISS); |
| 94 |
|
/* intersect face */ |
| 95 |
|
for (j = 0; j < 3; j++) |
| 96 |
|
v1[j] = (v1[j]*d2 - v2[j]*d1)/(d2 - d1); |
| 97 |
|
if (inface(v1, f)) |
| 98 |
< |
return(1); |
| 98 |
> |
return(O_HIT); |
| 99 |
|
|
| 100 |
< |
return(0); /* no intersection */ |
| 100 |
> |
return(O_MISS); /* no intersection */ |
| 101 |
|
} |