183 |
|
} |
184 |
|
|
185 |
|
|
186 |
+ |
sourcehit(r) /* check to see if ray hit distant source */ |
187 |
+ |
register RAY *r; |
188 |
+ |
{ |
189 |
+ |
int first, last; |
190 |
+ |
register int i; |
191 |
+ |
|
192 |
+ |
if (r->rsrc >= 0) { /* check only one if aimed */ |
193 |
+ |
first = last = r->rsrc; |
194 |
+ |
} else { /* otherwise check all */ |
195 |
+ |
first = 0; last = nsources-1; |
196 |
+ |
} |
197 |
+ |
for (i = first; i <= last; i++) |
198 |
+ |
if ((source[i].sflags & (SDISTANT|SVIRTUAL)) == SDISTANT) |
199 |
+ |
/* |
200 |
+ |
* Check to see if ray is within |
201 |
+ |
* solid angle of source. |
202 |
+ |
*/ |
203 |
+ |
if (2.0*PI * (1.0 - DOT(source[i].sloc,r->rdir)) |
204 |
+ |
<= source[i].ss2) { |
205 |
+ |
r->ro = source[i].so; |
206 |
+ |
if (!(source[i].sflags & SSKIP)) |
207 |
+ |
break; |
208 |
+ |
} |
209 |
+ |
|
210 |
+ |
if (r->ro != NULL) { |
211 |
+ |
for (i = 0; i < 3; i++) |
212 |
+ |
r->ron[i] = -r->rdir[i]; |
213 |
+ |
r->rod = 1.0; |
214 |
+ |
r->rox = NULL; |
215 |
+ |
return(1); |
216 |
+ |
} |
217 |
+ |
return(0); |
218 |
+ |
} |
219 |
+ |
|
220 |
+ |
|
221 |
|
static int |
222 |
|
cntcmp(sc1, sc2) /* contribution compare (descending) */ |
223 |
|
register CNTPTR *sc1, *sc2; |