--- ray/src/gen/mkillum2.c 1991/08/26 10:16:56 1.13 +++ ray/src/gen/mkillum2.c 1994/01/07 14:51:46 2.6 @@ -26,8 +26,7 @@ char *nm; sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", nm, ofun[ob->otype].funame, ob->oname); error(WARNING, errmsg); - if (!(il->flags & IL_LIGHT)) - printobj(il->altmat, ob); + printobj(il->altmat, ob); } @@ -67,7 +66,21 @@ char *nm; distarr = (float *)calloc(n, 3*sizeof(float)); if (distarr == NULL) error(SYSTEM, "out of memory in o_face"); - mkaxes(u, v, fa->norm); + /* take first edge longer than sqrt(area) */ + for (j = fa->nv-1, i = 0; i < fa->nv; j = i++) { + u[0] = VERTEX(fa,i)[0] - VERTEX(fa,j)[0]; + u[1] = VERTEX(fa,i)[1] - VERTEX(fa,j)[1]; + u[2] = VERTEX(fa,i)[2] - VERTEX(fa,j)[2]; + if ((r1 = DOT(u,u)) >= fa->area-FTINY) + break; + } + if (i < fa->nv) { /* got one! -- let's align our axes */ + r2 = 1.0/sqrt(r1); + u[0] *= r2; u[1] *= r2; u[2] *= r2; + fcross(v, fa->norm, u); + } else /* oh well, we'll just have to wing it */ + mkaxes(u, v, fa->norm); + /* now, find limits in (u,v) coordinates */ ur[0] = vr[0] = FHUGE; ur[1] = vr[1] = -FHUGE; for (i = 0; i < fa->nv; i++) { @@ -120,7 +133,7 @@ char *nm; if (il->sampdens > 0) flatout(il, distarr, nalt, nazi, u, v, fa->norm); illumout(il, ob); - } else if (!(il->flags & IL_LIGHT)) + } else printobj(il->altmat, ob); /* clean up */ freeface(ob); @@ -191,7 +204,7 @@ char *nm; else objerror(ob, WARNING, "diffuse distribution"); illumout(il, ob); - } else if (!(il->flags & IL_LIGHT)) + } else printobj(il->altmat, ob); /* clean up */ free((char *)distarr); @@ -247,7 +260,7 @@ char *nm; r1 = r3*cos(r2); r2 = r3*sin(r2); for (j = 0; j < 3; j++) - org[j] = CO_P0(co)[j] + r1*u[j] + r1*v[j] + + org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] + .001*co->ad[j]; /* send sample */ @@ -259,7 +272,7 @@ char *nm; if (il->sampdens > 0) flatout(il, distarr, nalt, nazi, u, v, co->ad); illumout(il, ob); - } else if (!(il->flags & IL_LIGHT)) + } else printobj(il->altmat, ob); /* clean up */ freecone(ob); @@ -291,6 +304,7 @@ register struct rtproc *rt; if (rt->nrays <= 0) return; bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); + errno = 0; if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf, 3*sizeof(float)*rt->nrays, 6*sizeof(float)*(rt->nrays+1)) <