| 193 | // -------------------------------------------------------------------------------------------------------------------- |
| 194 | |
| 195 | BakedPathData::BakedPathData(const IScene& scene, |
| 196 | const ProbeBatch& probes, |
| 197 | int numSamples, |
| 198 | float radius, |
| 199 | float threshold, |
| 200 | float visRange, |
| 201 | float visRangeRealTime, |
| 202 | float pathRange, |
| 203 | bool asymmetricVisRange, |
| 204 | const Vector3f& down, |
| 205 | bool pruneVisGraph, |
| 206 | int numThreads, |
| 207 | ThreadPool& threadPool, |
| 208 | std::atomic<bool>& cancel, |
| 209 | ProgressCallback progressCallback, |
| 210 | void* callbackUserData) |
| 211 | : mBakedPathRefs(probes.numProbes(), probes.numProbes()) |
| 212 | { |
| 213 | // First, generate the visibility graph. |
| 214 | ProbeVisibilityTester visTester(numSamples, asymmetricVisRange, down); |
| 215 | |
| 216 | JobGraph jobGraph{}; |
| 217 | mVisGraph = ipl::make_unique<ProbeVisibilityGraph>(scene, probes, visTester, radius, threshold, visRange, |
| 218 | numThreads, jobGraph, cancel, progressCallback, callbackUserData); |
| 219 | |
| 220 | threadPool.process(jobGraph, [progressCallback, callbackUserData](float percentComplete) { progressCallback(percentComplete, callbackUserData); }); |
| 221 | |
| 222 | // Next, using multiple threads, calculate shortest paths between every pair of probes. |
| 223 | PathFinder pathFinder(probes, numThreads); |
| 224 | Array<ProbePath, 2> probePaths(probes.numProbes(), probes.numProbes()); |
| 225 | |
| 226 | if (cancel) |
| 227 | { |
| 228 | cancel = false; |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | jobGraph.reset(); |
| 233 | |
| 234 | for (auto i = 0; i < probes.numProbes(); i++) |
| 235 | { |
| 236 | jobGraph.addJob([this, i, &scene, &probes, &probePaths, &pathFinder, radius, threshold, pathRange](int threadIndex, std::atomic<bool>&) |
| 237 | { |
| 238 | PROFILE_ZONE("BakedPathData::bakeJob"); |
| 239 | |
| 240 | for (auto j = 0; j < probes.numProbes(); ++j) |
| 241 | { |
| 242 | probePaths[i][j].nodes.clear(); |
| 243 | } |
| 244 | |
| 245 | pathFinder.findAllShortestPaths(scene, probes, *mVisGraph, i, radius, threshold, pathRange, threadIndex, probePaths[i]); |
| 246 | }); |
| 247 | } |
| 248 | |
| 249 | threadPool.process(jobGraph, [progressCallback, callbackUserData](float percentComplete) { progressCallback(percentComplete, callbackUserData); }); |
| 250 | |
| 251 | // Remove all data with j > i, since they can be reconstructed from the data with j < i due to symmetry. |
| 252 | ProbePath invalidProbePath; |
nothing calls this directly
no test coverage detected