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.2 by greg, Sun Aug 18 00:37:13 2024 UTC vs.
Revision 2.9 by greg, Mon Sep 16 23:49:13 2024 UTC

# 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 +        bool            swap2d;         // need to swap 16-bit depths?
47          const COLORV *  CF3(int x, int y) const {
48                                  return pbase.f + (rowStride*y + x)*3;
49                          }
# Line 67 | Line 68 | class PixelAccess {
68          COLRV *         SCB(int x, int y) {
69                                  return pbase.b + (rowStride*y + x)*(NCSAMP+1);
70                          }
71 +        void            EncodeDepth16(int x, int y, float z) {
72 +                                short * sp = dbase.s + rowStride*y + x;
73 +                                *sp = depth2code(z, refDepth);
74 +                                if (swap2d) swap16((char *)sp, 1);
75 +                        }
76 +        float           DecodeDepth16(int x, int y) const {
77 +                                short   sv = dbase.s[rowStride*y + x];
78 +                                if (swap2d) swap16((char *)&sv, 1);
79 +                                return code2depth(sv, refDepth);
80 +                        }
81   public:
82          double          refDepth;       // reference depth
83                          PixelAccess() {
84                                  refDepth = 1.;
85 +                                swap2d = !nativebigendian();
86                                  Init();
87                          }
88                          PixelAccess(COLORV *rp, int ystride, float *zp=NULL) {
89                                  refDepth = 1.;
90 +                                swap2d = !nativebigendian();
91                                  Init(rp, ystride, zp);
92                          }
93                          PixelAccess(COLRV *bp, int ystride, float *zp=NULL) {
94                                  refDepth = 1.;
95 +                                swap2d = !nativebigendian();
96                                  Init(bp, ystride, zp);
97                          }
98                          PixelAccess(COLRV *bp, int ystride, short *dp) {
99                                  refDepth = 1.;
100 +                                swap2d = !nativebigendian();
101                                  Init(bp, ystride, dp);
102                          }
103 +                        PixelAccess(COLORV *rp, int ystride, short *dp) {
104 +                                refDepth = 1.;
105 +                                swap2d = !nativebigendian();
106 +                                Init(rp, ystride, dp);
107 +                        }
108          void            Init() {
109                                  pbase.f = NULL; dbase.f = NULL;
110                                  rowStride = 0;
# Line 122 | Line 142 | class PixelAccess {
142                                  }
143                                  if (dp) dtyp |= RDTdshort;
144                          }
145 +        void            Init(COLORV *rp, int ystride, short *dp) {
146 +                                pbase.f = rp; dbase.s = dp;
147 +                                rowStride = ystride;
148 +                                if (NCSAMP > 3) {
149 +                                        dtyp = RDTscolor; primp = NULL;
150 +                                } else {
151 +                                        dtyp = RDTrgb; primp = stdprims;
152 +                                }
153 +                                if (dp) dtyp |= RDTdshort;
154 +                        }
155                          /// Set color space after non-empty initialization
156          bool            SetColorSpace(RenderDataType cs, RGBPRIMP pr=NULL);
157                          /// Get color space
# Line 165 | Line 195 | class PixelAccess {
195                                          scolor_scolr(SCB(x,y), pv);
196                                  else
197                                          copyscolor(SCF(x,y), pv);
198 <                                if (RDTdepthT(dtyp) == RDTdfloat)
198 >                                if (DepthType() == RDTdfloat)
199                                          dbase.f[rowStride*y + x] = z;
200 <                                else if (RDTdepthT(dtyp) == RDTdshort)
201 <                                        dbase.s[rowStride*y + x] = depth2code(z, refDepth);
200 >                                else if (DepthType() == RDTdshort)
201 >                                        EncodeDepth16(x, y, z);
202                                  return true;
203                          }
204                          /// Retrieve pixel color (& depth) -- may convert either/both
# Line 183 | Line 213 | class PixelAccess {
213                                  else
214                                          copyscolor(pv, SCF(x,y));
215                                  if (!zp) return true;
216 <                                if (RDTdepthT(dtyp) == RDTdfloat)
216 >                                if (DepthType() == RDTdfloat)
217                                          *zp = dbase.f[rowStride*y + x];
218 <                                else if (RDTdepthT(dtyp) == RDTdshort)
219 <                                        *zp = code2depth(dbase.s[rowStride*y + x], refDepth);
218 >                                else if (DepthType() == RDTdshort)
219 >                                        *zp = DecodeDepth16(x, y);
220                                  else
221                                          *zp = .0f;
222                                  return true;
# Line 204 | Line 234 | class PixelAccess {
234                                          copyscolr(SCB(dx,dy), SCB(sx,sy));
235                                  else
236                                          copyscolor(SCF(dx,dy), SCF(sx,sy));
237 <                                switch (RDTdepthT(dtyp)) {
237 >                                switch (DepthType()) {
238                                  case RDTdfloat:
239                                          dbase.f[rowStride*dy + dx] =
240                                                          dbase.f[rowStride*sy + sx];
# Line 237 | Line 267 | class RpictSimulManager : protected RtraceSimulManager
267          COLORV *                barPix;                 // current render bar pixels
268          float *                 barDepth;               // current render bar depths
269          bool                    SetTile(const int ti[2]);
270 <        bool                    RenderRect();
270 >        bool                    RenderRect(const int x0 = 0, const int y0 = 0);
271          bool                    ComputePixel(int x, int y);
272 <        bool                    BelowSampThresh(int x, int y, const int noff[4][2]) const;
272 >        bool                    BelowSampThresh(const int x, const int y,
273 >                                                        const int noff[4][2]) const;
274          void                    FillSquare(const int x, const int y, const int noff[4][2]);
275          void                    NewBar(int ht = 0);
276 <        bool                    LowerBar(int v);
276 >        bool                    LowerBar(int v, int ytop);
277          bool                    RenderBelow(int ytop, const int vstep, FILE *pfp,
278                                                          const int dt, FILE *dfp=NULL);
279   public:
# Line 261 | Line 292 | class RpictSimulManager : protected RtraceSimulManager
292                                          frameNo = 0;
293                                  }
294                                  ~RpictSimulManager() {
295 <                                        NewBar();
295 >                                        delete [] barPix; delete [] barDepth;
296                                  }
297                                  /// Load octree and prepare renderer
298          bool                    LoadOctree(const char *octn) {
# Line 280 | Line 311 | class RpictSimulManager : protected RtraceSimulManager
311                                          return RtraceSimulManager::AddHeader(ac, av);
312                                  }
313                                  /// Get header lines if any
314 <        const char *            GetHeader() const {
315 <                                        return RtraceSimulManager::GetHeader();
314 >        const char *            GetHeadStr() const {
315 >                                        return RtraceSimulManager::GetHeadStr();
316                                  }
317 +                                /// Look for specific header keyword, return value
318 +        const char *            GetHeadStr(const char *key, bool inOK = false) const {
319 +                                        return RtraceSimulManager::GetHeadStr(key, inOK);
320 +                                }
321                                  /// Set number of computation threads (0 => #cores)
322          int                     SetThreadCount(int nt = 0) {
323                                          return RtraceSimulManager::SetThreadCount(nt);
# Line 325 | Line 360 | class RpictSimulManager : protected RtraceSimulManager
360                                  /// Increments frameNo if >0
361          bool                    NewFrame(const VIEW &v, int xydim[2], double *ap=NULL,
362                                                  const int *tgrid=NULL);
363 +                                /// Get current view if set
364 +        const VIEW *            GetView() const {
365 +                                        if (!vw.type) return NULL;
366 +                                        return &vw;
367 +                                }
368 +                                /// Writeable previous view (for motion blur)
369 +        VIEW &                  PreView() {
370 +                                        return pvw;
371 +                                }
372                                  /// Get current picture width
373          int                     GetWidth() const {
374                                          return hvres[0];
# Line 353 | Line 397 | class RpictSimulManager : protected RtraceSimulManager
397                                  /// Same but also use 16-bit encoded depth buffer
398          bool                    RenderTile(COLRV *bp, int ystride, short *dp,
399                                                  const int *tile=NULL);
400 +                                /// Back to float color with 16-bit depth
401 +        bool                    RenderTile(COLORV *rp, int ystride, short *dp,
402 +                                                const int *tile=NULL);
403                                  /// Render and write a frame to the named file
404                                  /// Include any header lines set prior to call
405 <                                /// Picture file must not already exist
405 >                                /// Picture file must not exist
406                                  /// Write pixels to stdout if !pfname
407                                  /// Write depth to a command if dfname[0]=='!'
408          RenderDataType          RenderFrame(const char *pfname,
# Line 364 | Line 411 | class RpictSimulManager : protected RtraceSimulManager
411                                  /// Resume partially finished rendering
412                                  /// Picture file must exist with valid header
413          RenderDataType          ResumeFrame(const char *pfname,
414 +                                                const char *dfname=NULL);
415 +                                /// Prepare new picture (and depth) output
416 +                                /// Called by RenderFrame() after NewFrame()
417 +        RenderDataType          NewOutput(FILE *pdfp[2], const char *pfname,
418 +                                                RenderDataType dt=RDTrgbe,
419 +                                                const char *dfname=NULL);
420 +                                /// Reopen existing picture (and depth) file
421 +                                /// Called by ResumeFrame()
422 +                                /// File pointers @ end of header (before res.)
423 +        RenderDataType          ReopenOutput(FILE *pdfp[2], const char *pfname,
424                                                  const char *dfname=NULL);
425                                  /// Close octree, free data, return status
426          int                     Cleanup(bool everything = false) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines