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 2.4 by greg, Thu Aug 13 10:03:19 1992 UTC vs.
Revision 2.11 by schorsch, Mon Jun 30 14:59:11 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines to do the actual calculation for mkillum
6   */
7  
8 < #include  "mkillum.h"
8 > #include <string.h>
9  
10 + #include  "mkillum.h"
11   #include  "face.h"
14
12   #include  "cone.h"
16
13   #include  "random.h"
14  
15  
# Line 71 | Line 67 | char  *nm;
67                  u[0] = VERTEX(fa,i)[0] - VERTEX(fa,j)[0];
68                  u[1] = VERTEX(fa,i)[1] - VERTEX(fa,j)[1];
69                  u[2] = VERTEX(fa,i)[2] - VERTEX(fa,j)[2];
70 <                if (DOT(u,u) >= fa->area-FTINY)
70 >                if ((r1 = DOT(u,u)) >= fa->area-FTINY)
71                          break;
72          }
73          if (i < fa->nv) {       /* got one! -- let's align our axes */
74 <                normalize(u);
74 >                r2 = 1.0/sqrt(r1);
75 >                u[0] *= r2; u[1] *= r2; u[2] *= r2;
76                  fcross(v, fa->norm, u);
77          } else                  /* oh well, we'll just have to wing it */
78                  mkaxes(u, v, fa->norm);
# Line 117 | Line 114 | char  *nm;
114                          objerror(ob, WARNING, "bad aspect");
115                          rt->nrays = 0;
116                          freeface(ob);
117 <                        free((char *)distarr);
117 >                        free((void *)distarr);
118                          o_default(ob, il, rt, nm);
119                          return;
120                      }
# Line 136 | Line 133 | char  *nm;
133                  printobj(il->altmat, ob);
134                                  /* clean up */
135          freeface(ob);
136 <        free((char *)distarr);
136 >        free((void *)distarr);
137   #undef MAXMISS
138   }
139  
# Line 162 | Line 159 | char  *nm;
159                  nalt = nazi = 1;
160          else {
161                  n = 4.*PI * il->sampdens;
162 <                nalt = sqrt(n/PI) + .5;
163 <                nazi = PI*nalt + .5;
162 >                nalt = sqrt(2./PI*n) + .5;
163 >                nazi = PI/2.*nalt + .5;
164          }
165          n = nalt*nazi;
166          distarr = (float *)calloc(n, 3*sizeof(float));
# Line 206 | Line 203 | char  *nm;
203          } else
204                  printobj(il->altmat, ob);
205                                  /* clean up */
206 <        free((char *)distarr);
206 >        free((void *)distarr);
207   }
208  
209  
# Line 259 | Line 256 | char  *nm;
256                      r1 = r3*cos(r2);
257                      r2 = r3*sin(r2);
258                      for (j = 0; j < 3; j++)
259 <                        org[j] = CO_P0(co)[j] + r1*u[j] + r1*v[j] +
259 >                        org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] +
260                                          .001*co->ad[j];
261  
262                                          /* send sample */
# Line 275 | Line 272 | char  *nm;
272                  printobj(il->altmat, ob);
273                                  /* clean up */
274          freecone(ob);
275 <        free((char *)distarr);
275 >        free((void *)distarr);
276   }
277  
278  
# Line 302 | Line 299 | register struct rtproc  *rt;
299  
300          if (rt->nrays <= 0)
301                  return;
302 <        bzero(rt->buf+6*rt->nrays, 6*sizeof(float));
302 >        memset(rt->buf+6*rt->nrays, '\0', 6*sizeof(float));
303          errno = 0;
304 <        if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf,
305 <                        3*sizeof(float)*rt->nrays,
304 >        if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf,
305 >                        3*sizeof(float)*(rt->nrays+1),
306                          6*sizeof(float)*(rt->nrays+1)) <
307 <                        3*sizeof(float)*rt->nrays )
307 >                        3*sizeof(float)*(rt->nrays+1) )
308                  error(SYSTEM, "error reading from rtrace process");
309          i = rt->nrays;
310          while (i--) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines