Addressing some PR feedback; moved easeInEaseOut to Interpolate class. My function is faster than andrew's. :D

This commit is contained in:
trent 2017-05-02 19:56:36 -04:00
parent 0a5dfbb9af
commit 557a8fffd7
6 changed files with 29 additions and 21 deletions

View file

@ -276,7 +276,7 @@ glm::quat MyAvatar::getOrientationOutbound() const {
// Smooth the remote avatar movement.
float t = _smoothOrientationTimer / _smoothOrientationTime;
float interp = easeInOutQuad(glm::clamp(t, 0.0f, 1.0f));
float interp = Interpolate::easeInOutQuad(glm::clamp(t, 0.0f, 1.0f));
return (slerp(_smoothOrientationInitial, _smoothOrientationTarget, interp));
}
@ -1863,7 +1863,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
}
// update body orientation by movement inputs
glm::quat initialOrientation = getOrientation();
glm::quat initialOrientation = getOrientationOutbound();
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
if (snapTurn) {

View file

@ -579,17 +579,6 @@ private:
void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity);
// Basic ease-in-ease-out function for smoothing values.
static inline float easeInOutQuad(float lerpValue) {
assert(!((lerpValue < 0.0f) || (lerpValue > 1.0f)));
if (lerpValue < 0.5f) {
return (2.0f * lerpValue * lerpValue);
}
return (lerpValue*(4.0f - 2.0f * lerpValue) - 1.0f);
}
private:
virtual void updatePalms() override {}

View file

@ -40,11 +40,6 @@ ModelOverlay::ModelOverlay(const ModelOverlay* modelOverlay) :
}
void ModelOverlay::update(float deltatime) {
if (_model && _model->isActive()) {
_model->setRotation(getRotation());
_model->setTranslation(getPosition());
}
if (_updateModel) {
_updateModel = false;
_model->setSnapModelToCenter(true);
@ -275,3 +270,12 @@ bool ModelOverlay::findRayIntersectionExtraInfo(const glm::vec3& origin, const g
ModelOverlay* ModelOverlay::createClone() const {
return new ModelOverlay(this);
}
void ModelOverlay::locationChanged(bool tellPhysics) {
Base3DOverlay::locationChanged(tellPhysics);
if (_model && _model->isActive()) {
_model->setRotation(getRotation());
_model->setTranslation(getPosition());
}
}

View file

@ -39,6 +39,8 @@ public:
virtual bool addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
void locationChanged(bool tellPhysics) override;
protected:
// helper to extract metadata from our Model's rigged joints
template <typename itemType> using mapFunction = std::function<itemType(int jointIndex)>;

View file

@ -77,3 +77,13 @@ float Interpolate::calculateFadeRatio(quint64 start) {
const float EASING_SCALE = 1.001f;
return std::min(EASING_SCALE * fadeRatio, 1.0f);
}
float Interpolate::easeInOutQuad(float lerpValue) {
assert(!((lerpValue < 0.0f) || (lerpValue > 1.0f)));
if (lerpValue < 0.5f) {
return (2.0f * lerpValue * lerpValue);
}
return (lerpValue*(4.0f - 2.0f * lerpValue) - 1.0f);
}

View file

@ -30,6 +30,9 @@ public:
static float simpleNonLinearBlend(float fraction);
static float calculateFadeRatio(quint64 start);
// Basic ease-in-ease-out function for smoothing values.
static float easeInOutQuad(float lerpValue);
};
#endif // hifi_Interpolate_h