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

Comparing ray/src/ot/cvmesh.c (file contents):
Revision 2.11 by greg, Fri Feb 18 19:00:43 2011 UTC vs.
Revision 2.12 by greg, Fri Jan 24 01:26:44 2014 UTC

# Line 75 | Line 75 | nomem:
75   }
76  
77  
78 int
79 cvpoly( /* convert a polygon to extended triangles */
80        OBJECT  mo,
81        int     n,
82        FVECT   *vp,
83        FVECT   *vn,
84        RREAL   (*vc)[2]
85 )
86 {
87        int     tcnt = 0;
88        int     flags;
89        RREAL   *tn[3], *tc[3];
90        int     *ord;
91        int     i, j;
92
93        if (n < 3)              /* degenerate face */
94                return(0);
95        flags = MT_V;
96        if (vn != NULL) {
97                tn[0] = vn[0]; tn[1] = vn[1]; tn[2] = vn[2];
98                flags |= MT_N;
99        } else {
100                tn[0] = tn[1] = tn[2] = NULL;
101        }
102        if (vc != NULL) {
103                tc[0] = vc[0]; tc[1] = vc[1]; tc[2] = vc[2];
104                flags |= MT_UV;
105        } else {
106                tc[0] = tc[1] = tc[2] = NULL;
107        }
108        if (n == 3)             /* output single triangle */
109                return(cvtri(mo, vp[0], vp[1], vp[2],
110                                tn[0], tn[1], tn[2],
111                                tc[0], tc[1], tc[2]));
112
113                                /* decimate polygon (assumes convex) */
114        ord = (int *)malloc(n*sizeof(int));
115        if (ord == NULL)
116                error(SYSTEM, "out of memory in cvpoly");
117        for (i = n; i--; )
118                ord[i] = i;
119        while (n >= 3) {
120                if (flags & MT_N)
121                        for (i = 3; i--; )
122                                tn[i] = vn[ord[i]];
123                if (flags & MT_UV)
124                        for (i = 3; i--; )
125                                tc[i] = vc[ord[i]];
126                tcnt += cvtri(mo, vp[ord[0]], vp[ord[1]], vp[ord[2]],
127                                tn[0], tn[1], tn[2],
128                                tc[0], tc[1], tc[2]);
129                        /* remove vertex and rotate */
130                n--;
131                j = ord[0];
132                for (i = 0; i < n-1; i++)
133                        ord[i] = ord[i+2];
134                ord[i] = j;
135        }
136        free((void *)ord);
137        return(tcnt);
138 }
139
140
78   static void
79   add2bounds(             /* add point and uv coordinate to bounds */
80          FVECT   vp,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines