| 492 | |
| 493 | |
| 494 | void PathSimulator::calcAverageDirectionForPaths(const Vector3f& source, |
| 495 | const Vector3f& listener, |
| 496 | const ProbeBatch& probes, |
| 497 | int* starts, |
| 498 | int* ends, |
| 499 | int numPaths, |
| 500 | const SoundPath* paths, |
| 501 | const float* weights, |
| 502 | Vector3f* avgDirection) |
| 503 | { |
| 504 | PROFILE_FUNCTION(); |
| 505 | |
| 506 | if (!avgDirection) |
| 507 | return; |
| 508 | |
| 509 | Vector3f direction(.0f, .0f, .0f); |
| 510 | for (auto i = 0; i < numPaths; ++i) |
| 511 | { |
| 512 | if (!paths[i].isValid()) |
| 513 | continue; |
| 514 | |
| 515 | Vector3f virtualSource; |
| 516 | float distance; |
| 517 | |
| 518 | if (starts[i] >= 0 && ends[i] >= 0) |
| 519 | { |
| 520 | virtualSource = paths[i].toVirtualSource(probes, starts[i], ends[i]); |
| 521 | distance = (virtualSource - probes[ends[i]].influence.center).length(); |
| 522 | } |
| 523 | else |
| 524 | { |
| 525 | virtualSource = source; |
| 526 | distance = (virtualSource - listener).length(); |
| 527 | } |
| 528 | |
| 529 | auto distanceAttenuation = 1.0f / std::max(distance, 1.0f); |
| 530 | auto gain = weights[i] * distanceAttenuation; |
| 531 | auto pathDirection = Vector3f::unitVector(virtualSource - listener); |
| 532 | |
| 533 | direction += (pathDirection * gain); |
| 534 | } |
| 535 | |
| 536 | *avgDirection = Vector3f::unitVector(direction); |
| 537 | } |
| 538 | |
| 539 | void PathSimulator::calcDistanceRatioForPaths(const Vector3f& source, |
| 540 | const ProbeBatch& probes, |
nothing calls this directly
no test coverage detected