From e1dad5653f7f0430c26f5ed574ddf9469b37b9d3 Mon Sep 17 00:00:00 2001 From: "Gregory J. Ward" Date: Thu, 10 Oct 2024 21:02:52 +0000 Subject: [PATCH] fix: Allow unsetting of source-ray tracing flag --- src/rt/Rmakefile | 5 +++-- src/rt/RpictSimulManager.h | 3 +-- src/rt/RtraceSimulManager.cpp | 18 ++++++++++++++---- src/rt/RtraceSimulManager.h | 8 +++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/rt/Rmakefile b/src/rt/Rmakefile index f6fa1e30..bf55bc40 100644 --- a/src/rt/Rmakefile +++ b/src/rt/Rmakefile @@ -1,4 +1,4 @@ -# RCSid: $Id: Rmakefile,v 2.96 2024/09/16 23:49:12 greg Exp $ +# RCSid: $Id: Rmakefile,v 2.97 2024/10/10 21:02:52 greg Exp $ # # Compiles for ray tracing programs. # @@ -458,7 +458,8 @@ oocbuild.o: oocbuild.c oocbuild.h oocsort.h oococt.h oocnn.o: oocnn.c oocnn.h oococt.h oocsort.h RtraceSimulManager.o rxpiece.o rxpmain.o \ -rxtmain.o rxtrace.o: RtraceSimulManager.h +rxtmain.o rxtrace.o: RtraceSimulManager.h \ +../common/abitmap.h RpictSimulManager.o rxpiece.o rxpmain.o: RpictSimulManager.h \ ../common/view.h ../common/depthcodec.h ../common/abitmap.h diff --git a/src/rt/RpictSimulManager.h b/src/rt/RpictSimulManager.h index e155d7dc..153ff608 100644 --- a/src/rt/RpictSimulManager.h +++ b/src/rt/RpictSimulManager.h @@ -1,4 +1,4 @@ -/* RCSid $Id: RpictSimulManager.h,v 2.9 2024/09/16 23:49:13 greg Exp $ */ +/* RCSid $Id: RpictSimulManager.h,v 2.10 2024/10/10 21:02:52 greg Exp $ */ /* * RpictSimulManager.h * @@ -13,7 +13,6 @@ #include "RtraceSimulManager.h" #include "view.h" #include "depthcodec.h" -#include "abitmap.h" /// Data type flags for pixel access and output enum RenderDataType { diff --git a/src/rt/RtraceSimulManager.cpp b/src/rt/RtraceSimulManager.cpp index 60958bb2..445fd57e 100644 --- a/src/rt/RtraceSimulManager.cpp +++ b/src/rt/RtraceSimulManager.cpp @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: RtraceSimulManager.cpp,v 2.17 2024/09/16 19:18:32 greg Exp $"; +static const char RCSid[] = "$Id: RtraceSimulManager.cpp,v 2.18 2024/10/10 21:02:52 greg Exp $"; #endif /* * RtraceSimulManager.cpp @@ -288,11 +288,21 @@ RtraceSimulManager::UpdateMode() int misMatch = rtFlags ^ curFlags; // updates based on toggled flags if (misMatch & RTtraceSources) { + int sn = nsources; if (rtFlags & RTtraceSources) { - for (int sn = 0; sn < nsources; sn++) + srcFollowed.NewBitMap(nsources); + while (sn--) { + if (source[sn].sflags & SFOLLOW) + continue; source[sn].sflags |= SFOLLOW; - } else // cannot undo this... - rtFlags |= RTtraceSources; + srcFollowed.Set(sn); + } + } else { + while (sn--) + if (srcFollowed.Check(sn)) + source[sn].sflags &= ~SFOLLOW; + srcFollowed.NewBitMap(0); + } } if (misMatch & RTdoFIFO && FlushQueue() < 0) return false; diff --git a/src/rt/RtraceSimulManager.h b/src/rt/RtraceSimulManager.h index 9cde76ae..5d73f72e 100644 --- a/src/rt/RtraceSimulManager.h +++ b/src/rt/RtraceSimulManager.h @@ -1,4 +1,4 @@ -/* RCSid $Id: RtraceSimulManager.h,v 2.14 2024/09/16 19:18:32 greg Exp $ */ +/* RCSid $Id: RtraceSimulManager.h,v 2.15 2024/10/10 21:02:52 greg Exp $ */ /* * RtraceSimulManager.h * @@ -13,6 +13,7 @@ #define RtraceSimulManager_h #include "ray.h" +#include "abitmap.h" extern char * octname; // global octree name @@ -40,7 +41,7 @@ class RadSimulManager { bool LoadOctree(const char *octn); /// Prepare header from previous input (or clear) /// Normally called during octree load - bool NewHeader(const char *inspec=NULL); + bool NewHeader(const char *inspec = NULL); /// Add a line to header (adds newline if none) bool AddHeader(const char *str); /// Append program line to header @@ -83,6 +84,7 @@ class RtraceSimulManager : public RadSimulManager { RayReportCall * traceCall; // call for every ray in tree void * tcData; // client data for traced rays int curFlags; // current operating flags + ABitMap srcFollowed; // source flags changed // Call-back for global ray-tracing context static void RTracer(RAY *r); // Call-back for FIFO @@ -129,7 +131,7 @@ class RtraceSimulManager : public RadSimulManager { cookedCall = cb; ccData = cb ? cd : NULL; } - /// Set/change trace callback + /// Set/change trace callback (before threading) void SetTraceCall(RayReportCall *cb, void *cd = NULL) { traceCall = cb; tcData = cb ? cd : NULL;