ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapsrc.c
(Generate patch)

Comparing ray/src/rt/pmapsrc.c (file contents):
Revision 2.2 by greg, Tue Apr 21 19:16:51 2015 UTC vs.
Revision 2.9 by rschregle, Tue Sep 22 15:08:31 2015 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char RCSid[] = "$Id$";
3 + #endif
4   /*
5     ==================================================================
6     Photon map support routines for emission from light sources
7  
8     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
9     (c) Fraunhofer Institute for Solar Energy Systems,
10 <       Lucerne University of Applied Sciences & Arts  
10 >   (c) Lucerne University of Applied Sciences and Arts,
11 >   supported by the Swiss National Science Foundation (SNSF, #147053)
12     ==================================================================
13 <  
10 <   $Id$
13 >
14   */
15  
16  
# Line 531 | Line 534 | void getPhotonPorts ()
534     for (i = 0; i < nobjects; i++) {
535        obj = objptr(i);
536        
537 <      if (inset(ambset, obj -> omod)) {
537 >      /* Check if object is a surface and resolve its material via any
538 >       * aliases, then check for inclusion in port modifier list */
539 >      if (issurface(obj -> otype) &&
540 >          inset(ambset, objndx(findmaterial(obj)))) {
541           /* Add photon port */
542           photonPorts = (SRCREC*)realloc(photonPorts,
543                                          (numPhotonPorts + 1) *
# Line 591 | Line 597 | void initPhotonEmission (EmissionMap *emap, float numP
597     unsigned i, t, p;
598     double phi, cosTheta, sinTheta, du, dv, dOmega, thetaScale;
599     EmissionSample* sample;
600 <   const OBJREC* mod =  objptr(emap -> src -> so -> omod);
600 >   const OBJREC* mod =  findmaterial(emap -> src -> so);
601     static RAY r;
602   #if 0  
603     static double lastCosNorm = FHUGE;
604     static SRCREC *lastSrc = NULL, *lastPort = NULL;
605   #endif  
606  
607 +   setcolor(emap -> partFlux, 0, 0, 0);
608 +
609     photonOrigin [emap -> src -> so -> otype] (emap);
610     cosTheta = DOT(emap -> ws, emap -> wh);
611  
# Line 620 | Line 628 | void initPhotonEmission (EmissionMap *emap, float numP
628   #endif
629          
630     /* Need to recompute flux & PDF */
623   setcolor(emap -> partFlux, 0, 0, 0);
631     emap -> cdf = 0;
632     emap -> numSamples = 0;
633    
# Line 669 | Line 676 | void initPhotonEmission (EmissionMap *emap, float numP
676          
677        VCOPY(r.rorg, emap -> photonOrg);
678        VCOPY(r.rop, emap -> photonOrg);
679 <      r.rmax = FHUGE;
679 >      r.rmax = 0;
680        
681        for (t = 0; t < emap -> numTheta; t++) {
682           for (p = 0; p < emap -> numPhi; p++) {
# Line 739 | Line 746 | void emitPhoton (const EmissionMap* emap, RAY* ray)
746     unsigned long i, lo, hi;
747     const EmissionSample* sample = emap -> samples;
748     RREAL du, dv, cosTheta, cosThetaSqr, sinTheta, phi;  
749 <   const OBJREC* mod = objptr(emap -> src -> so -> omod);
749 >   const OBJREC* mod = findmaterial(emap -> src -> so);
750    
751     /* Choose a new origin within current partition for every
752        emitted photon to break up clustering artifacts */
753     photonOrigin [emap -> src -> so -> otype] ((EmissionMap*)emap);
754 +   /* If we have a local glow source with a maximum radius, then
755 +      restrict our photon to the specified distance (otherwise no limit) */
756 +   if (mod -> otype == MAT_GLOW && !(emap -> src -> sflags & SDISTANT)
757 +                && mod -> oargs.farg[3] > FTINY)
758 +      ray -> rmax = mod -> oargs.farg[3];
759 +   else
760 +      ray -> rmax = 0;
761     rayorigin(ray, PRIMARY, NULL, NULL);
748   ray -> rmax = FHUGE;
762    
763     if (!emap -> numSamples) {
764        /* Source is unmodified and has no port, and either local with

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines