47 |
|
|
48 |
|
m = objptr(o->omod); |
49 |
|
|
50 |
< |
if (m->otype != MAT_LIGHT && |
51 |
< |
m->otype != MAT_ILLUM && |
52 |
< |
m->otype != MAT_GLOW && |
53 |
< |
m->otype != MAT_SPOT) |
50 |
> |
if (!islight(m->otype)) |
51 |
|
continue; |
52 |
|
|
53 |
|
if (m->oargs.nfargs != (m->otype == MAT_GLOW ? 4 : |
307 |
|
double prob, ourthresh, hwt, test2, hit2; |
308 |
|
RAY sr; |
309 |
|
|
310 |
+ |
if (nsources <= 0) |
311 |
+ |
return; |
312 |
|
srccnt = (CONTRIB *)malloc(nsources*sizeof(CONTRIB)); |
313 |
|
cntord = (CNTPTR *)malloc(nsources*sizeof(CNTPTR)); |
314 |
|
if (srccnt == NULL || cntord == NULL) |
328 |
|
/* compute coefficient */ |
329 |
|
(*f)(srccnt[sn].val, p, srccnt[sn].dir, srccnt[sn].dom); |
330 |
|
cntord[sn].brt = bright(srccnt[sn].val); |
331 |
< |
if (cntord[sn].brt <= FTINY) |
331 |
> |
if (cntord[sn].brt <= 0.0) |
332 |
|
continue; |
333 |
|
/* compute intersection */ |
334 |
|
if (!( source[sn].sflags & SDISTANT ? |
337 |
|
(source[sn].so, &sr) )) |
338 |
|
continue; |
339 |
|
/* compute contribution */ |
340 |
< |
rayshade(&sr, sr.ro->omod); |
340 |
> |
raycont(&sr); |
341 |
|
multcolor(srccnt[sn].val, sr.rcol); |
342 |
|
cntord[sn].brt = bright(srccnt[sn].val); |
343 |
|
} |
344 |
|
/* sort contributions */ |
345 |
|
qsort(cntord, nsources, sizeof(CNTPTR), cntcmp); |
346 |
< |
/* find last */ |
347 |
< |
sn = 0; ncnts = nsources; |
348 |
< |
while (sn < ncnts-1) { |
349 |
< |
register int m; |
350 |
< |
m = (sn + ncnts) >> 1; |
351 |
< |
if (cntord[m].brt > 0.0) |
352 |
< |
sn = m; |
353 |
< |
else |
354 |
< |
ncnts = m; |
355 |
< |
} |
346 |
> |
{ /* find last */ |
347 |
> |
register int l, m; |
348 |
> |
|
349 |
> |
sn = 0; ncnts = l = nsources; |
350 |
> |
while ((m = (sn + ncnts) >> 1) != l) { |
351 |
> |
if (cntord[m].brt > 0.0) |
352 |
> |
sn = m; |
353 |
> |
else |
354 |
> |
ncnts = m; |
355 |
> |
l = m; |
356 |
> |
} |
357 |
> |
} |
358 |
|
/* accumulate tail */ |
359 |
|
for (sn = ncnts-1; sn > 0; sn--) |
360 |
|
cntord[sn-1].brt += cntord[sn].brt; |
375 |
|
/* test for hit */ |
376 |
|
rayorigin(&sr, r, SHADOW, 1.0); |
377 |
|
VCOPY(sr.rdir, srccnt[cntord[sn].sno].dir); |
378 |
+ |
sr.rsrc = cntord[sn].sno; |
379 |
|
if (localhit(&sr, &thescene) && |
380 |
|
sr.ro != source[cntord[sn].sno].so) { |
381 |
|
/* check for transmission */ |
382 |
< |
if (sr.clipset != NULL && inset(sr.clipset,sr.ro->omod)) |
381 |
< |
raytrans(&sr); /* object is clipped */ |
382 |
< |
else |
383 |
< |
rayshade(&sr, sr.ro->omod); |
382 |
> |
raycont(&sr); |
383 |
|
if (bright(sr.rcol) <= FTINY) |
384 |
|
continue; /* missed! */ |
385 |
|
(*f)(srccnt[cntord[sn].sno].val, p, |
407 |
|
addcolor(r->rcol, srccnt[cntord[sn].sno].val); |
408 |
|
} |
409 |
|
|
410 |
< |
free(srccnt); |
411 |
< |
free(cntord); |
410 |
> |
free((char *)srccnt); |
411 |
> |
free((char *)cntord); |
412 |
|
} |
413 |
|
|
414 |
|
|
428 |
|
register OBJREC *m; |
429 |
|
register RAY *r; |
430 |
|
{ |
432 |
– |
/* check for behind */ |
433 |
– |
if (r->rod < 0.0) |
434 |
– |
return; |
431 |
|
/* check for over-counting */ |
432 |
|
if (wrongsource(m, r) || badambient(m, r)) |
433 |
|
return; |
441 |
|
|
442 |
|
/* otherwise treat as source */ |
443 |
|
} else { |
444 |
+ |
/* check for behind */ |
445 |
+ |
if (r->rod < 0.0) |
446 |
+ |
return; |
447 |
|
/* get distribution pattern */ |
448 |
|
raytexture(r, m->omod); |
449 |
|
/* get source color */ |
452 |
|
m->oargs.farg[2]); |
453 |
|
/* modify value */ |
454 |
|
multcolor(r->rcol, r->pcol); |
455 |
+ |
/* assign distance */ |
456 |
+ |
r->rt = r->rot; |
457 |
|
} |
458 |
|
} |
458 |
– |
|
459 |
– |
|
460 |
– |
o_source() {} /* intersection with a source is done elsewhere */ |