diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-02 13:34:37 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-05 09:45:58 +0100 |
commit | 4f66e718cc72eeb8c600a0809c260d8f9ed43ea0 (patch) | |
tree | 093653e5a84497998ea09b60748b35742ad14e08 | |
parent | f9d3ab01d35cbad6d9bd0f203c6647fbfe251754 (diff) | |
download | minetest-4f66e718cc72eeb8c600a0809c260d8f9ed43ea0.tar.xz |
Fix code quality in new files
-rw-r--r-- | src/splinesequence.h | 26 | ||||
-rw-r--r-- | src/wieldanimation.cpp | 4 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/splinesequence.h b/src/splinesequence.h index e1163e155..2ba40ca8f 100644 --- a/src/splinesequence.h +++ b/src/splinesequence.h @@ -28,7 +28,8 @@ struct SplineIndex unsigned int length; }; -template <typename T> class SplineSequence +template <typename T> +class SplineSequence { private: std::vector<T> nodes; @@ -55,17 +56,20 @@ public: T _interpolate(T &bottom, T &top, float alpha) const; }; -template <typename T> SplineSequence<T>::SplineSequence() : m_totalDuration(0.0f) +template <typename T> +SplineSequence<T>::SplineSequence() : m_totalDuration(0.0f) { // noop } -template <typename T> SplineSequence<T>::~SplineSequence() +template <typename T> +SplineSequence<T>::~SplineSequence() { // noop } -template <typename T> inline std::vector<T> SplineSequence<T>::getNodes() +template <typename T> +inline std::vector<T> SplineSequence<T>::getNodes() { return this->nodes; } @@ -76,7 +80,8 @@ inline std::vector<SplineIndex> SplineSequence<T>::getIndices() return this->indices; } -template <typename T> SplineSequence<T> &SplineSequence<T>::addNode(T node) +template <typename T> +SplineSequence<T> &SplineSequence<T>::addNode(T node) { nodes.push_back(node); return *this; @@ -126,7 +131,8 @@ SplineSequence<T> &SplineSequence<T>::normalizeDurations(float target) return *this; } -template <typename T> void SplineSequence<T>::interpolate(T &result, float alpha) const +template <typename T> +void SplineSequence<T>::interpolate(T &result, float alpha) const { // find the index @@ -153,8 +159,8 @@ template <typename T> void SplineSequence<T>::interpolate(T &result, float alpha typename std::vector<T>::const_iterator end = start; end += index->length; // std::cout << "Start: " << start->X << " " << start->Y << " " << start->Z << - // std::endl; std::cout << "End: " << end->X << " " << end->Y << " " << end->Z << - // std::endl; std::cout << "Ends: " << *start << " " << *end << std::endl; + // std::endl; std::cout << "End: " << end->X << " " << end->Y << " " << end->Z + // << std::endl; std::cout << "Ends: " << *start << " " << *end << std::endl; // these are both inclusive, but vector's range constructor // excludes the end -> advance by one end++; @@ -163,8 +169,8 @@ template <typename T> void SplineSequence<T>::interpolate(T &result, float alpha for (unsigned int degree = index->length; degree > 0; degree--) { for (unsigned int i = 0; i < degree; i++) { // std::cout << "Interpolating alpha " << alpha << ", degree " << - // degree << ", step " << i << std::endl; std::cout << "Before " << - // workspace[i] << " onto " << workspace[i+1] << std::endl; + // degree << ", step " << i << std::endl; std::cout << "Before " + // << workspace[i] << " onto " << workspace[i+1] << std::endl; workspace[i] = _interpolate( workspace[i], workspace[i + 1], alpha); //_interpolate(workspace[i], alpha, index->length); diff --git a/src/wieldanimation.cpp b/src/wieldanimation.cpp index f1ff51a75..10e744623 100644 --- a/src/wieldanimation.cpp +++ b/src/wieldanimation.cpp @@ -14,7 +14,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - #include "wieldanimation.h" v3f WieldAnimation::getTranslationAt(float time) const @@ -140,7 +139,6 @@ void WieldAnimation::fillRepository() .addNode(quatFromAngles(0.0f, 0.0f, 0.0f)); poke.m_rotationspline.addIndex(1.0, 0, 2).addIndex(1.0, 2, 2); poke.setDuration(0.5f); - } void WieldAnimation::serialize(std::ostream &os, u16 protocol_version) @@ -197,7 +195,7 @@ WieldAnimation WieldAnimation::deSerialize(std::istream &is) u32 rotationNodes_size = readU32(is); for (u32 i = 0; i < rotationNodes_size; i++) { v3f node = readV3F32(is); - anim.m_rotationspline.addNode(quatFromAngles(node.X,node.Y, node.Z)); + anim.m_rotationspline.addNode(quatFromAngles(node.X, node.Y, node.Z)); } u32 rotationIndex_size = readU32(is); for (u32 i = 0; i < rotationIndex_size; i++) { |