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.35 by greg, Thu Aug 27 04:33:31 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 298 | Line 298 | mBSDF_color(float coef[], const SDMat *dp, int i, int
298          if (dp->chroma == NULL)
299                  return 1;       /* grayscale */
300  
301 <        c_decodeChroma(&cxy, dp->chroma[o*dp->ninc + i]);
301 >        c_decodeChroma(&cxy, mBSDF_chroma(dp,i,o));
302          c_toSharpRGB(&cxy, coef[0], coef);
303          coef[0] *= mtx_RGB_coef[0];
304          coef[1] *= mtx_RGB_coef[1];
# Line 622 | Line 622 | subtract_min(C_COLOR *cs, SDMat *sm)
622                                  coef[c] = (coef[c] - min_coef[c]) /
623                                                  mtx_RGB_coef[c];
624                          if (c_fromSharpRGB(coef, &cxy) > 1e-5)
625 <                                sm->chroma[o*sm->ninc + i] = c_encodeChroma(&cxy);
625 >                                mBSDF_chroma(sm,i,o) = c_encodeChroma(&cxy);
626                          mBSDF_value(sm,i,o) -= ymin;
627                  }
628                                          /* return colored minimum */
# 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