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

Comparing ray/src/rt/RtraceSimulManager.h (file contents):
Revision 2.4 by greg, Wed Aug 2 00:04:31 2023 UTC vs.
Revision 2.7 by greg, Wed May 1 22:06:09 2024 UTC

# Line 16 | Line 16
16  
17   extern char *   octname;        // global octree name
18  
19 < /// Ray reporting callback method
20 < typedef void    RayReportCall(RAY *r, void *cd);
19 > extern int      castonly;       // doing ray-casting only?
20  
21 + /// Ray reporting callback method -- returns # successfully reported, -1 to abort
22 + typedef int     RayReportCall(RAY *r, void *cd);
23 +
24   /// Multi-threaded simulation manager base class
25   class RadSimulManager {
24        int                     nThreads;       // number of active threads
26   protected:
27                                  // Assign ray to subthread (fails if NThreads()<2)
28          bool                    SplitRay(RAY *r);
29   public:
30                                  RadSimulManager(const char *octn = NULL) {
31                                          LoadOctree(octn);
31                                        nThreads = 1;
32                                  }
33                                  ~RadSimulManager() {
34                                          Cleanup();
35                                  }
36                                  /// Load octree and prepare renderer
37          bool                    LoadOctree(const char *octn);
38 <                                /// How many cores are there?
38 >                                /// How many cores are available?
39          static int              GetNCores();
40                                  /// Set number of computation threads (0 => #cores)
41          int                     SetThreadCount(int nt = 0);
42                                  /// Check thread count (1 means no multi-threading)
43          int                     NThreads() const {
44 <                                        return nThreads;
44 >                                        return ray_pnprocs + !ray_pnprocs;
45                                  }
46                                  /// How many threads are currently unoccupied?
47          int                     ThreadsAvailable() const;
48                                  /// Are we ready?
49          bool                    Ready() const {
50 <                                        return (octname && nsceneobjs > 0);
50 >                                        return (octname && nobjects > 0);
51                                  }
52                                  /// Process a ray (in subthread), optional result
53          bool                    ProcessRay(RAY *r);
# Line 69 | Line 69 | class RtraceSimulManager : public RadSimulManager {
69          int                     curFlags;       // current operating flags
70                                  // Call-back for global ray-tracing context
71          static void             RTracer(RAY *r);
72 +                                // Call-back for FIFO
73 +        static int              Rfifout(RAY *r);
74                                  // Check for changes to render flags, etc.
75          bool                    UpdateMode();
76   protected:
75                                // Add a ray result to FIFO, flushing what we can
76        int                     QueueResult(const RAY &ra);
77          RNUMBER                 lastRayID;      // last ray ID assigned
78   public:
79          int                     rtFlags;        // operation (RT*) flags
# Line 89 | Line 89 | class RtraceSimulManager : public RadSimulManager {
89                                  }
90                                  /// Set number of computation threads (0 => #cores)
91          int                     SetThreadCount(int nt = 0) {
92 <                                        if (nt <= 0) nt = GetNCores();
92 >                                        if (nt <= 0) nt = castonly ? 1 : GetNCores();
93                                          if (nt == NThreads()) return nt;
94 <                                        FlushQueue();
94 >                                        if (FlushQueue() < 0) return 0;
95                                          return RadSimulManager::SetThreadCount(nt);
96                                  }
97                                  /// Add ray bundle to queue w/ optional 1st ray ID
# Line 106 | Line 106 | class RtraceSimulManager : public RadSimulManager {
106                                          VCOPY(orgdir[0], org); VCOPY(orgdir[1], dir);
107                                          return(EnqueueBundle(orgdir, 1, rID) > 0);
108                                  }
109 <                                /// Set/change cooked ray callback & FIFO flag
109 >                                /// Set/change cooked ray callback
110          void                    SetCookedCall(RayReportCall *cb, void *cd = NULL) {
111                                          if (cookedCall && (cookedCall != cb) | (ccData != cd))
112                                                  FlushQueue();
113                                          cookedCall = cb;
114 <                                        ccData = cd;
114 >                                        ccData = cb ? cd : NULL;
115                                  }
116                                  /// Set/change trace callback
117          void                    SetTraceCall(RayReportCall *cb, void *cd = NULL) {
118                                          traceCall = cb;
119 <                                        tcData = cd;
119 >                                        tcData = cb ? cd : NULL;
120                                  }
121                                  /// Are we ready?
122          bool                    Ready() const {
# Line 127 | Line 127 | class RtraceSimulManager : public RadSimulManager {
127          int                     FlushQueue();
128                                  /// Close octree, free data, return status
129          int                     Cleanup(bool everything = false) {
130 +                                        FlushQueue();
131                                          SetCookedCall(NULL);
132                                          SetTraceCall(NULL);
133                                          rtFlags = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines