From 305623d8a7d3a2a45e592d48eac2e765be630c40 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 8 Jul 2014 21:37:08 -0700 Subject: [PATCH 1/9] Add option to hide focus indicators --- interface/src/Menu.cpp | 1 + interface/src/Menu.h | 1 + interface/src/avatar/Avatar.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c0c25bb00d..019ce1df9e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -406,6 +406,7 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::GlowWhenSpeaking, 0, true); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::HideFocusIndicators, 0, false); QMenu* oculusOptionsMenu = developerMenu->addMenu("Oculus Options"); addCheckableActionToQMenuAndActionHash(oculusOptionsMenu, MenuOption::DisplayOculusOverlays, 0, true); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e8146f8038..32458e1883 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -382,6 +382,7 @@ namespace MenuOption { const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity"; const QString HandsCollideWithSelf = "Collide With Self"; const QString HeadMouse = "Head Mouse"; + const QString HideFocusIndicators = "Hide Focus Indicators"; const QString IncreaseAvatarSize = "Increase Avatar Size"; const QString IncreaseVoxelSize = "Increase Voxel Size"; const QString LoadScript = "Open and Run Script File..."; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 9bb54efe20..e2e111c210 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -257,7 +257,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { } // If this is the avatar being looked at, render a little ball above their head - if (_isLookAtTarget) { + if (_isLookAtTarget && !Menu::getInstance()->isOptionChecked(MenuOption::HideFocusIndicators)) { const float LOOK_AT_INDICATOR_RADIUS = 0.03f; const float LOOK_AT_INDICATOR_OFFSET = 0.22f; const float LOOK_AT_INDICATOR_COLOR[] = { 0.8f, 0.0f, 0.0f, 0.75f }; From 801be7edee99278d3fccf53a8a7626c18ddd641c Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 9 Jul 2014 13:55:38 +0200 Subject: [PATCH 2/9] Stop QMenuBar to steal keyboard focus when pressing Alt key in Linux. --- interface/src/Application.cpp | 2 ++ interface/src/GLCanvas.cpp | 36 +++++++++++++++++++++++++++++++++++ interface/src/GLCanvas.h | 1 + 3 files changed, 39 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ace265ad4f..95cfaab4cf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -803,6 +803,7 @@ bool Application::event(QEvent* event) { } void Application::keyPressEvent(QKeyEvent* event) { + qDebug("Application::keyPressEvent(%x)", event->key()); _keysPressed.insert(event->key()); @@ -1053,6 +1054,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } void Application::keyReleaseEvent(QKeyEvent* event) { + qDebug("Application::keyReleaseEvent(%x)", event->key()); _keysPressed.remove(event->key()); diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 17026b5d5c..87c1016c5e 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -23,6 +23,11 @@ GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer)), _throttleRendering(false), _idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED) { +#ifdef Q_OS_LINUX + // Cause GLCanvas::eventFilter to be called. + // It wouldn't hurt to do this on Mac and PC too; but apparently it's only needed on linux. + qApp->installEventFilter(this); +#endif } bool GLCanvas::isThrottleRendering() const { @@ -162,3 +167,34 @@ void GLCanvas::dragEnterEvent(QDragEnterEvent* event) { void GLCanvas::dropEvent(QDropEvent* event) { Application::getInstance()->dropEvent(event); } + +// Pressing Alt (and Meta) key alone activates the menubar because its style inherits the +// SHMenuBarAltKeyNavigation from QWindowsStyle. This makes it impossible for a scripts to +// receive keyPress events for the Alt (and Meta) key in a reliable manner. +// +// This filter catches events before QMenuBar can steal the keyboard focus. +// The idea was borrowed from +// http://www.archivum.info/qt-interest@trolltech.com/2006-09/00053/Re-(Qt4)-Alt-key-focus-QMenuBar-(solved).html + +bool GLCanvas::eventFilter(QObject*, QEvent* event) { + switch (event->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::ShortcutOverride: + { + QKeyEvent* keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Alt || keyEvent->key() == Qt::Key_Meta) { + if (event->type() == QEvent::KeyPress) + keyPressEvent(keyEvent); + else if (event->type() == QEvent::KeyRelease) + keyReleaseEvent(keyEvent); + else + QGLWidget::event(event); + return true; + } + } + default: + break; + } + return false; +} diff --git a/interface/src/GLCanvas.h b/interface/src/GLCanvas.h index 024cd615ae..773fcb5c27 100644 --- a/interface/src/GLCanvas.h +++ b/interface/src/GLCanvas.h @@ -50,6 +50,7 @@ protected: private slots: void activeChanged(Qt::ApplicationState state); void throttleRender(); + bool eventFilter(QObject*, QEvent* event); }; #endif // hifi_GLCanvas_h From f2d49fa6a1b911118d84a416deaaaa2fa0f5dedf Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 9 Jul 2014 15:12:29 -0700 Subject: [PATCH 3/9] Rename focus indicators menu item and default to off --- interface/src/Menu.cpp | 2 +- interface/src/Menu.h | 2 +- interface/src/avatar/Avatar.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 019ce1df9e..beb6e18e5c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -406,7 +406,7 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::GlowWhenSpeaking, 0, true); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false); - addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::HideFocusIndicators, 0, false); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::FocusIndicators, 0, false); QMenu* oculusOptionsMenu = developerMenu->addMenu("Oculus Options"); addCheckableActionToQMenuAndActionHash(oculusOptionsMenu, MenuOption::DisplayOculusOverlays, 0, true); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 32458e1883..b66d3f1107 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -369,6 +369,7 @@ namespace MenuOption { const QString Faceshift = "Faceshift"; const QString FilterSixense = "Smooth Sixense Movement"; const QString FirstPerson = "First Person"; + const QString FocusIndicators = "Focus Indicators"; const QString FrameTimer = "Show Timer"; const QString FrustumRenderMode = "Render Mode"; const QString Fullscreen = "Fullscreen"; @@ -382,7 +383,6 @@ namespace MenuOption { const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity"; const QString HandsCollideWithSelf = "Collide With Self"; const QString HeadMouse = "Head Mouse"; - const QString HideFocusIndicators = "Hide Focus Indicators"; const QString IncreaseAvatarSize = "Increase Avatar Size"; const QString IncreaseVoxelSize = "Increase Voxel Size"; const QString LoadScript = "Open and Run Script File..."; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index e2e111c210..c7d01ba996 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -257,7 +257,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { } // If this is the avatar being looked at, render a little ball above their head - if (_isLookAtTarget && !Menu::getInstance()->isOptionChecked(MenuOption::HideFocusIndicators)) { + if (_isLookAtTarget && Menu::getInstance()->isOptionChecked(MenuOption::FocusIndicators)) { const float LOOK_AT_INDICATOR_RADIUS = 0.03f; const float LOOK_AT_INDICATOR_OFFSET = 0.22f; const float LOOK_AT_INDICATOR_COLOR[] = { 0.8f, 0.0f, 0.0f, 0.75f }; From 8fa7bf4fa091714b7010b49f16d44f2f794d2adc Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 9 Jul 2014 16:43:46 -0700 Subject: [PATCH 4/9] rename: ParentFrame --> ConstrainedFrame --- interface/src/avatar/FaceModel.cpp | 8 ++--- interface/src/avatar/SkeletonModel.cpp | 6 ++-- interface/src/renderer/JointState.cpp | 48 +++++++++++++------------- interface/src/renderer/JointState.h | 12 +++---- interface/src/renderer/Model.cpp | 8 ++--- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 59e5b08cc0..203dbf2283 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -49,9 +49,9 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) { void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { // get the rotation axes in joint space and use them to adjust the rotation glm::mat3 axes = glm::mat3_cast(glm::quat()); - glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInParentFrame()) * + glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInConstrainedFrame()) * joint.preTransform * glm::mat4_cast(joint.preRotation))); - state.setRotationInParentFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2])) + state.setRotationInConstrainedFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2])) * glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getFinalYaw(), glm::normalize(inverse * axes[1])) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalPitch(), glm::normalize(inverse * axes[0])) * joint.rotation); @@ -61,14 +61,14 @@ void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJ // likewise with the eye joints // NOTE: at the moment we do the math in the world-frame, hence the inverse transform is more complex than usual. glm::mat4 inverse = glm::inverse(glm::mat4_cast(_rotation) * parentState.getTransform() * - glm::translate(state.getDefaultTranslationInParentFrame()) * + glm::translate(state.getDefaultTranslationInConstrainedFrame()) * joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation)); glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT, 0.0f)); glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(_owningHead->getLookAtPosition() + _owningHead->getSaccade() - _translation, 1.0f)); glm::quat between = rotationBetween(front, lookAt); const float MAX_ANGLE = 30.0f * RADIANS_PER_DEGREE; - state.setRotationInParentFrame(glm::angleAxis(glm::clamp(glm::angle(between), -MAX_ANGLE, MAX_ANGLE), glm::axis(between)) * + state.setRotationInConstrainedFrame(glm::angleAxis(glm::clamp(glm::angle(between), -MAX_ANGLE, MAX_ANGLE), glm::axis(between)) * joint.rotation); } diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 2f35b96181..d9b2340a90 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -219,7 +219,7 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) { JointState& parentState = _jointStates[parentJointIndex]; parentState.setRotationFromBindFrame(palmRotation, PALM_PRIORITY); // lock hand to forearm by slamming its rotation (in parent-frame) to identity - _jointStates[jointIndex].setRotationInParentFrame(glm::quat()); + _jointStates[jointIndex].setRotationInConstrainedFrame(glm::quat()); } else { inverseKinematics(jointIndex, palmPosition, palmRotation, PALM_PRIORITY); } @@ -255,9 +255,9 @@ void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const } // get the rotation axes in joint space and use them to adjust the rotation glm::mat3 axes = glm::mat3_cast(glm::quat()); - glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInParentFrame()) * + glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInConstrainedFrame()) * joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation))); - state.setRotationInParentFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), + state.setRotationInConstrainedFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), glm::normalize(inverse * axes[2])) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), glm::normalize(inverse * axes[0])) * joint.rotation); } diff --git a/interface/src/renderer/JointState.cpp b/interface/src/renderer/JointState.cpp index 429084480d..5a2766d39f 100644 --- a/interface/src/renderer/JointState.cpp +++ b/interface/src/renderer/JointState.cpp @@ -26,7 +26,7 @@ JointState::JointState() : JointState::JointState(const JointState& other) : _constraint(NULL) { _transform = other._transform; _rotation = other._rotation; - _rotationInParentFrame = other._rotationInParentFrame; + _rotationInConstrainedFrame = other._rotationInConstrainedFrame; _animationPriority = other._animationPriority; _fbxJoint = other._fbxJoint; // DO NOT copy _constraint @@ -43,7 +43,7 @@ JointState::~JointState() { void JointState::setFBXJoint(const FBXJoint* joint) { assert(joint != NULL); - _rotationInParentFrame = joint->rotation; + _rotationInConstrainedFrame = joint->rotation; // NOTE: JointState does not own the FBXJoint to which it points. _fbxJoint = joint; if (_constraint) { @@ -68,24 +68,24 @@ void JointState::copyState(const JointState& state) { _animationPriority = state._animationPriority; _transform = state._transform; _rotation = extractRotation(_transform); - _rotationInParentFrame = state._rotationInParentFrame; + _rotationInConstrainedFrame = state._rotationInConstrainedFrame; _visibleTransform = state._visibleTransform; _visibleRotation = extractRotation(_visibleTransform); - _visibleRotationInParentFrame = state._visibleRotationInParentFrame; + _visibleRotationInConstrainedFrame = state._visibleRotationInConstrainedFrame; // DO NOT copy _fbxJoint or _constraint } void JointState::computeTransform(const glm::mat4& parentTransform) { - glm::quat modifiedRotation = _fbxJoint->preRotation * _rotationInParentFrame * _fbxJoint->postRotation; - glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform; + glm::quat rotationInConstrainedFrame = _fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation; + glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(rotationInConstrainedFrame) * _fbxJoint->postTransform; _transform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform; _rotation = extractRotation(_transform); } void JointState::computeVisibleTransform(const glm::mat4& parentTransform) { - glm::quat modifiedRotation = _fbxJoint->preRotation * _visibleRotationInParentFrame * _fbxJoint->postRotation; - glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform; + glm::quat rotationInConstrainedFrame = _fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation; + glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(rotationInConstrainedFrame) * _fbxJoint->postTransform; _visibleTransform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform; _visibleRotation = extractRotation(_visibleTransform); } @@ -97,7 +97,7 @@ glm::quat JointState::getRotationFromBindToModelFrame() const { void JointState::restoreRotation(float fraction, float priority) { assert(_fbxJoint != NULL); if (priority == _animationPriority || _animationPriority == 0.0f) { - setRotationInParentFrame(safeMix(_rotationInParentFrame, _fbxJoint->rotation, fraction)); + setRotationInConstrainedFrame(safeMix(_rotationInConstrainedFrame, _fbxJoint->rotation, fraction)); _animationPriority = 0.0f; } } @@ -106,11 +106,11 @@ void JointState::setRotationFromBindFrame(const glm::quat& rotation, float prior // rotation is from bind- to model-frame assert(_fbxJoint != NULL); if (priority >= _animationPriority) { - glm::quat targetRotation = _rotationInParentFrame * glm::inverse(_rotation) * rotation * glm::inverse(_fbxJoint->inverseBindRotation); + glm::quat targetRotation = _rotationInConstrainedFrame * glm::inverse(_rotation) * rotation * glm::inverse(_fbxJoint->inverseBindRotation); if (constrain && _constraint) { - _constraint->softClamp(targetRotation, _rotationInParentFrame, 0.5f); + _constraint->softClamp(targetRotation, _rotationInConstrainedFrame, 0.5f); } - setRotationInParentFrame(targetRotation); + setRotationInConstrainedFrame(targetRotation); _animationPriority = priority; } } @@ -137,12 +137,12 @@ void JointState::applyRotationDelta(const glm::quat& delta, bool constrain, floa _animationPriority = priority; if (!constrain || _constraint == NULL) { // no constraints - _rotationInParentFrame = _rotationInParentFrame * glm::inverse(_rotation) * delta * _rotation; + _rotationInConstrainedFrame = _rotationInConstrainedFrame * glm::inverse(_rotation) * delta * _rotation; _rotation = delta * _rotation; return; } - glm::quat targetRotation = _rotationInParentFrame * glm::inverse(_rotation) * delta * _rotation; - setRotationInParentFrame(targetRotation); + glm::quat targetRotation = _rotationInConstrainedFrame * glm::inverse(_rotation) * delta * _rotation; + setRotationInConstrainedFrame(targetRotation); } /// Applies delta rotation to joint but mixes a little bit of the default pose as well. @@ -154,30 +154,30 @@ void JointState::mixRotationDelta(const glm::quat& delta, float mixFactor, float return; } _animationPriority = priority; - glm::quat targetRotation = _rotationInParentFrame * glm::inverse(_rotation) * delta * _rotation; + glm::quat targetRotation = _rotationInConstrainedFrame * glm::inverse(_rotation) * delta * _rotation; if (mixFactor > 0.0f && mixFactor <= 1.0f) { targetRotation = safeMix(targetRotation, _fbxJoint->rotation, mixFactor); } if (_constraint) { - _constraint->softClamp(targetRotation, _rotationInParentFrame, 0.5f); + _constraint->softClamp(targetRotation, _rotationInConstrainedFrame, 0.5f); } - setRotationInParentFrame(targetRotation); + setRotationInConstrainedFrame(targetRotation); } glm::quat JointState::computeParentRotation() const { // R = Rp * Rpre * r * Rpost // Rp = R * (Rpre * r * Rpost)^ - return _rotation * glm::inverse(_fbxJoint->preRotation * _rotationInParentFrame * _fbxJoint->postRotation); + return _rotation * glm::inverse(_fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation); } -void JointState::setRotationInParentFrame(const glm::quat& targetRotation) { +void JointState::setRotationInConstrainedFrame(const glm::quat& targetRotation) { glm::quat parentRotation = computeParentRotation(); - _rotationInParentFrame = targetRotation; + _rotationInConstrainedFrame = targetRotation; // R' = Rp * Rpre * r' * Rpost - _rotation = parentRotation * _fbxJoint->preRotation * _rotationInParentFrame * _fbxJoint->postRotation; + _rotation = parentRotation * _fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation; } -const glm::vec3& JointState::getDefaultTranslationInParentFrame() const { +const glm::vec3& JointState::getDefaultTranslationInConstrainedFrame() const { assert(_fbxJoint != NULL); return _fbxJoint->translation; } @@ -185,5 +185,5 @@ const glm::vec3& JointState::getDefaultTranslationInParentFrame() const { void JointState::slaveVisibleTransform() { _visibleTransform = _transform; _visibleRotation = _rotation; - _visibleRotationInParentFrame = _rotationInParentFrame; + _visibleRotationInConstrainedFrame = _rotationInConstrainedFrame; } diff --git a/interface/src/renderer/JointState.h b/interface/src/renderer/JointState.h index 3bd752cdff..049eb6e6b0 100644 --- a/interface/src/renderer/JointState.h +++ b/interface/src/renderer/JointState.h @@ -66,14 +66,14 @@ public: void restoreRotation(float fraction, float priority); /// \param rotation is from bind- to model-frame - /// computes and sets new _rotationInParentFrame + /// computes and sets new _rotationInConstrainedFrame /// NOTE: the JointState's model-frame transform/rotation are NOT updated! void setRotationFromBindFrame(const glm::quat& rotation, float priority, bool constrain = false); - void setRotationInParentFrame(const glm::quat& targetRotation); - const glm::quat& getRotationInParentFrame() const { return _rotationInParentFrame; } + void setRotationInConstrainedFrame(const glm::quat& targetRotation); + const glm::quat& getRotationInConstrainedFrame() const { return _rotationInConstrainedFrame; } - const glm::vec3& getDefaultTranslationInParentFrame() const; + const glm::vec3& getDefaultTranslationInConstrainedFrame() const; void clearTransformTranslation(); @@ -92,11 +92,11 @@ private: glm::mat4 _transform; // joint- to model-frame glm::quat _rotation; // joint- to model-frame - glm::quat _rotationInParentFrame; // joint- to parentJoint-frame + glm::quat _rotationInConstrainedFrame; // rotation in frame where angular constraints would be applied glm::mat4 _visibleTransform; glm::quat _visibleRotation; - glm::quat _visibleRotationInParentFrame; + glm::quat _visibleRotationInConstrainedFrame; const FBXJoint* _fbxJoint; // JointState does NOT own its FBXJoint AngularConstraint* _constraint; // JointState owns its AngularConstraint diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 8b8557709c..cbdbff072b 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -460,7 +460,7 @@ void Model::reset() { } const FBXGeometry& geometry = _geometry->getFBXGeometry(); for (int i = 0; i < _jointStates.size(); i++) { - _jointStates[i].setRotationInParentFrame(geometry.joints.at(i).rotation); + _jointStates[i].setRotationInConstrainedFrame(geometry.joints.at(i).rotation); } } @@ -688,7 +688,7 @@ bool Model::getJointState(int index, glm::quat& rotation) const { if (index == -1 || index >= _jointStates.size()) { return false; } - rotation = _jointStates.at(index).getRotationInParentFrame(); + rotation = _jointStates.at(index).getRotationInConstrainedFrame(); const glm::quat& defaultRotation = _geometry->getFBXGeometry().joints.at(index).rotation; return glm::abs(rotation.x - defaultRotation.x) >= EPSILON || glm::abs(rotation.y - defaultRotation.y) >= EPSILON || @@ -701,7 +701,7 @@ void Model::setJointState(int index, bool valid, const glm::quat& rotation, floa JointState& state = _jointStates[index]; if (priority >= state._animationPriority) { if (valid) { - state.setRotationInParentFrame(rotation); + state.setRotationInConstrainedFrame(rotation); state._animationPriority = priority; } else { state.restoreRotation(1.0f, priority); @@ -1787,7 +1787,7 @@ void AnimationHandle::applyFrame(float frameIndex) { if (mapping != -1) { JointState& state = _model->_jointStates[mapping]; if (_priority >= state._animationPriority) { - state.setRotationInParentFrame(safeMix(floorFrame.rotations.at(i), ceilFrame.rotations.at(i), frameFraction)); + state.setRotationInConstrainedFrame(safeMix(floorFrame.rotations.at(i), ceilFrame.rotations.at(i), frameFraction)); state._animationPriority = _priority; } } From d1b96110409db6c8e1cf515de25b52b70975c876 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Thu, 10 Jul 2014 18:52:38 +0200 Subject: [PATCH 5/9] Remove debug output lines. --- interface/src/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 95cfaab4cf..ace265ad4f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -803,7 +803,6 @@ bool Application::event(QEvent* event) { } void Application::keyPressEvent(QKeyEvent* event) { - qDebug("Application::keyPressEvent(%x)", event->key()); _keysPressed.insert(event->key()); @@ -1054,7 +1053,6 @@ void Application::keyPressEvent(QKeyEvent* event) { } void Application::keyReleaseEvent(QKeyEvent* event) { - qDebug("Application::keyReleaseEvent(%x)", event->key()); _keysPressed.remove(event->key()); From d555017fb4c62690b5447a3033e3ca413835d015 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Thu, 10 Jul 2014 19:25:00 +0200 Subject: [PATCH 6/9] Coding style fix. --- interface/src/GLCanvas.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 87c1016c5e..cde1890e6d 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -184,12 +184,13 @@ bool GLCanvas::eventFilter(QObject*, QEvent* event) { { QKeyEvent* keyEvent = static_cast(event); if (keyEvent->key() == Qt::Key_Alt || keyEvent->key() == Qt::Key_Meta) { - if (event->type() == QEvent::KeyPress) + if (event->type() == QEvent::KeyPress) { keyPressEvent(keyEvent); - else if (event->type() == QEvent::KeyRelease) + } else if (event->type() == QEvent::KeyRelease) { keyReleaseEvent(keyEvent); - else + } else { QGLWidget::event(event); + } return true; } } From fdd9acb47768df14819175f9bb802e39995535f0 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 10 Jul 2014 10:55:41 -0700 Subject: [PATCH 7/9] bug fix: bad logic for early exit --- interface/src/avatar/AvatarManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 86ec7c2680..debe6489ea 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -41,7 +41,7 @@ void AvatarManager::init() { } void AvatarManager::updateOtherAvatars(float deltaTime) { - if (_avatarHash.size() > 1) { + if (_avatarHash.size() < 2) { return; } bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); From ad6a219a60b0b4abbaecca44663ea60c8da47c62 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 10 Jul 2014 11:08:15 -0700 Subject: [PATCH 8/9] fix bug: remove redundant _skeleton.simulate() --- interface/src/avatar/Avatar.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 4efb03b3f5..db4f44c82c 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -145,20 +145,20 @@ void Avatar::simulate(float deltaTime) { _skeletonModel.setLODDistance(getLODDistance()); if (!_shouldRenderBillboard && inViewFrustum) { - if (_hasNewJointRotations) { - PerformanceTimer perfTimer("skeleton"); - for (int i = 0; i < _jointData.size(); i++) { - const JointData& data = _jointData.at(i); - _skeletonModel.setJointState(i, data.valid, data.rotation); - } - _skeletonModel.simulate(deltaTime); - } { - PerformanceTimer perfTimer("head"); + PerformanceTimer perfTimer("skeleton"); + if (_hasNewJointRotations) { + for (int i = 0; i < _jointData.size(); i++) { + const JointData& data = _jointData.at(i); + _skeletonModel.setJointState(i, data.valid, data.rotation); + } + } _skeletonModel.simulate(deltaTime, _hasNewJointRotations); simulateAttachments(deltaTime); _hasNewJointRotations = false; - + } + { + PerformanceTimer perfTimer("head"); glm::vec3 headPosition = _position; _skeletonModel.getHeadPosition(headPosition); Head* head = getHead(); From 0be70063c5236bec901e6e6c63b80ed7a922cf0a Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 10 Jul 2014 11:39:49 -0700 Subject: [PATCH 9/9] only set hasNewJointRotations true for valid rotation --- libraries/avatars/src/AvatarData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 3f3e71c5e8..6cfa4ba488 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -490,11 +490,11 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { for (int i = 0; i < numJoints; i++) { JointData& data = _jointData[i]; if (data.valid) { + _hasNewJointRotations = true; sourceBuffer += unpackOrientationQuatFromBytes(sourceBuffer, data.rotation); } } } // numJoints * 8 bytes - _hasNewJointRotations = true; return sourceBuffer - startPosition; }