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

Comparing ray/src/hd/rhdisp3.c (file contents):
Revision 3.7 by gregl, Wed Nov 26 20:12:19 1997 UTC vs.
Revision 3.8 by gregl, Fri Dec 19 11:54:16 1997 UTC

# Line 84 | Line 84 | getback:
84   * The ray directions that define the pyramid in visit_cells() needn't
85   * be normalized, but they must be given in clockwise order as seen
86   * from the pyramid's apex (origin).
87 + * If no cell centers fall within the domain, the closest cell is visited.
88   */
89   int
90   visit_cells(orig, pyrd, hp, vf, dp)     /* visit cells within a pyramid */
91   FVECT   orig, pyrd[4];          /* pyramid ray directions in clockwise order */
92 < HOLO    *hp;
92 > register HOLO   *hp;
93   int     (*vf)();
94   char    *dp;
95   {
96 <        int     n = 0;
96 >        int     ncalls = 0, n = 0;
97          int     inflags = 0;
98          FVECT   gp, pn[4], lo, ld;
99          double  po[4], lbeg, lend, d, t;
100 <        GCOORD  gc;
100 >        GCOORD  gc, gc2[2];
101          register int    i;
102                                          /* figure out whose side we're on */
103          hdgrid(gp, hp, orig);
# Line 142 | Line 143 | char   *dp;
143                          if (lbeg >= lend)
144                                  continue;
145                          i = lend + .5;          /* visit cells on this scan */
146 <                        for (gc.i[0] = lbeg + .5; gc.i[0] < i; gc.i[0]++)
146 >                        for (gc.i[0] = lbeg + .5; gc.i[0] < i; gc.i[0]++) {
147                                  n += (*vf)(&gc, dp);
148 +                                ncalls++;
149 +                        }
150                  }
151          }
152 <        return(n);
152 >        if (ncalls)                     /* got one at least */
153 >                return(n);
154 >                                        /* else find closest cell */
155 >        VSUM(ld, pyrd[0], pyrd[1], 1.);
156 >        VSUM(ld, ld, pyrd[2], 1.);
157 >        VSUM(ld, ld, pyrd[3], 1.);
158 > #if 0
159 >        if (normalize(ld) == 0.0)       /* technically not necessary */
160 >                return(0);
161 > #endif
162 >        d = hdinter(gc2, NULL, &t, hp, orig, ld);
163 >        if (d >= FHUGE || t <= 0.)
164 >                return(0);
165 >        return((*vf)(gc2+1, dp));       /* visit it */
166   }
167  
168  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines