--- ray/src/gen/mkillum2.c 1991/11/08 13:17:47 1.14 +++ ray/src/gen/mkillum2.c 1992/08/13 10:03:19 2.4 @@ -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,20 @@ 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 (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 +132,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 +203,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 +271,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);