diff options
author | Chris Robinson <[email protected]> | 2021-05-25 14:08:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-05-25 14:08:16 -0700 |
commit | 58a9549a5886fe91aba698abb4e6e4c0c94f129e (patch) | |
tree | 9b6dc836e64496f6dffbc8070874ef5ce4f21a09 /common | |
parent | 62e6ce6d7322bc83ba3150316d9c921f5fadbb99 (diff) |
Handle the listener position separate from the rotation matrix
It's too unstable with larger vectors. Even when the source and listener
positions are the same, floating point precision can cause noticeable rounding
errors.
Diffstat (limited to 'common')
-rw-r--r-- | common/vecmat.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/common/vecmat.h b/common/vecmat.h index 62cba193..78fd806e 100644 --- a/common/vecmat.h +++ b/common/vecmat.h @@ -35,6 +35,13 @@ public: return *this; } + VectorR operator-(const VectorR &rhs) const noexcept + { + const VectorR ret{mVals[0] - rhs.mVals[0], mVals[1] - rhs.mVals[1], + mVals[2] - rhs.mVals[2], mVals[3] - rhs.mVals[3]}; + return ret; + } + T normalize(T limit = std::numeric_limits<T>::epsilon()) { limit = std::max(limit, std::numeric_limits<T>::epsilon()); |