26 |
|
sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", |
27 |
|
nm, ofun[ob->otype].funame, ob->oname); |
28 |
|
error(WARNING, errmsg); |
29 |
< |
if (!(il->flags & IL_LIGHT)) |
30 |
< |
printobj(il->altmat, ob); |
29 |
> |
printobj(il->altmat, ob); |
30 |
|
} |
31 |
|
|
32 |
|
|
66 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
67 |
|
if (distarr == NULL) |
68 |
|
error(SYSTEM, "out of memory in o_face"); |
69 |
< |
mkaxes(u, v, fa->norm); |
69 |
> |
/* take first edge longer than sqrt(area) */ |
70 |
> |
for (j = fa->nv-1, i = 0; i < fa->nv; j = i++) { |
71 |
> |
u[0] = VERTEX(fa,i)[0] - VERTEX(fa,j)[0]; |
72 |
> |
u[1] = VERTEX(fa,i)[1] - VERTEX(fa,j)[1]; |
73 |
> |
u[2] = VERTEX(fa,i)[2] - VERTEX(fa,j)[2]; |
74 |
> |
if ((r1 = DOT(u,u)) >= fa->area-FTINY) |
75 |
> |
break; |
76 |
> |
} |
77 |
> |
if (i < fa->nv) { /* got one! -- let's align our axes */ |
78 |
> |
r2 = 1.0/sqrt(r1); |
79 |
> |
u[0] *= r2; u[1] *= r2; u[2] *= r2; |
80 |
> |
fcross(v, fa->norm, u); |
81 |
> |
} else /* oh well, we'll just have to wing it */ |
82 |
> |
mkaxes(u, v, fa->norm); |
83 |
> |
/* now, find limits in (u,v) coordinates */ |
84 |
|
ur[0] = vr[0] = FHUGE; |
85 |
|
ur[1] = vr[1] = -FHUGE; |
86 |
|
for (i = 0; i < fa->nv; i++) { |
133 |
|
if (il->sampdens > 0) |
134 |
|
flatout(il, distarr, nalt, nazi, u, v, fa->norm); |
135 |
|
illumout(il, ob); |
136 |
< |
} else if (!(il->flags & IL_LIGHT)) |
136 |
> |
} else |
137 |
|
printobj(il->altmat, ob); |
138 |
|
/* clean up */ |
139 |
|
freeface(ob); |
204 |
|
else |
205 |
|
objerror(ob, WARNING, "diffuse distribution"); |
206 |
|
illumout(il, ob); |
207 |
< |
} else if (!(il->flags & IL_LIGHT)) |
207 |
> |
} else |
208 |
|
printobj(il->altmat, ob); |
209 |
|
/* clean up */ |
210 |
|
free((char *)distarr); |
272 |
|
if (il->sampdens > 0) |
273 |
|
flatout(il, distarr, nalt, nazi, u, v, co->ad); |
274 |
|
illumout(il, ob); |
275 |
< |
} else if (!(il->flags & IL_LIGHT)) |
275 |
> |
} else |
276 |
|
printobj(il->altmat, ob); |
277 |
|
/* clean up */ |
278 |
|
freecone(ob); |