| 1 |
– |
/* Copyright (c) 1987 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 |
|
* bbox.c - routines for bounding box computation. |
| 9 |
– |
* |
| 10 |
– |
* 8/4/87 |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "copyright.h" |
| 9 |
+ |
|
| 10 |
|
#include "standard.h" |
| 11 |
|
|
| 12 |
|
#include "object.h" |
| 13 |
|
|
| 14 |
+ |
#include "octree.h" |
| 15 |
+ |
|
| 16 |
|
#include "otypes.h" |
| 17 |
|
|
| 18 |
|
#include "face.h" |
| 21 |
|
|
| 22 |
|
#include "instance.h" |
| 23 |
|
|
| 24 |
+ |
#include "mesh.h" |
| 25 |
|
|
| 26 |
+ |
|
| 27 |
|
add2bbox(o, bbmin, bbmax) /* expand bounding box to fit object */ |
| 28 |
|
register OBJREC *o; |
| 29 |
|
FVECT bbmin, bbmax; |
| 30 |
|
{ |
| 31 |
< |
#define co ((CONE *)osp) |
| 32 |
< |
#define fo ((FACE *)osp) |
| 33 |
< |
#define io ((INSTANCE *)osp) |
| 34 |
< |
register char *osp; |
| 31 |
> |
CONE *co; |
| 32 |
> |
FACE *fo; |
| 33 |
> |
INSTANCE *io; |
| 34 |
> |
MESHINST *mi; |
| 35 |
|
FVECT v; |
| 36 |
|
register int i, j; |
| 37 |
|
|
| 65 |
|
circle2bbox(CO_P1(co), co->ad, CO_R1(co), bbmin, bbmax); |
| 66 |
|
break; |
| 67 |
|
case OBJ_INSTANCE: |
| 68 |
< |
io = getinstance(o, GET_BOUNDS); |
| 68 |
> |
io = getinstance(o, IO_BOUNDS); |
| 69 |
|
for (j = 0; j < 8; j++) { |
| 70 |
|
for (i = 0; i < 3; i++) { |
| 71 |
|
v[i] = io->obj->scube.cuorg[i]; |
| 72 |
|
if (j & 1<<i) |
| 73 |
|
v[i] += io->obj->scube.cusize; |
| 74 |
|
} |
| 75 |
< |
multp3(v, v, io->f.xfm); |
| 75 |
> |
multp3(v, v, io->x.f.xfm); |
| 76 |
|
point2bbox(v, bbmin, bbmax); |
| 77 |
|
} |
| 78 |
|
break; |
| 79 |
+ |
case OBJ_MESH: |
| 80 |
+ |
mi = getmeshinst(o, IO_BOUNDS); |
| 81 |
+ |
for (j = 0; j < 8; j++) { |
| 82 |
+ |
for (i = 0; i < 3; i++) { |
| 83 |
+ |
v[i] = mi->msh->mcube.cuorg[i]; |
| 84 |
+ |
if (j & 1<<i) |
| 85 |
+ |
v[i] += mi->msh->mcube.cusize; |
| 86 |
+ |
} |
| 87 |
+ |
multp3(v, v, mi->x.f.xfm); |
| 88 |
+ |
point2bbox(v, bbmin, bbmax); |
| 89 |
+ |
} |
| 90 |
+ |
break; |
| 91 |
|
} |
| 79 |
– |
#undef co |
| 80 |
– |
#undef fo |
| 81 |
– |
#undef io |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
|