--- ray/src/gen/mkillum2.c 1991/11/08 13:17:47 1.14 +++ ray/src/gen/mkillum2.c 1992/08/12 14:44:15 2.3 @@ -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,19 @@ 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 (i = 1; i < fa->nv; i++) { + for (j = 0; j < 3; j++) + u[j] = VERTEX(fa,i)[j] - VERTEX(fa,i-1)[j]; + if (DOT(u,u) >= fa->area-FTINY) + break; + } + if (i < fa->nv) { /* got one! -- let's align our axes */ + normalize(u); + 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 +131,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 +202,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); @@ -259,7 +270,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);