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.2 by greg, Wed Jul 26 23:27:44 2023 UTC vs.
Revision 2.4 by greg, Wed Aug 2 00:04:31 2023 UTC

# Line 23 | Line 23 | typedef void   RayReportCall(RAY *r, void *cd);
23   class RadSimulManager {
24          int                     nThreads;       // number of active threads
25   protected:
26 <                                /// How many cores are there?
27 <        static int              GetNCores();
26 >                                // Assign ray to subthread (fails if NThreads()<2)
27 >        bool                    SplitRay(RAY *r);
28   public:
29                                  RadSimulManager(const char *octn = NULL) {
30                                          LoadOctree(octn);
# Line 35 | Line 35 | class RadSimulManager { (public)
35                                  }
36                                  /// Load octree and prepare renderer
37          bool                    LoadOctree(const char *octn);
38 +                                /// How many cores are there?
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)
# Line 47 | Line 49 | class RadSimulManager { (public)
49          bool                    Ready() const {
50                                          return (octname && nsceneobjs > 0);
51                                  }
52 +                                /// Process a ray (in subthread), optional result
53 +        bool                    ProcessRay(RAY *r);
54 +                                /// Wait for next result (or fail)
55 +        bool                    WaitResult(RAY *r);
56                                  /// Close octree, free data, return status
57 <        int                     Cleanup();
57 >        int                     Cleanup(bool everything = false);
58   };
59  
60   /// Flags to control rendering operations
# Line 66 | Line 72 | class RtraceSimulManager : public RadSimulManager {
72                                  // Check for changes to render flags, etc.
73          bool                    UpdateMode();
74   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 76 | Line 84 | class RtraceSimulManager : public RadSimulManager {
84                                          SetCookedCall(cb, cd);
85                                          traceCall = NULL; tcData = NULL;
86                                  }
87 <                                ~RtraceSimulManager() {}
87 >                                ~RtraceSimulManager() {
88 >                                        FlushQueue();
89 >                                }
90                                  /// Set number of computation threads (0 => #cores)
91          int                     SetThreadCount(int nt = 0) {
92                                          if (nt <= 0) nt = GetNCores();
# Line 91 | Line 101 | class RtraceSimulManager : public RadSimulManager {
101          bool                    EnqueueRay(const FVECT org, const FVECT dir,
102                                                  RNUMBER rID = 0) {
103                                          if (dir == org+1)
104 <                                                return EnqueueBundle((const FVECT *)org, 1, rID);
104 >                                                return(EnqueueBundle((const FVECT *)org, 1, rID) > 0);
105                                          FVECT   orgdir[2];
106                                          VCOPY(orgdir[0], org); VCOPY(orgdir[1], dir);
107 <                                        return EnqueueBundle(orgdir, 1, rID);
107 >                                        return(EnqueueBundle(orgdir, 1, rID) > 0);
108                                  }
109                                  /// Set/change cooked ray callback & FIFO flag
110          void                    SetCookedCall(RayReportCall *cb, void *cd = NULL) {
# Line 113 | Line 123 | class RtraceSimulManager : public RadSimulManager {
123                                          return (cookedCall != NULL) | (traceCall != NULL) &&
124                                                  RadSimulManager::Ready();
125                                  }
126 <                                /// Finish pending rays and complete callbacks
127 <        bool                    FlushQueue();
126 >                                /// Finish pending rays and complete callbacks (return #sent)
127 >        int                     FlushQueue();
128                                  /// Close octree, free data, return status
129 <        int                     Cleanup() {
129 >        int                     Cleanup(bool everything = false) {
130                                          SetCookedCall(NULL);
131                                          SetTraceCall(NULL);
132                                          rtFlags = 0;
133                                          UpdateMode();
134                                          lastRayID = 0;
135 <                                        return RadSimulManager::Cleanup();
135 >                                        return RadSimulManager::Cleanup(everything);
136                                  }
137   };
138  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines