| 35 |
|
"Unknown error" |
| 36 |
|
}; |
| 37 |
|
|
| 38 |
+ |
/* Pointer to error list in preferred language */ |
| 39 |
+ |
const char **SDerrorList = SDerrorEnglish; |
| 40 |
+ |
|
| 41 |
|
/* Additional information on last error (ASCII English) */ |
| 42 |
|
char SDerrorDetail[256]; |
| 43 |
|
|
| 50 |
|
/* Retain BSDFs in cache list */ |
| 51 |
|
int SDretainSet = SDretainNone; |
| 52 |
|
|
| 53 |
< |
/* Report any error to the indicated stream (in English) */ |
| 53 |
> |
/* Report any error to the indicated stream */ |
| 54 |
|
SDError |
| 55 |
< |
SDreportEnglish(SDError ec, FILE *fp) |
| 55 |
> |
SDreportError(SDError ec, FILE *fp) |
| 56 |
|
{ |
| 57 |
|
if (!ec) |
| 58 |
|
return SDEnone; |
| 62 |
|
} |
| 63 |
|
if (fp == NULL) |
| 64 |
|
return ec; |
| 65 |
< |
fputs(SDerrorEnglish[ec], fp); |
| 65 |
> |
fputs(SDerrorList[ec], fp); |
| 66 |
|
if (SDerrorDetail[0]) { |
| 67 |
|
fputs(": ", fp); |
| 68 |
|
fputs(SDerrorDetail, fp); |
| 199 |
|
} |
| 200 |
|
wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer"); |
| 201 |
|
if (wtl == NULL) { |
| 202 |
< |
sprintf(SDerrorDetail, "BSDF \"%s\": no optical layers'", |
| 202 |
> |
sprintf(SDerrorDetail, "BSDF \"%s\": no optical layers", |
| 203 |
|
sd->name); |
| 204 |
|
ezxml_free(fl); |
| 205 |
|
return SDEformat; |
| 423 |
|
return NULL; |
| 424 |
|
SDerrorDetail[0] = '\0'; |
| 425 |
|
if ((sd = SDgetCache(fname)) == NULL) { |
| 426 |
< |
SDreportEnglish(SDEmemory, stderr); |
| 426 |
> |
SDreportError(SDEmemory, stderr); |
| 427 |
|
return NULL; |
| 428 |
|
} |
| 429 |
|
if (!SDisLoaded(sd) && (ec = SDloadFile(sd, fname))) { |
| 430 |
< |
SDreportEnglish(ec, stderr); |
| 430 |
> |
SDreportError(ec, stderr); |
| 431 |
|
SDfreeCache(sd); |
| 432 |
|
return NULL; |
| 433 |
|
} |
| 488 |
|
return SDEargument; |
| 489 |
|
/* get cumulative distribution */ |
| 490 |
|
VCOPY(inVec, ioVec); |
| 491 |
+ |
sv->cieY = 0; |
| 492 |
|
cd = (*sdc->func->getCDist)(inVec, sdc); |
| 493 |
< |
if (cd == NULL) |
| 494 |
< |
return SDEmemory; |
| 495 |
< |
if (cd->cTotal <= 1e-6) { /* anything to sample? */ |
| 493 |
> |
if (cd != NULL) |
| 494 |
> |
sv->cieY = cd->cTotal; |
| 495 |
> |
if (sv->cieY <= 1e-6) { /* nothing to sample? */ |
| 496 |
|
sv->spec = c_dfcolor; |
| 493 |
– |
sv->cieY = .0; |
| 497 |
|
memset(ioVec, 0, 3*sizeof(double)); |
| 498 |
|
return SDEnone; |
| 499 |
|
} |
| 497 |
– |
sv->cieY = cd->cTotal; |
| 500 |
|
/* compute sample direction */ |
| 501 |
|
ec = (*sdc->func->sampCDist)(ioVec, randX, cd); |
| 502 |
|
if (ec) |
| 558 |
|
SDmultiSamp(outVec, 2, randX); |
| 559 |
|
SDsquare2disk(outVec, outVec[0], outVec[1]); |
| 560 |
|
outVec[2] = 1. - outVec[0]*outVec[0] - outVec[1]*outVec[1]; |
| 561 |
< |
if (outVec[2] > 0) /* a bit of paranoia */ |
| 560 |
< |
outVec[2] = sqrt(outVec[2]); |
| 561 |
> |
outVec[2] = sqrt(outVec[2]*(outVec[2]>0)); |
| 562 |
|
if (!outFront) /* going out back? */ |
| 563 |
|
outVec[2] = -outVec[2]; |
| 564 |
|
} |
| 617 |
|
projSA[0] = M_PI; |
| 618 |
|
if (qflags == SDqueryMin+SDqueryMax) |
| 619 |
|
projSA[1] = M_PI; |
| 620 |
< |
} |
| 620 |
> |
} else if (qflags == SDqueryMin+SDqueryMax && projSA[0] > projSA[1]) |
| 621 |
> |
projSA[0] = projSA[1]; |
| 622 |
|
return SDEnone; |
| 623 |
|
} |
| 624 |
|
|
| 755 |
|
return SDEmemory; |
| 756 |
|
while (j-- > 0) { /* non-diffuse transmission */ |
| 757 |
|
cdarr[i+j] = (*tdf->comp[j].func->getCDist)(inVec, &tdf->comp[j]); |
| 758 |
< |
if (cdarr[i+j] == NULL) { |
| 759 |
< |
free(cdarr); |
| 758 |
< |
return SDEmemory; |
| 759 |
< |
} |
| 758 |
> |
if (cdarr[i+j] == NULL) |
| 759 |
> |
cdarr[i+j] = &SDemptyCD; |
| 760 |
|
sv->cieY += cdarr[i+j]->cTotal; |
| 761 |
|
} |
| 762 |
|
while (i-- > 0) { /* non-diffuse reflection */ |
| 763 |
|
cdarr[i] = (*rdf->comp[i].func->getCDist)(inVec, &rdf->comp[i]); |
| 764 |
< |
if (cdarr[i] == NULL) { |
| 765 |
< |
free(cdarr); |
| 766 |
< |
return SDEmemory; |
| 767 |
< |
} |
| 764 |
> |
if (cdarr[i] == NULL) |
| 765 |
> |
cdarr[i] = &SDemptyCD; |
| 766 |
|
sv->cieY += cdarr[i]->cTotal; |
| 767 |
|
} |
| 768 |
|
if (sv->cieY <= 1e-6) { /* anything to sample? */ |
| 788 |
|
randX -= sd->tLamb.cieY; |
| 789 |
|
} |
| 790 |
|
/* else one of cumulative dist. */ |
| 791 |
< |
for (i = 0; i < n && randX < cdarr[i]->cTotal; i++) |
| 791 |
> |
for (i = 0; i < n && randX > cdarr[i]->cTotal; i++) |
| 792 |
|
randX -= cdarr[i]->cTotal; |
| 793 |
|
if (i >= n) |
| 794 |
|
return SDEinternal; |