22 |
|
/// Multi-threaded simulation manager base class |
23 |
|
class RadSimulManager { |
24 |
|
int nThreads; // number of active threads |
25 |
– |
protected: |
26 |
– |
/// How many cores are there? |
27 |
– |
static int GetNCores(); |
25 |
|
public: |
26 |
|
RadSimulManager(const char *octn = NULL) { |
27 |
|
LoadOctree(octn); |
32 |
|
} |
33 |
|
/// Load octree and prepare renderer |
34 |
|
bool LoadOctree(const char *octn); |
35 |
+ |
/// How many cores are there? |
36 |
+ |
static int GetNCores(); |
37 |
|
/// Set number of computation threads (0 => #cores) |
38 |
|
int SetThreadCount(int nt = 0); |
39 |
|
/// Check thread count (1 means no multi-threading) |
47 |
|
return (octname && nsceneobjs > 0); |
48 |
|
} |
49 |
|
/// Close octree, free data, return status |
50 |
< |
int Cleanup(); |
50 |
> |
int Cleanup(bool everything = false); |
51 |
|
}; |
52 |
|
|
53 |
|
/// Flags to control rendering operations |
75 |
|
SetCookedCall(cb, cd); |
76 |
|
traceCall = NULL; tcData = NULL; |
77 |
|
} |
78 |
< |
~RtraceSimulManager() {} |
78 |
> |
~RtraceSimulManager() { |
79 |
> |
FlushQueue(); |
80 |
> |
} |
81 |
|
/// Set number of computation threads (0 => #cores) |
82 |
|
int SetThreadCount(int nt = 0) { |
83 |
|
if (nt <= 0) nt = GetNCores(); |
92 |
|
bool EnqueueRay(const FVECT org, const FVECT dir, |
93 |
|
RNUMBER rID = 0) { |
94 |
|
if (dir == org+1) |
95 |
< |
return EnqueueBundle((const FVECT *)org, 1, rID); |
95 |
> |
return(EnqueueBundle((const FVECT *)org, 1, rID) > 0); |
96 |
|
FVECT orgdir[2]; |
97 |
|
VCOPY(orgdir[0], org); VCOPY(orgdir[1], dir); |
98 |
< |
return EnqueueBundle(orgdir, 1, rID); |
98 |
> |
return(EnqueueBundle(orgdir, 1, rID) > 0); |
99 |
|
} |
100 |
|
/// Set/change cooked ray callback & FIFO flag |
101 |
|
void SetCookedCall(RayReportCall *cb, void *cd = NULL) { |
117 |
|
/// Finish pending rays and complete callbacks |
118 |
|
bool FlushQueue(); |
119 |
|
/// Close octree, free data, return status |
120 |
< |
int Cleanup() { |
120 |
> |
int Cleanup(bool everything = false) { |
121 |
|
SetCookedCall(NULL); |
122 |
|
SetTraceCall(NULL); |
123 |
|
rtFlags = 0; |
124 |
|
UpdateMode(); |
125 |
|
lastRayID = 0; |
126 |
< |
return RadSimulManager::Cleanup(); |
126 |
> |
return RadSimulManager::Cleanup(everything); |
127 |
|
} |
128 |
|
}; |
129 |
|
|