MCPcopy Create free account
hub / github.com/ValveSoftware/steam-audio / calcAverageDirectionForPaths

Method calcAverageDirectionForPaths

core/src/core/path_simulator.cpp:494–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492
493
494void 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
539void PathSimulator::calcDistanceRatioForPaths(const Vector3f& source,
540 const ProbeBatch& probes,

Callers

nothing calls this directly

Calls 5

toVirtualSourceMethod · 0.80
maxFunction · 0.70
unitVectorFunction · 0.50
isValidMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected