First, find the source-probe (the probe nearest to the source), and the listener-probes (all probes which influence the listener). For each listener-probe, query the baked data for the shortest path from the source-probe to the listener-probe. Weights are calculated for the paths reaching each listener-probe, such that if the listener is closer to a given listener-probe, its corresponding weight
| 123 | // |
| 124 | // Finally, all the paths that haven't been discarded are weighted and summed into a set of SH and EQ coefficients. |
| 125 | bool PathSimulator::findPaths(const Vector3f& source, |
| 126 | const Vector3f& listener, |
| 127 | const IScene& scene, |
| 128 | const ProbeBatch& probes, |
| 129 | const ProbeNeighborhood& sourceProbes, |
| 130 | const ProbeNeighborhood& listenerProbes, |
| 131 | float radius, |
| 132 | float threshold, |
| 133 | float visRange, |
| 134 | int order, |
| 135 | bool enableValidation, |
| 136 | bool findAlternatePaths, |
| 137 | bool simplifyPaths, |
| 138 | bool realTimeVis, |
| 139 | float* eqGains, |
| 140 | float* coeffs, |
| 141 | const DistanceAttenuationModel& distanceAttenuationModel, |
| 142 | const DeviationModel& deviationModel, |
| 143 | Vector3f* avgDirection, |
| 144 | float* distanceRatio, |
| 145 | float* totalDeviation, |
| 146 | ValidationRayVisualizationCallback validationRayVisualization, |
| 147 | void* userData, |
| 148 | bool forceDirectOcclusion) |
| 149 | { |
| 150 | PROFILE_FUNCTION(); |
| 151 | |
| 152 | const int kMaxPaths = 64; |
| 153 | |
| 154 | int numPaths = 0; |
| 155 | SoundPath paths[kMaxPaths]; |
| 156 | float pathWeights[kMaxPaths]; |
| 157 | int starts[kMaxPaths]; |
| 158 | int ends[kMaxPaths]; |
| 159 | |
| 160 | if (scene.isOccluded(listener, source) || forceDirectOcclusion) |
| 161 | { |
| 162 | if (sourceProbes.hasValidProbes() && listenerProbes.hasValidProbes()) |
| 163 | { |
| 164 | BakedDataIdentifier identifier; |
| 165 | identifier.variation = BakedDataVariation::Dynamic; |
| 166 | identifier.type = BakedDataType::Pathing; |
| 167 | |
| 168 | if (probes.hasData(identifier)) |
| 169 | { |
| 170 | const auto& bakedPathData = static_cast<const BakedPathData&>(probes[identifier]); |
| 171 | |
| 172 | if (sEnablePathsFromAllSourceProbes) |
| 173 | { |
| 174 | for (auto i = 0; i < sourceProbes.numProbes(); ++i) |
| 175 | { |
| 176 | findPathsFromSourceProbe(scene, probes, sourceProbes, listenerProbes, bakedPathData, i, sourceProbes.weights[i], |
| 177 | radius, threshold, visRange, enableValidation, findAlternatePaths, simplifyPaths, realTimeVis, |
| 178 | validationRayVisualization, userData, numPaths, paths, pathWeights, starts, ends); |
| 179 | } |
| 180 | } |
| 181 | else |
| 182 | { |