From fb37ef5bcaff1b91858b9e1b75bd92bb830a98b4 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 1 Apr 2014 11:25:39 -0700 Subject: [PATCH 1/2] Fix for annoying intermittent seg fault on Linux exit. Closes #2542. --- interface/interface_en.ts | 16 ++++++++-------- interface/src/Application.cpp | 3 +++ interface/src/Audio.cpp | 8 +++++++- interface/src/Audio.h | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index a1abb57b52..3f859c2cd1 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -4,22 +4,22 @@ Application - + Export Voxels - + Sparse Voxel Octree Files (*.svo) - + Open Script - + JavaScript Files (*.js) @@ -113,18 +113,18 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a237e92e2b..985e909f88 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -372,6 +372,9 @@ Application::~Application() { _nodeThread->quit(); _nodeThread->wait(); + // stop the audio process + QMetaObject::invokeMethod(&_audio, "stop"); + // ask the audio thread to quit and wait until it is done _audio.thread()->quit(); _audio.thread()->wait(); diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 9f993e653d..e4175cff48 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -308,6 +308,12 @@ void Audio::start() { } } +void Audio::stop() { + // "switch" to invalid devices in order to shut down the state + switchInputToAudioDevice(QAudioDeviceInfo()); + switchOutputToAudioDevice(QAudioDeviceInfo()); +} + QString Audio::getDefaultDeviceName(QAudio::Mode mode) { QAudioDeviceInfo deviceInfo = defaultAudioDeviceForMode(mode); return deviceInfo.deviceName(); @@ -846,7 +852,7 @@ bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) { // cleanup any previously initialized device if (_audioInput) { _audioInput->stop(); - disconnect(_inputDevice, 0, 0, 0); + disconnect(_inputDevice); _inputDevice = NULL; delete _audioInput; diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 170572a4d7..e728bc9645 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -76,6 +76,7 @@ public: public slots: void start(); + void stop(); void addReceivedAudioToBuffer(const QByteArray& audioByteArray); void handleAudioInput(); void reset(); From 865ca7de205d784fdd396c799952a23f5ca3167e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 1 Apr 2014 16:01:29 -0700 Subject: [PATCH 2/2] Align forearms with wrists. Closes #2577. --- interface/src/avatar/SkeletonModel.cpp | 43 +++++++++++--------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index c44d2ebdea..ca18c62718 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -133,12 +133,17 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector& fingerJoin return; } const FBXGeometry& geometry = _geometry->getFBXGeometry(); - setJointPosition(jointIndex, palm.getPosition()); float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f; + int parentJointIndex = geometry.joints.at(jointIndex).parentIndex; + if (parentJointIndex == -1) { + return; + } + + // rotate forearm to align with palm direction glm::quat palmRotation; - getJointRotation(jointIndex, palmRotation, true); - applyRotationDelta(jointIndex, rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()), false); - getJointRotation(jointIndex, palmRotation, true); + getJointRotation(parentJointIndex, palmRotation, true); + applyRotationDelta(parentJointIndex, rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()), false); + getJointRotation(parentJointIndex, palmRotation, true); // sort the finger indices by raw x, get the average direction QVector fingerIndices; @@ -155,33 +160,21 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector& fingerJoin } qSort(fingerIndices.begin(), fingerIndices.end()); - // rotate palm according to average finger direction + // rotate forearm according to average finger direction float directionLength = glm::length(direction); const unsigned int MIN_ROTATION_FINGERS = 3; if (directionLength > EPSILON && palm.getNumFingers() >= MIN_ROTATION_FINGERS) { - applyRotationDelta(jointIndex, rotationBetween(palmRotation * glm::vec3(-sign, 0.0f, 0.0f), direction), false); - getJointRotation(jointIndex, palmRotation, true); + applyRotationDelta(parentJointIndex, rotationBetween(palmRotation * glm::vec3(-sign, 0.0f, 0.0f), direction), false); + getJointRotation(parentJointIndex, palmRotation, true); } - // no point in continuing if there are no fingers - if (palm.getNumFingers() == 0 || fingerJointIndices.isEmpty()) { - return; - } + // let wrist inherit forearm rotation + _jointStates[jointIndex].rotation = glm::quat(); - // match them up as best we can - float proportion = fingerIndices.size() / (float)fingerJointIndices.size(); - for (int i = 0; i < fingerJointIndices.size(); i++) { - int fingerIndex = fingerIndices.at(roundf(i * proportion)).index; - glm::vec3 fingerVector = palm.getFingers()[fingerIndex].getTipPosition() - - palm.getFingers()[fingerIndex].getRootPosition(); - - int fingerJointIndex = fingerJointIndices.at(i); - int fingertipJointIndex = fingertipJointIndices.at(i); - glm::vec3 jointVector = extractTranslation(geometry.joints.at(fingertipJointIndex).bindTransform) - - extractTranslation(geometry.joints.at(fingerJointIndex).bindTransform); - - setJointRotation(fingerJointIndex, rotationBetween(palmRotation * jointVector, fingerVector) * palmRotation, true); - } + // set elbow position from wrist position + glm::vec3 forearmVector = palmRotation * glm::vec3(sign, 0.0f, 0.0f); + setJointPosition(parentJointIndex, palm.getPosition() + forearmVector * + geometry.joints.at(jointIndex).distanceToParent * extractUniformScale(_scale)); } void SkeletonModel::updateJointState(int index) {