128 |
|
sr->rsrc = sn; /* remember source */ |
129 |
|
/* get source direction */ |
130 |
|
if (source[sn].sflags & SDISTANT) { |
131 |
– |
if (source[sn].sflags & SSPOT) { /* check location */ |
132 |
– |
for (i = 0; i < 3; i++) |
133 |
– |
vd[i] = sr->rorg[i] - source[sn].sl.s->aim[i]; |
134 |
– |
d = DOT(source[sn].sloc,vd); |
135 |
– |
d = DOT(vd,vd) - d*d; |
136 |
– |
if (PI*d > source[sn].sl.s->siz) |
137 |
– |
return(0.0); |
138 |
– |
} |
131 |
|
/* constant direction */ |
132 |
|
VCOPY(sr->rdir, source[sn].sloc); |
133 |
|
} else { /* compute direction */ |
144 |
|
for (i = 0; i < 3; i++) { |
145 |
|
dimlist[ndims] = i + 8831; |
146 |
|
vd[i] = dstrsrc * source[sn].ss * |
147 |
< |
(1.0 - 2.0*urand(ilhash(dimlist,ndims+1)+samplendx)); |
147 |
> |
(1.0 - 2.0*urand(urind(ilhash(dimlist,ndims+1),samplendx))); |
148 |
|
} |
149 |
|
ndims--; |
150 |
|
if (source[sn].sflags & SFLAT) { /* project offset */ |
154 |
|
} |
155 |
|
for (i = 0; i < 3; i++) /* offset source direction */ |
156 |
|
sr->rdir[i] += vd[i]; |
157 |
+ |
/* normalize */ |
158 |
+ |
d = normalize(sr->rdir); |
159 |
|
|
160 |
< |
} else if (source[sn].sflags & SDISTANT) |
161 |
< |
/* already normalized */ |
162 |
< |
return(source[sn].ss2); |
160 |
> |
} else if (!(source[sn].sflags & SDISTANT)) |
161 |
> |
/* normalize direction */ |
162 |
> |
d = normalize(sr->rdir); |
163 |
|
|
164 |
< |
if ((d = normalize(sr->rdir)) == 0.0) |
165 |
< |
/* at source! */ |
164 |
> |
if (source[sn].sflags & SDISTANT) { |
165 |
> |
if (source[sn].sflags & SSPOT) { /* check location */ |
166 |
> |
for (i = 0; i < 3; i++) |
167 |
> |
vd[i] = source[sn].sl.s->aim[i] - sr->rorg[i]; |
168 |
> |
d = DOT(sr->rdir,vd); |
169 |
> |
if (d <= FTINY) |
170 |
> |
return(0.0); |
171 |
> |
d = DOT(vd,vd) - d*d; |
172 |
> |
if (PI*d > source[sn].sl.s->siz) |
173 |
> |
return(0.0); |
174 |
> |
} |
175 |
> |
return(source[sn].ss2); /* domega constant */ |
176 |
> |
} |
177 |
> |
/* check direction */ |
178 |
> |
if (d == 0.0) |
179 |
|
return(0.0); |
173 |
– |
|
174 |
– |
if (source[sn].sflags & SDISTANT) |
175 |
– |
/* domega constant */ |
176 |
– |
return(source[sn].ss2); |
177 |
– |
|
180 |
|
/* check proximity */ |
181 |
|
if (source[sn].sflags & SPROX && |
182 |
|
d > source[sn].sl.prox) |