--- ray/src/common/bsdf_t.c 2015/04/06 18:28:35 3.40 +++ ray/src/common/bsdf_t.c 2018/01/05 21:00:24 3.45 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf_t.c,v 3.40 2015/04/06 18:28:35 greg Exp $"; +static const char RCSid[] = "$Id: bsdf_t.c,v 3.45 2018/01/05 21:00:24 greg Exp $"; #endif /* * bsdf_t.c @@ -569,12 +569,12 @@ SDqueryTre(const SDTre *sdt, float *coef, return 0; /* should be internal error */ /* get BSDF value */ yval = SDlookupTre(sdt->stc[tt_Y], gridPos, hc); + if (coef == NULL) /* just getting hypercube? */ + return 1; if (sdt->stc[tt_u] == NULL || sdt->stc[tt_v] == NULL) { - if (coef != NULL) *coef = yval; + *coef = yval; return 1; /* no color */ } - if (coef == NULL) /* just getting hypercube? */ - return 1; /* else decode color */ SDyuv2rgb(yval, SDlookupTre(sdt->stc[tt_u], gridPos, NULL), SDlookupTre(sdt->stc[tt_v], gridPos, NULL), coef); @@ -789,6 +789,7 @@ SDgetTreCDist(const FVECT inVec, SDComponent *sdc) for (i = sdt->stc[tt_Y]->ndim - 2; i--; ) inCoord[i] = floor(inCoord[i]/quantum)*quantum + .5*quantum; cdlast = NULL; /* check for direction in cache list */ + /* PLACE MUTEX LOCK HERE FOR THREAD-SAFE */ for (cd = (SDTreCDst *)sdc->cdList; cd != NULL; cdlast = cd, cd = cd->next) { if (cd->sidef != mode) @@ -807,6 +808,7 @@ SDgetTreCDist(const FVECT inVec, SDComponent *sdc) cd->next = (SDTreCDst *)sdc->cdList; sdc->cdList = (SDCDst *)cd; } + /* END MUTEX LOCK */ return (SDCDst *)cd; /* ready to go */ } @@ -924,7 +926,7 @@ next_token(char **spp) } /* Advance pointer past matching token (or any token if c==0) */ -#define eat_token(spp,c) (next_token(spp)==(c) ^ !(c) ? *(*(spp))++ : 0) +#define eat_token(spp,c) ((next_token(spp)==(c)) ^ !(c) ? *(*(spp))++ : 0) /* Count words from this point in string to '}' */ static int @@ -1354,7 +1356,7 @@ extract_diffuse(SDValue *dv, SDSpectralDF *df) memcpy(df->comp[0].cspec, tt_RGB_prim, sizeof(tt_RGB_prim)); dv->cieY = subtract_min_RGB(&dv->spec, sdt->stc); } else { - df->comp[0].cspec[0] = c_dfcolor; + df->comp[0].cspec[0] = dv->spec = c_dfcolor; dv->cieY = subtract_min_Y(sdt->stc[tt_Y]); } df->maxHemi -= dv->cieY; /* adjust maximum hemispherical */ @@ -1419,7 +1421,7 @@ SDloadTre(SDData *sd, ezxml_t wtl) } /* Variable resolution BSDF methods */ -SDFunc SDhandleTre = { +const SDFunc SDhandleTre = { &SDgetTreBSDF, &SDqueryTreProjSA, &SDgetTreCDist,