| 43 |
|
{ |
| 44 |
|
int i; |
| 45 |
|
register OBJREC *o, *m; |
| 46 |
< |
register SRCREC *ns; |
| 46 |
> |
register int ns; |
| 47 |
|
/* initialize dispatch table */ |
| 48 |
|
initstypes(); |
| 49 |
|
/* find direct sources */ |
| 72 |
|
sfun[o->otype].of->setsrc == NULL) |
| 73 |
|
objerror(o, USER, "illegal material"); |
| 74 |
|
|
| 75 |
< |
if ((ns = newsource()) == NULL) |
| 75 |
> |
if ((ns = newsource()) < 0) |
| 76 |
|
goto memerr; |
| 77 |
|
|
| 78 |
< |
(*sfun[o->otype].of->setsrc)(ns, o); |
| 78 |
> |
setsource(&source[ns], o); |
| 79 |
|
|
| 80 |
|
if (m->otype == MAT_GLOW) { |
| 81 |
< |
ns->sflags |= SPROX; |
| 82 |
< |
ns->sl.prox = m->oargs.farg[3]; |
| 81 |
> |
source[ns].sflags |= SPROX; |
| 82 |
> |
source[ns].sl.prox = m->oargs.farg[3]; |
| 83 |
|
if (o->otype == OBJ_SOURCE) |
| 84 |
< |
ns->sflags |= SSKIP; |
| 84 |
> |
source[ns].sflags |= SSKIP; |
| 85 |
|
} else if (m->otype == MAT_SPOT) { |
| 86 |
< |
ns->sflags |= SSPOT; |
| 87 |
< |
if ((ns->sl.s = makespot(m)) == NULL) |
| 86 |
> |
source[ns].sflags |= SSPOT; |
| 87 |
> |
if ((source[ns].sl.s = makespot(m)) == NULL) |
| 88 |
|
goto memerr; |
| 89 |
+ |
if (source[ns].sflags & SFLAT && |
| 90 |
+ |
!checkspot(source[ns].sl.s,source[ns].snorm)) { |
| 91 |
+ |
objerror(o, WARNING, |
| 92 |
+ |
"invalid spotlight direction"); |
| 93 |
+ |
source[ns].sflags |= SSKIP; |
| 94 |
+ |
} |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
if (nsources <= 0) { |
| 101 |
|
markvirtuals(); /* find and add virtual sources */ |
| 102 |
|
srccnt = (CONTRIB *)malloc(nsources*sizeof(CONTRIB)); |
| 103 |
|
cntord = (CNTPTR *)malloc(nsources*sizeof(CNTPTR)); |
| 104 |
< |
if (srccnt != NULL && cntord != NULL) |
| 104 |
> |
if (srccnt == NULL || cntord == NULL) |
| 105 |
|
goto memerr; |
| 106 |
|
return; |
| 107 |
|
memerr: |
| 152 |
|
for (i = 0; i < 3; i++) { |
| 153 |
|
dimlist[ndims] = i + 8831; |
| 154 |
|
vd[i] = dstrsrc * source[sn].ss * |
| 155 |
< |
(1.0 - 2.0*urand(ilhash(dimlist,ndims+1)+samplendx)); |
| 155 |
> |
(1.0 - 2.0*urand(urind(ilhash(dimlist,ndims+1),samplendx))); |
| 156 |
|
} |
| 157 |
|
ndims--; |
| 158 |
|
if (source[sn].sflags & SFLAT) { /* project offset */ |