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; |
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() |
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); |
279 |
|
bool |
280 |
|
RtraceSimulManager::UpdateMode() |
281 |
|
{ |
251 |
– |
rtFlags &= RTmask; |
282 |
|
if (!cookedCall) |
283 |
|
rtFlags &= ~RTdoFIFO; |
284 |
|
if (!traceCall) |
286 |
|
if (rtFlags & RTimmIrrad) |
287 |
|
rtFlags &= ~RTlimDist; |
288 |
|
|
289 |
< |
int misMatch = rtFlags ^ curFlags; |
289 |
> |
int misMatch = (rtFlags ^ curFlags) & RTmask; |
290 |
|
// updates based on toggled flags |
291 |
< |
if (misMatch & RTtraceSources) { |
291 |
> |
if (((misMatch & RTtraceSources) != 0) & (nsources > 0)) { |
292 |
> |
int nt = NThreads(); |
293 |
> |
if (nt > 1) { |
294 |
> |
if (FlushQueue() < 0) |
295 |
> |
return false; |
296 |
> |
SetThreadCount(1); |
297 |
> |
} |
298 |
> |
int sn = nsources; |
299 |
|
if (rtFlags & RTtraceSources) { |
300 |
< |
for (int sn = 0; sn < nsources; sn++) |
300 |
> |
srcFollowed.NewBitMap(nsources); |
301 |
> |
while (sn--) { |
302 |
> |
if (source[sn].sflags & SFOLLOW) |
303 |
> |
continue; |
304 |
|
source[sn].sflags |= SFOLLOW; |
305 |
< |
} else // cannot undo this... |
306 |
< |
rtFlags |= RTtraceSources; |
305 |
> |
srcFollowed.Set(sn); |
306 |
> |
} |
307 |
> |
} else { |
308 |
> |
while (sn--) |
309 |
> |
if (srcFollowed.Check(sn)) |
310 |
> |
source[sn].sflags &= ~SFOLLOW; |
311 |
> |
srcFollowed.NewBitMap(0); |
312 |
> |
} |
313 |
> |
if (nt > 1) SetThreadCount(nt); |
314 |
|
} |
315 |
|
if (misMatch & RTdoFIFO && FlushQueue() < 0) |
316 |
|
return false; |
388 |
|
while (n-- > 0) { // queue each ray |
389 |
|
VCOPY(res.rorg, orig_direc[0]); |
390 |
|
VCOPY(res.rdir, orig_direc[1]); |
391 |
+ |
res.rmax = .0; |
392 |
|
orig_direc += 2; |
393 |
|
rayorigin(&res, PRIMARY, NULL, NULL); |
394 |
|
res.rno = rID0 ? (lastRayID = rID0++) : ++lastRayID; |