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