--- ray/src/rt/preload.c 2011/02/18 00:40:25 2.10 +++ ray/src/rt/preload.c 2024/04/04 18:51:18 2.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: preload.c,v 2.10 2011/02/18 00:40:25 greg Exp $"; +static const char RCSid[] = "$Id: preload.c,v 2.17 2024/04/04 18:51:18 greg Exp $"; #endif /* * Preload associated object structures to maximize memory sharing. @@ -18,20 +18,21 @@ static const char RCSid[] = "$Id: preload.c,v 2.10 201 #include "data.h" #include "func.h" #include "bsdf.h" -#include "paths.h" /* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */ -extern int +int load_os( /* load associated data for object */ - register OBJREC *op + OBJREC *op ) { - DATARRAY *dp; - SDData *sd; + DATARRAY *dp; + SDData *sd; + SDretainSet = SDretainAll; + switch (op->otype) { case OBJ_FACE: /* polygon */ getface(op); @@ -56,6 +57,8 @@ load_os( /* load associated data for object */ getfunc(op, 4, 0x3<<5, 0); return(1); case PAT_CDATA: /* color data */ + if (op->oargs.nsargs < 4) + goto sargerr; dp = getdata(op->oargs.sarg[3]); getdata(op->oargs.sarg[4]); getdata(op->oargs.sarg[5]); @@ -73,6 +76,26 @@ load_os( /* load associated data for object */ case PAT_CFUNC: /* color function */ getfunc(op, 3, 0x7, 0); return(1); + case PAT_SPECFUNC: /* spectral function */ + getfunc(op, 1, 0, 0); + return(1); + case PAT_SPECFILE: /* spectrum file */ + if (op->oargs.nsargs < 1) + goto sargerr; + getdata(op->oargs.sarg[0]); + return(1); + case PAT_SPECDATA: /* spectral data file */ + if (op->oargs.nsargs < 2) + goto sargerr; + dp = getdata(op->oargs.sarg[1]); + getfunc(op, 2, ((1<<(dp->nd-1)) - 1)<<3, 0); + return(1); + case PAT_SPECPICT: /* spectral picture */ + if (op->oargs.nsargs < 2) + goto sargerr; + getspec(op->oargs.sarg[1]); + getfunc(op, 2, 0x3<<3, 0); + return(1); case TEX_DATA: /* texture data */ if (op->oargs.nsargs < 6) goto sargerr; @@ -106,11 +129,16 @@ load_os( /* load associated data for object */ if (op->oargs.nsargs < 6) goto sargerr; getfunc(op, 5, 0x1d, 1); - sd = SDgetCache(op->oargs.sarg[1]); - if (sd != NULL && !SDisLoaded(sd)) - SDloadFile(sd, getpath(op->oargs.sarg[1], - getrlibpath(), R_OK)); + sd = loadBSDF(op->oargs.sarg[1]); + if (sd != NULL) SDfreeCache(sd); return(1); + case MAT_ABSDF: /* aBSDF material */ + if (op->oargs.nsargs < 5) + goto sargerr; + getfunc(op, 4, 0xe, 1); + sd = loadBSDF(op->oargs.sarg[0]); + if (sd != NULL) SDfreeCache(sd); + return(1); case MAT_PDATA: /* plastic BRDF data */ case MAT_MDATA: /* metal BRDF data */ case MAT_TDATA: /* trans BRDF data */ @@ -139,10 +167,10 @@ sargerr: } -extern void +void preload_objs(void) /* preload object data structures */ { - register OBJECT on; + OBJECT on; /* note that nobjects may change during loop */ for (on = 0; on < nobjects; on++) load_os(objptr(on));