68 |
|
r->gecc = seccg; |
69 |
|
r->slights = NULL; |
70 |
|
} else { /* spawned ray */ |
71 |
< |
if (ro->rot >= FHUGE) { |
71 |
> |
if (ro->rot >= FHUGE*.99) { |
72 |
|
memset(r, 0, sizeof(RAY)); |
73 |
|
return(-1); /* illegal continuation */ |
74 |
|
} |
116 |
|
if (photonMapping && rt != TRANS) |
117 |
|
return(-1); |
118 |
|
} |
119 |
< |
if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */ |
119 |
> |
if ((maxdepth <= 0) & (rc != NULL)) { /* Russian roulette */ |
120 |
|
if (minweight <= 0.0) |
121 |
|
error(USER, "zero ray weight in Russian roulette"); |
122 |
< |
if (maxdepth < 0 && r->rlvl > -maxdepth) |
122 |
> |
if ((maxdepth < 0) & (r->rlvl > -maxdepth)) |
123 |
|
return(-1); /* upper reflection limit */ |
124 |
|
if (r->rweight >= minweight) |
125 |
|
return(0); |
130 |
|
r->rweight = minweight; |
131 |
|
return(0); |
132 |
|
} |
133 |
< |
return(r->rweight >= minweight && r->rlvl <= abs(maxdepth) ? 0 : -1); |
133 |
> |
return((r->rweight >= minweight) & (r->rlvl <= abs(maxdepth)) ? 0 : -1); |
134 |
|
} |
135 |
|
|
136 |
|
|
146 |
|
r->ro = NULL; |
147 |
|
r->rox = NULL; |
148 |
|
r->rxt = r->rmt = r->rot = FHUGE; |
149 |
+ |
VCOPY(r->rop, r->rorg); |
150 |
|
r->pert[0] = r->pert[1] = r->pert[2] = 0.0; |
151 |
+ |
r->rflips = 0; |
152 |
|
r->uv[0] = r->uv[1] = 0.0; |
153 |
|
setcolor(r->pcol, 1.0, 1.0, 1.0); |
154 |
|
setcolor(r->mcol, 0.0, 0.0, 0.0); |
197 |
|
rayorigin(&tr, TRANS, r, NULL); /* always continue */ |
198 |
|
VCOPY(tr.rdir, r->rdir); |
199 |
|
rayvalue(&tr); |
200 |
+ |
copycolor(r->mcol, tr.mcol); |
201 |
|
copycolor(r->rcol, tr.rcol); |
202 |
|
r->rmt = r->rot + tr.rmt; |
203 |
|
r->rxt = r->rot + tr.rxt; |
210 |
|
RAY *r |
211 |
|
) |
212 |
|
{ |
213 |
< |
if ((ofun[m->otype].flags & (T_M|T_X)) && m->otype != MAT_CLIP) { |
213 |
> |
if (ofun[m->otype].flags & (T_M|T_X) && m->otype != MAT_CLIP) { |
214 |
|
if (istransp(m->otype) || isBSDFproxy(m)) { |
215 |
|
raytrans(r); |
216 |
|
return(1); |
231 |
|
int tst_irrad = do_irrad && !(r->crtype & ~(PRIMARY|TRANS)); |
232 |
|
OBJREC *m; |
233 |
|
|
234 |
< |
r->rxt = r->rmt = r->rot; /* preset effective ray length */ |
234 |
> |
r->rxt = r->rot; /* preset effective ray length */ |
235 |
|
for ( ; mod != OVOID; mod = m->omod) { |
236 |
|
m = objptr(mod); |
237 |
|
/****** unnecessary test since modifier() is always called |
370 |
|
scalecolor(br.rcol, 1.0-coef); |
371 |
|
copycolor(r->rcol, fr.rcol); |
372 |
|
addcolor(r->rcol, br.rcol); |
373 |
+ |
scalecolor(fr.mcol, coef); |
374 |
+ |
scalecolor(br.mcol, 1.0-coef); |
375 |
+ |
copycolor(r->mcol, fr.mcol); |
376 |
+ |
addcolor(r->mcol, br.mcol); |
377 |
|
mfore = bright(fr.mcol); mback = bright(br.mcol); |
378 |
|
r->rmt = mfore > mback ? fr.rmt : br.rmt; |
379 |
|
r->rxt = bright(fr.rcol)-mfore > bright(br.rcol)-mback ? |
405 |
|
int flags |
406 |
|
) |
407 |
|
{ |
408 |
< |
double eext[3]; |
402 |
< |
int i; |
408 |
> |
static int warnedPM = 0; |
409 |
|
|
404 |
– |
eext[0] = eext[1] = eext[2] = 0.; |
410 |
|
rc[0] = rc[1] = rc[2] = 1.; |
411 |
|
|
412 |
|
while (r != NULL && r->crtype&flags) { |
413 |
< |
for (i = 3; i--; ) { |
413 |
> |
int i = 3; |
414 |
> |
while (i--) |
415 |
|
rc[i] *= colval(r->rcoef,i); |
416 |
< |
eext[i] += r->rot * colval(r->cext,i); |
416 |
> |
/* check for participating medium */ |
417 |
> |
if (!warnedPM && (bright(r->cext) > FTINY) | |
418 |
> |
(bright(r->albedo) > FTINY)) { |
419 |
> |
error(WARNING, |
420 |
> |
"ray contribution calculation does not support participating media"); |
421 |
> |
warnedPM++; |
422 |
|
} |
423 |
|
r = r->parent; |
424 |
|
} |
414 |
– |
for (i = 3; i--; ) |
415 |
– |
rc[i] *= (eext[i] <= FTINY) ? 1. : |
416 |
– |
(eext[i] > 92.) ? 0. : exp(-eext[i]); |
425 |
|
} |
426 |
|
|
427 |
|
|
511 |
|
r->pert[0] = -r->pert[0]; |
512 |
|
r->pert[1] = -r->pert[1]; |
513 |
|
r->pert[2] = -r->pert[2]; |
514 |
+ |
r->rflips++; |
515 |
|
} |
516 |
|
|
517 |
|
|