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 |
|
|
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; |
27 |
> |
load_os( /* load associated data for object */ |
28 |
> |
OBJREC *op |
29 |
> |
) |
30 |
|
{ |
31 |
+ |
DATARRAY *dp; |
32 |
+ |
SDData *sd; |
33 |
+ |
|
34 |
+ |
SDretainSet = SDretainAll; |
35 |
+ |
|
36 |
|
switch (op->otype) { |
37 |
|
case OBJ_FACE: /* polygon */ |
38 |
|
getface(op); |
47 |
|
case OBJ_INSTANCE: /* octree instance */ |
48 |
|
getinstance(op, IO_ALL); |
49 |
|
return(1); |
50 |
+ |
case OBJ_MESH: /* mesh instance */ |
51 |
+ |
getmeshinst(op, IO_ALL); |
52 |
+ |
return(1); |
53 |
+ |
case PAT_CPICT: /* color picture */ |
54 |
+ |
if (op->oargs.nsargs < 4) |
55 |
+ |
goto sargerr; |
56 |
+ |
getpict(op->oargs.sarg[3]); |
57 |
+ |
getfunc(op, 4, 0x3<<5, 0); |
58 |
+ |
return(1); |
59 |
+ |
case PAT_CDATA: /* color data */ |
60 |
+ |
if (op->oargs.nsargs < 4) |
61 |
+ |
goto sargerr; |
62 |
+ |
dp = getdata(op->oargs.sarg[3]); |
63 |
+ |
getdata(op->oargs.sarg[4]); |
64 |
+ |
getdata(op->oargs.sarg[5]); |
65 |
+ |
getfunc(op, 6, ((1<<dp->nd)-1)<<7, 0); |
66 |
+ |
return(1); |
67 |
+ |
case PAT_BDATA: /* brightness data */ |
68 |
+ |
if (op->oargs.nsargs < 2) |
69 |
+ |
goto sargerr; |
70 |
+ |
dp = getdata(op->oargs.sarg[1]); |
71 |
+ |
getfunc(op, 2, ((1<<dp->nd)-1)<<3, 0); |
72 |
+ |
return(1); |
73 |
+ |
case PAT_BFUNC: /* brightness function */ |
74 |
+ |
getfunc(op, 1, 0x1, 0); |
75 |
+ |
return(1); |
76 |
+ |
case PAT_CFUNC: /* color function */ |
77 |
+ |
getfunc(op, 3, 0x7, 0); |
78 |
+ |
return(1); |
79 |
+ |
case PAT_SPECFUNC: /* spectral function */ |
80 |
+ |
getfunc(op, 1, 0, 0); |
81 |
+ |
return(1); |
82 |
+ |
case PAT_SPECFILE: /* spectrum file */ |
83 |
+ |
if (op->oargs.nsargs < 1) |
84 |
+ |
goto sargerr; |
85 |
+ |
getdata(op->oargs.sarg[0]); |
86 |
+ |
return(1); |
87 |
+ |
case PAT_SPECDATA: /* spectral data file */ |
88 |
+ |
if (op->oargs.nsargs < 2) |
89 |
+ |
goto sargerr; |
90 |
+ |
dp = getdata(op->oargs.sarg[1]); |
91 |
+ |
getfunc(op, 2, ((1<<(dp->nd-1)) - 1)<<3, 0); |
92 |
+ |
return(1); |
93 |
+ |
case PAT_SPECPICT: /* spectral picture */ |
94 |
+ |
if (op->oargs.nsargs < 2) |
95 |
+ |
goto sargerr; |
96 |
+ |
getspec(op->oargs.sarg[1]); |
97 |
+ |
getfunc(op, 2, 0x3<<3, 0); |
98 |
+ |
return(1); |
99 |
+ |
case TEX_DATA: /* texture data */ |
100 |
+ |
if (op->oargs.nsargs < 6) |
101 |
+ |
goto sargerr; |
102 |
+ |
dp = getdata(op->oargs.sarg[3]); |
103 |
+ |
getdata(op->oargs.sarg[4]); |
104 |
+ |
getdata(op->oargs.sarg[5]); |
105 |
+ |
getfunc(op, 6, ((1<<dp->nd)-1)<<7, 1); |
106 |
+ |
return(1); |
107 |
+ |
case TEX_FUNC: /* texture function */ |
108 |
+ |
getfunc(op, 3, 0x7, 1); |
109 |
+ |
return(1); |
110 |
+ |
case MIX_DATA: /* mixture data */ |
111 |
+ |
dp = getdata(op->oargs.sarg[3]); |
112 |
+ |
getfunc(op, 4, ((1<<dp->nd)-1)<<5, 0); |
113 |
+ |
return(1); |
114 |
+ |
case MIX_PICT: /* mixture picture */ |
115 |
+ |
getpict(op->oargs.sarg[3]); |
116 |
+ |
getfunc(op, 4, 0x3<<5, 0); |
117 |
+ |
return(1); |
118 |
+ |
case MIX_FUNC: /* mixture function */ |
119 |
+ |
getfunc(op, 3, 0x4, 0); |
120 |
+ |
return(1); |
121 |
+ |
case MAT_PLASTIC2: /* anisotropic plastic */ |
122 |
+ |
case MAT_METAL2: /* anisotropic metal */ |
123 |
+ |
getfunc(op, 3, 0x7, 1); |
124 |
+ |
return(1); |
125 |
+ |
case MAT_BRTDF: /* BRDTfunc material */ |
126 |
+ |
getfunc(op, 9, 0x3f, 0); |
127 |
+ |
return(1); |
128 |
+ |
case MAT_BSDF: /* BSDF material */ |
129 |
+ |
if (op->oargs.nsargs < 6) |
130 |
+ |
goto sargerr; |
131 |
+ |
getfunc(op, 5, 0x1d, 1); |
132 |
+ |
sd = loadBSDF(op->oargs.sarg[1]); |
133 |
+ |
if (sd != NULL) SDfreeCache(sd); |
134 |
+ |
return(1); |
135 |
+ |
case MAT_ABSDF: /* aBSDF material */ |
136 |
+ |
if (op->oargs.nsargs < 5) |
137 |
+ |
goto sargerr; |
138 |
+ |
getfunc(op, 4, 0xe, 1); |
139 |
+ |
sd = loadBSDF(op->oargs.sarg[0]); |
140 |
+ |
if (sd != NULL) SDfreeCache(sd); |
141 |
+ |
return(1); |
142 |
+ |
case MAT_PDATA: /* plastic BRDF data */ |
143 |
+ |
case MAT_MDATA: /* metal BRDF data */ |
144 |
+ |
case MAT_TDATA: /* trans BRDF data */ |
145 |
+ |
if (op->oargs.nsargs < 2) |
146 |
+ |
goto sargerr; |
147 |
+ |
getdata(op->oargs.sarg[1]); |
148 |
+ |
getfunc(op, 2, 0, 0); |
149 |
+ |
return(1); |
150 |
+ |
case MAT_PFUNC: /* plastic BRDF func */ |
151 |
+ |
case MAT_MFUNC: /* metal BRDF func */ |
152 |
+ |
case MAT_TFUNC: /* trans BRDF func */ |
153 |
+ |
getfunc(op, 1, 0, 0); |
154 |
+ |
return(1); |
155 |
+ |
case MAT_DIRECT1: /* prism1 material */ |
156 |
+ |
getfunc(op, 4, 0xf, 1); |
157 |
+ |
return(1); |
158 |
+ |
case MAT_DIRECT2: /* prism2 material */ |
159 |
+ |
getfunc(op, 8, 0xff, 1); |
160 |
+ |
return(1); |
161 |
|
} |
162 |
< |
/* don't bother with non-surfaces -- too tricky */ |
162 |
> |
/* nothing to load for the remaining types */ |
163 |
|
return(0); |
164 |
+ |
sargerr: |
165 |
+ |
objerror(op, USER, "too few string arguments"); |
166 |
+ |
return 0; /* pro forma return */ |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
< |
preload_objs() /* preload object data structures */ |
170 |
> |
void |
171 |
> |
preload_objs(void) /* preload object data structures */ |
172 |
|
{ |
173 |
< |
register OBJECT on; |
173 |
> |
OBJECT on; |
174 |
|
/* note that nobjects may change during loop */ |
175 |
|
for (on = 0; on < nobjects; on++) |
176 |
|
load_os(objptr(on)); |