--- ray/src/rt/preload.c 1993/01/25 15:15:41 2.4 +++ ray/src/rt/preload.c 2013/11/08 17:11:42 2.13 @@ -1,25 +1,35 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: preload.c,v 2.13 2013/11/08 17:11:42 greg Exp $"; #endif - /* * Preload associated object structures to maximize memory sharing. + * + * External symbols declared in ray.h */ -#include "standard.h" -#include "object.h" +#include "copyright.h" + +#include "ray.h" #include "otypes.h" #include "face.h" #include "cone.h" #include "instance.h" +#include "mesh.h" +#include "data.h" +#include "func.h" +#include "bsdf.h" +/* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */ + + int -load_os(op) /* load associated data for object */ -register OBJREC *op; +load_os( /* load associated data for object */ + OBJREC *op +) { + DATARRAY *dp; + switch (op->otype) { case OBJ_FACE: /* polygon */ getface(op); @@ -34,15 +44,100 @@ register OBJREC *op; case OBJ_INSTANCE: /* octree instance */ getinstance(op, IO_ALL); return(1); + case OBJ_MESH: /* mesh instance */ + getmeshinst(op, IO_ALL); + return(1); + case PAT_CPICT: /* color picture */ + if (op->oargs.nsargs < 4) + goto sargerr; + getpict(op->oargs.sarg[3]); + getfunc(op, 4, 0x3<<5, 0); + return(1); + case PAT_CDATA: /* color data */ + dp = getdata(op->oargs.sarg[3]); + getdata(op->oargs.sarg[4]); + getdata(op->oargs.sarg[5]); + getfunc(op, 6, ((1<nd)-1)<<7, 0); + return(1); + case PAT_BDATA: /* brightness data */ + if (op->oargs.nsargs < 2) + goto sargerr; + dp = getdata(op->oargs.sarg[1]); + getfunc(op, 2, ((1<nd)-1)<<3, 0); + return(1); + case PAT_BFUNC: /* brightness function */ + getfunc(op, 1, 0x1, 0); + return(1); + case PAT_CFUNC: /* color function */ + getfunc(op, 3, 0x7, 0); + return(1); + case TEX_DATA: /* texture data */ + if (op->oargs.nsargs < 6) + goto sargerr; + dp = getdata(op->oargs.sarg[3]); + getdata(op->oargs.sarg[4]); + getdata(op->oargs.sarg[5]); + getfunc(op, 6, ((1<nd)-1)<<7, 1); + return(1); + case TEX_FUNC: /* texture function */ + getfunc(op, 3, 0x7, 1); + return(1); + case MIX_DATA: /* mixture data */ + dp = getdata(op->oargs.sarg[3]); + getfunc(op, 4, ((1<nd)-1)<<5, 0); + return(1); + case MIX_PICT: /* mixture picture */ + getpict(op->oargs.sarg[3]); + getfunc(op, 4, 0x3<<5, 0); + return(1); + case MIX_FUNC: /* mixture function */ + getfunc(op, 3, 0x4, 0); + return(1); + case MAT_PLASTIC2: /* anisotropic plastic */ + case MAT_METAL2: /* anisotropic metal */ + getfunc(op, 3, 0x7, 1); + return(1); + case MAT_BRTDF: /* BRDTfunc material */ + getfunc(op, 9, 0x3f, 0); + return(1); + case MAT_BSDF: /* BSDF material */ + if (op->oargs.nsargs < 6) + goto sargerr; + getfunc(op, 5, 0x1d, 1); + loadBSDF(op->oargs.sarg[1]); + return(1); + case MAT_PDATA: /* plastic BRDF data */ + case MAT_MDATA: /* metal BRDF data */ + case MAT_TDATA: /* trans BRDF data */ + if (op->oargs.nsargs < 2) + goto sargerr; + getdata(op->oargs.sarg[1]); + getfunc(op, 2, 0, 0); + return(1); + case MAT_PFUNC: /* plastic BRDF func */ + case MAT_MFUNC: /* metal BRDF func */ + case MAT_TFUNC: /* trans BRDF func */ + getfunc(op, 1, 0, 0); + return(1); + case MAT_DIRECT1: /* prism1 material */ + getfunc(op, 4, 0xf, 1); + return(1); + case MAT_DIRECT2: /* prism2 material */ + getfunc(op, 8, 0xff, 1); + return(1); } - /* don't bother with non-surfaces -- too tricky */ + /* nothing to load for the remaining types */ return(0); +sargerr: + objerror(op, USER, "too few string arguments"); + return 0; /* pro forma return */ } -preload_objs() /* preload object data structures */ +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));