diff --git a/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a b/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a index 4eaf323c32..bb0330bec3 100644 Binary files a/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a and b/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a differ diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3c4b531cf0..4edaa74325 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1389,21 +1389,22 @@ void Application::setRenderThirdPerson(bool thirdPerson) { } void Application::increaseAvatarSize() { - if (5.0f < 1.05f * _myAvatar.getNewScale()) { - return; + if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) { + _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale()); + qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } - - _myAvatar.setNewScale(1.05f * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } void Application::decreaseAvatarSize() { - if (.95f * _myAvatar.getNewScale() < 0.15f) { - return; + if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) { + _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale()); + qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } +} - _myAvatar.setNewScale(.95f * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); +void Application::resetAvatarSize() { + _myAvatar.setNewScale(1.f); + qDebug("Reseted scale to %f\n", _myAvatar.getNewScale()); } void Application::setFrustumOffset(bool frustumOffset) { @@ -1981,6 +1982,7 @@ void Application::initMenu() { "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); + renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize())); QMenu* toolsMenu = menuBar->addMenu("Tools"); diff --git a/interface/src/Application.h b/interface/src/Application.h index 1e84de91e8..5987a13900 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -134,6 +134,7 @@ private slots: void setRenderThirdPerson(bool thirdPerson); void increaseAvatarSize(); void decreaseAvatarSize(); + void resetAvatarSize(); void renderThrustAtVoxel(const glm::vec3& thrust); void renderLineToTouchedVoxel(); diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index f71fcb1e7d..3fdb401751 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -105,7 +105,7 @@ void Camera::updateFollowMode(float deltaTime) { } } -float Camera::getFarClip() { +float Camera::getFarClip() const { return (_scale * _farClip < std::numeric_limits::max()) ? _scale * _farClip : std::numeric_limits::max() - 1; @@ -194,7 +194,7 @@ void Camera::initialize() { } // call to find out if the view frustum needs to be reshaped -bool Camera::getFrustumNeedsReshape() { +bool Camera::getFrustumNeedsReshape() const { return _frustumNeedsReshape; } diff --git a/interface/src/Camera.h b/interface/src/Camera.h index d11b49c88c..de4553b6dc 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -48,20 +48,20 @@ public: void setEyeOffsetOrientation( const glm::quat& o ); void setScale ( const float s ); - const glm::vec3& getTargetPosition () { return _targetPosition; } - const glm::vec3& getPosition () { return _position; } - const glm::quat& getTargetRotation () { return _targetRotation; } - const glm::quat& getRotation () { return _rotation; } - CameraMode getMode () { return _mode; } - float getFieldOfView () { return _fieldOfView; } - float getAspectRatio () { return _aspectRatio; } - float getNearClip () { return _scale * _nearClip; } - float getFarClip (); - const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; } - const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; } - float getScale () { return _scale; } + const glm::vec3& getTargetPosition () const { return _targetPosition; } + const glm::vec3& getPosition () const { return _position; } + const glm::quat& getTargetRotation () const { return _targetRotation; } + const glm::quat& getRotation () const { return _rotation; } + CameraMode getMode () const { return _mode; } + float getFieldOfView () const { return _fieldOfView; } + float getAspectRatio () const { return _aspectRatio; } + float getNearClip () const { return _scale * _nearClip; } + float getFarClip () const; + const glm::vec3& getEyeOffsetPosition () const { return _eyeOffsetPosition; } + const glm::quat& getEyeOffsetOrientation () const { return _eyeOffsetOrientation; } + float getScale () const { return _scale; } - bool getFrustumNeedsReshape(); // call to find out if the view frustum needs to be reshaped + bool getFrustumNeedsReshape() const; // call to find out if the view frustum needs to be reshaped void setFrustumWasReshaped(); // call this after reshaping the view frustum. private: diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 97dbaac228..26192ffe5a 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -529,7 +529,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { } if (isMyAvatar() && _scale != _newScale) { - float scale = 0.95f * _scale + 0.05f * _newScale; + float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale; setScale(scale); Application::getInstance()->getCamera()->setScale(scale); } @@ -1539,7 +1539,8 @@ void Avatar::setNewScale(const float scale) { void Avatar::setScale(const float scale) { _scale = scale; - if (_newScale * .98 < _scale && _scale < _newScale * 1.02) { + if (_newScale * (1.f - RESCALING_TOLERANCE) < _scale && + _scale < _newScale * (1.f + RESCALING_TOLERANCE)) { _scale = _newScale; } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 1ac2a376bf..b490429ec9 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -26,6 +26,13 @@ #include "Transmitter.h" #include "world.h" + +static const float MAX_SCALE = 5.f; +static const float MIN_SCALE = .5f; +static const float SCALING_RATIO = .05f; +static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1 +static const float RESCALING_TOLERANCE = .02f; + const float BODY_BALL_RADIUS_PELVIS = 0.07; const float BODY_BALL_RADIUS_TORSO = 0.065; const float BODY_BALL_RADIUS_CHEST = 0.08; @@ -134,7 +141,6 @@ public: void setGravity (glm::vec3 gravity); void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction); void setOrientation (const glm::quat& orientation); - void setScale (const float scale); void setNewScale (const float scale); //getters @@ -283,6 +289,7 @@ private: void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency); void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime ); void checkForMouseRayTouching(); + void setScale (const float scale); }; #endif