Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-26 06:58:49 +0300
committerCampbell Barton <campbell@blender.org>2022-09-26 07:12:38 +0300
commit6275541df7e02c40e8c8650bba3104b5df8d34ef (patch)
tree042b852b57a56c9423eb58bc1b7afe1c7c2188fa /source/blender/io/collada
parent96d88e56143b1972d9b0cd6c53c6e0cda9b62269 (diff)
Cleanup: use ELEM/STR_ELEM/STREQ macros
Diffstat (limited to 'source/blender/io/collada')
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp18
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp3
-rw-r--r--source/blender/io/collada/BCSampleData.cpp2
-rw-r--r--source/blender/io/collada/MeshImporter.cpp14
4 files changed, 21 insertions, 16 deletions
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index 2b56cf188f1..2d872377bbf 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -525,9 +525,9 @@ void AnimationImporter::Assign_transform_animations(
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
/* to check if the no of curves are valid */
- bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||
- tm_type == COLLADAFW::Transformation::SCALE) &&
- binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
+ bool xyz =
+ (ELEM(tm_type, COLLADAFW::Transformation::TRANSLATE, COLLADAFW::Transformation::SCALE) &&
+ binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) {
fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, int(curves->size()));
@@ -1510,8 +1510,9 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
/* for each AnimationBinding get the fcurves which animate the transform */
for (uint j = 0; j < bindings.getCount(); j++) {
std::vector<FCurve *> &curves = curve_map[bindings[j].animation];
- bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE ||
- nodeTmType == COLLADAFW::Transformation::SCALE) &&
+ bool xyz = (ELEM(nodeTmType,
+ COLLADAFW::Transformation::TRANSLATE,
+ COLLADAFW::Transformation::SCALE) &&
bindings[j].animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if ((!xyz && curves.size() == 1) || (xyz && curves.size() == 3) || is_matrix) {
@@ -1883,8 +1884,11 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
const COLLADAFW::UniqueId &listid = tm->getAnimationList();
COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
- if (type != COLLADAFW::Transformation::ROTATE && type != COLLADAFW::Transformation::SCALE &&
- type != COLLADAFW::Transformation::TRANSLATE && type != COLLADAFW::Transformation::MATRIX) {
+ if (!ELEM(type,
+ COLLADAFW::Transformation::ROTATE,
+ COLLADAFW::Transformation::SCALE,
+ COLLADAFW::Transformation::TRANSLATE,
+ COLLADAFW::Transformation::MATRIX)) {
fprintf(stderr, "animation of transformation %d is not supported yet\n", type);
return false;
}
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index 710758bd77b..ac7fa81883a 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -329,8 +329,7 @@ bool BCAnimationCurve::is_transform_curve() const
bool BCAnimationCurve::is_rotation_curve() const
{
std::string channel_type = this->get_channel_type();
- return (channel_type == "rotation" || channel_type == "rotation_euler" ||
- channel_type == "rotation_quaternion");
+ return ELEM(channel_type, "rotation", "rotation_euler", "rotation_quaternion");
}
float BCAnimationCurve::get_value(const float frame)
diff --git a/source/blender/io/collada/BCSampleData.cpp b/source/blender/io/collada/BCSampleData.cpp
index 42b436ec6fb..422ecdc598f 100644
--- a/source/blender/io/collada/BCSampleData.cpp
+++ b/source/blender/io/collada/BCSampleData.cpp
@@ -51,7 +51,7 @@ bool BCSample::get_value(std::string channel_target, const int array_index, floa
else if (channel_type == "scale") {
*val = matrix->scale()[array_index];
}
- else if (channel_type == "rotation" || channel_type == "rotation_euler") {
+ else if (ELEM(channel_type, "rotation", "rotation_euler")) {
*val = matrix->rotation()[array_index];
}
else if (channel_type == "rotation_quaternion") {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index ce7eada84d6..6d7593afb8b 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -284,7 +284,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
const char *type_str = bc_primTypeToStr(type);
/* OpenCollada passes POLYGONS type for <polylist> */
- if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
+ if (ELEM(type, COLLADAFW::MeshPrimitive::POLYLIST, COLLADAFW::MeshPrimitive::POLYGONS)) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray &vca = mpvc->getGroupedVerticesVertexCountArray();
@@ -324,8 +324,9 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
/* TODO: Add Checker for line syntax here */
}
- else if (type != COLLADAFW::MeshPrimitive::TRIANGLES &&
- type != COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
+ else if (!ELEM(type,
+ COLLADAFW::MeshPrimitive::TRIANGLES,
+ COLLADAFW::MeshPrimitive::TRIANGLE_FANS)) {
fprintf(stderr, "ERROR: Primitive type %s is not supported.\n", type_str);
return false;
}
@@ -688,9 +689,10 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
}
}
- if (collada_meshtype == COLLADAFW::MeshPrimitive::POLYLIST ||
- collada_meshtype == COLLADAFW::MeshPrimitive::POLYGONS ||
- collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLES) {
+ if (ELEM(collada_meshtype,
+ COLLADAFW::MeshPrimitive::POLYLIST,
+ COLLADAFW::MeshPrimitive::POLYGONS,
+ COLLADAFW::MeshPrimitive::TRIANGLES)) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
uint start_index = 0;