| 1 |
|
#ifndef lint |
| 2 |
< |
static const char RCSid[] = "$Id$"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 4 |
|
/* |
| 5 |
|
* oconv.c - main program for object to octree conversion. |
| 25 |
|
|
| 26 |
|
int nowarn = 0; /* supress warnings? */ |
| 27 |
|
|
| 28 |
< |
int objlim = 5; /* # of objects before split */ |
| 28 |
> |
int objlim = 6; /* # of objects before split */ |
| 29 |
|
|
| 30 |
< |
int resolu = 8192; /* octree resolution limit */ |
| 30 |
> |
int resolu = 16384; /* octree resolution limit */ |
| 31 |
|
|
| 32 |
|
CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ |
| 33 |
|
|
| 85 |
|
break; |
| 86 |
|
} |
| 87 |
|
breakopt: |
| 88 |
< |
#ifdef MSDOS |
| 89 |
< |
setmode(fileno(stdout), O_BINARY); |
| 90 |
< |
#endif |
| 88 |
> |
SET_FILE_BINARY(stdout); |
| 89 |
|
if (infile != NULL) { /* get old octree & objects */ |
| 90 |
|
if (thescene.cusize > FTINY) |
| 91 |
|
error(USER, "only one of '-b' or '-i'"); |
| 206 |
|
register CUBE *cu; |
| 207 |
|
OBJECT obj; |
| 208 |
|
{ |
| 209 |
< |
CUBE cukid; |
| 212 |
< |
OCTREE ot; |
| 213 |
< |
OBJECT oset[MAXSET+1]; |
| 214 |
< |
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
| 215 |
< |
int in; |
| 216 |
< |
register int i, j; |
| 209 |
> |
int inc; |
| 210 |
|
|
| 211 |
< |
in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); |
| 211 |
> |
inc = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); |
| 212 |
|
|
| 213 |
< |
if (in == O_MISS) |
| 213 |
> |
if (inc == O_MISS) |
| 214 |
|
return; /* no intersection */ |
| 215 |
|
|
| 216 |
|
if (istree(cu->cutree)) { |
| 217 |
< |
/* do children */ |
| 217 |
> |
CUBE cukid; /* do children */ |
| 218 |
> |
int i, j; |
| 219 |
|
cukid.cusize = cu->cusize * 0.5; |
| 220 |
|
for (i = 0; i < 8; i++) { |
| 221 |
|
cukid.cutree = octkid(cu->cutree, i); |
| 230 |
|
return; |
| 231 |
|
} |
| 232 |
|
if (isempty(cu->cutree)) { |
| 233 |
< |
/* singular set */ |
| 233 |
> |
OBJECT oset[2]; /* singular set */ |
| 234 |
|
oset[0] = 1; oset[1] = obj; |
| 235 |
|
cu->cutree = fullnode(oset); |
| 236 |
|
return; |
| 237 |
|
} |
| 238 |
|
/* add to full node */ |
| 239 |
+ |
add2full(cu, obj, inc); |
| 240 |
+ |
} |
| 241 |
+ |
|
| 242 |
+ |
|
| 243 |
+ |
add2full(cu, obj, inc) /* add object to full node */ |
| 244 |
+ |
register CUBE *cu; |
| 245 |
+ |
OBJECT obj; |
| 246 |
+ |
int inc; |
| 247 |
+ |
{ |
| 248 |
+ |
OCTREE ot; |
| 249 |
+ |
OBJECT oset[MAXSET+1]; |
| 250 |
+ |
CUBE cukid; |
| 251 |
+ |
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
| 252 |
+ |
register int i, j; |
| 253 |
+ |
|
| 254 |
|
objset(oset, cu->cutree); |
| 255 |
|
cukid.cusize = cu->cusize * 0.5; |
| 256 |
|
|
| 257 |
< |
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 257 |
> |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 258 |
|
/* add to set */ |
| 259 |
|
if (oset[0] >= MAXSET) { |
| 260 |
|
sprintf(errmsg, "set overflow in addobject (%s)", |