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

Comparing ray/src/util/rmatrix.c (file contents):
Revision 2.39 by greg, Sat Dec 28 18:05:14 2019 UTC vs.
Revision 2.42 by greg, Thu Mar 26 18:04:24 2020 UTC

# Line 100 | Line 100 | get_dminfo(char *s, void *p)
100                  ip->swapin = (nativebigendian() != i);
101                  return(0);
102          }
103 +        if (isexpos(s)) {
104 +                double  d = exposval(s);
105 +                scalecolor(ip->mtx, d);
106 +                return(0);
107 +        }
108 +        if (iscolcor(s)) {
109 +                COLOR   ctmp;
110 +                colcorval(ctmp, s);
111 +                multcolor(ip->mtx, ctmp);
112 +                return(0);
113 +        }
114          if (!formatval(fmt, s)) {
115                  rmx_addinfo(ip, s);
116                  return(0);
# Line 150 | Line 161 | rmx_load_float(RMATRIX *rm, FILE *fp)
161   static int
162   rmx_load_double(RMATRIX *rm, FILE *fp)
163   {
164 <        int     i, j;
164 >        int     i;
165  
166 <        for (i = 0; i < rm->nrows; i++)
167 <            for (j = 0; j < rm->ncols; j++) {
168 <                if (getbinary(&rmx_lval(rm,i,j,0), sizeof(double), rm->ncomp, fp) != rm->ncomp)
169 <                    return(0);
166 >        if (&rmx_lval(rm,0,0,0) - &rmx_lval(rm,1,0,0) != rm->ncols*rm->ncomp) {
167 >                fputs("Code error in rmx_load_double()\n", stderr);
168 >                exit(1);
169 >        }
170 >        for (i = 0; i < rm->nrows; i++) {
171 >                if (getbinary(&rmx_lval(rm,i,0,0), sizeof(double)*rm->ncomp,
172 >                                        rm->ncols, fp) != rm->ncols)
173 >                        return(0);
174                  if (rm->swapin)
175 <                    swap64((char *)&rmx_lval(rm,i,j,0), rm->ncomp);
176 <            }
175 >                        swap64((char *)&rmx_lval(rm,i,0,0), rm->ncols*rm->ncomp);
176 >        }
177          return(1);
178   }
179  
# Line 226 | Line 241 | rmx_load(const char *inspec)
241          dinfo.dtype = DTascii;                  /* assumed w/o FORMAT */
242          dinfo.swapin = 0;
243          dinfo.info = NULL;
244 +        dinfo.mtx[0] = dinfo.mtx[1] = dinfo.mtx[2] = 1.;
245          if (getheader(fp, get_dminfo, &dinfo) < 0) {
246                  fclose(fp);
247                  return(NULL);
# Line 272 | Line 288 | rmx_load(const char *inspec)
288          case DTxyze:
289                  if (!rmx_load_rgbe(dnew, fp))
290                          goto loaderr;
291 <                dnew->dtype = dinfo.dtype;
291 >                dnew->dtype = dinfo.dtype;      /* undo exposure? */
292 >                if ((dinfo.mtx[0] != 1.) | (dinfo.mtx[1] != 1.) |
293 >                                (dinfo.mtx[2] != 1.)) {
294 >                        dinfo.mtx[0] = 1./dinfo.mtx[0];
295 >                        dinfo.mtx[1] = 1./dinfo.mtx[1];
296 >                        dinfo.mtx[2] = 1./dinfo.mtx[2];
297 >                        rmx_scale(dnew, dinfo.mtx);
298 >                }
299                  break;
300          default:
301                  goto loaderr;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines