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.36 by greg, Fri Oct 14 00:54:21 2016 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)
193   {
194 +        static void     *last_p = NULL;
195          static int      last_li = -1;
196          static double   last_ohm;
197          ANGLE_BASIS     *ab = (ANGLE_BASIS *)p;
# Line 201 | Line 202 | io_getohm(int ndx, void *p)
202                  return -1.;
203          for (li = 0; ndx >= ab->lat[li].nphis; li++)
204                  ndx -= ab->lat[li].nphis;
205 <        if (li == last_li)                      /* cached latitude? */
205 >        if ((p == last_p) & (li == last_li))            /* cached latitude? */
206                  return last_ohm;
207 +        last_p = p;
208          last_li = li;
209          theta = M_PI/180. * ab->lat[li].tmin;
210          theta1 = M_PI/180. * ab->lat[li+1].tmin;
# Line 298 | Line 300 | mBSDF_color(float coef[], const SDMat *dp, int i, int
300          if (dp->chroma == NULL)
301                  return 1;       /* grayscale */
302  
303 <        c_decodeChroma(&cxy, dp->chroma[o*dp->ninc + i]);
303 >        c_decodeChroma(&cxy, mBSDF_chroma(dp,i,o));
304          c_toSharpRGB(&cxy, coef[0], coef);
305          coef[0] *= mtx_RGB_coef[0];
306          coef[1] *= mtx_RGB_coef[1];
# Line 622 | Line 624 | subtract_min(C_COLOR *cs, SDMat *sm)
624                                  coef[c] = (coef[c] - min_coef[c]) /
625                                                  mtx_RGB_coef[c];
626                          if (c_fromSharpRGB(coef, &cxy) > 1e-5)
627 <                                sm->chroma[o*sm->ninc + i] = c_encodeChroma(&cxy);
627 >                                mBSDF_chroma(sm,i,o) = c_encodeChroma(&cxy);
628                          mBSDF_value(sm,i,o) -= ymin;
629                  }
630                                          /* return colored minimum */
# Line 849 | Line 851 | SDgetMtxCDist(const FVECT inVec, SDComponent *sdc)
851                  reverse = 1;
852          }
853          cdlast = NULL;                  /* check for it in cache list */
854 +        /* PLACE MUTEX LOCK HERE FOR THREAD-SAFE */
855          for (cd = (SDMatCDst *)sdc->cdList; cd != NULL;
856                                          cdlast = cd, cd = cd->next)
857                  if (cd->indx == myCD.indx && (cd->calen == myCD.calen) &
# Line 872 | Line 875 | SDgetMtxCDist(const FVECT inVec, SDComponent *sdc)
875                  cd->next = (SDMatCDst *)sdc->cdList;
876                  sdc->cdList = (SDCDst *)cd;
877          }
878 +        /* END MUTEX LOCK */
879          return (SDCDst *)cd;            /* ready to go */
880   }
881  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines