ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/preload.c
(Generate patch)

Comparing ray/src/rt/preload.c (file contents):
Revision 2.3 by greg, Thu Jan 21 17:01:26 1993 UTC vs.
Revision 2.10 by greg, Fri Feb 18 00:40:25 2011 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1993 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Preload associated object structures to maximize memory sharing.
6 + *
7 + *  External symbols declared in ray.h
8   */
9  
10 < #include "standard.h"
11 < #include "object.h"
10 > #include "copyright.h"
11 >
12 > #include "ray.h"
13   #include "otypes.h"
14   #include "face.h"
15   #include "cone.h"
16   #include "instance.h"
17 + #include "mesh.h"
18 + #include "data.h"
19 + #include "func.h"
20 + #include "bsdf.h"
21 + #include "paths.h"
22  
23  
24 < int
25 < load_os(op)                     /* load associated data for object */
26 < register OBJREC *op;
24 > /* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */
25 >
26 >
27 > extern int
28 > load_os(                        /* load associated data for object */
29 >        register OBJREC *op
30 > )
31   {
32 +        DATARRAY  *dp;
33 +        SDData  *sd;
34 +
35          switch (op->otype) {
36          case OBJ_FACE:          /* polygon */
37                  getface(op);
# Line 34 | Line 46 | register OBJREC        *op;
46          case OBJ_INSTANCE:      /* octree instance */
47                  getinstance(op, IO_ALL);
48                  return(1);
49 +        case OBJ_MESH:          /* mesh instance */
50 +                getmeshinst(op, IO_ALL);
51 +                return(1);
52 +        case PAT_CPICT:         /* color picture */
53 +                if (op->oargs.nsargs < 4)
54 +                        goto sargerr;
55 +                getpict(op->oargs.sarg[3]);
56 +                getfunc(op, 4, 0x3<<5, 0);
57 +                return(1);
58 +        case PAT_CDATA:         /* color data */
59 +                dp = getdata(op->oargs.sarg[3]);
60 +                getdata(op->oargs.sarg[4]);
61 +                getdata(op->oargs.sarg[5]);
62 +                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 0);
63 +                return(1);
64 +        case PAT_BDATA:         /* brightness data */
65 +                if (op->oargs.nsargs < 2)
66 +                        goto sargerr;
67 +                dp = getdata(op->oargs.sarg[1]);
68 +                getfunc(op, 2, ((1<<dp->nd)-1)<<3, 0);
69 +                return(1);
70 +        case PAT_BFUNC:         /* brightness function */
71 +                getfunc(op, 1, 0x1, 0);
72 +                return(1);
73 +        case PAT_CFUNC:         /* color function */
74 +                getfunc(op, 3, 0x7, 0);
75 +                return(1);
76 +        case TEX_DATA:          /* texture data */
77 +                if (op->oargs.nsargs < 6)
78 +                        goto sargerr;
79 +                dp = getdata(op->oargs.sarg[3]);
80 +                getdata(op->oargs.sarg[4]);
81 +                getdata(op->oargs.sarg[5]);
82 +                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 1);
83 +                return(1);
84 +        case TEX_FUNC:          /* texture function */
85 +                getfunc(op, 3, 0x7, 1);
86 +                return(1);
87 +        case MIX_DATA:          /* mixture data */
88 +                dp = getdata(op->oargs.sarg[3]);
89 +                getfunc(op, 4, ((1<<dp->nd)-1)<<5, 0);
90 +                return(1);
91 +        case MIX_PICT:          /* mixture picture */
92 +                getpict(op->oargs.sarg[3]);
93 +                getfunc(op, 4, 0x3<<5, 0);
94 +                return(1);
95 +        case MIX_FUNC:          /* mixture function */
96 +                getfunc(op, 3, 0x4, 0);
97 +                return(1);
98 +        case MAT_PLASTIC2:      /* anisotropic plastic */
99 +        case MAT_METAL2:        /* anisotropic metal */
100 +                getfunc(op, 3, 0x7, 1);
101 +                return(1);
102 +        case MAT_BRTDF:         /* BRDTfunc material */
103 +                getfunc(op, 9, 0x3f, 0);
104 +                return(1);
105 +        case MAT_BSDF:          /* BSDF material */
106 +                if (op->oargs.nsargs < 6)
107 +                        goto sargerr;
108 +                getfunc(op, 5, 0x1d, 1);
109 +                sd = SDgetCache(op->oargs.sarg[1]);
110 +                if (sd != NULL && !SDisLoaded(sd))
111 +                        SDloadFile(sd, getpath(op->oargs.sarg[1],
112 +                                                getrlibpath(), R_OK));
113 +                return(1);
114 +        case MAT_PDATA:         /* plastic BRDF data */
115 +        case MAT_MDATA:         /* metal BRDF data */
116 +        case MAT_TDATA:         /* trans BRDF data */
117 +                if (op->oargs.nsargs < 2)
118 +                        goto sargerr;
119 +                getdata(op->oargs.sarg[1]);
120 +                getfunc(op, 2, 0, 0);
121 +                return(1);
122 +        case MAT_PFUNC:         /* plastic BRDF func */
123 +        case MAT_MFUNC:         /* metal BRDF func */
124 +        case MAT_TFUNC:         /* trans BRDF func */
125 +                getfunc(op, 1, 0, 0);
126 +                return(1);
127 +        case MAT_DIRECT1:       /* prism1 material */
128 +                getfunc(op, 4, 0xf, 1);
129 +                return(1);
130 +        case MAT_DIRECT2:       /* prism2 material */
131 +                getfunc(op, 8, 0xff, 1);
132 +                return(1);
133          }
134 <                        /* don't bother with non-surfaces -- too tricky */
134 >                        /* nothing to load for the remaining types */
135          return(0);
136 + sargerr:
137 +        objerror(op, USER, "too few string arguments");
138 +        return 0; /* pro forma return */
139   }
140  
141  
142 < preload_objs()          /* preload object data structures */
142 > extern void
143 > preload_objs(void)              /* preload object data structures */
144   {
145          register OBJECT on;
146                                  /* note that nobjects may change during loop */
147          for (on = 0; on < nobjects; on++)
148                  load_os(objptr(on));
49 }
50
51
52 clean_slate()           /* reset time and ray counters */
53 {
54        extern long     tstart, time();
55        extern long     raynum, nrays;
56        register OBJECT on;
57
58        tstart = time(0);
59        raynum = nrays = 0;
60        for (on = 0; on < nobjects; on++)
61                objptr(on)->lastrno = -1;
149   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines