| 14 |
|
char * |
| 15 |
|
transSDError(SDError ec) |
| 16 |
|
{ |
| 17 |
– |
static char mymess[128]; |
| 18 |
– |
|
| 17 |
|
if (!SDerrorDetail[0]) |
| 18 |
< |
return(strcpy(mymess, SDerrorEnglish[ec])); |
| 19 |
< |
sprintf(mymess, "%s: %s", SDerrorEnglish[ec], SDerrorDetail); |
| 20 |
< |
return(mymess); |
| 18 |
> |
return(strcpy(errmsg, SDerrorList[ec])); |
| 19 |
> |
|
| 20 |
> |
sprintf(errmsg, "%s: %s", SDerrorList[ec], SDerrorDetail); |
| 21 |
> |
return(errmsg); |
| 22 |
|
} |
| 23 |
|
|
| 24 |
|
/* Make sure we're not over 100% scattering for this component */ |
| 35 |
|
|
| 36 |
|
/* Load a BSDF file and perform some basic checks */ |
| 37 |
|
SDData * |
| 38 |
< |
loadBSDF(char *name) |
| 38 |
> |
loadBSDF(char *fname) |
| 39 |
|
{ |
| 40 |
< |
SDData *sd = SDgetCache(name); |
| 40 |
> |
SDData *sd; |
| 41 |
|
SDError ec; |
| 42 |
|
char *pname; |
| 43 |
|
|
| 44 |
+ |
sd = SDgetCache(fname); /* look up or allocate */ |
| 45 |
|
if (sd == NULL) |
| 46 |
|
error(SYSTEM, "out of memory in loadBSDF"); |
| 47 |
< |
if (SDisLoaded(sd)) |
| 47 |
> |
if (SDisLoaded(sd)) /* already in memory? */ |
| 48 |
|
return(sd); |
| 49 |
< |
|
| 50 |
< |
pname = getpath(name, getrlibpath(), R_OK); |
| 49 |
> |
/* else find and load it */ |
| 50 |
> |
pname = getpath(fname, getrlibpath(), R_OK); |
| 51 |
|
if (pname == NULL) { |
| 52 |
< |
sprintf(errmsg, "cannot find BSDF file \"%s\"", name); |
| 53 |
< |
error(USER, errmsg); |
| 52 |
> |
sprintf(errmsg, "cannot find BSDF file \"%s\"", fname); |
| 53 |
> |
error(SYSTEM, errmsg); |
| 54 |
|
} |
| 55 |
|
ec = SDloadFile(sd, pname); |
| 56 |
|
if (ec) |
| 57 |
|
error(USER, transSDError(ec)); |
| 58 |
|
/* simple checks */ |
| 59 |
< |
checkDF(name, sd->rLambFront.cieY, sd->rf, "front reflection"); |
| 60 |
< |
checkDF(name, sd->rLambBack.cieY, sd->rb, "rear reflection"); |
| 61 |
< |
checkDF(name, sd->tLamb.cieY, sd->tf, "transmission"); |
| 62 |
< |
|
| 59 |
> |
checkDF(sd->name, sd->rLambFront.cieY, sd->rf, "front reflection"); |
| 60 |
> |
checkDF(sd->name, sd->rLambBack.cieY, sd->rb, "rear reflection"); |
| 61 |
> |
checkDF(sd->name, sd->tLamb.cieY, sd->tf, "front transmission"); |
| 62 |
> |
checkDF(sd->name, sd->tLamb.cieY, sd->tb, "back transmission"); |
| 63 |
> |
#ifdef DEBUG |
| 64 |
> |
{ |
| 65 |
> |
float rgb[3]; |
| 66 |
> |
fprintf(stderr, "Loaded BSDF '%s' (file \"%s\")\n", sd->name, pname); |
| 67 |
> |
ccy2rgb(&sd->rLambFront.spec, sd->rLambFront.cieY, rgb); |
| 68 |
> |
fprintf(stderr, "Front diffuse RGB: %.4f %.4f %.4f\n", rgb[0], rgb[1], rgb[2]); |
| 69 |
> |
ccy2rgb(&sd->rLambBack.spec, sd->rLambBack.cieY, rgb); |
| 70 |
> |
fprintf(stderr, "Back diffuse RGB: %.4f %.4f %.4f\n", rgb[0], rgb[1], rgb[2]); |
| 71 |
> |
ccy2rgb(&sd->tLamb.spec, sd->tLamb.cieY, rgb); |
| 72 |
> |
fprintf(stderr, "Diffuse RGB transmittance: %.4f %.4f %.4f\n", rgb[0], rgb[1], rgb[2]); |
| 73 |
> |
if (sd->rf) |
| 74 |
> |
fprintf(stderr, "Maximum direct hemispherical front reflection: %.3f%%\n", |
| 75 |
> |
sd->rf->maxHemi*100.); |
| 76 |
> |
if (sd->rb) |
| 77 |
> |
fprintf(stderr, "Maximum direct hemispherical back reflection: %.3f%%\n", |
| 78 |
> |
sd->rb->maxHemi*100.); |
| 79 |
> |
if (sd->tf) |
| 80 |
> |
fprintf(stderr, "Maximum direct hemispherical front transmission: %.3f%%\n", |
| 81 |
> |
sd->tf->maxHemi*100.); |
| 82 |
> |
if (sd->tb) |
| 83 |
> |
fprintf(stderr, "Maximum direct hemispherical back transmission: %.3f%%\n", |
| 84 |
> |
sd->tb->maxHemi*100.); |
| 85 |
> |
} |
| 86 |
> |
#endif |
| 87 |
|
SDretainSet = SDretainAll; /* keep data in core */ |
| 88 |
+ |
#ifdef SMLMEM |
| 89 |
+ |
SDmaxCache = 5L*1024*1024; |
| 90 |
+ |
#else |
| 91 |
+ |
SDmaxCache = 250L*1024*1024; |
| 92 |
+ |
#endif |
| 93 |
|
return(sd); |
| 94 |
|
} |