Skip to content

Commit 94ab45f

Browse files
committed
Revert "Merge pull request #2 from carbonengine/minor-update-dates"
This reverts commit 46d53fe, reversing changes made to db645e9.
1 parent 46d53fe commit 94ab45f

File tree

7 files changed

+19
-74
lines changed

7 files changed

+19
-74
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Spatial Audio Object Clustering Plugin for Wwise
22

3-
Copyright 2025 CCP Games
3+
Copyright 2024 CCP Games
44

55
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
66

ObjectCluster/SoundEnginePlugin/KMeans.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 CCP ehf.
2+
* Copyright 2024 CCP ehf.
33
*
44
* This software was developed by CCP Games for spatial audio object clustering
55
* in EVE Online and EVE Frontier.
@@ -223,15 +223,6 @@ class KMeans {
223223
float minDistanceThreshold = 10.f,
224224
float maxDistanceThreshold = 1000.f);
225225

226-
227-
void reinitializeClustering() {
228-
centroids.clear();
229-
labels.clear();
230-
clusters.clear();
231-
sse_values.clear();
232-
unassignedPoints.clear();
233-
}
234-
235226
/**
236227
* @brief Sets the convergence tolerance.
237228
* @param newValue The new tolerance value.

ObjectCluster/SoundEnginePlugin/Kmeans.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void KMeans::initializeCentroids(const std::vector<ObjectPosition>& objects) {
3636
std::vector<ObjectMetadata> objectsMetadata;
3737
objectsMetadata.reserve(objects.size());
3838

39-
// Use a smaller radius for density calculation when threshold is small
40-
const float densityRadius = m_distanceThreshold * 0.25f; // More sensitive to local density
39+
// Calculate local density including origin region
40+
const float densityRadius = m_distanceThreshold * 0.5f;
4141
const float densityRadiusSq = densityRadius * densityRadius;
4242

4343
// Track density around origin specifically
@@ -109,22 +109,25 @@ void KMeans::initializeCentroids(const std::vector<ObjectPosition>& objects) {
109109
size_t bestCandidate = 0;
110110
bool candidateFound = false;
111111

112+
// Find point with maximum minimum distance to existing centroids
112113
for (size_t i = 0; i < objectsMetadata.size(); ++i) {
113114
float minDist = std::numeric_limits<float>::max();
114115
for (const auto& centroid : centroids) {
115116
float dist = calculateDistance(objectsMetadata[i].object.position, centroid);
116117
minDist = std::min(minDist, dist);
117118
}
118119

119-
// More likely to create new centroids with smaller thresholds
120-
if (minDist > maxMinDistance && minDist > m_distanceThreshold * 0.5f) {
120+
if (minDist > maxMinDistance) {
121121
maxMinDistance = minDist;
122122
bestCandidate = i;
123123
candidateFound = true;
124124
}
125125
}
126126

127-
if (!candidateFound) break;
127+
if (!candidateFound || maxMinDistance < m_distanceThreshold) {
128+
break;
129+
}
130+
128131
centroids.push_back(objectsMetadata[bestCandidate].object.position);
129132
}
130133
}
@@ -344,30 +347,16 @@ void KMeans::setTolerance(float newValue) {
344347
}
345348

346349
void KMeans::setDistanceThreshold(float newValue) {
347-
348-
if (newValue != m_distanceThreshold) {
349-
m_distanceThreshold = clamp(newValue, m_minThreshold, m_maxThreshold);
350-
351-
// Clear existing state to force recalculation
352-
centroids.clear();
353-
labels.clear();
354-
clusters.clear();
355-
sse_values.clear();
356-
unassignedPoints.clear();
357-
}
350+
m_distanceThreshold = clamp(newValue, m_minThreshold, m_maxThreshold);
358351
}
359352

360353
void KMeans::performClustering(const std::vector<ObjectPosition>& objects, unsigned int max_iterations) {
361-
// Resize labels vector to match input size
362354
labels.resize(objects.size(), -1);
363-
364-
// Recalculate max clusters based on current objects
365355
maxClusters = determineMaxClusters(objects.size());
366-
367-
// Always reinitialize centroids
368356
initializeCentroids(objects);
369357

370358
for (unsigned int iter = 0; iter < max_iterations; ++iter) {
359+
371360
bool changed = assignPointsToClusters(objects);
372361
adjustClusterCount();
373362
bool centroidsUpdated = updateCentroids();

ObjectCluster/SoundEnginePlugin/ObjectClusterFX.cpp

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
2222
the 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
2727
This implementation was developed by CCP Games for spatial audio object clustering
2828
in 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-
389372
void 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

ObjectCluster/SoundEnginePlugin/ObjectClusterFX.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
2222
the 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
2727
This implementation was developed by CCP Games for spatial audio object clustering
2828
in EVE Online and EVE Frontier. This implementation does not grant any rights to
@@ -114,10 +114,6 @@ class ObjectClusterFX : public AK::IAkOutOfPlaceObjectPlugin
114114
AK::IAkPluginMemAlloc* m_pAllocator;
115115
AK::IAkEffectPluginContext* m_pContext;
116116

117-
bool thresholdChanged = false;
118-
119-
void SafeCleanupForThresholdChange();
120-
121117
/**
122118
* @brief Updates KMeans algorithm with input object positions
123119
* @param inObjects Input audio objects

ObjectCluster/SoundEnginePlugin/Utilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 CCP ehf.
2+
* Copyright 2024 CCP ehf.
33
*
44
* This software was developed by CCP Games for spatial audio object clustering
55
* in EVE Online and EVE Frontier.

ObjectCluster/SoundEnginePlugin/Utilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 CCP ehf.
2+
* Copyright 2024 CCP ehf.
33
*
44
* This software was developed by CCP Games for spatial audio object clustering
55
* in EVE Online and EVE Frontier.

0 commit comments

Comments
 (0)