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

Comparing ray/src/cv/bsdfinterp.c (file contents):
Revision 2.8 by greg, Wed Dec 12 04:49:59 2012 UTC vs.
Revision 2.9 by greg, Fri Dec 14 22:41:44 2012 UTC

# Line 151 | Line 151 | static int
151   in_mesh(MIGRATION *miga[3], unsigned char *emap, int nedges,
152                          const FVECT ivec, MIGRATION *mig)
153   {
154 <        MIGRATION       *ej1, *ej2;
155 <        RBFNODE         *tv;
154 >        RBFNODE         *tv[2];
155 >        MIGRATION       *sej[2], *dej[2];
156 >        int             i;
157                                                  /* check visitation record */
158          if (!check_edge(emap, nedges, mig, 1))
159                  return(0);
# Line 160 | Line 161 | in_mesh(MIGRATION *miga[3], unsigned char *emap, int n
161                  miga[0] = mig;                  /* close enough to edge */
162                  return(1);
163          }
164 <                                                /* do triangles either side */
165 <        for (ej1 = mig->rbfv[0]->ejl; ej1 != NULL;
166 <                                ej1 = nextedge(mig->rbfv[0],ej1)) {
167 <            if (ej1 == mig)
168 <                continue;
169 <            tv = opp_rbf(mig->rbfv[0],ej1);
170 <            for (ej2 = tv->ejl; ej2 != NULL; ej2 = nextedge(tv,ej2))
171 <                if (opp_rbf(tv,ej2) == mig->rbfv[1]) {
172 <                        int     do_ej1 = check_edge(emap, nedges, ej1, 0);
173 <                        int     do_ej2 = check_edge(emap, nedges, ej2, 0);
174 <                        if (do_ej1 && in_mesh(miga, emap, nedges, ivec, ej1))
175 <                                return(1);
176 <                        if (do_ej2 && in_mesh(miga, emap, nedges, ivec, ej2))
177 <                                return(1);
178 <                                                /* check just once */
178 <                        if (do_ej1 & do_ej2 && in_tri(mig->rbfv[0],
179 <                                                mig->rbfv[1], tv, ivec)) {
180 <                                miga[0] = mig;
181 <                                miga[1] = ej1;
182 <                                miga[2] = ej2;
183 <                                return(1);
164 >        if (!get_triangles(tv, mig))            /* do triangles either side? */
165 >                return(0);
166 >        for (i = 2; i--; ) {                    /* identify edges to check */
167 >                MIGRATION       *ej;
168 >                sej[i] = dej[i] = NULL;
169 >                if (tv[i] == NULL)
170 >                        continue;
171 >                for (ej = tv[i]->ejl; ej != NULL; ej = nextedge(tv[i],ej)) {
172 >                        RBFNODE *rbfop = opp_rbf(tv[i],ej);
173 >                        if (rbfop == mig->rbfv[0]) {
174 >                                if (check_edge(emap, nedges, ej, 0))
175 >                                        sej[i] = ej;
176 >                        } else if (rbfop == mig->rbfv[1]) {
177 >                                if (check_edge(emap, nedges, ej, 0))
178 >                                        dej[i] = ej;
179                          }
180                  }
181          }
182 +        for (i = 2; i--; ) {                    /* check triangles just once */
183 +                if (sej[i] != NULL && in_mesh(miga, emap, nedges, ivec, sej[i]))
184 +                        return(1);
185 +                if (dej[i] != NULL && in_mesh(miga, emap, nedges, ivec, dej[i]))
186 +                        return(1);
187 +                if ((sej[i] == NULL) | (dej[i] == NULL))
188 +                        continue;
189 +                if (in_tri(mig->rbfv[0], mig->rbfv[1], tv[i], ivec)) {
190 +                        miga[0] = mig;
191 +                        miga[1] = sej[i];
192 +                        miga[2] = dej[i];
193 +                        return(1);
194 +                }
195 +        }
196          return(0);                              /* not near this edge */
197   }
198  
# Line 231 | Line 240 | get_interp(MIGRATION *miga[3], FVECT invec)
240                          exit(1);
241                  }
242                                                  /* identify intersection  */
243 <                if (!in_mesh(miga, emap, nedges, invec, mig_list))
243 >                if (!in_mesh(miga, emap, nedges, invec, mig_list)) {
244 > #ifdef DEBUG
245 >                        fprintf(stderr,
246 >                        "Incident angle (%.1f,%.1f) deg. outside mesh\n",
247 >                                        get_theta180(invec), get_phi360(invec));
248 > #endif
249                          sym = -1;               /* outside mesh */
250 <                else if (miga[1] != NULL &&
250 >                } else if (miga[1] != NULL &&
251                                  (miga[2] == NULL || !order_triangle(miga))) {
252   #ifdef DEBUG
253                          fputs("Munged triangle in get_interp()\n", stderr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines