code review

This commit is contained in:
Seth Alves 2015-12-17 11:46:41 -08:00
parent f3adb8a2f7
commit b80fa1c806
2 changed files with 27 additions and 5 deletions

View file

@ -78,8 +78,16 @@ void AvatarActionHold::prepareForPhysicsSimulation() {
// bullet has moved the av's rigid body but the rigid body's location has not yet been
// copied out into the Avatar class.
glm::quat avatarRotationInverse = glm::inverse(avatarRigidBodyRotation);
_palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition);
_palmRotationFromRigidBody = avatarRotationInverse * palmRotation;
// the offset should be in the frame of the avatar, but something about the order
// things are updated makes this wrong:
// _palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition);
// I'll leave it here as a comment in case avatar handling changes.
_palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition;
// rotation should also be needed, but again, the order of updates makes this unneeded. leaving
// code here for future reference.
// _palmRotationFromRigidBody = avatarRotationInverse * palmRotation;
});
}
@ -116,8 +124,21 @@ std::shared_ptr<Avatar> AvatarActionHold::getTarget(glm::quat& rotation, glm::ve
// and the data in the Avatar class is stale. This means that the result of get*PalmPosition will
// be stale. Instead, determine the current palm position with the current avatar's rigid body
// location and the saved offsets.
palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody;
palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody;
// this line is more correct but breaks for the current way avatar data is updated.
// palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody;
// instead, use this for now:
palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody;
// the item jitters the least by getting the rotation based on the opinion of Avatar.h rather
// than that of the rigid body. leaving this next line here for future reference:
// palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody;
if (isRightHand) {
palmRotation = holdingAvatar->getRightPalmRotation();
} else {
palmRotation = holdingAvatar->getLeftPalmRotation();
}
} else {
if (isRightHand) {
palmPosition = holdingAvatar->getRightPalmPosition();

View file

@ -61,7 +61,8 @@ private:
glm::vec3 _previousPositionalDelta;
glm::vec3 _palmOffsetFromRigidBody;
glm::quat _palmRotationFromRigidBody;
// leaving this here for future refernece.
// glm::quat _palmRotationFromRigidBody;
};
#endif // hifi_AvatarActionHold_h