Cleanup: use ELEM/STR_ELEM/STREQ macros
This commit is contained in:
parent
96d88e5614
commit
6275541df7
|
@ -222,7 +222,7 @@ static bool testsort_listbase_array_str_cmp(ListBase *lb, char **arr, int arr_nu
|
|||
|
||||
link_step = (LinkData *)lb->first;
|
||||
for (i = 0; i < arr_num; i++) {
|
||||
if (strcmp(arr[i], (char *)link_step->data) != 0) {
|
||||
if (!STREQ(arr[i], (char *)link_step->data)) {
|
||||
return false;
|
||||
}
|
||||
link_step = link_step->next;
|
||||
|
@ -241,7 +241,7 @@ static bool testsort_listbase_sort_is_stable(ListBase *lb, bool forward)
|
|||
|
||||
link_step = (LinkData *)lb->first;
|
||||
while (link_step && link_step->next) {
|
||||
if (strcmp((const char *)link_step->data, (const char *)link_step->next->data) == 0) {
|
||||
if (STREQ((const char *)link_step->data, (const char *)link_step->next->data)) {
|
||||
if ((link_step < link_step->next) != forward) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -466,7 +466,7 @@ TEST(path_util, PathFrameStrip)
|
|||
#define PATH_EXTENSION_CHECK(input_path, input_ext, expect_ext) \
|
||||
{ \
|
||||
const bool ret = BLI_path_extension_check(input_path, input_ext); \
|
||||
if (strcmp(input_ext, expect_ext) == 0) { \
|
||||
if (STREQ(input_ext, expect_ext)) { \
|
||||
EXPECT_TRUE(ret); \
|
||||
} \
|
||||
else { \
|
||||
|
|
|
@ -1131,7 +1131,7 @@ static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *op)
|
|||
/* Ensure that there are no dots in the name. */
|
||||
BLI_str_replace_char(name, '.', '_');
|
||||
LISTBASE_FOREACH (ViewLayerLightgroup *, lightgroup, &view_layer->lightgroups) {
|
||||
if (strcmp(lightgroup->name, name) == 0) {
|
||||
if (STREQ(lightgroup->name, name)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -562,7 +562,7 @@ void USDMaterialReader::follow_connection(const pxr::UsdShadeInput &usd_input,
|
|||
/* For now, only convert UsdUVTexture and UsdPrimvarReader_float2 inputs. */
|
||||
if (shader_id == usdtokens::UsdUVTexture) {
|
||||
|
||||
if (strcmp(dest_socket_name, "Normal") == 0) {
|
||||
if (STREQ(dest_socket_name, "Normal")) {
|
||||
|
||||
/* The normal texture input requires creating a normal map node. */
|
||||
float locx = 0.0f;
|
||||
|
|
|
@ -455,7 +455,7 @@ static bNode *traverse_channel(bNodeSocket *input, const short target_type)
|
|||
static bNode *find_bsdf_node(Material *material)
|
||||
{
|
||||
LISTBASE_FOREACH (bNode *, node, &material->nodetree->nodes) {
|
||||
if (node->type == SH_NODE_BSDF_PRINCIPLED || node->type == SH_NODE_BSDF_DIFFUSE) {
|
||||
if (ELEM(node->type, SH_NODE_BSDF_PRINCIPLED, SH_NODE_BSDF_DIFFUSE)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ static void export_texture(bNode *node,
|
|||
const pxr::UsdStageRefPtr stage,
|
||||
const bool allow_overwrite)
|
||||
{
|
||||
if (node->type != SH_NODE_TEX_IMAGE && node->type != SH_NODE_TEX_ENVIRONMENT) {
|
||||
if (!ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class obj_importer_test : public BlendfileLoadingBaseTest {
|
|||
ASSERT_STREQ(object->id.name, exp.name.c_str());
|
||||
EXPECT_EQ(object->type, exp.type);
|
||||
EXPECT_V3_NEAR(object->loc, float3(0, 0, 0), 0.0001f);
|
||||
if (strcmp(object->id.name, "OBCube") != 0) {
|
||||
if (!STREQ(object->id.name, "OBCube")) {
|
||||
EXPECT_V3_NEAR(object->rot, float3(M_PI_2, 0, 0), 0.0001f);
|
||||
}
|
||||
EXPECT_V3_NEAR(object->scale, float3(1, 1, 1), 0.0001f);
|
||||
|
|
|
@ -851,7 +851,7 @@ class RenderLayerOperation : public NodeOperation {
|
|||
|
||||
/* Other output passes are not supported for now, so allocate them as invalid. */
|
||||
for (const bNodeSocket *output : this->node()->output_sockets()) {
|
||||
if (!STREQ(output->identifier, "Image") && !STREQ(output->identifier, "Alpha")) {
|
||||
if (!STR_ELEM(output->identifier, "Image", "Alpha")) {
|
||||
get_result(output->identifier).allocate_invalid();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue