158 |
|
return(set_modval(mp, lastmod(objndx(wp->mtp), mp->nam), wp->rp)); |
159 |
|
} |
160 |
|
|
161 |
+ |
/* set calculation context for given component of MAT_WGMDF */ |
162 |
|
static int |
163 |
|
setWGMDfunc(MODVAL *mp, const WGMDDAT *wp) |
164 |
|
{ |
165 |
< |
static char lastMod[MAXSTR] = ""; |
165 |
> |
static char lastMod[MAXSTR]; |
166 |
|
double sf; |
167 |
|
FVECT vec; |
168 |
|
|
169 |
|
if (setfunc(wp->mtp, wp->rp) == 0 && |
170 |
|
!strcmp(mp->nam, lastMod)) |
171 |
|
return(0); /* already set */ |
171 |
– |
/* else (re)assign special variables */ |
172 |
|
strcpy(lastMod, mp->nam); |
173 |
< |
sf = (wp->rp->rod > 0) ? 1. : -1.; |
174 |
< |
varset("RdotP`", '=', (-1. < mp->pdot) & (mp->pdot < 1.) |
175 |
< |
? sf*mp->pdot : 1.); |
176 |
< |
sf /= funcxf.sca; |
173 |
> |
/* else (re)assign special variables */ |
174 |
> |
sf = 1 - 2*(wp->rp->rod < 0); |
175 |
> |
varset("RdotP`", '=', mp->pdot*sf); |
176 |
|
multv3(vec, mp->pnorm, funcxf.xfm); |
177 |
+ |
sf /= funcxf.sca; |
178 |
|
varset("NxP`", '=', vec[0]*sf); |
179 |
|
varset("NyP`", '=', vec[1]*sf); |
180 |
|
varset("NzP`", '=', vec[2]*sf); |
213 |
|
static void |
214 |
|
set_scomp(WGMDDAT *wp, int trans) |
215 |
|
{ |
216 |
< |
SCOMP *sp = trans ? &wp->ts : &wp->rs; |
217 |
< |
const int eoff = 3*(trans != 0); |
218 |
< |
double coef; |
216 |
> |
SCOMP *sp = trans ? &wp->ts : &wp->rs; |
217 |
> |
EPNODE **exa = wp->mf->ep + 3*(trans != 0); |
218 |
> |
double coef; |
219 |
|
/* constant zero check */ |
220 |
< |
if (wp->mf->ep[eoff]->type == NUM && |
221 |
< |
wp->mf->ep[eoff]->v.num <= FTINY) { |
220 |
> |
if (exa[0]->type == NUM && exa[0]->v.num <= FTINY) { |
221 |
|
scolorblack(sp->scol); |
222 |
|
return; |
223 |
|
} /* need modifier */ |
229 |
|
} |
230 |
|
setWGMDfunc(&sp->mo, wp); |
231 |
|
errno = 0; |
232 |
< |
coef = evalue(wp->mf->ep[eoff]); |
232 |
> |
coef = evalue(exa[0]); |
233 |
|
if ((errno == EDOM) | (errno == ERANGE)) { |
234 |
|
objerror(wp->mtp, WARNING, "specular compute error"); |
235 |
|
scolorblack(sp->scol); |
246 |
|
return; /* got black pattern */ |
247 |
|
} |
248 |
|
errno = 0; /* else get roughness */ |
249 |
< |
sp->u_alpha = evalue(wp->mf->ep[eoff+1]); |
250 |
< |
sp->v_alpha = (sp->u_alpha > FTINY) ? evalue(wp->mf->ep[eoff+2]) : 0.0; |
249 |
> |
sp->u_alpha = evalue(exa[1]); |
250 |
> |
sp->v_alpha = (sp->u_alpha > FTINY) ? evalue(exa[2]) : 0.0; |
251 |
|
if ((errno == EDOM) | (errno == ERANGE)) { |
252 |
|
objerror(wp->mtp, WARNING, "roughness compute error"); |
253 |
|
scolorblack(sp->scol); |