@@ -22,7 +22,7 @@ OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
2222the specific language governing permissions and limitations under the License.
2323
2424 Copyright (c) 2023 Audiokinetic Inc.
25- Copyright (c) 2025 CCP ehf.
25+ Copyright (c) 2024 CCP ehf.
2626
2727This implementation was developed by CCP Games for spatial audio object clustering
2828in EVE Online and EVE Frontier. This implementation does not grant any rights to
@@ -369,64 +369,33 @@ void ObjectClusterFX::MixToCluster(const AkAudioObject* inObject, AkAudioBuffer*
369369 AKPLATFORM::AkMemCpy (pGeneratedObject->volumeMatrix , currentVolumes, uTransmixSize);
370370}
371371
372- void ObjectClusterFX::SafeCleanupForThresholdChange ()
373- {
374- auto it = m_mapInObjsToOutObjs.Begin ();
375- while (it != m_mapInObjsToOutObjs.End ()) {
376- if ((*it).pUserData ) {
377- // Don't delete the object, just mark it as unclustered
378- (*it).pUserData ->isClustered = false ;
379- // Reset index to force reassignment
380- (*it).pUserData ->index = -1 ;
381- }
382- ++it;
383- }
384-
385- // Clear cluster assignments but maintain existing objects
386- m_clusters.clear ();
387- }
388-
389372void ObjectClusterFX::FeedPositionsToKMeans (const AkAudioObjects& inObjects)
390373{
391- bool thresholdChanged = false ;
392- bool thresholdDecreased = false ;
393374
394375 if (m_lastDistanceThreshold != m_pParams->RTPC .distanceThreshold ) {
395- thresholdChanged = true ;
396- thresholdDecreased = m_pParams->RTPC .distanceThreshold < m_lastDistanceThreshold;
397-
398376 m_kmeans->setDistanceThreshold (m_pParams->RTPC .distanceThreshold );
399377 m_lastDistanceThreshold = m_pParams->RTPC .distanceThreshold ;
400-
401- // Safe cleanup when threshold changes
402- SafeCleanupForThresholdChange ();
403378 }
404379
405380 std::vector<ObjectPosition> objectPositions;
406381 objectPositions.reserve (inObjects.uNumObjects );
407382
408- // Collect positions and ensure proper redistribution
409383 for (AkUInt32 i = 0 ; i < inObjects.uNumObjects ; ++i) {
410384 AkAudioObject* inobj = inObjects.ppObjects [i];
411385
386+ // Check if this is either position-only or position+orientation
412387 bool shouldCluster = (inobj->positioning .behavioral .spatMode == AK_SpatializationMode_PositionOnly ||
413388 inobj->positioning .behavioral .spatMode == AK_SpatializationMode_PositionAndOrientation);
414389
415390 if (shouldCluster) {
416391 objectPositions.push_back ({ inobj->positioning .threeD .xform .Position (), inobj->key });
417392 }
418393 }
419-
394+ // Perform clustering only if there are objects
395+ m_clusters.clear ();
420396 if (!objectPositions.empty ()) {
421- // Force reinitialization of KMeans when threshold decreases
422- if (thresholdDecreased) {
423- m_kmeans->reinitializeClustering ();
424- }
425-
426397 m_kmeans->performClustering (objectPositions);
427398
428- // Update clusters with new assignments
429- m_clusters.clear ();
430399 auto tempClusters = m_kmeans->getClusters ();
431400 m_clusters.reserve (tempClusters.size ());
432401
0 commit comments