--- ray/src/ot/oconv.c 2003/02/22 02:07:26 2.12 +++ ray/src/ot/oconv.c 2003/06/21 15:05:01 2.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: oconv.c,v 2.12 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: oconv.c,v 2.17 2003/06/21 15:05:01 greg Exp $"; #endif /* * oconv.c - main program for object to octree conversion. @@ -8,13 +8,10 @@ static const char RCSid[] = "$Id: oconv.c,v 2.12 2003/ */ #include "standard.h" - +#include "platform.h" #include "octree.h" - #include "object.h" - #include "otypes.h" - #include "paths.h" #define OMARGIN (10*FTINY) /* margin around global cube */ @@ -25,9 +22,9 @@ char *progname; /* argv[0] */ int nowarn = 0; /* supress warnings? */ -int objlim = 5; /* # of objects before split */ +int objlim = 6; /* # of objects before split */ -int resolu = 8192; /* octree resolution limit */ +int resolu = 16384; /* octree resolution limit */ CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ @@ -85,9 +82,7 @@ char *argv[]; break; } breakopt: -#ifdef MSDOS - setmode(fileno(stdout), O_BINARY); -#endif + SET_FILE_BINARY(stdout); if (infile != NULL) { /* get old octree & objects */ if (thescene.cusize > FTINY) error(USER, "only one of '-b' or '-i'"); @@ -196,6 +191,11 @@ register char *s; inln = 0; } + /* conflicting def's in param.h */ +#undef tstbit +#undef setbit +#undef clrbit +#undef tglbit #define bitop(f,i,op) (f[((i)>>3)] op (1<<((i)&7))) #define tstbit(f,i) bitop(f,i,&) @@ -208,20 +208,16 @@ addobject(cu, obj) /* add an object to a cube */ register CUBE *cu; OBJECT obj; { - CUBE cukid; - OCTREE ot; - OBJECT oset[MAXSET+1]; - unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; - int in; - register int i, j; + int inc; - in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); + inc = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); - if (in == O_MISS) + if (inc == O_MISS) return; /* no intersection */ if (istree(cu->cutree)) { - /* do children */ + CUBE cukid; /* do children */ + int i, j; cukid.cusize = cu->cusize * 0.5; for (i = 0; i < 8; i++) { cukid.cutree = octkid(cu->cutree, i); @@ -236,16 +232,31 @@ OBJECT obj; return; } if (isempty(cu->cutree)) { - /* singular set */ + OBJECT oset[2]; /* singular set */ oset[0] = 1; oset[1] = obj; cu->cutree = fullnode(oset); return; } /* add to full node */ + add2full(cu, obj, inc); +} + + +add2full(cu, obj, inc) /* add object to full node */ +register CUBE *cu; +OBJECT obj; +int inc; +{ + OCTREE ot; + OBJECT oset[MAXSET+1]; + CUBE cukid; + unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; + register int i, j; + objset(oset, cu->cutree); cukid.cusize = cu->cusize * 0.5; - if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { + if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { /* add to set */ if (oset[0] >= MAXSET) { sprintf(errmsg, "set overflow in addobject (%s)",