Changed orientation tweak names, restore tweaked orientation rather than

primary one.  Closes #2310.
This commit is contained in:
Andrzej Kapolka 2014-03-14 11:13:15 -07:00
parent 5f7e41b79b
commit 4366b45445
3 changed files with 23 additions and 17 deletions

View file

@ -36,9 +36,9 @@ Head::Head(Avatar* owningAvatar) :
_leftEyeBlinkVelocity(0.0f), _leftEyeBlinkVelocity(0.0f),
_rightEyeBlinkVelocity(0.0f), _rightEyeBlinkVelocity(0.0f),
_timeWithoutTalking(0.0f), _timeWithoutTalking(0.0f),
_tweakedPitch(0.f), _pitchTweak(0.f),
_tweakedYaw(0.f), _yawTweak(0.f),
_tweakedRoll(0.f), _rollTweak(0.f),
_isCameraMoving(false), _isCameraMoving(false),
_faceModel(this) _faceModel(this)
{ {
@ -202,15 +202,15 @@ glm::vec3 Head::getScalePivot() const {
} }
float Head::getTweakedYaw() const { float Head::getTweakedYaw() const {
return glm::clamp(_yaw + _tweakedYaw, MIN_HEAD_YAW, MAX_HEAD_YAW); return glm::clamp(_yaw + _yawTweak, MIN_HEAD_YAW, MAX_HEAD_YAW);
} }
float Head::getTweakedPitch() const { float Head::getTweakedPitch() const {
return glm::clamp(_pitch + _tweakedPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); return glm::clamp(_pitch + _pitchTweak, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
} }
float Head::getTweakedRoll() const { float Head::getTweakedRoll() const {
return glm::clamp(_roll + _tweakedRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); return glm::clamp(_roll + _rollTweak, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
} }
void Head::applyCollision(CollisionInfo& collision) { void Head::applyCollision(CollisionInfo& collision) {

View file

@ -70,10 +70,15 @@ public:
/// Returns the point about which scaling occurs. /// Returns the point about which scaling occurs.
glm::vec3 getScalePivot() const; glm::vec3 getScalePivot() const;
void tweakPitch(float pitch) { _tweakedPitch = pitch; } void setPitchTweak(float pitch) { _pitchTweak = pitch; }
void tweakYaw(float yaw) { _tweakedYaw = yaw; } float getPitchTweak() const { return _pitchTweak; }
void tweakRoll(float roll) { _tweakedRoll = roll; }
void setYawTweak(float yaw) { _yawTweak = yaw; }
float getYawTweak() const { return _yawTweak; }
void setRollTweak(float roll) { _rollTweak = roll; }
float getRollTweak() const { return _rollTweak; }
virtual float getTweakedPitch() const; virtual float getTweakedPitch() const;
virtual float getTweakedYaw() const; virtual float getTweakedYaw() const;
virtual float getTweakedRoll() const; virtual float getTweakedRoll() const;
@ -104,9 +109,9 @@ private:
float _timeWithoutTalking; float _timeWithoutTalking;
// tweaked angles affect the rendered head, but not the camera // tweaked angles affect the rendered head, but not the camera
float _tweakedPitch; float _pitchTweak;
float _tweakedYaw; float _yawTweak;
float _tweakedRoll; float _rollTweak;
bool _isCameraMoving; bool _isCameraMoving;
FaceModel _faceModel; FaceModel _faceModel;

View file

@ -363,8 +363,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
// restore rotation, lean to neutral positions // restore rotation, lean to neutral positions
const float RESTORE_PERIOD = 1.f; // seconds const float RESTORE_PERIOD = 1.f; // seconds
float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f); float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f);
head->setYaw(glm::mix(head->getYaw(), 0.0f, restorePercentage)); head->setPitchTweak(glm::mix(head->getPitchTweak(), 0.0f, restorePercentage));
head->setRoll(glm::mix(head->getRoll(), 0.0f, restorePercentage)); head->setYawTweak(glm::mix(head->getYawTweak(), 0.0f, restorePercentage));
head->setRollTweak(glm::mix(head->getRollTweak(), 0.0f, restorePercentage));
head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage)); head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage));
head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage)); head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage));
return; return;
@ -375,9 +376,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f; const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f; const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f; const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
head->tweakPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); head->setPitchTweak(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
head->tweakYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); head->setYawTweak(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
head->tweakRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); head->setRollTweak(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
// Update torso lean distance based on accelerometer data // Update torso lean distance based on accelerometer data
const float TORSO_LENGTH = 0.5f; const float TORSO_LENGTH = 0.5f;