| 18 |
|
|
| 19 |
|
#include "random.h" |
| 20 |
|
|
| 21 |
+ |
#ifndef WFLUSH |
| 22 |
+ |
#define WFLUSH 30 /* flush after this many rays */ |
| 23 |
+ |
#endif |
| 24 |
|
|
| 25 |
+ |
|
| 26 |
|
getrect(s, r) /* get a box */ |
| 27 |
|
char *s; |
| 28 |
|
register RECT *r; |
| 134 |
|
register PNODE *p; |
| 135 |
|
int xmin, ymin, xmax, ymax; |
| 136 |
|
{ |
| 137 |
+ |
extern long nrays; |
| 138 |
+ |
static long lastflush = 0; |
| 139 |
|
static RAY thisray; |
| 140 |
|
double h, v; |
| 141 |
|
register int i; |
| 147 |
|
return; |
| 148 |
|
} |
| 149 |
|
/* jitter ray direction */ |
| 150 |
< |
p->x = h = xmin + (xmax-xmin)*frandom(); |
| 151 |
< |
h /= hresolu; |
| 146 |
< |
p->y = v = ymin + (ymax-ymin)*frandom(); |
| 147 |
< |
v /= vresolu; |
| 150 |
> |
h = xmin + (xmax-xmin)*frandom(); |
| 151 |
> |
v = ymin + (ymax-ymin)*frandom(); |
| 152 |
|
|
| 153 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, h, v); |
| 150 |
< |
|
| 153 |
> |
viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu); |
| 154 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 152 |
– |
|
| 155 |
|
rayvalue(&thisray); |
| 156 |
|
|
| 157 |
+ |
p->x = h; |
| 158 |
+ |
p->y = v; |
| 159 |
|
copycolor(p->v, thisray.rcol); |
| 156 |
– |
|
| 160 |
|
scalecolor(p->v, exposure); |
| 161 |
|
|
| 162 |
|
(*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax); |
| 163 |
+ |
|
| 164 |
+ |
if (dev->flush != NULL && nrays - lastflush >= WFLUSH) { |
| 165 |
+ |
lastflush = nrays; |
| 166 |
+ |
(*dev->flush)(); |
| 167 |
+ |
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
|
| 357 |
|
} else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
| 358 |
|
copystruct(&oldview, &ourview); |
| 359 |
|
copystruct(&ourview, vp); |
| 360 |
< |
newimage(); /* newimage() calls with vp=&ourview! */ |
| 360 |
> |
newimage(); |
| 361 |
|
} |
| 362 |
|
} |
| 363 |
|
|