mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
CR feedback
This commit is contained in:
parent
2da911ad84
commit
4daa0c6537
4 changed files with 29 additions and 12 deletions
|
@ -1120,7 +1120,7 @@ Rectangle {
|
|||
var data = message.params;
|
||||
var index = -1;
|
||||
iAmAdmin = Users.canKick;
|
||||
index = findNearbySessionIndex(MyAvatar.sessionUUID, data);
|
||||
index = findNearbySessionIndex("", data);
|
||||
if (index !== -1) {
|
||||
myData = data[index];
|
||||
data.splice(index, 1);
|
||||
|
@ -1197,8 +1197,8 @@ Rectangle {
|
|||
for (var userId in message.params) {
|
||||
var audioLevel = message.params[userId][0];
|
||||
var avgAudioLevel = message.params[userId][1];
|
||||
// If the userId is 0, we're updating "myData".
|
||||
if (userId == 0) {
|
||||
// If the userId is "", we're updating "myData".
|
||||
if (userId === "") {
|
||||
myData.audioLevel = audioLevel;
|
||||
myCard.audioLevel = audioLevel; // Defensive programming
|
||||
myData.avgAudioLevel = avgAudioLevel;
|
||||
|
|
|
@ -670,7 +670,7 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV
|
|||
}
|
||||
}
|
||||
|
||||
QString AvatarManager::getPalData(const QList<QString> specificAvatarIdentifiers) {
|
||||
QVariantMap AvatarManager::getPalData(const QList<QString> specificAvatarIdentifiers) {
|
||||
QJsonArray palData;
|
||||
|
||||
auto avatarMap = getHashCopy();
|
||||
|
@ -680,6 +680,13 @@ QString AvatarManager::getPalData(const QList<QString> specificAvatarIdentifiers
|
|||
QString currentSessionUUID = avatar->getSessionUUID().toString();
|
||||
if (specificAvatarIdentifiers.isEmpty() || specificAvatarIdentifiers.contains(currentSessionUUID)) {
|
||||
QJsonObject thisAvatarPalData;
|
||||
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
if (currentSessionUUID == myAvatar->getSessionUUID().toString()) {
|
||||
currentSessionUUID = "";
|
||||
}
|
||||
|
||||
thisAvatarPalData.insert("sessionUUID", currentSessionUUID);
|
||||
thisAvatarPalData.insert("sessionDisplayName", avatar->getSessionDisplayName());
|
||||
thisAvatarPalData.insert("audioLoudness", avatar->getAudioLoudness());
|
||||
|
@ -704,6 +711,7 @@ QString AvatarManager::getPalData(const QList<QString> specificAvatarIdentifiers
|
|||
}
|
||||
++itr;
|
||||
}
|
||||
QJsonDocument doc(palData);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
QJsonObject doc;
|
||||
doc.insert("data", palData);
|
||||
return doc.toVariantMap();
|
||||
}
|
||||
|
|
|
@ -157,7 +157,16 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void setAvatarSortCoefficient(const QString& name, const QScriptValue& value);
|
||||
|
||||
Q_INVOKABLE QString getPalData(const QList<QString> specificAvatarIdentifiers = QList<QString>());
|
||||
/**jsdoc
|
||||
* Used in the PAL for getting PAL-related data about avatars nearby. Using this method is faster
|
||||
* than iterating over each avatar and obtaining data about them in JavaScript, as that method
|
||||
* locks and unlocks each avatar's data structure potentially hundreds of times per update tick.
|
||||
* @function AvatarManager.getPalData
|
||||
* @param {string list} specificAvatarIdentifiers - A list of specific Avatar Identifiers about which
|
||||
* you want to get PAL data
|
||||
* @returns {string}
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getPalData(const QList<QString> specificAvatarIdentifiers = QList<QString>());
|
||||
|
||||
float getMyAvatarSendRate() const { return _myAvatarSendRate.rate(); }
|
||||
int getIdentityRequestsSent() const { return _identityRequestsSent; }
|
||||
|
|
|
@ -448,7 +448,7 @@ function populateNearbyUserList(selectData, oldAudioData) {
|
|||
horizontalAngleNormal = filter && Quat.getUp(orientation);
|
||||
avatarsOfInterest = {};
|
||||
|
||||
var avatarData = JSON.parse(AvatarList.getPalData());
|
||||
var avatarData = AvatarList.getPalData().data;
|
||||
|
||||
avatarData.forEach(function (currentAvatarData) {
|
||||
var id = currentAvatarData.sessionUUID;
|
||||
|
@ -487,7 +487,7 @@ function populateNearbyUserList(selectData, oldAudioData) {
|
|||
};
|
||||
// Everyone needs to see admin status. Username and fingerprint returns default constructor output if the requesting user isn't an admin.
|
||||
Users.requestUsernameFromID(id);
|
||||
if (id !== MyAvatar.sessionUUID) {
|
||||
if (id !== "") {
|
||||
addAvatarNode(id); // No overlay for ourselves
|
||||
avatarsOfInterest[id] = true;
|
||||
} else {
|
||||
|
@ -548,7 +548,7 @@ function updateAudioLevel(overlay, avatarData) {
|
|||
|
||||
var param = {};
|
||||
var level = [audioLevel, avgAudioLevel];
|
||||
var userId = avatarData.sessionUUID === MyAvatar.sessionUUID ? 0 : avatarData.sessionUUID;
|
||||
var userId = avatarData.sessionUUID;
|
||||
param[userId] = level;
|
||||
sendToQml({ method: 'updateAudioLevel', params: param });
|
||||
}
|
||||
|
@ -557,12 +557,12 @@ var pingPong = true;
|
|||
function updateOverlays() {
|
||||
var eye = Camera.position;
|
||||
|
||||
var avatarData = JSON.parse(AvatarList.getPalData());
|
||||
var avatarData = AvatarList.getPalData().data;
|
||||
|
||||
avatarData.forEach(function (currentAvatarData) {
|
||||
updateAudioLevel(overlay, currentAvatarData);
|
||||
|
||||
if (currentAvatarData.sessionUUID === MyAvatar.sessionUUID || !avatarsOfInterest[currentAvatarData.sessionUUID]) {
|
||||
if (currentAvatarData.sessionUUID === "" || !avatarsOfInterest[currentAvatarData.sessionUUID]) {
|
||||
return; // don't update ourself, or avatars we're not interested in
|
||||
}
|
||||
var overlay = ExtendedOverlay.get(currentAvatarData.sessionUUID);
|
||||
|
|
Loading…
Reference in a new issue