From 4cd1d54f15ae22dbb1e09e82a178dcee0ac1fb30 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 6 Feb 2015 21:42:58 -0800 Subject: [PATCH 01/10] Fix progress bar's SVG dimensions --- examples/progress.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/progress.js b/examples/progress.js index 6ee53c55e6..7fb2a043e2 100644 --- a/examples/progress.js +++ b/examples/progress.js @@ -23,18 +23,19 @@ fadeWaitTimer = null, FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%. visible = false, - BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar. - BAR_HEIGHT = 20, + BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar. + BAR_HEIGHT = 30, BAR_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar.svg", - BACKGROUND_WIDTH = 360, - BACKGROUND_HEIGHT = 60, - BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg", + BACKGROUND_WIDTH = 540, + BACKGROUND_HEIGHT = 90, + BACKGROUND_URL = "http://ctrlaltstudio.com/hifi/progress-bar-background.svg", + //BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg", isOnHMD = false, windowWidth = 0, windowHeight = 0, background2D = {}, bar2D = {}, - SCALE_2D = 0.55, // Scale the SVGs for 2D display. + SCALE_2D = 0.35, // Scale the SVGs for 2D display. background3D = {}, bar3D = {}, ENABLE_VR_MODE_MENU_ITEM = "Enable VR Mode", @@ -43,7 +44,7 @@ PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes. PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction. PROGRESS_3D_PITCH = -60.0, // Degrees from vertical. - SCALE_3D = 0.0017, // Scale the bar SVG for 3D display. + SCALE_3D = 0.0011, // Scale the bar SVG for 3D display. BACKGROUND_3D_SIZE = { x: 0.76, y: 0.08 }, // Match up with the 3D background with those of notifications.js notices. BACKGROUND_3D_COLOR = { red: 2, green: 2, blue: 2 }, BACKGROUND_3D_ALPHA = 0.7; From 334f26c84fc7583e5d889d8241076d51933bcae3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 6 Feb 2015 21:43:21 -0800 Subject: [PATCH 02/10] Display some progress while waiting at 0% and limit speed of advance --- examples/progress.js | 110 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 48 deletions(-) diff --git a/examples/progress.js b/examples/progress.js index 7fb2a043e2..57a1fd1a07 100644 --- a/examples/progress.js +++ b/examples/progress.js @@ -13,9 +13,13 @@ (function () { - var progress = 100, // % + var rawProgress = 100, // % raw value. + displayProgress = 100, // % smoothed value to display. + DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress. + DISPLAY_PROGRESS_MINOR_INCREMENT = 0.1, // % amount to increment display value each update when 0% raw progress. + DISPLAY_PROGRESS_MAJOR_INCREMENT = 5, // % maximum amount to increment display value when >0% raw progress. alpha = 0.0, - alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/ + alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out. ALPHA_DELTA_IN = 0.15, ALPHA_DELTA_OUT = -0.02, fadeTimer = null, @@ -90,56 +94,15 @@ function onDownloadInfoChanged(info) { var i; - // Calculate progress + // Update raw progress value if (info.downloading.length + info.pending === 0) { - progress = 100; + rawProgress = 100; } else { - progress = 0; + rawProgress = 0; for (i = 0; i < info.downloading.length; i += 1) { - progress += info.downloading[i]; + rawProgress += info.downloading[i]; } - progress = progress / (info.downloading.length + info.pending); - } - - // Update state - if (!visible) { // Not visible because no recent downloads - if (progress < 100) { // Have started downloading so fade in - visible = true; - alphaDelta = ALPHA_DELTA_IN; - fadeTimer = Script.setInterval(fade, FADE_INTERVAL); - } - } else if (alphaDelta !== 0.0) { // Fading in or out - if (alphaDelta > 0) { - if (progress === 100) { // Was donloading but now have finished so fade out - alphaDelta = ALPHA_DELTA_OUT; - } - } else { - if (progress < 100) { // Was finished downloading but have resumed so fade in - alphaDelta = ALPHA_DELTA_IN; - } - } - } else { // Fully visible because downloading or recently so - if (fadeWaitTimer === null) { - if (progress === 100) { // Was downloading but have finished so fade out soon - fadeWaitTimer = Script.setTimeout(function () { - alphaDelta = ALPHA_DELTA_OUT; - fadeTimer = Script.setInterval(fade, FADE_INTERVAL); - fadeWaitTimer = null; - }, FADE_OUT_WAIT); - } - } else { - if (progress < 100) { // Was finished and waiting to fade out but have resumed downloading so don't fade out - Script.clearInterval(fadeWaitTimer); - fadeWaitTimer = null; - } - } - } - - // Update progress bar - if (visible) { - Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, { - subImage: { x: BAR_WIDTH * (1 - progress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT } - }); + rawProgress = rawProgress / (info.downloading.length + info.pending); } } @@ -201,7 +164,58 @@ createOverlays(); } + // Calculate progress value to display + if (rawProgress === 0 && displayProgress <= DISPLAY_PROGRESS_MINOR_MAXIMUM) { + displayProgress = Math.min(displayProgress + DISPLAY_PROGRESS_MINOR_INCREMENT, DISPLAY_PROGRESS_MINOR_MAXIMUM); + } else if (rawProgress < displayProgress) { + displayProgress = rawProgress; + } else if (rawProgress > displayProgress) { + displayProgress = Math.min(rawProgress, displayProgress + DISPLAY_PROGRESS_MAJOR_INCREMENT); + } // else (rawProgress === displayProgress); do nothing. + + // Update state + if (!visible) { // Not visible because no recent downloads + if (displayProgress < 100) { // Have started downloading so fade in + visible = true; + alphaDelta = ALPHA_DELTA_IN; + fadeTimer = Script.setInterval(fade, FADE_INTERVAL); + } + } else if (alphaDelta !== 0.0) { // Fading in or out + if (alphaDelta > 0) { + if (displayProgress === 100) { // Was downloading but now have finished so fade out + alphaDelta = ALPHA_DELTA_OUT; + } + } else { + if (displayProgress < 100) { // Was finished downloading but have resumed so fade in + alphaDelta = ALPHA_DELTA_IN; + } + } + } else { // Fully visible because downloading or recently so + if (fadeWaitTimer === null) { + if (displayProgress === 100) { // Was downloading but have finished so fade out soon + fadeWaitTimer = Script.setTimeout(function () { + alphaDelta = ALPHA_DELTA_OUT; + fadeTimer = Script.setInterval(fade, FADE_INTERVAL); + fadeWaitTimer = null; + }, FADE_OUT_WAIT); + } + } else { + if (displayProgress < 100) { // Was finished and waiting to fade out but have resumed so don't fade out + Script.clearInterval(fadeWaitTimer); + fadeWaitTimer = null; + } + } + } + if (visible) { + + // Update progress bar + Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, { + visible: visible, + subImage: { x: BAR_WIDTH * (1 - displayProgress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT } + }); + + // Update position if (isOnHMD) { // Update 3D overlays to maintain positions relative to avatar eyePosition = MyAvatar.getDefaultEyePosition(); From 57797329d13e5e670cfd3954965f3d181e3927f4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:14:03 -0800 Subject: [PATCH 03/10] do sample size arithmetic before scaling by sizeof --- interface/src/audio/AudioScope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/audio/AudioScope.cpp b/interface/src/audio/AudioScope.cpp index 45820e2393..8cc27341d6 100644 --- a/interface/src/audio/AudioScope.cpp +++ b/interface/src/audio/AudioScope.cpp @@ -230,7 +230,7 @@ int AudioScope::addSilenceToScope(QByteArray* byteArray, int frameOffset, int si int samplesToBufferEnd = _samplesPerScope - frameOffset; if (silentSamples > samplesToBufferEnd) { memset(destination + frameOffset, 0, samplesToBufferEnd * sizeof(int16_t)); - memset(destination, 0, silentSamples - samplesToBufferEnd * sizeof(int16_t)); + memset(destination, 0, (silentSamples - samplesToBufferEnd) * sizeof(int16_t)); } else { memset(destination + frameOffset, 0, silentSamples * sizeof(int16_t)); } From b69ab6c80df6d6befb183a756f6af4e54faedcbd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:56:12 -0800 Subject: [PATCH 04/10] verify NodeList has a linkedData before using it --- libraries/networking/src/LimitedNodeList.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 13bb2b1ad8..4fbb1d14fe 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -309,13 +309,16 @@ int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& match matchingNode->setLastHeardMicrostamp(usecTimestampNow()); - if (!matchingNode->getLinkedData() && linkedDataCreateCallback) { + NodeData* linkedData = matchingNode->getLinkedData(); + if (!linkedData && linkedDataCreateCallback) { linkedDataCreateCallback(matchingNode.data()); } - - QMutexLocker linkedDataLocker(&matchingNode->getLinkedData()->getMutex()); - - return matchingNode->getLinkedData()->parseData(packet); + + if (linkedData) { + QMutexLocker linkedDataLocker(&linkedData->getMutex()); + return linkedData->parseData(packet); + } + return 0; } int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packet) { From 0de598586cb2d0962d3a4c66973417941ae8fc83 Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:37:23 +0100 Subject: [PATCH 05/10] removed id "g3322" in start-script.svg because it is no longer used and causes a "link rect899 hasn't been detected!" message on script editor open. --- interface/resources/icons/start-script.svg | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/interface/resources/icons/start-script.svg b/interface/resources/icons/start-script.svg index 86354a555d..1401853fe4 100644 --- a/interface/resources/icons/start-script.svg +++ b/interface/resources/icons/start-script.svg @@ -536,22 +536,5 @@ height="44.57473" x="84.498352" y="1050.0748" /> - - - - From fa1bcc43e6d42cfa584b2cdeb85b402518d55beb Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:40:20 +0100 Subject: [PATCH 06/10] removed "Script.scriptEnding.connect(scriptEnding);" from lookWithMouse.js, because the function scriptEnding it is no longer available in that script. --- examples/lookWithMouse.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 70a98c0733..41d7a29bd9 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -84,6 +84,4 @@ MyAvatar.bodyYaw = 0; MyAvatar.bodyPitch = 0; MyAvatar.bodyRoll = 0; -// would be nice to change to update -Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); From 4048627de7c36ffa76e2a89a55a9e1a1d35b77cc Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:50:20 +0100 Subject: [PATCH 07/10] 2n try: removed "Script.scriptEnding.connect(scriptEnding);" from lookWithMouse.js, because the function scriptEnding it is no longer available in that script. --- examples/lookWithMouse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 41d7a29bd9..470a56bd63 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -84,4 +84,5 @@ MyAvatar.bodyYaw = 0; MyAvatar.bodyPitch = 0; MyAvatar.bodyRoll = 0; -Script.scriptEnding.connect(scriptEnding); +// would be nice to change to update +Script.update.connect(update); From a7d6d6d5618e6cf824a7815194517aed9f01740c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:04:21 -0800 Subject: [PATCH 08/10] return non-trivial value --- libraries/networking/src/LimitedNodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 4fbb1d14fe..4811c9c1ff 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -325,7 +325,7 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe SharedNodePointer matchingNode = sendingNodeForPacket(packet); if (matchingNode) { - updateNodeWithDataFromPacket(matchingNode, packet); + return updateNodeWithDataFromPacket(matchingNode, packet); } // we weren't able to match the sender address to the address we have for this node, unlock and don't parse From 488492126e3609ddac80a7b8e029dfc61777df64 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:08:20 -0800 Subject: [PATCH 09/10] fix typo in comment --- libraries/networking/src/NodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index d35e11a1c3..f70c2d9b3c 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -347,7 +347,7 @@ void NodeList::handleICEConnectionToDomainServer() { qDebug() << "Sending ping packets to establish connectivity with domain-server with ID" << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); - // send the ping packet to the local and public sockets for this nodfe + // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID()); writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket()); From 505c50ebe14cf7ec350ff516d27db71e120942d0 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 12:07:32 -0800 Subject: [PATCH 10/10] correct gain variance in linearFade() --- libraries/audio/src/AudioEditBuffer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/audio/src/AudioEditBuffer.h b/libraries/audio/src/AudioEditBuffer.h index b773fedfb8..66639f20bb 100644 --- a/libraries/audio/src/AudioEditBuffer.h +++ b/libraries/audio/src/AudioEditBuffer.h @@ -23,8 +23,8 @@ public: bool getZeroCrossing(uint32_t start, bool direction, float32_t epsilon, uint32_t& zero); - void linearFade(uint32_t start, uint32_t stop, bool slope); - void exponentialFade(uint32_t start, uint32_t stop, bool slope); + void linearFade(uint32_t start, uint32_t stop, bool increasing); + void exponentialFade(uint32_t start, uint32_t stop, bool increasing); }; template< typename T > @@ -74,7 +74,7 @@ inline bool AudioEditBuffer::getZeroCrossing(uint32_t start, bool direction, } template< typename T > -inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool slope) { +inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool increasing) { if (start >= stop || start > this->_frameCount || stop > this->_frameCount ) { return; @@ -84,7 +84,7 @@ inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool s float32_t delta; float32_t gain; - if (slope) { // 0.0 to 1.0f in delta increments + if (increasing) { // 0.0 to 1.0f in delta increments delta = 1.0f / (float32_t)count; gain = 0.0f; } else { // 1.0f to 0.0f in delta increments @@ -95,13 +95,13 @@ inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool s for (uint32_t i = start; i < stop; ++i) { for (uint32_t j = 0; j < this->_channelCount; ++j) { this->_frameBuffer[j][i] *= gain; - gain += delta; } + gain += delta; } } template< typename T > -inline void AudioEditBuffer::exponentialFade(uint32_t start, uint32_t stop, bool slope) { +inline void AudioEditBuffer::exponentialFade(uint32_t start, uint32_t stop, bool increasing) { // TBD }