| 29 |
|
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
| 30 |
|
#endif |
| 31 |
|
|
| 32 |
< |
static unsigned long niflush; /* flushes since newimage() */ |
| 32 |
> |
static RNUMBER niflush; /* flushes since newimage() */ |
| 33 |
|
|
| 34 |
|
int |
| 35 |
|
getrect( /* get a box */ |
| 192 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
| 193 |
|
h/hresolu, v/vresolu)) < -FTINY) { |
| 194 |
|
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
| 195 |
< |
} else if (nproc == 1) { /* immediate mode */ |
| 195 |
> |
} else if (nproc == 1 || newparam) { /* immediate mode */ |
| 196 |
|
ray_trace(&thisray); |
| 197 |
|
} else { /* queuing mode */ |
| 198 |
|
int rval; |
| 199 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
| 200 |
< |
thisray.rno = (unsigned long)p; |
| 200 |
> |
thisray.rno = (RNUMBER)p; |
| 201 |
|
rval = ray_pqueue(&thisray); |
| 202 |
|
if (!rval) |
| 203 |
|
return(0); |
| 204 |
|
if (rval < 0) |
| 205 |
|
return(-1); |
| 206 |
+ |
/* get node for returned ray */ |
| 207 |
|
p = (PNODE *)thisray.rno; |
| 208 |
|
} |
| 209 |
|
|
| 213 |
|
recolor(p); /* paint it */ |
| 214 |
|
|
| 215 |
|
if (dev->flush != NULL) { /* shall we check for input? */ |
| 216 |
< |
static unsigned long lastflush = 0; |
| 217 |
< |
unsigned long counter = raynum; |
| 218 |
< |
int flushintvl; |
| 216 |
> |
static RNUMBER lastflush = 0; |
| 217 |
> |
RNUMBER counter = raynum; |
| 218 |
> |
int flushintvl; |
| 219 |
|
if (nproc == 1) { |
| 220 |
|
counter = nrays; |
| 221 |
|
flushintvl = WFLUSH1; |
| 225 |
|
flushintvl = nproc*niflush/(ambounce+1); |
| 226 |
|
else |
| 227 |
|
flushintvl = nproc*WFLUSH/(ambounce+1); |
| 228 |
+ |
if (lastflush > counter) |
| 229 |
+ |
lastflush = 0; /* counter wrapped */ |
| 230 |
|
|
| 231 |
|
if (counter - lastflush >= flushintvl) { |
| 232 |
|
lastflush = counter; |
| 266 |
|
) |
| 267 |
|
{ |
| 268 |
|
extern int ray_pnprocs; |
| 269 |
< |
int newnp; |
| 270 |
< |
/* change in nproc? */ |
| 271 |
< |
if (s != NULL && sscanf(s, "%d", &newnp) == 1 && |
| 272 |
< |
(newnp > 0) & (newnp != nproc)) { |
| 270 |
< |
if (!newparam) { |
| 271 |
< |
if (newnp == 1) |
| 272 |
< |
ray_pclose(0); |
| 273 |
< |
else if (newnp < ray_pnprocs) |
| 274 |
< |
ray_pclose(ray_pnprocs - newnp); |
| 275 |
< |
else |
| 276 |
< |
ray_popen(newnp - ray_pnprocs); |
| 277 |
< |
} |
| 278 |
< |
nproc = newnp; |
| 279 |
< |
} |
| 269 |
> |
int newnp = 0; |
| 270 |
> |
/* # rendering procs arg? */ |
| 271 |
> |
if (s != NULL) |
| 272 |
> |
sscanf(s, "%d", &newnp); |
| 273 |
|
/* free old image */ |
| 274 |
|
freepkids(&ptrunk); |
| 275 |
|
/* compute resolution */ |
| 286 |
|
if (newparam) { /* (re)start rendering procs */ |
| 287 |
|
if (ray_pnprocs > 0) |
| 288 |
|
ray_pclose(0); |
| 289 |
+ |
if (newnp > 0) |
| 290 |
+ |
nproc = newnp; |
| 291 |
|
if (nproc > 1) |
| 292 |
|
ray_popen(nproc); |
| 293 |
|
newparam = 0; |
| 294 |
+ |
} else if ((newnp > 0) & (newnp != nproc)) { |
| 295 |
+ |
if (newnp == 1) /* change # rendering procs */ |
| 296 |
+ |
ray_pclose(0); |
| 297 |
+ |
else if (newnp < ray_pnprocs) |
| 298 |
+ |
ray_pclose(ray_pnprocs - newnp); |
| 299 |
+ |
else |
| 300 |
+ |
ray_popen(newnp - ray_pnprocs); |
| 301 |
+ |
nproc = newnp; |
| 302 |
|
} |
| 303 |
|
niflush = 0; /* get first value */ |
| 304 |
|
paint(&ptrunk); |