--- ray/src/ot/oconv.c 1994/03/28 11:13:58 2.8 +++ ray/src/ot/oconv.c 2003/03/12 04:59:04 2.13 @@ -1,9 +1,6 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: oconv.c,v 2.13 2003/03/12 04:59:04 greg Exp $"; #endif - /* * oconv.c - main program for object to octree conversion. * @@ -22,17 +19,15 @@ static char SCCSid[] = "$SunId$ LBL"; #define OMARGIN (10*FTINY) /* margin around global cube */ -#define MAXOBJFIL 63 /* maximum number of scene files */ +#define MAXOBJFIL 127 /* maximum number of scene files */ char *progname; /* argv[0] */ -char *libpath; /* library search path */ - int nowarn = 0; /* supress warnings? */ int objlim = 5; /* # of objects before split */ -int resolu = 1024; /* octree resolution limit */ +int resolu = 8192; /* octree resolution limit */ CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ @@ -41,14 +36,13 @@ int nfiles = 0; /* number of object files */ double mincusize; /* minimum cube size from resolu */ -int (*addobjnotify[])() = {NULL}; /* new object notifier functions */ +void (*addobjnotify[])() = {NULL}; /* new object notifier functions */ main(argc, argv) /* convert object files to an octree */ int argc; -char **argv; +char *argv[]; { - extern char *getenv(); FVECT bbmin, bbmax; char *infile = NULL; int inpfrozen = 0; @@ -58,15 +52,11 @@ char **argv; progname = argv[0] = fixargv0(argv[0]); - if ((libpath = getenv(ULIBVAR)) == NULL) - libpath = DEFPATH; - initotypes(); for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { case '\0': /* scene from stdin */ - outflags &= ~IO_FILES; goto breakopt; case 'i': /* input octree */ infile = argv[++i]; @@ -167,6 +157,7 @@ breakopt: } +void quit(code) /* exit program */ int code; { @@ -174,12 +165,14 @@ int code; } +void cputs() /* interactive error */ { /* referenced, but not used */ } +void wputs(s) /* warning message */ char *s; { @@ -188,6 +181,7 @@ char *s; } +void eputs(s) /* put string to stderr */ register char *s; { @@ -214,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); @@ -242,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)",