--- ray/src/rt/pmapsrc.c 2015/09/29 18:16:34 2.10 +++ ray/src/rt/pmapsrc.c 2018/02/02 19:47:55 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pmapsrc.c,v 2.10 2015/09/29 18:16:34 rschregle Exp $"; +static const char RCSid[] = "$Id: pmapsrc.c,v 2.14 2018/02/02 19:47:55 rschregle Exp $"; #endif /* ================================================================== @@ -525,20 +525,21 @@ void getPhotonPorts () /* Find geometry declared as photon ports */ { OBJECT i; - OBJREC* obj; + OBJREC *obj, *mat; /* Check for missing port modifiers */ if (!ambset [0]) - error(USER, "no photon ports found"); + error(USER, "no photon ports"); for (i = 0; i < nobjects; i++) { obj = objptr(i); + mat = findmaterial(obj); /* Check if object is a surface and NOT a light source (duh) and * resolve its material via any aliases, then check for inclusion in * port modifier list */ - if (issurface(obj -> otype) && !islight(obj -> otype) && - inset(ambset, objndx(findmaterial(obj)))) { + if (issurface(obj -> otype) && mat && !islight(mat -> otype) && + inset(ambset, objndx(mat))) { /* Add photon port */ photonPorts = (SRCREC*)realloc(photonPorts, (numPhotonPorts + 1) * @@ -556,6 +557,9 @@ void getPhotonPorts () numPhotonPorts++; } } + + if (!numPhotonPorts) + error(USER, "no valid photon ports found"); } @@ -753,12 +757,13 @@ void emitPhoton (const EmissionMap* emap, RAY* ray) emitted photon to break up clustering artifacts */ photonOrigin [emap -> src -> so -> otype] ((EmissionMap*)emap); /* If we have a local glow source with a maximum radius, then - restrict our photon to the specified distance (otherwise no limit) */ + restrict our photon to the specified distance, otherwise we set + the limit imposed by photonMaxDist (or no limit if 0) */ if (mod -> otype == MAT_GLOW && !(emap -> src -> sflags & SDISTANT) && mod -> oargs.farg[3] > FTINY) ray -> rmax = mod -> oargs.farg[3]; else - ray -> rmax = 0; + ray -> rmax = photonMaxDist; rayorigin(ray, PRIMARY, NULL, NULL); if (!emap -> numSamples) {