Merge branch 'master' of github.com:highfidelity/hifi into edit-lights-overlays

This commit is contained in:
Ryan Huffman 2015-03-13 14:13:56 -07:00
commit d512a67c8a
23 changed files with 380 additions and 211 deletions

View file

@ -267,10 +267,6 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded); connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled); connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled);
QTimer* silentNodeTimer = new QTimer(this);
connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readAvailableDatagrams())); connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readAvailableDatagrams()));
// add whatever static assignments that have been parsed to the queue // add whatever static assignments that have been parsed to the queue

View file

@ -9,7 +9,7 @@
// //
Script.load("progress.js"); Script.load("progress.js");
Script.load("editEntities.js"); Script.load("edit.js");
Script.load("selectAudioDevice.js"); Script.load("selectAudioDevice.js");
Script.load("controllers/hydra/hydraMove.js"); Script.load("controllers/hydra/hydraMove.js");
Script.load("headMove.js"); Script.load("headMove.js");

View file

@ -134,7 +134,7 @@ var toolBar = (function () {
// Hide active button for now - this may come back, so not deleting yet. // Hide active button for now - this may come back, so not deleting yet.
activeButton = toolBar.addTool({ activeButton = toolBar.addTool({
imageURL: toolIconUrl + "models-tool.svg", imageURL: toolIconUrl + "edit-status.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
width: toolWidth, width: toolWidth,
height: toolHeight, height: toolHeight,
@ -143,7 +143,7 @@ var toolBar = (function () {
}, true, false); }, true, false);
newModelButton = toolBar.addTool({ newModelButton = toolBar.addTool({
imageURL: toolIconUrl + "add-model-tool.svg", imageURL: toolIconUrl + "upload.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
width: toolWidth, width: toolWidth,
height: toolHeight, height: toolHeight,
@ -152,7 +152,7 @@ var toolBar = (function () {
}); });
browseModelsButton = toolBar.addTool({ browseModelsButton = toolBar.addTool({
imageURL: toolIconUrl + "list-icon.svg", imageURL: toolIconUrl + "marketplace.svg",
width: toolWidth, width: toolWidth,
height: toolHeight, height: toolHeight,
alpha: 0.9, alpha: 0.9,

View file

@ -94,7 +94,7 @@ Tool = function(properties, selectable, selected) { // selectable and selected a
} }
selected = doSelect; selected = doSelect;
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height; properties.subImage.y = (selected ? 0 : 1) * properties.subImage.height;
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage }); Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });
} }
this.toggle = function() { this.toggle = function() {
@ -102,7 +102,7 @@ Tool = function(properties, selectable, selected) { // selectable and selected a
return; return;
} }
selected = !selected; selected = !selected;
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height; properties.subImage.y = (selected ? 0 : 1) * properties.subImage.height;
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage }); Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });
return selected; return selected;

View file

@ -13,29 +13,39 @@ var usersWindow = (function () {
var WINDOW_WIDTH_2D = 150, var WINDOW_WIDTH_2D = 150,
WINDOW_MARGIN_2D = 12, WINDOW_MARGIN_2D = 12,
WINDOW_FONT_2D = { size: 12 },
WINDOW_FOREGROUND_COLOR_2D = { red: 240, green: 240, blue: 240 }, WINDOW_FOREGROUND_COLOR_2D = { red: 240, green: 240, blue: 240 },
WINDOW_FOREGROUND_ALPHA_2D = 0.9, WINDOW_FOREGROUND_ALPHA_2D = 0.9,
WINDOW_HEADING_COLOR_2D = { red: 180, green: 180, blue: 180 }, WINDOW_HEADING_COLOR_2D = { red: 180, green: 180, blue: 180 },
WINDOW_HEADING_ALPHA_2D = 0.9, WINDOW_HEADING_ALPHA_2D = 0.9,
WINDOW_BACKGROUND_COLOR_2D = { red: 80, green: 80, blue: 80 }, WINDOW_BACKGROUND_COLOR_2D = { red: 80, green: 80, blue: 80 },
WINDOW_BACKGROUND_ALPHA_2D = 0.7, WINDOW_BACKGROUND_ALPHA_2D = 0.7,
windowHeight = 0, windowPane2D,
usersPane2D, windowHeading2D,
usersHeading2D, VISIBILITY_SPACER_2D = 12, // Space between list of users and visibility controls
USERS_FONT_2D = { size: 14 }, visibilityHeading2D,
usersLineHeight, VISIBILITY_RADIO_SPACE = 16,
usersLineSpacing, visibilityControls2D,
windowHeight,
windowTextHeight,
windowLineSpacing,
windowLineHeight, // = windowTextHeight + windowLineSpacing
usersOnline, // Raw data usersOnline, // Raw users data
linesOfUsers, // Array of indexes pointing into usersOnline linesOfUsers = [], // Array of indexes pointing into usersOnline
API_URL = "https://metaverse.highfidelity.io/api/v1/users?status=online", API_URL = "https://metaverse.highfidelity.io/api/v1/users?status=online",
HTTP_GET_TIMEOUT = 60000, // ms = 1 minute HTTP_GET_TIMEOUT = 60000, // ms = 1 minute
usersRequest, usersRequest,
processUsers, processUsers,
usersTimedOut, pollUsersTimedOut,
usersTimer = null, usersTimer = null,
UPDATE_TIMEOUT = 5000, // ms = 5s USERS_UPDATE_TIMEOUT = 5000, // ms = 5s
myVisibility,
VISIBILITY_VALUES = ["all", "friends", "none"],
visibilityInterval,
VISIBILITY_POLL_INTERVAL = 5000, // ms = 5s
MENU_NAME = "Tools", MENU_NAME = "Tools",
MENU_ITEM = "Users Online", MENU_ITEM = "Users Online",
@ -43,45 +53,56 @@ var usersWindow = (function () {
isVisible = true, isVisible = true,
viewportHeight; viewportHeight,
function onMousePressEvent(event) { HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/",
var clickedOverlay, RADIO_BUTTON_SVG = HIFI_PUBLIC_BUCKET + "images/radio-button.svg",
numLinesBefore, RADIO_BUTTON_SVG_DIAMETER = 14,
overlayX, RADIO_BUTTON_DISPLAY_SCALE = 0.7, // 1.0 = windowTextHeight
overlayY, radioButtonDiameter;
minY,
maxY,
lineClicked;
if (!isVisible) { function calculateWindowHeight() {
return; // Reserve 5 lines for window heading plus visibility heading and controls
} // Subtract windowLineSpacing for both end of user list and end of controls
windowHeight = (linesOfUsers.length > 0 ? linesOfUsers.length + 5 : 5) * windowLineHeight
- 2 * windowLineSpacing + VISIBILITY_SPACER_2D + 2 * WINDOW_MARGIN_2D;
}
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); function updateOverlayPositions() {
if (clickedOverlay === usersPane2D) { var i,
y;
overlayX = event.x - WINDOW_MARGIN_2D; Overlays.editOverlay(windowPane2D, {
overlayY = event.y - viewportHeight + windowHeight - WINDOW_MARGIN_2D - (usersLineHeight + usersLineSpacing); y: viewportHeight - windowHeight
});
numLinesBefore = Math.floor(overlayY / (usersLineHeight + usersLineSpacing)); Overlays.editOverlay(windowHeading2D, {
minY = numLinesBefore * (usersLineHeight + usersLineSpacing); y: viewportHeight - windowHeight + WINDOW_MARGIN_2D
maxY = minY + usersLineHeight; });
Overlays.editOverlay(visibilityHeading2D, {
lineClicked = -1; y: viewportHeight - 4 * windowLineHeight + windowLineSpacing - WINDOW_MARGIN_2D
if (minY <= overlayY && overlayY <= maxY) { });
lineClicked = numLinesBefore; for (i = 0; i < visibilityControls2D.length; i += 1) {
} y = viewportHeight - (3 - i) * windowLineHeight + windowLineSpacing - WINDOW_MARGIN_2D;
Overlays.editOverlay(visibilityControls2D[i].radioOverlay, { y: y });
if (0 <= lineClicked && lineClicked < linesOfUsers.length Overlays.editOverlay(visibilityControls2D[i].textOverlay, { y: y });
&& overlayX <= usersOnline[linesOfUsers[lineClicked]].usernameWidth) {
//print("Go to " + usersOnline[linesOfUsers[lineClicked]].username);
location.goToUser(usersOnline[linesOfUsers[lineClicked]].username);
}
} }
} }
function updateWindow() { function updateVisibilityControls() {
var i,
color;
for (i = 0; i < visibilityControls2D.length; i += 1) {
color = visibilityControls2D[i].selected ? WINDOW_FOREGROUND_COLOR_2D : WINDOW_HEADING_COLOR_2D;
Overlays.editOverlay(visibilityControls2D[i].radioOverlay, {
color: color,
subImage: { y: visibilityControls2D[i].selected ? 0 : RADIO_BUTTON_SVG_DIAMETER }
});
Overlays.editOverlay(visibilityControls2D[i].textOverlay, { color: color });
}
}
function updateUsersDisplay() {
var displayText = "", var displayText = "",
myUsername, myUsername,
user, user,
@ -92,32 +113,38 @@ var usersWindow = (function () {
for (i = 0; i < usersOnline.length; i += 1) { for (i = 0; i < usersOnline.length; i += 1) {
user = usersOnline[i]; user = usersOnline[i];
if (user.username !== myUsername && user.online) { if (user.username !== myUsername && user.online) {
usersOnline[i].usernameWidth = Overlays.textSize(usersPane2D, user.username).width; usersOnline[i].usernameWidth = Overlays.textSize(windowPane2D, user.username).width;
linesOfUsers.push(i); linesOfUsers.push(i);
displayText += "\n" + user.username; displayText += "\n" + user.username;
if (user.location.root) {
displayText += " @ " + user.location.root.name;
}
} }
} }
windowHeight = (linesOfUsers.length > 0 ? linesOfUsers.length + 1 : 1) * (usersLineHeight + usersLineSpacing) displayText = displayText.slice(1); // Remove leading "\n".
- usersLineSpacing + 2 * WINDOW_MARGIN_2D; // First or only line is for heading
Overlays.editOverlay(usersPane2D, { calculateWindowHeight();
Overlays.editOverlay(windowPane2D, {
y: viewportHeight - windowHeight, y: viewportHeight - windowHeight,
height: windowHeight, height: windowHeight,
text: displayText text: displayText
}); });
Overlays.editOverlay(usersHeading2D, { Overlays.editOverlay(windowHeading2D, {
y: viewportHeight - windowHeight + WINDOW_MARGIN_2D, y: viewportHeight - windowHeight + WINDOW_MARGIN_2D,
text: linesOfUsers.length > 0 ? "Online" : "No users online" text: linesOfUsers.length > 0 ? "Users online" : "No users online"
}); });
updateOverlayPositions();
} }
function requestUsers() { function pollUsers() {
usersRequest = new XMLHttpRequest(); usersRequest = new XMLHttpRequest();
usersRequest.open("GET", API_URL, true); usersRequest.open("GET", API_URL, true);
usersRequest.timeout = HTTP_GET_TIMEOUT; usersRequest.timeout = HTTP_GET_TIMEOUT;
usersRequest.ontimeout = usersTimedOut; usersRequest.ontimeout = pollUsersTimedOut;
usersRequest.onreadystatechange = processUsers; usersRequest.onreadystatechange = processUsers;
usersRequest.send(); usersRequest.send();
} }
@ -130,46 +157,62 @@ var usersWindow = (function () {
response = JSON.parse(usersRequest.responseText); response = JSON.parse(usersRequest.responseText);
if (response.status !== "success") { if (response.status !== "success") {
print("Error: Request for users status returned status = " + response.status); print("Error: Request for users status returned status = " + response.status);
usersTimer = Script.setTimeout(requestUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay. usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
return; return;
} }
if (!response.hasOwnProperty("data") || !response.data.hasOwnProperty("users")) { if (!response.hasOwnProperty("data") || !response.data.hasOwnProperty("users")) {
print("Error: Request for users status returned invalid data"); print("Error: Request for users status returned invalid data");
usersTimer = Script.setTimeout(requestUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay. usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
return; return;
} }
usersOnline = response.data.users; usersOnline = response.data.users;
updateWindow(); updateUsersDisplay();
} else { } else {
print("Error: Request for users status returned " + usersRequest.status + " " + usersRequest.statusText); print("Error: Request for users status returned " + usersRequest.status + " " + usersRequest.statusText);
usersTimer = Script.setTimeout(requestUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay. usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
return; return;
} }
usersTimer = Script.setTimeout(requestUsers, UPDATE_TIMEOUT); // Update after finished processing. usersTimer = Script.setTimeout(pollUsers, USERS_UPDATE_TIMEOUT); // Update after finished processing.
} }
}; };
usersTimedOut = function () { pollUsersTimedOut = function () {
print("Error: Request for users status timed out"); print("Error: Request for users status timed out");
usersTimer = Script.setTimeout(requestUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay. usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
}; };
function pollVisibility() {
var currentVisibility = myVisibility;
myVisibility = GlobalServices.findableBy;
if (myVisibility !== currentVisibility) {
updateVisibilityControls();
}
}
function setVisible(visible) { function setVisible(visible) {
var i;
isVisible = visible; isVisible = visible;
if (isVisible) { if (isVisible) {
if (usersTimer === null) { if (usersTimer === null) {
requestUsers(); pollUsers();
} }
} else { } else {
Script.clearTimeout(usersTimer); Script.clearTimeout(usersTimer);
usersTimer = null; usersTimer = null;
} }
Overlays.editOverlay(usersPane2D, { visible: isVisible }); Overlays.editOverlay(windowPane2D, { visible: isVisible });
Overlays.editOverlay(usersHeading2D, { visible: isVisible }); Overlays.editOverlay(windowHeading2D, { visible: isVisible });
Overlays.editOverlay(visibilityHeading2D, { visible: isVisible });
for (i = 0; i < visibilityControls2D.length; i += 1) {
Overlays.editOverlay(visibilityControls2D[i].radioOverlay, { visible: isVisible });
Overlays.editOverlay(visibilityControls2D[i].textOverlay, { visible: isVisible });
}
} }
function onMenuItemEvent(event) { function onMenuItemEvent(event) {
@ -178,48 +221,182 @@ var usersWindow = (function () {
} }
} }
function update() { function onMousePressEvent(event) {
var clickedOverlay,
numLinesBefore,
overlayX,
overlayY,
minY,
maxY,
lineClicked,
i,
visibilityChanged;
if (!isVisible) {
return;
}
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
if (clickedOverlay === windowPane2D) {
overlayX = event.x - WINDOW_MARGIN_2D;
overlayY = event.y - viewportHeight + windowHeight - WINDOW_MARGIN_2D - windowLineHeight;
numLinesBefore = Math.floor(overlayY / windowLineHeight);
minY = numLinesBefore * windowLineHeight;
maxY = minY + windowTextHeight;
lineClicked = -1;
if (minY <= overlayY && overlayY <= maxY) {
lineClicked = numLinesBefore;
}
if (0 <= lineClicked && lineClicked < linesOfUsers.length
&& overlayX <= usersOnline[linesOfUsers[lineClicked]].usernameWidth) {
//print("Go to " + usersOnline[linesOfUsers[lineClicked]].username);
location.goToUser(usersOnline[linesOfUsers[lineClicked]].username);
}
}
visibilityChanged = false;
for (i = 0; i < visibilityControls2D.length; i += 1) {
// Don't need to test radioOverlay if it us under textOverlay.
if (clickedOverlay === visibilityControls2D[i].textOverlay) {
GlobalServices.findableBy = VISIBILITY_VALUES[i];
visibilityChanged = true;
}
}
if (visibilityChanged) {
for (i = 0; i < visibilityControls2D.length; i += 1) {
// Don't need to handle radioOverlay if it us under textOverlay.
visibilityControls2D[i].selected = clickedOverlay === visibilityControls2D[i].textOverlay;
}
updateVisibilityControls();
}
}
function onScriptUpdate() {
var oldViewportHeight = viewportHeight;
viewportHeight = Controller.getViewportDimensions().y; viewportHeight = Controller.getViewportDimensions().y;
Overlays.editOverlay(usersPane2D, { if (viewportHeight !== oldViewportHeight) {
y: viewportHeight - windowHeight updateOverlayPositions();
}); }
Overlays.editOverlay(usersHeading2D, {
y: viewportHeight - windowHeight + WINDOW_MARGIN_2D
});
} }
function setUp() { function setUp() {
usersPane2D = Overlays.addOverlay("text", { var textSizeOverlay;
bounds: { x: 0, y: 0, width: WINDOW_WIDTH_2D, height: 0 },
topMargin: WINDOW_MARGIN_2D, textSizeOverlay = Overlays.addOverlay("text", { font: WINDOW_FONT_2D, visible: false });
windowTextHeight = Math.floor(Overlays.textSize(textSizeOverlay, "1").height);
windowLineSpacing = Math.floor(Overlays.textSize(textSizeOverlay, "1\n2").height - 2 * windowTextHeight);
windowLineHeight = windowTextHeight + windowLineSpacing;
radioButtonDiameter = RADIO_BUTTON_DISPLAY_SCALE * windowTextHeight;
Overlays.deleteOverlay(textSizeOverlay);
calculateWindowHeight();
viewportHeight = Controller.getViewportDimensions().y;
windowPane2D = Overlays.addOverlay("text", {
x: 0,
y: viewportHeight, // Start up off-screen
width: WINDOW_WIDTH_2D,
height: windowHeight,
topMargin: WINDOW_MARGIN_2D + windowLineHeight,
leftMargin: WINDOW_MARGIN_2D, leftMargin: WINDOW_MARGIN_2D,
color: WINDOW_FOREGROUND_COLOR_2D, color: WINDOW_FOREGROUND_COLOR_2D,
alpha: WINDOW_FOREGROUND_ALPHA_2D, alpha: WINDOW_FOREGROUND_ALPHA_2D,
backgroundColor: WINDOW_BACKGROUND_COLOR_2D, backgroundColor: WINDOW_BACKGROUND_COLOR_2D,
backgroundAlpha: WINDOW_BACKGROUND_ALPHA_2D, backgroundAlpha: WINDOW_BACKGROUND_ALPHA_2D,
text: "", text: "",
font: USERS_FONT_2D, font: WINDOW_FONT_2D,
visible: isVisible visible: isVisible
}); });
usersHeading2D = Overlays.addOverlay("text", { windowHeading2D = Overlays.addOverlay("text", {
x: WINDOW_MARGIN_2D, x: WINDOW_MARGIN_2D,
y: viewportHeight,
width: WINDOW_WIDTH_2D - 2 * WINDOW_MARGIN_2D, width: WINDOW_WIDTH_2D - 2 * WINDOW_MARGIN_2D,
height: USERS_FONT_2D.size, height: windowTextHeight,
topMargin: 0, topMargin: 0,
leftMargin: 0, leftMargin: 0,
color: WINDOW_HEADING_COLOR_2D, color: WINDOW_HEADING_COLOR_2D,
alpha: WINDOW_HEADING_ALPHA_2D, alpha: WINDOW_HEADING_ALPHA_2D,
backgroundAlpha: 0.0, backgroundAlpha: 0.0,
text: "No users online", text: "No users online",
font: USERS_FONT_2D, font: WINDOW_FONT_2D,
visible: isVisible visible: isVisible
}); });
viewportHeight = Controller.getViewportDimensions().y; visibilityHeading2D = Overlays.addOverlay("text", {
x: WINDOW_MARGIN_2D,
y: viewportHeight,
width: WINDOW_WIDTH_2D - 2 * WINDOW_MARGIN_2D,
height: windowTextHeight,
topMargin: 0,
leftMargin: 0,
color: WINDOW_HEADING_COLOR_2D,
alpha: WINDOW_HEADING_ALPHA_2D,
backgroundAlpha: 0.0,
text: "I am visible to:",
font: WINDOW_FONT_2D,
visible: isVisible
});
usersLineHeight = Math.floor(Overlays.textSize(usersPane2D, "1").height); myVisibility = GlobalServices.findableBy;
usersLineSpacing = Math.floor(Overlays.textSize(usersPane2D, "1\n2").height - 2 * usersLineHeight); if (!/^(all|friends|none)$/.test(myVisibility)) {
print("Error: Unrecognized findableBy value");
myVisibility = "";
}
visibilityControls2D = [{
radioOverlay: Overlays.addOverlay("image", { // Create first so that it is under textOverlay.
x: WINDOW_MARGIN_2D,
y: viewportHeight,
width: radioButtonDiameter,
height: radioButtonDiameter,
imageURL: RADIO_BUTTON_SVG,
subImage: {
x: 0,
y: RADIO_BUTTON_SVG_DIAMETER, // Off
width: RADIO_BUTTON_SVG_DIAMETER,
height: RADIO_BUTTON_SVG_DIAMETER
},
color: WINDOW_HEADING_COLOR_2D,
alpha: WINDOW_FOREGROUND_ALPHA_2D
}),
textOverlay: Overlays.addOverlay("text", {
x: WINDOW_MARGIN_2D,
y: viewportHeight,
width: WINDOW_WIDTH_2D - 2 * WINDOW_MARGIN_2D,
height: windowTextHeight,
topMargin: 0,
leftMargin: VISIBILITY_RADIO_SPACE,
color: WINDOW_HEADING_COLOR_2D,
alpha: WINDOW_FOREGROUND_ALPHA_2D,
backgroundAlpha: 0.0,
text: "everyone",
font: WINDOW_FONT_2D,
visible: isVisible
}),
selected: myVisibility === VISIBILITY_VALUES[0]
} ];
visibilityControls2D[1] = {
radioOverlay: Overlays.cloneOverlay(visibilityControls2D[0].radioOverlay),
textOverlay: Overlays.cloneOverlay(visibilityControls2D[0].textOverlay),
selected: myVisibility === VISIBILITY_VALUES[1]
};
Overlays.editOverlay(visibilityControls2D[1].textOverlay, { text: "my friends" });
visibilityControls2D[2] = {
radioOverlay: Overlays.cloneOverlay(visibilityControls2D[0].radioOverlay),
textOverlay: Overlays.cloneOverlay(visibilityControls2D[0].textOverlay),
selected: myVisibility === VISIBILITY_VALUES[2]
};
Overlays.editOverlay(visibilityControls2D[2].textOverlay, { text: "no one" });
updateVisibilityControls();
Controller.mousePressEvent.connect(onMousePressEvent); Controller.mousePressEvent.connect(onMousePressEvent);
@ -232,17 +409,28 @@ var usersWindow = (function () {
}); });
Menu.menuItemEvent.connect(onMenuItemEvent); Menu.menuItemEvent.connect(onMenuItemEvent);
Script.update.connect(update); Script.update.connect(onScriptUpdate);
visibilityInterval = Script.setInterval(pollVisibility, VISIBILITY_POLL_INTERVAL);
pollUsers();
requestUsers();
} }
function tearDown() { function tearDown() {
var i;
Menu.removeMenuItem(MENU_NAME, MENU_ITEM); Menu.removeMenuItem(MENU_NAME, MENU_ITEM);
Script.clearInterval(visibilityInterval);
Script.clearTimeout(usersTimer); Script.clearTimeout(usersTimer);
Overlays.deleteOverlay(usersHeading2D); Overlays.deleteOverlay(windowPane2D);
Overlays.deleteOverlay(usersPane2D); Overlays.deleteOverlay(windowHeading2D);
Overlays.deleteOverlay(visibilityHeading2D);
for (i = 0; i <= visibilityControls2D.length; i += 1) {
Overlays.deleteOverlay(visibilityControls2D[i].textOverlay);
Overlays.deleteOverlay(visibilityControls2D[i].radioOverlay);
}
} }
setUp(); setUp();

View file

@ -146,7 +146,6 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
static QTimer* locationUpdateTimer = NULL; static QTimer* locationUpdateTimer = NULL;
static QTimer* balanceUpdateTimer = NULL; static QTimer* balanceUpdateTimer = NULL;
static QTimer* silentNodeTimer = NULL;
static QTimer* identityPacketTimer = NULL; static QTimer* identityPacketTimer = NULL;
static QTimer* billboardPacketTimer = NULL; static QTimer* billboardPacketTimer = NULL;
static QTimer* checkFPStimer = NULL; static QTimer* checkFPStimer = NULL;
@ -258,7 +257,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_dependencyManagerIsSetup(setupEssentials(argc, argv)), _dependencyManagerIsSetup(setupEssentials(argc, argv)),
_window(new MainWindow(desktop())), _window(new MainWindow(desktop())),
_toolWindow(NULL), _toolWindow(NULL),
_nodeThread(new QThread(this)),
_datagramProcessor(), _datagramProcessor(),
_undoStack(), _undoStack(),
_undoStackScriptingInterface(&_undoStack), _undoStackScriptingInterface(&_undoStack),
@ -329,18 +327,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_runningScriptsWidget = new RunningScriptsWidget(_window); _runningScriptsWidget = new RunningScriptsWidget(_window);
// start the nodeThread so its event loop is running // start the nodeThread so its event loop is running
_nodeThread->setObjectName("Datagram Processor Thread"); QThread* nodeThread = new QThread(this);
_nodeThread->start(); nodeThread->setObjectName("Datagram Processor Thread");
nodeThread->start();
// make sure the node thread is given highest priority // make sure the node thread is given highest priority
_nodeThread->setPriority(QThread::TimeCriticalPriority); nodeThread->setPriority(QThread::TimeCriticalPriority);
_datagramProcessor = new DatagramProcessor(nodeList.data());
// have the NodeList use deleteLater from DM customDeleter
nodeList->setCustomDeleter([](Dependency* dependency) {
static_cast<NodeList*>(dependency)->deleteLater();
});
// put the NodeList and datagram processing on the node thread // put the NodeList and datagram processing on the node thread
nodeList->moveToThread(_nodeThread); nodeList->moveToThread(nodeThread);
_datagramProcessor.moveToThread(_nodeThread);
// connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, _datagramProcessor, &DatagramProcessor::processDatagrams);
// put the audio processing on a separate thread // put the audio processing on a separate thread
QThread* audioThread = new QThread(); QThread* audioThread = new QThread();
@ -427,12 +432,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
// connect to the packet sent signal of the _entityEditSender // connect to the packet sent signal of the _entityEditSender
connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
// move the silentNodeTimer to the _nodeThread
silentNodeTimer = new QTimer();
connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
silentNodeTimer->moveToThread(_nodeThread);
// send the identity packet for our avatar each second to our avatar mixer // send the identity packet for our avatar each second to our avatar mixer
identityPacketTimer = new QTimer(); identityPacketTimer = new QTimer();
connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@ -547,7 +546,7 @@ void Application::aboutToQuit() {
} }
void Application::cleanupBeforeQuit() { void Application::cleanupBeforeQuit() {
_datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
_entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
ScriptEngine::stopAllScripts(this); // stop all currently running global scripts ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
@ -555,7 +554,6 @@ void Application::cleanupBeforeQuit() {
// depending on what thread they run in // depending on what thread they run in
locationUpdateTimer->stop(); locationUpdateTimer->stop();
balanceUpdateTimer->stop(); balanceUpdateTimer->stop();
QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection);
identityPacketTimer->stop(); identityPacketTimer->stop();
billboardPacketTimer->stop(); billboardPacketTimer->stop();
checkFPStimer->stop(); checkFPStimer->stop();
@ -565,7 +563,6 @@ void Application::cleanupBeforeQuit() {
// and then delete those that got created by "new" // and then delete those that got created by "new"
delete locationUpdateTimer; delete locationUpdateTimer;
delete balanceUpdateTimer; delete balanceUpdateTimer;
delete silentNodeTimer;
delete identityPacketTimer; delete identityPacketTimer;
delete billboardPacketTimer; delete billboardPacketTimer;
delete checkFPStimer; delete checkFPStimer;
@ -576,10 +573,6 @@ void Application::cleanupBeforeQuit() {
_settingsThread.quit(); _settingsThread.quit();
saveSettings(); saveSettings();
_window->saveGeometry(); _window->saveGeometry();
// TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
// an event loop to send the packet?
UserActivityLogger::getInstance().close();
// let the avatar mixer know we're out // let the avatar mixer know we're out
MyAvatar::sendKillAvatar(); MyAvatar::sendKillAvatar();
@ -597,10 +590,6 @@ Application::~Application() {
tree->lockForWrite(); tree->lockForWrite();
_entities.getTree()->setSimulation(NULL); _entities.getTree()->setSimulation(NULL);
tree->unlock(); tree->unlock();
// ask the datagram processing thread to quit and wait until it is done
_nodeThread->quit();
_nodeThread->wait();
_octreeProcessor.terminate(); _octreeProcessor.terminate();
_entityEditSender.terminate(); _entityEditSender.terminate();
@ -620,6 +609,13 @@ Application::~Application() {
DependencyManager::destroy<GeometryCache>(); DependencyManager::destroy<GeometryCache>();
//DependencyManager::destroy<ScriptCache>(); //DependencyManager::destroy<ScriptCache>();
DependencyManager::destroy<SoundCache>(); DependencyManager::destroy<SoundCache>();
QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
DependencyManager::destroy<NodeList>();
// ask the node thread to quit and wait until it is done
nodeThread->quit();
nodeThread->wait();
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
} }
@ -889,7 +885,7 @@ bool Application::event(QEvent* event) {
if (!url.isEmpty()) { if (!url.isEmpty()) {
if (url.scheme() == HIFI_URL_SCHEME) { if (url.scheme() == HIFI_URL_SCHEME) {
DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString()); DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
} else if (url.url().toLower().endsWith(SVO_EXTENSION)) { } else if (url.path().toLower().endsWith(SVO_EXTENSION)) {
emit svoImportRequested(url.url()); emit svoImportRequested(url.url());
} }
} }
@ -1455,10 +1451,11 @@ void Application::dropEvent(QDropEvent *event) {
QString snapshotPath; QString snapshotPath;
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
foreach (QUrl url, mimeData->urls()) { foreach (QUrl url, mimeData->urls()) {
if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) { auto lower = url.path().toLower();
if (lower.endsWith(SNAPSHOT_EXTENSION)) {
snapshotPath = url.toLocalFile(); snapshotPath = url.toLocalFile();
break; break;
} else if (url.url().toLower().endsWith(SVO_EXTENSION)) { } else if (lower.endsWith(SVO_EXTENSION)) {
emit svoImportRequested(url.url()); emit svoImportRequested(url.url());
event->acceptProposedAction(); event->acceptProposedAction();
return; return;
@ -1498,7 +1495,7 @@ void Application::checkFPS() {
_fps = (float)_frameCount / diffTime; _fps = (float)_frameCount / diffTime;
_frameCount = 0; _frameCount = 0;
_datagramProcessor.resetCounters(); _datagramProcessor->resetCounters();
_timerStart.start(); _timerStart.start();
// ask the node list to check in with the domain server // ask the node list to check in with the domain server
@ -2739,7 +2736,6 @@ const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f }; const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f }; const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
const float GLOBAL_LIGHT_INTENSITY = 1.0f;
void Application::setupWorldLight() { void Application::setupWorldLight() {

View file

@ -445,10 +445,8 @@ private:
MainWindow* _window; MainWindow* _window;
ToolWindow* _toolWindow; ToolWindow* _toolWindow;
DatagramProcessor* _datagramProcessor;
QThread* _nodeThread;
DatagramProcessor _datagramProcessor;
QUndoStack _undoStack; QUndoStack _undoStack;
UndoStackScriptingInterface _undoStackScriptingInterface; UndoStackScriptingInterface _undoStackScriptingInterface;

View file

@ -170,7 +170,7 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
void GLCanvas::dragEnterEvent(QDragEnterEvent* event) { void GLCanvas::dragEnterEvent(QDragEnterEvent* event) {
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
foreach (QUrl url, mimeData->urls()) { foreach (QUrl url, mimeData->urls()) {
auto lower = url.url().toLower(); auto lower = url.path().toLower();
if (lower.endsWith(SNAPSHOT_EXTENSION) || lower.endsWith(SVO_EXTENSION)) { if (lower.endsWith(SNAPSHOT_EXTENSION) || lower.endsWith(SVO_EXTENSION)) {
event->acceptProposedAction(); event->acceptProposedAction();
break; break;

View file

@ -697,6 +697,12 @@ void Menu::removeAction(QMenu* menu, const QString& actionName) {
} }
void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) { void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) {
if (thread() != QThread::currentThread()) {
QMetaObject::invokeMethod(Menu::getInstance(), "setIsOptionChecked", Qt::BlockingQueuedConnection,
Q_ARG(const QString&, menuOption),
Q_ARG(bool, isChecked));
return;
}
QAction* menu = _actionHash.value(menuOption); QAction* menu = _actionHash.value(menuOption);
if (menu) { if (menu) {
menu->setChecked(isChecked); menu->setChecked(isChecked);

View file

@ -49,8 +49,6 @@ using namespace std;
const glm::vec3 DEFAULT_UP_DIRECTION(0.0f, 1.0f, 0.0f); const glm::vec3 DEFAULT_UP_DIRECTION(0.0f, 1.0f, 0.0f);
const float YAW_SPEED = 500.0f; // degrees/sec const float YAW_SPEED = 500.0f; // degrees/sec
const float PITCH_SPEED = 100.0f; // degrees/sec const float PITCH_SPEED = 100.0f; // degrees/sec
const float COLLISION_RADIUS_SCALAR = 1.2f; // pertains to avatar-to-avatar collisions
const float COLLISION_RADIUS_SCALE = 0.125f;
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f; const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
const float MAX_WALKING_SPEED = 2.5f; // human walking speed const float MAX_WALKING_SPEED = 2.5f; // human walking speed

View file

@ -791,8 +791,6 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
glPopMatrix(); glPopMatrix();
} }
const int BALL_SUBDIVISIONS = 10;
bool SkeletonModel::hasSkeleton() { bool SkeletonModel::hasSkeleton() {
return isActive() ? _geometry->getFBXGeometry().rootJointIndex != -1 : false; return isActive() ? _geometry->getFBXGeometry().rootJointIndex != -1 : false;
} }

View file

@ -107,13 +107,16 @@ void TV3DManager::display(Camera& whichCamera) {
const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface); const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface);
DependencyManager::get<GlowEffect>()->prepare(); DependencyManager::get<GlowEffect>()->prepare();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
// render left side view // render left side view
glViewport(portalX, portalY, portalW, portalH); glViewport(portalX, portalY, portalW, portalH);
glScissor(portalX, portalY, portalW, portalH); glScissor(portalX, portalY, portalW, portalH);
Camera eyeCamera;
eyeCamera.setRotation(whichCamera.getRotation());
eyeCamera.setPosition(whichCamera.getPosition());
glPushMatrix(); glPushMatrix();
{ {
@ -129,7 +132,8 @@ void TV3DManager::display(Camera& whichCamera) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
Application::getInstance()->displaySide(whichCamera, false, RenderArgs::STEREO_LEFT); eyeCamera.setEyeOffsetPosition(glm::vec3(-_activeEye->modelTranslation,0,0));
Application::getInstance()->displaySide(eyeCamera, false, RenderArgs::MONO);
if (displayOverlays) { if (displayOverlays) {
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov); applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
@ -150,7 +154,7 @@ void TV3DManager::display(Camera& whichCamera) {
_activeEye = &_rightEye; _activeEye = &_rightEye;
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // reset projection matrix glLoadIdentity(); // reset projection matrix
glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set left view frustum glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set right view frustum
GLfloat p[4][4]; GLfloat p[4][4];
glGetFloatv(GL_PROJECTION_MATRIX, &(p[0][0])); glGetFloatv(GL_PROJECTION_MATRIX, &(p[0][0]));
GLfloat cotangent = p[1][1]; GLfloat cotangent = p[1][1];
@ -159,7 +163,8 @@ void TV3DManager::display(Camera& whichCamera) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
Application::getInstance()->displaySide(whichCamera, false, RenderArgs::STEREO_RIGHT); eyeCamera.setEyeOffsetPosition(glm::vec3(-_activeEye->modelTranslation,0,0));
Application::getInstance()->displaySide(eyeCamera, false, RenderArgs::MONO);
if (displayOverlays) { if (displayOverlays) {
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov); applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);

View file

@ -32,7 +32,6 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityI
_type = EntityTypes::Light; _type = EntityTypes::Light;
// default property values // default property values
const quint8 MAX_COLOR = 255;
_color[RED_INDEX] = _color[GREEN_INDEX] = _color[BLUE_INDEX] = 0; _color[RED_INDEX] = _color[GREEN_INDEX] = _color[BLUE_INDEX] = 0;
_intensity = 1.0f; _intensity = 1.0f;
_exponent = 0.0f; _exponent = 0.0f;

View file

@ -134,55 +134,55 @@ void EarthSunModel::setSunLongitude(float lon) {
_sunLongitude = validateLongitude(lon); _sunLongitude = validateLongitude(lon);
invalidate(); invalidate();
} }
Atmosphere::Atmosphere() { Atmosphere::Atmosphere() {
// only if created from nothing shall we create the Buffer to store the properties // only if created from nothing shall we create the Buffer to store the properties
Data data; Data data;
_dataBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Data), (const gpu::Buffer::Byte*) &data)); _dataBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Data), (const gpu::Buffer::Byte*) &data));
setScatteringWavelength(_scatteringWavelength); setScatteringWavelength(_scatteringWavelength);
setRayleighScattering(_rayleighScattering); setRayleighScattering(_rayleighScattering);
setInnerOuterRadiuses(getInnerRadius(), getOuterRadius()); setInnerOuterRadiuses(getInnerRadius(), getOuterRadius());
} }
void Atmosphere::setScatteringWavelength(Vec3 wavelength) { void Atmosphere::setScatteringWavelength(Vec3 wavelength) {
_scatteringWavelength = wavelength; _scatteringWavelength = wavelength;
Data& data = editData(); Data& data = editData();
data._invWaveLength = Vec4(1.0f / powf(wavelength.x, 4.0f), 1.0f / powf(wavelength.y, 4.0f), 1.0f / powf(wavelength.z, 4.0f), 0.0f); data._invWaveLength = Vec4(1.0f / powf(wavelength.x, 4.0f), 1.0f / powf(wavelength.y, 4.0f), 1.0f / powf(wavelength.z, 4.0f), 0.0f);
} }
void Atmosphere::setRayleighScattering(float scattering) {
_rayleighScattering = scattering;
updateScattering();
}
void Atmosphere::setMieScattering(float scattering) {
_mieScattering = scattering;
updateScattering();
}
void Atmosphere::setSunBrightness(float brightness) {
_sunBrightness = brightness;
updateScattering();
}
void Atmosphere::updateScattering() { void Atmosphere::setRayleighScattering(float scattering) {
Data& data = editData(); _rayleighScattering = scattering;
updateScattering();
data._scatterings.x = getRayleighScattering() * getSunBrightness(); }
data._scatterings.y = getMieScattering() * getSunBrightness();
data._scatterings.z = getRayleighScattering() * 4.0f * glm::pi<float>();
data._scatterings.w = getMieScattering() * 4.0f * glm::pi<float>();
}
void Atmosphere::setInnerOuterRadiuses(float inner, float outer) { void Atmosphere::setMieScattering(float scattering) {
Data& data = editData(); _mieScattering = scattering;
data._radiuses.x = inner; updateScattering();
data._radiuses.y = outer; }
data._scales.x = 1.0f / (outer - inner);
data._scales.z = data._scales.x / data._scales.y; void Atmosphere::setSunBrightness(float brightness) {
} _sunBrightness = brightness;
updateScattering();
}
void Atmosphere::updateScattering() {
Data& data = editData();
data._scatterings.x = getRayleighScattering() * getSunBrightness();
data._scatterings.y = getMieScattering() * getSunBrightness();
data._scatterings.z = getRayleighScattering() * 4.0f * glm::pi<float>();
data._scatterings.w = getMieScattering() * 4.0f * glm::pi<float>();
}
void Atmosphere::setInnerOuterRadiuses(float inner, float outer) {
Data& data = editData();
data._radiuses.x = inner;
data._radiuses.y = outer;
data._scales.x = 1.0f / (outer - inner);
data._scales.z = data._scales.x / data._scales.y;
}
const int NUM_DAYS_PER_YEAR = 365; const int NUM_DAYS_PER_YEAR = 365;
@ -267,7 +267,7 @@ void SunSkyStage::updateGraphicsObject() const {
static int firstTime = 0; static int firstTime = 0;
if (firstTime == 0) { if (firstTime == 0) {
firstTime++; firstTime++;
bool result = gpu::Shader::makeProgram(*(_skyPipeline->getProgram())); gpu::Shader::makeProgram(*(_skyPipeline->getProgram()));
} }

View file

@ -19,7 +19,6 @@
#include <QtCore/QUrlQuery> #include <QtCore/QUrlQuery>
#include <QtNetwork/QHttpMultiPart> #include <QtNetwork/QHttpMultiPart>
#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkRequest>
#include <QEventLoop>
#include <qthread.h> #include <qthread.h>
#include <SettingHandle.h> #include <SettingHandle.h>
@ -300,8 +299,6 @@ void AccountManager::processReply() {
passErrorToCallback(requestReply); passErrorToCallback(requestReply);
} }
delete requestReply; delete requestReply;
emit replyFinished();
} }
void AccountManager::passSuccessToCallback(QNetworkReply* requestReply) { void AccountManager::passSuccessToCallback(QNetworkReply* requestReply) {
@ -342,15 +339,6 @@ void AccountManager::passErrorToCallback(QNetworkReply* requestReply) {
} }
} }
void AccountManager::waitForAllPendingReplies() {
while (_pendingCallbackMap.size() > 0) {
QEventLoop loop;
QObject::connect(this, &AccountManager::replyFinished, &loop, &QEventLoop::quit);
loop.exec();
}
}
void AccountManager::persistAccountToSettings() { void AccountManager::persistAccountToSettings() {
if (_shouldPersistToSettingsFile) { if (_shouldPersistToSettingsFile) {
// store this access token into the local settings // store this access token into the local settings

View file

@ -72,8 +72,6 @@ public:
void requestProfile(); void requestProfile();
DataServerAccountInfo& getAccountInfo() { return _accountInfo; } DataServerAccountInfo& getAccountInfo() { return _accountInfo; }
void waitForAllPendingReplies();
public slots: public slots:
void requestAccessToken(const QString& login, const QString& password); void requestAccessToken(const QString& login, const QString& password);
@ -95,8 +93,6 @@ signals:
void loginFailed(); void loginFailed();
void logoutComplete(); void logoutComplete();
void balanceChanged(qint64 newBalance); void balanceChanged(qint64 newBalance);
void replyFinished();
private slots: private slots:
void processReply(); void processReply();
void handleKeypairGenerationError(); void handleKeypairGenerationError();

View file

@ -80,6 +80,10 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
connect(localSocketUpdate, &QTimer::timeout, this, &LimitedNodeList::updateLocalSockAddr); connect(localSocketUpdate, &QTimer::timeout, this, &LimitedNodeList::updateLocalSockAddr);
localSocketUpdate->start(LOCAL_SOCKET_UPDATE_INTERVAL_MSECS); localSocketUpdate->start(LOCAL_SOCKET_UPDATE_INTERVAL_MSECS);
QTimer* silentNodeTimer = new QTimer(this);
connect(silentNodeTimer, &QTimer::timeout, this, &LimitedNodeList::removeSilentNodes);
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
// check the local socket right now // check the local socket right now
updateLocalSockAddr(); updateLocalSockAddr();
@ -500,6 +504,7 @@ void LimitedNodeList::resetPacketStats() {
} }
void LimitedNodeList::removeSilentNodes() { void LimitedNodeList::removeSilentNodes() {
QSet<SharedNodePointer> killedNodes; QSet<SharedNodePointer> killedNodes;
eachNodeHashIterator([&](NodeHash::iterator& it){ eachNodeHashIterator([&](NodeHash::iterator& it){

View file

@ -223,6 +223,8 @@ protected:
HifiSockAddr _localSockAddr; HifiSockAddr _localSockAddr;
HifiSockAddr _publicSockAddr; HifiSockAddr _publicSockAddr;
HifiSockAddr _stunSockAddr; HifiSockAddr _stunSockAddr;
QTimer* _silentNodeTimer;
// XXX can BandwidthRecorder be used for this? // XXX can BandwidthRecorder be used for this?
int _numCollectedPackets; int _numCollectedPackets;

View file

@ -37,6 +37,7 @@ const quint64 DOMAIN_SERVER_CHECK_IN_MSECS = 1 * 1000;
const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5; const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
class Application;
class Assignment; class Assignment;
class NodeList : public LimitedNodeList { class NodeList : public LimitedNodeList {
@ -95,6 +96,8 @@ private:
HifiSockAddr _assignmentServerSocket; HifiSockAddr _assignmentServerSocket;
bool _hasCompletedInitialSTUNFailure; bool _hasCompletedInitialSTUNFailure;
unsigned int _stunRequestsSinceSuccess; unsigned int _stunRequestsSinceSuccess;
friend class Application;
}; };
#endif // hifi_NodeList_h #endif // hifi_NodeList_h

View file

@ -67,10 +67,6 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy
connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit())); connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
QTimer* silentNodeRemovalTimer = new QTimer(this);
connect(silentNodeRemovalTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
silentNodeRemovalTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
if (shouldSendStats) { if (shouldSendStats) {
// send a stats packet every 1 second // send a stats packet every 1 second
QTimer* statsTimer = new QTimer(this); QTimer* statsTimer = new QTimer(this);

View file

@ -61,7 +61,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
params.errorCallbackReceiver = this; params.errorCallbackReceiver = this;
params.errorCallbackMethod = "requestError"; params.errorCallbackMethod = "requestError";
} }
accountManager.authenticatedRequest(USER_ACTIVITY_URL, accountManager.authenticatedRequest(USER_ACTIVITY_URL,
QNetworkAccessManager::PostOperation, QNetworkAccessManager::PostOperation,
params, params,
@ -86,13 +86,6 @@ void UserActivityLogger::launch(QString applicationVersion) {
logAction(ACTION_NAME, actionDetails); logAction(ACTION_NAME, actionDetails);
} }
void UserActivityLogger::close() {
const QString ACTION_NAME = "close";
logAction(ACTION_NAME, QJsonObject());
AccountManager::getInstance().waitForAllPendingReplies();
}
void UserActivityLogger::changedDisplayName(QString displayName) { void UserActivityLogger::changedDisplayName(QString displayName) {
const QString ACTION_NAME = "changed_display_name"; const QString ACTION_NAME = "changed_display_name";
QJsonObject actionDetails; QJsonObject actionDetails;

View file

@ -30,7 +30,7 @@ public slots:
void logAction(QString action, QJsonObject details = QJsonObject(), JSONCallbackParameters params = JSONCallbackParameters()); void logAction(QString action, QJsonObject details = QJsonObject(), JSONCallbackParameters params = JSONCallbackParameters());
void launch(QString applicationVersion); void launch(QString applicationVersion);
void close();
void changedDisplayName(QString displayName); void changedDisplayName(QString displayName);
void changedModel(QString typeOfModel, QString modelURL); void changedModel(QString typeOfModel, QString modelURL);
void changedDomain(QString domainURL); void changedDomain(QString domainURL);

View file

@ -17,9 +17,11 @@ using namespace meshinfo;
//origin is the default reference point for generating the tetrahedron from each triangle of the mesh. //origin is the default reference point for generating the tetrahedron from each triangle of the mesh.
MeshInfo::MeshInfo(vector<Vertex> *vertices, vector<int> *triangles) :\ MeshInfo::MeshInfo(vector<Vertex> *vertices, vector<int> *triangles) :\
_vertices(vertices), _vertices(vertices),
_triangles(triangles), _centerOfMass(Vertex(0.0, 0.0, 0.0)),
_centerOfMass(Vertex(0.0, 0.0, 0.0)){ _triangles(triangles)
{
} }
MeshInfo::~MeshInfo(){ MeshInfo::~MeshInfo(){