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

Comparing ray/src/common/bsdf_m.c (file contents):
Revision 3.31 by greg, Mon Apr 6 16:00:15 2015 UTC vs.
Revision 3.34 by greg, Sun Aug 23 00:56:00 2015 UTC

# Line 132 | Line 132 | SDfreeMatrix(void *ptr)
132          free(ptr);
133   }
134  
135 + /* compute square of real value */
136 + static double sq(double x) { return x*x; }
137 +
138   /* Get vector for this angle basis index (front exiting) */
139   int
140   fo_getvec(FVECT v, double ndxr, void *p)
# Line 141 | Line 144 | fo_getvec(FVECT v, double ndxr, void *p)
144          double          randX = ndxr - ndx;
145          double          rx[2];
146          int             li;
147 <        double          pol, azi, d;
147 >        double          azi, d;
148          
149          if ((ndxr < 0) | (ndx >= ab->nangles))
150                  return RC_FAIL;
151          for (li = 0; ndx >= ab->lat[li].nphis; li++)
152                  ndx -= ab->lat[li].nphis;
153          SDmultiSamp(rx, 2, randX);
154 <        pol = M_PI/180.*( (1.-rx[0])*ab->lat[li].tmin +
155 <                                rx[0]*ab->lat[li+1].tmin );
154 >        d = (1. - rx[0])*sq(cos(M_PI/180.*ab->lat[li].tmin)) +
155 >                rx[0]*sq(cos(M_PI/180.*ab->lat[li+1].tmin));
156 >        v[2] = d = sqrt(d);     /* cos(pol) */
157          azi = 2.*M_PI*(ndx + rx[1] - .5)/ab->lat[li].nphis;
154        v[2] = d = cos(pol);
158          d = sqrt(1. - d*d);     /* sin(pol) */
159          v[0] = cos(azi)*d;
160          v[1] = sin(azi)*d;
# Line 184 | Line 187 | fo_getndx(const FVECT v, void *p)
187          return ndx;
188   }
189  
187 /* compute square of real value */
188 static double sq(double x) { return x*x; }
189
190   /* Get projected solid angle for this angle basis index (universal) */
191   double
192   io_getohm(int ndx, void *p)
# Line 849 | Line 849 | SDgetMtxCDist(const FVECT inVec, SDComponent *sdc)
849                  reverse = 1;
850          }
851          cdlast = NULL;                  /* check for it in cache list */
852 +        /* PLACE MUTEX LOCK HERE FOR THREAD-SAFE */
853          for (cd = (SDMatCDst *)sdc->cdList; cd != NULL;
854                                          cdlast = cd, cd = cd->next)
855                  if (cd->indx == myCD.indx && (cd->calen == myCD.calen) &
# Line 872 | Line 873 | SDgetMtxCDist(const FVECT inVec, SDComponent *sdc)
873                  cd->next = (SDMatCDst *)sdc->cdList;
874                  sdc->cdList = (SDCDst *)cd;
875          }
876 +        /* END MUTEX LOCK */
877          return (SDCDst *)cd;            /* ready to go */
878   }
879  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines