ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/preload.c
Revision: 2.7
Committed: Tue Feb 25 02:47:23 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.6: +1 -56 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * Preload associated object structures to maximize memory sharing.
6 *
7 * External symbols declared in ray.h
8 */
9
10 #include "copyright.h"
11
12 #include "standard.h"
13 #include "octree.h"
14 #include "object.h"
15 #include "otypes.h"
16 #include "face.h"
17 #include "cone.h"
18 #include "instance.h"
19 #include "color.h"
20 #include "data.h"
21
22
23 /* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */
24
25
26 int
27 load_os(op) /* load associated data for object */
28 register OBJREC *op;
29 {
30 DATARRAY *dp;
31
32 switch (op->otype) {
33 case OBJ_FACE: /* polygon */
34 getface(op);
35 return(1);
36 case OBJ_CONE: /* cone */
37 case OBJ_RING: /* disk */
38 case OBJ_CYLINDER: /* cylinder */
39 case OBJ_CUP: /* inverted cone */
40 case OBJ_TUBE: /* inverted cylinder */
41 getcone(op, 1);
42 return(1);
43 case OBJ_INSTANCE: /* octree instance */
44 getinstance(op, IO_ALL);
45 return(1);
46 case PAT_CPICT: /* color picture */
47 if (op->oargs.nsargs < 4)
48 goto sargerr;
49 getpict(op->oargs.sarg[3]);
50 getfunc(op, 4, 0x3<<5, 0);
51 return(1);
52 case PAT_CDATA: /* color data */
53 dp = getdata(op->oargs.sarg[3]);
54 getdata(op->oargs.sarg[4]);
55 getdata(op->oargs.sarg[5]);
56 getfunc(op, 6, ((1<<dp->nd)-1)<<7, 0);
57 return(1);
58 case PAT_BDATA: /* brightness data */
59 if (op->oargs.nsargs < 2)
60 goto sargerr;
61 dp = getdata(op->oargs.sarg[1]);
62 getfunc(op, 2, ((1<<dp->nd)-1)<<3, 0);
63 return(1);
64 case PAT_BFUNC: /* brightness function */
65 getfunc(op, 1, 0x1, 0);
66 return(1);
67 case PAT_CFUNC: /* color function */
68 getfunc(op, 3, 0x7, 0);
69 return(1);
70 case TEX_DATA: /* texture data */
71 if (op->oargs.nsargs < 6)
72 goto sargerr;
73 dp = getdata(op->oargs.sarg[3]);
74 getdata(op->oargs.sarg[4]);
75 getdata(op->oargs.sarg[5]);
76 getfunc(op, 6, ((1<<dp->nd)-1)<<7, 1);
77 return(1);
78 case TEX_FUNC: /* texture function */
79 getfunc(op, 3, 0x7, 1);
80 return(1);
81 case MIX_DATA: /* mixture data */
82 dp = getdata(op->oargs.sarg[3]);
83 getfunc(op, 4, ((1<<dp->nd)-1)<<5, 0);
84 return(1);
85 case MIX_PICT: /* mixture picture */
86 getpict(op->oargs.sarg[3]);
87 getfunc(op, 4, 0x3<<5, 0);
88 return(1);
89 case MIX_FUNC: /* mixture function */
90 getfunc(op, 3, 0x4, 0);
91 return(1);
92 case MAT_PLASTIC2: /* anisotropic plastic */
93 case MAT_METAL2: /* anisotropic metal */
94 getfunc(op, 3, 0x7, 1);
95 return(1);
96 case MAT_BRTDF: /* BRDTfunc material */
97 getfunc(op, 9, 0x3f, 0);
98 return(1);
99 case MAT_PDATA: /* plastic BRDF data */
100 case MAT_MDATA: /* metal BRDF data */
101 case MAT_TDATA: /* trans BRDF data */
102 if (op->oargs.nsargs < 2)
103 goto sargerr;
104 getdata(op->oargs.sarg[1]);
105 getfunc(op, 2, 0, 0);
106 return(1);
107 case MAT_PFUNC: /* plastic BRDF func */
108 case MAT_MFUNC: /* metal BRDF func */
109 case MAT_TFUNC: /* trans BRDF func */
110 getfunc(op, 1, 0, 0);
111 return(1);
112 case MAT_DIRECT1: /* prism1 material */
113 getfunc(op, 4, 0xf, 1);
114 return(1);
115 case MAT_DIRECT2: /* prism2 material */
116 getfunc(op, 8, 0xff, 1);
117 return(1);
118 }
119 /* nothing to load for the remaining types */
120 return(0);
121 sargerr:
122 objerror(op, USER, "too few string arguments");
123 }
124
125
126 void
127 preload_objs() /* preload object data structures */
128 {
129 register OBJECT on;
130 /* note that nobjects may change during loop */
131 for (on = 0; on < nobjects; on++)
132 load_os(objptr(on));
133 }