13 |
|
|
14 |
|
#include "ray.h" |
15 |
|
#include "rpaint.h" |
16 |
+ |
#include "otypes.h" |
17 |
+ |
#include "otspecial.h" |
18 |
|
#include "random.h" |
19 |
|
|
20 |
|
#ifndef WFLUSH |
31 |
|
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
32 |
|
#endif |
33 |
|
|
34 |
+ |
extern int ray_pnprocs; |
35 |
+ |
|
36 |
|
static RNUMBER niflush; /* flushes since newimage() */ |
37 |
|
|
38 |
|
int |
116 |
|
} |
117 |
|
if (!direc || ourview.type == VT_PAR) { |
118 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
119 |
< |
if (!localhit(&thisray, &thescene)) { |
119 |
> |
while (localhit(&thisray, &thescene)) { |
120 |
> |
OBJREC *m = findmaterial(thisray.ro); |
121 |
> |
if (m != NULL && !istransp(m->otype) && |
122 |
> |
!isBSDFproxy(m) && |
123 |
> |
(thisray.clipset == NULL || |
124 |
> |
!inset(thisray.clipset, |
125 |
> |
thisray.ro->omod))) |
126 |
> |
break; /* found something */ |
127 |
> |
VCOPY(thisray.rorg, thisray.rop); |
128 |
> |
rayclear(&thisray); /* skip invisible */ |
129 |
> |
} |
130 |
> |
if ((thisray.ro == NULL) | (thisray.ro == &Aftplane)) { |
131 |
|
error(COMMAND, "not a local object"); |
132 |
|
return(-1); |
133 |
|
} |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
< |
float * /* keep consistent with COLOR typedef */ |
155 |
> |
COLORV * |
156 |
|
greyof( /* convert color to greyscale */ |
157 |
|
COLOR col |
158 |
|
) |
207 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
208 |
|
h/hresolu, v/vresolu)) < -FTINY) { |
209 |
|
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
210 |
< |
} else if (nproc == 1) { /* immediate mode */ |
210 |
> |
} else if (!ray_pnprocs) { /* immediate mode */ |
211 |
|
ray_trace(&thisray); |
212 |
|
} else { /* queuing mode */ |
213 |
|
int rval; |
231 |
|
static RNUMBER lastflush = 0; |
232 |
|
RNUMBER counter = raynum; |
233 |
|
int flushintvl; |
234 |
< |
if (nproc == 1) { |
234 |
> |
if (!ray_pnprocs) { |
235 |
|
counter = nrays; |
236 |
|
flushintvl = WFLUSH1; |
237 |
|
} else if (ambounce == 0) |
238 |
< |
flushintvl = nproc*WFLUSH; |
238 |
> |
flushintvl = ray_pnprocs*WFLUSH; |
239 |
|
else if (niflush < WFLUSH) |
240 |
< |
flushintvl = nproc*niflush/(ambounce+1); |
240 |
> |
flushintvl = ray_pnprocs*niflush/(ambounce*(ambounce>0)+1); |
241 |
|
else |
242 |
< |
flushintvl = nproc*WFLUSH/(ambounce+1); |
242 |
> |
flushintvl = ray_pnprocs*WFLUSH/(ambounce*(ambounce>0)+1); |
243 |
|
if (lastflush > counter) |
244 |
|
lastflush = 0; /* counter wrapped */ |
245 |
|
|
260 |
|
int rval; |
261 |
|
RAY raydone; |
262 |
|
|
263 |
< |
if (nproc <= 1) /* immediate mode? */ |
263 |
> |
if (!ray_pnprocs) /* immediate mode? */ |
264 |
|
return(0); |
265 |
|
while ((rval = ray_presult(&raydone, 0)) > 0) { |
266 |
|
PNODE *p = (PNODE *)raydone.rno; |
280 |
|
char *s |
281 |
|
) |
282 |
|
{ |
283 |
< |
extern int ray_pnprocs; |
284 |
< |
int newnp; |
285 |
< |
/* change in nproc? */ |
286 |
< |
if (s != NULL && sscanf(s, "%d", &newnp) == 1 && |
272 |
< |
(newnp > 0) & (newnp != nproc)) { |
273 |
< |
if (!newparam) { |
274 |
< |
if (newnp == 1) |
275 |
< |
ray_pclose(0); |
276 |
< |
else if (newnp < ray_pnprocs) |
277 |
< |
ray_pclose(ray_pnprocs - newnp); |
278 |
< |
else |
279 |
< |
ray_popen(newnp - ray_pnprocs); |
280 |
< |
} |
281 |
< |
nproc = newnp; |
282 |
< |
} |
283 |
> |
int newnp = 0; |
284 |
> |
/* # rendering procs arg? */ |
285 |
> |
if (s != NULL) |
286 |
> |
sscanf(s, "%d", &newnp); |
287 |
|
/* free old image */ |
288 |
|
freepkids(&ptrunk); |
289 |
|
/* compute resolution */ |
298 |
|
(*dev->clear)(hresolu, vresolu); |
299 |
|
|
300 |
|
if (newparam) { /* (re)start rendering procs */ |
301 |
< |
if (ray_pnprocs > 0) |
302 |
< |
ray_pclose(0); |
301 |
> |
if (ray_pnprocs) |
302 |
> |
ray_pclose(0); /* should already be closed */ |
303 |
> |
if (newnp > 0) |
304 |
> |
nproc = newnp; |
305 |
|
if (nproc > 1) |
306 |
|
ray_popen(nproc); |
307 |
|
newparam = 0; |
308 |
+ |
} else if ((newnp > 0) & (newnp != nproc)) { |
309 |
+ |
if (newnp == 1) /* change # rendering procs */ |
310 |
+ |
ray_pclose(0); |
311 |
+ |
else if (newnp < ray_pnprocs) |
312 |
+ |
ray_pclose(ray_pnprocs - newnp); |
313 |
+ |
else |
314 |
+ |
ray_popen(newnp - ray_pnprocs); |
315 |
+ |
nproc = newnp; |
316 |
|
} |
317 |
|
niflush = 0; /* get first value */ |
318 |
|
paint(&ptrunk); |
530 |
|
) |
531 |
|
{ |
532 |
|
double d; |
519 |
– |
FVECT v1; |
533 |
|
VIEW nv = ourview; |
534 |
|
int i; |
535 |
|
|
536 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
537 |
< |
if (elev != 0.0) { |
538 |
< |
fcross(v1, ourview.vup, nv.vdir); |
539 |
< |
normalize(v1); |
527 |
< |
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
528 |
< |
} |
537 |
> |
if (elev != 0.0) |
538 |
> |
geodesic(nv.vdir, nv.vdir, nv.vup, elev*(-PI/180.), GEOD_RAD); |
539 |
> |
|
540 |
|
if (nv.type == VT_PAR) { |
541 |
|
nv.horiz /= mag; |
542 |
|
nv.vert /= mag; |