fix for the avatar scale reset when we re-enter hmd mode

This commit is contained in:
amantley 2018-08-07 18:29:51 -07:00
parent 079b276c2b
commit 274bf33318
5 changed files with 10 additions and 1 deletions

View file

@ -8133,7 +8133,6 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) {
// reset the avatar, to set head and hand palms back to a reasonable default pose.
getMyAvatar()->reset(false);
// switch to first person if entering hmd and setting is checked
if (menu) {
QAction* action = menu->getActionForOption(newDisplayPlugin->getName());

View file

@ -806,6 +806,7 @@ void MyAvatar::updateSensorToWorldMatrix() {
// update the sensor mat so that the body position will end up in the desired
// position when driven from the head.
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
qCDebug(interfaceapp) << sensorToWorldScale;
glm::mat4 desiredMat = createMatFromScaleQuatAndPos(glm::vec3(sensorToWorldScale), getWorldOrientation(), getWorldPosition());
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
@ -1742,6 +1743,10 @@ controller::Pose MyAvatar::getControllerPoseInSensorFrame(controller::Action act
controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action action) const {
auto pose = getControllerPoseInSensorFrame(action);
glm::mat4 printout = getSensorToWorldMatrix();
if (action == controller::Action::HEAD) {
//qCDebug(interfaceapp) << "matrix 4 sensor to world" << printout;
}
if (pose.valid) {
return pose.transform(getSensorToWorldMatrix());
} else {
@ -1751,6 +1756,7 @@ controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action acti
controller::Pose MyAvatar::getControllerPoseInAvatarFrame(controller::Action action) const {
auto pose = getControllerPoseInWorldFrame(action);
// qCDebug(interfaceapp) << " the head position in world frame is " << pose.getTranslation();
if (pose.valid) {
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition()));
return pose.transform(invAvatarMatrix);

View file

@ -116,7 +116,9 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
// input action is the highest priority source for head orientation.
auto avatarHeadPose = myAvatar->getControllerPoseInAvatarFrame(controller::Action::HEAD);
if (avatarHeadPose.isValid()) {
//qCDebug(interfaceapp) << " the head position in avatar frame is " << avatarHeadPose.getTranslation();
AnimPose pose(avatarHeadPose.getRotation(), avatarHeadPose.getTranslation());
params.primaryControllerPoses[Rig::PrimaryControllerType_Head] = avatarToRigPose * pose;
params.primaryControllerFlags[Rig::PrimaryControllerType_Head] = (uint8_t)Rig::ControllerFlags::Enabled;

View file

@ -1761,6 +1761,7 @@ void Avatar::ensureInScene(AvatarSharedPointer self, const render::ScenePointer&
// thread-safe
float Avatar::getEyeHeight() const {
qCDebug(animation) << "modelscale "<<getModelScale() <<" eyeheight " << getUnscaledEyeHeight();
return getModelScale() * getUnscaledEyeHeight();
}

View file

@ -282,6 +282,7 @@ void Model::reset() {
const FBXGeometry& geometry = getFBXGeometry();
_rig.reset(geometry);
emit rigReset();
emit rigReady();
}
}