--- ray/src/rt/pmapmat.c 2015/10/20 15:49:44 2.11 +++ ray/src/rt/pmapmat.c 2018/03/20 19:55:33 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pmapmat.c,v 2.11 2015/10/20 15:49:44 rschregle Exp $"; +static const char RCSid[] = "$Id: pmapmat.c,v 2.15 2018/03/20 19:55:33 rschregle Exp $"; #endif /* ================================================================== @@ -106,23 +106,28 @@ void photonRay (const RAY *rayIn, RAY *rayOut, { rayorigin(rayOut, rayOutType, rayIn, NULL); - /* Transfer flux */ - copycolor(rayOut -> rcol, rayIn -> rcol); - - /* Copy caustic flag & direction for transferred rays */ - if (rayOutType == PMAP_XFER) { - /* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */ - rayOut -> rtype |= rayIn -> rtype; - VCOPY(rayOut -> rdir, rayIn -> rdir); - } - else if (fluxAtten) { - /* Attenuate and normalise flux for scattered rays */ - multcolor(rayOut -> rcol, fluxAtten); - colorNorm(rayOut -> rcol); - } + if (rayIn) { + /* Transfer flux */ + copycolor(rayOut -> rcol, rayIn -> rcol); + + /* Copy caustic flag & direction for transferred rays */ + if (rayOutType == PMAP_XFER) { + /* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */ + rayOut -> rtype |= rayIn -> rtype; + VCOPY(rayOut -> rdir, rayIn -> rdir); + } + else if (fluxAtten) { + /* Attenuate and normalise flux for scattered rays */ + multcolor(rayOut -> rcol, fluxAtten); + colorNorm(rayOut -> rcol); + } - /* Propagate index of emitting light source */ - rayOut -> rsrc = rayIn -> rsrc; + /* Propagate index of emitting light source */ + rayOut -> rsrc = rayIn -> rsrc; + + /* Update maximum photon path distance */ + rayOut -> rmax = rayIn -> rmax - rayIn -> rot; + } } @@ -132,17 +137,17 @@ static void addPhotons (const RAY *r) { if (!r -> rlvl) /* Add direct photon map at primary hitpoint */ - addPhoton(directPmap, r); + newPhoton(directPmap, r); else { /* Add global or precomputed photon map at indirect hitpoint */ - addPhoton(preCompPmap ? preCompPmap : globalPmap, r); + newPhoton(preCompPmap ? preCompPmap : globalPmap, r); /* Store caustic photon if specular flag set */ if (PMAP_CAUSTICRAY(r)) - addPhoton(causticPmap, r); + newPhoton(causticPmap, r); /* Store in contribution photon map */ - addPhoton(contribPmap, r); + newPhoton(contribPmap, r); } } @@ -979,7 +984,7 @@ static int aliasPhotonScatter (OBJREC *mat, RAY *rayIn /* Straight replacement? */ if (!mat -> oargs.nsargs) { /* Skip void modifier! */ - if (mat -> omod != OVOID) { + if (mat -> omod != OVOID) { mat = objptr(mat -> omod); photonScatter [mat -> otype] (mat, rayIn); } @@ -1662,7 +1667,7 @@ static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn) static int lightPhotonScatter (OBJREC* mat, RAY* ray) -/* Light sources doan' reflect */ +/* Light sources doan' reflect, mang */ { return 0; }