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

Comparing ray/src/rt/RcontribSimulManager.cpp (file contents):
Revision 2.18 by greg, Fri Oct 24 18:37:05 2025 UTC vs.
Revision 2.23 by greg, Tue Nov 11 02:08:52 2025 UTC

# Line 125 | Line 125 | fileDataShare(const char *name, RCOutputOp op, size_t
125                  error(SYSTEM, errmsg);
126                  return NULL;
127          }
128 <        return new RdataShareFile(name, RSDOflags[op], siz);
128 >        RdataShare *    rds = new RdataShareFile(name, RSDOflags[op],
129 >                                                 siz*(op != RCOforce));
130 >                                                
131 >        if (!rds || (op == RCOforce && rds->Resize(siz) < siz)) {
132 >                delete rds;
133 >                sprintf(errmsg, "cannot create %lu byte output file '%s'",
134 >                                        (unsigned long)siz, name);
135 >                error(SYSTEM, errmsg);
136 >                return NULL;
137 >        }
138 >        return rds;
139   }
140  
141   // Memory-mapped data share function
# Line 137 | Line 147 | mapDataShare(const char *name, RCOutputOp op, size_t s
147                  error(SYSTEM, errmsg);
148                  return NULL;
149          }
150 <        return new RdataShareMap(name, RSDOflags[op], siz);
150 >        RdataShare *    rds = new RdataShareMap(name, RSDOflags[op],
151 >                                                 siz*(op != RCOforce));
152 >
153 >        if (!rds || (op == RCOforce && rds->Resize(siz) < siz)) {
154 >                delete rds;
155 >                sprintf(errmsg, "cannot create %lu byte output map '%s'",
156 >                                        (unsigned long)siz, name);
157 >                error(SYSTEM, errmsg);
158 >                return NULL;
159 >        }
160 >        return rds;
161   }
162  
163   // Set output format ('f', 'd', or 'c')
# Line 183 | Line 203 | RcontribSimulManager::RctCall(RAY *r, void *cd)
203          if (!mp)
204                  return 0;               // not in our modifier list
205  
206 <        int                     bi = 0; // get bin index
206 >        int     i;                      // pre-emptive check for zero
207 >        if (rcp->HasFlag(RCcontrib)) {
208 >                for (i = NCSAMP; i--; )
209 >                        if (r->rcoef[i]*r->rcol[i] > FTINY)
210 >                                break;
211 >                if (i < 0)
212 >                        return 0;       // zero contribution
213 >        } else if (sintens(r->rcoef) <= FTINY)
214 >                return 0;               // zero coefficient
215 >
216 >        int     bi = 0;                 // get bin index
217          if (mp->binv) {
218                  worldfunc(RCCONTEXT, r);
219                  set_eparams(mp->params);
# Line 203 | Line 233 | RcontribSimulManager::RctCall(RAY *r, void *cd)
233          if (rcp->HasFlag(RCcontrib))
234                  smultscolor(contr, r->rcol);    // -> value contribution
235  
236 <        for (int i = 0; i < NCSAMP; i++)
236 >        for (i = 0; i < NCSAMP; i++)
237                  *dvp++ += contr[i];             // accumulate color/spectrum
238          return 1;
239   }
# Line 414 | Line 444 | RcontribSimulManager::PrepOutput()
444          }
445          rowsDone.NewBitMap(outList->nRows);     // create row completion map
446          rowsDone.ClearBits(0, rInPos, true);
447 <        return rInPos;
447 >        return nrDone = rInPos;
448   }
449  
450   // Create header in open write-only channel
# Line 449 | Line 479 | RcontribOutput::NewHeader(const RcontribSimulManager *
479          sprintf(hdr+begData, "%s%d\n", NCOMPSTR, NCSAMP);
480          begData += strlen(hdr+begData);
481          if (NCSAMP > 3) {
482 <                sprintf(hdr+begData, "%s %f %f %f %f\n", WLSPLTSTR,
482 >                sprintf(hdr+begData, "%s %g %g %g %g\n", WLSPLTSTR,
483                                  WLPART[0], WLPART[1], WLPART[2], WLPART[3]);
484                  begData += strlen(hdr+begData);
485          }
# Line 534 | Line 564 | RcontribOutput::CheckHeader(const RcontribSimulManager
564                  return -1;
565          }
566                                                  // check #columns
567 <        if (((cp = findArgs(hdr, "NCOLS=", begData)) && atoi(cp)*esiz != rowBytes) ||
568 <                        !rcp->xres | (rowBytes > esiz)) {
569 <                sprintf(errmsg, "expected NCOLS=%d in '%s'",
540 <                                int(rowBytes/esiz), GetName());
567 >        if ((cp = findArgs(hdr, "NCOLS=", begData)) ? (atoi(cp)*esiz != rowBytes)
568 >                                                    : (!rcp->xres | (rowBytes > esiz))) {
569 >                sprintf(errmsg, "expected NCOLS=%d in '%s'", int(rowBytes/esiz), GetName());
570                  error(USER, errmsg);
571                  return -1;
572          }
# Line 579 | Line 608 | RcontribSimulManager::ResetRow(int r)
608                          return false;
609  
610          rowsDone.ClearBits(r, rInPos-r, false);
611 <        rInPos = r;
611 >        nrDone = rInPos = r;
612          return true;
613   }
614  
# Line 738 | Line 767 | RcontribSimulManager::UpdateRowsDone(int r)
767                  error(WARNING, "redundant call to UpdateRowsDone()");
768                  return false;
769          }
770 <        int     nDone = GetRowFinished();
771 <        if (nDone <= r)
770 >        GetRowFinished();
771 >        if (nrDone <= r)
772                  return true;                    // nothing to update, yet
773          for (RcontribOutput *op = outList; op; op = op->next)
774 <                if (!op->SetRowsDone(nDone))
774 >                if (!op->SetRowsDone(nrDone))
775                          return false;
776          return true;                            // up-to-date
777   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)