--- ray/src/ot/oconv.c 1995/01/06 10:13:04 2.10 +++ ray/src/ot/oconv.c 2003/06/08 12:03:10 2.16 @@ -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.16 2003/06/08 12:03:10 schorsch Exp $"; #endif - /* * oconv.c - main program for object to octree conversion. * @@ -11,26 +8,23 @@ static char SCCSid[] = "$SunId$ LBL"; */ #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 */ -#define MAXOBJFIL 63 /* maximum number of scene files */ +#define MAXOBJFIL 127 /* maximum number of scene files */ 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 = 1024; /* octree resolution limit */ +int resolu = 16384; /* octree resolution limit */ CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ @@ -39,7 +33,7 @@ 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 */ @@ -88,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'"); @@ -160,6 +152,7 @@ breakopt: } +void quit(code) /* exit program */ int code; { @@ -167,12 +160,14 @@ int code; } +void cputs() /* interactive error */ { /* referenced, but not used */ } +void wputs(s) /* warning message */ char *s; { @@ -181,6 +176,7 @@ char *s; } +void eputs(s) /* put string to stderr */ register char *s; { @@ -207,20 +203,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); @@ -235,16 +227,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)",