mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 19:39:20 +02:00
print warnings if head position contains not-a-number
This commit is contained in:
parent
00538c69cd
commit
b6f7d2eb89
2 changed files with 46 additions and 16 deletions
|
@ -561,6 +561,12 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
if (!_skeletonModel->getHeadPosition(headPosition)) {
|
||||
headPosition = getWorldPosition();
|
||||
}
|
||||
|
||||
if (isNaN(headPosition)) {
|
||||
qCDebug(interfaceapp) << "MyAvatar::simulate headPosition is NaN";
|
||||
headPosition = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
head->setPosition(headPosition);
|
||||
head->setScale(getModelScale());
|
||||
head->simulate(deltaTime);
|
||||
|
@ -2700,27 +2706,42 @@ void MyAvatar::setWalkSpeed(float value) {
|
|||
}
|
||||
|
||||
glm::vec3 MyAvatar::getPositionForAudio() {
|
||||
glm::vec3 result;
|
||||
switch (_audioListenerMode) {
|
||||
case AudioListenerMode::FROM_HEAD:
|
||||
return getHead()->getPosition();
|
||||
result = getHead()->getPosition();
|
||||
case AudioListenerMode::FROM_CAMERA:
|
||||
return qApp->getCamera().getPosition();
|
||||
result = qApp->getCamera().getPosition();
|
||||
case AudioListenerMode::CUSTOM:
|
||||
return _customListenPosition;
|
||||
result = _customListenPosition;
|
||||
}
|
||||
return vec3();
|
||||
|
||||
if (isNaN(result)) {
|
||||
qCDebug(interfaceapp) << "MyAvatar::getPositionForAudio produced NaN" << _audioListenerMode;
|
||||
result = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::quat MyAvatar::getOrientationForAudio() {
|
||||
glm::quat result;
|
||||
|
||||
switch (_audioListenerMode) {
|
||||
case AudioListenerMode::FROM_HEAD:
|
||||
return getHead()->getFinalOrientationInWorldFrame();
|
||||
result = getHead()->getFinalOrientationInWorldFrame();
|
||||
case AudioListenerMode::FROM_CAMERA:
|
||||
return qApp->getCamera().getOrientation();
|
||||
result = qApp->getCamera().getOrientation();
|
||||
case AudioListenerMode::CUSTOM:
|
||||
return _customListenOrientation;
|
||||
result = _customListenOrientation;
|
||||
}
|
||||
return quat();
|
||||
|
||||
if (isNaN(result)) {
|
||||
qCDebug(interfaceapp) << "MyAvatar::getOrientationForAudio produced NaN" << _audioListenerMode;
|
||||
result = glm::quat();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void MyAvatar::setAudioListenerMode(AudioListenerMode audioListenerMode) {
|
||||
|
|
|
@ -445,22 +445,31 @@ void Rig::setJointRotation(int index, bool valid, const glm::quat& rotation, flo
|
|||
}
|
||||
|
||||
bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const {
|
||||
bool success { false };
|
||||
if (QThread::currentThread() == thread()) {
|
||||
if (isIndexValid(jointIndex)) {
|
||||
position = (rotation * _internalPoseSet._absolutePoses[jointIndex].trans()) + translation;
|
||||
return true;
|
||||
success = true;
|
||||
} else {
|
||||
return false;
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||
position = (rotation * _externalPoseSet._absolutePoses[jointIndex].trans()) + translation;
|
||||
success = true;
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||
position = (rotation * _externalPoseSet._absolutePoses[jointIndex].trans()) + translation;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
if (isNaN(position)) {
|
||||
qCWarning(animation) << "Rig::getJointPositionInWorldFrame produces NaN";
|
||||
success = false;
|
||||
position = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Rig::getJointPosition(int jointIndex, glm::vec3& position) const {
|
||||
|
|
Loading…
Reference in a new issue