12 |
|
#include "otypes.h" |
13 |
|
#include "source.h" |
14 |
|
|
15 |
– |
char *shm_boundary = NULL; /* boundary of shared memory */ |
16 |
– |
|
15 |
|
CUBE thescene; /* our scene */ |
16 |
|
OBJECT nsceneobjs; /* number of objects in our scene */ |
17 |
|
|
66 |
|
|
67 |
|
static void trace_contrib(RAY *r); /* our trace callback */ |
68 |
|
|
69 |
< |
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); } |
69 |
> |
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv,1); free(p); } |
70 |
|
|
71 |
|
LUTAB modconttab = LU_SINIT(NULL,mcfree); /* modifier lookup table */ |
72 |
|
|
73 |
|
/************************** INITIALIZATION ROUTINES ***********************/ |
74 |
|
|
75 |
< |
char * |
75 |
> |
const char * |
76 |
|
formstr( /* return format identifier */ |
77 |
|
int f |
78 |
|
) |
81 |
|
case 'a': return("ascii"); |
82 |
|
case 'f': return("float"); |
83 |
|
case 'd': return("double"); |
84 |
< |
case 'c': return(COLRFMT); |
84 |
> |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
85 |
|
} |
86 |
|
return("unknown"); |
87 |
|
} |
132 |
|
error(USER, errmsg); |
133 |
|
} |
134 |
|
/* initialize results holder */ |
135 |
< |
mp = (MODCONT *)malloc(sizeof(MODCONT)+sizeof(DCOLOR)*(bincnt-1)); |
135 |
> |
mp = (MODCONT *)malloc(mcsize(bincnt)); |
136 |
|
if (mp == NULL) |
137 |
|
error(SYSTEM, "out of memory in addmodifier"); |
138 |
|
mp->outspec = outf; /* XXX assumes static string */ |
141 |
|
mp->binv = ebinv; |
142 |
|
mp->bin0 = 0; |
143 |
|
mp->nbins = bincnt; |
144 |
< |
memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt); |
144 |
> |
memset(mp->cbin, 0, DCOLORSIZ*bincnt); |
145 |
|
/* figure out starting bin */ |
146 |
|
while (!getostream(mp->outspec, mp->modname, mp->bin0, 1)) |
147 |
|
mp->bin0++; |
224 |
|
if (nproc > MAXPROCESS) |
225 |
|
sprintf(errmsg, "too many processes requested -- reducing to %d", |
226 |
|
nproc = MAXPROCESS); |
227 |
< |
if (nproc > 1) { |
228 |
< |
preload_objs(); /* preload auxiliary data */ |
231 |
< |
/* set shared memory boundary */ |
232 |
< |
shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY"); |
233 |
< |
} |
227 |
> |
if (nproc > 1) |
228 |
> |
cow_memshare(); /* preload auxiliary data */ |
229 |
|
trace = trace_contrib; /* set up trace call-back */ |
230 |
|
for (i = 0; i < nsources; i++) /* tracing to sources as well */ |
231 |
|
source[i].sflags |= SFOLLOW; |
268 |
|
MODCONT *mp; |
269 |
|
double bval; |
270 |
|
int bn; |
271 |
< |
RREAL contr[3]; |
271 |
> |
SCOLOR contr; |
272 |
> |
DCOLORV *dvp; |
273 |
> |
int i; |
274 |
|
|
275 |
|
if (r->ro == NULL || r->ro->omod == OVOID) |
276 |
|
return; |
294 |
|
} |
295 |
|
raycontrib(contr, r, PRIMARY); /* compute coefficient */ |
296 |
|
if (contrib) |
297 |
< |
multcolor(contr, r->rcol); /* -> contribution */ |
298 |
< |
addcolor(mp->cbin[bn], contr); |
297 |
> |
smultscolor(contr, r->rcol); /* -> contribution */ |
298 |
> |
dvp = mcbin(mp, bn); |
299 |
> |
for (i = 0; i < NCSAMP; i++) /* add it in */ |
300 |
> |
*dvp++ += contr[i]; |
301 |
|
} |
302 |
|
|
303 |
|
|
351 |
|
for (i = 0; i < nmods; i++) { /* output records & clear */ |
352 |
|
mp = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
353 |
|
mod_output(mp); |
354 |
< |
memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins); |
354 |
> |
memset(mp->cbin, 0, DCOLORSIZ*mp->nbins); |
355 |
|
} |
356 |
|
end_record(); /* end lines & flush if time */ |
357 |
|
|