mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 21:26:25 +02:00
Initial pass at fix looks promising
This commit is contained in:
parent
d8581c1026
commit
6ddd7a612c
4 changed files with 21 additions and 9 deletions
|
@ -583,7 +583,7 @@ Item {
|
||||||
|
|
||||||
// Function body by Howard Stearns 2017-01-08
|
// Function body by Howard Stearns 2017-01-08
|
||||||
function goToUserInDomain(avatarUuid) {
|
function goToUserInDomain(avatarUuid) {
|
||||||
var avatar = AvatarList.getAvatar(avatarUuid);
|
var avatar = AvatarList.getAvatarCopy(avatarUuid);
|
||||||
if (!avatar) {
|
if (!avatar) {
|
||||||
console.log("This avatar is no longer present. goToUserInDomain() failed.");
|
console.log("This avatar is no longer present. goToUserInDomain() failed.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -35,6 +35,17 @@ AvatarData* AvatarHashMap::getAvatar(QUuid avatarID) {
|
||||||
return getAvatarBySessionID(avatarID).get();
|
return getAvatarBySessionID(avatarID).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AvatarData* AvatarHashMap::getAvatarCopy(QUuid avatarID) {
|
||||||
|
AvatarData* avatarDataOriginal = getAvatarBySessionID(avatarID).get();
|
||||||
|
AvatarData* avatarDataCopy = new AvatarData();
|
||||||
|
avatarDataCopy->setSessionUUID(avatarDataOriginal->getSessionUUID());
|
||||||
|
avatarDataCopy->setSessionDisplayName(avatarDataOriginal->getSessionDisplayName());
|
||||||
|
avatarDataCopy->setPosition(avatarDataOriginal->getPosition());
|
||||||
|
//avatarDataCopy->setAudioLoudness(avatarDataOriginal->getAudioLoudness());
|
||||||
|
//avatarDataCopy->setAudioAverageLoudness(avatarDataOriginal->getAudioAverageLoudness());
|
||||||
|
return avatarDataCopy;
|
||||||
|
}
|
||||||
|
|
||||||
bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range) {
|
bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range) {
|
||||||
auto hashCopy = getHashCopy();
|
auto hashCopy = getHashCopy();
|
||||||
foreach(const AvatarSharedPointer& sharedAvatar, hashCopy) {
|
foreach(const AvatarSharedPointer& sharedAvatar, hashCopy) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
// Currently, your own avatar will be included as the null avatar id.
|
// Currently, your own avatar will be included as the null avatar id.
|
||||||
Q_INVOKABLE QVector<QUuid> getAvatarIdentifiers();
|
Q_INVOKABLE QVector<QUuid> getAvatarIdentifiers();
|
||||||
Q_INVOKABLE AvatarData* getAvatar(QUuid avatarID);
|
Q_INVOKABLE AvatarData* getAvatar(QUuid avatarID);
|
||||||
|
Q_INVOKABLE AvatarData* getAvatarCopy(QUuid avatarID);
|
||||||
|
|
||||||
virtual AvatarSharedPointer getAvatarBySessionID(const QUuid& sessionID) const { return findAvatar(sessionID); }
|
virtual AvatarSharedPointer getAvatarBySessionID(const QUuid& sessionID) const { return findAvatar(sessionID); }
|
||||||
int numberOfAvatarsInRange(const glm::vec3& position, float rangeMeters);
|
int numberOfAvatarsInRange(const glm::vec3& position, float rangeMeters);
|
||||||
|
|
|
@ -487,7 +487,7 @@ function populateNearbyUserList(selectData, oldAudioData) {
|
||||||
horizontalAngleNormal = filter && Quat.getUp(orientation);
|
horizontalAngleNormal = filter && Quat.getUp(orientation);
|
||||||
avatarsOfInterest = {};
|
avatarsOfInterest = {};
|
||||||
avatars.forEach(function (id) {
|
avatars.forEach(function (id) {
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatarCopy(id);
|
||||||
var name = avatar.sessionDisplayName;
|
var name = avatar.sessionDisplayName;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
// Either we got a data packet but no identity yet, or something is really messed up. In any case,
|
// Either we got a data packet but no identity yet, or something is really messed up. In any case,
|
||||||
|
@ -561,7 +561,7 @@ function updateOverlays() {
|
||||||
if (!id || !avatarsOfInterest[id]) {
|
if (!id || !avatarsOfInterest[id]) {
|
||||||
return; // don't update ourself, or avatars we're not interested in
|
return; // don't update ourself, or avatars we're not interested in
|
||||||
}
|
}
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatarCopy(id);
|
||||||
if (!avatar) {
|
if (!avatar) {
|
||||||
return; // will be deleted below if there had been an overlay.
|
return; // will be deleted below if there had been an overlay.
|
||||||
}
|
}
|
||||||
|
@ -574,10 +574,10 @@ function updateOverlays() {
|
||||||
var distance = Vec3.distance(target, eye);
|
var distance = Vec3.distance(target, eye);
|
||||||
var offset = 0.2;
|
var offset = 0.2;
|
||||||
var diff = Vec3.subtract(target, eye); // get diff between target and eye (a vector pointing to the eye from avatar position)
|
var diff = Vec3.subtract(target, eye); // get diff between target and eye (a vector pointing to the eye from avatar position)
|
||||||
var headIndex = avatar.getJointIndex("Head"); // base offset on 1/2 distance from hips to head if we can
|
//var headIndex = avatar.getJointIndex("Head"); // base offset on 1/2 distance from hips to head if we can
|
||||||
if (headIndex > 0) {
|
//if (headIndex > 0) {
|
||||||
offset = avatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y / 2;
|
// offset = avatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y / 2;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// move a bit in front, towards the camera
|
// move a bit in front, towards the camera
|
||||||
target = Vec3.subtract(target, Vec3.multiply(Vec3.normalize(diff), offset));
|
target = Vec3.subtract(target, Vec3.multiply(Vec3.normalize(diff), offset));
|
||||||
|
@ -843,14 +843,14 @@ function getAudioLevel(id) {
|
||||||
// the VU meter should work similarly to the one in AvatarInputs: log scale, exponentially averaged
|
// the VU meter should work similarly to the one in AvatarInputs: log scale, exponentially averaged
|
||||||
// But of course it gets the data at a different rate, so we tweak the averaging ratio and frequency
|
// But of course it gets the data at a different rate, so we tweak the averaging ratio and frequency
|
||||||
// of updating (the latter for efficiency too).
|
// of updating (the latter for efficiency too).
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatarCopy(id);
|
||||||
var audioLevel = 0.0;
|
var audioLevel = 0.0;
|
||||||
var avgAudioLevel = 0.0;
|
var avgAudioLevel = 0.0;
|
||||||
var data = id ? ExtendedOverlay.get(id) : myData;
|
var data = id ? ExtendedOverlay.get(id) : myData;
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
||||||
// we will do exponential moving average by taking some the last loudness and averaging
|
// we will do exponential moving average by taking some the last loudness and averaging
|
||||||
data.accumulatedLevel = AVERAGING_RATIO * (data.accumulatedLevel || 0) + (1 - AVERAGING_RATIO) * (avatar.audioLoudness);
|
data.accumulatedLevel = 0;//AVERAGING_RATIO * (data.accumulatedLevel || 0) + (1 - AVERAGING_RATIO) * (avatar.audioLoudness);
|
||||||
|
|
||||||
// add 1 to insure we don't go log() and hit -infinity. Math.log is
|
// add 1 to insure we don't go log() and hit -infinity. Math.log is
|
||||||
// natural log, so to get log base 2, just divide by ln(2).
|
// natural log, so to get log base 2, just divide by ln(2).
|
||||||
|
|
Loading…
Reference in a new issue