From 6e8267999754d846aa446c4c4807a6416695071d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 2 Feb 2015 11:19:11 -0800 Subject: [PATCH 01/20] Permanently re-enable audio selection on Windows --- interface/src/Audio.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 2bc5aa5023..6dd9b7985c 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -134,23 +134,13 @@ void Audio::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; } From c1ae98fa1ad5595ba8c8729f642a80c2e0583860 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 2 Feb 2015 15:02:29 -0800 Subject: [PATCH 02/20] quiet some compiler warnings about signed vs unsigned comparisons --- interface/src/Audio.h | 2 +- interface/src/devices/MotionTracker.h | 2 +- interface/src/scripting/ControllerScriptingInterface.h | 2 +- libraries/gpu/src/gpu/Texture.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Audio.h b/interface/src/Audio.h index d815b3035c..be374de959 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -212,7 +212,7 @@ private: bool _outputStarveDetectionEnabled; quint64 _outputStarveDetectionStartTimeMsec; int _outputStarveDetectionCount; - int _outputStarveDetectionPeriodMsec; + uint _outputStarveDetectionPeriodMsec; int _outputStarveDetectionThreshold; // Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size diff --git a/interface/src/devices/MotionTracker.h b/interface/src/devices/MotionTracker.h index 42ddc6768c..84b909d4fd 100644 --- a/interface/src/devices/MotionTracker.h +++ b/interface/src/devices/MotionTracker.h @@ -37,7 +37,7 @@ public: // Semantic and Index types to retreive the JointTrackers of this MotionTracker typedef std::string Semantic; - typedef int Index; + typedef uint Index; static const Index INVALID_SEMANTIC = -1; static const Index INVALID_PARENT = -2; diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h index 29921008e6..d56d159c06 100644 --- a/interface/src/scripting/ControllerScriptingInterface.h +++ b/interface/src/scripting/ControllerScriptingInterface.h @@ -38,7 +38,7 @@ public slots: private: int _deviceTrackerId; - int _subTrackerId; + uint _subTrackerId; // cache for the spatial SpatialEvent _eventCache; diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index f9fbcb72df..7615c599b0 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -175,7 +175,7 @@ Texture::Size Texture::resize(Type type, const Element& texelFormat, uint16 widt // Evaluate the new size with the new format const int DIM_SIZE[] = {1, 1, 1, 6}; - int size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize(); + uint size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize(); // If size change then we need to reset if (changed || (size != getSize())) { From c97eb20d6968c5a00ed9b11798a4160e793bfd31 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 3 Feb 2015 17:11:10 -0800 Subject: [PATCH 03/20] avoid use of sprintf in overlay code --- interface/src/ui/Stats.cpp | 106 +++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 56 deletions(-) diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index dd179cc7c0..4919f4fc62 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -256,25 +256,20 @@ void Stats::display( int columnOneHorizontalOffset = horizontalOffset; - char serverNodes[30]; - sprintf(serverNodes, "Servers: %d", totalServers); - char avatarNodes[30]; - sprintf(avatarNodes, "Avatars: %d", totalAvatars); - char framesPerSecond[30]; - sprintf(framesPerSecond, "Framerate: %3.0f FPS", fps); + QString serverNodes = QString("Servers: %1").arg(totalServers); + QString avatarNodes = QString("Avatars: %1").arg(totalAvatars); + QString framesPerSecond = QString("Framerate: %1 FPS").arg(fps, 3, 'f', 0); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, serverNodes, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, serverNodes.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond.toUtf8().constData(), color); // TODO: the display of these timing details should all be moved to JavaScript if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) { // Timing details... - const int TIMER_OUTPUT_LINE_LENGTH = 1000; - char perfLine[TIMER_OUTPUT_LINE_LENGTH]; verticalOffset += STATS_PELS_PER_LINE * 4; // skip 4 lines to be under the other columns drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font, "-------------------------------------------------------- Function " @@ -301,12 +296,13 @@ void Stats::display( QString functionName = j.value(); const PerformanceTimerRecord& record = allRecords.value(functionName); - sprintf(perfLine, "%120s: %8.4f [%6llu]", qPrintable(functionName), - (float)record.getMovingAverage() / (float)USECS_PER_MSEC, - record.getCount()); - + QString perfLine = QString("%1: %2 [%3]"). + arg(QString(qPrintable(functionName)), 120). + arg((float)record.getMovingAverage() / (float)USECS_PER_MSEC, 8, 'f', 3). + arg(record.getCount(), 6); + verticalOffset += STATS_PELS_PER_LINE; - drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font, perfLine, color); + drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font, perfLine.toUtf8().constData(), color); } } @@ -320,17 +316,15 @@ void Stats::display( } horizontalOffset += 5; - char packetsPerSecondString[30]; - sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond); - char averageMegabitsPerSecond[30]; - sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f", - (float)inKbitsPerSecond * 1.0f / 1000.0f, - (float)outKbitsPerSecond * 1.0f / 1000.0f); + QString packetsPerSecondString = QString("Packets In/Out: %1/%2").arg(inPacketsPerSecond).arg(outPacketsPerSecond); + QString averageMegabitsPerSecond = QString("Mbps In/Out: %1/%2"). + arg((float)inKbitsPerSecond * 1.0f / 1000.0f). + arg((float)outKbitsPerSecond * 1.0f / 1000.0f); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond.toUtf8().constData(), color); @@ -375,44 +369,44 @@ void Stats::display( horizontalOffset += 5; - char audioPing[30]; + QString audioPing; if (pingAudio >= 0) { - sprintf(audioPing, "Audio ping: %d", pingAudio); + audioPing = QString("Audio ping: %1").arg(pingAudio); } else { - sprintf(audioPing, "Audio ping: --"); + audioPing = QString("Audio ping: --"); } - char avatarPing[30]; + QString avatarPing; if (pingAvatar >= 0) { - sprintf(avatarPing, "Avatar ping: %d", pingAvatar); + avatarPing = QString("Avatar ping: %1").arg(pingAvatar); } else { - sprintf(avatarPing, "Avatar ping: --"); + avatarPing = QString("Avatar ping: --"); } - char voxelAvgPing[30]; + QString voxelAvgPing; if (pingVoxel >= 0) { - sprintf(voxelAvgPing, "Entities avg ping: %d", pingVoxel); + voxelAvgPing = QString("Entities avg ping: %1").arg(pingVoxel); } else { - sprintf(voxelAvgPing, "Entities avg ping: --"); + voxelAvgPing = QString("Entities avg ping: --"); } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, audioPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, audioPing.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPing.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelAvgPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelAvgPing.toUtf8().constData(), color); if (_expanded) { - char voxelMaxPing[30]; + QString voxelMaxPing; if (pingVoxel >= 0) { // Average is only meaningful if pingVoxel is valid. - sprintf(voxelMaxPing, "Voxel max ping: %d", pingOctreeMax); + voxelMaxPing = QString("Voxel max ping: %1").arg(pingOctreeMax); } else { - sprintf(voxelMaxPing, "Voxel max ping: --"); + voxelMaxPing = QString("Voxel max ping: --"); } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelMaxPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelMaxPing.toUtf8().constData(), color); } verticalOffset = 0; @@ -429,35 +423,35 @@ void Stats::display( } horizontalOffset += 5; - char avatarPosition[200]; - sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z); - char avatarVelocity[30]; - sprintf(avatarVelocity, "Velocity: %.1f", glm::length(myAvatar->getVelocity())); - char avatarBodyYaw[30]; - sprintf(avatarBodyYaw, "Yaw: %.1f", myAvatar->getBodyYaw()); - char avatarMixerStats[200]; + QString avatarPosition = QString("Position: %1, %2, %3"). + arg(avatarPos.x, -1, 'f', 1). + arg(avatarPos.y, -1, 'f', 1). + arg(avatarPos.z, -1, 'f', 1); + QString avatarVelocity = QString("Velocity: %1").arg(glm::length(myAvatar->getVelocity()), -1, 'f', 1); + QString avatarBodyYaw = QString("Yaw: %1").arg(myAvatar->getBodyYaw(), -1, 'f', 1); + QString avatarMixerStats; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPosition, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPosition.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarVelocity, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarVelocity.toUtf8().constData(), color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarBodyYaw, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarBodyYaw.toUtf8().constData(), color); if (_expanded) { SharedNodePointer avatarMixer = DependencyManager::get()->soloNodeOfType(NodeType::AvatarMixer); if (avatarMixer) { - sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", - roundf(bandwidthRecorder->getAverageInputKilobitsPerSecond(NodeType::AudioMixer) + - bandwidthRecorder->getAverageOutputKilobitsPerSecond(NodeType::AudioMixer)), - roundf(bandwidthRecorder->getAverageInputPacketsPerSecond(NodeType::AudioMixer) + + avatarMixerStats = QString("Avatar Mixer: %1 kbps, %1 pps"). + arg(roundf(bandwidthRecorder->getAverageInputKilobitsPerSecond(NodeType::AudioMixer) + + bandwidthRecorder->getAverageOutputKilobitsPerSecond(NodeType::AudioMixer))). + arg(roundf(bandwidthRecorder->getAverageInputPacketsPerSecond(NodeType::AudioMixer) + bandwidthRecorder->getAverageOutputPacketsPerSecond(NodeType::AudioMixer))); } else { - sprintf(avatarMixerStats, "No Avatar Mixer"); + avatarMixerStats = QString("No Avatar Mixer"); } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarMixerStats, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarMixerStats.toUtf8().constData(), color); stringstream downloads; downloads << "Downloads: "; From 3d23446dcbd423696f72f2cb1ac699eac4b67ee7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 3 Feb 2015 17:21:41 -0800 Subject: [PATCH 04/20] remove a couple more sprintfs --- interface/src/ui/ApplicationOverlay.cpp | 5 ++--- interface/src/ui/OctreeStatsDialog.cpp | 5 ++--- interface/src/ui/Stats.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 0eeac9a90e..6e95327165 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -929,14 +929,13 @@ void ApplicationOverlay::renderStatsAndLogs() { // Show on-screen msec timer if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { - char frameTimer[10]; quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); - sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); + QString frameTimer = QString("%1\n").arg((int)(mSecsNow % 1000)); int timerBottom = (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) ? 80 : 20; drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom, - 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT); + 0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT); } nodeBoundsDisplay.drawOverlay(); } diff --git a/interface/src/ui/OctreeStatsDialog.cpp b/interface/src/ui/OctreeStatsDialog.cpp index 44b7ea553e..d9c8124180 100644 --- a/interface/src/ui/OctreeStatsDialog.cpp +++ b/interface/src/ui/OctreeStatsDialog.cpp @@ -236,9 +236,8 @@ void OctreeStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t ser serverCount++; if (serverCount > _octreeServerLabelsCount) { - char label[128] = { 0 }; - sprintf(label, "%s Server %d", serverTypeName, serverCount); - int thisServerRow = _octreeServerLables[serverCount-1] = AddStatItem(label); + QString label = QString("%1 Server %2").arg(serverTypeName).arg(serverCount); + int thisServerRow = _octreeServerLables[serverCount-1] = AddStatItem(label.toUtf8().constData()); _labels[thisServerRow]->setTextFormat(Qt::RichText); _labels[thisServerRow]->setTextInteractionFlags(Qt::TextBrowserInteraction); connect(_labels[thisServerRow], SIGNAL(linkActivated(const QString&)), this, SLOT(moreless(const QString&))); diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 4919f4fc62..05faf991b6 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -441,7 +441,7 @@ void Stats::display( if (_expanded) { SharedNodePointer avatarMixer = DependencyManager::get()->soloNodeOfType(NodeType::AvatarMixer); if (avatarMixer) { - avatarMixerStats = QString("Avatar Mixer: %1 kbps, %1 pps"). + avatarMixerStats = QString("Avatar Mixer: %1 kbps, %2 pps"). arg(roundf(bandwidthRecorder->getAverageInputKilobitsPerSecond(NodeType::AudioMixer) + bandwidthRecorder->getAverageOutputKilobitsPerSecond(NodeType::AudioMixer))). arg(roundf(bandwidthRecorder->getAverageInputPacketsPerSecond(NodeType::AudioMixer) + From ee49ce08cb8bae9a180795dc2cf299654db11621 Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Wed, 4 Feb 2015 09:53:38 -0800 Subject: [PATCH 05/20] Added the script look with mouse to default script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Look with touch does not work on PC’s or any mouse that does not accept two finger touch. I have therefore added look with mouse to default scripts. --- examples/defaultScripts.js | 1 + 1 file changed, 1 insertion(+) 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") From a2002d169f5a1807c20417c9d777ed3d7f4889ab Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 Feb 2015 10:27:33 -0800 Subject: [PATCH 06/20] fix for exception handled lookup in LimitedNodeList --- libraries/networking/src/LimitedNodeList.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 4957084279..06b3b6a0db 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -412,25 +412,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; } } From 01a00b51278a3666d76e2703e65e5337afad855f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:40:50 -0800 Subject: [PATCH 07/20] Disable editEntities always-on --- examples/editEntities.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3a70d2020e..3686134a88 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(); From 4fbc7a5dcdd13079ed7ab7cdc4299a9f26c82a61 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:42:01 -0800 Subject: [PATCH 08/20] Add focus easing and auto-focus to menu and settings --- examples/editEntities.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3686134a88..4cc317e8b6 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -74,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 = [ @@ -515,7 +517,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 { @@ -661,9 +663,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)); + } } } } @@ -705,7 +709,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); @@ -731,11 +737,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(); From 09752589b83a166b4bff8e9e72ec31de53e125b5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:43:28 -0800 Subject: [PATCH 09/20] Reenable on/off button --- examples/editEntities.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 4cc317e8b6..9c4c9a5776 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -120,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); @@ -235,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); From 36238bb5dfb30873c623da0dbeaac596a8b476a8 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:43:55 -0800 Subject: [PATCH 10/20] Update editEntities to use left click for select --- examples/editEntities.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 9c4c9a5776..c0c74b8f33 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -535,6 +535,9 @@ var idleMouseTimerId = null; var IDLE_MOUSE_TIMEOUT = 200; function mouseMoveEvent(event) { + if (!isActive) { + return; + } if (idleMouseTimerId) { Script.clearTimeout(idleMouseTimerId); } @@ -602,7 +605,7 @@ function mouseReleaseEvent(event) { } function mouseClickEvent(event) { - if (!event.isRightButton) { + if (!event.isLeftButton || !isActive) { return; } From 02d828443b6290cae5297277b5b0988e3d08e97f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:44:54 -0800 Subject: [PATCH 11/20] Update zoom sensitivity when using keys --- examples/libraries/entityCameraTool.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index bf5bf6b105..947da45594 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -15,8 +15,8 @@ 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; @@ -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) { From ded035094a5286dbc1116c51a2e289d4340b03af Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 4 Feb 2015 10:45:04 -0800 Subject: [PATCH 12/20] actually delete resources... even on windows --- libraries/networking/src/ResourceCache.cpp | 4 ---- 1 file changed, 4 deletions(-) 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 } } From 3af025574f0c3eeb7b55554ffbae8347865f537c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:45:07 -0800 Subject: [PATCH 13/20] Decrease distance from object when focusing --- examples/libraries/entityCameraTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index 947da45594..bbd28dd38a 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -18,8 +18,8 @@ var PAN_ZOOM_SCALE_RATIO = 0.4; 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; From 2b00e3fadc61872b005e9dff072b16d2ecdf16d8 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:49:49 -0800 Subject: [PATCH 14/20] Add force option to deleteEntity --- libraries/entities/src/EntityTree.cpp | 10 +++++----- libraries/entities/src/EntityTree.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) 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); From a645d784d8a66bb1e4298449916689a8f1ece228 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 4 Feb 2015 11:26:05 -0800 Subject: [PATCH 15/20] uint32_t rather than uint, which mac doesn't like --- interface/src/Audio.h | 2 +- interface/src/devices/MotionTracker.h | 2 +- libraries/audio/src/AudioFilterBank.h | 2 +- libraries/gpu/src/gpu/Texture.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Audio.h b/interface/src/Audio.h index be374de959..7b7031d3cb 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -212,7 +212,7 @@ private: bool _outputStarveDetectionEnabled; quint64 _outputStarveDetectionStartTimeMsec; int _outputStarveDetectionCount; - uint _outputStarveDetectionPeriodMsec; + uint32_t _outputStarveDetectionPeriodMsec; int _outputStarveDetectionThreshold; // Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size diff --git a/interface/src/devices/MotionTracker.h b/interface/src/devices/MotionTracker.h index 84b909d4fd..6db4374fdf 100644 --- a/interface/src/devices/MotionTracker.h +++ b/interface/src/devices/MotionTracker.h @@ -37,7 +37,7 @@ public: // Semantic and Index types to retreive the JointTrackers of this MotionTracker typedef std::string Semantic; - typedef uint Index; + typedef uint32_t Index; static const Index INVALID_SEMANTIC = -1; static const Index INVALID_PARENT = -2; diff --git a/libraries/audio/src/AudioFilterBank.h b/libraries/audio/src/AudioFilterBank.h index c5f0c4c171..723fa6b270 100644 --- a/libraries/audio/src/AudioFilterBank.h +++ b/libraries/audio/src/AudioFilterBank.h @@ -52,7 +52,7 @@ public: AudioFilterBank() : _sampleRate(0.0f), _frameCount(0) { - for (int i = 0; i < _channelCount; ++i) { + for (uint32_t i = 0; i < _channelCount; ++i) { _buffer[ i ] = NULL; } } diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 7615c599b0..33df50042e 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -175,7 +175,7 @@ Texture::Size Texture::resize(Type type, const Element& texelFormat, uint16 widt // Evaluate the new size with the new format const int DIM_SIZE[] = {1, 1, 1, 6}; - uint size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize(); + uint32_t size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize(); // If size change then we need to reset if (changed || (size != getSize())) { From 4061e14c2d11b03d47186e161dfd445b706ba3dc Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 4 Feb 2015 13:24:37 -0800 Subject: [PATCH 16/20] move static members of ResourceManager into DependencyManager --- interface/src/Application.cpp | 7 ++++++ libraries/networking/src/ResourceCache.cpp | 21 +++++++++--------- libraries/networking/src/ResourceCache.h | 25 ++++++++++++++++++---- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f1ead1ac4f..3c1806b00b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -188,6 +189,7 @@ bool setupEssentials(int& argc, char** argv) { auto jsConsole = DependencyManager::set(); auto dialogsManager = DependencyManager::set(); auto bandwidthRecorder = DependencyManager::set(); + auto resouceCacheSharedItems = DependencyManager::set(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) auto speechRecognizer = DependencyManager::set(); #endif @@ -514,6 +516,11 @@ Application::~Application() { _myAvatar = NULL; DependencyManager::destroy(); + DependencyManager::destroy(); + DependencyManager::destroy(); + DependencyManager::destroy(); + DependencyManager::destroy(); + DependencyManager::destroy(); } void Application::initializeGL() { diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 613eb93228..59275ea8e3 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -112,27 +112,31 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) { } void ResourceCache::attemptRequest(Resource* resource) { + auto sharedItems = DependencyManager::get(); if (_requestLimit <= 0) { // wait until a slot becomes available - _pendingRequests.append(resource); + sharedItems->_pendingRequests.append(resource); return; } _requestLimit--; - _loadingRequests.append(resource); + sharedItems->_loadingRequests.append(resource); resource->makeRequest(); } void ResourceCache::requestCompleted(Resource* resource) { - _loadingRequests.removeOne(resource); + + auto sharedItems = DependencyManager::get(); + sharedItems->_loadingRequests.removeOne(resource); _requestLimit++; // look for the highest priority pending request int highestIndex = -1; float highestPriority = -FLT_MAX; - for (int i = 0; i < _pendingRequests.size(); ) { - Resource* resource = _pendingRequests.at(i).data(); + int pendingRequests = sharedItems->_pendingRequests.size(); + for (int i = 0; i < pendingRequests; ) { + Resource* resource = sharedItems->_pendingRequests.at(i).data(); if (!resource) { - _pendingRequests.removeAt(i); + sharedItems->_pendingRequests.removeAt(i); continue; } float priority = resource->getLoadPriority(); @@ -143,16 +147,13 @@ void ResourceCache::requestCompleted(Resource* resource) { i++; } if (highestIndex >= 0) { - attemptRequest(_pendingRequests.takeAt(highestIndex)); + attemptRequest(sharedItems->_pendingRequests.takeAt(highestIndex)); } } const int DEFAULT_REQUEST_LIMIT = 10; int ResourceCache::_requestLimit = DEFAULT_REQUEST_LIMIT; -QList > ResourceCache::_pendingRequests; -QList ResourceCache::_loadingRequests; - Resource::Resource(const QUrl& url, bool delayLoad) : _url(url), _request(url) { diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 519b205d46..62fca71ea5 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -22,6 +22,8 @@ #include #include +#include + class QNetworkReply; class QTimer; @@ -40,6 +42,21 @@ static const qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES; static const qint64 MIN_UNUSED_MAX_SIZE = 0; static const qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES; +// We need to make sure that these items are available for all instances of +// ResourceCache derived classes. Since we can't count on the ordering of +// static members destruction, we need to use this Dependency manager implemented +// object instead +class ResouceCacheSharedItems : public Dependency { + SINGLETON_DEPENDENCY +public: + QList > _pendingRequests; + QList _loadingRequests; +private: + ResouceCacheSharedItems() { } + virtual ~ResouceCacheSharedItems() { } +}; + + /// Base class for resource caches. class ResourceCache : public QObject { Q_OBJECT @@ -51,9 +68,11 @@ public: void setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize); qint64 getUnusedResourceCacheSize() const { return _unusedResourcesMaxSize; } - static const QList& getLoadingRequests() { return _loadingRequests; } + static const QList& getLoadingRequests() + { return DependencyManager::get()->_loadingRequests; } - static int getPendingRequestCount() { return _pendingRequests.size(); } + static int getPendingRequestCount() + { return DependencyManager::get()->_pendingRequests.size(); } ResourceCache(QObject* parent = NULL); virtual ~ResourceCache(); @@ -90,8 +109,6 @@ private: int _lastLRUKey = 0; static int _requestLimit; - static QList > _pendingRequests; - static QList _loadingRequests; }; /// Base class for resources. From efed79d76cf41aae66813f403f5c5c0065a5308e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 13:37:11 -0800 Subject: [PATCH 17/20] Update the default properties for text entities --- examples/editEntities.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index c0c74b8f33..220f10dffa 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -424,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."); From 0e28f669065be93d3f1fb9ae81d23d2eee4a2f84 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 13:45:06 -0800 Subject: [PATCH 18/20] Fix rotation of selection shadow for editEntities --- examples/libraries/entitySelectionTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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), }); From 698fcd81164997dc29eaf892426c826b3e99914e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 4 Feb 2015 13:54:14 -0800 Subject: [PATCH 19/20] fix crash on shutdown --- libraries/networking/src/ResourceCache.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 59275ea8e3..7eadb0a3dd 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -132,8 +132,7 @@ void ResourceCache::requestCompleted(Resource* resource) { // look for the highest priority pending request int highestIndex = -1; float highestPriority = -FLT_MAX; - int pendingRequests = sharedItems->_pendingRequests.size(); - for (int i = 0; i < pendingRequests; ) { + for (int i = 0; i < sharedItems->_pendingRequests.size(); ) { Resource* resource = sharedItems->_pendingRequests.at(i).data(); if (!resource) { sharedItems->_pendingRequests.removeAt(i); From 8fd11e70ccb6cfcf20aeff8c9dbd6d4879896d1e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 4 Feb 2015 15:16:18 -0800 Subject: [PATCH 20/20] clamp dt for skipTimeForward to prevent near infinite loops --- libraries/entities/src/EntityItem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 690e6d2c1a..eeb7282814 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -548,7 +548,10 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef // is sending us data with a known "last simulated" time. That time is likely in the past, and therefore // this "new" data is actually slightly out of date. We calculate the time we need to skip forward and // use our simulation helper routine to get a best estimate of where the entity should be. - float skipTimeForward = (float)(now - _lastSimulated) / (float)(USECS_PER_SECOND); + const float MIN_TIME_SKIP = 0.0f; + const float MAX_TIME_SKIP = 1.0f; // in seconds + float skipTimeForward = glm::clamp((float)(now - _lastSimulated) / (float)(USECS_PER_SECOND), + MIN_TIME_SKIP, MAX_TIME_SKIP); if (skipTimeForward > 0.0f) { #ifdef WANT_DEBUG qDebug() << "skipTimeForward:" << skipTimeForward;