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

Comparing ray/src/hd/rhpict2.c (file contents):
Revision 3.6 by gwlarson, Tue Mar 9 14:23:51 1999 UTC vs.
Revision 3.8 by gwlarson, Tue Mar 9 15:08:22 1999 UTC

# Line 205 | Line 205 | int    n;
205  
206  
207   int
208 < random_samp(h, v, nl, n)        /* grow sample point noisily */
208 > random_samp(h, v, nl, n, rf)    /* grow sample point noisily */
209   int     h, v;
210   register short  nl[NNEIGH][2];
211   int     n;
212 + double  *rf;
213   {
214 <        float   nwt[NNEIGH];
214 >        double  tv = *rf * (1.-1./NNEIGH);
215          int4    maxr2;
216          register int4   p, r2;
217          register int    i;
# Line 223 | Line 224 | int    n;
224          maxr2 = (h-nl[n-1][0])*(h-nl[n-1][0]) + (v-nl[n-1][1])*(v-nl[n-1][1]);
225          DCHECK(maxr2>=MAXRAD2, CONSISTENCY, "out of range neighbor");
226          maxr = isqrt(maxr2);
226                                                /* compute neighbor weights */
227        for (i = n; i--; ) {
228                r2 = (nl[i][0]-h)*(nl[i][0]-h) + (nl[i][1]-v)*(nl[i][1]-v);
229                nwt[i] = pixWeight[r2];
230        }
227                                                  /* sample kernel */
228          for (v2 = v-maxr; v2 <= v+maxr; v2++) {
229                  if (v2 < 0) v2 = 0;
# Line 239 | Line 235 | int    n;
235                          if (r2 > maxr2) continue;
236                          if (CHK4(pixFlags, v2*hres+h2))
237                                  continue;       /* occupied */
238 <                        if (frandom() > pixWeight[r2]) {
243 <                                                /* pick neighbor instead */
238 >                        if (frandom() < tv) {   /* use neighbor instead? */
239                                  i = random() % n;
240                                  r2 = nl[i][1]*hres + nl[i][0];
241                                  copycolor(ctmp, mypixel[r2]);
242 <                                scalecolor(ctmp, nwt[i]);
243 <                                addcolor(mypixel[v2*hres+h2], ctmp);
244 <                                myweight[v2*hres+h2] += nwt[i] * myweight[r2];
245 <                                continue;
242 >                                r2 = (h2-nl[i][0])*(h2-nl[i][0]) +
243 >                                                (v2-nl[i][1])*(v2-nl[i][1]);
244 >                                if (r2 < MAXRAD2) {
245 >                                        scalecolor(ctmp, pixWeight[r2]);
246 >                                        addcolor(mypixel[v2*hres+h2], ctmp);
247 >                                        myweight[v2*hres+h2] += pixWeight[r2] *
248 >                                              myweight[nl[i][1]*hres+nl[i][0]];
249 >                                        continue;
250 >                                }
251                          }
252 <                        addcolor(mypixel[v2*hres+h2], mypixel[p]);
253 <                        myweight[v2*hres+h2] += myweight[p];
252 >                                                /* use central sample */
253 >                        copycolor(ctmp, mypixel[p]);
254 >                        scalecolor(ctmp, pixWeight[r2]);
255 >                        addcolor(mypixel[v2*hres+h2], ctmp);
256 >                        myweight[v2*hres+h2] += pixWeight[r2] * myweight[p];
257                  }
258          }
259          return(1);
# Line 258 | Line 261 | int    n;
261  
262  
263   pixFinish(ransamp)              /* done with beams -- compute pixel values */
264 < int     ransamp;
264 > double  ransamp;
265   {
266          if (pixWeight[0] <= FTINY)
267                  init_wfunc();           /* initialize weighting function */
268          reset_flags();                  /* set occupancy flags */
269 <        meet_neighbors(kill_occl);      /* eliminate occlusion errors */
269 >        meet_neighbors(kill_occl,NULL); /* eliminate occlusion errors */
270          reset_flags();                  /* reset occupancy flags */
271 <        if (ransamp)                    /* spread samples over image */
272 <                meet_neighbors(random_samp);
271 >        if (ransamp >= 0.)              /* spread samples over image */
272 >                meet_neighbors(random_samp,&ransamp);
273          else
274 <                meet_neighbors(smooth_samp);
274 >                meet_neighbors(smooth_samp,NULL);
275          free((char *)pixFlags);         /* free pixel flags */
276          pixFlags = NULL;
277   }
# Line 345 | Line 348 | register short (*rnl)[NNEIGH];
348   }
349  
350  
351 < meet_neighbors(nf)              /* run through samples and their neighbors */
351 > meet_neighbors(nf, dp)          /* run through samples and their neighbors */
352   int     (*nf)();
353 + char    *dp;
354   {
355          short   ln[NNEIGH][2];
356          int     h, v, n, v2;
# Line 370 | Line 374 | int    (*nf)();
374                          if (!CHK4(pixFlags, v*hres+h))
375                                  continue;       /* no one home */
376                          n = findneigh(ln, h, v, rnl);
377 <                        (*nf)(h, v, ln, n);     /* call on neighbors */
377 >                        (*nf)(h, v, ln, n, dp); /* call on neighbors */
378                  }
379                  if (++v >= vres)                /* reinitialize row list */
380                          break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines