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

Comparing ray/src/hd/rhdisp2.c (file contents):
Revision 3.17 by gregl, Thu Jan 1 13:00:16 1998 UTC vs.
Revision 3.19 by gregl, Wed Jan 7 16:04:14 1998 UTC

# Line 322 | Line 322 | register struct cellact        *cap;
322          register int    i;
323                                  /* compute cell center */
324          cgp[gcp->w>>1] = gcp->w&1 ? hp->grid[gcp->w>>1] : 0 ;
325 <        cgp[((gcp->w>>1)+1)%3] = gcp->i[0] + .5;
326 <        cgp[((gcp->w>>1)+2)%3] = gcp->i[1] + .5;
325 >        cgp[hdwg0[gcp->w]] = gcp->i[0] + .5;
326 >        cgp[hdwg1[gcp->w]] = gcp->i[1] + .5;
327          hdworld(org, hp, cgp);
328                                  /* compute direction to voxel center */
329          for (i = 3; i--; )
# Line 350 | Line 350 | register struct cellact        *cap;
350          for (i = 3; i--; )
351                  v1[i] = hp->xv[j][i] * d;
352          d = 0.5/hp->grid[j=(axmax+2)%3];
353 <        if (DOT(hp->wn[axmax], vc) < 0.)
354 <                d = -d; /* reverse vertex ordering */
353 >        if (DOT(hp->wg[axmax], vc) < 0.)
354 >                d = -d; /* reverse vertex order */
355          for (i = 3; i--; )
356                  v2[i] = hp->xv[j][i] * d;
357                                  /* compute voxel pyramid */
# Line 392 | Line 392 | VIEW   *vold, *vnew;
392          int     netchange = 0;
393          struct cellact  oca, nca;
394          int     ocnt, ncnt;
395 <        int     c;
395 >        int     nmatch = 0;
396          GCOORD  *ogcl, *ngcl;
397 +        register int    c;
398          register GCOORD *ogcp, *ngcp;
399                                  /* get old and new cell lists */
400          ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
# Line 405 | Line 406 | VIEW   *vold, *vnew;
406                  ocnt = -ocnt;
407          if ((nca.rev = ncnt < 0))
408                  ncnt = -ncnt;
409 <        if (nca.rev == oca.rev)         /* add and delete cells in order */
410 <                while (ocnt > 0 & ncnt > 0)
411 <                        if ((c = cellcmp(ogcp, ngcp)) > 0) {    /* new cell */
412 <                                netchange += docell(ngcp++, &nca);
413 <                                ncnt--;
414 <                        } else if (c < 0) {                     /* old cell */
415 <                                netchange -= docell(ogcp++, &oca);
416 <                                ocnt--;
417 <                        } else {                                /* same cell */
418 <                                ogcp++; ocnt--;
419 <                                ngcp++; ncnt--;
409 >        if (oca.rev == nca.rev) {       /* count matches */
410 >                int     oc = ocnt, nc = ncnt;
411 >                while (oc > 0 & nc > 0) {
412 >                        c = cellcmp(ogcp, ngcp);
413 >                        if (c >= 0) { ngcp++; nc--; }
414 >                        if (c <= 0) { ogcp++; oc--; }
415 >                        nmatch += c==0;
416 >                }
417 >                ogcp = ogcl; ngcp = ngcl;
418 >        }
419 >        if (nmatch < ocnt>>1) {         /* faster to just delete old cells? */
420 >                for (c = ncbeams; c--; )
421 >                        if (cbeam[c].wants & 1<<voxi) {
422 >                                cbeam[c].wants &= ~(1<<voxi);
423 >                                netchange--;
424                          }
425 +                free((char *)ogcl);
426 +                ogcl = NULL; ocnt = 0;
427 +        }
428 +                                /* add and delete cells in order */
429 +        while (ocnt > 0 & ncnt > 0)
430 +                if ((c = cellcmp(ogcp, ngcp)) > 0) {    /* new cell */
431 +                        netchange += docell(ngcp++, &nca);
432 +                        ncnt--;
433 +                } else if (c < 0) {                     /* old cell */
434 +                        netchange -= docell(ogcp++, &oca);
435 +                        ocnt--;
436 +                } else {                                /* same cell */
437 +                        ogcp++; ocnt--;
438 +                        ngcp++; ncnt--;
439 +                }
440                                  /* take care of list tails */
441          for ( ; ncnt > 0; ncnt--)
442                  netchange += docell(ngcp++, &nca);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines