diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/collada/BCSampleData.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
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
Diffstat (limited to 'source/blender/collada/BCSampleData.cpp')
-rw-r--r-- | source/blender/collada/BCSampleData.cpp | 157 |
1 files changed, 77 insertions, 80 deletions
diff --git a/source/blender/collada/BCSampleData.cpp b/source/blender/collada/BCSampleData.cpp index 812ac3c2a5a..6e17598469f 100644 --- a/source/blender/collada/BCSampleData.cpp +++ b/source/blender/collada/BCSampleData.cpp @@ -20,161 +20,158 @@ #include "BCSampleData.h" #include "collada_utils.h" -BCSample::BCSample(Object *ob): - obmat(ob) -{} +BCSample::BCSample(Object *ob) : obmat(ob) +{ +} BCSample::~BCSample() { - BCBoneMatrixMap::iterator it; - for (it = bonemats.begin(); it != bonemats.end(); ++it) { - delete it->second; - } + BCBoneMatrixMap::iterator it; + for (it = bonemats.begin(); it != bonemats.end(); ++it) { + delete it->second; + } } void BCSample::add_bone_matrix(Bone *bone, Matrix &mat) { - BCMatrix *matrix; - BCBoneMatrixMap::const_iterator it = bonemats.find(bone); - if (it != bonemats.end()) { - throw std::invalid_argument("bone " + std::string(bone->name) + " already defined before"); - } - matrix = new BCMatrix(mat); - bonemats[bone] = matrix; + BCMatrix *matrix; + BCBoneMatrixMap::const_iterator it = bonemats.find(bone); + if (it != bonemats.end()) { + throw std::invalid_argument("bone " + std::string(bone->name) + " already defined before"); + } + matrix = new BCMatrix(mat); + bonemats[bone] = matrix; } BCMatrix::BCMatrix(Matrix &mat) { - set_transform(mat); + set_transform(mat); } BCMatrix::BCMatrix(Object *ob) { - set_transform(ob); + set_transform(ob); } void BCMatrix::set_transform(Matrix &mat) { - copy_m4_m4(matrix, mat); - mat4_decompose(this->loc, this->q, this->size, mat); - quat_to_eul(this->rot, this->q); + copy_m4_m4(matrix, mat); + mat4_decompose(this->loc, this->q, this->size, mat); + quat_to_eul(this->rot, this->q); } void BCMatrix::set_transform(Object *ob) { - Matrix lmat; + Matrix lmat; - BKE_object_matrix_local_get(ob, lmat); - copy_m4_m4(matrix, lmat); + BKE_object_matrix_local_get(ob, lmat); + copy_m4_m4(matrix, lmat); - mat4_decompose(this->loc, this->q, this->size, lmat); - quat_to_compatible_eul(this->rot, ob->rot, this->q); + mat4_decompose(this->loc, this->q, this->size, lmat); + quat_to_compatible_eul(this->rot, ob->rot, this->q); } const BCMatrix *BCSample::get_matrix(Bone *bone) const { - BCBoneMatrixMap::const_iterator it = bonemats.find(bone); - if (it == bonemats.end()) { - return NULL; - } - return it->second; + BCBoneMatrixMap::const_iterator it = bonemats.find(bone); + if (it == bonemats.end()) { + return NULL; + } + return it->second; } const BCMatrix &BCSample::get_matrix() const { - return obmat; + return obmat; } - /* Get channel value */ const bool BCSample::get_value(std::string channel_target, const int array_index, float *val) const { - if (channel_target == "location") { - *val = obmat.location()[array_index]; - } - else if (channel_target == "scale") { - *val = obmat.scale()[array_index]; - } - else if (channel_target == "rotation" || - channel_target == "rotation_euler") - { - *val = obmat.rotation()[array_index]; - } - else if (channel_target == "rotation_quat") { - *val = obmat.quat()[array_index]; - } - else { - *val = 0; - return false; - } - - return true; + if (channel_target == "location") { + *val = obmat.location()[array_index]; + } + else if (channel_target == "scale") { + *val = obmat.scale()[array_index]; + } + else if (channel_target == "rotation" || channel_target == "rotation_euler") { + *val = obmat.rotation()[array_index]; + } + else if (channel_target == "rotation_quat") { + *val = obmat.quat()[array_index]; + } + else { + *val = 0; + return false; + } + + return true; } void BCMatrix::copy(Matrix &out, Matrix &in) { - /* destination comes first: */ - memcpy(out, in, sizeof(Matrix)); + /* destination comes first: */ + memcpy(out, in, sizeof(Matrix)); } void BCMatrix::transpose(Matrix &mat) { - transpose_m4(mat); + transpose_m4(mat); } void BCMatrix::sanitize(Matrix &mat, int precision) { - bc_sanitize_mat(mat, precision); + bc_sanitize_mat(mat, precision); } void BCMatrix::unit() { - unit_m4(matrix); + unit_m4(matrix); } /* We need double here because the OpenCollada API needs it. precision = -1 indicates to not limit the precision */ -void BCMatrix::get_matrix(double(&mat)[4][4], const bool transposed, const int precision) const +void BCMatrix::get_matrix(double (&mat)[4][4], const bool transposed, const int precision) const { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) { - float val = (transposed) ? matrix[j][i] : matrix[i][j]; - if (precision >= 0) - val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision); - mat[i][j] = val; - } + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) { + float val = (transposed) ? matrix[j][i] : matrix[i][j]; + if (precision >= 0) + val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision); + mat[i][j] = val; + } } const bool BCMatrix::in_range(const BCMatrix &other, float distance) const { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - if (fabs(other.matrix[i][j] - matrix[i][j]) > distance) { - return false; - } - } - } - return true; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + if (fabs(other.matrix[i][j] - matrix[i][j]) > distance) { + return false; + } + } + } + return true; } -float(&BCMatrix::location() const)[3] +float (&BCMatrix::location() const)[3] { - return loc; + return loc; } -float(&BCMatrix::rotation() const)[3] +float (&BCMatrix::rotation() const)[3] { - return rot; + return rot; } -float(&BCMatrix::scale() const)[3] +float (&BCMatrix::scale() const)[3] { - return size; + return size; } -float(&BCMatrix::quat() const)[4] +float (&BCMatrix::quat() const)[4] { - return q; + return q; } |