diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-20 19:24:49 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 19:24:49 -0300 |
commit | ee0f53df52d88ca57079579f3f3e943e7e40f53a (patch) | |
tree | fcf670f1e8aec411c6deaf97e9fc77bf5c195f31 /core/math/quat.cpp | |
parent | 72a02555850016ab792cf498c5370983d3b72832 (diff) | |
parent | 6f4f9aa6ded6da027c84cc466c767334dc3d3362 (diff) | |
download | redot-engine-ee0f53df52d88ca57079579f3f3e943e7e40f53a.tar.gz |
Merge pull request #7528 from tagcup/real_t_float_fixes
Use real_t rather than float or double in generic functions (core/mat…
Diffstat (limited to 'core/math/quat.cpp')
-rw-r--r-- | core/math/quat.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/math/quat.cpp b/core/math/quat.cpp index 055e2b7c35..4085f9b84a 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -124,8 +124,8 @@ Quat Quat::slerp(const Quat& q, const real_t& t) const { // Standard case (slerp) real_t sine = Math::sqrt(1 - cosine*cosine); real_t angle = Math::atan2(sine, cosine); - real_t inv_sine = 1.0f / sine; - real_t coeff_0 = Math::sin((1.0f - t) * angle) * inv_sine; + real_t inv_sine = 1.0 / sine; + real_t coeff_0 = Math::sin((1.0 - t) * angle) * inv_sine; real_t coeff_1 = Math::sin(t * angle) * inv_sine; Quat ret= src * coeff_0 + dst * coeff_1; @@ -137,7 +137,7 @@ Quat Quat::slerp(const Quat& q, const real_t& t) const { // 2. "rkP" and "q" are almost invedste of each other (cosine ~= -1), there // are an infinite number of possibilities interpolation. but we haven't // have method to fix this case, so just use linear interpolation here. - Quat ret = src * (1.0f - t) + dst *t; + Quat ret = src * (1.0 - t) + dst *t; // taking the complement requires renormalisation ret.normalize(); return ret; @@ -194,14 +194,14 @@ Quat Quat::slerpni(const Quat& q, const real_t& t) const { const Quat &from = *this; - float dot = from.dot(q); + real_t dot = from.dot(q); - if (Math::absf(dot) > 0.9999f) return from; + if (Math::absf(dot) > 0.9999) return from; - float theta = Math::acos(dot), - sinT = 1.0f / Math::sin(theta), + real_t theta = Math::acos(dot), + sinT = 1.0 / Math::sin(theta), newFactor = Math::sin(t * theta) * sinT, - invFactor = Math::sin((1.0f - t) * theta) * sinT; + invFactor = Math::sin((1.0 - t) * theta) * sinT; return Quat(invFactor * from.x + newFactor * q.x, invFactor * from.y + newFactor * q.y, @@ -259,7 +259,7 @@ Quat Quat::slerpni(const Quat& q, const real_t& t) const { Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const real_t& t) const { //the only way to do slerp :| - float t2 = (1.0-t)*t*2; + real_t t2 = (1.0-t)*t*2; Quat sp = this->slerp(q,t); Quat sq = prep.slerpni(postq,t); return sp.slerpni(sq,t2); |