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.11 by greg, Thu Aug 22 12:12:23 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 116 | Line 127 | char  *nm;
127                  }
128          rayflush(rt);
129                                  /* write out the face and its distribution */
130 <        average(il, distarr, nalt*nazi);
131 <        if (il->sampdens > 0)
132 <                flatout(il, distarr, nalt, nazi, u, v, fa->norm);
133 <        illumout(il, ob);
130 >        if (average(il, distarr, nalt*nazi)) {
131 >                if (il->sampdens > 0)
132 >                        flatout(il, distarr, nalt, nazi, u, v, fa->norm);
133 >                illumout(il, ob);
134 >        } else
135 >                printobj(il->altmat, ob);
136                                  /* clean up */
137          freeface(ob);
138          free((char *)distarr);
# Line 164 | 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 183 | Line 196 | char  *nm;
196                  }
197          rayflush(rt);
198                                  /* write out the sphere and its distribution */
199 <        average(il, distarr, nalt*nazi);
200 <        if (il->sampdens > 0)
201 <                roundout(il, distarr, nalt, nazi);
202 <        else
203 <                objerror(ob, WARNING, "diffuse distribution");
204 <        illumout(il, ob);
199 >        if (average(il, distarr, nalt*nazi)) {
200 >                if (il->sampdens > 0)
201 >                        roundout(il, distarr, nalt, nazi);
202 >                else
203 >                        objerror(ob, WARNING, "diffuse distribution");
204 >                illumout(il, ob);
205 >        } else
206 >                printobj(il->altmat, ob);
207                                  /* clean up */
208          free((char *)distarr);
209   }
# Line 232 | 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 251 | Line 266 | char  *nm;
266                  }
267          rayflush(rt);
268                                  /* write out the ring and its distribution */
269 <        average(il, distarr, nalt*nazi);
270 <        if (il->sampdens > 0)
271 <                flatout(il, distarr, nalt, nazi, u, v, co->ad);
272 <        illumout(il, ob);
269 >        if (average(il, distarr, nalt*nazi)) {
270 >                if (il->sampdens > 0)
271 >                        flatout(il, distarr, nalt, nazi, u, v, co->ad);
272 >                illumout(il, ob);
273 >        } else
274 >                printobj(il->altmat, ob);
275                                  /* clean up */
276          freecone(ob);
277          free((char *)distarr);
# Line 285 | 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