From 15d804168328101fef9e703ee7656284f7111ee0 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 21 Feb 2017 13:14:45 -0800 Subject: [PATCH 01/10] snapshot working, before button change --- interface/resources/qml/hifi/Pal.qml | 30 ++++++++- interface/src/Camera.cpp | 2 + interface/src/avatar/AvatarManager.cpp | 2 +- libraries/avatars/src/AvatarHashMap.cpp | 2 +- .../src/UsersScriptingInterface.h | 1 - scripts/system/pal.js | 63 +++++++++++++++++-- 6 files changed, 89 insertions(+), 11 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index c1fea7c09b..a13e31418a 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -308,6 +308,7 @@ Rectangle { } // Refresh button Rectangle { + id: reload // Size width: hifi.dimensions.tableHeaderHeight-1 height: hifi.dimensions.tableHeaderHeight-1 @@ -338,13 +339,38 @@ Rectangle { // So use onPressed instead of onClicked onPressed: { reloadButton.color = hifi.colors.lightGrayText - pal.sendToScript({method: 'refresh'}) + pal.sendToScript({method: 'refresh', params: {filter: false}}) // fixme re filter } onReleased: reloadButton.color = (containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.darkGray) onEntered: reloadButton.color = hifi.colors.baseGrayHighlight onExited: reloadButton.color = (pressed ? hifi.colors.lightGrayText: hifi.colors.darkGray) } } + HiFiGlyphs { + id: filter + width: hifi.dimensions.tableHeaderHeight - 1 + height: filter.width + text: "\ue007" + size: filter.width + color: hifi.colors.darkGray + anchors { + left: reload.right + leftMargin: 4 + top: reload.top + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onPressed: { + filter.color = hifi.colors.lightGrayText + pal.sendToScript({method: 'refresh', params: {filter: {distance: 30}}}) + } + onReleased: filter.color = (containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.darkGray) + onEntered: filter.color = hifi.colors.baseGrayHighlight + onExited: filter.color = (pressed ? hifi.colors.lightGrayText : hifi.colors.darkGray) + } + } + // Separator between user and admin functions Rectangle { // Size @@ -501,7 +527,7 @@ Rectangle { if (alreadyRefreshed === true) { letterbox('', '', 'The last editor of this object is either you or not among this list of users.'); } else { - pal.sendToScript({method: 'refresh', params: message.params}); + pal.sendToScript({method: 'refresh', params: {selected: message.params}}); } } else { // If we've already refreshed the PAL and found the avatar in the model diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index f930424569..cf3261ee88 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -192,6 +192,8 @@ QVariantMap Camera::getViewFrustum() { result["orientation"].setValue(frustum.getOrientation()); result["projection"].setValue(frustum.getProjection()); result["centerRadius"].setValue(frustum.getCenterRadius()); + result["fieldOfView"].setValue(frustum.getFieldOfView()); + result["aspectRatio"].setValue(frustum.getAspectRatio()); return result; } diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index c3fc974365..0e06c4a238 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -85,7 +85,7 @@ AvatarManager::AvatarManager(QObject* parent) : // immediately remove that avatar instead of waiting for the absence of packets from avatar mixer connect(nodeList.data(), &NodeList::ignoredNode, this, [=](const QUuid& nodeID, bool enabled) { if (enabled) { - removeAvatar(nodeID); + removeAvatar(nodeID, KillAvatarReason::AvatarIgnored); } }); } diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 00c515a635..0652bf6ca3 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -182,7 +182,7 @@ void AvatarHashMap::removeAvatar(const QUuid& sessionUUID, KillAvatarReason remo void AvatarHashMap::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) { qCDebug(avatars) << "Removed avatar with UUID" << uuidStringWithoutCurlyBraces(removedAvatar->getSessionUUID()) - << "from AvatarHashMap"; + << "from AvatarHashMap" << removalReason; emit avatarRemovedEvent(removedAvatar->getSessionUUID()); } diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 76b98c6217..608fa937c8 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -150,7 +150,6 @@ signals: private: bool getRequestsDomainListData(); void setRequestsDomainListData(bool requests); - bool _requestsDomainListData; }; diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 57648da79a..9c0bc1f513 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -33,6 +33,15 @@ var conserveResources = true; Script.include("/~/system/libraries/controllers.js"); +function projectVectorOntoPlane(normalizedVector, planeNormal) { + return Vec3.cross(planeNormal, Vec3.cross(normalizedVector, planeNormal)); +} +function angleBetweenVectorsInPlane(from, to, normal) { + var projectedFrom = projectVectorOntoPlane(from, normal); + var projectedTo = projectVectorOntoPlane(to, normal); + return Vec3.orientedAngle(projectedFrom, projectedTo, normal); +} + // // Overlays. // @@ -234,7 +243,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'refresh': removeOverlays(); - populateUserList(message.params); + populateUserList(message.params.selected, message.params.filter); UserActivityLogger.palAction("refresh", ""); break; case 'updateGain': @@ -280,13 +289,48 @@ function addAvatarNode(id) { color: color(selected, false, 0.0), ignoreRayIntersection: false}, selected, !conserveResources); } -function populateUserList(selectData) { +var filter = false; +// Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter. +var avatarsOfInterest = {}; +function populateUserList(selectData, filterRequest) { + if (filterRequest !== undefined) { + filter = filterRequest; + } var data = [], avatars = AvatarList.getAvatarIdentifiers(); - conserveResources = avatars.length > 20; + avatarsOfInterest = {}; + var myPosition = filter && Camera.position, + frustum = filter && Camera.frustum, + verticalHalfAngle = filter && (frustum.fieldOfView / 2), + horizontalHalfAngle = filter && (verticalHalfAngle * frustum.aspectRatio), + orientation = filter && Camera.orientation, + front = filter && Quat.getFront(orientation), + verticalAngleNormal = filter && Quat.getRight(orientation), + horizontalAngleNormal = filter && Quat.getUp(orientation); + print('fixme h/v...myPosition', horizontalHalfAngle, verticalHalfAngle, JSON.stringify(horizontalAngleNormal), JSON.stringify(verticalAngleNormal), JSON.stringify(myPosition)); avatars.forEach(function (id) { // sorting the identifiers is just an aid for debugging var avatar = AvatarList.getAvatar(id); + var name = avatar.sessionDisplayName; + if (!name) { + // Either we got a data packet but no identity yet, or something is really messed up. In any case, + // we won't be able to do anything with this user, so don't include them. + // In normal circumstances, a refresh will bring in the new user, but if we're very heavily loaded, + // we could be losing and gaining people randomly. + print('No avatar identity data for', id); + return; + } + if (id && myPosition && (Vec3.distance(avatar.position, myPosition) > filter.distance)) { + return; + } + var normal = id && filter && Vec3.normalize(Vec3.subtract(avatar.position, myPosition)); + var horizontal = normal && angleBetweenVectorsInPlane(normal, front, horizontalAngleNormal); + var vertical = normal && angleBetweenVectorsInPlane(normal, front, verticalAngleNormal); + print('fixme id/h/v/pos/norm', id, horizontal, vertical, JSON.stringify(avatar.position), JSON.stringify(normal)); + if (id && filter && ((Math.abs(horizontal) > horizontalHalfAngle) || (Math.abs(vertical) > verticalHalfAngle))) { + print('fixme skip out of angle'); + return; + } var avatarPalDatum = { - displayName: avatar.sessionDisplayName, + displayName: name, userName: '', sessionId: id || '', audioLevel: 0.0, @@ -298,10 +342,13 @@ function populateUserList(selectData) { addAvatarNode(id); // No overlay for ourselves // Everyone needs to see admin status. Username and fingerprint returns default constructor output if the requesting user isn't an admin. Users.requestUsernameFromID(id); + avatarsOfInterest[id] = true; } data.push(avatarPalDatum); print('PAL data:', JSON.stringify(avatarPalDatum)); }); + print('fixme avatarsOfInterest', JSON.stringify(avatarsOfInterest)); + conserveResources = Object.keys(avatarsOfInterest).length > 20; sendToQml({ method: 'users', params: data }); if (selectData) { selectData[2] = true; @@ -326,11 +373,13 @@ var pingPong = true; function updateOverlays() { var eye = Camera.position; AvatarList.getAvatarIdentifiers().forEach(function (id) { - if (!id) { - return; // don't update ourself + if (!id || !avatarsOfInterest[id]) { + if (id) print('fixme not updating', id, Object.keys(avatarsOfInterest).length); + return; // don't update ourself, or avatars we're not interested in } var avatar = AvatarList.getAvatar(id); if (!avatar) { + print('fixme not updating missing avatar', id); return; // will be deleted below if there had been an overlay. } var overlay = ExtendedOverlay.get(id); @@ -517,6 +566,7 @@ function off() { triggerMapping.disable(); // It's ok if we disable twice. triggerPressMapping.disable(); // see above removeOverlays(); + print('fixme clear requestsDomainListData'); Users.requestsDomainListData = false; } function onClicked() { @@ -538,6 +588,7 @@ function onClicked() { pal.setVisible(!pal.visible); } else { tablet.loadQMLSource("../Pal.qml"); + print('fixme setting requestsDomainListData'); Users.requestsDomainListData = true; populateUserList(); isWired = true; From f21e17d5123948a805d5a9fee967e5844f0efea3 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 21 Feb 2017 15:32:41 -0800 Subject: [PATCH 02/10] new buttons --- interface/resources/qml/hifi/Pal.qml | 88 ++++++++-------------------- 1 file changed, 23 insertions(+), 65 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index a13e31418a..b17182432a 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -52,6 +52,9 @@ Rectangle { letterboxMessage.visible = true letterboxMessage.popupRadius = 0 } + function refreshWithFilter() { + pal.sendToScript({method: 'refresh', params: {filter: filter.checked && {distance: 30}}}) + } // This is the container for the PAL Rectangle { @@ -93,7 +96,26 @@ Rectangle { // Anchors anchors.left: parent.left } - } + Row { + HifiControls.CheckBox { + id: filter + text: "in view" + boxSize: reload.height + onCheckedChanged: refreshWithFilter() + } + HifiControls.GlyphButton { + id: reload + glyph: hifi.glyphs.reload + width: reload.height + onClicked: refreshWithFilter() + } + spacing: 40 + anchors { + right: parent.right + top: parent.top + topMargin: 10 + } + } // Rectangles used to cover up rounded edges on bottom of MyInfo Rectangle Rectangle { color: pal.color @@ -306,70 +328,6 @@ Rectangle { } } } - // Refresh button - Rectangle { - id: reload - // Size - width: hifi.dimensions.tableHeaderHeight-1 - height: hifi.dimensions.tableHeaderHeight-1 - // Anchors - anchors.left: table.left - anchors.leftMargin: 4 - anchors.top: table.top - // Style - color: hifi.colors.tableBackgroundLight - // Actual refresh icon - HiFiGlyphs { - id: reloadButton - text: hifi.glyphs.reloadSmall - // Size - size: parent.width*1.5 - // Anchors - anchors.fill: parent - // Style - horizontalAlignment: Text.AlignHCenter - color: hifi.colors.darkGray - } - MouseArea { - id: reloadButtonArea - // Anchors - anchors.fill: parent - hoverEnabled: true - // Everyone likes a responsive refresh button! - // So use onPressed instead of onClicked - onPressed: { - reloadButton.color = hifi.colors.lightGrayText - pal.sendToScript({method: 'refresh', params: {filter: false}}) // fixme re filter - } - onReleased: reloadButton.color = (containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.darkGray) - onEntered: reloadButton.color = hifi.colors.baseGrayHighlight - onExited: reloadButton.color = (pressed ? hifi.colors.lightGrayText: hifi.colors.darkGray) - } - } - HiFiGlyphs { - id: filter - width: hifi.dimensions.tableHeaderHeight - 1 - height: filter.width - text: "\ue007" - size: filter.width - color: hifi.colors.darkGray - anchors { - left: reload.right - leftMargin: 4 - top: reload.top - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - onPressed: { - filter.color = hifi.colors.lightGrayText - pal.sendToScript({method: 'refresh', params: {filter: {distance: 30}}}) - } - onReleased: filter.color = (containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.darkGray) - onEntered: filter.color = hifi.colors.baseGrayHighlight - onExited: filter.color = (pressed ? hifi.colors.lightGrayText : hifi.colors.darkGray) - } - } // Separator between user and admin functions Rectangle { From 1ddc7de5815048502139e9ce0ff7ceca4f03622d Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 21 Feb 2017 15:41:17 -0800 Subject: [PATCH 03/10] remove debugging (and fix missing brace) --- interface/resources/qml/hifi/Pal.qml | 1 + scripts/system/pal.js | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index b17182432a..f87b110ecb 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -116,6 +116,7 @@ Rectangle { topMargin: 10 } } + } // Rectangles used to cover up rounded edges on bottom of MyInfo Rectangle Rectangle { color: pal.color diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 14e11e3fcd..0a135aeddb 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -297,7 +297,6 @@ function populateUserList(selectData, filterRequest) { front = filter && Quat.getFront(orientation), verticalAngleNormal = filter && Quat.getRight(orientation), horizontalAngleNormal = filter && Quat.getUp(orientation); - print('fixme h/v...myPosition', horizontalHalfAngle, verticalHalfAngle, JSON.stringify(horizontalAngleNormal), JSON.stringify(verticalAngleNormal), JSON.stringify(myPosition)); avatars.forEach(function (id) { // sorting the identifiers is just an aid for debugging var avatar = AvatarList.getAvatar(id); var name = avatar.sessionDisplayName; @@ -315,9 +314,7 @@ function populateUserList(selectData, filterRequest) { var normal = id && filter && Vec3.normalize(Vec3.subtract(avatar.position, myPosition)); var horizontal = normal && angleBetweenVectorsInPlane(normal, front, horizontalAngleNormal); var vertical = normal && angleBetweenVectorsInPlane(normal, front, verticalAngleNormal); - print('fixme id/h/v/pos/norm', id, horizontal, vertical, JSON.stringify(avatar.position), JSON.stringify(normal)); if (id && filter && ((Math.abs(horizontal) > horizontalHalfAngle) || (Math.abs(vertical) > verticalHalfAngle))) { - print('fixme skip out of angle'); return; } var avatarPalDatum = { @@ -338,7 +335,6 @@ function populateUserList(selectData, filterRequest) { data.push(avatarPalDatum); print('PAL data:', JSON.stringify(avatarPalDatum)); }); - print('fixme avatarsOfInterest', JSON.stringify(avatarsOfInterest)); conserveResources = Object.keys(avatarsOfInterest).length > 20; sendToQml({ method: 'users', params: data }); if (selectData) { @@ -365,12 +361,10 @@ function updateOverlays() { var eye = Camera.position; AvatarList.getAvatarIdentifiers().forEach(function (id) { if (!id || !avatarsOfInterest[id]) { - if (id) print('fixme not updating', id, Object.keys(avatarsOfInterest).length); return; // don't update ourself, or avatars we're not interested in } var avatar = AvatarList.getAvatar(id); if (!avatar) { - print('fixme not updating missing avatar', id); return; // will be deleted below if there had been an overlay. } var overlay = ExtendedOverlay.get(id); @@ -570,7 +564,6 @@ function off() { triggerMapping.disable(); // It's ok if we disable twice. triggerPressMapping.disable(); // see above removeOverlays(); - print('fixme clear requestsDomainListData'); Users.requestsDomainListData = false; } function onTabletButtonClicked() { From a20590a2f953e06601a6c6dbf6ca0e1fbefa9322 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 21 Feb 2017 16:03:59 -0800 Subject: [PATCH 04/10] fixed myCard width in all cases (admin or not) --- interface/resources/qml/hifi/Pal.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index f87b110ecb..b79f3bc7de 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -29,7 +29,9 @@ Rectangle { property int myCardHeight: 90 property int rowHeight: 70 property int actionButtonWidth: 55 - property int nameCardWidth: palContainer.width - actionButtonWidth*(iAmAdmin ? 4 : 2) - 4 - hifi.dimensions.scrollbarBackgroundWidth + property int actionButtonAllowance: actionButtonWidth * 2 + property int minNameCardWidth: palContainer.width - (actionButtonAllowance * 2) - 4 - hifi.dimensions.scrollbarBackgroundWidth + property int nameCardWidth: minNameCardWidth + (iAmAdmin ? 0 : actionButtonAllowance) property var myData: ({displayName: "", userName: "", audioLevel: 0.0, admin: true}) // valid dummy until set property var ignored: ({}); // Keep a local list of ignored avatars & their data. Necessary because HashMap is slow to respond after ignoring. property var userModelData: [] // This simple list is essentially a mirror of the userModel listModel without all the extra complexities. @@ -91,7 +93,7 @@ Rectangle { audioLevel: myData.audioLevel isMyCard: true // Size - width: nameCardWidth + width: minNameCardWidth height: parent.height // Anchors anchors.left: parent.left From 023a32563c13d4f554b01664c974410281b1ace8 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 22 Feb 2017 12:59:40 -0800 Subject: [PATCH 05/10] work around .qml settings issues --- interface/resources/qml/hifi/Pal.qml | 11 ++++++++++- scripts/system/pal.js | 13 +++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index b79f3bc7de..cc5bd521ff 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -13,6 +13,7 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 +import Qt.labs.settings 1.0 import "../styles-uit" import "../controls-uit" as HifiControls @@ -54,8 +55,15 @@ Rectangle { letterboxMessage.visible = true letterboxMessage.popupRadius = 0 } + Settings { + id: settings + category: "pal" + property bool filtered: false + property int nearDistance: 30 + } function refreshWithFilter() { - pal.sendToScript({method: 'refresh', params: {filter: filter.checked && {distance: 30}}}) + // We should just be able to set settings.filtered to filter.checked, but see #3249, so send to .js for saving. + pal.sendToScript({method: 'refresh', params: {filter: filter.checked && {distance: settings.nearDistance}}}); } // This is the container for the PAL @@ -101,6 +109,7 @@ Rectangle { Row { HifiControls.CheckBox { id: filter + checked: settings.filtered text: "in view" boxSize: reload.height onCheckedChanged: refreshWithFilter() diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 0a135aeddb..8ae4412fae 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -238,7 +238,11 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'refresh': removeOverlays(); - populateUserList(message.params.selected, message.params.filter); + // If filter is specified from .qml instead of through settings, update the settings. + if (message.params.filter !== undefined) { + Settings.setValue('pal/filtered', !!message.params.filter); + } + populateUserList(message.params.selected); UserActivityLogger.palAction("refresh", ""); break; case 'updateGain': @@ -280,13 +284,10 @@ function addAvatarNode(id) { color: color(selected, false, 0.0), ignoreRayIntersection: false}, selected, !conserveResources); } -var filter = false; // Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter. var avatarsOfInterest = {}; -function populateUserList(selectData, filterRequest) { - if (filterRequest !== undefined) { - filter = filterRequest; - } +function populateUserList(selectData) { + var filter = Settings.getValue('pal/filtered') && {distance: Settings.getValue('pal/nearDistance')}; var data = [], avatars = AvatarList.getAvatarIdentifiers(); avatarsOfInterest = {}; var myPosition = filter && Camera.position, From de3a0d3d0c7c5504068d7237139459a84e0e440e Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 22 Feb 2017 13:02:05 -0800 Subject: [PATCH 06/10] button styling --- interface/resources/qml/hifi/Pal.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index cc5bd521ff..cf5ea98b81 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -111,7 +111,7 @@ Rectangle { id: filter checked: settings.filtered text: "in view" - boxSize: reload.height + boxSize: reload.height * 0.70 onCheckedChanged: refreshWithFilter() } HifiControls.GlyphButton { @@ -120,7 +120,7 @@ Rectangle { width: reload.height onClicked: refreshWithFilter() } - spacing: 40 + spacing: 50 anchors { right: parent.right top: parent.top From 1429a32928361d31126629f0764ac3b31da8f0ee Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 22 Feb 2017 16:28:52 -0800 Subject: [PATCH 07/10] Prevent use after free of ScriptEngine pointer when shutting down all scripts. Before this change, if you were running with the Debug defaultScripts.js option on, it could result in a dereference of a previously freed ScriptEngine pointer. To prevent this, defaultScripts.js no longer explicitly calls ScriptDiscoveryService.stopScript() on Script.scriptEnding. --- scripts/defaultScripts.js | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 40a77eda55..e544f3cd1f 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -20,7 +20,7 @@ var DEFAULT_SCRIPTS = [ "system/bubble.js", "system/snapshot.js", "system/help.js", - "system/pal.js", //"system/mod.js", // older UX, if you prefer + "system/pal.js", // "system/mod.js", // older UX, if you prefer "system/goto.js", "system/marketplaces/marketplaces.js", "system/edit.js", @@ -54,9 +54,6 @@ if (previousSetting === true || previousSetting === 'true') { previousSetting = true; } - - - if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) { Menu.addMenuItem({ menuName: MENU_CATEGORY, @@ -78,11 +75,11 @@ function runDefaultsSeparately() { Script.load(DEFAULT_SCRIPTS[i]); } } + // start all scripts if (Menu.isOptionChecked(MENU_ITEM)) { // we're debugging individual default scripts // so we load each into its own ScriptEngine instance - debuggingDefaultScripts = true; runDefaultsSeparately(); } else { // include all default scripts into this ScriptEngine @@ -90,32 +87,14 @@ if (Menu.isOptionChecked(MENU_ITEM)) { } function menuItemEvent(menuItem) { - if (menuItem == MENU_ITEM) { - - isChecked = Menu.isOptionChecked(MENU_ITEM); + if (menuItem === MENU_ITEM) { + var isChecked = Menu.isOptionChecked(MENU_ITEM); if (isChecked === true) { Settings.setValue(SETTINGS_KEY, true); } else if (isChecked === false) { Settings.setValue(SETTINGS_KEY, false); } - Window.alert('You must reload all scripts for this to take effect.') - } - - -} - - - -function stopLoadedScripts() { - // remove debug script loads - var runningScripts = ScriptDiscoveryService.getRunning(); - for (var i in runningScripts) { - var scriptName = runningScripts[i].name; - for (var j in DEFAULT_SCRIPTS) { - if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) { - ScriptDiscoveryService.stopScript(runningScripts[i].url); - } - } + Window.alert('You must reload all scripts for this to take effect.'); } } @@ -126,7 +105,6 @@ function removeMenuItem() { } Script.scriptEnding.connect(function() { - stopLoadedScripts(); removeMenuItem(); }); From 83b3c12559b180cd697ce8dbe5f2d14df8dc8792 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 22 Feb 2017 17:01:31 -0800 Subject: [PATCH 08/10] Removed Window.alert() because it was blocking the defaultScripts thread. --- scripts/defaultScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index e544f3cd1f..f2791f0275 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -94,7 +94,7 @@ function menuItemEvent(menuItem) { } else if (isChecked === false) { Settings.setValue(SETTINGS_KEY, false); } - Window.alert('You must reload all scripts for this to take effect.'); + console.log('You must reload all scripts for this to take effect.'); } } From 84b29c6872b4a1c08d7d2ac4874715185fe519d4 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 23 Feb 2017 11:02:25 -0800 Subject: [PATCH 09/10] Reload all scripts when Debug defaultScripts.js is changed. --- scripts/defaultScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index f2791f0275..5d8813e988 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -94,7 +94,7 @@ function menuItemEvent(menuItem) { } else if (isChecked === false) { Settings.setValue(SETTINGS_KEY, false); } - console.log('You must reload all scripts for this to take effect.'); + Menu.triggerOption("Reload All Scripts"); } } From 60fd4afc4d94a1af7b4887f3fad4b2a01a658623 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 23 Feb 2017 18:52:10 -0800 Subject: [PATCH 10/10] don't count NoData avatars as having been broadcast, fix avatars slightly out of view from freezing --- .../src/avatars/AvatarMixerSlave.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixerSlave.cpp b/assignment-client/src/avatars/AvatarMixerSlave.cpp index 8d9a5e6951..dd25aa4c4b 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlave.cpp @@ -384,18 +384,20 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) { if (includeThisAvatar) { numAvatarDataBytes += avatarPacketList->write(otherNode->getUUID().toRfc4122()); numAvatarDataBytes += avatarPacketList->write(bytes); - _stats.numOthersIncluded++; - // increment the number of avatars sent to this reciever - nodeData->incrementNumAvatarsSentLastFrame(); + if (detail != AvatarData::NoData) { + _stats.numOthersIncluded++; - // set the last sent sequence number for this sender on the receiver - nodeData->setLastBroadcastSequenceNumber(otherNode->getUUID(), - otherNodeData->getLastReceivedSequenceNumber()); + // increment the number of avatars sent to this reciever + nodeData->incrementNumAvatarsSentLastFrame(); - // remember the last time we sent details about this other node to the receiver - nodeData->setLastBroadcastTime(otherNode->getUUID(), start); + // set the last sent sequence number for this sender on the receiver + nodeData->setLastBroadcastSequenceNumber(otherNode->getUUID(), + otherNodeData->getLastReceivedSequenceNumber()); + // remember the last time we sent details about this other node to the receiver + nodeData->setLastBroadcastTime(otherNode->getUUID(), start); + } } avatarPacketList->endSegment();