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; |
135 |
– |
register int i; |
141 |
|
|
142 |
|
if (xmax - xmin <= 0 || ymax - ymin <= 0) { /* empty */ |
143 |
|
p->x = xmin; |
146 |
|
return; |
147 |
|
} |
148 |
|
/* jitter ray direction */ |
149 |
< |
p->x = h = xmin + (xmax-xmin)*frandom(); |
150 |
< |
h /= hresolu; |
146 |
< |
p->y = v = ymin + (ymax-ymin)*frandom(); |
147 |
< |
v /= vresolu; |
149 |
> |
h = xmin + (xmax-xmin)*frandom(); |
150 |
> |
v = ymin + (ymax-ymin)*frandom(); |
151 |
|
|
152 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, h, v); |
150 |
< |
|
152 |
> |
viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu); |
153 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
152 |
– |
|
154 |
|
rayvalue(&thisray); |
155 |
|
|
156 |
+ |
p->x = h; |
157 |
+ |
p->y = v; |
158 |
|
copycolor(p->v, thisray.rcol); |
156 |
– |
|
159 |
|
scalecolor(p->v, exposure); |
160 |
|
|
161 |
|
(*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax); |
162 |
+ |
|
163 |
+ |
if (dev->flush != NULL && nrays - lastflush >= WFLUSH) { |
164 |
+ |
lastflush = nrays; |
165 |
+ |
(*dev->flush)(); |
166 |
+ |
} |
167 |
|
} |
168 |
|
|
169 |
|
|
353 |
|
if ((err = setview(vp)) != NULL) { |
354 |
|
sprintf(errmsg, "view not set - %s", err); |
355 |
|
error(COMMAND, errmsg); |
356 |
< |
} else if (bcmp(vp, &ourview, sizeof(VIEW))) { |
357 |
< |
copyview(&oldview, &ourview); |
358 |
< |
copyview(&ourview, vp); |
359 |
< |
newimage(); /* newimage() calls with vp=&ourview! */ |
356 |
> |
} else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
357 |
> |
copystruct(&oldview, &ourview); |
358 |
> |
copystruct(&ourview, vp); |
359 |
> |
newimage(); |
360 |
|
} |
361 |
|
} |
362 |
|
|