ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum2.c
(Generate patch)

Comparing ray/src/gen/mkillum2.c (file contents):
Revision 1.12 by greg, Fri Aug 23 12:30:33 1991 UTC vs.
Revision 2.3 by greg, Wed Aug 12 14:44:15 1992 UTC

# Line 26 | Line 26 | char  *nm;
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  
# Line 67 | Line 66 | char  *nm;
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 (i = 1; i < fa->nv; i++) {
71 >                for (j = 0; j < 3; j++)
72 >                        u[j] = VERTEX(fa,i)[j] - VERTEX(fa,i-1)[j];
73 >                if (DOT(u,u) >= fa->area-FTINY)
74 >                        break;
75 >        }
76 >        if (i < fa->nv) {       /* got one! -- let's align our axes */
77 >                normalize(u);
78 >                fcross(v, fa->norm, u);
79 >        } else                  /* oh well, we'll just have to wing it */
80 >                mkaxes(u, v, fa->norm);
81 >                                /* now, find limits in (u,v) coordinates */
82          ur[0] = vr[0] = FHUGE;
83          ur[1] = vr[1] = -FHUGE;
84          for (i = 0; i < fa->nv; i++) {
# Line 88 | Line 99 | char  *nm;
99                      h = ilhash(dim, 3) + i;
100                      multisamp(sp, 2, urand(h));
101                      r1 = (dim[1] + sp[0])/nalt;
102 <                    r2 = (dim[2] + sp[1])/nazi;
102 >                    r2 = (dim[2] + sp[1] - .5)/nazi;
103                      flatdir(dn, r1, r2);
104                      for (j = 0; j < 3; j++)
105                          dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j];
# Line 120 | Line 131 | char  *nm;
131                  if (il->sampdens > 0)
132                          flatout(il, distarr, nalt, nazi, u, v, fa->norm);
133                  illumout(il, ob);
134 <        } else if (!(il->flags & IL_LIGHT))
134 >        } else
135                  printobj(il->altmat, ob);
136                                  /* clean up */
137          freeface(ob);
# Line 166 | Line 177 | char  *nm;
177                      multisamp(sp, 4, urand(ilhash(dim,3)+i));
178                                          /* random direction */
179                      r1 = (dim[1] + sp[0])/nalt;
180 <                    r2 = (dim[2] + sp[1])/nazi;
180 >                    r2 = (dim[2] + sp[1] - .5)/nazi;
181                      rounddir(dir, r1, r2);
182                                          /* random location */
183                      mkaxes(u, v, dir);          /* yuck! */
# Line 191 | Line 202 | char  *nm;
202                  else
203                          objerror(ob, WARNING, "diffuse distribution");
204                  illumout(il, ob);
205 <        } else if (!(il->flags & IL_LIGHT))
205 >        } else
206                  printobj(il->altmat, ob);
207                                  /* clean up */
208          free((char *)distarr);
# Line 236 | Line 247 | char  *nm;
247                      multisamp(sp, 4, urand(ilhash(dim,3)+i));
248                                          /* random direction */
249                      r1 = (dim[1] + sp[0])/nalt;
250 <                    r2 = (dim[2] + sp[1])/nalt;
250 >                    r2 = (dim[2] + sp[1] - .5)/nazi;
251                      flatdir(dn, r1, r2);
252                      for (j = 0; j < 3; j++)
253                          dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j];
# Line 259 | Line 270 | char  *nm;
270                  if (il->sampdens > 0)
271                          flatout(il, distarr, nalt, nazi, u, v, co->ad);
272                  illumout(il, ob);
273 <        } else if (!(il->flags & IL_LIGHT))
273 >        } else
274                  printobj(il->altmat, ob);
275                                  /* clean up */
276          freecone(ob);
# Line 291 | Line 302 | register struct rtproc  *rt;
302          if (rt->nrays <= 0)
303                  return;
304          bzero(rt->buf+6*rt->nrays, 6*sizeof(float));
305 +        errno = 0;
306          if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf,
307                          3*sizeof(float)*rt->nrays,
308                          6*sizeof(float)*(rt->nrays+1)) <

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines