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

Comparing ray/src/common/dircode.c (file contents):
Revision 2.10 by greg, Tue Aug 27 23:51:23 2019 UTC vs.
Revision 2.11 by greg, Wed Mar 4 02:55:43 2020 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9  
10   #include "rtmath.h"
11  
12 < #define DCSCALE         11585.2         /* (1<<13)*sqrt(2) */
12 > #define DCSCALE         11584.7         /* (1<<13)*sqrt(2) - .5 */
13   #define FXNEG           01
14   #define FYNEG           02
15   #define FZNEG           04
# Line 28 | Line 28 | encodedir(FVECT dv)            /* encode a normalized direction
28  
29          for (i = 0; i < 3; i++)
30                  if (dv[i] < 0.) {
31 <                        cd[i] = (int)(dv[i] * -DCSCALE);
31 >                        cd[i] = (int)(dv[i] * -DCSCALE + .5);
32                          dc |= FXNEG<<i;
33                  } else
34 <                        cd[i] = (int)(dv[i] * DCSCALE);
34 >                        cd[i] = (int)(dv[i] * DCSCALE + .5);
35          if (!(cd[0] | cd[1] | cd[2]))
36                  return(0);              /* zero normal */
37          if (cd[0] <= cd[1]) {
# Line 94 | Line 94 | decodedir(FVECT dv, int32 dc)  /* decode a normalized d
94                  dv[0] = dv[1] = dv[2] = 0.;
95                  return;
96          }
97 <        d1 = ((dc>>F1SFT & FMASK)+.5)*(1./DCSCALE);
98 <        d2 = ((dc>>F2SFT & FMASK)+.5)*(1./DCSCALE);
97 >        d1 = (dc>>F1SFT & FMASK)*(1./DCSCALE);
98 >        d2 = (dc>>F2SFT & FMASK)*(1./DCSCALE);
99          der = sqrt(1. - d1*d1 - d2*d2);
100          dv[itab[ndx][0]] = d1;
101          dv[itab[ndx][1]] = d2;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines