109 |
|
/* set min & max radii */ |
110 |
|
if (ar <= 0) { |
111 |
|
minarad = 0; |
112 |
< |
maxarad = thescene.cusize*0.5; |
112 |
> |
maxarad = thescene.cusize*0.2; |
113 |
|
} else { |
114 |
|
minarad = thescene.cusize / ar; |
115 |
|
maxarad = 64.0 * minarad; /* heuristic */ |
116 |
< |
if (maxarad > thescene.cusize*0.5) |
117 |
< |
maxarad = thescene.cusize*0.5; |
116 |
> |
if (maxarad > thescene.cusize*0.2) |
117 |
> |
maxarad = thescene.cusize*0.2; |
118 |
|
} |
119 |
|
if (minarad <= FTINY) |
120 |
|
minarad = 10.0*FTINY; |
165 |
|
initambfile(0); /* file exists */ |
166 |
|
lastpos = ftell(ambfp); |
167 |
|
while (readambval(&amb, ambfp)) |
168 |
< |
avinsert(avstore(&amb)); |
168 |
> |
avstore(&amb); |
169 |
|
nambshare = nambvals; /* share loaded values */ |
170 |
|
if (readonly) { |
171 |
|
sprintf(errmsg, |
443 |
|
/* |
444 |
|
* Ambient level test |
445 |
|
*/ |
446 |
< |
if (av->lvl > al) /* list sorted, so this works */ |
446 |
> |
if (av->lvl > al || /* list sorted, so this works */ |
447 |
> |
(av->lvl == al) & (av->weight < 0.9*r->rweight)) |
448 |
|
break; |
448 |
– |
if (av->weight < 0.9*r->rweight) |
449 |
– |
continue; |
449 |
|
/* |
450 |
|
* Direction test using unperturbed normal |
451 |
|
*/ |
607 |
|
} |
608 |
|
avh.next = at->alist; /* order by increasing level */ |
609 |
|
for (ap = &avh; ap->next != NULL; ap = ap->next) |
610 |
< |
if (ap->next->lvl >= av->lvl) |
610 |
> |
if ( ap->next->lvl > av->lvl || |
611 |
> |
(ap->next->lvl == av->lvl) & |
612 |
> |
(ap->next->weight <= av->weight) ) |
613 |
|
break; |
614 |
|
av->next = ap->next; |
615 |
|
ap->next = (AMBVAL*)av; |
722 |
|
/* |
723 |
|
* Ambient level test. |
724 |
|
*/ |
725 |
< |
if (av->lvl > al) /* list sorted, so this works */ |
725 |
> |
if (av->lvl > al || /* list sorted, so this works */ |
726 |
> |
(av->lvl == al) & (av->weight < 0.9*r->rweight)) |
727 |
|
break; |
726 |
– |
if (av->weight < 0.9*r->rweight) |
727 |
– |
continue; |
728 |
|
/* |
729 |
|
* Ambient radius test. |
730 |
|
*/ |
906 |
|
} |
907 |
|
avh.next = at->alist; /* order by increasing level */ |
908 |
|
for (ap = &avh; ap->next != NULL; ap = ap->next) |
909 |
< |
if (ap->next->lvl >= av->lvl) |
909 |
> |
if ( ap->next->lvl > av->lvl || |
910 |
> |
(ap->next->lvl == av->lvl) & |
911 |
> |
(ap->next->weight <= av->weight) ) |
912 |
|
break; |
913 |
|
av->next = ap->next; |
914 |
|
ap->next = (AMBVAL*)av; |
960 |
|
AMBVAL *av |
961 |
|
) |
962 |
|
{ |
963 |
< |
avinsert(avstore(av)); |
963 |
> |
avstore(av); |
964 |
|
if (ambfp == NULL) |
965 |
|
return; |
966 |
|
if (writambval(av, ambfp) < 0) |
975 |
|
|
976 |
|
|
977 |
|
static AMBVAL * |
978 |
< |
avstore( /* allocate memory and store aval */ |
978 |
> |
avstore( /* allocate memory and save aval */ |
979 |
|
AMBVAL *aval |
980 |
|
) |
981 |
|
{ |
993 |
|
avsum += log(d); |
994 |
|
navsum++; |
995 |
|
} |
996 |
+ |
avinsert(av); /* insert in our cache tree */ |
997 |
|
return(av); |
998 |
|
} |
999 |
|
|
1194 |
|
if (i_avlist < nambvals) |
1195 |
|
error(CONSISTENCY, "missing ambient values in sortambvals"); |
1196 |
|
#endif |
1197 |
< |
qsort((char *)avlist1, nambvals, sizeof(struct avl), &alatcmp); |
1198 |
< |
qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), &aposcmp); |
1197 |
> |
qsort((char *)avlist1, nambvals, sizeof(struct avl), alatcmp); |
1198 |
> |
qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), aposcmp); |
1199 |
|
for (i = 0; i < nambvals; i++) { |
1200 |
|
if (avlist1[i].p == NULL) |
1201 |
|
continue; |
1276 |
|
error(WARNING, errmsg); |
1277 |
|
break; |
1278 |
|
} |
1279 |
< |
avinsert(avstore(&avs)); |
1279 |
> |
avstore(&avs); |
1280 |
|
n -= AMBVALSIZ; |
1281 |
|
} |
1282 |
|
lastpos = flen - n; |