From e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Apr 2019 06:17:24 +0200 Subject: ClangFormat: apply to source, most of intern Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat --- source/blender/physics/intern/eigen_utils.h | 265 ++++++++++++++-------------- 1 file changed, 132 insertions(+), 133 deletions(-) (limited to 'source/blender/physics/intern/eigen_utils.h') diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h index 16e1186441f..7d56fe1a608 100644 --- a/source/blender/physics/intern/eigen_utils.h +++ b/source/blender/physics/intern/eigen_utils.h @@ -39,69 +39,68 @@ #include "BLI_utildefines.h" - typedef float Scalar; /* slightly extended Eigen vector class * with conversion to/from plain C float array */ class Vector3 : public Eigen::Vector3f { -public: - typedef float *ctype; - - Vector3() - { - } - - Vector3(const ctype &v) - { - for (int k = 0; k < 3; ++k) - coeffRef(k) = v[k]; - } - - Vector3& operator =(const ctype &v) - { - for (int k = 0; k < 3; ++k) - coeffRef(k) = v[k]; - return *this; - } - - operator ctype() - { - return data(); - } + public: + typedef float *ctype; + + Vector3() + { + } + + Vector3(const ctype &v) + { + for (int k = 0; k < 3; ++k) + coeffRef(k) = v[k]; + } + + Vector3 &operator=(const ctype &v) + { + for (int k = 0; k < 3; ++k) + coeffRef(k) = v[k]; + return *this; + } + + operator ctype() + { + return data(); + } }; /* slightly extended Eigen matrix class * with conversion to/from plain C float array */ class Matrix3 : public Eigen::Matrix3f { -public: - typedef float (*ctype)[3]; - - Matrix3() - { - } - - Matrix3(const ctype &v) - { - for (int k = 0; k < 3; ++k) - for (int l = 0; l < 3; ++l) - coeffRef(l, k) = v[k][l]; - } - - Matrix3& operator =(const ctype &v) - { - for (int k = 0; k < 3; ++k) - for (int l = 0; l < 3; ++l) - coeffRef(l, k) = v[k][l]; - return *this; - } - - operator ctype() - { - return (ctype)data(); - } + public: + typedef float (*ctype)[3]; + + Matrix3() + { + } + + Matrix3(const ctype &v) + { + for (int k = 0; k < 3; ++k) + for (int l = 0; l < 3; ++l) + coeffRef(l, k) = v[k][l]; + } + + Matrix3 &operator=(const ctype &v) + { + for (int k = 0; k < 3; ++k) + for (int l = 0; l < 3; ++l) + coeffRef(l, k) = v[k][l]; + return *this; + } + + operator ctype() + { + return (ctype)data(); + } }; typedef Eigen::VectorXf lVector; @@ -110,29 +109,28 @@ typedef Eigen::VectorXf lVector; * providing 3-float block access for blenlib math functions */ class lVector3f : public Eigen::VectorXf { -public: - typedef Eigen::VectorXf base_t; - - lVector3f() - { - } - - template - lVector3f& operator =(T rhs) - { - base_t::operator=(rhs); - return *this; - } - - float *v3(int vertex) - { - return &coeffRef(3 * vertex); - } - - const float *v3(int vertex) const - { - return &coeffRef(3 * vertex); - } + public: + typedef Eigen::VectorXf base_t; + + lVector3f() + { + } + + template lVector3f &operator=(T rhs) + { + base_t::operator=(rhs); + return *this; + } + + float *v3(int vertex) + { + return &coeffRef(3 * vertex); + } + + const float *v3(int vertex) const + { + return &coeffRef(3 * vertex); + } }; typedef Eigen::Triplet Triplet; @@ -146,77 +144,78 @@ typedef Eigen::SparseMatrix lMatrix; * After all elements have been defined using the set() method, the actual matrix can be filled using construct(). */ struct lMatrix3fCtor { - lMatrix3fCtor() - { - } - - void reset() - { - m_trips.clear(); - } - - void reserve(int numverts) - { - /* reserve for diagonal entries */ - m_trips.reserve(numverts * 9); - } - - void add(int i, int j, const Matrix3 &m) - { - i *= 3; - j *= 3; - for (int k = 0; k < 3; ++k) - for (int l = 0; l < 3; ++l) - m_trips.push_back(Triplet(i + k, j + l, m.coeff(l, k))); - } - - void sub(int i, int j, const Matrix3 &m) - { - i *= 3; - j *= 3; - for (int k = 0; k < 3; ++k) - for (int l = 0; l < 3; ++l) - m_trips.push_back(Triplet(i + k, j + l, -m.coeff(l, k))); - } - - inline void construct(lMatrix &m) - { - m.setFromTriplets(m_trips.begin(), m_trips.end()); - m_trips.clear(); - } - -private: - TripletList m_trips; + lMatrix3fCtor() + { + } + + void reset() + { + m_trips.clear(); + } + + void reserve(int numverts) + { + /* reserve for diagonal entries */ + m_trips.reserve(numverts * 9); + } + + void add(int i, int j, const Matrix3 &m) + { + i *= 3; + j *= 3; + for (int k = 0; k < 3; ++k) + for (int l = 0; l < 3; ++l) + m_trips.push_back(Triplet(i + k, j + l, m.coeff(l, k))); + } + + void sub(int i, int j, const Matrix3 &m) + { + i *= 3; + j *= 3; + for (int k = 0; k < 3; ++k) + for (int l = 0; l < 3; ++l) + m_trips.push_back(Triplet(i + k, j + l, -m.coeff(l, k))); + } + + inline void construct(lMatrix &m) + { + m.setFromTriplets(m_trips.begin(), m_trips.end()); + m_trips.clear(); + } + + private: + TripletList m_trips; }; -typedef Eigen::ConjugateGradient > ConjugateGradient; +typedef Eigen::ConjugateGradient> + ConjugateGradient; using Eigen::ComputationInfo; BLI_INLINE void print_lvector(const lVector3f &v) { - for (int i = 0; i < v.rows(); ++i) { - if (i > 0 && i % 3 == 0) - printf("\n"); + for (int i = 0; i < v.rows(); ++i) { + if (i > 0 && i % 3 == 0) + printf("\n"); - printf("%f,\n", v[i]); - } + printf("%f,\n", v[i]); + } } BLI_INLINE void print_lmatrix(const lMatrix &m) { - for (int j = 0; j < m.rows(); ++j) { - if (j > 0 && j % 3 == 0) - printf("\n"); - - for (int i = 0; i < m.cols(); ++i) { - if (i > 0 && i % 3 == 0) - printf(" "); - - implicit_print_matrix_elem(m.coeff(j, i)); - } - printf("\n"); - } + for (int j = 0; j < m.rows(); ++j) { + if (j > 0 && j % 3 == 0) + printf("\n"); + + for (int i = 0; i < m.cols(); ++i) { + if (i > 0 && i % 3 == 0) + printf(" "); + + implicit_print_matrix_elem(m.coeff(j, i)); + } + printf("\n"); + } } #endif -- cgit v1.2.3