--- ray/src/rt/pmap.c 2015/02/24 19:39:26 2.1 +++ ray/src/rt/pmap.c 2015/05/22 14:09:01 2.7 @@ -4,10 +4,11 @@ Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) (c) Fraunhofer Institute for Solar Energy Systems, - Lucerne University of Applied Sciences & Arts + (c) Lucerne University of Applied Sciences and Arts, + supported by the Swiss National Science Foundation (SNSF, #147053) ================================================================== - $Id: pmap.c,v 2.1 2015/02/24 19:39:26 greg Exp $ + $Id: pmap.c,v 2.7 2015/05/22 14:09:01 greg Exp $ */ @@ -20,7 +21,6 @@ #include "pmapbias.h" #include "pmapdiag.h" #include "otypes.h" -#include #include #include @@ -28,7 +28,7 @@ extern char *octname; -static char PmapRevision [] = "$Revision: 2.1 $"; +static char PmapRevision [] = "$Revision: 2.7 $"; @@ -65,7 +65,8 @@ void loadPmaps (PhotonMap **pmaps, const PhotonMapPara for (t = 0; t < NUM_PMAP_TYPES; t++) if (setPmapParam(&pm, parm + t)) { /* Check if photon map newer than octree */ - if (!stat(pm -> fileName, &pmstat) && !stat(octname, &octstat) && + if (pm -> fileName && octname && + !stat(pm -> fileName, &pmstat) && !stat(octname, &octstat) && octstat.st_mtime > pmstat.st_mtime) { sprintf(errmsg, "photon map in file %s may be stale", pm -> fileName); @@ -100,7 +101,7 @@ void savePmaps (const PhotonMap **pmaps, int argc, cha for (t = 0; t < NUM_PMAP_TYPES; t++) { if (pmaps [t]) - savePhotonMap(pmaps [t], pmaps [t] -> fileName, t, argc, argv); + savePhotonMap(pmaps [t], pmaps [t] -> fileName, argc, argv); } } @@ -205,10 +206,12 @@ void tracePhoton (RAY *ray) OBJREC* mat; if (ray -> rlvl > photonMaxBounce) { +#ifdef PMAP_RUNAWAY_WARN error(WARNING, "runaway photon!"); +#endif return; } - + if (colorAvg(ray -> cext) > FTINY && !photonParticipate(ray)) return; @@ -264,9 +267,11 @@ static void preComputeGlobal (PhotonMap *pmap) /* Record start time, baby */ repStartTime = time(NULL); - signal(SIGCONT, pmapPreCompReport); + #ifdef SIGCONT + signal(SIGCONT, pmapPreCompReport); + #endif repProgress = 0; - bcopy(pmap -> heap, nuHeap, nuHeapSize * sizeof(Photon)); + memcpy(nuHeap, pmap -> heap, nuHeapSize * sizeof(Photon)); for (i = 0, p = nuHeap; i < nuHeapSize; i++, p++) { ray.ro = NULL; @@ -285,12 +290,14 @@ static void preComputeGlobal (PhotonMap *pmap) if (photonRepTime > 0 && time(NULL) >= repLastTime + photonRepTime) pmapPreCompReport(); -#ifndef BSD - else signal(SIGCONT, pmapPreCompReport); -#endif + #ifdef SIGCONT + else signal(SIGCONT, pmapPreCompReport); + #endif } - signal(SIGCONT, SIG_DFL); + #ifdef SIGCONT + signal(SIGCONT, SIG_DFL); + #endif /* Replace & rebuild heap */ free(pmap -> heap); @@ -401,7 +408,9 @@ void distribPhotons (PhotonMap **pmaps) /* Record start time and enable progress report signal handler */ repStartTime = time(NULL); - signal(SIGCONT, pmapDistribReport); + #ifdef SIGCONT + signal(SIGCONT, pmapDistribReport); + #endif repProgress = prePassCnt = 0; if (photonRepTime) @@ -500,7 +509,7 @@ void distribPhotons (PhotonMap **pmaps) for (srcIdx = 0; srcIdx < nsources; srcIdx++) { unsigned portCnt = 0; emap.src = source + srcIdx; - + do { emap.port = emap.src -> sflags & SDISTANT ? photonPorts + portCnt : NULL; @@ -561,7 +570,7 @@ void distribPhotons (PhotonMap **pmaps) if (photonRepTime > 0 && time(NULL) >= repLastTime + photonRepTime) pmapDistribReport(); - #ifndef BSD + #ifdef SIGCONT else signal(SIGCONT, pmapDistribReport); #endif } @@ -591,7 +600,9 @@ void distribPhotons (PhotonMap **pmaps) /* =================================================================== * POST-DISTRIBUTION - Set photon flux and build kd-tree, etc. * =================================================================== */ - signal(SIGCONT, SIG_DFL); + #ifdef SIGCONT + signal(SIGCONT, SIG_DFL); + #endif free(emap.samples); /* Set photon flux (repProgress is total num emitted) */