--- ray/src/common/rglinst.c 1998/06/09 11:18:35 3.1 +++ ray/src/common/rglinst.c 2003/04/23 02:28:06 3.7 @@ -1,16 +1,17 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rglinst.c,v 3.7 2003/04/23 02:28:06 greg Exp $"; #endif - /* * Routines for reading instances and converting to OpenGL. */ +#include "copyright.h" + #include "radogl.h" #include "octree.h" +#define MAXLEVEL 16 /* maximum instance hierarchy level */ + typedef struct { int listid; /* our list id */ short localmatl; /* uses local material only */ @@ -18,14 +19,12 @@ typedef struct { char octfile[256]; /* octree file path */ } OCTINST; /* octree to instantiate */ -OBJECT nobjects; /* number of objects loaded so far */ - -extern int free(); - static double ogetflt(); static long ogetint(); static char *ogetstr(); -static int loadobj(), octerror(), skiptree(); +static int loadobj(); +static void skiptree(); +static void octerror(); static OCTINST *getoct(); static char *infn; /* input file name */ @@ -33,12 +32,13 @@ static FILE *infp; /* input file stream */ static int objsize; /* size of stored OBJECT's */ static short otypmap[NUMOTYPE+8]; /* object type map */ -static long imhash(mod) char *mod; {return((long)mod);} +static unsigned long imhash(mod) char *mod; {return((unsigned long)mod);} static LUTAB imtab = {imhash,NULL,NULL,NULL,0,NULL,0}; static LUTAB ottab = LU_SINIT(free,free); +int o_instance(o) /* convert instance to list call */ register OBJREC *o; { @@ -67,15 +67,17 @@ register OBJREC *o; } ot = getoct(o->oargs.sarg[0]); /* get octree reference */ if (ot->localmatl &= o->os != NULL) /* set material */ - setmaterial(o->os, ot->cent, 0); + setmaterial((MATREC *)o->os, ot->cent, 0); /* call the assigned list */ glCallList(ot->listid); if (o->oargs.nsargs > 1) { /* end transform */ + glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); } rgl_checkerr("creating instance"); + return(0); } @@ -101,10 +103,13 @@ LUENT *lp; int loadoctrees() /* load octrees we've saved up */ { + int levelsleft = MAXLEVEL; int nocts = 0; LUTAB looptab; /* loop through new octree references */ while (ottab.tsiz) { + if (!levelsleft--) + error(USER, "too many octree levels -- instance loop?"); copystruct(&looptab, &ottab); ottab.tsiz = 0; nocts += lu_doall(&looptab, buildoctlist); @@ -191,6 +196,7 @@ FVECT cent; } +int loadoct(fname) /* read in objects from octree */ char *fname; { @@ -280,7 +286,7 @@ ogetflt() /* get a floating point number */ } -static +static void skiptree() /* skip octree on input */ { register int i; @@ -305,7 +311,7 @@ skiptree() /* skip octree on input */ } -static +static int loadobj() /* get next object */ { static OBJREC ob; @@ -378,7 +384,7 @@ memerr: } -static +static void octerror(etyp, msg) /* octree error */ int etyp; char *msg;