mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 12:30:40 +02:00
Addressing some PR feedback; moved easeInEaseOut to Interpolate class. My function is faster than andrew's. :D
This commit is contained in:
parent
0a5dfbb9af
commit
557a8fffd7
6 changed files with 29 additions and 21 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)>;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue