Remove unused variables, change orbit pitch behavior (closes #1582).

This commit is contained in:
Andrzej Kapolka 2014-01-17 17:00:03 -08:00
parent bb41fe6ddb
commit 765f98fadc

View file

@ -175,8 +175,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
// Compute instantaneous acceleration // Compute instantaneous acceleration
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime; float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
const float ACCELERATION_PITCH_DECAY = 0.4f;
const float ACCELERATION_PULL_THRESHOLD = 0.2f;
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f; const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
const int OCULUS_YAW_OFFSET_THRESHOLD = 10; const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
@ -475,14 +473,19 @@ void MyAvatar::loadData(QSettings* settings) {
} }
void MyAvatar::orbit(const glm::vec3& position, int deltaX, int deltaY) { void MyAvatar::orbit(const glm::vec3& position, int deltaX, int deltaY) {
glm::vec3 vector = getPosition() - position; // first orbit horizontally
glm::quat orientation = getOrientation(); glm::quat orientation = getOrientation();
glm::vec3 up = orientation * IDENTITY_UP;
const float ANGULAR_SCALE = 0.5f; const float ANGULAR_SCALE = 0.5f;
glm::quat rotation = glm::angleAxis(deltaX * -ANGULAR_SCALE, up); glm::quat rotation = glm::angleAxis(deltaX * -ANGULAR_SCALE, orientation * IDENTITY_UP);
const float LINEAR_SCALE = 0.01f; setPosition(position + rotation * (getPosition() - position));
setPosition(position + rotation * vector + up * (deltaY * LINEAR_SCALE * _scale)); orientation = rotation * orientation;
setOrientation(rotation * orientation); setOrientation(orientation);
// then vertically
float oldMousePitch = _head.getMousePitch();
_head.setMousePitch(oldMousePitch + deltaY * ANGULAR_SCALE);
rotation = glm::angleAxis(_head.getMousePitch() - oldMousePitch, orientation * IDENTITY_RIGHT);
setPosition(position + rotation * (getPosition() - position));
} }
float MyAvatar::getAbsoluteHeadYaw() const { float MyAvatar::getAbsoluteHeadYaw() const {