11 |
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
12 |
|
================================================================== |
13 |
|
|
14 |
– |
$Id$ |
14 |
|
*/ |
15 |
|
|
16 |
|
|
106 |
|
{ |
107 |
|
rayorigin(rayOut, rayOutType, rayIn, NULL); |
108 |
|
|
109 |
< |
/* Transfer flux */ |
110 |
< |
copycolor(rayOut -> rcol, rayIn -> rcol); |
111 |
< |
|
112 |
< |
/* Copy caustic flag & direction for transferred rays */ |
113 |
< |
if (rayOutType == PMAP_XFER) { |
114 |
< |
/* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */ |
115 |
< |
rayOut -> rtype |= rayIn -> rtype; |
116 |
< |
VCOPY(rayOut -> rdir, rayIn -> rdir); |
117 |
< |
} |
118 |
< |
else if (fluxAtten) { |
119 |
< |
/* Attenuate and normalise flux for scattered rays */ |
120 |
< |
multcolor(rayOut -> rcol, fluxAtten); |
121 |
< |
colorNorm(rayOut -> rcol); |
122 |
< |
} |
109 |
> |
if (rayIn) { |
110 |
> |
/* Transfer flux */ |
111 |
> |
copycolor(rayOut -> rcol, rayIn -> rcol); |
112 |
> |
|
113 |
> |
/* Copy caustic flag & direction for transferred rays */ |
114 |
> |
if (rayOutType == PMAP_XFER) { |
115 |
> |
/* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */ |
116 |
> |
rayOut -> rtype |= rayIn -> rtype; |
117 |
> |
VCOPY(rayOut -> rdir, rayIn -> rdir); |
118 |
> |
} |
119 |
> |
else if (fluxAtten) { |
120 |
> |
/* Attenuate and normalise flux for scattered rays */ |
121 |
> |
multcolor(rayOut -> rcol, fluxAtten); |
122 |
> |
colorNorm(rayOut -> rcol); |
123 |
> |
} |
124 |
|
|
125 |
< |
/* Propagate index of emitting light source */ |
126 |
< |
rayOut -> rsrc = rayIn -> rsrc; |
125 |
> |
/* Propagate index of emitting light source */ |
126 |
> |
rayOut -> rsrc = rayIn -> rsrc; |
127 |
> |
} |
128 |
|
} |
129 |
|
|
130 |
|
|
134 |
|
{ |
135 |
|
if (!r -> rlvl) |
136 |
|
/* Add direct photon map at primary hitpoint */ |
137 |
< |
addPhoton(directPmap, r); |
137 |
> |
newPhoton(directPmap, r); |
138 |
|
else { |
139 |
|
/* Add global or precomputed photon map at indirect hitpoint */ |
140 |
< |
addPhoton(preCompPmap ? preCompPmap : globalPmap, r); |
140 |
> |
newPhoton(preCompPmap ? preCompPmap : globalPmap, r); |
141 |
|
|
142 |
|
/* Store caustic photon if specular flag set */ |
143 |
|
if (PMAP_CAUSTICRAY(r)) |
144 |
< |
addPhoton(causticPmap, r); |
144 |
> |
newPhoton(causticPmap, r); |
145 |
|
|
146 |
|
/* Store in contribution photon map */ |
147 |
< |
addPhoton(contribPmap, r); |
147 |
> |
newPhoton(contribPmap, r); |
148 |
|
} |
149 |
|
} |
150 |
|
|
980 |
|
|
981 |
|
/* Straight replacement? */ |
982 |
|
if (!mat -> oargs.nsargs) { |
983 |
< |
mat = objptr(mat -> omod); |
984 |
< |
photonScatter [mat -> otype] (mat, rayIn); |
983 |
> |
/* Skip void modifier! */ |
984 |
> |
if (mat -> omod != OVOID) { |
985 |
> |
mat = objptr(mat -> omod); |
986 |
> |
photonScatter [mat -> otype] (mat, rayIn); |
987 |
> |
} |
988 |
|
|
989 |
|
return 0; |
990 |
|
} |
1255 |
|
if (errno) |
1256 |
|
objerror(mat, WARNING, "compute error"); |
1257 |
|
else { |
1258 |
< |
mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]); |
1259 |
< |
photonScatter [mat -> otype] (mat, rayIn); |
1258 |
> |
OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1]; |
1259 |
> |
|
1260 |
> |
if (mxMod != OVOID) { |
1261 |
> |
mat = objptr(mxMod); |
1262 |
> |
photonScatter [mat -> otype] (mat, rayIn); |
1263 |
> |
} |
1264 |
> |
else { |
1265 |
> |
/* Transfer ray if no modifier */ |
1266 |
> |
RAY rayOut; |
1267 |
> |
|
1268 |
> |
photonRay(rayIn, &rayOut, PMAP_XFER, NULL); |
1269 |
> |
tracePhoton(&rayOut); |
1270 |
> |
} |
1271 |
|
} |
1272 |
|
|
1273 |
|
return 0; |
1319 |
|
if (errno) |
1320 |
|
objerror(mat, WARNING, "compute error"); |
1321 |
|
else { |
1322 |
< |
mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]); |
1323 |
< |
photonScatter [mat -> otype] (mat, rayIn); |
1322 |
> |
OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1]; |
1323 |
> |
|
1324 |
> |
if (mxMod != OVOID) { |
1325 |
> |
mat = objptr(mxMod); |
1326 |
> |
photonScatter [mat -> otype] (mat, rayIn); |
1327 |
> |
} |
1328 |
> |
else { |
1329 |
> |
/* Transfer ray if no modifier */ |
1330 |
> |
RAY rayOut; |
1331 |
> |
|
1332 |
> |
photonRay(rayIn, &rayOut, PMAP_XFER, NULL); |
1333 |
> |
tracePhoton(&rayOut); |
1334 |
> |
} |
1335 |
|
} |
1336 |
|
|
1337 |
|
return 0; |
1370 |
|
if (errno) |
1371 |
|
objerror(mat, WARNING, "compute error"); |
1372 |
|
else { |
1373 |
< |
mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]); |
1374 |
< |
photonScatter [mat -> otype] (mat, rayIn); |
1373 |
> |
OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1]; |
1374 |
> |
|
1375 |
> |
if (mxMod != OVOID) { |
1376 |
> |
mat = objptr(mxMod); |
1377 |
> |
photonScatter [mat -> otype] (mat, rayIn); |
1378 |
> |
} |
1379 |
> |
else { |
1380 |
> |
/* Transfer ray if no modifier */ |
1381 |
> |
RAY rayOut; |
1382 |
> |
|
1383 |
> |
photonRay(rayIn, &rayOut, PMAP_XFER, NULL); |
1384 |
> |
tracePhoton(&rayOut); |
1385 |
> |
} |
1386 |
|
} |
1387 |
|
|
1388 |
|
return 0; |