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

Comparing ray/src/cv/obj2rad.c (file contents):
Revision 2.17 by greg, Sat Feb 22 02:07:23 2003 UTC vs.
Revision 2.18 by greg, Tue Mar 4 01:42:29 2003 UTC

# Line 557 | Line 557 | char   *v1, *v2, *v3;
557          BARYCCM bvecs;
558          FLOAT   bcoor[3][3];
559          int     texOK, patOK;
560 +        int     flatness;
561          register int    i;
562  
563          if ((mod = getmtl()) == NULL)
# Line 565 | Line 566 | char   *v1, *v2, *v3;
566          if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3))
567                  return(0);
568                                          /* compute barycentric coordinates */
569 <        if (!flatten && v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0)
570 <                switch (flat_tri(vlist[v1i[0]], vlist[v2i[0]], vlist[v3i[0]],
571 <                        vnlist[v1i[2]], vnlist[v2i[2]], vnlist[v3i[2]])) {
571 <                case DEGEN:             /* zero area */
572 <                        return(-1);
573 <                case RVFLAT:            /* reversed normals, but flat */
574 <                case ISFLAT:            /* smoothing unnecessary */
575 <                        texOK = 0;
576 <                        break;
577 <                case RVBENT:            /* reversed normals with smoothing */
578 <                case ISBENT:            /* proper smoothing */
579 <                        texOK = 1;
580 <                        break;
581 <                }
569 >        if (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0)
570 >                flatness = flat_tri(vlist[v1i[0]], vlist[v2i[0]], vlist[v3i[0]],
571 >                                vnlist[v1i[2]], vnlist[v2i[2]], vnlist[v3i[2]]);
572          else
573 +                flatness = ISFLAT;
574 +
575 +        switch (flatness) {
576 +        case DEGEN:                     /* zero area */
577 +                return(-1);
578 +        case RVFLAT:                    /* reversed normals, but flat */
579 +        case ISFLAT:                    /* smoothing unnecessary */
580                  texOK = 0;
581 +                break;
582 +        case RVBENT:                    /* reversed normals with smoothing */
583 +        case ISBENT:                    /* proper smoothing */
584 +                texOK = 1;
585 +                break;
586 +        }
587 +        if (flatten)
588 +                texOK = 0;
589   #ifdef TEXMAPS
590          patOK = mapname[0] && (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0);
591   #else
# Line 618 | Line 623 | char   *v1, *v2, *v3;
623                  put_baryc(&bvecs, bcoor, 2);
624          }
625   #endif
626 <                                        /* put out triangle */
626 >                                        /* put out (reversed) triangle */
627          printf("\n%s polygon %s.%d\n", mod, getonm(), faceno);
628          printf("0\n0\n9\n");
629 <        pvect(vlist[v1i[0]]);
630 <        pvect(vlist[v2i[0]]);
631 <        pvect(vlist[v3i[0]]);
632 <
629 >        if (flatness == RVFLAT || flatness == RVBENT) {
630 >                pvect(vlist[v3i[0]]);
631 >                pvect(vlist[v2i[0]]);
632 >                pvect(vlist[v1i[0]]);
633 >        } else {
634 >                pvect(vlist[v1i[0]]);
635 >                pvect(vlist[v2i[0]]);
636 >                pvect(vlist[v3i[0]]);
637 >        }
638          return(1);
639   }
640  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines