Merge pull request #2585 from ey6es/master

Align forearms with wrists again, fix for annoying intermittent seg fault on Linux exit.
This commit is contained in:
Philip Rosedale 2014-04-01 20:59:51 -07:00
commit e53bfe4ea1
5 changed files with 37 additions and 34 deletions

View file

@ -4,22 +4,22 @@
<context> <context>
<name>Application</name> <name>Application</name>
<message> <message>
<location filename="src/Application.cpp" line="1382"/> <location filename="src/Application.cpp" line="1385"/>
<source>Export Voxels</source> <source>Export Voxels</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="1383"/> <location filename="src/Application.cpp" line="1386"/>
<source>Sparse Voxel Octree Files (*.svo)</source> <source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3703"/> <location filename="src/Application.cpp" line="3714"/>
<source>Open Script</source> <source>Open Script</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3704"/> <location filename="src/Application.cpp" line="3715"/>
<source>JavaScript Files (*.js)</source> <source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -113,18 +113,18 @@
<context> <context>
<name>Menu</name> <name>Menu</name>
<message> <message>
<location filename="src/Menu.cpp" line="462"/> <location filename="src/Menu.cpp" line="463"/>
<source>Open .ini config file</source> <source>Open .ini config file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Menu.cpp" line="464"/> <location filename="src/Menu.cpp" line="465"/>
<location filename="src/Menu.cpp" line="476"/> <location filename="src/Menu.cpp" line="477"/>
<source>Text files (*.ini)</source> <source>Text files (*.ini)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Menu.cpp" line="474"/> <location filename="src/Menu.cpp" line="475"/>
<source>Save .ini config file</source> <source>Save .ini config file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -372,6 +372,9 @@ Application::~Application() {
_nodeThread->quit(); _nodeThread->quit();
_nodeThread->wait(); _nodeThread->wait();
// stop the audio process
QMetaObject::invokeMethod(&_audio, "stop");
// ask the audio thread to quit and wait until it is done // ask the audio thread to quit and wait until it is done
_audio.thread()->quit(); _audio.thread()->quit();
_audio.thread()->wait(); _audio.thread()->wait();

View file

@ -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) { QString Audio::getDefaultDeviceName(QAudio::Mode mode) {
QAudioDeviceInfo deviceInfo = defaultAudioDeviceForMode(mode); QAudioDeviceInfo deviceInfo = defaultAudioDeviceForMode(mode);
return deviceInfo.deviceName(); return deviceInfo.deviceName();
@ -846,7 +852,7 @@ bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
// cleanup any previously initialized device // cleanup any previously initialized device
if (_audioInput) { if (_audioInput) {
_audioInput->stop(); _audioInput->stop();
disconnect(_inputDevice, 0, 0, 0); disconnect(_inputDevice);
_inputDevice = NULL; _inputDevice = NULL;
delete _audioInput; delete _audioInput;

View file

@ -76,6 +76,7 @@ public:
public slots: public slots:
void start(); void start();
void stop();
void addReceivedAudioToBuffer(const QByteArray& audioByteArray); void addReceivedAudioToBuffer(const QByteArray& audioByteArray);
void handleAudioInput(); void handleAudioInput();
void reset(); void reset();

View file

@ -133,12 +133,17 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin
return; return;
} }
const FBXGeometry& geometry = _geometry->getFBXGeometry(); const FBXGeometry& geometry = _geometry->getFBXGeometry();
setJointPosition(jointIndex, palm.getPosition());
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f; 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; glm::quat palmRotation;
getJointRotation(jointIndex, palmRotation, true); getJointRotation(parentJointIndex, palmRotation, true);
applyRotationDelta(jointIndex, rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()), false); applyRotationDelta(parentJointIndex, rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()), false);
getJointRotation(jointIndex, palmRotation, true); getJointRotation(parentJointIndex, palmRotation, true);
// sort the finger indices by raw x, get the average direction // sort the finger indices by raw x, get the average direction
QVector<IndexValue> fingerIndices; QVector<IndexValue> fingerIndices;
@ -155,33 +160,21 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin
} }
qSort(fingerIndices.begin(), fingerIndices.end()); qSort(fingerIndices.begin(), fingerIndices.end());
// rotate palm according to average finger direction // rotate forearm according to average finger direction
float directionLength = glm::length(direction); float directionLength = glm::length(direction);
const unsigned int MIN_ROTATION_FINGERS = 3; const unsigned int MIN_ROTATION_FINGERS = 3;
if (directionLength > EPSILON && palm.getNumFingers() >= MIN_ROTATION_FINGERS) { if (directionLength > EPSILON && palm.getNumFingers() >= MIN_ROTATION_FINGERS) {
applyRotationDelta(jointIndex, rotationBetween(palmRotation * glm::vec3(-sign, 0.0f, 0.0f), direction), false); applyRotationDelta(parentJointIndex, rotationBetween(palmRotation * glm::vec3(-sign, 0.0f, 0.0f), direction), false);
getJointRotation(jointIndex, palmRotation, true); getJointRotation(parentJointIndex, palmRotation, true);
} }
// no point in continuing if there are no fingers // let wrist inherit forearm rotation
if (palm.getNumFingers() == 0 || fingerJointIndices.isEmpty()) { _jointStates[jointIndex].rotation = glm::quat();
return;
}
// match them up as best we can // set elbow position from wrist position
float proportion = fingerIndices.size() / (float)fingerJointIndices.size(); glm::vec3 forearmVector = palmRotation * glm::vec3(sign, 0.0f, 0.0f);
for (int i = 0; i < fingerJointIndices.size(); i++) { setJointPosition(parentJointIndex, palm.getPosition() + forearmVector *
int fingerIndex = fingerIndices.at(roundf(i * proportion)).index; geometry.joints.at(jointIndex).distanceToParent * extractUniformScale(_scale));
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);
}
} }
void SkeletonModel::updateJointState(int index) { void SkeletonModel::updateJointState(int index) {