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

Comparing ray/src/rt/RtraceSimulManager.cpp (file contents):
Revision 2.13 by greg, Sat Aug 3 15:38:06 2024 UTC vs.
Revision 2.19 by greg, Wed Nov 6 18:28:52 2024 UTC

# Line 69 | Line 69 | RadSimulManager::AddHeader(const char *str)
69   {
70          if (!str) return false;
71          int     len = strlen(str);
72 <        while (len && str[len-1] == '\n')
72 >        while (len && (str[len-1] == '\n') | (str[len-1] == '\r'))
73                  --len;                  // don't copy EOL(s)
74          if (!len)
75                  return false;
# Line 106 | Line 106 | check_special(const char *s)
106  
107   // Append program line to header
108   bool
109 < RadSimulManager::AddHeader(int ac, const char *av[])
109 > RadSimulManager::AddHeader(int ac, char *av[])
110   {
111          if ((ac <= 0) | !av) return false;
112          int     len = 0;
# Line 141 | Line 141 | RadSimulManager::AddHeader(int ac, const char *av[])
141          return true;
142   }
143  
144 + // Look for specific header keyword, return value
145 + const char *
146 + RadSimulManager::GetHeadStr(const char *key, bool inOK) const
147 + {
148 +        if (!key | !hlen || strchr(key, '\n'))
149 +                return NULL;
150 +        if (inOK)                       // skip leading spaces?
151 +                while (isspace(*key)) key++;
152 +
153 +        const int       klen = strlen(key);
154 +        if (!klen)
155 +                return NULL;
156 +        const char *    cp = header;
157 +        while (*cp) {
158 +                if (inOK) {             // skip leading spaces?
159 +                        while (isspace(*cp) && *cp++ != '\n')
160 +                                ;
161 +                        if (cp[-1] == '\n')
162 +                                continue;
163 +                }
164 +                if (!strncmp(cp, key, klen))
165 +                        return cp+klen; // found it!
166 +
167 +                while (*cp && *cp++ != '\n')
168 +                        ;
169 +        }
170 +        return NULL;
171 + }
172 +
173   // How many processors are available?
174   int
175   RadSimulManager::GetNCores()
# Line 210 | Line 239 | RadSimulManager::WaitResult(RAY *r)
239   int
240   RadSimulManager::Cleanup(bool everything)
241   {
242 +        if (ray_pnprocs < 0)
243 +                return 0;               // skip in child process
244          NewHeader();
245          if (!ray_pnprocs)
246                  ray_done(everything);
# Line 259 | Line 290 | RtraceSimulManager::UpdateMode()
290          int     misMatch = rtFlags ^ curFlags;
291                                  // updates based on toggled flags
292          if (misMatch & RTtraceSources) {
293 +                int     sn = nsources;
294                  if (rtFlags & RTtraceSources) {
295 <                        for (int sn = 0; sn < nsources; sn++)
295 >                        srcFollowed.NewBitMap(nsources);
296 >                        while (sn--) {
297 >                                if (source[sn].sflags & SFOLLOW)
298 >                                        continue;
299                                  source[sn].sflags |= SFOLLOW;
300 <                } else          // cannot undo this...
301 <                        rtFlags |= RTtraceSources;
300 >                                srcFollowed.Set(sn);
301 >                        }
302 >                } else {
303 >                        while (sn--)
304 >                                if (srcFollowed.Check(sn))
305 >                                        source[sn].sflags &= ~SFOLLOW;
306 >                        srcFollowed.NewBitMap(0);
307 >                }
308          }
309          if (misMatch & RTdoFIFO && FlushQueue() < 0)
310                  return false;
# Line 341 | Line 382 | RtraceSimulManager::EnqueueBundle(const FVECT orig_dir
382          while (n-- > 0) {               // queue each ray
383                  VCOPY(res.rorg, orig_direc[0]);
384                  VCOPY(res.rdir, orig_direc[1]);
385 +                res.rmax = .0;
386                  orig_direc += 2;
387                  rayorigin(&res, PRIMARY, NULL, NULL);
388                  res.rno = rID0 ? (lastRayID = rID0++) : ++lastRayID;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines