mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:28:46 +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.
|
// Smooth the remote avatar movement.
|
||||||
float t = _smoothOrientationTimer / _smoothOrientationTime;
|
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));
|
return (slerp(_smoothOrientationInitial, _smoothOrientationTarget, interp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1863,13 +1863,13 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update body orientation by movement inputs
|
// 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))));
|
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||||
|
|
||||||
if (snapTurn) {
|
if (snapTurn) {
|
||||||
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
||||||
_smoothOrientationInitial = initialOrientation;
|
_smoothOrientationInitial = initialOrientation;
|
||||||
_smoothOrientationTarget = getOrientation();
|
_smoothOrientationTarget = getOrientation();
|
||||||
_smoothOrientationTimer = 0.0f;
|
_smoothOrientationTimer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -579,17 +579,6 @@ private:
|
||||||
|
|
||||||
void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity);
|
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:
|
private:
|
||||||
|
|
||||||
virtual void updatePalms() override {}
|
virtual void updatePalms() override {}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
QString const ModelOverlay::TYPE = "model";
|
QString const ModelOverlay::TYPE = "model";
|
||||||
|
|
||||||
ModelOverlay::ModelOverlay()
|
ModelOverlay::ModelOverlay()
|
||||||
: _model(std::make_shared<Model>(std::make_shared<Rig>(), nullptr, this)),
|
: _model(std::make_shared<Model>(std::make_shared<Rig>(), nullptr, this)),
|
||||||
_modelTextures(QVariantMap())
|
_modelTextures(QVariantMap())
|
||||||
{
|
{
|
||||||
_model->init();
|
_model->init();
|
||||||
|
@ -40,11 +40,6 @@ ModelOverlay::ModelOverlay(const ModelOverlay* modelOverlay) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOverlay::update(float deltatime) {
|
void ModelOverlay::update(float deltatime) {
|
||||||
if (_model && _model->isActive()) {
|
|
||||||
_model->setRotation(getRotation());
|
|
||||||
_model->setTranslation(getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_updateModel) {
|
if (_updateModel) {
|
||||||
_updateModel = false;
|
_updateModel = false;
|
||||||
_model->setSnapModelToCenter(true);
|
_model->setSnapModelToCenter(true);
|
||||||
|
@ -274,4 +269,13 @@ bool ModelOverlay::findRayIntersectionExtraInfo(const glm::vec3& origin, const g
|
||||||
|
|
||||||
ModelOverlay* ModelOverlay::createClone() const {
|
ModelOverlay* ModelOverlay::createClone() const {
|
||||||
return new ModelOverlay(this);
|
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 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;
|
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
|
void locationChanged(bool tellPhysics) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// helper to extract metadata from our Model's rigged joints
|
// helper to extract metadata from our Model's rigged joints
|
||||||
template <typename itemType> using mapFunction = std::function<itemType(int jointIndex)>;
|
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;
|
const float EASING_SCALE = 1.001f;
|
||||||
return std::min(EASING_SCALE * fadeRatio, 1.0f);
|
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 simpleNonLinearBlend(float fraction);
|
||||||
|
|
||||||
static float calculateFadeRatio(quint64 start);
|
static float calculateFadeRatio(quint64 start);
|
||||||
|
|
||||||
|
// Basic ease-in-ease-out function for smoothing values.
|
||||||
|
static float easeInOutQuad(float lerpValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Interpolate_h
|
#endif // hifi_Interpolate_h
|
||||||
|
|
Loading…
Reference in a new issue