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

Comparing ray/src/rt/RpictSimulManager.h (file contents):
Revision 2.1 by greg, Wed Aug 14 20:05:23 2024 UTC vs.
Revision 2.5 by greg, Wed Aug 21 23:32:24 2024 UTC

# Line 27 | Line 27 | enum RenderDataType {
27   #define RDTcolorT(f)    RenderDataType((f) & RDTcolorM)
28   #define RDTdepthT(f)    RenderDataType((f) & RDTdepthM)
29   #define RDTcommonE(f)   (RDTcolorT(f) >= RDTscolr)
30 < #define RDTnewCT(f,c)   RenderDataType((f) & ~RDTcolorM | (c))
31 < #define RDTnewDT(f,d)   RenderDataType((f) & ~RDTdepthM | (d))
30 > #define RDTnewCT(f,c)   RenderDataType((f) & ~RDTcolorM | (c) & RDTcolorM)
31 > #define RDTnewDT(f,d)   RenderDataType((f) & ~RDTdepthM | (d) & RDTdepthM)
32  
33   /// Pixel accessor (read/write to caller's buffer with possible conversion)
34   class PixelAccess {
# Line 43 | Line 43 | class PixelAccess {
43          long            rowStride;      // # values to next y position
44          int             dtyp;           // data type flags
45          RGBPRIMP        primp;          // color primaries if tristimulus
46 <        COLORMAT        xyz2myrgbmat;   // custom color conversion matrix
46 >        const COLORV *  CF3(int x, int y) const {
47 >                                return pbase.f + (rowStride*y + x)*3;
48 >                        }
49          COLORV *        CF3(int x, int y) {
50                                  return pbase.f + (rowStride*y + x)*3;
51                          }
52 <        COLORV *        GetCF3(int x, int y) const {
53 <                                return const_cast<COLORV *>(pbase.f + (rowStride*y + x)*3);
52 >        const COLRV *   CB3(int x, int y) const {
53 >                                return pbase.b + (rowStride*y + x)*4;
54                          }
53        COLORV *        SCF(int x, int y) {
54                                return pbase.f + (rowStride*y + x)*NCSAMP;
55                        }
56        COLORV *        GetSCF(int x, int y) const {
57                                return const_cast<COLORV *>(pbase.f + (rowStride*y + x)*NCSAMP);
58                        }
55          COLRV *         CB3(int x, int y) {
56                                  return pbase.b + (rowStride*y + x)*4;
57                          }
58 <        COLRV *         GetCB3(int x, int y) const {
59 <                                return const_cast<COLRV *>(pbase.b + (rowStride*y + x)*4);
58 >        const COLORV *  SCF(int x, int y) const {
59 >                                return pbase.f + (rowStride*y + x)*NCSAMP;
60                          }
61 +        COLORV *        SCF(int x, int y) {
62 +                                return pbase.f + (rowStride*y + x)*NCSAMP;
63 +                        }
64 +        const COLRV *   SCB(int x, int y) const {
65 +                                return pbase.b + (rowStride*y + x)*(NCSAMP+1);
66 +                        }
67          COLRV *         SCB(int x, int y) {
68                                  return pbase.b + (rowStride*y + x)*(NCSAMP+1);
69                          }
68        COLRV *         GetSCB(int x, int y) const {
69                                return const_cast<COLRV *>(pbase.b + (rowStride*y + x)*(NCSAMP+1));
70                        }
70   public:
71          double          refDepth;       // reference depth
72                          PixelAccess() {
# Line 86 | Line 85 | class PixelAccess {
85                                  refDepth = 1.;
86                                  Init(bp, ystride, dp);
87                          }
88 +                        PixelAccess(COLORV *rp, int ystride, short *dp) {
89 +                                refDepth = 1.;
90 +                                Init(rp, ystride, dp);
91 +                        }
92          void            Init() {
93                                  pbase.f = NULL; dbase.f = NULL;
94                                  rowStride = 0;
# Line 123 | Line 126 | class PixelAccess {
126                                  }
127                                  if (dp) dtyp |= RDTdshort;
128                          }
129 +        void            Init(COLORV *rp, int ystride, short *dp) {
130 +                                pbase.f = rp; dbase.s = dp;
131 +                                rowStride = ystride;
132 +                                if (NCSAMP > 3) {
133 +                                        dtyp = RDTscolor; primp = NULL;
134 +                                } else {
135 +                                        dtyp = RDTrgb; primp = stdprims;
136 +                                }
137 +                                if (dp) dtyp |= RDTdshort;
138 +                        }
139                          /// Set color space after non-empty initialization
140          bool            SetColorSpace(RenderDataType cs, RGBPRIMP pr=NULL);
141                          /// Get color space
# Line 176 | Line 189 | class PixelAccess {
189          bool            GetPixel(int x, int y, COLORV *pv, float *zp=NULL) const {
190                                  if (NC() == 3) {
191                                          if (RDTcommonE(dtyp))
192 <                                                colr_color(pv, GetCB3(x,y));
192 >                                                colr_color(pv, CB3(x,y));
193                                          else
194 <                                                copycolor(pv, GetCF3(x,y));
194 >                                                copycolor(pv, CF3(x,y));
195                                  } else if (RDTcommonE(dtyp))
196 <                                        scolr_scolor(pv, GetSCB(x,y));
196 >                                        scolr_scolor(pv, SCB(x,y));
197                                  else
198 <                                        copyscolor(pv, GetSCF(x,y));
198 >                                        copyscolor(pv, SCF(x,y));
199                                  if (!zp) return true;
200                                  if (RDTdepthT(dtyp) == RDTdfloat)
201                                          *zp = dbase.f[rowStride*y + x];
# Line 198 | Line 211 | class PixelAccess {
211                                  const int       nc = NC();
212                                  if (nc == 3) {
213                                          if (RDTcommonE(dtyp))
214 <                                                copycolr(CB3(dx,dy), GetCB3(sx,sy));
214 >                                                copycolr(CB3(dx,dy), CB3(sx,sy));
215                                          else
216 <                                                copycolor(CF3(dx,dy), GetCF3(sx,sy));
216 >                                                copycolor(CF3(dx,dy), CF3(sx,sy));
217                                  } else if (RDTcommonE(dtyp))
218 <                                        copyscolr(SCB(dx,dy), GetSCB(sx,sy));
218 >                                        copyscolr(SCB(dx,dy), SCB(sx,sy));
219                                  else
220 <                                        copyscolor(SCF(dx,dy), GetSCF(sx,sy));
220 >                                        copyscolor(SCF(dx,dy), SCF(sx,sy));
221                                  switch (RDTdepthT(dtyp)) {
222                                  case RDTdfloat:
223                                          dbase.f[rowStride*dy + dx] =
# Line 241 | Line 254 | class RpictSimulManager : protected RtraceSimulManager
254          bool                    RenderRect();
255          bool                    ComputePixel(int x, int y);
256          bool                    BelowSampThresh(int x, int y, const int noff[4][2]) const;
257 <        void                    FillSquare(int x, int y, const int noff[4][2]);
257 >        void                    FillSquare(const int x, const int y, const int noff[4][2]);
258          void                    NewBar(int ht = 0);
259 <        bool                    LowerBar(int v);
259 >        bool                    LowerBar(int v, int ytop);
260          bool                    RenderBelow(int ytop, const int vstep, FILE *pfp,
261                                                          const int dt, FILE *dfp=NULL);
262   public:
# Line 262 | Line 275 | class RpictSimulManager : protected RtraceSimulManager
275                                          frameNo = 0;
276                                  }
277                                  ~RpictSimulManager() {
278 <                                        NewBar();
278 >                                        delete [] barPix; delete [] barDepth;
279                                  }
280                                  /// Load octree and prepare renderer
281          bool                    LoadOctree(const char *octn) {
# Line 326 | Line 339 | class RpictSimulManager : protected RtraceSimulManager
339                                  /// Increments frameNo if >0
340          bool                    NewFrame(const VIEW &v, int xydim[2], double *ap=NULL,
341                                                  const int *tgrid=NULL);
342 +                                /// Get current view if set
343 +        const VIEW *            GetView() const {
344 +                                        if (!vw.type) return NULL;
345 +                                        return &vw;
346 +                                }
347 +                                /// Writeable previous view (for motion blur)
348 +        VIEW &                  PreView() {
349 +                                        return pvw;
350 +                                }
351                                  /// Get current picture width
352          int                     GetWidth() const {
353                                          return hvres[0];
# Line 354 | Line 376 | class RpictSimulManager : protected RtraceSimulManager
376                                  /// Same but also use 16-bit encoded depth buffer
377          bool                    RenderTile(COLRV *bp, int ystride, short *dp,
378                                                  const int *tile=NULL);
379 +                                /// Back to float color with 16-bit depth
380 +        bool                    RenderTile(COLORV *rp, int ystride, short *dp,
381 +                                                const int *tile=NULL);
382                                  /// Render and write a frame to the named file
383                                  /// Include any header lines set prior to call
384 <                                /// Picture file must not already exist
385 <                                /// Picture to stdout if pfname==NULL
386 <                                /// Depth written to a command if dfname[0]=='!'
384 >                                /// Picture file must not exist
385 >                                /// Write pixels to stdout if !pfname
386 >                                /// Write depth to a command if dfname[0]=='!'
387          RenderDataType          RenderFrame(const char *pfname,
388                                                  RenderDataType dt=RDTrgbe,
389                                                  const char *dfname=NULL);
390                                  /// Resume partially finished rendering
391                                  /// Picture file must exist with valid header
392          RenderDataType          ResumeFrame(const char *pfname,
393 +                                                const char *dfname=NULL);
394 +                                /// Prepare new picture (and depth) output
395 +                                /// Writes current render size as resolution
396 +        RenderDataType          NewOutput(FILE *pdfp[2], const char *pfname,
397 +                                                RenderDataType dt=RDTrgbe,
398 +                                                const char *dfname=NULL);
399 +                                /// Reopen existing picture (and depth) file
400 +                                /// File pointers @ end of header (before res.)
401 +        RenderDataType          ReopenOutput(FILE *pdfp[2], const char *pfname,
402                                                  const char *dfname=NULL);
403                                  /// Close octree, free data, return status
404          int                     Cleanup(bool everything = false) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines