--- ray/src/common/readoct.c 2003/10/27 10:19:31 2.24 +++ ray/src/common/readoct.c 2019/05/04 00:32:47 2.31 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: readoct.c,v 2.24 2003/10/27 10:19:31 schorsch Exp $"; +static const char RCSid[] = "$Id: readoct.c,v 2.31 2019/05/04 00:32:47 greg Exp $"; #endif /* * readoct.c - routines to read octree information. @@ -11,7 +11,7 @@ static const char RCSid[] = "$Id: readoct.c,v 2.24 200 #include #include "platform.h" -#include "rtprocess.h" +#include "paths.h" #include "standard.h" #include "octree.h" #include "object.h" @@ -21,7 +21,7 @@ static const char RCSid[] = "$Id: readoct.c,v 2.24 200 static double ogetflt(void); static long ogetint(int); static char *ogetstr(char *); -static int nonsurfinset(OBJECT *); +static int nonsurfintree(OCTREE ot); static void octerror(int etyp, char *msg); static void skiptree(void); static OCTREE getfullnode(void), gettree(void); @@ -34,11 +34,12 @@ static OBJECT fnobjects; /* number of objects in thi int -readoct(inpspec, load, scene, ofn) /* read in octree file or stream */ -char *inpspec; -int load; -CUBE *scene; -char *ofn[]; +readoct( /* read in octree file or stream */ + char *inpspec, + int load, + CUBE *scene, + char *ofn[] +) { char sbuf[512]; int nf; @@ -110,22 +111,21 @@ char *ofn[]; if (nobjects != objorig+fnobjects) octerror(USER, "bad object count; octree stale?"); /* check for non-surfaces */ - if (dosets(nonsurfinset)) + if (nonsurfintree(scene->cutree)) octerror(USER, "modifier in tree; octree stale?"); } } /* close the input */ if (infn[0] == '!') pclose(infp); - else + else if (infp != stdin) fclose(infp); return(nf); } static char * -ogetstr(s) /* get null-terminated string */ -char *s; +ogetstr(char *s) /* get null-terminated string */ { extern char *getstr(); @@ -154,8 +154,7 @@ getfullnode() /* get a set, return fullnode */ static long -ogetint(siz) /* get a siz-byte integer */ -int siz; +ogetint(int siz) /* get a siz-byte integer */ { extern long getint(); register long r; @@ -207,15 +206,22 @@ gettree() /* get a pre-ordered octree */ static int -nonsurfinset(os) /* check set for modifier */ -register OBJECT *os; +nonsurfintree(OCTREE ot) /* check tree for modifiers */ { - register OBJECT s; + OBJECT set[MAXSET+1]; register int i; - for (i = *os; i-- > 0; ) - if ((s = *++os) >= objorig && s < objorig+fnobjects && - ismodifier(objptr(s)->otype)) + if (isempty(ot)) + return(0); + if (istree(ot)) { + for (i = 0; i < 8; i++) + if (nonsurfintree(octkid(ot, i))) + return(1); + return(0); + } + objset(set, ot); + for (i = set[0]; i > 0; i-- ) + if (ismodifier(objptr(set[i])->otype)) return(1); return(0); } @@ -247,9 +253,7 @@ skiptree(void) /* skip octree on input */ static void -octerror(etyp, msg) /* octree error */ -int etyp; -char *msg; +octerror(int etyp, char *msg) /* octree error */ { char msgbuf[128];