diff --git a/src/rt/RtraceSimulManager.cpp b/src/rt/RtraceSimulManager.cpp index 0e4a8476..3191d91f 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.21 2024/11/09 00:10:49 greg Exp $"; +static const char RCSid[] = "$Id: RtraceSimulManager.cpp,v 2.22 2024/11/13 02:43:51 greg Exp $"; #endif /* * RtraceSimulManager.cpp @@ -196,18 +196,8 @@ RadSimulManager::SetThreadCount(int nt) return NThreads(); } -// Assign ray to subthread (fails if NThreads()<2) -bool -RadSimulManager::SplitRay(RAY *r) -{ - if (!ray_pnprocs || ThreadsAvailable() < 1) - return false; - - return (ray_psend(r) > 0); -} - // Process a ray (in subthread), optional result -bool +int RadSimulManager::ProcessRay(RAY *r) { if (!Ready()) return false; @@ -215,14 +205,9 @@ RadSimulManager::ProcessRay(RAY *r) if (!ray_pnprocs) { // single-threaded mode? samplendx++; rayvalue(r); - return true; + return 1; } - int rv = ray_pqueue(r); - if (rv < 0) { - error(WARNING, "ray tracing process(es) died"); - return false; - } - return (rv > 0); + return ray_pqueue(r); } // Wait for next result (or fail) @@ -249,15 +234,6 @@ RadSimulManager::Cleanup(bool everything) return 0; } -// How many threads are currently unoccupied? -int -RadSimulManager::ThreadsAvailable() const -{ - if (!ray_pnprocs) return 1; - - return ray_pnidle; -} - // Global pointer to simulation manager for trace call-back (only one) static const RtraceSimulManager * ourRTsimMan = NULL; @@ -405,8 +381,12 @@ RtraceSimulManager::EnqueueBundle(const FVECT orig_direc[], int n, RNUMBER rID0) if (ray_fifo_in(&res) < 0) return -1; sendRes = false; - } else - sendRes &= ProcessRay(&res); + } else { + int rv = ProcessRay(&res); + if (rv < 0) + return -1; + sendRes &= (rv > 0); + } } else if (ThreadsAvailable() < NThreads() && FlushQueue() < 0) return -1; diff --git a/src/rt/RtraceSimulManager.h b/src/rt/RtraceSimulManager.h index c89904ee..a9f078f5 100644 --- a/src/rt/RtraceSimulManager.h +++ b/src/rt/RtraceSimulManager.h @@ -1,4 +1,4 @@ -/* RCSid $Id: RtraceSimulManager.h,v 2.16 2024/10/23 23:40:41 greg Exp $ */ +/* RCSid $Id: RtraceSimulManager.h,v 2.17 2024/11/13 02:43:51 greg Exp $ */ /* * RtraceSimulManager.h * @@ -27,8 +27,9 @@ class RadSimulManager { char * header; // header (less intro and format) int hlen; // header string length protected: - // Assign ray to subthread (fails if NThreads()<2) - bool SplitRay(RAY *r); + bool SplitRay(RAY *r) { + return (ray_pnprocs && ray_psend(r) > 0); + } public: RadSimulManager(const char *octn = NULL) { header = NULL; hlen = 0; @@ -65,13 +66,15 @@ class RadSimulManager { return ray_pnprocs + !ray_pnprocs; } /// How many threads are currently unoccupied? - int ThreadsAvailable() const; + int ThreadsAvailable() const { + return ray_pnprocs ? ray_pnidle : 1; + } /// Are we ready? bool Ready() const { return (octname && nobjects > 0); } /// Process a ray (in subthread), optional result - bool ProcessRay(RAY *r); + int ProcessRay(RAY *r); /// Wait for next result (or fail) bool WaitResult(RAY *r); /// Close octree, free data, return status @@ -120,13 +123,13 @@ class RtraceSimulManager : public RadSimulManager { int EnqueueBundle(const FVECT orig_direc[], int n, RNUMBER rID0 = 0); /// Enqueue a single ray w/ optional ray ID - bool EnqueueRay(const FVECT org, const FVECT dir, + int EnqueueRay(const FVECT org, const FVECT dir, RNUMBER rID = 0) { if (dir == org+1) return(EnqueueBundle((const FVECT *)org, 1, rID) > 0); FVECT orgdir[2]; VCOPY(orgdir[0], org); VCOPY(orgdir[1], dir); - return(EnqueueBundle(orgdir, 1, rID) > 0); + return EnqueueBundle(orgdir, 1, rID); } /// Set/change cooked ray callback void SetCookedCall(RayReportCall *cb, void *cd = NULL) {