104 |
|
for (i = 0; i < vsmat->nproj; i++) |
105 |
|
if ((*vsmat->vproj)(proj, o, &source[sn], i)) |
106 |
|
if ((ns = makevsrc(o, sn, proj)) >= 0) { |
107 |
+ |
source[ns].sa.sv.pn = i; |
108 |
|
#ifdef DEBUG |
109 |
|
virtverb(ns, stderr); |
110 |
|
#endif |
135 |
|
if (source[sn].sflags & SPROX) |
136 |
|
return(-1); /* should never get here! */ |
137 |
|
multv3(nsloc, source[sn].sloc, pm); |
138 |
+ |
normalize(nsloc); |
139 |
|
VCOPY(ourspot.aim, ocent); |
140 |
|
ourspot.siz = PI*maxrad2; |
141 |
|
ourspot.flen = 0.; |
171 |
|
if (source[sn].sflags & SSPOT) { |
172 |
|
copystruct(&theirspot, source[sn].sl.s); |
173 |
|
multv3(theirspot.aim, source[sn].sl.s->aim, pm); |
174 |
+ |
normalize(theirspot.aim); |
175 |
|
if (nsflags & SSPOT) { |
176 |
|
ourspot.flen = theirspot.flen; |
177 |
|
d = ourspot.siz; |
194 |
|
} |
195 |
|
if (source[sn].sflags & SFLAT) { /* behind source? */ |
196 |
|
multv3(nsnorm, source[sn].snorm, pm); |
197 |
+ |
normalize(nsnorm); |
198 |
|
if (!checkspot(&ourspot, nsnorm)) |
199 |
|
return(-1); |
200 |
|
} |
218 |
|
} |
219 |
|
if (nsflags & SPROX) |
220 |
|
source[i].sl.prox = source[sn].sl.prox; |
221 |
< |
source[i].sa.svnext = sn; |
221 |
> |
source[i].sa.sv.sn = sn; |
222 |
|
source[i].so = op; |
223 |
|
return(i); |
224 |
|
memerr: |
271 |
|
FVECT offsdir; |
272 |
|
double or, d; |
273 |
|
int infront; |
274 |
< |
int ssn; |
274 |
> |
int stestlim, ssn; |
275 |
|
int nhit, nok; |
276 |
|
register int i, n; |
277 |
|
/* return if pretesting disabled */ |
297 |
|
#endif |
298 |
|
/* sample */ |
299 |
|
or = sqrt(or2); |
300 |
< |
ssn = STESTMAX*n; |
300 |
> |
stestlim = n*STESTMAX; |
301 |
> |
ssn = 0; |
302 |
|
nhit = nok = 0; |
303 |
|
while (n-- > 0) { |
304 |
|
/* get sample point */ |
305 |
|
do { |
306 |
< |
if (--ssn < 0) { |
306 |
> |
if (ssn >= stestlim) { |
307 |
|
#ifdef DEBUG |
308 |
|
fprintf(stderr, "\ttoo hard to hit\n"); |
309 |
|
#endif |
311 |
|
} |
312 |
|
for (i = 0; i < 3; i++) |
313 |
|
offsdir[i] = or*(1. - |
314 |
< |
2.*urand(931*i+5827+ssn)); |
314 |
> |
2.*urand(urind(931*i+5827,ssn))); |
315 |
> |
ssn++; |
316 |
|
for (i = 0; i < 3; i++) |
317 |
|
sr.rorg[i] = oc[i] + offsdir[i]; |
318 |
|
d = DOT(offsdir,onorm); |
338 |
|
continue; |
339 |
|
nok++; |
340 |
|
/* check against obstructions */ |
341 |
< |
srcray(&sr, NULL, sn); |
341 |
> |
rayclear(&sr); |
342 |
> |
sr.revf = raytrace; |
343 |
|
rayvalue(&sr); |
344 |
|
if (bright(sr.rcol) > FTINY) |
345 |
|
nhit++; |
377 |
|
fprintf(fp, "\tat (%f,%f,%f)\n", |
378 |
|
source[sn].sloc[0], source[sn].sloc[1], source[sn].sloc[2]); |
379 |
|
fprintf(fp, "\tlinked to source %d (%s)\n", |
380 |
< |
source[sn].sa.svnext, source[source[sn].sa.svnext].so->oname); |
380 |
> |
source[sn].sa.sv.sn, source[source[sn].sa.sv.sn].so->oname); |
381 |
|
if (source[sn].sflags & SFOLLOW) |
382 |
|
fprintf(fp, "\talways followed\n"); |
383 |
|
else |