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

Comparing ray/src/hd/sm_ogl.c (file contents):
Revision 3.12 by gwlarson, Tue Jan 5 16:52:38 1999 UTC vs.
Revision 3.13 by gwlarson, Sun Jan 10 10:27:48 1999 UTC

# Line 47 | Line 47 | static QT_LUENT        *qt_htbl = NULL;        /* quadtree cache */
47   static int      qt_hsiz = 0;            /* quadtree cache size */
48  
49  
50 + typedef struct _T_DEPTH {
51 +  int tri;
52 +  double depth;
53 + }T_DEPTH;
54 +
55   /*
56 <  * smClean()           : display has been wiped clean
57 <  *
56 >  * smClean(tmflag)     : display has been wiped clean
57 >  *     int tmflag;
58    * Called after display has been effectively cleared, meaning that all
59    * geometry must be resent down the pipeline in the next call to smUpdate().
60 +  * If tmflag is set, tone-mapping should be performed
61    */
62 < smClean()
62 > smClean(tmflag)
63 >   int tmflag;
64   {
65      smClean_notify = TRUE;
66 +    if(tmflag)
67 +       SM_TONE_MAP(smMesh) = 0;
68   }
69  
70   int
# Line 281 | Line 290 | smRender_stree(sm, qual)       /* render some quadtree trian
290   SM *sm;
291   int qual;
292   {
293 <  int i, ntarget;
293 >  int i, n,ntarget;
294    int lvlcnt[QT_MAX_LEVELS];
295    STREE *st;
296 <
296 >  int4 *active_flag;
297    if (qual <= 0)
298      return;
299                                  /* compute rendering target */
300    ntarget = 0;
301 <  SM_FOR_ALL_ACTIVE_TRIS(sm,i)
302 <    ntarget++;
303 <  ntarget = ntarget*qual/100;
301 >
302 >  active_flag = SM_NTH_FLAGS(sm,T_ACTIVE_FLAG);
303 >  for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
304 >    if(active_flag[n])
305 >      for(i=0; i < 32; i++)
306 >        if(active_flag[n] & (1L << i))
307 >          ntarget++;
308 >
309 >  ntarget = ntarget*qual/MAXQUALITY;
310    if (!ntarget)
311      return;
312    for (i = QT_MAX_LEVELS; i--; )
# Line 328 | Line 343 | FVECT vp,vc;
343    /* NOTE:Triangles are defined clockwise:historical relative to spherical
344       tris: could change
345       */
346 +  if(bg0 && bg1 && bg2)
347 +    return;
348 +
349    cnt = 0;
350    d = 0.0;
351    rgb[0] = rgb[1] = rgb[2] = 0;
352  
335  if(bg0 && bg1 && bg2)
336    return;
337
353    if(!bg0)
354    {
355      rgb[0] += rgb0[0];
# Line 456 | Line 471 | double d;
471  
472   }
473  
474 < smRender_mesh(sm,vp,clr)
474 > smRender_mesh(sm,vp)
475   SM *sm;
476   FVECT vp;
462 int clr;
477   {
478 <  int i,bg0,bg1,bg2;
478 >  int i,n,bg0,bg1,bg2;
479    double d;
480    int v0_id,v1_id,v2_id;
481    TRI *tri;
482    float (*wp)[3];
483    BYTE  (*rgb)[3];
484 +  int4  *active_flag,*bg_flag;
485  
486    wp = SM_WP(sm);
487    rgb =SM_RGB(sm);
# Line 476 | Line 491 | int clr;
491    /* First draw background polygons */
492    glDisable(GL_DEPTH_TEST);
493    glBegin(GL_TRIANGLES);
494 <  /* Maintain a list? */
495 <  SM_FOR_ALL_ACTIVE_BG_TRIS(sm,i)
496 <  {
497 <    if (clr)
498 <      SM_CLR_NTH_T_NEW(sm,i);
499 <    tri = SM_NTH_TRI(sm,i);
500 <    v0_id = T_NTH_V(tri,0);
501 <    v1_id = T_NTH_V(tri,1);
502 <    v2_id = T_NTH_V(tri,2);
503 <    render_bg_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
504 <                   rgb[v2_id],vp,SM_VIEW_CENTER(sm),d);
505 <  }
494 >
495 >  active_flag = SM_NTH_FLAGS(sm,T_ACTIVE_FLAG);
496 >  bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG);
497 >  for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
498 >    if(active_flag[n] & bg_flag[n])
499 >      for(i=0; i < 32; i++)
500 >        if(active_flag[n] & bg_flag[n] & (1L << i))
501 >         {
502 >           tri = SM_NTH_TRI(sm,(n<<5)+i);
503 >           v0_id = T_NTH_V(tri,0);
504 >           v1_id = T_NTH_V(tri,1);
505 >           v2_id = T_NTH_V(tri,2);
506 >           render_bg_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
507 >                         rgb[v2_id],vp,SM_VIEW_CENTER(sm),d);
508 >         }
509    glEnd();
510 +
511    glEnable(GL_DEPTH_TEST);
512    glBegin(GL_TRIANGLES);
513 <  SM_FOR_ALL_ACTIVE_FG_TRIS(sm,i)
514 <  {
515 <    if (clr)
516 <      SM_CLR_NTH_T_NEW(sm,i);
517 <    tri = SM_NTH_TRI(sm,i);
518 <    v0_id = T_NTH_V(tri,0);
519 <    v1_id = T_NTH_V(tri,1);
520 <    v2_id = T_NTH_V(tri,2);
521 <    bg0 = SM_DIR_ID(sm,v0_id) || SM_BASE_ID(sm,v0_id);
522 <    bg1 = SM_DIR_ID(sm,v1_id) || SM_BASE_ID(sm,v1_id);
523 <    bg2 = SM_DIR_ID(sm,v2_id) || SM_BASE_ID(sm,v2_id);
524 <    if(!(bg0 || bg1 || bg2))
525 <        render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
526 <                   rgb[v2_id])
527 <   else
528 <        render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
529 <           rgb[v2_id],bg0,bg1,bg2,vp,SM_VIEW_CENTER(sm));
530 <  }
513 >  for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
514 >    if(active_flag[n])
515 >      for(i=0; i < 32; i++)
516 >        if((active_flag[n] & (1L << i)) && !(bg_flag[n] & (1L << i)))
517 >         {
518 >           tri = SM_NTH_TRI(sm,(n<<5)+i);
519 >           v0_id = T_NTH_V(tri,0);
520 >           v1_id = T_NTH_V(tri,1);
521 >           v2_id = T_NTH_V(tri,2);
522 >           bg0 = SM_DIR_ID(sm,v0_id) || SM_BASE_ID(sm,v0_id);
523 >           bg1 = SM_DIR_ID(sm,v1_id) || SM_BASE_ID(sm,v1_id);
524 >           bg2 = SM_DIR_ID(sm,v2_id) || SM_BASE_ID(sm,v2_id);
525 >           if(!(bg0 || bg1 || bg2))
526 >             render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
527 >                        rgb[v2_id])
528 >               else
529 >                 render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],
530 >                  rgb[v1_id],rgb[v2_id],bg0,bg1,bg2,vp,SM_VIEW_CENTER(sm));
531 >         }
532    glEnd();
533  
534    glPopAttrib();
# Line 519 | Line 539 | compare_tri_depths(T_DEPTH *td1,T_DEPTH *td2)
539   {
540    double d;
541  
522  if(td1->tri==-1)
523    {
524      if(td2->tri==-1)
525        return(0);
526      else
527        return(-1);
528    }
529  if(td2->tri==-1)
530    return(1);
531
542    d = td2->depth-td1->depth;
543    
544    if(d > 0.0)
# Line 537 | Line 547 | compare_tri_depths(T_DEPTH *td1,T_DEPTH *td2)
547      return(-1);
548    
549    return(0);
550 +
551   }
552  
553 < int
554 < compare_tri_depths_old(T_DEPTH *td1,T_DEPTH *td2)
555 < {
545 <  double d;
553 > #ifdef DEBUG
554 > #define freebuf(b)  tempbuf(-1)
555 > #endif
556  
547  d = td2->depth-td1->depth;
548  
549  if(d > 0.0)
550    return(1);
551  if(d < 0.0)
552    return(-1);
553  
554  return(0);
555 }
557  
558 < LIST
559 < *smDepth_sort_tris(sm,vp,td)
560 < SM *sm;
560 < FVECT vp;
561 < T_DEPTH *td;
558 > char *
559 > tempbuf(len)                    /* get a temporary buffer */
560 > unsigned  len;
561   {
562 <  int i,j,t_id,v;
563 <  TRI *tri;
564 <  double d,min_d;
566 <  LIST *tlist=NULL;
567 <  FVECT diff;
562 >        extern char  *malloc(), *realloc();
563 >        static char  *tempbuf = NULL;
564 >        static unsigned  tempbuflen = 0;
565  
566 <  i = 0;
567 <  SM_FOR_ALL_NEW_TRIS(sm,t_id)
568 <  {
569 <    if(SM_BG_TRI(sm,t_id))
570 <    {
571 <        tlist = push_data(tlist,t_id);
572 <        continue;
573 <    }
574 <    tri = SM_NTH_TRI(sm,t_id);
575 <    td[i].tri = t_id;
576 <    min_d = -1;
577 <    for(j=0;j < 3;j++)
581 <    {
582 <        v = T_NTH_V(tri,j);
583 <        if(!SM_BG_SAMPLE(sm,v))
584 <        {
585 <            VSUB(diff,SM_NTH_WV(sm,v),vp);
586 <            d = DOT(diff,diff);
587 <            if(min_d == -1 || d < min_d)
588 <               min_d = d;
566 > #ifdef DEBUG
567 >        static int in_use=FALSE;
568 >
569 >        if(len == -1)
570 >          {
571 >            in_use = FALSE;
572 >            return(NULL);
573 >          }
574 >        if(in_use)
575 >        {
576 >            eputs("Buffer in use:cannot allocate:tempbuf()\n");
577 >            return(NULL);
578          }
579 <    }
580 <    td[i].depth = min_d;
581 <    i++;
582 <  }
583 <  td[i].tri = -1;
584 <  if(i)
585 <     qsort((void *)td,i,sizeof(T_DEPTH),compare_tri_depths);
586 <  return(tlist);
579 > #endif
580 >        if (len > tempbuflen) {
581 >                if (tempbuflen > 0)
582 >                        tempbuf = realloc(tempbuf, len);
583 >                else
584 >                        tempbuf = malloc(len);
585 >                tempbuflen = tempbuf==NULL ? 0 : len;
586 >        }
587 > #ifdef DEBUG
588 >        in_use = TRUE;
589 > #endif
590 >        return(tempbuf);
591   }
592  
593 <
601 <
602 < LIST
603 < *smOrder_new_tris(sm,vp,td,sort)
593 > smOrder_new_tris(sm,vp,td)
594   SM *sm;
595   FVECT vp;
596   T_DEPTH *td;
607 int sort;
597   {
598 <  int i,j,t_id,v;
598 >  int n,i,j,tcnt,v;
599    TRI *tri;
600    double d,min_d;
612  LIST *tlist=NULL;
601    FVECT diff;
602 +  int4 *new_flag,*bg_flag;
603  
604 <  i = 0;
605 <  for(i=0; i < smNew_tri_cnt;i++)
606 <  {
607 <    t_id = smNew_tris[i].tri;
608 <
609 <    tri = SM_NTH_TRI(sm,t_id);
610 <    if(!T_IS_VALID(tri))
611 <    {
612 <      smNew_tris[i].tri = -1;
613 <      continue;
614 <    }
615 <    if(SM_BG_TRI(sm,t_id))
616 <    {
617 <        tlist = push_data(tlist,t_id);
618 <        smNew_tris[i].tri = -1;
619 <        continue;
620 <    }
621 <    if(!sort)
622 <      continue;
623 <    min_d = -1;
624 <    for(j=0;j < 3;j++)
625 <    {
626 <        v = T_NTH_V(tri,j);
638 <        if(!SM_BG_SAMPLE(sm,v))
639 <        {
640 <            VSUB(diff,SM_NTH_WV(sm,v),vp);
641 <            d = DOT(diff,diff);
642 <            if(min_d == -1 || d < min_d)
643 <               min_d = d;
644 <        }
645 <    }
646 <    td[i].depth = min_d;
604 >  tcnt=0;
605 >  new_flag = SM_NTH_FLAGS(sm,T_NEW_FLAG);
606 >  bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG);
607 >  for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
608 >    if(new_flag[n] & ~bg_flag[n])
609 >      for(i=0; i < 32; i++)
610 >        if(new_flag[n] & (1L << i) & ~bg_flag[n])
611 >         {
612 >           tri = SM_NTH_TRI(sm,(n<<5)+i);
613 >           td[tcnt].tri = (n << 5)+i;
614 >           min_d = -1;
615 >           for(j=0;j < 3;j++)
616 >             {
617 >               v = T_NTH_V(tri,j);
618 >               if(!SM_BG_SAMPLE(sm,v))
619 >                 {
620 >                   VSUB(diff,SM_NTH_WV(sm,v),vp);
621 >                   d = DOT(diff,diff);
622 >                   if(min_d == -1 || d < min_d)
623 >                     min_d = d;
624 >                 }
625 >             }
626 >           td[tcnt++].depth = min_d;
627    }
628 <  if(!sort)
629 <    return(tlist);
630 <  qsort((void *)td,smNew_tri_cnt,sizeof(T_DEPTH),compare_tri_depths);
651 <  return(tlist);
628 >  td[tcnt].tri = -1;
629 >  if(tcnt)
630 >      qsort((void *)td,tcnt,sizeof(T_DEPTH),compare_tri_depths);
631   }
632  
633  
# Line 657 | Line 636 | SM *sm;
636   FVECT vp;
637   int clr;
638   {
639 <  static T_DEPTH *td= NULL;
661 <  static int tsize = 0;
662 <  int i,v0_id,v1_id,v2_id,bg0,bg1,bg2;
639 >  int i,n,v0_id,v1_id,v2_id,bg0,bg1,bg2;
640    GLint depth_test;
641    double d;
665  LIST *bglist;
642    TRI *tri;
643    float (*wp)[3];
644    BYTE  (*rgb)[3];
645 <
645 >  int4  *new_flag,*bg_flag;
646 >  T_DEPTH *td = NULL;
647    /* For all of the NEW triangles (since last update): assume
648       ACTIVE. Go through and sort on depth value (from vp). Turn
649       Depth Buffer test off and render back-front
650       */
674  /* NOTE: could malloc each time or hard code */
675 #if 0
676  if(smNew_tri_cnt > tsize)
677  {
678    if(td)
679      free((char *)td);
680    td = (T_DEPTH *)malloc(smNew_tri_cnt*sizeof(T_DEPTH));
681    tsize = smNew_tri_cnt;
682  }
683  if(!td)
684  {
685    error(SYSTEM,"smUpdate_Rendered_mesh:Cannot allocate memory\n");
686  }
687  bglist = smDepth_sort_tris(sm,vp,td);
688 #else
689  td = smNew_tris;
651    if(!EQUAL_VEC3(SM_VIEW_CENTER(sm),vp))
652 <    bglist = smOrder_new_tris(sm,vp,td,1);
653 <  else
654 <    bglist = smOrder_new_tris(sm,vp,td,0);
652 >  {
653 >    /* Must depth sort if view points do not coincide */
654 >    td = (T_DEPTH *)tempbuf(smNew_tri_cnt*sizeof(T_DEPTH));
655 > #ifdef DEBUG
656 >    if(!td)
657 >        eputs("Cant create list:wont depth sort:smUpdate_rendered_mesh\n");
658   #endif
659 +    smOrder_new_tris(sm,vp,td);
660 +  }
661    wp = SM_WP(sm);
662    rgb =SM_RGB(sm);
663    /* Turn Depth Test off -- using Painter's algorithm */
664    glPushAttrib(GL_DEPTH_BUFFER_BIT);
665    glDepthFunc(GL_ALWAYS);
666    d = (dev_zmin+dev_zmax)/2.0;
667 +
668    /* Now render back-to front */
669    /* First render bg triangles */
670 +  new_flag = SM_NTH_FLAGS(sm,T_NEW_FLAG);
671 +  bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG);
672    glBegin(GL_TRIANGLES);
673 <  while(bglist)
674 <  {
675 <    i = pop_list(&bglist);
676 <    if (clr)
677 <      SM_CLR_NTH_T_NEW(sm,i);
678 <    tri = SM_NTH_TRI(sm,i);
679 <    v0_id = T_NTH_V(tri,0);
680 <    v1_id = T_NTH_V(tri,1);
681 <    v2_id = T_NTH_V(tri,2);
682 <    render_bg_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
683 <                   rgb[v2_id],vp,SM_VIEW_CENTER(sm),d);
684 <  }
673 >  for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
674 >    if(new_flag[n] & bg_flag[n])
675 >      for(i=0; i < 32; i++)
676 >        if(new_flag[n] & (1L << i) & bg_flag[n] )
677 >         {
678 >           tri = SM_NTH_TRI(sm,(n<<5)+i);
679 >           v0_id = T_NTH_V(tri,0);
680 >           v1_id = T_NTH_V(tri,1);
681 >           v2_id = T_NTH_V(tri,2);
682 >           render_bg_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
683 >                         rgb[v2_id],vp,SM_VIEW_CENTER(sm),d);
684 >         }
685    glEnd();
686  
687  
688    glBegin(GL_TRIANGLES);
689 <  i=0;
721 <  while(i != smNew_tri_cnt)
689 >  if(!td)
690    {
691 <    if(td[i].tri == -1)
692 <      {
693 <        i++;
694 <        continue;
695 <      }
696 <    if (clr)
697 <      SM_CLR_NTH_T_NEW(sm,td[i].tri);
698 <    tri = SM_NTH_TRI(sm,td[i].tri);
699 <    v0_id = T_NTH_V(tri,0);
700 <    v1_id = T_NTH_V(tri,1);
701 <    v2_id = T_NTH_V(tri,2);
702 <    bg0 = SM_DIR_ID(sm,v0_id) || SM_BASE_ID(sm,v0_id);
703 <    bg1 = SM_DIR_ID(sm,v1_id) || SM_BASE_ID(sm,v1_id);
704 <    bg2 = SM_DIR_ID(sm,v2_id) || SM_BASE_ID(sm,v2_id);
705 <    if(!(bg0 || bg1 || bg2))
706 <      render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
707 <                 rgb[v2_id])
708 <   else
709 <     render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
710 <                      rgb[v2_id],bg0,bg1,bg2,vp,SM_VIEW_CENTER(sm));
711 <    i++;
691 >    for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;)
692 >     if(new_flag[n] & ~bg_flag[n])
693 >      for(i=0; i < 32; i++)
694 >        if(new_flag[n] & (1L << i) & ~bg_flag[n])
695 >         {
696 >           tri = SM_NTH_TRI(sm,(n<<5)+i);
697 >           /* Dont need to check for valid tri because flags are
698 >              cleared on delete
699 >            */
700 >           v0_id = T_NTH_V(tri,0);
701 >           v1_id = T_NTH_V(tri,1);
702 >           v2_id = T_NTH_V(tri,2);
703 >           bg0 = SM_DIR_ID(sm,v0_id) || SM_BASE_ID(sm,v0_id);
704 >           bg1 = SM_DIR_ID(sm,v1_id) || SM_BASE_ID(sm,v1_id);
705 >           bg2 = SM_DIR_ID(sm,v2_id) || SM_BASE_ID(sm,v2_id);
706 >           if(!(bg0 || bg1 || bg2))
707 >             render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
708 >                        rgb[v2_id])
709 >           else
710 >             render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],
711 >                              rgb[v1_id],rgb[v2_id],bg0,bg1,bg2,vp,
712 >                              SM_VIEW_CENTER(sm));
713 >         }
714    }
715 +  else
716 +  {
717 +    for(i=0; td[i].tri != -1;i++)
718 +    {
719 +      tri = SM_NTH_TRI(sm,td[i].tri);
720 +      /* Dont need to check for valid tri because flags are
721 +         cleared on delete
722 +         */
723 +      v0_id = T_NTH_V(tri,0);
724 +      v1_id = T_NTH_V(tri,1);
725 +      v2_id = T_NTH_V(tri,2);
726 +      bg0 = SM_DIR_ID(sm,v0_id) || SM_BASE_ID(sm,v0_id);
727 +      bg1 = SM_DIR_ID(sm,v1_id) || SM_BASE_ID(sm,v1_id);
728 +      bg2 = SM_DIR_ID(sm,v2_id) || SM_BASE_ID(sm,v2_id);
729 +      if(!(bg0 || bg1 || bg2))
730 +        render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id],
731 +                   rgb[v2_id])
732 +          else
733 +            render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],
734 +                             rgb[v1_id],rgb[v2_id],bg0,bg1,bg2,vp,
735 +                             SM_VIEW_CENTER(sm));
736 +    }
737 + #ifdef DEBUG
738 +    freebuf(td);
739 + #endif
740 +  }
741    glEnd();
742  
743    /* Restore Depth Test */
# Line 765 | Line 761 | smUpdate(view,qual)
761     int qual;
762   {
763    double d;
764 <  int last_update;
769 <  int t;
764 >  int last_update,t;
765  
766 +  if(!smMesh)
767 +    return;
768 +
769    /* If view has moved beyond epsilon from canonical: must rebuild -
770       epsilon is calculated as running avg of distance of sample points
771       from canonical view: m = 1/(AVG(1/r)): some fraction of this
772     */
775
776  if(!smMesh)
777    return;
778
773    d = DIST(view->vp,SM_VIEW_CENTER(smMesh));
774 <  if(qual >= 100 && d > SM_ALLOWED_VIEW_CHANGE(smMesh))
774 >  if(qual >= MAXQUALITY  && d > SM_ALLOWED_VIEW_CHANGE(smMesh))
775    {
776        /* Re-build the mesh */
777   #ifdef TEST_DRIVER
# Line 787 | Line 781 | smUpdate(view,qual)
781        smRebuild_mesh(smMesh,view);
782        smClean_notify = TRUE;
783    }
784 <  /* This is our final update iff qual==100 and view==&odev.v */
785 <  last_update = qual>=100 && view==&(odev.v);
784 >  /* This is our final update iff qual==MAXQUALITY and view==&odev.v */
785 >  last_update = qual>=MAXQUALITY && view==&(odev.v);
786    /* Check if we should draw ALL triangles in current frustum */
787 <  if(smClean_notify || smNew_tri_cnt > SM_SAMPLE_TRIS(smMesh)*SM_INC_PERCENT)
787 >  if(smClean_notify || smNew_tri_cnt>SM_SAMPLE_TRIS(smMesh)*SM_INC_PERCENT)
788    {
789   #ifdef TEST_DRIVER
790      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
791   #else
792 <    if ( SM_TONE_MAP(smMesh) < SM_NUM_SAMP(smMesh))
792 >    if (SM_TONE_MAP(smMesh) < SM_NUM_SAMP(smMesh))
793      {
794         tmClearHisto();
795         tmAddHisto(SM_BRT(smMesh),SM_NUM_SAMP(smMesh),1);
796 <       tmComputeMapping(0.,0.,0.);
796 >       if(tmComputeMapping(0.,0.,0.) != TM_E_OK)
797 >         return;
798         tmMapPixels(SM_RGB(smMesh),SM_BRT(smMesh),SM_CHR(smMesh),
799                     SM_NUM_SAMP(smMesh));
800      }
801   #endif
802      mark_tris_in_frustum(view);
803 <    if (qual <= 75)
803 >    if (qual <= (MAXQUALITY*3/4))
804          smRender_stree(smMesh,qual);
805      else
806 <        smRender_mesh(smMesh,view->vp,last_update);
806 >        smRender_mesh(smMesh,view->vp);
807   #ifdef TEST_DRIVER
808      glFlush();
809      glutSwapBuffers();
# Line 830 | Line 825 | smUpdate(view,qual)
825          if(tmComputeMapping(0.,0.,0.) != TM_E_OK)
826             return;
827      }
828 <    tmMapPixels(SM_NTH_RGB(smMesh,t),&SM_NTH_BRT(smMesh,t),
828 >      tmMapPixels(SM_NTH_RGB(smMesh,t),&SM_NTH_BRT(smMesh,t),
829                     SM_NTH_CHR(smMesh,t), SM_NUM_SAMP(smMesh)-t);
830          
831   #endif    
# Line 847 | Line 842 | smUpdate(view,qual)
842    {
843      smClean_notify = FALSE;
844      smNew_tri_cnt = 0;
850 #if 0  
845      smClear_flags(smMesh,T_NEW_FLAG);
852 #endif
846      qtCache_init(0);
847    }
848  
849   }
850 +
851 +
852 +
853 +
854 +
855 +
856 +
857 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines