diff --git a/examples/defaultScripts.js b/examples/defaultScripts.js index ea13694f0c..65682deb74 100644 --- a/examples/defaultScripts.js +++ b/examples/defaultScripts.js @@ -17,3 +17,4 @@ Script.load("headMove.js"); Script.load("inspect.js"); Script.load("lobby.js"); Script.load("notifications.js"); +Script.load("lookWithMouse.js") diff --git a/examples/editEntities.js b/examples/editEntities.js index 3a70d2020e..220f10dffa 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -46,28 +46,8 @@ gridTool.setVisible(false); var entityListTool = EntityListTool(); -var hasShownPropertiesTool = false; - -var entityListVisible = false; - selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); - if (selectionManager.hasSelection() && !hasShownPropertiesTool) { - // Open properties and model list, but force selection of model list tab - propertiesTool.setVisible(false); - entityListTool.setVisible(false); - gridTool.setVisible(false); - propertiesTool.setVisible(true); - entityListTool.setVisible(true); - gridTool.setVisible(true); - Window.setFocus(); - hasShownPropertiesTool = true; - } - if (!selectionManager.hasSelection()) { - toolBar.setActive(false); - } else { - toolBar.setActive(true); - } }); var windowDimensions = Controller.getViewportDimensions(); @@ -94,9 +74,11 @@ var DEFAULT_DIMENSIONS = { }; var MENU_INSPECT_TOOL_ENABLED = "Inspect Tool"; +var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select"; var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled"; +var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var modelURLs = [ @@ -138,10 +120,9 @@ var toolBar = (function () { // Hide active button for now - this may come back, so not deleting yet. activeButton = toolBar.addTool({ imageURL: toolIconUrl + "models-tool.svg", - // subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, - subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: 0, height: 0 }, - width: 0,//toolWidth, - height: 0,//toolHeight, + subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, + width: toolWidth, + height: toolHeight, alpha: 0.9, visible: true }, true, false); @@ -253,7 +234,10 @@ var toolBar = (function () { } else { hasShownPropertiesTool = false; cameraManager.enable(); - grid.setEnabled(true); + entityListTool.setVisible(true); + gridTool.setVisible(true); + propertiesTool.setVisible(true); + Window.setFocus(); } } toolBar.selectTool(activeButton, active); @@ -440,11 +424,11 @@ var toolBar = (function () { Entities.addEntity({ type: "Text", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), - dimensions: DEFAULT_DIMENSIONS, - backgroundColor: { red: 0, green: 0, blue: 0 }, + dimensions: { x: 0.5, y: 0.3, z: 0.01 }, + backgroundColor: { red: 64, green: 64, blue: 64 }, textColor: { red: 255, green: 255, blue: 255 }, text: "some text", - lineHight: "0.1" + lineHeight: 0.06 }); } else { print("Can't create box: Text would be out of bounds."); @@ -535,7 +519,7 @@ function mousePressEvent(event) { if (result !== null) { var currentProperties = Entities.getEntityProperties(result.entityID); cameraManager.enable(); - cameraManager.focus(currentProperties.position, null, true); + cameraManager.focus(currentProperties.position, null, Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); cameraManager.mousePressEvent(event); } } else { @@ -551,6 +535,9 @@ var idleMouseTimerId = null; var IDLE_MOUSE_TIMEOUT = 200; function mouseMoveEvent(event) { + if (!isActive) { + return; + } if (idleMouseTimerId) { Script.clearTimeout(idleMouseTimerId); } @@ -618,7 +605,7 @@ function mouseReleaseEvent(event) { } function mouseClickEvent(event) { - if (!event.isRightButton) { + if (!event.isLeftButton || !isActive) { return; } @@ -681,9 +668,11 @@ function mouseClickEvent(event) { print("Model selected: " + foundEntity.id); selectionDisplay.select(selectedEntityID, event); - cameraManager.focus(selectionManager.worldPosition, - selectionManager.worldDimensions, - true); + if (Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)) { + cameraManager.focus(selectionManager.worldPosition, + selectionManager.worldDimensions, + Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + } } } } @@ -725,7 +714,9 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); - Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED, + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_AUTO_FOCUS_ON_SELECT, afterItem: MENU_INSPECT_TOOL_ENABLED, + isCheckable: true, isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) == "true" }); + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_AUTO_FOCUS_ON_SELECT, isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" }); Entities.setLightsArePickable(false); @@ -751,11 +742,12 @@ function cleanupModelMenus() { Menu.removeMenuItem("File", "Import Models"); Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); + Menu.removeMenuItem("View", MENU_AUTO_FOCUS_ON_SELECT); Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS); } Script.scriptEnding.connect(function() { - Settings.setValue(SETTING_INSPECT_TOOL_ENABLED, Menu.isOptionChecked(MENU_INSPECT_TOOL_ENABLED)); + Settings.setValue(SETTING_AUTO_FOCUS_ON_SELECT, Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)); Settings.setValue(SETTING_EASE_ON_FOCUS, Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); progressDialog.cleanup(); diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index bf5bf6b105..bbd28dd38a 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -15,11 +15,11 @@ var MOUSE_SENSITIVITY = 0.9; var SCROLL_SENSITIVITY = 0.05; var PAN_ZOOM_SCALE_RATIO = 0.4; -var KEY_ORBIT_SENSITIVITY = 40; -var KEY_ZOOM_SENSITIVITY = 10; +var KEY_ORBIT_SENSITIVITY = 90; +var KEY_ZOOM_SENSITIVITY = 3; -// Scaling applied based on the size of the object being focused -var FOCUS_ZOOM_SCALE = 1.3; +// Scaling applied based on the size of the object being focused (Larger values focus further away) +var FOCUS_ZOOM_SCALE = 2.3; // Minimum zoom level when focusing on an object var FOCUS_MIN_ZOOM = 0.5; @@ -433,8 +433,13 @@ CameraManager = function() { that.targetYaw += (actions.orbitRight - actions.orbitLeft) * dt * KEY_ORBIT_SENSITIVITY; that.targetPitch += (actions.orbitUp - actions.orbitDown) * dt * KEY_ORBIT_SENSITIVITY; that.targetPitch = clamp(that.targetPitch, -90, 90); - that.targetZoomDistance += (actions.orbitBackward - actions.orbitForward) * dt * KEY_ZOOM_SENSITIVITY; - that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE); + + var dZoom = actions.orbitBackward - actions.orbitForward; + if (dZoom) { + dZoom *= that.targetZoomDistance * dt * KEY_ZOOM_SENSITIVITY; + that.targetZoomDistance += dZoom; + that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE); + } if (easing) { diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 4b931f0c57..85be97b1ce 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -1221,7 +1221,7 @@ SelectionDisplay = (function () { x: selectionManager.worldDimensions.x, y: selectionManager.worldDimensions.z }, - rotation: Quat.fromPitchYawRollDegrees(0, 0, 0), + rotation: Quat.fromPitchYawRollDegrees(90, 0, 0), }); diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 5ae6d4e7e7..9f569c9893 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -152,23 +152,13 @@ void AudioClient::audioMixerKilled() { QAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& deviceName) { QAudioDeviceInfo result; -// Temporarily enable audio device selection in Windows again to test how it behaves now -//#ifdef WIN32 -#if FALSE - // NOTE - // this is a workaround for a windows only QtBug https://bugreports.qt-project.org/browse/QTBUG-16117 - // static QAudioDeviceInfo objects get deallocated when QList objects go out of scope - result = (mode == QAudio::AudioInput) ? - QAudioDeviceInfo::defaultInputDevice() : - QAudioDeviceInfo::defaultOutputDevice(); -#else foreach(QAudioDeviceInfo audioDevice, QAudioDeviceInfo::availableDevices(mode)) { if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) { result = audioDevice; break; } } -#endif + return result; } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index a0a8a33ca8..fa64540c4e 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -228,7 +228,7 @@ void EntityTree::setSimulation(EntitySimulation* simulation) { _simulation = simulation; } -void EntityTree::deleteEntity(const EntityItemID& entityID) { +void EntityTree::deleteEntity(const EntityItemID& entityID, bool force) { EntityTreeElement* containingElement = getContainingElement(entityID); if (!containingElement) { qDebug() << "UNEXPECTED!!!! EntityTree::deleteEntity() entityID doesn't exist!!! entityID=" << entityID; @@ -241,7 +241,7 @@ void EntityTree::deleteEntity(const EntityItemID& entityID) { return; } - if (existingEntity->getLocked()) { + if (existingEntity->getLocked() && !force) { qDebug() << "ERROR! EntityTree::deleteEntity() trying to delete locked entity. entityID=" << entityID; return; } @@ -255,7 +255,7 @@ void EntityTree::deleteEntity(const EntityItemID& entityID) { _isDirty = true; } -void EntityTree::deleteEntities(QSet entityIDs) { +void EntityTree::deleteEntities(QSet entityIDs, bool force) { // NOTE: callers must lock the tree before using this method DeleteEntityOperator theOperator(this); foreach(const EntityItemID& entityID, entityIDs) { @@ -271,7 +271,7 @@ void EntityTree::deleteEntities(QSet entityIDs) { continue; } - if (existingEntity->getLocked()) { + if (existingEntity->getLocked() && !force) { qDebug() << "ERROR! EntityTree::deleteEntities() trying to delete locked entity. entityID=" << entityID; continue; } @@ -667,7 +667,7 @@ void EntityTree::update() { foreach (EntityItem* entity, entitiesToDelete) { idsToDelete.insert(entity->getEntityItemID()); } - deleteEntities(idsToDelete); + deleteEntities(idsToDelete, true); } unlock(); } diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 405cbecd99..b4621f1a10 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -91,8 +91,8 @@ public: // use this method if you have a pointer to the entity (avoid an extra entity lookup) bool updateEntity(EntityItem* entity, const EntityItemProperties& properties); - void deleteEntity(const EntityItemID& entityID); - void deleteEntities(QSet entityIDs); + void deleteEntity(const EntityItemID& entityID, bool force = false); + void deleteEntities(QSet entityIDs, bool force = false); void removeEntityFromSimulation(EntityItem* entity); const EntityItem* findClosestEntity(glm::vec3 position, float targetRadius); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 91e09d61fc..d6e4a610df 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -398,25 +398,27 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) { SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) { - try { - SharedNodePointer matchingNode = _nodeHash.at(uuid); + NodeHash::const_iterator it = _nodeHash.find(uuid); + + if (it != _nodeHash.end()) { + SharedNodePointer& matchingNode = it->second; matchingNode->setPublicSocket(publicSocket); matchingNode->setLocalSocket(localSocket); return matchingNode; - } catch (std::out_of_range) { + } else { // we didn't have this node, so add them Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket); - SharedNodePointer newNodeSharedPointer(newNode, &QObject::deleteLater); + SharedNodePointer newNodePointer(newNode); - _nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodeSharedPointer)); + _nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer)); qDebug() << "Added" << *newNode; - emit nodeAdded(newNodeSharedPointer); + emit nodeAdded(newNodePointer); - return newNodeSharedPointer; + return newNodePointer; } } diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 9d61129d78..613eb93228 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -248,11 +248,7 @@ void Resource::allReferencesCleared() { _cache->addUnusedResource(self); } else { -#ifndef WIN32 - // Note to Andrzej this causes a consistent crash on windows/vs2013 - // patching here as a very temporary workaround. --craig delete this; -#endif // !WIN32 } }