ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/RpictSimulManager.cpp
(Generate patch)

Comparing ray/src/rt/RpictSimulManager.cpp (file contents):
Revision 2.1 by greg, Wed Aug 14 20:05:23 2024 UTC vs.
Revision 2.2 by greg, Sun Aug 18 00:37:13 2024 UTC

# Line 50 | Line 50 | PixelAccess::SetPixel(int x, int y, const RAY *rp)
50                  scolor_out(col, primp, rp->rcol);
51                  return SetPixel(x, y, col, zv);
52          default:
53 <                error(INTERNAL, "missing color space type in SetPixel()");
53 >                error(INTERNAL, "botched color space type in SetPixel()");
54          }
55          return false;
56   }
# Line 79 | Line 79 | PixelAccess::SetColorSpace(RenderDataType cs, RGBPRIMP
79          case RDTrgb:
80                  primp = pr ? pr : stdprims;
81                  break;
82 <        default:                        // RDTscolr | RDTscolor
82 >        case RDTscolr:
83 >        case RDTscolor:
84                  primp = NULL;
85                  break;
86 +        default:
87 +                error(INTERNAL, "botched color space type in SetColorSpace()");
88          }
89          dtyp = RDTnewCT(dtyp, cs);
87        if (primp)
88                xyz2myrgbmat[0][0] = 0;
90          return true;
91   }
92  
# Line 138 | Line 139 | int
139   RpictSimulManager::RtCall(RAY *r, void *cd)
140   {
141          RpictSimulManager *     rsp = (RpictSimulManager *)cd;
142 <        const int               ty = r->rno / rsp->TWidth();
143 <        const int               tx = r->rno - (RNUMBER)ty*rsp->TWidth();
142 >        const int               ty = (r->rno-1) / rsp->TWidth();
143 >        const int               tx = r->rno-1 - (RNUMBER)ty*rsp->TWidth();
144  
145          if (ty >= rsp->THeight()) {
146                  error(INTERNAL, "bad pixel calculation position in RtCall()");
# Line 227 | Line 228 | RpictSimulManager::ComputePixel(int x, int y)
228          for (i = (dlim > FTINY)*3; i--; )
229                  rodir[1][i] *= dlim;
230  
231 <        return EnqueueRay(rodir[0], rodir[1], (RNUMBER)y*TWidth()+x);
231 >        return EnqueueRay(rodir[0], rodir[1], (RNUMBER)y*TWidth()+x+1);
232   }
233  
234   // Check if neighbor differences are below pixel sampling threshold
# Line 261 | Line 262 | RpictSimulManager::BelowSampThresh(int x, int y, const
262  
263   // Fill an interior square patch with interpolated values
264   void
265 < RpictSimulManager::FillSquare(int x, int y, const int noff[4][2])
265 > RpictSimulManager::FillSquare(const int x, const int y, const int noff[4][2])
266   {
267          SCOLOR  pval[4];
268          float   dist[4];
# Line 271 | Line 272 | RpictSimulManager::FillSquare(int x, int y, const int
272                  pacc.GetPixel(x+noff[i][0], y+noff[i][1], pval[i], &dist[i]);
273  
274          i = abs(noff[1][0]-noff[0][0]);
275 <        j = abs(noff[1][1]-noff[0][1]);
276 <        const int       slen =  i > j ? i : j;
276 <        const double    sf = 1./slen;
275 >        j = abs(noff[1][1]-noff[0][1]); // i==j for diamond fill
276 >        const int       slen =  (i > j) ? i : j;
277          const bool      spectr = (pacc.NC() > 3);
278 <        for (i = 0; i <= slen; i++) {   // bilinear interpolant
279 <            const double        c1 = i*sf;
280 <            for (j = 0; j <= slen; j++) {
281 <                const double    c2 = j*sf;
278 >        for (i = slen+1 + (i==j)*slen; i--; ) {
279 >            const double        c1 = (i>slen ? i-slen-.5 : (double)i)/slen;
280 >            for (j = slen + (i<=slen); j--; ) {
281 >                const double    c2 = (j + (i>slen)*.5)/slen;
282                  const int       px = int(x + (1.-c1)*(1.-c2)*noff[0][0] +
283                                                  c1*(1.-c2)*noff[1][0] +
284                                                  (1.-c1)*c2*noff[2][0] +
# Line 331 | Line 331 | static void
331   SetQuincunx(ABitMap2 *bmp2, int noff[4][2], const int spc, const bool odd)
332   {
333          for (int y = 0; y < bmp2->Height(); y += spc>>1)
334 <            for (int x = odd*(spc>>1); x < bmp2->Width(); x += spc)
334 >            for (int x = (odd^(y&1))*(spc>>1); x < bmp2->Width(); x += spc)
335                  bmp2->Set(x, y);
336                                          // order neighbors CCW
337          if (odd) {
# Line 370 | Line 370 | TWidth(), THeight(), psample, maxdiff);
370                  sampMap -= doneSamples; // avoid resampling pixels
371                  // Are we into adaptive sampling realm?
372                  if (noff[0][0]*noff[0][0] + noff[0][1]*noff[0][1] < psample*psample) {
373 <                        if (FlushQueue() < 0)   // need results to check threshold
373 >                        if (FlushQueue() < 0)   // need results to check thresholds
374                                  return false;
375                          ABitMap2        fillMap = sampMap;
376                          for (x = y = 0; sampMap.Find(&x, &y); x++)
# Line 378 | Line 378 | TWidth(), THeight(), psample, maxdiff);
378                                          sampMap.Reset(x, y);
379                                          // spread sampling to neighbors...
380                          const ABitMap2  origSampMap = sampMap;
381 <                        for (int yoff = -(1<<(sp2-1));
382 <                                        yoff <= 1<<(sp2-1); yoff += 1<<sp2)
383 <                            for (int xoff = -(1<<(sp2-1));
384 <                                        xoff <= 1<<(sp2-1); xoff += 1<<sp2) {
381 >                        for (x = 4; x--; ) {
382                                  ABitMap2        stamp = origSampMap;
383 <                                stamp.Shift(xoff, yoff);
383 >                                stamp.Shift(noff[x][0], noff[x][1]);
384                                  sampMap |= stamp;
385                          }               // ...but don't resample what's done
386                          sampMap -= doneSamples;
# Line 509 | Line 506 | RpictSimulManager::LowerBar(int v)
506          if (v <= 0) return !v;
507          if (!barPix | !barDepth | (v > THeight()) | !tvw.type)
508                  return false;
509 <        tvw.voff -= double(v)/GetHeight();
510 <        ptvw.voff -= double(v)/GetHeight();
509 >        tvw.voff -= double(v)/THeight();
510 >        ptvw.voff -= double(v)/THeight();
511          if (v == THeight()) {
512                  doneMap.ClearBitMap();
513                  return true;
# Line 562 | Line 559 | RpictSimulManager::RenderBelow(int ytop, const int vst
559          }
560          int             lastOut = ytop;         // render down frame
561          while (ytop > 0) {
562 + fprintf(stderr, "At y=%d, source drawing %s...\n", ytop, parr ? "ON" : "OFF");
563                  if (ytop < THeight())           // mark what we won't do as finished
564                          doneMap.ClearRect(0, 0, TWidth(), THeight()-ytop, true);
565                  if (prCB)
# Line 605 | Line 603 | RpictSimulManager::RenderBelow(int ytop, const int vst
603                                          error(SYSTEM, "cannot write SCOLOR output");
604                                  break;
605                          default:
606 <                                error(INTERNAL, "missing output color type in RenderBelow()");
606 >                                error(INTERNAL, "botched output color type in RenderBelow()");
607                                  break;
608                          }
609                          bpos += pacc.NC()*TWidth();
# Line 629 | Line 627 | RpictSimulManager::RenderBelow(int ytop, const int vst
627   * Render and write a frame to the named file
628   * Include any header lines set prior to call
629   * Picture file must not already exist
630 < * Picture to stdout if pfname==NULL
631 < * Depth written to a command if dfname[0]=='!'
630 > * Write pixels to stdout if !pfname
631 > * Write depth to a command if dfname[0]=='!'
632   */
633   RenderDataType
634   RpictSimulManager::RenderFrame(const char *pfname, RenderDataType dt, const char *dfname)
# Line 640 | Line 638 | RpictSimulManager::RenderFrame(const char *pfname, Ren
638          FILE *  dfp = NULL;
639  
640          if (!RDTcolorT(dt))
641 <                error(INTERNAL, "missing pixel output type in RenderFrame()");
641 >                error(INTERNAL, "botched color output type in RenderFrame()");
642          if (NCSAMP == 3) {
643                  if (RDTcolorT(dt) == RDTscolr)
644                          dt = RDTnewCT(dt, prims==xyzprims ? RDTxyze : RDTrgbe);
# Line 676 | Line 674 | RpictSimulManager::RenderFrame(const char *pfname, Ren
674          if (frameNo > 0)
675                  fprintf(pfp, "FRAME=%d\n", frameNo);
676          double  pasp = viewaspect(&vw) * GetWidth() / GetHeight();
677 <        if (!FABSEQ(pasp, 1.0))
677 >        if ((0.99 > pasp) | (pasp > 1.01))
678                  fputaspect(pasp, pfp);
679          fputnow(pfp);
680          switch (RDTcolorT(dt)) {                // set primaries and picture format

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines