46 |
|
|
47 |
|
int do_irrad = 0; /* compute irradiance? */ |
48 |
|
|
49 |
+ |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
50 |
+ |
|
51 |
|
void (*trace)() = NULL; /* trace call */ |
52 |
|
|
53 |
|
char *tralist[128]; /* list of modifers to trace (or no) */ |
54 |
|
int traincl = -1; /* include == 1, exclude == 0 */ |
55 |
< |
#define MAXTSET 511 /* maximum number in trace set */ |
55 |
> |
#ifndef MAXTSET |
56 |
> |
#define MAXTSET 1024 /* maximum number in trace set */ |
57 |
> |
#endif |
58 |
|
OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */ |
59 |
|
|
60 |
|
int hresolu = 0; /* horizontal (scan) size */ |
152 |
|
char *fname |
153 |
|
) |
154 |
|
{ |
155 |
< |
long vcount = hresolu>1 ? hresolu*vresolu : vresolu; |
155 |
> |
unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu |
156 |
> |
: vresolu; |
157 |
|
long nextflush = hresolu; |
158 |
|
FILE *fp; |
159 |
|
double d; |
192 |
|
d = normalize(direc); |
193 |
|
if (d == 0.0) { /* zero ==> flush */ |
194 |
|
bogusray(); |
195 |
< |
if (--nextflush <= 0 || vcount <= 0) { |
195 |
> |
if (--nextflush <= 0 || !vcount) { |
196 |
|
fflush(stdout); |
197 |
|
nextflush = hresolu; |
198 |
|
} |
199 |
|
} else { |
200 |
< |
samplendx++; |
200 |
> |
samplendx = rand_samp ? random() : samplendx+1; |
201 |
|
/* compute and print */ |
202 |
|
if (imm_irrad) |
203 |
|
irrad(orig, direc); |
204 |
|
else |
205 |
|
rad(orig, direc, lim_dist ? d : 0.0); |
206 |
|
/* flush if time */ |
207 |
< |
if (--nextflush == 0) { |
207 |
> |
if (!--nextflush) { |
208 |
|
fflush(stdout); |
209 |
|
nextflush = hresolu; |
210 |
|
} |
211 |
|
} |
212 |
|
if (ferror(stdout)) |
213 |
|
error(SYSTEM, "write error"); |
214 |
< |
if (--vcount == 0) /* check for end */ |
214 |
> |
if (vcount && !--vcount) /* check for end */ |
215 |
|
break; |
216 |
|
} |
217 |
|
fflush(stdout); |
218 |
< |
if (vcount > 0) |
218 |
> |
if (vcount) |
219 |
|
error(USER, "unexpected EOF on input"); |
220 |
|
if (fname != NULL) |
221 |
|
fclose(fp); |
638 |
|
RAY *r |
639 |
|
) |
640 |
|
{ |
641 |
< |
COLOR contr; |
641 |
> |
double contr[3]; |
642 |
|
|
643 |
|
raycontrib(contr, r, PRIMARY); |
644 |
< |
(*putreal)(colval(contr,RED)); |
645 |
< |
(*putreal)(colval(contr,GRN)); |
646 |
< |
(*putreal)(colval(contr,BLU)); |
644 |
> |
(*putreal)(contr[RED]); |
645 |
> |
(*putreal)(contr[GRN]); |
646 |
> |
(*putreal)(contr[BLU]); |
647 |
|
} |
648 |
|
|
649 |
|
|