From a4db2441822a05ed5b7ff859830accc3642bfba9 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 13:57:20 -0800 Subject: [PATCH 01/14] Mirror/warning fixes. --- interface/src/Application.cpp | 18 +++++++----------- interface/src/ui/RearMirrorTools.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e58f79cb5e..0740e424a1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -108,7 +108,7 @@ static unsigned STARFIELD_SEED = 1; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored -const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB +const qint64 MAXIMUM_CACHE_SIZE = 10737418240L; // 10GB static QTimer* idleTimer = NULL; @@ -724,11 +724,11 @@ void Application::paintGL() { displaySide(*whichCamera); glPopMatrix(); - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - renderRearViewMirror(_mirrorViewRect); - - } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { _rearMirrorTools->render(true); + + } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + renderRearViewMirror(_mirrorViewRect); } _glowEffect.render(); @@ -4314,8 +4314,6 @@ bool Application::isVSyncOn() const { if (wglewGetExtension("WGL_EXT_swap_control")) { int swapInterval = wglGetSwapIntervalEXT(); return (swapInterval > 0); - } else { - return true; } #elif defined(Q_OS_LINUX) // TODO: write the poper code for linux @@ -4326,10 +4324,9 @@ bool Application::isVSyncOn() const { } else { return true; } - */ -#else - return true; + */ #endif + return true; } bool Application::isVSyncEditable() const { @@ -4344,7 +4341,6 @@ bool Application::isVSyncEditable() const { return true; } */ -#else #endif return false; } diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp index f4b0bb82b5..8423a9c432 100644 --- a/interface/src/ui/RearMirrorTools.cpp +++ b/interface/src/ui/RearMirrorTools.cpp @@ -40,7 +40,7 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se _zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/plus.svg")); _zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg")); - _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); + _shrinkIconRect = QRect(ICON_PADDING, ICON_SIZE + ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _bodyZoomIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); @@ -106,7 +106,7 @@ bool RearMirrorTools::mousePressEvent(int x, int y) { } if (_fullScreen) { - if (_shrinkIconRect.contains(x, y)) { + if (_shrinkIconRect.contains(x, 2 * _shrinkIconRect.top() - y)) { _fullScreen = false; emit shrinkView(); return true; @@ -156,6 +156,9 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture } glEnd(); glPopMatrix(); + + glMatrixMode(GL_MODELVIEW); + glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } From 61e0660d6542dd196b62f96bfb75c0ee0f065e6d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 14:01:28 -0800 Subject: [PATCH 02/14] This actually seems to work differently on OS X versus Linux. --- interface/src/ui/RearMirrorTools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp index 8423a9c432..fb6ef63647 100644 --- a/interface/src/ui/RearMirrorTools.cpp +++ b/interface/src/ui/RearMirrorTools.cpp @@ -40,7 +40,7 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se _zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/plus.svg")); _zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg")); - _shrinkIconRect = QRect(ICON_PADDING, ICON_SIZE + ICON_PADDING, ICON_SIZE, ICON_SIZE); + _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _bodyZoomIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); @@ -106,7 +106,7 @@ bool RearMirrorTools::mousePressEvent(int x, int y) { } if (_fullScreen) { - if (_shrinkIconRect.contains(x, 2 * _shrinkIconRect.top() - y)) { + if (_shrinkIconRect.contains(x, y)) { _fullScreen = false; emit shrinkView(); return true; From b421ee92432e87e25aa0835ac14855c8fd21dd6f Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 14:09:40 -0800 Subject: [PATCH 03/14] Fix for audio toolbox. --- interface/src/ui/ApplicationOverlay.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 4d2c710be7..e0aa1f3020 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -984,7 +984,9 @@ void ApplicationOverlay::renderAudioMeter() { const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET + AUDIO_METER_GAP; int audioMeterY; - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + bool boxed = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && + !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror); + if (boxed) { audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_GAP + MUTE_ICON_PADDING; } else { audioMeterY = AUDIO_METER_GAP + MUTE_ICON_PADDING; @@ -1022,9 +1024,7 @@ void ApplicationOverlay::renderAudioMeter() { renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f); } - audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, - audioMeterY, - Menu::getInstance()->isOptionChecked(MenuOption::Mirror)); + audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, audioMeterY, boxed); audio->renderScope(glWidget->width(), glWidget->height()); From 70080124928ceb8875eeade003ac423591e7eace Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 14:20:31 -0800 Subject: [PATCH 04/14] Trigger fixes. --- interface/src/Application.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0740e424a1..a2cfc8f024 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2009,25 +2009,17 @@ void Application::init() { void Application::closeMirrorView() { if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - Menu::getInstance()->triggerOption(MenuOption::Mirror);; + Menu::getInstance()->triggerOption(MenuOption::Mirror); } } void Application::restoreMirrorView() { - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - Menu::getInstance()->triggerOption(MenuOption::Mirror);; - } - if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); } } void Application::shrinkMirrorView() { - if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - Menu::getInstance()->triggerOption(MenuOption::Mirror);; - } - if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); } From cd110d60482feeddcf9a9b91ecdecba5ea354928 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 14:35:01 -0800 Subject: [PATCH 05/14] Fix for invalid projection matrix on startup. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a2cfc8f024..0afe011cd6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -786,7 +786,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) // Tell our viewFrustum about this change, using the application camera if (updateViewFrustum) { loadViewFrustum(camera, _viewFrustum); - computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum From 6445b3aa5d46e4ff4d69211b6d00c924ddeb3197 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Nov 2014 15:59:16 -0800 Subject: [PATCH 06/14] Linux warnings fixes. --- interface/src/Audio.cpp | 2 +- interface/src/Menu.cpp | 2 +- interface/src/gpu/Batch.cpp | 2 +- interface/src/gpu/GLBackend.cpp | 53 ++++++++++++++++--------------- interface/src/gpu/Resource.cpp | 2 ++ interface/src/renderer/Model.cpp | 4 --- interface/src/ui/TextRenderer.cpp | 6 ++-- libraries/avatars/src/Player.cpp | 6 ++-- libraries/avatars/src/Player.h | 6 ++-- 9 files changed, 41 insertions(+), 42 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 3039b7adfb..98ad76dcd2 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -544,7 +544,7 @@ void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioF gverb_do(_gverb, value, &lValue, &rValue); // Mix, accounting for clipping, the left and right channels. Ignore the rest. - for (unsigned int j = sample; j < sample + audioFormat.channelCount(); j++) { + for (int j = sample; j < sample + audioFormat.channelCount(); j++) { if (j == sample) { // left channel int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction), -32768, 32767); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 21c1cded88..cd074805b6 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -386,7 +386,7 @@ Menu::Menu() : #if defined(Q_OS_MAC) #else - QAction* vsyncAction = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true, this, SLOT(changeVSync())); + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true, this, SLOT(changeVSync())); #endif } diff --git a/interface/src/gpu/Batch.cpp b/interface/src/gpu/Batch.cpp index e02a0a551e..e176e1641a 100644 --- a/interface/src/gpu/Batch.cpp +++ b/interface/src/gpu/Batch.cpp @@ -106,7 +106,7 @@ void Batch::setInputStream(Slot startChannel, const BufferStream& stream) { const Buffers& buffers = stream.getBuffers(); const Offsets& offsets = stream.getOffsets(); const Offsets& strides = stream.getStrides(); - for (int i = 0; i < buffers.size(); i++) { + for (unsigned int i = 0; i < buffers.size(); i++) { setInputBuffer(startChannel + i, buffers[i], offsets[i], strides[i]); } } diff --git a/interface/src/gpu/GLBackend.cpp b/interface/src/gpu/GLBackend.cpp index 5e13d03ff4..5c2451d81f 100644 --- a/interface/src/gpu/GLBackend.cpp +++ b/interface/src/gpu/GLBackend.cpp @@ -31,15 +31,15 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::GLBackend::do_glEnable), (&::gpu::GLBackend::do_glDisable), - + (&::gpu::GLBackend::do_glEnableClientState), (&::gpu::GLBackend::do_glDisableClientState), (&::gpu::GLBackend::do_glCullFace), (&::gpu::GLBackend::do_glAlphaFunc), - (&::gpu::GLBackend::do_glDepthFunc), - (&::gpu::GLBackend::do_glDepthMask), + (&::gpu::GLBackend::do_glDepthFunc), + (&::gpu::GLBackend::do_glDepthMask), (&::gpu::GLBackend::do_glDepthRange), (&::gpu::GLBackend::do_glBindBuffer), @@ -57,18 +57,18 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::GLBackend::do_glPushMatrix), (&::gpu::GLBackend::do_glPopMatrix), (&::gpu::GLBackend::do_glMultMatrixf), - (&::gpu::GLBackend::do_glLoadMatrixf), - (&::gpu::GLBackend::do_glLoadIdentity), - (&::gpu::GLBackend::do_glRotatef), - (&::gpu::GLBackend::do_glScalef), - (&::gpu::GLBackend::do_glTranslatef), + (&::gpu::GLBackend::do_glLoadMatrixf), + (&::gpu::GLBackend::do_glLoadIdentity), + (&::gpu::GLBackend::do_glRotatef), + (&::gpu::GLBackend::do_glScalef), + (&::gpu::GLBackend::do_glTranslatef), - (&::gpu::GLBackend::do_glDrawArrays), + (&::gpu::GLBackend::do_glDrawArrays), (&::gpu::GLBackend::do_glDrawRangeElements), - - (&::gpu::GLBackend::do_glColorPointer), - (&::gpu::GLBackend::do_glNormalPointer), - (&::gpu::GLBackend::do_glTexCoordPointer), + + (&::gpu::GLBackend::do_glColorPointer), + (&::gpu::GLBackend::do_glNormalPointer), + (&::gpu::GLBackend::do_glTexCoordPointer), (&::gpu::GLBackend::do_glVertexPointer), (&::gpu::GLBackend::do_glVertexAttribPointer), @@ -77,7 +77,7 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::GLBackend::do_glColor4f), - (&::gpu::GLBackend::do_glMaterialf), + (&::gpu::GLBackend::do_glMaterialf), (&::gpu::GLBackend::do_glMaterialfv), }; @@ -112,9 +112,8 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= { GLBackend::GLBackend() : - _inputFormat(0), - _inputAttributeActivation(0), _needInputFormatUpdate(true), + _inputFormat(0), _inputBuffersState(0), _inputBuffers(_inputBuffersState.size(), BufferPointer(0)), @@ -122,7 +121,8 @@ GLBackend::GLBackend() : _inputBufferStrides(_inputBuffersState.size(), 0), _indexBuffer(0), - _indexBufferOffset(0) + _indexBufferOffset(0), + _inputAttributeActivation(0) { } @@ -138,7 +138,7 @@ void GLBackend::renderBatch(Batch& batch) { GLBackend backend; - for (int i = 0; i < numCommands; i++) { + for (unsigned int i = 0; i < numCommands; i++) { CommandCall call = _commandCalls[(*command)]; (backend.*(call))(batch, *offset); command++; @@ -203,7 +203,7 @@ void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) { GLenum glType = _elementTypeToGLType[_indexBufferType]; - glDrawElements(mode, numIndices, glType, (GLvoid*)(startIndex + _indexBufferOffset)); + glDrawElements(mode, numIndices, glType, reinterpret_cast(startIndex + _indexBufferOffset)); CHECK_GL_ERROR(); } @@ -265,7 +265,7 @@ void GLBackend::updateInput() { } // Manage Activation what was and what is expected now - for (int i = 0; i < newActivation.size(); i++) { + for (unsigned int i = 0; i < newActivation.size(); i++) { bool newState = newActivation[i]; if (newState != _inputAttributeActivation[i]) { #if defined(SUPPORT_LEGACY_OPENGL) @@ -314,7 +314,7 @@ void GLBackend::updateInput() { CHECK_GL_ERROR(); _inputBuffersState[bufferNum] = false; - for (int i = 0; i < channel._slots.size(); i++) { + for (unsigned int i = 0; i < channel._slots.size(); i++) { const Stream::Attribute& attrib = attributes.at(channel._slots[i]); GLuint slot = attrib._slot; GLuint count = attrib._element.getDimensionCount(); @@ -325,16 +325,16 @@ void GLBackend::updateInput() { if (slot < NUM_CLASSIC_ATTRIBS) { switch (slot) { case Stream::POSITION: - glVertexPointer(count, type, stride, (GLvoid*)pointer); + glVertexPointer(count, type, stride, reinterpret_cast(pointer)); break; case Stream::NORMAL: - glNormalPointer(type, stride, (GLvoid*)pointer); + glNormalPointer(type, stride, reinterpret_cast(pointer)); break; case Stream::COLOR: - glColorPointer(count, type, stride, (GLvoid*)pointer); + glColorPointer(count, type, stride, reinterpret_cast(pointer)); break; case Stream::TEXCOORD: - glTexCoordPointer(count, type, stride, (GLvoid*)pointer); + glTexCoordPointer(count, type, stride, reinterpret_cast(pointer)); break; }; } else { @@ -342,7 +342,8 @@ void GLBackend::updateInput() { { #endif GLboolean isNormalized = attrib._element.isNormalized(); - glVertexAttribPointer(slot, count, type, isNormalized, stride, (GLvoid*)pointer); + glVertexAttribPointer(slot, count, type, isNormalized, stride, + reinterpret_cast(pointer)); } CHECK_GL_ERROR(); } diff --git a/interface/src/gpu/Resource.cpp b/interface/src/gpu/Resource.cpp index cd1b4ef84b..3a6e47a7ba 100644 --- a/interface/src/gpu/Resource.cpp +++ b/interface/src/gpu/Resource.cpp @@ -8,6 +8,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + +#include "Context.h" #include "Resource.h" #include diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 38562df696..3137ab8369 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -479,9 +479,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g float bestDistance = std::numeric_limits::max(); float distanceToSubMesh; BoxFace subMeshFace; - BoxFace bestSubMeshFace; int subMeshIndex = 0; - int bestSubMeshIndex = -1; // If we hit the models box, then consider the submeshes... foreach(const AABox& subMeshBox, _calculatedMeshBoxes) { @@ -489,9 +487,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g if (subMeshBox.findRayIntersection(origin, direction, distanceToSubMesh, subMeshFace)) { if (distanceToSubMesh < bestDistance) { - bestSubMeshIndex = subMeshIndex; bestDistance = distanceToSubMesh; - bestSubMeshFace = subMeshFace; intersectedSomething = true; extraInfo = geometry.getModelNameOfMesh(subMeshIndex); } diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index 69df609ba9..fed041d6ea 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -129,7 +129,7 @@ int TextRenderer::draw(int x, int y, const char* str) { leftBottom.x, rightTop.y, ls, tt, }; const int NUM_COLOR_SCALARS_PER_GLYPH = 4; - unsigned int colorBuffer[NUM_COLOR_SCALARS_PER_GLYPH] = { compactColor, compactColor, compactColor, compactColor }; + int colorBuffer[NUM_COLOR_SCALARS_PER_GLYPH] = { compactColor, compactColor, compactColor, compactColor }; gpu::Buffer::Size offset = sizeof(vertexBuffer) * _numGlyphsBatched; gpu::Buffer::Size colorOffset = sizeof(colorBuffer) * _numGlyphsBatched; @@ -181,9 +181,9 @@ TextRenderer::TextRenderer(const Properties& properties) : _color(properties.color), _glyphsBuffer(new gpu::Buffer()), _glyphsColorBuffer(new gpu::Buffer()), - _numGlyphsBatched(0), _glyphsStreamFormat(new gpu::Stream::Format()), - _glyphsStream(new gpu::BufferStream()) + _glyphsStream(new gpu::BufferStream()), + _numGlyphsBatched(0) { _glyphsStreamFormat->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::POS_XYZ), 0); const int NUM_POS_COORDS = 2; diff --git a/libraries/avatars/src/Player.cpp b/libraries/avatars/src/Player.cpp index 47d1b04421..56f820ab97 100644 --- a/libraries/avatars/src/Player.cpp +++ b/libraries/avatars/src/Player.cpp @@ -297,7 +297,7 @@ void Player::play() { _injector->setOptions(_options); } -void Player::setCurrentFrame(unsigned int currentFrame) { +void Player::setCurrentFrame(int currentFrame) { if (_recording && currentFrame >= _recording->getFrameNumber()) { stopPlaying(); return; @@ -314,7 +314,7 @@ void Player::setCurrentFrame(unsigned int currentFrame) { } } -void Player::setCurrentTime(unsigned int currentTime) { +void Player::setCurrentTime(int currentTime) { if (currentTime >= _recording->getLength()) { stopPlaying(); return; @@ -393,7 +393,7 @@ bool Player::computeCurrentFrame() { _currentFrame = 0; } - quint64 elapsed = glm::clamp(Player::elapsed() - _audioOffset, (qint64)0, (qint64)_recording->getLength()); + qint64 elapsed = glm::clamp(Player::elapsed() - _audioOffset, (qint64)0, (qint64)_recording->getLength()); while(_currentFrame >= 0 && _recording->getFrameTimestamp(_currentFrame) > elapsed) { --_currentFrame; diff --git a/libraries/avatars/src/Player.h b/libraries/avatars/src/Player.h index 043fcc4a25..7ed76fa495 100644 --- a/libraries/avatars/src/Player.h +++ b/libraries/avatars/src/Player.h @@ -44,8 +44,8 @@ public slots: void loadRecording(RecordingPointer recording); void play(); - void setCurrentFrame(unsigned int currentFrame); - void setCurrentTime(unsigned int currentTime); + void setCurrentFrame(int currentFrame); + void setCurrentTime(int currentTime); void setVolume(float volume); void setAudioOffset(int audioOffset); @@ -87,4 +87,4 @@ private: bool _useSkeletonURL; }; -#endif // hifi_Player_h \ No newline at end of file +#endif // hifi_Player_h From 0c1ea784b9263f31726b79371476649e25aaabf7 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 10 Nov 2014 11:49:02 -0800 Subject: [PATCH 07/14] Set face. --- interface/src/renderer/Model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 3137ab8369..8d426d067b 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -489,6 +489,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g if (distanceToSubMesh < bestDistance) { bestDistance = distanceToSubMesh; intersectedSomething = true; + face = subMeshFace; extraInfo = geometry.getModelNameOfMesh(subMeshIndex); } } From 5f89b6e00ea8f48f9b0814d07929a66dc99d61d3 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 10 Nov 2014 11:58:52 -0800 Subject: [PATCH 08/14] The spec actually says that the 'L' (should have been 'LL' anyway) isn't necessary; the compiler will know to read the constant as a long long. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0afe011cd6..d54a638239 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -108,7 +108,7 @@ static unsigned STARFIELD_SEED = 1; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored -const qint64 MAXIMUM_CACHE_SIZE = 10737418240L; // 10GB +const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB static QTimer* idleTimer = NULL; From edec4d1298443c0a881d8776b813bf7d3d2a5c47 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 10 Nov 2014 14:10:29 -0800 Subject: [PATCH 09/14] Mixer send mute when if too noisy --- assignment-client/src/audio/AudioMixer.cpp | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index e00d8eb44d..e7f41a2dca 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -141,11 +141,6 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(AudioMixerClientData* l return 0; } - // if the stream should be muted, bail - if (shouldMute(streamToAdd->getQuietestFrameLoudness())) { - return 0; - } - float bearingRelativeAngleToSource = 0.0f; float attenuationCoefficient = 1.0f; int numSamplesDelay = 0; @@ -722,6 +717,25 @@ void AudioMixer::run() { // That's how the popped audio data will be read for mixing (but only if the pop was successful) nodeData->checkBuffersBeforeFrameSend(); + // if the stream should be muted, send mute packet + if (shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) { + int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment); + int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float); + + // Fake data to force mute + glm::vec3 position = nodeData->getAvatarAudioStream()->getPosition(); + float radius = 1.0f; + + char* packet = (char*)malloc(packetSize); + populatePacketHeader(packet, PacketTypeMuteEnvironment); + memcpy(packet + headerSize, &position, sizeof(glm::vec3)); + memcpy(packet + headerSize + sizeof(glm::vec3), &radius, sizeof(float)); + + nodeList->writeDatagram(packet, packetSize, node); + free(packet); + } + + if (node->getType() == NodeType::Agent && node->getActiveSocket() && nodeData->getAvatarAudioStream()) { From 53fb9e9047a8f4c26590ab5746e552576913ed11 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 10 Nov 2014 14:11:17 -0800 Subject: [PATCH 10/14] make mute icon pulsate when muted --- interface/src/Audio.cpp | 19 ++++++++++++++++++- interface/src/Audio.h | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 4a488bb296..7ff811b8aa 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -54,6 +54,9 @@ static const int APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS = (int)(30.0f * 1000. // Mute icon configration static const int MUTE_ICON_SIZE = 24; +static const float PULSE_MIN = 0.0f; +static const float PULSE_MAX = 1.0f; +static const float PULSE_STEP = 0.05f; static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100; @@ -97,6 +100,9 @@ Audio::Audio(QObject* parent) : _muted(false), _reverb(false), _reverbOptions(&_scriptReverbOptions), + _gverb(NULL), + _iconColor(1.0f), + _iconPulseFactor(-1), _processSpatialAudio(false), _spatialAudioStart(0), _spatialAudioFinish(0), @@ -1390,11 +1396,22 @@ void Audio::renderToolBox(int x, int y, bool boxed) { _iconBounds = QRect(x, y, MUTE_ICON_SIZE, MUTE_ICON_SIZE); if (!_muted) { glBindTexture(GL_TEXTURE_2D, _micTextureId); + _iconColor = 1.0f; + _iconPulseFactor = -1; } else { glBindTexture(GL_TEXTURE_2D, _muteTextureId); + // Make muted icon pulsate + _iconColor += _iconPulseFactor * PULSE_STEP; + if (_iconColor >= PULSE_MAX) { + _iconColor = PULSE_MAX; + _iconPulseFactor = -1; + } else if (_iconColor <= PULSE_MIN) { + _iconColor = PULSE_MIN; + _iconPulseFactor = 1; + } } - glColor3f(1,1,1); + glColor3f(_iconColor, _iconColor, _iconColor); glBegin(GL_QUADS); glTexCoord2f(1, 1); diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 6de7cf8d91..ebdf620121 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -248,11 +248,13 @@ private: AudioEffectOptions _scriptReverbOptions; AudioEffectOptions _zoneReverbOptions; AudioEffectOptions* _reverbOptions; - ty_gverb *_gverb; + ty_gverb* _gverb; GLuint _micTextureId; GLuint _muteTextureId; GLuint _boxTextureId; QRect _iconBounds; + float _iconColor; + int _iconPulseFactor; /// Audio callback in class context. inline void performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* outputRight); From 125ef0e3e2abc949a498c1a43d2f2640f995fd59 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 10 Nov 2014 15:12:40 -0800 Subject: [PATCH 11/14] make pulsate function into a cos --- interface/src/Audio.cpp | 33 +++++++++++++++++---------------- interface/src/Audio.h | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 7ff811b8aa..87f7163cd5 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -54,9 +54,6 @@ static const int APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS = (int)(30.0f * 1000. // Mute icon configration static const int MUTE_ICON_SIZE = 24; -static const float PULSE_MIN = 0.0f; -static const float PULSE_MAX = 1.0f; -static const float PULSE_STEP = 0.05f; static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100; @@ -102,7 +99,7 @@ Audio::Audio(QObject* parent) : _reverbOptions(&_scriptReverbOptions), _gverb(NULL), _iconColor(1.0f), - _iconPulseFactor(-1), + _iconPulseTimeReference(usecTimestampNow()), _processSpatialAudio(false), _spatialAudioStart(0), _spatialAudioFinish(0), @@ -1397,33 +1394,37 @@ void Audio::renderToolBox(int x, int y, bool boxed) { if (!_muted) { glBindTexture(GL_TEXTURE_2D, _micTextureId); _iconColor = 1.0f; - _iconPulseFactor = -1; } else { glBindTexture(GL_TEXTURE_2D, _muteTextureId); + // Make muted icon pulsate - _iconColor += _iconPulseFactor * PULSE_STEP; - if (_iconColor >= PULSE_MAX) { - _iconColor = PULSE_MAX; - _iconPulseFactor = -1; - } else if (_iconColor <= PULSE_MIN) { - _iconColor = PULSE_MIN; - _iconPulseFactor = 1; + static const float PULSE_MIN = 0.4f; + static const float PULSE_MAX = 1.0f; + static const float PULSE_FREQUENCY = 1.0f; // in Hz + qint64 now = usecTimestampNow(); + if (now - _iconPulseTimeReference > USECS_PER_SECOND) { + // Prevents t from getting too big, which would diminish glm::cos precision + _iconPulseTimeReference = now - ((now - _iconPulseTimeReference) % USECS_PER_SECOND); } + float t = (float)(now - _iconPulseTimeReference) / (float)USECS_PER_SECOND; + float pulseFactor = (glm::cos(t * PULSE_FREQUENCY * 2.0f * PI) + 1.0f) / 2.0f; + _iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor; + } glColor3f(_iconColor, _iconColor, _iconColor); glBegin(GL_QUADS); - glTexCoord2f(1, 1); + glTexCoord2f(1.0f, 1.0f); glVertex2f(_iconBounds.left(), _iconBounds.top()); - glTexCoord2f(0, 1); + glTexCoord2f(0.0f, 1.0f); glVertex2f(_iconBounds.right(), _iconBounds.top()); - glTexCoord2f(0, 0); + glTexCoord2f(0.0f, 0.0f); glVertex2f(_iconBounds.right(), _iconBounds.bottom()); - glTexCoord2f(1, 0); + glTexCoord2f(1.0f, 0.0f); glVertex2f(_iconBounds.left(), _iconBounds.bottom()); glEnd(); diff --git a/interface/src/Audio.h b/interface/src/Audio.h index ebdf620121..ecbef026c4 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -254,7 +254,7 @@ private: GLuint _boxTextureId; QRect _iconBounds; float _iconColor; - int _iconPulseFactor; + qint64 _iconPulseTimeReference; /// Audio callback in class context. inline void performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* outputRight); From 02b401701f4e4770ea7ec71eb20ac07e180c9a81 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 10 Nov 2014 15:46:36 -0800 Subject: [PATCH 12/14] Set a minimum mute intervalle in the mixer --- assignment-client/src/audio/AudioMixer.cpp | 33 +++++++++++-------- .../src/audio/AvatarAudioStream.cpp | 3 +- .../src/audio/AvatarAudioStream.h | 7 +++- interface/src/Audio.cpp | 1 - 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index e7f41a2dca..c01afeda4e 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -719,20 +719,25 @@ void AudioMixer::run() { // if the stream should be muted, send mute packet if (shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) { - int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment); - int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float); - - // Fake data to force mute - glm::vec3 position = nodeData->getAvatarAudioStream()->getPosition(); - float radius = 1.0f; - - char* packet = (char*)malloc(packetSize); - populatePacketHeader(packet, PacketTypeMuteEnvironment); - memcpy(packet + headerSize, &position, sizeof(glm::vec3)); - memcpy(packet + headerSize + sizeof(glm::vec3), &radius, sizeof(float)); - - nodeList->writeDatagram(packet, packetSize, node); - free(packet); + static const int TIME_BETWEEN_MUTES = 5; // in secs + if (usecTimestampNow() - nodeData->getAvatarAudioStream()->getLastMuted() > + TIME_BETWEEN_MUTES * USECS_PER_SECOND) { + int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment); + int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float); + + // Fake data to force mute + glm::vec3 position = nodeData->getAvatarAudioStream()->getPosition(); + float radius = 1.0f; + + char* packet = (char*)malloc(packetSize); + populatePacketHeader(packet, PacketTypeMuteEnvironment); + memcpy(packet + headerSize, &position, sizeof(glm::vec3)); + memcpy(packet + headerSize + sizeof(glm::vec3), &radius, sizeof(float)); + + nodeList->writeDatagram(packet, packetSize, node); + nodeData->getAvatarAudioStream()->setLastMutedNow(); + free(packet); + } } diff --git a/assignment-client/src/audio/AvatarAudioStream.cpp b/assignment-client/src/audio/AvatarAudioStream.cpp index 90dcefa09d..cd67722a2e 100644 --- a/assignment-client/src/audio/AvatarAudioStream.cpp +++ b/assignment-client/src/audio/AvatarAudioStream.cpp @@ -14,7 +14,8 @@ #include "AvatarAudioStream.h" AvatarAudioStream::AvatarAudioStream(bool isStereo, const InboundAudioStream::Settings& settings) : - PositionalAudioStream(PositionalAudioStream::Microphone, isStereo, settings) + PositionalAudioStream(PositionalAudioStream::Microphone, isStereo, settings), + _lastMuted(usecTimestampNow()) { } diff --git a/assignment-client/src/audio/AvatarAudioStream.h b/assignment-client/src/audio/AvatarAudioStream.h index cc2ff1aca7..e1fb6dd486 100644 --- a/assignment-client/src/audio/AvatarAudioStream.h +++ b/assignment-client/src/audio/AvatarAudioStream.h @@ -19,13 +19,18 @@ class AvatarAudioStream : public PositionalAudioStream { public: AvatarAudioStream(bool isStereo, const InboundAudioStream::Settings& settings); - + + qint64 getLastMuted() const { return _lastMuted; } + void setLastMutedNow() { _lastMuted = usecTimestampNow(); } + private: // disallow copying of AvatarAudioStream objects AvatarAudioStream(const AvatarAudioStream&); AvatarAudioStream& operator= (const AvatarAudioStream&); int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples); + + qint64 _lastMuted; }; #endif // hifi_AvatarAudioStream_h diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 87f7163cd5..726d1e609a 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -1409,7 +1409,6 @@ void Audio::renderToolBox(int x, int y, bool boxed) { float t = (float)(now - _iconPulseTimeReference) / (float)USECS_PER_SECOND; float pulseFactor = (glm::cos(t * PULSE_FREQUENCY * 2.0f * PI) + 1.0f) / 2.0f; _iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor; - } glColor3f(_iconColor, _iconColor, _iconColor); From a868661a255e875806f6a979cfab8924b56ee541 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 10 Nov 2014 15:51:31 -0800 Subject: [PATCH 13/14] Extra space --- assignment-client/src/audio/AudioMixer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index c01afeda4e..9131c99c6d 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -740,7 +740,6 @@ void AudioMixer::run() { } } - if (node->getType() == NodeType::Agent && node->getActiveSocket() && nodeData->getAvatarAudioStream()) { From dabc2b23a395bda91e4114df65072e0b98269e35 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 10 Nov 2014 15:51:56 -0800 Subject: [PATCH 14/14] add a guard in case local audio cannot be handled --- interface/src/Audio.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 4a488bb296..43ad14aca7 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -1342,8 +1342,11 @@ void Audio::handleAudioByteArray(const QByteArray& audioByteArray, const AudioIn QAudioOutput* localSoundOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName), localFormat, this); QIODevice* localIODevice = localSoundOutput->start(); - qDebug() << "Writing" << audioByteArray.size() << "to" << localIODevice; - localIODevice->write(audioByteArray); + if (localIODevice) { + localIODevice->write(audioByteArray); + } else { + qDebug() << "Unable to handle audio byte array. Error:" << localSoundOutput->error(); + } } else { qDebug() << "Audio::handleAudioByteArray called with an empty byte array. Sound is likely still downloading."; }