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

Comparing ray/src/hd/rhd_odraw.c (file contents):
Revision 3.4 by gwlarson, Mon Dec 21 14:05:43 1998 UTC vs.
Revision 3.7 by gwlarson, Wed Dec 23 21:49:43 1998 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14   #include <GL/glx.h>
15   #include <GL/glu.h>
16  
17 #include "random.h"
17   #include "rhd_odraw.h"
18  
19   #ifndef DEPTHEPS
# Line 131 | Line 130 | int    n;
130                  DCHECK(count<=0 | nextsamp>=n,
131                                  CONSISTENCY, "counter botch in odInit");
132                  if (!i) count = j;
133 +                odView[i].sfirst = nextsamp;
134                  while (j--) {           /* initialize blocks & free lists */
135                          odView[i].bmap[j].pthresh = FHUGE;
136                          odView[i].bmap[j].first = k = nextsamp;
# Line 142 | Line 142 | int    n;
142                          odS.nextfree(k-1) = ENDFREE;
143                          odView[i].bmap[j].nused = 0;
144                  }
145 +                odView[i].snext = nextsamp;
146          }
147          CLR4ALL(odS.redraw, odS.nsamp);         /* clear redraw flags */
148          for (i = odS.nsamp; i--; ) {            /* clear values */
# Line 316 | Line 317 | int    newhist;
317   }
318  
319  
320 + odRedrawAll()                           /* mark all samples for redraw */
321 + {
322 +        register int    i;
323 +
324 +        if ((needmapping&(NEWMAP|NEWRGB)) == (NEWMAP|NEWRGB))
325 +                return;                 /* will be called later, anyway */
326 +        for (i = odS.nsamp; i--; )
327 +                if (odS.ip[i][0] >= 0)
328 +                        SET4(odS.redraw, i);
329 + }
330 +
331 +
332   odRedraw(vn, hmin, vmin, hmax, vmax)    /* redraw view region */
333   int     vn, hmin, vmin, hmax, vmax;
334   {
# Line 433 | Line 446 | int    vn;
446                  if (needmapping & NEWMAP) {
447                          if (needmapping & NEWHIST)
448                                  tmClearHisto();
449 +                        needmapping &= ~NEWHIST;
450                          if (tmAddHisto(odS.brt,odS.nsamp,1) != TM_E_OK)
451                                  return;
452                          if (tmComputeMapping(0.,0.,0.) != TM_E_OK)
453                                  return;
454 <                        for (i = odS.nsamp; i--; )      /* redraw all */
455 <                                if (odS.ip[i][0] >= 0)
442 <                                        SET4(odS.redraw, i);
454 >                        needmapping &= ~NEWMAP;
455 >                        odRedrawAll();                  /* redraw everything */
456                  }
457                  if (tmMapPixels(odS.rgb,odS.brt,odS.chr,odS.nsamp) != TM_E_OK)
458                          return;
459 <                needmapping = 0;                /* reset flag */
459 >                needmapping &= ~NEWRGB;
460          }
461 <                                        /* draw samples flagged for redraw */
462 <        for (j = FL4NELS(odS.nsamp); j--; )
461 >                                        /* this code segment was too slow */
462 > #if 0
463 >        for (i = odView[vn].sfirst; i < odView[vn].snext; i++)
464 >                if (CHK4(odS.redraw, i)) {
465 >                        odDrawSamp(vn, i);
466 >                        CLR4(odS.redraw, i);
467 >                }
468 > #else
469 >                                        /* redraw samples at each end */
470 >        for (i = odView[vn].sfirst; i < odView[vn].sfirst+31; i++)
471 >                if (CHK4(odS.redraw, i)) {
472 >                        odDrawSamp(vn, i);
473 >                        CLR4(odS.redraw, i);
474 >                }
475 >        for (i = odView[vn].snext-31; i < odView[vn].snext; i++)
476 >                if (CHK4(odS.redraw, i)) {
477 >                        odDrawSamp(vn, i);
478 >                        CLR4(odS.redraw, i);
479 >                }
480 >                                        /* faster flag checks in middle */
481 >        for (j = odView[vn].snext>>5; j-- > (odView[vn].sfirst+0x1f)>>5; )
482                  for (i = 0; odS.redraw[j]; i++)         /* skips faster */
483                          if (odS.redraw[j] & 1L<<i) {
484                                  odDrawSamp(vn, (j<<5)+i);
485                                  odS.redraw[j] &= ~(1L<<i);
486                          }
487 + #endif
488   }
489  
490  
491 +                                        /* this turned out to be unnecessary */
492   #if 0
493   static
494   clip_end(p, o, vp)                      /* clip line segment to view */
# Line 492 | Line 526 | register struct ODview *vp;
526   double  sz;
527   {
528          int     na, dv;
529 <        double  hrad, vrad, phi0, phi;
529 >        double  hrad, vrad, phi;
530          register int    i;
531  
532          DCHECK(sz > 1, CONSISTENCY, "super-unary size in make_arms");
# Line 502 | Line 536 | double sz;
536          vrad = FANSIZE*sz*vp->vhi/vp->vlow;
537          if (hrad*vrad < 2.25)
538                  hrad = vrad = 1.5;
505        phi0 = (2.*PI) * frandom();
539          dv = OMAXDEPTH*sz + 0.5;
540          for (i = 0; i < na; i++) {
541 <                phi = phi0 + (2.*PI)*i/na;
541 >                phi = (2.*PI)*i/na;
542                  ar[i][0] = cp[0] + tcos(phi)*hrad + 0.5;
543                  ar[i][1] = cp[1] + tsin(phi)*vrad + 0.5;
544                  ar[i][2] = dv;
# Line 558 | Line 591 | register struct ODview *vp;
591          n = rise + run;
592          while (n--)                     /* run out arm, checking depth */
593                  if (run2 > rise2) {
561                        if (depthchange(vp, x, y, x+xstep, y))
562                                break;
594                          x += xstep;
595                          rise2 += rise;
596 <                } else {
566 <                        if (depthchange(vp, x, y, x, y+ystep))
596 >                        if (depthchange(vp, x-xstep, y, x, y))
597                                  break;
598 +                } else {
599                          y += ystep;
600                          run2 += run;
601 +                        if (depthchange(vp, x, y-ystep, x, y))
602 +                                break;
603                  }
604          if (n < 0)                      /* found something? */
605                  return;
# Line 590 | Line 623 | register int   h, v;
623   }
624  
625  
626 + static int
627 + blockedge(vp, bi0, bi1)                 /* check for edge between blocks? */
628 + register struct ODview  *vp;
629 + register int    bi0, bi1;
630 + {
631 +        if (bi1 < 0)
632 +                return(1);              /* end off view */
633 +        if (CHK4(vp->emap, bi1))
634 +                return(1);              /* end has edges */
635 +        if (bi1 == bi0+1 || bi1 == bi0-1 ||
636 +                        bi1 == bi0+vp->hlow || bi1 == bi0-vp->hlow)
637 +                return(0);              /* end in adjacent block -- no edges */
638 +        return(1);                      /* conservative for rarer case */
639 + }
640 +
641 +
642   odDrawSamp(vn, id)                      /* draw view sample */
643   int     vn;
644   register int    id;
645   {
646          GLshort arm[MAXFAN][3];
647 <        int     narms, blockindex, bi1;
647 >        int     narms, blockindex;
648          register struct ODview  *vp;
649          double  size;
650          int     home_edges;
# Line 612 | Line 661 | register int   id;
661          if (vp->emap != NULL) {         /* check for edge collisions */
662                  home_edges = CHK4(vp->emap, blockindex);
663                  for (i = 0; i < narms; i++)
664 <                        /* the following test is flawed, because we could
665 <                         * be passing through a block on a diagonal run */
617 <                        if (home_edges ||
618 <                                ( (bi1 = getblock(vp, arm[i][0], arm[i][1]))
619 <                                                != blockindex &&
620 <                                        (bi1 < 0 || CHK4(vp->emap, bi1)) ))
664 >                        if (home_edges || blockedge(vp, blockindex,
665 >                                        getblock(vp, arm[i][0], arm[i][1])))
666                                  clip_edge(arm[i], odS.ip[id], vp);
667          }
668                                          /* draw triangle fan */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines