| 16 |
|
#include "random.h" |
| 17 |
|
|
| 18 |
|
#ifndef WFLUSH |
| 19 |
< |
#define WFLUSH 64 /* flush after this many rays */ |
| 19 |
> |
#define WFLUSH 64 /* flush after this many primary rays */ |
| 20 |
|
#endif |
| 21 |
+ |
#ifndef WFLUSH1 |
| 22 |
+ |
#define WFLUSH1 512 /* or this many total rays */ |
| 23 |
+ |
#endif |
| 24 |
|
|
| 25 |
+ |
|
| 26 |
|
#ifdef SMLFLT |
| 27 |
|
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
| 28 |
|
#else |
| 176 |
|
PNODE *p |
| 177 |
|
) |
| 178 |
|
{ |
| 175 |
– |
extern int ray_pnprocs; |
| 176 |
– |
static unsigned long lastflush = 0; |
| 179 |
|
static RAY thisray; |
| 178 |
– |
int flushintvl; |
| 180 |
|
double h, v; |
| 181 |
|
|
| 182 |
< |
if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0) { /* empty */ |
| 182 |
> |
if ((p->xmax <= p->xmin) | (p->ymax <= p->ymin)) { /* empty */ |
| 183 |
|
p->x = p->xmin; |
| 184 |
|
p->y = p->ymin; |
| 185 |
|
setcolor(p->v, 0.0, 0.0, 0.0); |
| 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 { |
| 196 |
< |
int rval; |
| 195 |
> |
} else if (nproc == 1) { /* 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; |
| 201 |
|
rval = ray_pqueue(&thisray); |
| 211 |
|
|
| 212 |
|
recolor(p); /* paint it */ |
| 213 |
|
|
| 214 |
< |
if (ambounce <= 0) /* shall we check for input? */ |
| 215 |
< |
flushintvl = ray_pnprocs*WFLUSH; |
| 216 |
< |
else if (niflush < WFLUSH) |
| 217 |
< |
flushintvl = ray_pnprocs*niflush/(ambounce+1); |
| 218 |
< |
else |
| 219 |
< |
flushintvl = ray_pnprocs*WFLUSH/(ambounce+1); |
| 214 |
> |
if (dev->flush != NULL) { /* shall we check for input? */ |
| 215 |
> |
static unsigned long lastflush = 0; |
| 216 |
> |
unsigned long counter = raynum; |
| 217 |
> |
int flushintvl; |
| 218 |
> |
if (nproc == 1) { |
| 219 |
> |
counter = nrays; |
| 220 |
> |
flushintvl = WFLUSH1; |
| 221 |
> |
} else if (ambounce == 0) |
| 222 |
> |
flushintvl = nproc*WFLUSH; |
| 223 |
> |
else if (niflush < WFLUSH) |
| 224 |
> |
flushintvl = nproc*niflush/(ambounce+1); |
| 225 |
> |
else |
| 226 |
> |
flushintvl = nproc*WFLUSH/(ambounce+1); |
| 227 |
|
|
| 228 |
< |
if (dev->flush != NULL && raynum - lastflush >= flushintvl) { |
| 229 |
< |
lastflush = raynum; |
| 230 |
< |
(*dev->flush)(); |
| 231 |
< |
niflush++; |
| 228 |
> |
if (counter - lastflush >= flushintvl) { |
| 229 |
> |
lastflush = counter; |
| 230 |
> |
(*dev->flush)(); |
| 231 |
> |
niflush++; |
| 232 |
> |
} |
| 233 |
|
} |
| 234 |
|
return(1); |
| 235 |
|
} |
| 241 |
|
int nwaited = 0; |
| 242 |
|
int rval; |
| 243 |
|
RAY raydone; |
| 244 |
< |
|
| 244 |
> |
|
| 245 |
> |
if (nproc <= 1) /* immediate mode? */ |
| 246 |
> |
return(0); |
| 247 |
|
while ((rval = ray_presult(&raydone, 0)) > 0) { |
| 248 |
|
PNODE *p = (PNODE *)raydone.rno; |
| 249 |
|
copycolor(p->v, raydone.rcol); |
| 262 |
|
char *s |
| 263 |
|
) |
| 264 |
|
{ |
| 265 |
< |
int newnp; |
| 265 |
> |
extern int ray_pnprocs; |
| 266 |
> |
int newnp; |
| 267 |
|
/* change in nproc? */ |
| 268 |
< |
if (s != NULL && sscanf(s, "%d", &newnp) == 1 && newnp > 0) { |
| 268 |
> |
if (s != NULL && sscanf(s, "%d", &newnp) == 1 && |
| 269 |
> |
(newnp > 0) & (newnp != nproc)) { |
| 270 |
|
if (!newparam) { |
| 271 |
< |
if (newnp < nproc) |
| 272 |
< |
ray_pclose(nproc - newnp); |
| 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 - nproc); |
| 276 |
> |
ray_popen(newnp - ray_pnprocs); |
| 277 |
|
} |
| 278 |
|
nproc = newnp; |
| 279 |
|
} |
| 291 |
|
(*dev->clear)(hresolu, vresolu); |
| 292 |
|
|
| 293 |
|
if (newparam) { /* (re)start rendering procs */ |
| 294 |
< |
ray_pclose(0); |
| 295 |
< |
ray_popen(nproc); |
| 294 |
> |
if (ray_pnprocs > 0) |
| 295 |
> |
ray_pclose(0); |
| 296 |
> |
if (nproc > 1) |
| 297 |
> |
ray_popen(nproc); |
| 298 |
|
newparam = 0; |
| 299 |
|
} |
| 300 |
|
niflush = 0; /* get first value */ |