8 |
|
#include "copyright.h" |
9 |
|
|
10 |
|
#include "ray.h" |
11 |
– |
#include "paths.h" |
11 |
|
#include "ambient.h" |
12 |
|
#include "source.h" |
13 |
|
#include "func.h" |
64 |
|
|
65 |
|
#define cvt_sdcolor(cv, svp) ccy2rgb(&(svp)->spec, (svp)->cieY, cv) |
66 |
|
|
68 |
– |
/* Convert error from BSDF library */ |
69 |
– |
static char * |
70 |
– |
cvt_sderr(SDError ec) |
71 |
– |
{ |
72 |
– |
if (!SDerrorDetail[0]) |
73 |
– |
return(strcpy(errmsg, SDerrorEnglish[ec])); |
74 |
– |
sprintf(errmsg, "%s: %s", SDerrorEnglish[ec], SDerrorDetail); |
75 |
– |
return(errmsg); |
76 |
– |
} |
77 |
– |
|
67 |
|
/* Compute source contribution for BSDF */ |
68 |
|
static void |
69 |
|
dirbsdf( |
112 |
|
return; |
113 |
|
ec = SDevalBSDF(&sv, vout, np->vinc, np->sd); |
114 |
|
if (ec) |
115 |
< |
objerror(np->mp, USER, cvt_sderr(ec)); |
115 |
> |
objerror(np->mp, USER, transSDError(ec)); |
116 |
|
|
117 |
|
if (sv.cieY <= FTINY) /* not worth using? */ |
118 |
|
return; |
163 |
|
: urand(ilhash(dimlist,ndims)+samplendx), |
164 |
|
dcp); |
165 |
|
if (ec) |
166 |
< |
objerror(ndp->mp, USER, cvt_sderr(ec)); |
166 |
> |
objerror(ndp->mp, USER, transSDError(ec)); |
167 |
|
/* zero component? */ |
168 |
|
if (bsv.cieY <= FTINY) |
169 |
|
break; |
262 |
|
(m->oargs.nfargs % 3)) |
263 |
|
objerror(m, USER, "bad # arguments"); |
264 |
|
|
265 |
< |
SDerrorDetail[0] = '\0'; /* get BSDF data */ |
266 |
< |
nd.sd = SDgetCache(m->oargs.sarg[1]); |
278 |
< |
if (nd.sd == NULL) |
279 |
< |
error(SYSTEM, "out of memory in m_bsdf"); |
280 |
< |
if (!SDisLoaded(nd.sd)) { |
281 |
< |
char *pname = getpath(m->oargs.sarg[1], getrlibpath(), R_OK); |
282 |
< |
if (pname == NULL) { |
283 |
< |
sprintf(errmsg, "cannot find BSDF file \"%s\"", |
284 |
< |
m->oargs.sarg[1]); |
285 |
< |
objerror(m, USER, errmsg); |
286 |
< |
} |
287 |
< |
ec = SDloadFile(nd.sd, pname); |
288 |
< |
if (ec) |
289 |
< |
objerror(m, USER, cvt_sderr(ec)); |
290 |
< |
SDretainSet = SDretainAll; |
291 |
< |
} |
265 |
> |
/* get BSDF data */ |
266 |
> |
nd.sd = loadBSDF(m->oargs.sarg[1]); |
267 |
|
/* load cal file */ |
268 |
|
mf = getfunc(m, 5, 0x1d, 1); |
269 |
|
/* get thickness */ |
348 |
|
if (!ec) |
349 |
|
ec = SDinvXform(nd.fromloc, nd.toloc); |
350 |
|
if (ec) { |
351 |
< |
objerror(m, WARNING, cvt_sderr(ec)); |
351 |
> |
objerror(m, WARNING, transSDError(ec)); |
352 |
|
SDfreeCache(nd.sd); |
353 |
|
return(1); |
354 |
|
} |