399 |
|
SDSpectralDF *df; |
400 |
|
SDMat *dp; |
401 |
|
char *sdata; |
402 |
– |
int tfront; |
402 |
|
int inbi, outbi; |
403 |
|
int i; |
404 |
|
/* allocate BSDF component */ |
407 |
|
return RC_FAIL; |
408 |
|
/* |
409 |
|
* Remember that front and back are reversed from WINDOW 6 orientations |
411 |
– |
* Favor their "Front" (incoming light) since that's more often valid |
410 |
|
*/ |
411 |
< |
tfront = !strcasecmp(sdata, "Transmission Back"); |
412 |
< |
if (!strcasecmp(sdata, "Transmission Front") || |
413 |
< |
tfront & (sd->tf == NULL)) { |
411 |
> |
if (!strcasecmp(sdata, "Transmission Front")) { |
412 |
> |
if (sd->tb != NULL) |
413 |
> |
SDfreeSpectralDF(sd->tb); |
414 |
> |
if ((sd->tb = SDnewSpectralDF(1)) == NULL) |
415 |
> |
return RC_MEMERR; |
416 |
> |
df = sd->tb; |
417 |
> |
} else if (!strcasecmp(sdata, "Transmission Back")) { |
418 |
|
if (sd->tf != NULL) |
419 |
|
SDfreeSpectralDF(sd->tf); |
420 |
|
if ((sd->tf = SDnewSpectralDF(1)) == NULL) |
421 |
|
return RC_MEMERR; |
422 |
|
df = sd->tf; |
423 |
|
} else if (!strcasecmp(sdata, "Reflection Front")) { |
424 |
< |
if (sd->rb != NULL) /* note back-front reversal */ |
424 |
> |
if (sd->rb != NULL) |
425 |
|
SDfreeSpectralDF(sd->rb); |
426 |
|
if ((sd->rb = SDnewSpectralDF(1)) == NULL) |
427 |
|
return RC_MEMERR; |
428 |
|
df = sd->rb; |
429 |
|
} else if (!strcasecmp(sdata, "Reflection Back")) { |
430 |
< |
if (sd->rf != NULL) /* note front-back reversal */ |
430 |
> |
if (sd->rf != NULL) |
431 |
|
SDfreeSpectralDF(sd->rf); |
432 |
|
if ((sd->rf = SDnewSpectralDF(1)) == NULL) |
433 |
|
return RC_MEMERR; |
469 |
|
dp->ib_priv = &abase_list[inbi]; |
470 |
|
dp->ob_priv = &abase_list[outbi]; |
471 |
|
if (df == sd->tf) { |
472 |
< |
if (tfront) { |
473 |
< |
dp->ib_vec = &fi_getvec; |
474 |
< |
dp->ib_ndx = &fi_getndx; |
475 |
< |
dp->ob_vec = &bo_getvec; |
476 |
< |
dp->ob_ndx = &bo_getndx; |
477 |
< |
} else { |
478 |
< |
dp->ib_vec = &bi_getvec; |
479 |
< |
dp->ib_ndx = &bi_getndx; |
480 |
< |
dp->ob_vec = &fo_getvec; |
479 |
< |
dp->ob_ndx = &fo_getndx; |
480 |
< |
} |
472 |
> |
dp->ib_vec = &fi_getvec; |
473 |
> |
dp->ib_ndx = &fi_getndx; |
474 |
> |
dp->ob_vec = &bo_getvec; |
475 |
> |
dp->ob_ndx = &bo_getndx; |
476 |
> |
} else if (df == sd->tb) { |
477 |
> |
dp->ib_vec = &bi_getvec; |
478 |
> |
dp->ib_ndx = &bi_getndx; |
479 |
> |
dp->ob_vec = &fo_getvec; |
480 |
> |
dp->ob_ndx = &fo_getndx; |
481 |
|
} else if (df == sd->rf) { |
482 |
|
dp->ib_vec = &fi_getvec; |
483 |
|
dp->ib_ndx = &fi_getndx; |
616 |
|
/* separate diffuse components */ |
617 |
|
extract_diffuse(&sd->rLambFront, sd->rf); |
618 |
|
extract_diffuse(&sd->rLambBack, sd->rb); |
619 |
< |
extract_diffuse(&sd->tLamb, sd->tf); |
619 |
> |
extract_diffuse(&sd->tLamb, (sd->tf != NULL) ? sd->tf : sd->tb); |
620 |
|
/* return success */ |
621 |
|
return SDEnone; |
622 |
|
} |