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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-26 18:03:11 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-26 18:59:24 +0300
commitfca515838e70f8bec7028b840bb921a1be9fabbb (patch)
tree1752923de19eca5f01ca4cfb5754fd4d1f13d934 /source/blender/collada
parentd44890ee75634052f325531766a661a5bcef628f (diff)
Cleanup: strcmp/strncmp -> STREQ/STREQLEN (in boolean usage).
Makes usage of those funcs much more clear, we even had mixed '!strcmp(foo, bar)' and 'strcmp(foo, bar) == 0' in several places...
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationExporter.cpp88
-rw-r--r--source/blender/collada/AnimationImporter.cpp2
-rw-r--r--source/blender/collada/ArmatureExporter.cpp2
-rw-r--r--source/blender/collada/ArmatureImporter.cpp2
-rw-r--r--source/blender/collada/ErrorHandler.cpp8
-rw-r--r--source/blender/collada/MeshImporter.cpp2
6 files changed, 53 insertions, 51 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index f2c057d32d8..9077db524db 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -76,9 +76,9 @@ void AnimationExporter::operator()(Object *ob)
else
transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
- (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
- (!strcmp(transformName, "rotation_quaternion")))
+ if ((STREQ(transformName, "location") || STREQ(transformName, "scale")) ||
+ (STREQ(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
+ (STREQ(transformName, "rotation_quaternion")))
{
dae_animation(ob, fcu, transformName, false);
}
@@ -98,8 +98,8 @@ void AnimationExporter::operator()(Object *ob)
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size")) ||
- (!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance")))
+ if ((STREQ(transformName, "color")) || (STREQ(transformName, "spot_size")) ||
+ (STREQ(transformName, "spot_blend")) || (STREQ(transformName, "distance")))
{
dae_animation(ob, fcu, transformName, true);
}
@@ -113,10 +113,10 @@ void AnimationExporter::operator()(Object *ob)
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "lens")) ||
- (!strcmp(transformName, "ortho_scale")) ||
- (!strcmp(transformName, "clip_end")) ||
- (!strcmp(transformName, "clip_start")))
+ if ((STREQ(transformName, "lens")) ||
+ (STREQ(transformName, "ortho_scale")) ||
+ (STREQ(transformName, "clip_end")) ||
+ (STREQ(transformName, "clip_start")))
{
dae_animation(ob, fcu, transformName, true);
}
@@ -134,9 +134,9 @@ void AnimationExporter::operator()(Object *ob)
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "specular_hardness")) || (!strcmp(transformName, "specular_color")) ||
- (!strcmp(transformName, "diffuse_color")) || (!strcmp(transformName, "alpha")) ||
- (!strcmp(transformName, "ior")))
+ if ((STREQ(transformName, "specular_hardness")) || (STREQ(transformName, "specular_color")) ||
+ (STREQ(transformName, "diffuse_color")) || (STREQ(transformName, "alpha")) ||
+ (STREQ(transformName, "ior")))
{
dae_animation(ob, fcu, transformName, true, ma);
}
@@ -225,7 +225,7 @@ float *AnimationExporter::get_eul_source_for_quat(Object *ob)
while (fcu) {
char *transformName = extract_transform_name(fcu->rna_path);
- if (!strcmp(transformName, "rotation_quaternion") ) {
+ if (STREQ(transformName, "rotation_quaternion") ) {
for (int i = 0; i < fcu->totvert; i++) {
*(quat + (i * 4) + fcu->array_index) = fcu->bezt[i].vec[1][1];
}
@@ -278,17 +278,17 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
bool has_tangents = false;
bool quatRotation = false;
- if (!strcmp(transformName, "rotation_quaternion") ) {
+ if (STREQ(transformName, "rotation_quaternion") ) {
fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n");
quatRotation = true;
return;
}
//axis names for colors
- else if (!strcmp(transformName, "color") ||
- !strcmp(transformName, "specular_color") ||
- !strcmp(transformName, "diffuse_color") ||
- !strcmp(transformName, "alpha"))
+ else if (STREQ(transformName, "color") ||
+ STREQ(transformName, "specular_color") ||
+ STREQ(transformName, "diffuse_color") ||
+ STREQ(transformName, "alpha"))
{
const char *axis_names[] = {"R", "G", "B"};
if (fcu->array_index < 3)
@@ -296,10 +296,10 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
}
//axis names for transforms
- else if (!strcmp(transformName, "location") ||
- !strcmp(transformName, "scale") ||
- !strcmp(transformName, "rotation_euler") ||
- !strcmp(transformName, "rotation_quaternion"))
+ else if (STREQ(transformName, "location") ||
+ STREQ(transformName, "scale") ||
+ STREQ(transformName, "rotation_euler") ||
+ STREQ(transformName, "rotation_quaternion"))
{
const char *axis_names[] = {"X", "Y", "Z"};
if (fcu->array_index < 3)
@@ -357,7 +357,7 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
MEM_freeN(eul);
MEM_freeN(eul_axis);
}
- else if (!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) {
+ else if (STREQ(transformName, "lens") && (ob->type == OB_CAMERA)) {
output_id = create_lens_source_from_fcurve((Camera *) ob->data, COLLADASW::InputSemantic::OUTPUT, fcu, anim_id);
}
else {
@@ -763,7 +763,7 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti
{
std::string source_id = anim_id + get_semantic_suffix(semantic);
- //bool is_angle = !strcmp(fcu->rna_path, "rotation");
+ //bool is_angle = STREQ(fcu->rna_path, "rotation");
bool is_angle = false;
if (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path,"spot_size")) is_angle = true;
@@ -1103,13 +1103,13 @@ std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type,
if (rna_path) {
char *name = extract_transform_name(rna_path);
- if (!strcmp(name, "color"))
+ if (STREQ(name, "color"))
tm_type = 1;
- else if (!strcmp(name, "spot_size"))
+ else if (STREQ(name, "spot_size"))
tm_type = 2;
- else if (!strcmp(name, "spot_blend"))
+ else if (STREQ(name, "spot_blend"))
tm_type = 3;
- else if (!strcmp(name, "distance"))
+ else if (STREQ(name, "distance"))
tm_type = 4;
else
tm_type = -1;
@@ -1151,13 +1151,13 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
if (rna_path) {
char *name = extract_transform_name(rna_path);
- if (!strcmp(name, "lens"))
+ if (STREQ(name, "lens"))
tm_type = 0;
- else if (!strcmp(name, "ortho_scale"))
+ else if (STREQ(name, "ortho_scale"))
tm_type = 1;
- else if (!strcmp(name, "clip_end"))
+ else if (STREQ(name, "clip_end"))
tm_type = 2;
- else if (!strcmp(name, "clip_start"))
+ else if (STREQ(name, "clip_start"))
tm_type = 3;
else
@@ -1203,23 +1203,23 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
if (rna_path) {
char *name = extract_transform_name(rna_path);
- if (!strcmp(name, "rotation_euler"))
+ if (STREQ(name, "rotation_euler"))
tm_type = 0;
- else if (!strcmp(name, "rotation_quaternion"))
+ else if (STREQ(name, "rotation_quaternion"))
tm_type = 1;
- else if (!strcmp(name, "scale"))
+ else if (STREQ(name, "scale"))
tm_type = 2;
- else if (!strcmp(name, "location"))
+ else if (STREQ(name, "location"))
tm_type = 3;
- else if (!strcmp(name, "specular_hardness"))
+ else if (STREQ(name, "specular_hardness"))
tm_type = 4;
- else if (!strcmp(name, "specular_color"))
+ else if (STREQ(name, "specular_color"))
tm_type = 5;
- else if (!strcmp(name, "diffuse_color"))
+ else if (STREQ(name, "diffuse_color"))
tm_type = 6;
- else if (!strcmp(name, "alpha"))
+ else if (STREQ(name, "alpha"))
tm_type = 7;
- else if (!strcmp(name, "ior"))
+ else if (STREQ(name, "ior"))
tm_type = 8;
else
@@ -1311,7 +1311,7 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
if (bone_name) {
- if (!strncmp(fcu->rna_path, prefix, strlen(prefix)))
+ if (STREQLEN(fcu->rna_path, prefix, strlen(prefix)))
fcu->flag &= ~FCURVE_DISABLED;
else
fcu->flag |= FCURVE_DISABLED;
@@ -1378,11 +1378,11 @@ void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const c
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
for (; fcu; fcu = fcu->next) {
- if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
+ if (prefix && !STREQLEN(prefix, fcu->rna_path, strlen(prefix)))
continue;
char *name = extract_transform_name(fcu->rna_path);
- if (!strcmp(name, tm_name)) {
+ if (STREQ(name, tm_name)) {
for (unsigned int i = 0; i < fcu->totvert; i++) {
float f = fcu->bezt[i].vec[1][0];
if (std::find(fra.begin(), fra.end(), f) == fra.end())
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 6e2d337a32e..7e937e42787 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -649,7 +649,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
/* All anim_types whose values are to be converted from Degree to Radians can be ORed here */
- if (strcmp("spot_size", anim_type)==0) {
+ if (STREQ("spot_size", anim_type)) {
/* 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)
*/
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 5ce62873377..36ab85b9b5b 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -181,7 +181,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
std::list<Object *>::iterator i = child_objects.begin();
while (i != child_objects.end()) {
- if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) {
+ if ((*i)->partype == PARBONE && STREQ((*i)->parsubstr, bone->name)) {
float backup_parinv[4][4];
copy_m4_m4(backup_parinv, (*i)->parentinv);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 7ffd300c6de..c2ee6170470 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -54,7 +54,7 @@ static EditBone *get_edit_bone(bArmature * armature, char *name) {
EditBone *eBone;
for (eBone = (EditBone *)armature->edbo->first; eBone; eBone = eBone->next) {
- if (!strcmp(name, eBone->name))
+ if (STREQ(name, eBone->name))
return eBone;
}
diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp
index 854e8abd76d..b271604f839 100644
--- a/source/blender/collada/ErrorHandler.cpp
+++ b/source/blender/collada/ErrorHandler.cpp
@@ -34,6 +34,8 @@
#include <string.h>
+#include "BLI_utildefines.h"
+
//--------------------------------------------------------------------
ErrorHandler::ErrorHandler() : mError(false)
{
@@ -55,13 +57,13 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
// Workaround to avoid wrong error
if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
- if (strcmp(parserError.getElement(), "effect") == 0) {
+ if (STREQ(parserError.getElement(), "effect")) {
isError = false;
}
}
if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
- if (!((strcmp(parserError.getElement(), "extra") == 0) &&
- (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
+ if (!(STREQ(parserError.getElement(), "extra") &&
+ STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract")))
{
isError = false;
}
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 571faf8c2e9..3c6c90068de 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -1061,7 +1061,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
// set texture face
if (color_texture &&
strlen((color_texture)->uvname) &&
- strcmp(layername, color_texture->uvname) != 0) {
+ !STREQ(layername, color_texture->uvname)) {
texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
color_texture->uvname);
strcpy(layername, color_texture->uvname);