| 20 |
|
#include "pmaprand.h" |
| 21 |
|
#include "otypes.h" |
| 22 |
|
|
| 23 |
< |
|
| 24 |
< |
|
| 25 |
< |
SRCREC *photonPorts = NULL; /* Photon port list */ |
| 23 |
> |
/* List of photon port modifier names */ |
| 24 |
> |
char *photonPortList [MAXSET + 1] = {NULL}; |
| 25 |
> |
/* Photon port objects (with modifiers in photonPortMods) */ |
| 26 |
> |
SRCREC *photonPorts = NULL; |
| 27 |
|
unsigned numPhotonPorts = 0; |
| 28 |
|
|
| 29 |
|
void (*photonPartition [NUMOTYPE]) (EmissionMap*); |
| 30 |
|
void (*photonOrigin [NUMOTYPE]) (EmissionMap*); |
| 31 |
|
|
| 31 |
– |
extern OBJECT ambset []; |
| 32 |
– |
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
static int flatPhotonPartition2 (EmissionMap* emap, unsigned long mp, |
| 520 |
|
|
| 521 |
|
|
| 522 |
|
|
| 523 |
< |
void getPhotonPorts () |
| 524 |
< |
/* Find geometry declared as photon ports */ |
| 523 |
> |
void getPhotonPorts (char **portList) |
| 524 |
> |
/* Find geometry declared as photon ports from modifiers in portList */ |
| 525 |
|
{ |
| 526 |
|
OBJECT i; |
| 527 |
|
OBJREC *obj, *mat; |
| 528 |
+ |
char **lp; |
| 529 |
|
|
| 530 |
|
/* Check for missing port modifiers */ |
| 531 |
< |
if (!ambset [0]) |
| 531 |
> |
if (!portList [0]) |
| 532 |
|
error(USER, "no photon ports"); |
| 533 |
|
|
| 534 |
|
for (i = 0; i < nobjects; i++) { |
| 537 |
|
|
| 538 |
|
/* Check if object is a surface and NOT a light source (duh) and |
| 539 |
|
* resolve its material via any aliases, then check for inclusion in |
| 540 |
< |
* port modifier list */ |
| 541 |
< |
if (issurface(obj -> otype) && mat && !islight(mat -> otype) && |
| 542 |
< |
inset(ambset, objndx(mat))) { |
| 543 |
< |
/* Add photon port */ |
| 544 |
< |
photonPorts = (SRCREC*)realloc(photonPorts, |
| 545 |
< |
(numPhotonPorts + 1) * |
| 546 |
< |
sizeof(SRCREC)); |
| 547 |
< |
if (!photonPorts) |
| 548 |
< |
error(USER, "can't allocate photon ports"); |
| 549 |
< |
|
| 550 |
< |
photonPorts [numPhotonPorts].so = obj; |
| 551 |
< |
photonPorts [numPhotonPorts].sflags = 0; |
| 540 |
> |
* modifier list */ |
| 541 |
> |
if (issurface(obj -> otype) && mat && !islight(mat -> otype)) { |
| 542 |
> |
for (lp = portList; *lp && strcmp(mat -> oname, *lp); lp++); |
| 543 |
|
|
| 544 |
< |
if (!sfun [obj -> otype].of || !sfun[obj -> otype].of -> setsrc) |
| 545 |
< |
objerror(obj, USER, "illegal photon port"); |
| 544 |
> |
if (*lp) { |
| 545 |
> |
/* Add photon port */ |
| 546 |
> |
photonPorts = (SRCREC*)realloc(photonPorts, |
| 547 |
> |
(numPhotonPorts + 1) * |
| 548 |
> |
sizeof(SRCREC)); |
| 549 |
> |
if (!photonPorts) |
| 550 |
> |
error(USER, "can't allocate photon ports"); |
| 551 |
|
|
| 552 |
< |
setsource(photonPorts + numPhotonPorts, obj); |
| 553 |
< |
numPhotonPorts++; |
| 552 |
> |
photonPorts [numPhotonPorts].so = obj; |
| 553 |
> |
photonPorts [numPhotonPorts].sflags = 0; |
| 554 |
> |
|
| 555 |
> |
if (!sfun [obj -> otype].of || !sfun[obj -> otype].of -> setsrc) |
| 556 |
> |
objerror(obj, USER, "illegal photon port"); |
| 557 |
> |
|
| 558 |
> |
setsource(photonPorts + numPhotonPorts, obj); |
| 559 |
> |
numPhotonPorts++; |
| 560 |
> |
} |
| 561 |
|
} |
| 562 |
|
} |
| 563 |
|
|