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:
authorJacques Lucke <jacques@blender.org>2020-07-03 15:59:27 +0300
committerJacques Lucke <jacques@blender.org>2020-07-03 15:59:27 +0300
commit2633683b52054d15006aea1314f62f73a8505b42 (patch)
treea97b2916170b53f04fc9a898f4eedb527f14f84e /source/blender/io/collada
parent93da09d717ff4502975c506c574faf0c07f010b4 (diff)
Clang-tidy: enable readability-container-size-empty warning
Reviewers: sergey Differential Revision: https://developer.blender.org/D8197
Diffstat (limited to 'source/blender/io/collada')
-rw-r--r--source/blender/io/collada/AnimationExporter.cpp10
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp14
-rw-r--r--source/blender/io/collada/ArmatureImporter.cpp4
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp4
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp25
-rw-r--r--source/blender/io/collada/MeshImporter.cpp8
-rw-r--r--source/blender/io/collada/SkinInfo.cpp2
-rw-r--r--source/blender/io/collada/collada_internal.cpp2
8 files changed, 35 insertions, 34 deletions
diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp
index 9f0c1924bb9..c25b4ea543b 100644
--- a/source/blender/io/collada/AnimationExporter.cpp
+++ b/source/blender/io/collada/AnimationExporter.cpp
@@ -222,7 +222,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
std::vector<float> frames;
sampler.get_object_frames(frames, ob);
- if (frames.size() > 0) {
+ if (!frames.empty()) {
BCMatrixSampleMap samples;
bool is_animated = sampler.get_object_samples(samples, ob);
if (keep_flat_curves || is_animated) {
@@ -264,7 +264,7 @@ void AnimationExporter::export_bone_animations_recursive(Object *ob,
std::vector<float> frames;
sampler.get_bone_frames(frames, ob, bone);
- if (frames.size()) {
+ if (!frames.empty()) {
BCMatrixSampleMap samples;
bool is_animated = sampler.get_bone_samples(samples, ob, bone);
if (keep_flat_curves || is_animated) {
@@ -542,7 +542,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
param.push_back("ANGLE");
}
else {
- if (axis != "") {
+ if (!axis.empty()) {
param.push_back(axis);
}
else if (transform) {
@@ -836,11 +836,11 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
bool is_angle = curve.is_rotation_curve();
- if (tm_name.size()) {
+ if (!tm_name.empty()) {
if (is_angle) {
return tm_name + std::string(axis_name) + ".ANGLE";
}
- else if (axis_name != "") {
+ else if (!axis_name.empty()) {
return tm_name + "." + std::string(axis_name);
}
else {
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index 1de86425521..0e211f08d1f 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -52,7 +52,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
@@ -277,7 +277,7 @@ AnimationImporter::~AnimationImporter()
BKE_fcurve_free(*it);
}
- if (unused_curves.size()) {
+ if (!unused_curves.empty()) {
fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
}
}
@@ -738,7 +738,7 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
/* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
* Reason: old blender versions stored spot_size in radians (was a bug)
*/
- if (this->import_from_version == "" ||
+ if (this->import_from_version.empty() ||
BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) {
fcurve_deg_to_rad(fcu);
}
@@ -878,7 +878,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
newcu[i]->totvert = frames.size();
}
- if (frames.size() == 0) {
+ if (frames.empty()) {
return;
}
@@ -1333,7 +1333,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
newcu[i]->totvert = frames.size();
}
- if (frames.size() == 0) {
+ if (frames.empty()) {
return;
}
@@ -1641,7 +1641,7 @@ Object *AnimationImporter::translate_animation_OLD(
job = get_joint_object(root, node, par_job);
#endif
- if (frames.size() == 0) {
+ if (frames.empty()) {
return job;
}
@@ -1876,7 +1876,7 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4],
unit_m4(m);
- std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+ std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName();
if (!evaluate_animation(tm, m, fra, nodename.c_str())) {
switch (type) {
case COLLADAFW::Transformation::ROTATE:
diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp
index a69500432e8..3755b71f300 100644
--- a/source/blender/io/collada/ArmatureImporter.cpp
+++ b/source/blender/io/collada/ArmatureImporter.cpp
@@ -41,7 +41,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
ArmatureImporter::ArmatureImporter(UnitConverter *conv,
@@ -606,7 +606,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
}
}
- if (!shared && this->joint_parent_map.size() > 0) {
+ if (!shared && !this->joint_parent_map.empty()) {
/* All armatures have been created while creating the Node tree.
* The Collada exporter currently does not create a
* strict relationship between geometries and armatures
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index 4aea74cd82f..f44e3e8385d 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -78,7 +78,7 @@ void BCAnimationSampler::add_object(Object *ob)
BCAnimationCurveMap *BCAnimationSampler::get_curves(Object *ob)
{
BCAnimation &animation = *objects[ob];
- if (animation.curve_map.size() == 0) {
+ if (animation.curve_map.empty()) {
initialize_curves(animation.curve_map, ob);
}
return &animation.curve_map;
@@ -279,7 +279,7 @@ void BCAnimationSampler::find_depending_animated(std::set<Object *> &animated_ob
break;
}
}
- } while (found_more && candidates.size() > 0);
+ } while (found_more && !candidates.empty());
}
void BCAnimationSampler::get_animated_from_export_set(std::set<Object *> &animated_objects,
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index 2305072a6eb..0f84db79c28 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -251,7 +251,7 @@ void DocumentImporter::finish()
}
}
- if (libnode_ob.size()) {
+ if (!libnode_ob.empty()) {
fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
/* free all library_nodes */
@@ -667,7 +667,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
++it) {
ob = *it;
- std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+ std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName();
BKE_libblock_rename(bmain, &ob->id, (char *)nodename.c_str());
object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
node_map[node->getUniqueId()] = node;
@@ -699,11 +699,11 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
- if (objects_done->size() > 0) {
- ob = *objects_done->begin();
+ if (objects_done->empty()) {
+ ob = NULL;
}
else {
- ob = NULL;
+ ob = *objects_done->begin();
}
for (unsigned int i = 0; i < child_nodes.getCount(); i++) {
@@ -792,7 +792,8 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
}
Main *bmain = CTX_data_main(mContext);
- const std::string &str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
+ const std::string &str_mat_id = cmat->getName().empty() ? cmat->getOriginalId() :
+ cmat->getName();
Material *ma = BKE_material_add(bmain, (char *)str_mat_id.c_str());
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
@@ -880,11 +881,11 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
ExtraTags *et = getExtraTags(camera->getUniqueId());
cam_id = camera->getOriginalId();
cam_name = camera->getName();
- if (cam_name.size()) {
- cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str());
+ if (cam_name.empty()) {
+ cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str());
}
else {
- cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str());
+ cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str());
}
if (!cam) {
@@ -1042,11 +1043,11 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
la_id = light->getOriginalId();
la_name = light->getName();
- if (la_name.size()) {
- lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str());
+ if (la_name.empty()) {
+ lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str());
}
else {
- lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str());
+ lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str());
}
if (!lamp) {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 6683f07bf65..495af60488b 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -50,7 +50,7 @@
// get node name, or fall back to original id if not present (name is optional)
template<class T> static const std::string bc_get_dae_name(T *node)
{
- return node->getName().size() ? node->getName() : node->getOriginalId();
+ return node->getName().empty() ? node->getOriginalId() : node->getName();
}
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
@@ -1126,7 +1126,7 @@ Object *MeshImporter::create_mesh_object(
}
// name Object
- const std::string &id = node->getName().size() ? node->getName() : node->getOriginalId();
+ const std::string &id = node->getName().empty() ? node->getOriginalId() : node->getName();
const char *name = (id.length()) ? id.c_str() : NULL;
// add object
@@ -1185,8 +1185,8 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
return true;
}
- const std::string &str_geom_id = mesh->getName().size() ? mesh->getName() :
- mesh->getOriginalId();
+ const std::string &str_geom_id = mesh->getName().empty() ? mesh->getOriginalId() :
+ mesh->getName();
Mesh *me = BKE_mesh_add(m_bmain, (char *)str_geom_id.c_str());
id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object
diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp
index 317e0b37796..5692d11d0c3 100644
--- a/source/blender/io/collada/SkinInfo.cpp
+++ b/source/blender/io/collada/SkinInfo.cpp
@@ -49,7 +49,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
/* This is used to store data passed in write_controller_data.
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index 7e834045795..f123e8ea31f 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -221,7 +221,7 @@ std::string translate_id(const char *idString)
std::string translate_id(const std::string &id)
{
- if (id.size() == 0) {
+ if (id.empty()) {
return id;
}