use assert rather than whole if block

This commit is contained in:
humbletim 2017-05-08 21:34:55 -04:00
parent 42d1498d20
commit 68ca0d921e

View file

@ -73,51 +73,50 @@ void SkeletonModel::initJointStates() {
// Called within Model::simulate call, below. // Called within Model::simulate call, below.
void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
if (!_owningAvatar->isMyAvatar()) { assert(!_owningAvatar->isMyAvatar());
const FBXGeometry& geometry = getFBXGeometry(); const FBXGeometry& geometry = getFBXGeometry();
Head* head = _owningAvatar->getHead(); Head* head = _owningAvatar->getHead();
// make sure lookAt is not too close to face (avoid crosseyes) // make sure lookAt is not too close to face (avoid crosseyes)
glm::vec3 lookAt = _owningAvatar->isMyAvatar() ? head->getLookAtPosition() : head->getCorrectedLookAtPosition(); glm::vec3 lookAt = _owningAvatar->isMyAvatar() ? head->getLookAtPosition() : head->getCorrectedLookAtPosition();
glm::vec3 focusOffset = lookAt - _owningAvatar->getHead()->getEyePosition(); glm::vec3 focusOffset = lookAt - _owningAvatar->getHead()->getEyePosition();
float focusDistance = glm::length(focusOffset); float focusDistance = glm::length(focusOffset);
const float MIN_LOOK_AT_FOCUS_DISTANCE = 1.0f; const float MIN_LOOK_AT_FOCUS_DISTANCE = 1.0f;
if (focusDistance < MIN_LOOK_AT_FOCUS_DISTANCE && focusDistance > EPSILON) { if (focusDistance < MIN_LOOK_AT_FOCUS_DISTANCE && focusDistance > EPSILON) {
lookAt = _owningAvatar->getHead()->getEyePosition() + (MIN_LOOK_AT_FOCUS_DISTANCE / focusDistance) * focusOffset; lookAt = _owningAvatar->getHead()->getEyePosition() + (MIN_LOOK_AT_FOCUS_DISTANCE / focusDistance) * focusOffset;
} }
// no need to call Model::updateRig() because otherAvatars get their joint state // no need to call Model::updateRig() because otherAvatars get their joint state
// copied directly from AvtarData::_jointData (there are no Rig animations to blend) // copied directly from AvtarData::_jointData (there are no Rig animations to blend)
_needsUpdateClusterMatrices = true; _needsUpdateClusterMatrices = true;
// This is a little more work than we really want. // This is a little more work than we really want.
// //
// Other avatars joint, including their eyes, should already be set just like any other joints // Other avatars joint, including their eyes, should already be set just like any other joints
// from the wire data. But when looking at me, we want the eyes to use the corrected lookAt. // from the wire data. But when looking at me, we want the eyes to use the corrected lookAt.
// //
// Thus this should really only be ... else if (_owningAvatar->getHead()->isLookingAtMe()) {... // Thus this should really only be ... else if (_owningAvatar->getHead()->isLookingAtMe()) {...
// However, in the !isLookingAtMe case, the eyes aren't rotating the way they should right now. // However, in the !isLookingAtMe case, the eyes aren't rotating the way they should right now.
// We will revisit that as priorities allow, and particularly after the new rig/animation/joints. // We will revisit that as priorities allow, and particularly after the new rig/animation/joints.
// If the head is not positioned, updateEyeJoints won't get the math right // If the head is not positioned, updateEyeJoints won't get the math right
glm::quat headOrientation; glm::quat headOrientation;
_rig->getJointRotation(geometry.headJointIndex, headOrientation); _rig->getJointRotation(geometry.headJointIndex, headOrientation);
glm::vec3 eulers = safeEulerAngles(headOrientation); glm::vec3 eulers = safeEulerAngles(headOrientation);
head->setBasePitch(glm::degrees(-eulers.x)); head->setBasePitch(glm::degrees(-eulers.x));
head->setBaseYaw(glm::degrees(eulers.y)); head->setBaseYaw(glm::degrees(eulers.y));
head->setBaseRoll(glm::degrees(-eulers.z)); head->setBaseRoll(glm::degrees(-eulers.z));
Rig::EyeParameters eyeParams; Rig::EyeParameters eyeParams;
eyeParams.eyeLookAt = lookAt; eyeParams.eyeLookAt = lookAt;
eyeParams.eyeSaccade = glm::vec3(0.0f); eyeParams.eyeSaccade = glm::vec3(0.0f);
eyeParams.modelRotation = getRotation(); eyeParams.modelRotation = getRotation();
eyeParams.modelTranslation = getTranslation(); eyeParams.modelTranslation = getTranslation();
eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex; eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex; eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
_rig->updateFromEyeParameters(eyeParams); _rig->updateFromEyeParameters(eyeParams);
}
} }
void SkeletonModel::updateAttitude() { void SkeletonModel::updateAttitude() {