--- ray/src/rt/RpictSimulManager.h 2024/08/18 17:24:48 2.3 +++ ray/src/rt/RpictSimulManager.h 2024/08/21 23:52:24 2.6 @@ -1,4 +1,4 @@ -/* RCSid $Id: RpictSimulManager.h,v 2.3 2024/08/18 17:24:48 greg Exp $ */ +/* RCSid $Id: RpictSimulManager.h,v 2.6 2024/08/21 23:52:24 greg Exp $ */ /* * RpictSimulManager.h * @@ -85,6 +85,10 @@ class PixelAccess { (public) refDepth = 1.; Init(bp, ystride, dp); } + PixelAccess(COLORV *rp, int ystride, short *dp) { + refDepth = 1.; + Init(rp, ystride, dp); + } void Init() { pbase.f = NULL; dbase.f = NULL; rowStride = 0; @@ -122,6 +126,16 @@ class PixelAccess { (public) } if (dp) dtyp |= RDTdshort; } + void Init(COLORV *rp, int ystride, short *dp) { + pbase.f = rp; dbase.s = dp; + rowStride = ystride; + if (NCSAMP > 3) { + dtyp = RDTscolor; primp = NULL; + } else { + dtyp = RDTrgb; primp = stdprims; + } + if (dp) dtyp |= RDTdshort; + } /// Set color space after non-empty initialization bool SetColorSpace(RenderDataType cs, RGBPRIMP pr=NULL); /// Get color space @@ -261,7 +275,7 @@ class RpictSimulManager : protected RtraceSimulManager frameNo = 0; } ~RpictSimulManager() { - NewBar(); + delete [] barPix; delete [] barDepth; } /// Load octree and prepare renderer bool LoadOctree(const char *octn) { @@ -325,6 +339,15 @@ class RpictSimulManager : protected RtraceSimulManager /// Increments frameNo if >0 bool NewFrame(const VIEW &v, int xydim[2], double *ap=NULL, const int *tgrid=NULL); + /// Get current view if set + const VIEW * GetView() const { + if (!vw.type) return NULL; + return &vw; + } + /// Writeable previous view (for motion blur) + VIEW & PreView() { + return pvw; + } /// Get current picture width int GetWidth() const { return hvres[0]; @@ -353,9 +376,12 @@ class RpictSimulManager : protected RtraceSimulManager /// Same but also use 16-bit encoded depth buffer bool RenderTile(COLRV *bp, int ystride, short *dp, const int *tile=NULL); + /// Back to float color with 16-bit depth + bool RenderTile(COLORV *rp, int ystride, short *dp, + const int *tile=NULL); /// Render and write a frame to the named file /// Include any header lines set prior to call - /// Picture file must not already exist + /// Picture file must not exist /// Write pixels to stdout if !pfname /// Write depth to a command if dfname[0]=='!' RenderDataType RenderFrame(const char *pfname, @@ -364,6 +390,16 @@ class RpictSimulManager : protected RtraceSimulManager /// Resume partially finished rendering /// Picture file must exist with valid header RenderDataType ResumeFrame(const char *pfname, + const char *dfname=NULL); + /// Prepare new picture (and depth) output + /// Called by RenderFrame() + RenderDataType NewOutput(FILE *pdfp[2], const char *pfname, + RenderDataType dt=RDTrgbe, + const char *dfname=NULL); + /// Reopen existing picture (and depth) file + /// Called by ResumeFrame() + /// File pointers @ end of header (before res.) + RenderDataType ReopenOutput(FILE *pdfp[2], const char *pfname, const char *dfname=NULL); /// Close octree, free data, return status int Cleanup(bool everything = false) {