mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into feat/replicants
This commit is contained in:
commit
e6ef153148
19 changed files with 321 additions and 44 deletions
|
@ -226,8 +226,9 @@ void AvatarMixer::start() {
|
||||||
nodeList->nestedEach([&](NodeList::const_iterator cbegin, NodeList::const_iterator cend) {
|
nodeList->nestedEach([&](NodeList::const_iterator cbegin, NodeList::const_iterator cend) {
|
||||||
std::for_each(cbegin, cend, [&](const SharedNodePointer& node) {
|
std::for_each(cbegin, cend, [&](const SharedNodePointer& node) {
|
||||||
if (node->getType() == NodeType::Agent && !node->isUpstream()) {
|
if (node->getType() == NodeType::Agent && !node->isUpstream()) {
|
||||||
manageDisplayName(node);
|
manageIdentityData(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
++_sumListeners;
|
++_sumListeners;
|
||||||
});
|
});
|
||||||
}, &lockWait, &nodeTransform, &functor);
|
}, &lockWait, &nodeTransform, &functor);
|
||||||
|
@ -278,8 +279,9 @@ void AvatarMixer::start() {
|
||||||
|
|
||||||
// NOTE: nodeData->getAvatar() might be side effected, must be called when access to node/nodeData
|
// NOTE: nodeData->getAvatar() might be side effected, must be called when access to node/nodeData
|
||||||
// is guaranteed to not be accessed by other thread
|
// is guaranteed to not be accessed by other thread
|
||||||
void AvatarMixer::manageDisplayName(const SharedNodePointer& node) {
|
void AvatarMixer::manageIdentityData(const SharedNodePointer& node) {
|
||||||
AvatarMixerClientData* nodeData = reinterpret_cast<AvatarMixerClientData*>(node->getLinkedData());
|
AvatarMixerClientData* nodeData = reinterpret_cast<AvatarMixerClientData*>(node->getLinkedData());
|
||||||
|
bool sendIdentity = false;
|
||||||
if (nodeData && nodeData->getAvatarSessionDisplayNameMustChange()) {
|
if (nodeData && nodeData->getAvatarSessionDisplayNameMustChange()) {
|
||||||
AvatarData& avatar = nodeData->getAvatar();
|
AvatarData& avatar = nodeData->getAvatar();
|
||||||
const QString& existingBaseDisplayName = nodeData->getBaseDisplayName();
|
const QString& existingBaseDisplayName = nodeData->getBaseDisplayName();
|
||||||
|
@ -305,9 +307,39 @@ void AvatarMixer::manageDisplayName(const SharedNodePointer& node) {
|
||||||
soFar.second++; // refcount
|
soFar.second++; // refcount
|
||||||
nodeData->flagIdentityChange();
|
nodeData->flagIdentityChange();
|
||||||
nodeData->setAvatarSessionDisplayNameMustChange(false);
|
nodeData->setAvatarSessionDisplayNameMustChange(false);
|
||||||
sendIdentityPacket(nodeData, node); // Tell node whose name changed about its new session display name.
|
sendIdentity = true;
|
||||||
qCDebug(avatars) << "Giving session display name" << sessionDisplayName << "to node with ID" << node->getUUID();
|
qCDebug(avatars) << "Giving session display name" << sessionDisplayName << "to node with ID" << node->getUUID();
|
||||||
}
|
}
|
||||||
|
if (nodeData && nodeData->getAvatarSkeletonModelUrlMustChange()) { // never true for an empty _avatarWhitelist
|
||||||
|
nodeData->setAvatarSkeletonModelUrlMustChange(false);
|
||||||
|
AvatarData& avatar = nodeData->getAvatar();
|
||||||
|
static const QUrl emptyURL("");
|
||||||
|
QUrl url = avatar.cannonicalSkeletonModelURL(emptyURL);
|
||||||
|
if (!isAvatarInWhitelist(url)) {
|
||||||
|
qCDebug(avatars) << "Forbidden avatar" << nodeData->getNodeID() << avatar.getSkeletonModelURL() << "replaced with" << (_replacementAvatar.isEmpty() ? "default" : _replacementAvatar);
|
||||||
|
avatar.setSkeletonModelURL(_replacementAvatar);
|
||||||
|
sendIdentity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sendIdentity) {
|
||||||
|
sendIdentityPacket(nodeData, node); // Tell node whose name changed about its new session display name or avatar.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AvatarMixer::isAvatarInWhitelist(const QUrl& url) {
|
||||||
|
// The avatar is in the whitelist if:
|
||||||
|
// 1. The avatar's URL's host matches one of the hosts of the URLs in the whitelist AND
|
||||||
|
// 2. The avatar's URL's path starts with the path of that same URL in the whitelist
|
||||||
|
for (const auto& whiteListedPrefix : _avatarWhitelist) {
|
||||||
|
auto whiteListURL = QUrl::fromUserInput(whiteListedPrefix);
|
||||||
|
// check if this script URL matches the whitelist domain and, optionally, is beneath the path
|
||||||
|
if (url.host().compare(whiteListURL.host(), Qt::CaseInsensitive) == 0 &&
|
||||||
|
url.path().startsWith(whiteListURL.path(), Qt::CaseInsensitive)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarMixer::throttle(std::chrono::microseconds duration, int frame) {
|
void AvatarMixer::throttle(std::chrono::microseconds duration, int frame) {
|
||||||
|
@ -520,13 +552,18 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer<ReceivedMessage> mes
|
||||||
// parse the identity packet and update the change timestamp if appropriate
|
// parse the identity packet and update the change timestamp if appropriate
|
||||||
bool identityChanged = false;
|
bool identityChanged = false;
|
||||||
bool displayNameChanged = false;
|
bool displayNameChanged = false;
|
||||||
avatar.processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged);
|
bool skeletonModelUrlChanged = false;
|
||||||
|
avatar.processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged, skeletonModelUrlChanged);
|
||||||
|
|
||||||
if (identityChanged) {
|
if (identityChanged) {
|
||||||
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
||||||
nodeData->flagIdentityChange();
|
nodeData->flagIdentityChange();
|
||||||
if (displayNameChanged) {
|
if (displayNameChanged) {
|
||||||
nodeData->setAvatarSessionDisplayNameMustChange(true);
|
nodeData->setAvatarSessionDisplayNameMustChange(true);
|
||||||
}
|
}
|
||||||
|
if (skeletonModelUrlChanged && !_avatarWhitelist.isEmpty()) {
|
||||||
|
nodeData->setAvatarSkeletonModelUrlMustChange(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -882,4 +919,21 @@ void AvatarMixer::parseDomainServerSettings(const QJsonObject& domainSettings) {
|
||||||
|
|
||||||
qCDebug(avatars) << "This domain requires a minimum avatar scale of" << _domainMinimumScale
|
qCDebug(avatars) << "This domain requires a minimum avatar scale of" << _domainMinimumScale
|
||||||
<< "and a maximum avatar scale of" << _domainMaximumScale;
|
<< "and a maximum avatar scale of" << _domainMaximumScale;
|
||||||
|
|
||||||
|
const QString AVATAR_WHITELIST_DEFAULT{ "" };
|
||||||
|
static const QString AVATAR_WHITELIST_OPTION = "avatar_whitelist";
|
||||||
|
_avatarWhitelist = domainSettings[AVATARS_SETTINGS_KEY].toObject()[AVATAR_WHITELIST_OPTION].toString(AVATAR_WHITELIST_DEFAULT).split(',', QString::KeepEmptyParts);
|
||||||
|
|
||||||
|
static const QString REPLACEMENT_AVATAR_OPTION = "replacement_avatar";
|
||||||
|
_replacementAvatar = domainSettings[AVATARS_SETTINGS_KEY].toObject()[REPLACEMENT_AVATAR_OPTION].toString(REPLACEMENT_AVATAR_DEFAULT);
|
||||||
|
|
||||||
|
if ((_avatarWhitelist.count() == 1) && _avatarWhitelist[0].isEmpty()) {
|
||||||
|
_avatarWhitelist.clear(); // KeepEmptyParts above will parse "," as ["", ""] (which is ok), but "" as [""] (which is not ok).
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_avatarWhitelist.isEmpty()) {
|
||||||
|
qCDebug(avatars) << "All avatars are allowed.";
|
||||||
|
} else {
|
||||||
|
qCDebug(avatars) << "Avatars other than" << _avatarWhitelist << "will be replaced by" << (_replacementAvatar.isEmpty() ? "default" : _replacementAvatar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,12 @@ private:
|
||||||
void parseDomainServerSettings(const QJsonObject& domainSettings);
|
void parseDomainServerSettings(const QJsonObject& domainSettings);
|
||||||
void sendIdentityPacket(AvatarMixerClientData* nodeData, const SharedNodePointer& destinationNode);
|
void sendIdentityPacket(AvatarMixerClientData* nodeData, const SharedNodePointer& destinationNode);
|
||||||
|
|
||||||
void manageDisplayName(const SharedNodePointer& node);
|
void manageIdentityData(const SharedNodePointer& node);
|
||||||
|
bool isAvatarInWhitelist(const QUrl& url);
|
||||||
|
|
||||||
|
const QString REPLACEMENT_AVATAR_DEFAULT{ "" };
|
||||||
|
QStringList _avatarWhitelist { };
|
||||||
|
QString _replacementAvatar { REPLACEMENT_AVATAR_DEFAULT };
|
||||||
|
|
||||||
void optionallyReplicatePacket(ReceivedMessage& message, const Node& node);
|
void optionallyReplicatePacket(ReceivedMessage& message, const Node& node);
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
void flagIdentityChange() { _identityChangeTimestamp = usecTimestampNow(); }
|
void flagIdentityChange() { _identityChangeTimestamp = usecTimestampNow(); }
|
||||||
bool getAvatarSessionDisplayNameMustChange() const { return _avatarSessionDisplayNameMustChange; }
|
bool getAvatarSessionDisplayNameMustChange() const { return _avatarSessionDisplayNameMustChange; }
|
||||||
void setAvatarSessionDisplayNameMustChange(bool set = true) { _avatarSessionDisplayNameMustChange = set; }
|
void setAvatarSessionDisplayNameMustChange(bool set = true) { _avatarSessionDisplayNameMustChange = set; }
|
||||||
|
bool getAvatarSkeletonModelUrlMustChange() const { return _avatarSkeletonModelUrlMustChange; }
|
||||||
|
void setAvatarSkeletonModelUrlMustChange(bool set = true) { _avatarSkeletonModelUrlMustChange = set; }
|
||||||
|
|
||||||
void resetNumAvatarsSentLastFrame() { _numAvatarsSentLastFrame = 0; }
|
void resetNumAvatarsSentLastFrame() { _numAvatarsSentLastFrame = 0; }
|
||||||
void incrementNumAvatarsSentLastFrame() { ++_numAvatarsSentLastFrame; }
|
void incrementNumAvatarsSentLastFrame() { ++_numAvatarsSentLastFrame; }
|
||||||
|
@ -146,6 +148,7 @@ private:
|
||||||
|
|
||||||
uint64_t _identityChangeTimestamp;
|
uint64_t _identityChangeTimestamp;
|
||||||
bool _avatarSessionDisplayNameMustChange{ true };
|
bool _avatarSessionDisplayNameMustChange{ true };
|
||||||
|
bool _avatarSkeletonModelUrlMustChange{ false };
|
||||||
|
|
||||||
int _numAvatarsSentLastFrame = 0;
|
int _numAvatarsSentLastFrame = 0;
|
||||||
int _numFramesSinceAdjustment = 0;
|
int _numFramesSinceAdjustment = 0;
|
||||||
|
|
|
@ -866,6 +866,22 @@
|
||||||
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1000.",
|
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1000.",
|
||||||
"placeholder": 3.0,
|
"placeholder": 3.0,
|
||||||
"default": 3.0
|
"default": 3.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "avatar_whitelist",
|
||||||
|
"label": "Avatars Allowed from:",
|
||||||
|
"help": "Comma separated list of URLs (with optional paths) that avatar .fst files are allowed from. If someone attempts to use an avatar with a different domain, it will be rejected and the replacement avatar will be used. If left blank, any domain is allowed.",
|
||||||
|
"placeholder": "",
|
||||||
|
"default": "",
|
||||||
|
"advanced": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "replacement_avatar",
|
||||||
|
"label": "Replacement Avatar for disallowed avatars",
|
||||||
|
"help": "A URL for an avatar .fst to be used when someone tries to use an avatar that is not allowed. If left blank, the generic default avatar is used.",
|
||||||
|
"placeholder": "",
|
||||||
|
"default": "",
|
||||||
|
"advanced": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1721,6 +1721,10 @@ void Application::cleanupBeforeQuit() {
|
||||||
|
|
||||||
// Cleanup all overlays after the scripts, as scripts might add more
|
// Cleanup all overlays after the scripts, as scripts might add more
|
||||||
_overlays.cleanupAllOverlays();
|
_overlays.cleanupAllOverlays();
|
||||||
|
// The cleanup process enqueues the transactions but does not process them. Calling this here will force the actual
|
||||||
|
// removal of the items.
|
||||||
|
// See https://highfidelity.fogbugz.com/f/cases/5328
|
||||||
|
_main3DScene->processTransactionQueue();
|
||||||
|
|
||||||
// first stop all timers directly or by invokeMethod
|
// first stop all timers directly or by invokeMethod
|
||||||
// depending on what thread they run in
|
// depending on what thread they run in
|
||||||
|
@ -5292,6 +5296,11 @@ void Application::nodeActivated(SharedNodePointer node) {
|
||||||
|
|
||||||
if (node->getType() == NodeType::AvatarMixer) {
|
if (node->getType() == NodeType::AvatarMixer) {
|
||||||
// new avatar mixer, send off our identity packet on next update loop
|
// new avatar mixer, send off our identity packet on next update loop
|
||||||
|
// Reset skeletonModelUrl if the last server modified our choice.
|
||||||
|
static const QUrl empty{};
|
||||||
|
if (getMyAvatar()->getFullAvatarURLFromPreferences() != getMyAvatar()->cannonicalSkeletonModelURL(empty)) {
|
||||||
|
getMyAvatar()->resetFullAvatarURL();
|
||||||
|
}
|
||||||
getMyAvatar()->markIdentityDataChanged();
|
getMyAvatar()->markIdentityDataChanged();
|
||||||
getMyAvatar()->resetLastSent();
|
getMyAvatar()->resetLastSent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1961,6 +1961,32 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
totalBodyYaw += (speedFactor * deltaAngle * (180.0f / PI));
|
totalBodyYaw += (speedFactor * deltaAngle * (180.0f / PI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use head/HMD roll to turn while walking or flying.
|
||||||
|
if (qApp->isHMDMode() && _hmdRollControlEnabled) {
|
||||||
|
// Turn with head roll.
|
||||||
|
const float MIN_CONTROL_SPEED = 0.01f;
|
||||||
|
float speed = glm::length(getVelocity());
|
||||||
|
if (speed >= MIN_CONTROL_SPEED) {
|
||||||
|
// Feather turn when stopping moving.
|
||||||
|
float speedFactor;
|
||||||
|
if (getDriveKey(TRANSLATE_Z) != 0.0f || _lastDrivenSpeed == 0.0f) {
|
||||||
|
_lastDrivenSpeed = speed;
|
||||||
|
speedFactor = 1.0f;
|
||||||
|
} else {
|
||||||
|
speedFactor = glm::min(speed / _lastDrivenSpeed, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float direction = glm::dot(getVelocity(), getRotation() * Vectors::UNIT_NEG_Z) > 0.0f ? 1.0f : -1.0f;
|
||||||
|
|
||||||
|
float rollAngle = glm::degrees(asinf(glm::dot(IDENTITY_UP, _hmdSensorOrientation * IDENTITY_RIGHT)));
|
||||||
|
float rollSign = rollAngle < 0.0f ? -1.0f : 1.0f;
|
||||||
|
rollAngle = fabsf(rollAngle);
|
||||||
|
rollAngle = rollAngle > _hmdRollControlDeadZone ? rollSign * (rollAngle - _hmdRollControlDeadZone) : 0.0f;
|
||||||
|
|
||||||
|
totalBodyYaw += speedFactor * direction * rollAngle * deltaTime * _hmdRollControlRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update body orientation by movement inputs
|
// update body orientation by movement inputs
|
||||||
glm::quat initialOrientation = getOrientationOutbound();
|
glm::quat initialOrientation = getOrientationOutbound();
|
||||||
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||||
|
|
|
@ -132,6 +132,10 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
||||||
Q_PROPERTY(bool useAdvancedMovementControls READ useAdvancedMovementControls WRITE setUseAdvancedMovementControls)
|
Q_PROPERTY(bool useAdvancedMovementControls READ useAdvancedMovementControls WRITE setUseAdvancedMovementControls)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool hmdRollControlEnabled READ getHMDRollControlEnabled WRITE setHMDRollControlEnabled)
|
||||||
|
Q_PROPERTY(float hmdRollControlDeadZone READ getHMDRollControlDeadZone WRITE setHMDRollControlDeadZone)
|
||||||
|
Q_PROPERTY(float hmdRollControlRate READ getHMDRollControlRate WRITE setHMDRollControlRate)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum DriveKeys {
|
enum DriveKeys {
|
||||||
TRANSLATE_X = 0,
|
TRANSLATE_X = 0,
|
||||||
|
@ -337,6 +341,13 @@ public:
|
||||||
void setUseAdvancedMovementControls(bool useAdvancedMovementControls)
|
void setUseAdvancedMovementControls(bool useAdvancedMovementControls)
|
||||||
{ _useAdvancedMovementControls.set(useAdvancedMovementControls); }
|
{ _useAdvancedMovementControls.set(useAdvancedMovementControls); }
|
||||||
|
|
||||||
|
void setHMDRollControlEnabled(bool value) { _hmdRollControlEnabled = value; }
|
||||||
|
bool getHMDRollControlEnabled() const { return _hmdRollControlEnabled; }
|
||||||
|
void setHMDRollControlDeadZone(float value) { _hmdRollControlDeadZone = value; }
|
||||||
|
float getHMDRollControlDeadZone() const { return _hmdRollControlDeadZone; }
|
||||||
|
void setHMDRollControlRate(float value) { _hmdRollControlRate = value; }
|
||||||
|
float getHMDRollControlRate() const { return _hmdRollControlRate; }
|
||||||
|
|
||||||
// get/set avatar data
|
// get/set avatar data
|
||||||
void saveData();
|
void saveData();
|
||||||
void loadData();
|
void loadData();
|
||||||
|
@ -687,6 +698,13 @@ private:
|
||||||
bool _useSnapTurn { true };
|
bool _useSnapTurn { true };
|
||||||
bool _clearOverlayWhenMoving { true };
|
bool _clearOverlayWhenMoving { true };
|
||||||
|
|
||||||
|
const float ROLL_CONTROL_DEAD_ZONE_DEFAULT = 8.0f; // deg
|
||||||
|
const float ROLL_CONTROL_RATE_DEFAULT = 2.5f; // deg/sec/deg
|
||||||
|
bool _hmdRollControlEnabled { true };
|
||||||
|
float _hmdRollControlDeadZone { ROLL_CONTROL_DEAD_ZONE_DEFAULT };
|
||||||
|
float _hmdRollControlRate { ROLL_CONTROL_RATE_DEFAULT };
|
||||||
|
float _lastDrivenSpeed { 0.0f };
|
||||||
|
|
||||||
// working copies -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
// working copies -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
||||||
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
||||||
|
|
||||||
|
|
|
@ -48,15 +48,31 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod
|
||||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||||
const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString();
|
const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString();
|
||||||
if (inDevice != _currentInputDevice) {
|
if (inDevice != _currentInputDevice) {
|
||||||
|
// before using the old setting, check to make sure the device still exists....
|
||||||
|
bool inDeviceExists = DependencyManager::get<AudioClient>()->getNamedAudioDeviceForModeExists(QAudio::AudioInput, inDevice);
|
||||||
|
|
||||||
|
if (inDeviceExists) {
|
||||||
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
|
||||||
setInputDeviceAsync(inDevice);
|
setInputDeviceAsync(inDevice);
|
||||||
|
} else {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "previously selected device no longer exists inDevice: [" << inDevice << "] keeping device _currentInputDevice:" << _currentInputDevice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the audio_output_device setting is not available, use the _currentOutputDevice
|
// If the audio_output_device setting is not available, use the _currentOutputDevice
|
||||||
auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString();
|
auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString();
|
||||||
|
|
||||||
if (outDevice != _currentOutputDevice) {
|
if (outDevice != _currentOutputDevice) {
|
||||||
|
// before using the old setting, check to make sure the device still exists....
|
||||||
|
bool outDeviceExists = DependencyManager::get<AudioClient>()->getNamedAudioDeviceForModeExists(QAudio::AudioOutput, outDevice);
|
||||||
|
|
||||||
|
if (outDeviceExists) {
|
||||||
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
|
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
|
||||||
setOutputDeviceAsync(outDevice);
|
setOutputDeviceAsync(outDevice);
|
||||||
|
} else {
|
||||||
|
qCDebug(audioclient) << __FUNCTION__ << "previously selected device no longer exists outDevice: [" << outDevice << "] keeping device _currentOutputDevice:" << _currentOutputDevice;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1164,9 +1164,32 @@ void Rig::updateFromHandAndFeetParameters(const HandAndFeetParameters& params, f
|
||||||
bool bodySensorTrackingEnabled = params.isLeftFootEnabled || params.isRightFootEnabled;
|
bool bodySensorTrackingEnabled = params.isLeftFootEnabled || params.isRightFootEnabled;
|
||||||
|
|
||||||
const float RELAX_DURATION = 0.6f;
|
const float RELAX_DURATION = 0.6f;
|
||||||
|
const float CONTROL_DURATION = 0.4f;
|
||||||
|
const bool TO_CONTROLLED = true;
|
||||||
|
const bool FROM_CONTROLLED = false;
|
||||||
|
const bool LEFT_HAND = true;
|
||||||
|
const bool RIGHT_HAND = false;
|
||||||
|
|
||||||
if (params.isLeftEnabled) {
|
if (params.isLeftEnabled) {
|
||||||
|
if (!_isLeftHandControlled) {
|
||||||
|
_leftHandControlTimeRemaining = CONTROL_DURATION;
|
||||||
|
_isLeftHandControlled = true;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 handPosition = params.leftPosition;
|
glm::vec3 handPosition = params.leftPosition;
|
||||||
|
glm::quat handRotation = params.leftOrientation;
|
||||||
|
|
||||||
|
if (_leftHandControlTimeRemaining > 0.0f) {
|
||||||
|
// Move hand from non-controlled position to controlled position.
|
||||||
|
_leftHandControlTimeRemaining = std::max(_leftHandControlTimeRemaining - dt, 0.0f);
|
||||||
|
AnimPose handPose(Vectors::ONE, handRotation, handPosition);
|
||||||
|
if (transitionHandPose(_leftHandControlTimeRemaining, CONTROL_DURATION, handPose, LEFT_HAND, TO_CONTROLLED,
|
||||||
|
handPose)) {
|
||||||
|
handPosition = handPose.trans();
|
||||||
|
handRotation = handPose.rot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bodySensorTrackingEnabled) {
|
if (!bodySensorTrackingEnabled) {
|
||||||
// prevent the hand IK targets from intersecting the body capsule
|
// prevent the hand IK targets from intersecting the body capsule
|
||||||
glm::vec3 displacement;
|
glm::vec3 displacement;
|
||||||
|
@ -1176,27 +1199,22 @@ void Rig::updateFromHandAndFeetParameters(const HandAndFeetParameters& params, f
|
||||||
}
|
}
|
||||||
|
|
||||||
_animVars.set("leftHandPosition", handPosition);
|
_animVars.set("leftHandPosition", handPosition);
|
||||||
_animVars.set("leftHandRotation", params.leftOrientation);
|
_animVars.set("leftHandRotation", handRotation);
|
||||||
_animVars.set("leftHandType", (int)IKTarget::Type::RotationAndPosition);
|
_animVars.set("leftHandType", (int)IKTarget::Type::RotationAndPosition);
|
||||||
|
|
||||||
_isLeftHandControlled = true;
|
_lastLeftHandControlledPose = AnimPose(Vectors::ONE, handRotation, handPosition);
|
||||||
_lastLeftHandControlledPose = AnimPose(glm::vec3(1.0f), params.leftOrientation, handPosition);
|
|
||||||
} else {
|
} else {
|
||||||
if (_isLeftHandControlled) {
|
if (_isLeftHandControlled) {
|
||||||
_leftHandRelaxDuration = RELAX_DURATION;
|
_leftHandRelaxTimeRemaining = RELAX_DURATION;
|
||||||
_isLeftHandControlled = false;
|
_isLeftHandControlled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_leftHandRelaxDuration > 0) {
|
if (_leftHandRelaxTimeRemaining > 0.0f) {
|
||||||
// Move hand from controlled position to non-controlled position.
|
// Move hand from controlled position to non-controlled position.
|
||||||
_leftHandRelaxDuration = std::max(_leftHandRelaxDuration - dt, 0.0f);
|
_leftHandRelaxTimeRemaining = std::max(_leftHandRelaxTimeRemaining - dt, 0.0f);
|
||||||
auto ikNode = getAnimInverseKinematicsNode();
|
|
||||||
if (ikNode) {
|
|
||||||
float alpha = 1.0f - _leftHandRelaxDuration / RELAX_DURATION;
|
|
||||||
const AnimPose geometryToRigTransform(_geometryToRigTransform);
|
|
||||||
AnimPose uncontrolledHandPose = geometryToRigTransform * ikNode->getUncontrolledLeftHandPose();
|
|
||||||
AnimPose handPose;
|
AnimPose handPose;
|
||||||
::blend(1, &_lastLeftHandControlledPose, &uncontrolledHandPose, alpha, &handPose);
|
if (transitionHandPose(_leftHandRelaxTimeRemaining, RELAX_DURATION, _lastLeftHandControlledPose, LEFT_HAND,
|
||||||
|
FROM_CONTROLLED, handPose)) {
|
||||||
_animVars.set("leftHandPosition", handPose.trans());
|
_animVars.set("leftHandPosition", handPose.trans());
|
||||||
_animVars.set("leftHandRotation", handPose.rot());
|
_animVars.set("leftHandRotation", handPose.rot());
|
||||||
_animVars.set("leftHandType", (int)IKTarget::Type::RotationAndPosition);
|
_animVars.set("leftHandType", (int)IKTarget::Type::RotationAndPosition);
|
||||||
|
@ -1209,7 +1227,25 @@ void Rig::updateFromHandAndFeetParameters(const HandAndFeetParameters& params, f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.isRightEnabled) {
|
if (params.isRightEnabled) {
|
||||||
|
if (!_isRightHandControlled) {
|
||||||
|
_rightHandControlTimeRemaining = CONTROL_DURATION;
|
||||||
|
_isRightHandControlled = true;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 handPosition = params.rightPosition;
|
glm::vec3 handPosition = params.rightPosition;
|
||||||
|
glm::quat handRotation = params.rightOrientation;
|
||||||
|
|
||||||
|
if (_rightHandControlTimeRemaining > 0.0f) {
|
||||||
|
// Move hand from non-controlled position to controlled position.
|
||||||
|
_rightHandControlTimeRemaining = std::max(_rightHandControlTimeRemaining - dt, 0.0f);
|
||||||
|
AnimPose handPose(Vectors::ONE, handRotation, handPosition);
|
||||||
|
if (transitionHandPose(_rightHandControlTimeRemaining, CONTROL_DURATION, handPose, RIGHT_HAND, TO_CONTROLLED,
|
||||||
|
handPose)) {
|
||||||
|
handPosition = handPose.trans();
|
||||||
|
handRotation = handPose.rot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bodySensorTrackingEnabled) {
|
if (!bodySensorTrackingEnabled) {
|
||||||
// prevent the hand IK targets from intersecting the body capsule
|
// prevent the hand IK targets from intersecting the body capsule
|
||||||
glm::vec3 displacement;
|
glm::vec3 displacement;
|
||||||
|
@ -1219,27 +1255,22 @@ void Rig::updateFromHandAndFeetParameters(const HandAndFeetParameters& params, f
|
||||||
}
|
}
|
||||||
|
|
||||||
_animVars.set("rightHandPosition", handPosition);
|
_animVars.set("rightHandPosition", handPosition);
|
||||||
_animVars.set("rightHandRotation", params.rightOrientation);
|
_animVars.set("rightHandRotation", handRotation);
|
||||||
_animVars.set("rightHandType", (int)IKTarget::Type::RotationAndPosition);
|
_animVars.set("rightHandType", (int)IKTarget::Type::RotationAndPosition);
|
||||||
|
|
||||||
_isRightHandControlled = true;
|
_lastRightHandControlledPose = AnimPose(Vectors::ONE, handRotation, handPosition);
|
||||||
_lastRightHandControlledPose = AnimPose(glm::vec3(1.0f), params.rightOrientation, handPosition);
|
|
||||||
} else {
|
} else {
|
||||||
if (_isRightHandControlled) {
|
if (_isRightHandControlled) {
|
||||||
_rightHandRelaxDuration = RELAX_DURATION;
|
_rightHandRelaxTimeRemaining = RELAX_DURATION;
|
||||||
_isRightHandControlled = false;
|
_isRightHandControlled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rightHandRelaxDuration > 0) {
|
if (_rightHandRelaxTimeRemaining > 0.0f) {
|
||||||
// Move hand from controlled position to non-controlled position.
|
// Move hand from controlled position to non-controlled position.
|
||||||
_rightHandRelaxDuration = std::max(_rightHandRelaxDuration - dt, 0.0f);
|
_rightHandRelaxTimeRemaining = std::max(_rightHandRelaxTimeRemaining - dt, 0.0f);
|
||||||
auto ikNode = getAnimInverseKinematicsNode();
|
|
||||||
if (ikNode) {
|
|
||||||
float alpha = 1.0f - _rightHandRelaxDuration / RELAX_DURATION;
|
|
||||||
const AnimPose geometryToRigTransform(_geometryToRigTransform);
|
|
||||||
AnimPose uncontrolledHandPose = geometryToRigTransform * ikNode->getUncontrolledRightHandPose();
|
|
||||||
AnimPose handPose;
|
AnimPose handPose;
|
||||||
::blend(1, &_lastRightHandControlledPose, &uncontrolledHandPose, alpha, &handPose);
|
if (transitionHandPose(_rightHandRelaxTimeRemaining, RELAX_DURATION, _lastRightHandControlledPose, RIGHT_HAND,
|
||||||
|
FROM_CONTROLLED, handPose)) {
|
||||||
_animVars.set("rightHandPosition", handPose.trans());
|
_animVars.set("rightHandPosition", handPose.trans());
|
||||||
_animVars.set("rightHandRotation", handPose.rot());
|
_animVars.set("rightHandRotation", handPose.rot());
|
||||||
_animVars.set("rightHandType", (int)IKTarget::Type::RotationAndPosition);
|
_animVars.set("rightHandType", (int)IKTarget::Type::RotationAndPosition);
|
||||||
|
@ -1545,3 +1576,25 @@ void Rig::computeAvatarBoundingCapsule(
|
||||||
glm::vec3 rigCenter = (geometryToRig * (0.5f * (totalExtents.maximum + totalExtents.minimum)));
|
glm::vec3 rigCenter = (geometryToRig * (0.5f * (totalExtents.maximum + totalExtents.minimum)));
|
||||||
localOffsetOut = rigCenter - (geometryToRig * rootPosition);
|
localOffsetOut = rigCenter - (geometryToRig * rootPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Rig::transitionHandPose(float deltaTime, float totalDuration, AnimPose& controlledHandPose, bool isLeftHand,
|
||||||
|
bool isToControlled, AnimPose& returnHandPose) {
|
||||||
|
auto ikNode = getAnimInverseKinematicsNode();
|
||||||
|
if (ikNode) {
|
||||||
|
float alpha = 1.0f - deltaTime / totalDuration;
|
||||||
|
const AnimPose geometryToRigTransform(_geometryToRigTransform);
|
||||||
|
AnimPose uncontrolledHandPose;
|
||||||
|
if (isLeftHand) {
|
||||||
|
uncontrolledHandPose = geometryToRigTransform * ikNode->getUncontrolledLeftHandPose();
|
||||||
|
} else {
|
||||||
|
uncontrolledHandPose = geometryToRigTransform * ikNode->getUncontrolledRightHandPose();
|
||||||
|
}
|
||||||
|
if (isToControlled) {
|
||||||
|
::blend(1, &uncontrolledHandPose, &controlledHandPose, alpha, &returnHandPose);
|
||||||
|
} else {
|
||||||
|
::blend(1, &controlledHandPose, &uncontrolledHandPose, alpha, &returnHandPose);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -352,10 +352,15 @@ private:
|
||||||
int _nextStateHandlerId { 0 };
|
int _nextStateHandlerId { 0 };
|
||||||
QMutex _stateMutex;
|
QMutex _stateMutex;
|
||||||
|
|
||||||
|
bool transitionHandPose(float deltaTime, float totalDuration, AnimPose& controlledHandPose, bool isLeftHand,
|
||||||
|
bool isToControlled, AnimPose& returnHandPose);
|
||||||
|
|
||||||
bool _isLeftHandControlled { false };
|
bool _isLeftHandControlled { false };
|
||||||
bool _isRightHandControlled { false };
|
bool _isRightHandControlled { false };
|
||||||
float _leftHandRelaxDuration { 0.0f };
|
float _leftHandControlTimeRemaining { 0.0f };
|
||||||
float _rightHandRelaxDuration { 0.0f };
|
float _rightHandControlTimeRemaining { 0.0f };
|
||||||
|
float _leftHandRelaxTimeRemaining { 0.0f };
|
||||||
|
float _rightHandRelaxTimeRemaining { 0.0f };
|
||||||
AnimPose _lastLeftHandControlledPose;
|
AnimPose _lastLeftHandControlledPose;
|
||||||
AnimPose _lastRightHandControlledPose;
|
AnimPose _lastRightHandControlledPose;
|
||||||
};
|
};
|
||||||
|
|
|
@ -395,6 +395,11 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
||||||
return (mode == QAudio::AudioInput) ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
return (mode == QAudio::AudioInput) ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioClient::getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName) {
|
||||||
|
return (getNamedAudioDeviceForMode(mode, deviceName).deviceName() == deviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// attempt to use the native sample rate and channel count
|
// attempt to use the native sample rate and channel count
|
||||||
bool nativeFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
bool nativeFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
||||||
QAudioFormat& audioFormat) {
|
QAudioFormat& audioFormat) {
|
||||||
|
|
|
@ -149,6 +149,8 @@ public:
|
||||||
|
|
||||||
static const float CALLBACK_ACCELERATOR_RATIO;
|
static const float CALLBACK_ACCELERATOR_RATIO;
|
||||||
|
|
||||||
|
bool getNamedAudioDeviceForModeExists(QAudio::Mode mode, const QString& deviceName);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static QString friendlyNameForAudioDevice(wchar_t* guid);
|
static QString friendlyNameForAudioDevice(wchar_t* guid);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1483,7 +1483,8 @@ QUrl AvatarData::cannonicalSkeletonModelURL(const QUrl& emptyURL) const {
|
||||||
return _skeletonModelURL.scheme() == "file" ? emptyURL : _skeletonModelURL;
|
return _skeletonModelURL.scheme() == "file" ? emptyURL : _skeletonModelURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::processAvatarIdentity(const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged) {
|
void AvatarData::processAvatarIdentity(const QByteArray& identityData, bool& identityChanged,
|
||||||
|
bool& displayNameChanged, bool& skeletonModelUrlChanged) {
|
||||||
|
|
||||||
QDataStream packetStream(identityData);
|
QDataStream packetStream(identityData);
|
||||||
|
|
||||||
|
@ -1516,6 +1517,7 @@ void AvatarData::processAvatarIdentity(const QByteArray& identityData, bool& ide
|
||||||
if (_firstSkeletonCheck || (identity.skeletonModelURL != cannonicalSkeletonModelURL(emptyURL))) {
|
if (_firstSkeletonCheck || (identity.skeletonModelURL != cannonicalSkeletonModelURL(emptyURL))) {
|
||||||
setSkeletonModelURL(identity.skeletonModelURL);
|
setSkeletonModelURL(identity.skeletonModelURL);
|
||||||
identityChanged = true;
|
identityChanged = true;
|
||||||
|
skeletonModelUrlChanged = true;
|
||||||
if (_firstSkeletonCheck) {
|
if (_firstSkeletonCheck) {
|
||||||
displayNameChanged = true;
|
displayNameChanged = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,6 +369,7 @@ public:
|
||||||
virtual ~AvatarData();
|
virtual ~AvatarData();
|
||||||
|
|
||||||
static const QUrl& defaultFullAvatarModelUrl();
|
static const QUrl& defaultFullAvatarModelUrl();
|
||||||
|
QUrl cannonicalSkeletonModelURL(const QUrl& empty) const;
|
||||||
|
|
||||||
virtual bool isMyAvatar() const { return false; }
|
virtual bool isMyAvatar() const { return false; }
|
||||||
|
|
||||||
|
@ -534,8 +535,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// identityChanged returns true if identity has changed, false otherwise.
|
// identityChanged returns true if identity has changed, false otherwise.
|
||||||
// displayNameChanged returns true if displayName has changed, false otherwise.
|
// identityChanged returns true if identity has changed, false otherwise. Similarly for displayNameChanged and skeletonModelUrlChange.
|
||||||
void processAvatarIdentity(const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged);
|
void processAvatarIdentity(const QByteArray& identityData, bool& identityChanged,
|
||||||
|
bool& displayNameChanged, bool& skeletonModelUrlChanged);
|
||||||
|
|
||||||
QByteArray identityByteArray(bool shouldForwardIncomingSequenceNumber = false) const;
|
QByteArray identityByteArray(bool shouldForwardIncomingSequenceNumber = false) const;
|
||||||
|
|
||||||
|
@ -691,7 +693,6 @@ protected:
|
||||||
QVector<AttachmentData> _attachmentData;
|
QVector<AttachmentData> _attachmentData;
|
||||||
QString _displayName;
|
QString _displayName;
|
||||||
QString _sessionDisplayName { };
|
QString _sessionDisplayName { };
|
||||||
QUrl cannonicalSkeletonModelURL(const QUrl& empty) const;
|
|
||||||
|
|
||||||
QHash<QString, int> _jointIndices; ///< 1-based, since zero is returned for missing keys
|
QHash<QString, int> _jointIndices; ///< 1-based, since zero is returned for missing keys
|
||||||
QStringList _jointNames; ///< in order of depth-first traversal
|
QStringList _jointNames; ///< in order of depth-first traversal
|
||||||
|
|
|
@ -155,8 +155,9 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage>
|
||||||
auto avatar = newOrExistingAvatar(identityUUID, sendingNode);
|
auto avatar = newOrExistingAvatar(identityUUID, sendingNode);
|
||||||
bool identityChanged = false;
|
bool identityChanged = false;
|
||||||
bool displayNameChanged = false;
|
bool displayNameChanged = false;
|
||||||
|
bool skeletonModelUrlChanged = false;
|
||||||
// In this case, the "sendingNode" is the Avatar Mixer.
|
// In this case, the "sendingNode" is the Avatar Mixer.
|
||||||
avatar->processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged);
|
avatar->processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged, skeletonModelUrlChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ var DEFAULT_SCRIPTS_COMBINED = [
|
||||||
];
|
];
|
||||||
var DEFAULT_SCRIPTS_SEPARATE = [
|
var DEFAULT_SCRIPTS_SEPARATE = [
|
||||||
"system/controllers/controllerScripts.js",
|
"system/controllers/controllerScripts.js",
|
||||||
"system/chat.js"
|
// "system/chat.js"
|
||||||
];
|
];
|
||||||
|
|
||||||
// add a menu item for debugging
|
// add a menu item for debugging
|
||||||
|
|
17
scripts/developer/hmdRollControlDisable.js
Normal file
17
scripts/developer/hmdRollControlDisable.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// hmdRollControlDisable.js
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 4 Jun 2017.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var hmdRollControlEnabled = false;
|
||||||
|
|
||||||
|
//print("HMD roll control: " + hmdRollControlEnabled);
|
||||||
|
|
||||||
|
MyAvatar.hmdRollControlEnabled = hmdRollControlEnabled;
|
||||||
|
|
||||||
|
Script.stop();
|
21
scripts/developer/hmdRollControlEnable.js
Normal file
21
scripts/developer/hmdRollControlEnable.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// hmdRollControlEnable.js
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 4 Jun 2017.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var hmdRollControlEnabled = true;
|
||||||
|
var hmdRollControlDeadZone = 8.0; // deg
|
||||||
|
var hmdRollControlRate = 2.5; // deg/sec/deg
|
||||||
|
|
||||||
|
//print("HMD roll control: " + hmdRollControlEnabled + ", " + hmdRollControlDeadZone + ", " + hmdRollControlRate);
|
||||||
|
|
||||||
|
MyAvatar.hmdRollControlEnabled = hmdRollControlEnabled;
|
||||||
|
MyAvatar.hmdRollControlDeadZone = hmdRollControlDeadZone;
|
||||||
|
MyAvatar.hmdRollControlRate = hmdRollControlRate;
|
||||||
|
|
||||||
|
Script.stop();
|
|
@ -101,6 +101,10 @@ function getApplicationDataDirectory() {
|
||||||
return path.join(getRootHifiDataDirectory(), '/Server Console');
|
return path.join(getRootHifiDataDirectory(), '/Server Console');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update lock filepath
|
||||||
|
const UPDATER_LOCK_FILENAME = ".updating";
|
||||||
|
const UPDATER_LOCK_FULL_PATH = getRootHifiDataDirectory() + "/" + UPDATER_LOCK_FILENAME;
|
||||||
|
|
||||||
// Configure log
|
// Configure log
|
||||||
global.log = require('electron-log');
|
global.log = require('electron-log');
|
||||||
const logFile = getApplicationDataDirectory() + '/log.txt';
|
const logFile = getApplicationDataDirectory() + '/log.txt';
|
||||||
|
@ -630,11 +634,22 @@ function checkNewContent() {
|
||||||
userConfig.save(configPath);
|
userConfig.save(configPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (fs.existsSync(UPDATER_LOCK_FULL_PATH)) {
|
||||||
|
backupResourceDirectoriesAndRestart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory) {
|
||||||
|
if (fs.existsSync(UPDATER_LOCK_FULL_PATH)) {
|
||||||
|
log.debug('Removing incomplete content update files before copying new update');
|
||||||
|
fs.emptyDirSync(dsResourceDirectory);
|
||||||
|
fs.emptyDirSync(acResourceDirectory);
|
||||||
|
} else {
|
||||||
|
fs.ensureFileSync(UPDATER_LOCK_FULL_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function maybeInstallDefaultContentSet(onComplete) {
|
function maybeInstallDefaultContentSet(onComplete) {
|
||||||
// Check for existing data
|
// Check for existing data
|
||||||
|
@ -673,7 +688,11 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Found contentPath:" + argv.contentPath);
|
log.debug("Found contentPath:" + argv.contentPath);
|
||||||
|
|
||||||
if (argv.contentPath) {
|
if (argv.contentPath) {
|
||||||
|
// check if we're updating a data folder whose update is incomplete
|
||||||
|
removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory);
|
||||||
|
|
||||||
fs.copy(argv.contentPath, getRootHifiDataDirectory(), function (err) {
|
fs.copy(argv.contentPath, getRootHifiDataDirectory(), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.debug('Could not copy home content: ' + err);
|
log.debug('Could not copy home content: ' + err);
|
||||||
|
@ -682,12 +701,12 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
log.debug('Copied home content over to: ' + getRootHifiDataDirectory());
|
log.debug('Copied home content over to: ' + getRootHifiDataDirectory());
|
||||||
userConfig.set('homeContentLastModified', new Date());
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
userConfig.save(configPath);
|
userConfig.save(configPath);
|
||||||
|
fs.removeSync(UPDATER_LOCK_FULL_PATH);
|
||||||
onComplete();
|
onComplete();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Show popup
|
// Show popup
|
||||||
var window = new BrowserWindow({
|
var window = new BrowserWindow({
|
||||||
icon: appIcon,
|
icon: appIcon,
|
||||||
|
@ -718,6 +737,9 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
|
|
||||||
var aborted = false;
|
var aborted = false;
|
||||||
|
|
||||||
|
// check if we're updating a data folder whose update is incomplete
|
||||||
|
removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory);
|
||||||
|
|
||||||
// Start downloading content set
|
// Start downloading content set
|
||||||
var req = progress(request.get({
|
var req = progress(request.get({
|
||||||
url: HOME_CONTENT_URL
|
url: HOME_CONTENT_URL
|
||||||
|
@ -763,6 +785,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
log.debug("Finished unarchiving home content set");
|
log.debug("Finished unarchiving home content set");
|
||||||
userConfig.set('homeContentLastModified', new Date());
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
userConfig.save(configPath);
|
userConfig.save(configPath);
|
||||||
|
fs.removeSync(UPDATER_LOCK_FULL_PATH);
|
||||||
sendStateUpdate('complete');
|
sendStateUpdate('complete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue