From 2bd178ed67dc9924f32cee9b6cced5b04f20e81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20B=C3=A9land?= Date: Tue, 12 Oct 2021 19:54:45 -0400 Subject: [PATCH] Found a temporary way to prevent the creation of invalid triplets when computing a VBAP speaker setup (issue #315). --- Source/sg_vbap.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/sg_vbap.cpp b/Source/sg_vbap.cpp index d5990009..468a5938 100644 --- a/Source/sg_vbap.cpp +++ b/Source/sg_vbap.cpp @@ -516,12 +516,17 @@ static triplet_list_t generateTriplets(std::array co for (auto j{ i + 1 }; j < speakerIndexesSortedByElevation.size(); ++j) { auto const speaker2Index{ speakerIndexesSortedByElevation[j] }; auto const & speaker2{ speakers[speaker2Index] }; - static constexpr radians_t MAX_ELEVATION_DIFF{ degrees_t{ 10.0f } }; - if (speaker2.getPolar().elevation - speaker1.getPolar().elevation > MAX_ELEVATION_DIFF) { - // The elevation difference is only going to get greater : we can move the 1st speaker and reset the - // other loops - break; - } + + // TODO : disabling this check seems to have solved a lot of incomplete triangular meshes that used to + // happen on various random speaker setups. + + // static constexpr radians_t MAX_ELEVATION_DIFF{ degrees_t{ 10.0f } }; + // if (speaker2.getPolar().elevation - speaker1.getPolar().elevation > MAX_ELEVATION_DIFF) { + // // The elevation difference is only going to get greater : we can move the 1st speaker and reset the + // // other loops + // break; + //} + for (size_t k{}; k < speakerIndexesSortedByElevation.size(); ++k) { if (k >= i && k <= j) { // If k is between i and j, it means that i and k are within the elevation threshold (as well as k @@ -530,9 +535,8 @@ static triplet_list_t generateTriplets(std::array co } auto const speaker3Index{ speakerIndexesSortedByElevation[k] }; auto const & speaker3{ speakers[speaker3Index] }; - auto const isValidCandidate{ parallelepipedVolumeSideLength(speaker1, speaker2, speaker3) - > MIN_VOL_P_SIDE_LENGTH }; - if (isValidCandidate) { + auto const parallelepipedVolume{ parallelepipedVolumeSideLength(speaker1, speaker2, speaker3) }; + if (parallelepipedVolume > MIN_VOL_P_SIDE_LENGTH) { connections[speaker1Index][speaker2Index] = true; connections[speaker2Index][speaker1Index] = true; connections[speaker1Index][speaker3Index] = true;