| 191 |
|
int |
| 192 |
|
RcontribSimulManager::RctCall(RAY *r, void *cd) |
| 193 |
|
{ |
| 194 |
< |
if (!r->ro || r->ro->omod == OVOID) // hit nothing? |
| 195 |
< |
return 0; |
| 196 |
< |
// shadow ray not on source? |
| 194 |
> |
int i; |
| 195 |
> |
|
| 196 |
> |
if (!r->ro || (i = r->ro->omod) == OVOID) |
| 197 |
> |
return 0; // hit nothing |
| 198 |
> |
|
| 199 |
|
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
| 200 |
< |
return 0; |
| 200 |
> |
return 0; // shadow ray not on source |
| 201 |
|
|
| 202 |
< |
const char * mname = objptr(r->ro->omod)->oname; |
| 202 |
> |
const char * mname = objptr(i)->oname; |
| 203 |
|
RcontribSimulManager * rcp = (RcontribSimulManager *)cd; |
| 204 |
|
RcontribMod * mp = (RcontribMod *)lu_find(&rcp->modLUT,mname)->data; |
| 205 |
|
if (!mp) |
| 206 |
|
return 0; // not in our modifier list |
| 207 |
|
|
| 208 |
< |
if (rcp->HasFlag(RCcontrib) && sintens(r->rcol) <= FTINY) |
| 209 |
< |
return 0; // zero contribution |
| 208 |
> |
if (rcp->HasFlag(RCcontrib)) { // pre-emptive check for zero |
| 209 |
> |
for (i = NCSAMP; i--; ) |
| 210 |
> |
if (r->rcoef[i]*r->rcol[i] > FTINY) |
| 211 |
> |
break; |
| 212 |
> |
if (i < 0) |
| 213 |
> |
return 0; // zero contribution |
| 214 |
> |
} else if (sintens(r->rcoef) <= FTINY) |
| 215 |
> |
return 0; // zero coefficient |
| 216 |
|
|
| 217 |
< |
int bi = 0; // get bin index |
| 217 |
> |
int bi = 0; // get bin index |
| 218 |
|
if (mp->binv) { |
| 219 |
|
worldfunc(RCCONTEXT, r); |
| 220 |
|
set_eparams(mp->params); |
| 234 |
|
if (rcp->HasFlag(RCcontrib)) |
| 235 |
|
smultscolor(contr, r->rcol); // -> value contribution |
| 236 |
|
|
| 237 |
< |
for (int i = 0; i < NCSAMP; i++) |
| 237 |
> |
for (i = 0; i < NCSAMP; i++) |
| 238 |
|
*dvp++ += contr[i]; // accumulate color/spectrum |
| 239 |
|
return 1; |
| 240 |
|
} |