- changed according to review comments

- added reset scale option
This commit is contained in:
atlante45 2013-08-05 15:23:40 -07:00
parent 6c0ea0cf9c
commit 29062c51b2
7 changed files with 38 additions and 27 deletions

View file

@ -1389,21 +1389,22 @@ void Application::setRenderThirdPerson(bool thirdPerson) {
} }
void Application::increaseAvatarSize() { void Application::increaseAvatarSize() {
if (5.0f < 1.05f * _myAvatar.getNewScale()) { if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) {
return; _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale());
}
_myAvatar.setNewScale(1.05f * _myAvatar.getNewScale());
qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); qDebug("Changed scale to %f\n", _myAvatar.getNewScale());
}
} }
void Application::decreaseAvatarSize() { void Application::decreaseAvatarSize() {
if (.95f * _myAvatar.getNewScale() < 0.15f) { if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) {
return; _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale());
}
_myAvatar.setNewScale(.95f * _myAvatar.getNewScale());
qDebug("Changed scale to %f\n", _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) { void Application::setFrustumOffset(bool frustumOffset) {
@ -1981,6 +1982,7 @@ void Application::initMenu() {
"Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus);
renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus);
renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize()));
QMenu* toolsMenu = menuBar->addMenu("Tools"); QMenu* toolsMenu = menuBar->addMenu("Tools");

View file

@ -134,6 +134,7 @@ private slots:
void setRenderThirdPerson(bool thirdPerson); void setRenderThirdPerson(bool thirdPerson);
void increaseAvatarSize(); void increaseAvatarSize();
void decreaseAvatarSize(); void decreaseAvatarSize();
void resetAvatarSize();
void renderThrustAtVoxel(const glm::vec3& thrust); void renderThrustAtVoxel(const glm::vec3& thrust);
void renderLineToTouchedVoxel(); void renderLineToTouchedVoxel();

View file

@ -105,7 +105,7 @@ void Camera::updateFollowMode(float deltaTime) {
} }
} }
float Camera::getFarClip() { float Camera::getFarClip() const {
return (_scale * _farClip < std::numeric_limits<int16_t>::max()) return (_scale * _farClip < std::numeric_limits<int16_t>::max())
? _scale * _farClip ? _scale * _farClip
: std::numeric_limits<int16_t>::max() - 1; : std::numeric_limits<int16_t>::max() - 1;
@ -194,7 +194,7 @@ void Camera::initialize() {
} }
// call to find out if the view frustum needs to be reshaped // call to find out if the view frustum needs to be reshaped
bool Camera::getFrustumNeedsReshape() { bool Camera::getFrustumNeedsReshape() const {
return _frustumNeedsReshape; return _frustumNeedsReshape;
} }

View file

@ -48,20 +48,20 @@ public:
void setEyeOffsetOrientation( const glm::quat& o ); void setEyeOffsetOrientation( const glm::quat& o );
void setScale ( const float s ); void setScale ( const float s );
const glm::vec3& getTargetPosition () { return _targetPosition; } const glm::vec3& getTargetPosition () const { return _targetPosition; }
const glm::vec3& getPosition () { return _position; } const glm::vec3& getPosition () const { return _position; }
const glm::quat& getTargetRotation () { return _targetRotation; } const glm::quat& getTargetRotation () const { return _targetRotation; }
const glm::quat& getRotation () { return _rotation; } const glm::quat& getRotation () const { return _rotation; }
CameraMode getMode () { return _mode; } CameraMode getMode () const { return _mode; }
float getFieldOfView () { return _fieldOfView; } float getFieldOfView () const { return _fieldOfView; }
float getAspectRatio () { return _aspectRatio; } float getAspectRatio () const { return _aspectRatio; }
float getNearClip () { return _scale * _nearClip; } float getNearClip () const { return _scale * _nearClip; }
float getFarClip (); float getFarClip () const;
const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; } const glm::vec3& getEyeOffsetPosition () const { return _eyeOffsetPosition; }
const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; } const glm::quat& getEyeOffsetOrientation () const { return _eyeOffsetOrientation; }
float getScale () { return _scale; } 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. void setFrustumWasReshaped(); // call this after reshaping the view frustum.
private: private:

View file

@ -529,7 +529,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
} }
if (isMyAvatar() && _scale != _newScale) { if (isMyAvatar() && _scale != _newScale) {
float scale = 0.95f * _scale + 0.05f * _newScale; float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale;
setScale(scale); setScale(scale);
Application::getInstance()->getCamera()->setScale(scale); Application::getInstance()->getCamera()->setScale(scale);
} }
@ -1539,7 +1539,8 @@ void Avatar::setNewScale(const float scale) {
void Avatar::setScale(const float scale) { void Avatar::setScale(const float scale) {
_scale = 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; _scale = _newScale;
} }

View file

@ -26,6 +26,13 @@
#include "Transmitter.h" #include "Transmitter.h"
#include "world.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_PELVIS = 0.07;
const float BODY_BALL_RADIUS_TORSO = 0.065; const float BODY_BALL_RADIUS_TORSO = 0.065;
const float BODY_BALL_RADIUS_CHEST = 0.08; const float BODY_BALL_RADIUS_CHEST = 0.08;
@ -134,7 +141,6 @@ public:
void setGravity (glm::vec3 gravity); void setGravity (glm::vec3 gravity);
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction); void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
void setOrientation (const glm::quat& orientation); void setOrientation (const glm::quat& orientation);
void setScale (const float scale);
void setNewScale (const float scale); void setNewScale (const float scale);
//getters //getters
@ -283,6 +289,7 @@ private:
void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency); void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency);
void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime ); void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime );
void checkForMouseRayTouching(); void checkForMouseRayTouching();
void setScale (const float scale);
}; };
#endif #endif