From d8dbd49a2f23b7637f05fc058f39bdf6ab706624 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 31 May 2019 22:51:19 +1000 Subject: Cleanup: style, use braces in source/ Automated using clang-tidy. --- source/blender/collada/AnimationExporter.cpp | 41 ++++-- source/blender/collada/AnimationImporter.cpp | 200 +++++++++++++++++--------- source/blender/collada/ArmatureExporter.cpp | 6 +- source/blender/collada/ArmatureImporter.cpp | 74 ++++++---- source/blender/collada/BCAnimationCurve.cpp | 48 ++++--- source/blender/collada/BCAnimationSampler.cpp | 21 ++- source/blender/collada/BCSampleData.cpp | 12 +- source/blender/collada/ControllerExporter.cpp | 24 ++-- source/blender/collada/DocumentExporter.cpp | 6 +- source/blender/collada/DocumentImporter.cpp | 81 +++++++---- source/blender/collada/EffectExporter.cpp | 6 +- source/blender/collada/ErrorHandler.cpp | 3 +- source/blender/collada/ExtraHandler.cpp | 3 +- source/blender/collada/ExtraTags.cpp | 12 +- source/blender/collada/GeometryExporter.cpp | 12 +- source/blender/collada/MaterialExporter.cpp | 3 +- source/blender/collada/MaterialExporter.h | 3 +- source/blender/collada/MeshImporter.cpp | 87 +++++++---- source/blender/collada/SceneExporter.cpp | 3 +- source/blender/collada/SkinInfo.cpp | 24 ++-- source/blender/collada/TransformWriter.cpp | 3 +- source/blender/collada/collada.cpp | 9 +- source/blender/collada/collada_internal.cpp | 6 +- source/blender/collada/collada_utils.cpp | 141 ++++++++++++------ source/blender/collada/collada_utils.h | 15 +- 25 files changed, 561 insertions(+), 282 deletions(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 2c6ae8a52f5..9ed79396dee 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -40,12 +40,14 @@ std::string AnimationExporter::get_axis_name(std::string channel, int id) std::map>::const_iterator it; it = BC_COLLADA_AXIS_FROM_TYPE.find(channel); - if (it == BC_COLLADA_AXIS_FROM_TYPE.end()) + if (it == BC_COLLADA_AXIS_FROM_TYPE.end()) { return ""; + } const std::vector &subchannel = it->second; - if (id >= subchannel.size()) + if (id >= subchannel.size()) { return ""; + } return subchannel[id]; } @@ -71,8 +73,9 @@ void AnimationExporter::openAnimationWithClip(std::string action_id, std::string void AnimationExporter::close_animation_container(bool has_container) { - if (has_container) + if (has_container) { closeAnimation(); + } } bool AnimationExporter::exportAnimations() @@ -152,8 +155,9 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler) /* Export skeletal animation (if any) */ bArmature *arm = (bArmature *)ob->data; - for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) + for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) { export_bone_animations_recursive(ob, root_bone, sampler); + } } close_animation_container(container_is_open); @@ -265,8 +269,9 @@ void AnimationExporter::export_bone_animations_recursive(Object *ob, } } - for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) + for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { export_bone_animations_recursive(ob, child, sampler); + } } /** @@ -382,15 +387,17 @@ bool AnimationExporter::is_bone_deform_group(Bone *bone) { bool is_def; /* Check if current bone is deform */ - if ((bone->flag & BONE_NO_DEFORM) == 0) + if ((bone->flag & BONE_NO_DEFORM) == 0) { return true; - /* Check child bones */ + /* Check child bones */ + } else { for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { /* loop through all the children until deform bone is found, and then return */ is_def = is_bone_deform_group(child); - if (is_def) + if (is_def) { return true; + } } } /* no deform bone found in children also */ @@ -424,10 +431,12 @@ void AnimationExporter::export_collada_curve_animation( bool has_tangents = false; std::string interpolation_id; - if (this->export_settings.get_keep_smooth_curves()) + if (this->export_settings.get_keep_smooth_curves()) { interpolation_id = collada_interpolation_source(curve, id, axis, &has_tangents); - else + } + else { interpolation_id = collada_linear_interpolation_source(frames.size(), id); + } std::string intangent_id; std::string outtangent_id; @@ -803,8 +812,9 @@ const std::string AnimationExporter::get_collada_name(std::string channel_target std::map::iterator name_it = BC_CHANNEL_BLENDER_TO_COLLADA.find( channel_target); - if (name_it == BC_CHANNEL_BLENDER_TO_COLLADA.end()) + if (name_it == BC_CHANNEL_BLENDER_TO_COLLADA.end()) { return ""; + } std::string tm_name = name_it->second; return tm_name; @@ -823,12 +833,15 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve, bool is_angle = curve.is_rotation_curve(); if (tm_name.size()) { - if (is_angle) + if (is_angle) { return tm_name + std::string(axis_name) + ".ANGLE"; - else if (axis_name != "") + } + else if (axis_name != "") { return tm_name + "." + std::string(axis_name); - else + } + else { return tm_name; + } } return tm_name; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 3ab859bdb00..992b5083fbc 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -185,10 +185,12 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, { bAction *act; - if (!ob->adt || !ob->adt->action) + if (!ob->adt || !ob->adt->action) { act = verify_adt_action(bmain, (ID *)&ob->id, 1); - else + } + else { act = ob->adt->action; + } std::vector::iterator it; int i; @@ -206,10 +208,12 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, FCurve *fcu = *it; fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); - if (array_index == -1) + if (array_index == -1) { fcu->array_index = i; - else + } + else { fcu->array_index = array_index; + } if (ob->type == OB_ARMATURE) { bActionGroup *grp = NULL; @@ -256,11 +260,14 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, AnimationImporter::~AnimationImporter() { /* free unused FCurves */ - for (std::vector::iterator it = unused_curves.begin(); it != unused_curves.end(); it++) + for (std::vector::iterator it = unused_curves.begin(); it != unused_curves.end(); + it++) { free_fcurve(*it); + } - if (unused_curves.size()) + if (unused_curves.size()) { fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size()); + } } bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim) @@ -444,10 +451,12 @@ void AnimationImporter::modify_fcurve(std::vector *curves, FCurve *fcu = *it; fcu->rna_path = BLI_strdup(rna_path); - if (array_index == -1) + if (array_index == -1) { fcu->array_index = i; - else + } + else { fcu->array_index = array_index; + } fcurve_is_used(fcu); } @@ -473,8 +482,9 @@ void AnimationImporter::find_frames(std::vector *frames, std::vectorbezt[k].vec[1][0]; /* if frame already not added add frame to frames */ - if (std::find(frames->begin(), frames->end(), fra) == frames->end()) + if (std::find(frames->begin(), frames->end(), fra) == frames->end()) { frames->push_back(fra); + } } } } @@ -508,10 +518,12 @@ void AnimationImporter::Assign_transform_animations( case COLLADAFW::Transformation::TRANSLATE: case COLLADAFW::Transformation::SCALE: { bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE; - if (is_joint) + if (is_joint) { BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale"); - else + } + else { BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path)); + } switch (binding->animationClass) { case COLLADAFW::AnimationList::POSITION_X: @@ -537,17 +549,20 @@ void AnimationImporter::Assign_transform_animations( } case COLLADAFW::Transformation::ROTATE: { - if (is_joint) + if (is_joint) { BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path); - else + } + else { BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path)); + } std::vector::iterator iter; for (iter = curves->begin(); iter != curves->end(); iter++) { FCurve *fcu = *iter; /* if transform is rotation the fcurves values must be turned in to radian. */ - if (is_rotation) + if (is_rotation) { fcurve_deg_to_rad(fcu); + } } COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform; COLLADABU::Math::Vector3 &axis = rot->getRotationAxis(); @@ -563,8 +578,9 @@ void AnimationImporter::Assign_transform_animations( else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { modify_fcurve(curves, rna_path, 2); } - else + else { unused_fcurve(curves); + } break; case COLLADAFW::AnimationList::AXISANGLE: /* TODO convert axis-angle to quat? or XYZ? */ @@ -767,8 +783,9 @@ void AnimationImporter::apply_matrix_curves(Object *ob, bool is_joint = node->getType() == COLLADAFW::Node::JOINT; const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; char joint_path[200]; - if (is_joint) + if (is_joint) { armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + } std::vector frames; find_frames(&frames, &animcurves); @@ -812,16 +829,19 @@ void AnimationImporter::apply_matrix_curves(Object *ob, axis = i - 7; } - if (is_joint) + if (is_joint) { BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); - else + } + else { BLI_strncpy(rna_path, tm_str, sizeof(rna_path)); + } newcu[i] = create_fcurve(axis, rna_path); newcu[i]->totvert = frames.size(); } - if (frames.size() == 0) + if (frames.size() == 0) { return; + } std::sort(frames.begin(), frames.end()); @@ -872,12 +892,15 @@ void AnimationImporter::apply_matrix_curves(Object *ob, /* add keys */ for (int i = 0; i < totcu; i++) { - if (i < 4) + if (i < 4) { add_bezt(newcu[i], fra, rot[i]); - else if (i < 7) + } + else if (i < 7) { add_bezt(newcu[i], fra, loc[i - 4]); - else + } + else { add_bezt(newcu[i], fra, scale[i - 7]); + } } } Main *bmain = CTX_data_main(mContext); @@ -887,10 +910,12 @@ void AnimationImporter::apply_matrix_curves(Object *ob, /* add curves */ for (int i = 0; i < totcu; i++) { - if (is_joint) + if (is_joint) { add_bone_fcurve(ob, node, newcu[i]); - else + } + else { BLI_addtail(curves, newcu[i]); + } #if 0 fcurve_is_used(newcu[i]); /* never added to unused */ #endif @@ -929,10 +954,12 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera) } else { const double xfov = camera->getXFov().getValue(); - if (xfov == 0) + if (xfov == 0) { aspect = 1; - else + } + else { aspect = xfov / yfov; + } } } return aspect; @@ -941,10 +968,12 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera) static ListBase &get_animation_curves(Main *bmain, Material *ma) { bAction *act; - if (!ma->adt || !ma->adt->action) + if (!ma->adt || !ma->adt->action) { act = verify_adt_action(bmain, (ID *)&ma->id, 1); - else + } + else { act = ma->adt->action; + } return act->curves; } @@ -961,10 +990,12 @@ void AnimationImporter::translate_Animations( COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid]; Object *ob; - if (is_joint) + if (is_joint) { ob = armature_importer->get_armature_for_joint(root); - else + } + else { ob = object_map.find(uid) == object_map.end() ? NULL : object_map.find(uid)->second; + } if (!ob) { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); @@ -979,14 +1010,16 @@ void AnimationImporter::translate_Animations( /* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */ char joint_path[200]; - if (is_joint) + if (is_joint) { armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + } - if (!ob->adt || !ob->adt->action) + if (!ob->adt || !ob->adt->action) { act = verify_adt_action(bmain, (ID *)&ob->id, 1); - - else + } + else { act = ob->adt->action; + } /* Get the list of animation curves of the object */ ListBase *AnimCurves = &(act->curves); @@ -1049,10 +1082,12 @@ void AnimationImporter::translate_Animations( if ((animType->light) != 0) { Light *lamp = (Light *)ob->data; - if (!lamp->adt || !lamp->adt->action) + if (!lamp->adt || !lamp->adt->action) { act = verify_adt_action(bmain, (ID *)&lamp->id, 1); - else + } + else { act = lamp->adt->action; + } ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceLightPointerArray &nodeLights = node->getInstanceLights(); @@ -1085,10 +1120,12 @@ void AnimationImporter::translate_Animations( if (animType->camera != 0) { Camera *cam = (Camera *)ob->data; - if (!cam->adt || !cam->adt->action) + if (!cam->adt || !cam->adt->action) { act = verify_adt_action(bmain, (ID *)&cam->id, 1); - else + } + else { act = cam->adt->action; + } ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras(); @@ -1139,10 +1176,12 @@ void AnimationImporter::translate_Animations( if (animType->material != 0) { Material *ma = give_current_material(ob, 1); - if (!ma->adt || !ma->adt->action) + if (!ma->adt || !ma->adt->action) { act = verify_adt_action(bmain, (ID *)&ma->id, 1); - else + } + else { act = ma->adt->action; + } const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries(); for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { @@ -1260,8 +1299,9 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, newcu[i]->totvert = frames.size(); } - if (frames.size() == 0) + if (frames.size() == 0) { return; + } std::sort(frames.begin(), frames.end()); @@ -1308,12 +1348,15 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, /* add keys */ for (int i = 0; i < totcu; i++) { - if (i < 4) + if (i < 4) { add_bezt(newcu[i], fra, rot[i]); - else if (i < 7) + } + else if (i < 7) { add_bezt(newcu[i], fra, loc[i - 4]); - else + } + else { add_bezt(newcu[i], fra, scale[i - 7]); + } } } Main *bmain = CTX_data_main(mContext); @@ -1364,8 +1407,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type( types->light = setAnimType(&(light->getFallOffAngle()), (types->light), LIGHT_FOA); types->light = setAnimType(&(light->getFallOffExponent()), (types->light), LIGHT_FOE); - if (types->light != 0) + if (types->light != 0) { break; + } } const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras(); @@ -1395,8 +1439,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type( types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR); types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR); - if (types->camera != 0) + if (types->camera != 0) { break; + } } const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries(); @@ -1431,10 +1476,12 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types, { int anim_type; const COLLADAFW::UniqueId &listid = prop->getAnimationList(); - if (animlist_map.find(listid) != animlist_map.end()) + if (animlist_map.find(listid) != animlist_map.end()) { anim_type = types | addition; - else + } + else { anim_type = types; + } return anim_type; } @@ -1480,15 +1527,17 @@ void AnimationImporter::find_frames_old(std::vector *frames, FCurve *fcu = *iter; /* if transform is rotation the fcurves values must be turned in to radian. */ - if (is_rotation) + if (is_rotation) { fcurve_deg_to_rad(fcu); + } for (unsigned int k = 0; k < fcu->totvert; k++) { /* get frame value from bezTriple */ float fra = fcu->bezt[k].vec[1][0]; /* if frame already not added add frame to frames */ - if (std::find(frames->begin(), frames->end(), fra) == frames->end()) + if (std::find(frames->begin(), frames->end(), fra) == frames->end()) { frames->push_back(fra); + } } } } @@ -1560,8 +1609,9 @@ Object *AnimationImporter::translate_animation_OLD( job = get_joint_object(root, node, par_job); #endif - if (frames.size() == 0) + if (frames.size() == 0) { return job; + } std::sort(frames.begin(), frames.end()); @@ -1585,8 +1635,9 @@ Object *AnimationImporter::translate_animation_OLD( char rna_path[200]; char joint_path[200]; - if (is_joint) + if (is_joint) { armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + } /* new curves */ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */ @@ -1611,10 +1662,12 @@ Object *AnimationImporter::translate_animation_OLD( } } - if (is_joint) + if (is_joint) { BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); - else + } + else { BLI_strncpy(rna_path, tm_str, sizeof(rna_path)); + } newcu[i] = create_fcurve(axis, rna_path); #ifdef ARMATURE_TEST @@ -1683,12 +1736,15 @@ Object *AnimationImporter::translate_animation_OLD( /* add keys */ for (i = 0; i < totcu; i++) { if (is_matrix) { - if (i < 4) + if (i < 4) { add_bezt(newcu[i], fra, rot[i]); - else if (i < 7) + } + else if (i < 7) { add_bezt(newcu[i], fra, loc[i - 4]); - else + } + else { add_bezt(newcu[i], fra, scale[i - 7]); + } } else { add_bezt(newcu[i], fra, val[i]); @@ -1739,10 +1795,12 @@ Object *AnimationImporter::translate_animation_OLD( /* add curves */ for (i = 0; i < totcu; i++) { - if (is_joint) + if (is_joint) { add_bone_fcurve(ob, node, newcu[i]); - else + } + else { BLI_addtail(curves, newcu[i]); + } #ifdef ARMATURE_TEST if (is_joint) @@ -1839,8 +1897,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, return false; } - if (animlist_map.find(listid) == animlist_map.end()) + if (animlist_map.find(listid) == animlist_map.end()) { return false; + } const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings(); @@ -1851,10 +1910,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, bool is_scale = (type == COLLADAFW::Transformation::SCALE); bool is_translate = (type == COLLADAFW::Transformation::TRANSLATE); - if (is_scale) + if (is_scale) { dae_scale_to_v3(tm, vec); - else if (is_translate) + } + else if (is_translate) { dae_translate_to_v3(tm, vec); + } for (unsigned int index = 0; index < bindings.getCount(); index++) { const COLLADAFW::AnimationList::AnimationBinding &binding = bindings[index]; @@ -1903,10 +1964,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, bool is_xyz = animclass == COLLADAFW::AnimationList::POSITION_XYZ; if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) { - if (is_xyz) + if (is_xyz) { fprintf(stderr, "%s: expected 3 curves, got %d\n", path, (int)curves.size()); - else + } + else { fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size()); + } return false; } @@ -1955,10 +2018,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, } } - if (is_scale) + if (is_scale) { size_to_mat4(mat, vec); - else + } + else { copy_v3_v3(mat[3], vec); + } return is_scale || is_translate; } @@ -2009,8 +2074,9 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], COLLADAFW::NodePointerArray &children = node->getChildNodes(); for (unsigned int i = 0; i < children.getCount(); i++) { - if (calc_joint_parent_mat_rest(mat, m, children[i], end)) + if (calc_joint_parent_mat_rest(mat, m, children[i], end)) { return true; + } } return false; diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index f974996191b..ed645ee5001 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -94,8 +94,9 @@ bool ArmatureExporter::add_instance_controller(Object *ob) ins.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, controller_id)); Mesh *me = (Mesh *)ob->data; - if (!me->dvert) + if (!me->dvert) { return false; + } // write root bone URLs Bone *bone; @@ -234,8 +235,9 @@ void ArmatureExporter::add_bone_node(Bone *bone, copy_m4_m4(ob->parentinv, backup_parinv); iter = child_objects.erase(iter); } - else + else { iter++; + } } for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 1c540b6cdaa..080a62536f5 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -105,8 +105,9 @@ int ArmatureImporter::create_bone(SkinInfo *skin, /* Checking if bone is already made. */ std::vector::iterator it; it = std::find(finished_joints.begin(), finished_joints.end(), node); - if (it != finished_joints.end()) + if (it != finished_joints.end()) { return chain_length; + } EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node)); totbone++; @@ -143,15 +144,17 @@ int ArmatureImporter::create_bone(SkinInfo *skin, get_node_mat(mat, node, NULL, NULL, parent_mat); } - if (parent) + if (parent) { bone->parent = parent; + } float loc[3], size[3], rot[3][3]; BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(arm); BoneExtended &be = add_bone_extended(bone, node, totchild, layer_labels, extended_bones); int layer = be.get_bone_layers(); - if (layer) + if (layer) { bone->layer = layer; + } arm->layer |= layer; // ensure that all populated bone layers are visible after import float *tail = be.get_tail(); @@ -205,8 +208,9 @@ int ArmatureImporter::create_bone(SkinInfo *skin, for (unsigned int i = 0; i < children.getCount(); i++) { int cl = create_bone(skin, children[i], bone, children.getCount(), mat, arm, layer_labels); - if (cl > chain_length) + if (cl > chain_length) { chain_length = cl; + } } bone->length = len_v3v3(bone->head, bone->tail); @@ -228,8 +232,9 @@ void ArmatureImporter::fix_leaf_bone_hierarchy(bArmature *armature, Bone *bone, bool fix_orientation) { - if (bone == NULL) + if (bone == NULL) { return; + } if (bc_is_leaf_bone(bone)) { BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature); @@ -276,8 +281,9 @@ void ArmatureImporter::fix_leaf_bone(bArmature *armature, void ArmatureImporter::fix_parent_connect(bArmature *armature, Bone *bone) { /* armature has no bones */ - if (bone == NULL) + if (bone == NULL) { return; + } if (bone->parent && bone->flag & BONE_CONNECTED) { copy_v3_v3(bone->parent->tail, bone->head); @@ -294,8 +300,9 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone BoneExtended *dominant_child = NULL; int maxlen = 0; - if (parentbone == NULL) + if (parentbone == NULL) { return; + } Bone *child = (Bone *)parentbone->childbase.first; if (child && (import_settings->find_chains || child->next == NULL)) { @@ -356,8 +363,9 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone } else { /* can't connect this Bone. Proceed with children ... */ - if (pbe) + if (pbe) { pbe->set_leaf_bone(true); + } for (Bone *ch = (Bone *)parentbone->childbase.first; ch; ch = ch->next) { ArmatureImporter::connect_bone_chains(armature, ch, UNLIMITED_CHAIN_MAX); } @@ -417,8 +425,9 @@ void ArmatureImporter::set_euler_rotmode() Object *ArmatureImporter::get_empty_for_leaves() { - if (empty) + if (empty) { return empty; + } empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, NULL); empty->empty_drawtype = OB_EMPTY_SPHERE; @@ -467,16 +476,19 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector /* if there is an armature created for root_joint next root_joint */ for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { - if (get_armature_for_joint(*ri) != NULL) + if (get_armature_for_joint(*ri) != NULL) { continue; + } Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()]; - if (!ob_arm) + if (!ob_arm) { continue; + } bArmature *armature = (bArmature *)ob_arm->data; - if (!armature) + if (!armature) { continue; + } char *bone_name = (char *)bc_get_joint_name(*ri); Bone *bone = BKE_armature_find_bone_name(armature, bone_name); @@ -568,8 +580,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) std::map::iterator it; for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) { SkinInfo *b = &it->second; - if (b == a || b->BKE_armature_from_object() == NULL) + if (b == a || b->BKE_armature_from_object() == NULL) { continue; + } skin_root_joints.clear(); @@ -583,8 +596,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) } } - if (shared != NULL) + if (shared != NULL) { break; + } } if (!shared && this->joint_parent_map.size() > 0) { @@ -620,9 +634,10 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) std::vector::iterator ri; for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { /* for shared armature check if bone tree is already created */ - if (shared && - std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end()) + if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != + skin_root_joints.end()) { continue; + } /* since root_joints may contain joints for multiple controllers, we need to filter */ if (skin.uses_joint_or_descendant(*ri)) { @@ -631,8 +646,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) &skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, armature, layer_labels); if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() && - !skin.get_parent()) + !skin.get_parent()) { skin.set_parent(joint_parent_map[(*ri)->getUniqueId()]); + } } } @@ -767,16 +783,19 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector &object ob_arms.push_back(ob_arm); } } - else + else { fprintf(stderr, "Cannot find object to link armature with.\n"); + } } - else + else { fprintf(stderr, "Cannot find geometry to link armature with.\n"); + } /* set armature parent if any */ Object *par = skin.get_parent(); - if (par) + if (par) { bc_set_parent(skin.BKE_armature_from_object(), par, C, false); + } /* free memory stolen from SkinControllerData */ skin.free(); @@ -938,8 +957,9 @@ void ArmatureImporter::make_shape_keys(bContext *C) COLLADAFW::UniqueId *ArmatureImporter::get_geometry_uid(const COLLADAFW::UniqueId &controller_uid) { - if (geom_uid_by_controller_uid.find(controller_uid) == geom_uid_by_controller_uid.end()) + if (geom_uid_by_controller_uid.find(controller_uid) == geom_uid_by_controller_uid.end()) { return NULL; + } return &geom_uid_by_controller_uid[controller_uid]; } @@ -950,14 +970,16 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) { SkinInfo &skin = it->second; - if (skin.uses_joint_or_descendant(node)) + if (skin.uses_joint_or_descendant(node)) { return skin.BKE_armature_from_object(); + } } std::map::iterator arm; for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) { - if (arm->first == node->getUniqueId()) + if (arm->first == node->getUniqueId()) { return arm->second; + } } return NULL; } @@ -1031,10 +1053,12 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, } be->set_bone_layers(layers, layer_labels); - if (has_tail) + if (has_tail) { be->set_tail(tail); - if (has_roll) + } + if (has_roll) { be->set_roll(roll); + } } if (!has_connect && this->import_settings->auto_connect) { diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp index 3f46d43840c..3ba2570ac42 100644 --- a/source/blender/collada/BCAnimationCurve.cpp +++ b/source/blender/collada/BCAnimationCurve.cpp @@ -145,8 +145,9 @@ const std::string BCAnimationCurve::get_animation_name(Object *ob) const } break; case BC_ANIMATION_TYPE_BONE: { - if (fcurve == NULL || fcurve->rna_path == NULL) + if (fcurve == NULL || fcurve->rna_path == NULL) { name = ""; + } else { const char *boneName = BLI_str_quoted_substrN(fcurve->rna_path, "pose.bones["); name = (boneName) ? std::string(boneName) : ""; @@ -193,27 +194,31 @@ const std::string BCAnimationCurve::get_rna_path() const const int BCAnimationCurve::sample_count() const { - if (fcurve == NULL) + if (fcurve == NULL) { return 0; + } return fcurve->totvert; } const int BCAnimationCurve::closest_index_above(const float sample_frame, const int start_at) const { - if (fcurve == NULL) + if (fcurve == NULL) { return -1; + } const int cframe = fcurve->bezt[start_at].vec[1][0]; // inacurate! - if (fabs(cframe - sample_frame) < 0.00001) + if (fabs(cframe - sample_frame) < 0.00001) { return start_at; + } return (fcurve->totvert > start_at + 1) ? start_at + 1 : start_at; } const int BCAnimationCurve::closest_index_below(const float sample_frame) const { - if (fcurve == NULL) + if (fcurve == NULL) { return -1; + } float lower_frame = sample_frame; float upper_frame = sample_frame; @@ -234,8 +239,9 @@ const int BCAnimationCurve::closest_index_below(const float sample_frame) const } } - if (lower_index == upper_index) + if (lower_index == upper_index) { return lower_index; + } const float fraction = float(sample_frame - lower_frame) / (upper_frame - lower_frame); return (fraction < 0.5) ? lower_index : upper_index; @@ -244,8 +250,9 @@ const int BCAnimationCurve::closest_index_below(const float sample_frame) const const int BCAnimationCurve::get_interpolation_type(float sample_frame) const { const int index = closest_index_below(sample_frame); - if (index < 0) + if (index < 0) { return BEZT_IPO_BEZ; + } return fcurve->bezt[index].ipo; } @@ -273,8 +280,9 @@ FCurve *BCAnimationCurve::get_edit_fcurve() void BCAnimationCurve::clean_handles() { - if (fcurve == NULL) + if (fcurve == NULL) { fcurve = get_edit_fcurve(); + } /* Keep old bezt data for copy)*/ BezTriple *old_bezts = fcurve->bezt; @@ -292,8 +300,9 @@ void BCAnimationCurve::clean_handles() } /* now free the memory used by the old BezTriples */ - if (old_bezts) + if (old_bezts) { MEM_freeN(old_bezts); + } } const bool BCAnimationCurve::is_transform_curve() const @@ -500,15 +509,18 @@ bool BCAnimationCurve::is_animated() bool BCAnimationCurve::is_keyframe(int frame) { - if (this->fcurve == NULL) + if (this->fcurve == NULL) { return false; + } for (int i = 0; i < fcurve->totvert; ++i) { const int cframe = nearbyint(fcurve->bezt[i].vec[1][0]); - if (cframe == frame) + if (cframe == frame) { return true; - if (cframe > frame) + } + if (cframe > frame) { break; + } } return false; } @@ -523,8 +535,9 @@ inline bool operator<(const BCAnimationCurve &lhs, const BCAnimationCurve &rhs) const int rha = rhs.get_channel_index(); return lha < rha; } - else + else { return lhtgt < rhtgt; + } } BCCurveKey::BCCurveKey() @@ -587,14 +600,17 @@ const BC_animation_type BCCurveKey::get_animation_type() const const bool BCCurveKey::operator<(const BCCurveKey &other) const { /* needed for using this class as key in maps and sets */ - if (this->key_type != other.key_type) + if (this->key_type != other.key_type) { return this->key_type < other.key_type; + } - if (this->curve_subindex != other.curve_subindex) + if (this->curve_subindex != other.curve_subindex) { return this->curve_subindex < other.curve_subindex; + } - if (this->rna_path != other.rna_path) + if (this->rna_path != other.rna_path) { return this->rna_path < other.rna_path; + } return this->curve_array_index < other.curve_array_index; } diff --git a/source/blender/collada/BCAnimationSampler.cpp b/source/blender/collada/BCAnimationSampler.cpp index 1e6ff79f132..f64a8e8bbb7 100644 --- a/source/blender/collada/BCAnimationSampler.cpp +++ b/source/blender/collada/BCAnimationSampler.cpp @@ -76,8 +76,9 @@ 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.size() == 0) { initialize_curves(animation.curve_map, ob); + } return &animation.curve_map; } @@ -88,8 +89,9 @@ static void get_sample_frames(BCFrameSet &sample_frames, { sample_frames.clear(); - if (sampling_rate < 1) + if (sampling_rate < 1) { return; // no sample frames in this case + } float sfra = scene->r.sfra; float efra = scene->r.efra; @@ -237,8 +239,9 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob, const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - if (!bc_validateConstraints(con)) + if (!bc_validateConstraints(con)) { continue; + } if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; @@ -247,8 +250,9 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob, for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) { obtar = ct->tar; if (obtar) { - if (animated_objects.find(obtar) != animated_objects.end()) + if (animated_objects.find(obtar) != animated_objects.end()) { return true; + } } } } @@ -297,8 +301,9 @@ void BCAnimationSampler::get_animated_from_export_set(std::set &animat } else { ListBase conlist = cob->constraints; - if (conlist.first) + if (conlist.first) { candidates.insert(cob); + } } } find_depending_animated(animated_objects, candidates); @@ -403,8 +408,9 @@ void BCAnimationSampler::generate_transforms(Object *ob, Bone *bone, BCAnimation std::string prep = "pose.bones[\"" + std::string(bone->name) + "\"]."; generate_transforms(ob, prep, BC_ANIMATION_TYPE_BONE, curves); - for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) + for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { generate_transforms(ob, child, curves); + } } /** @@ -453,8 +459,9 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object * generate_transforms(ob, EMPTY_STRING, object_type, curves); if (ob->type == OB_ARMATURE) { bArmature *arm = (bArmature *)ob->data; - for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) + for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) { generate_transforms(ob, root_bone, curves); + } } /* Add curves on Object->data actions */ diff --git a/source/blender/collada/BCSampleData.cpp b/source/blender/collada/BCSampleData.cpp index 88a7fd5993c..0734a2eb048 100644 --- a/source/blender/collada/BCSampleData.cpp +++ b/source/blender/collada/BCSampleData.cpp @@ -203,13 +203,15 @@ void BCMatrix::unit() * precision = -1 indicates to not limit the precision. */ void BCMatrix::get_matrix(DMatrix &mat, const bool transposed, const int precision) const { - for (int i = 0; i < 4; i++) + 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) + if (precision >= 0) { val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision); + } mat[i][j] = val; } + } } void BCMatrix::get_matrix(Matrix &mat, @@ -217,13 +219,15 @@ void BCMatrix::get_matrix(Matrix &mat, const int precision, const bool inverted) const { - for (int i = 0; i < 4; i++) + 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) + if (precision >= 0) { val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision); + } mat[i][j] = val; } + } if (inverted) { invert_m4(mat); diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index cb15a3a7a7c..1e1da13fc5f 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -79,8 +79,9 @@ bool ControllerExporter::add_instance_controller(Object *ob) ins.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, controller_id)); Mesh *me = (Mesh *)ob->data; - if (!me->dvert) + if (!me->dvert) { return false; + } /* write root bone URLs */ Bone *bone; @@ -227,10 +228,12 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) bDeformGroup *def; for (def = (bDeformGroup *)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) { - if (is_bone_defgroup(ob_arm, def)) + if (is_bone_defgroup(ob_arm, def)) { joint_index_by_def_index.push_back(j++); - else + } + else { joint_index_by_def_index.push_back(-1); + } } int oob_counter = 0; @@ -440,8 +443,9 @@ void ControllerExporter::add_bind_shape_mat(Object *ob) // UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat); UnitConverter::mat4_to_dae_double(bind_mat, f_obmat); - if (this->export_settings.get_limit_precision()) + if (this->export_settings.get_limit_precision()) { bc_sanitize_mat(bind_mat, LIMITTED_PRECISION); + } addBindShapeTransform(bind_mat); } @@ -455,8 +459,9 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, int totjoint = 0; bDeformGroup *def; for (def = (bDeformGroup *)defbase->first; def; def = def->next) { - if (is_bone_defgroup(ob_arm, def)) + if (is_bone_defgroup(ob_arm, def)) { totjoint++; + } } COLLADASW::NameSource source(mSW); @@ -472,8 +477,9 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, for (def = (bDeformGroup *)defbase->first; def; def = def->next) { Bone *bone = get_bone_from_defgroup(ob_arm, def); - if (bone) + if (bone) { source.appendValues(get_joint_sid(bone)); + } } source.finish(); @@ -489,8 +495,9 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, int totjoint = 0; for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) { - if (is_bone_defgroup(ob_arm, def)) + if (is_bone_defgroup(ob_arm, def)) { totjoint++; + } } COLLADASW::FloatSourceF source(mSW); @@ -561,8 +568,9 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, invert_m4_m4(mat, world); UnitConverter::mat4_to_dae(inv_bind_mat, mat); - if (this->export_settings.get_limit_precision()) + if (this->export_settings.get_limit_precision()) { bc_sanitize_mat(inv_bind_mat, LIMITTED_PRECISION); + } source.appendValues(inv_bind_mat); } } diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index f9232851fbb..0ebcd6d0919 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -130,8 +130,9 @@ extern bool bc_has_object_type(LinkNode *export_set, short obtype); char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n) { int layer_index = CustomData_get_layer_index(data, type); - if (layer_index < 0) + if (layer_index < 0) { return NULL; + } return data->layers[layer_index + n].name; } @@ -140,8 +141,9 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type) { /* get the layer index of the active layer of type */ int layer_index = CustomData_get_active_layer_index(data, type); - if (layer_index < 0) + if (layer_index < 0) { return NULL; + } return data->layers[layer_index].name; } diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 60813fb951c..1c241671c81 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -179,8 +179,9 @@ void DocumentImporter::start() void DocumentImporter::finish() { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return; + } Main *bmain = CTX_data_main(mContext); /* TODO: create a new scene except the selected - @@ -287,10 +288,12 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, * part in skinning. */ if (par) { // && par->getType() == COLLADAFW::Node::JOINT) { /* par is root if there's no corresp. key in root_map */ - if (root_map.find(par->getUniqueId()) == root_map.end()) + if (root_map.find(par->getUniqueId()) == root_map.end()) { root_map[node->getUniqueId()] = node; - else + } + else { root_map[node->getUniqueId()] = root_map[par->getUniqueId()]; + } } #if 0 @@ -446,8 +449,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, for (unsigned int i = 0; i < children.getCount(); i++) { COLLADAFW::Node *child_node = children[i]; const COLLADAFW::UniqueId &child_id = child_node->getUniqueId(); - if (object_map.find(child_id) == object_map.end()) + if (object_map.find(child_id) == object_map.end()) { continue; + } COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes(); Object *new_child = NULL; if (inodes.getCount()) { // \todo loop through instance nodes @@ -462,8 +466,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, } bc_set_parent(new_child, obn, mContext, true); - if (is_library_node) + if (is_library_node) { libnode_ob.push_back(new_child); + } } } @@ -665,8 +670,9 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, object_map.insert(std::pair(node->getUniqueId(), ob)); node_map[node->getUniqueId()] = node; - if (is_library_node) + if (is_library_node) { libnode_ob.push_back(ob); + } } // create_constraints(et,ob); @@ -676,8 +682,9 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, ++it) { ob = *it; - if (read_transform) + if (read_transform) { anim_importer.read_node_transform(node, ob); // overwrites location set earlier + } if (!is_joint) { if (par && ob) { @@ -715,8 +722,9 @@ finally: */ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } /* This method called on post process after writeGeometry, writeMaterial, etc. */ @@ -739,8 +747,9 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } Scene *sce = CTX_data_scene(mContext); @@ -759,8 +768,9 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } return mesh_importer.write_geometry(geom); } @@ -769,8 +779,9 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom) * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } Main *bmain = CTX_data_main(mContext); const std::string &str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); @@ -800,8 +811,9 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } const COLLADAFW::UniqueId &uid = effect->getUniqueId(); @@ -836,8 +848,9 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } Main *bmain = CTX_data_main(mContext); Camera *cam = NULL; @@ -846,10 +859,12 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) ExtraTags *et = getExtraTags(camera->getUniqueId()); cam_id = camera->getOriginalId(); cam_name = camera->getName(); - if (cam_name.size()) + if (cam_name.size()) { cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str()); - else + } + else { cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str()); + } if (!cam) { fprintf(stderr, "Cannot create camera.\n"); @@ -944,8 +959,9 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } const std::string &imagepath = image->getImageURI().toNativePath(); @@ -981,8 +997,9 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } Main *bmain = CTX_data_main(mContext); Light *lamp = NULL; @@ -1000,10 +1017,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) la_id = light->getOriginalId(); la_name = light->getName(); - if (la_name.size()) + if (la_name.size()) { lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str()); - else + } + else { lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str()); + } if (!lamp) { fprintf(stderr, "Cannot create light.\n"); @@ -1087,10 +1106,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) lamp->type = LA_SPOT; lamp->att1 = att1; lamp->att2 = att2; - if (IS_EQ(att1, 0.0f) && att2 > 0) + if (IS_EQ(att1, 0.0f) && att2 > 0) { lamp->falloff_type = LA_FALLOFF_INVSQUARE; - if (IS_EQ(att2, 0.0f) && att1 > 0) + } + if (IS_EQ(att2, 0.0f) && att1 > 0) { lamp->falloff_type = LA_FALLOFF_INVLINEAR; + } lamp->spotsize = DEG2RADF(light->getFallOffAngle().getValue()); lamp->spotblend = light->getFallOffExponent().getValue(); } break; @@ -1102,10 +1123,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) lamp->type = LA_LOCAL; lamp->att1 = att1; lamp->att2 = att2; - if (IS_EQ(att1, 0.0f) && att2 > 0) + if (IS_EQ(att1, 0.0f) && att2 > 0) { lamp->falloff_type = LA_FALLOFF_INVSQUARE; - if (IS_EQ(att2, 0.0f) && att1 > 0) + } + if (IS_EQ(att2, 0.0f) && att1 > 0) { lamp->falloff_type = LA_FALLOFF_INVLINEAR; + } } break; case COLLADAFW::Light::UNDEFINED: { fprintf(stderr, "Current light type is not supported.\n"); @@ -1122,8 +1145,9 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) /* this function is called only for animations that pass COLLADAFW::validate */ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } return anim_importer.write_animation(anim); } @@ -1131,8 +1155,9 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim) /* called on post-process stage after writeVisualScenes */ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } /* return true; */ return anim_importer.write_animation_list(animationList); @@ -1143,8 +1168,9 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat * called on post-process stage after writeVisualScenes */ bool DocumentImporter::writeAnimationClip(const COLLADAFW::AnimationClip *animationClip) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } return true; /* TODO: implement import of AnimationClips */ @@ -1162,8 +1188,9 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa /* this is called on postprocess, before writeVisualScenes */ bool DocumentImporter::writeController(const COLLADAFW::Controller *controller) { - if (mImportStage == Fetching_Controller_data) + if (mImportStage == Fetching_Controller_data) { return true; + } return armature_importer.write_controller(controller); } diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 61603226dfd..c58edd60611 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -46,8 +46,9 @@ static std::string getActiveUVLayerName(Object *ob) Mesh *me = (Mesh *)ob->data; int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); - if (num_layers) + if (num_layers) { return std::string(bc_CustomData_get_active_layer_name(&me->ldata, CD_MLOOPUV)); + } return ""; } @@ -67,8 +68,9 @@ bool EffectsExporter::hasEffects(Scene *sce) Material *ma = give_current_material(ob, a + 1); // no material, but check all of the slots - if (!ma) + if (!ma) { continue; + } return true; } diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp index 379f54247e0..af9d10c7841 100644 --- a/source/blender/collada/ErrorHandler.cpp +++ b/source/blender/collada/ErrorHandler.cpp @@ -79,9 +79,10 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) error_context = "File access"; } - else + else { isError = (parserError.getSeverity() != GeneratedSaxParser::ParserError::Severity::SEVERITY_ERROR_NONCRITICAL); + } } else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) { error_context = "Sax FWL"; diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index 8109952b4ae..4875ee72b0f 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -50,8 +50,9 @@ bool ExtraHandler::textData(const char *text, size_t textLength) { char buf[1024]; - if (currentElement.length() == 0 || currentExtraTags == 0) + if (currentElement.length() == 0 || currentExtraTags == 0) { return false; + } BLI_strncpy(buf, text, textLength + 1); currentExtraTags->addTag(currentElement, std::string(buf)); diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 4da0725f380..496ba3891f7 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -82,8 +82,9 @@ bool ExtraTags::setData(std::string tag, short *data) { bool ok = false; int tmp = asInt(tag, &ok); - if (ok) + if (ok) { *data = (short)tmp; + } return ok; } @@ -91,8 +92,9 @@ bool ExtraTags::setData(std::string tag, int *data) { bool ok = false; int tmp = asInt(tag, &ok); - if (ok) + if (ok) { *data = tmp; + } return ok; } @@ -100,8 +102,9 @@ bool ExtraTags::setData(std::string tag, float *data) { bool ok = false; float tmp = asFloat(tag, &ok); - if (ok) + if (ok) { *data = tmp; + } return ok; } @@ -109,8 +112,9 @@ bool ExtraTags::setData(std::string tag, char *data) { bool ok = false; int tmp = asInt(tag, &ok); - if (ok) + if (ok) { *data = (char)tmp; + } return ok; } diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 5125a9a0562..a172e2a53e3 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -311,8 +311,9 @@ static bool collect_vertex_counts_per_poly(Mesh *me, if (p->mat_nr == material_index) { int vertex_count = p->totloop; vcount_list.push_back(vertex_count); - if (vertex_count != 3) + if (vertex_count != 3) { is_triangulated = false; + } } } return is_triangulated; @@ -426,11 +427,13 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, for (int j = 0; j < loop_count; j++) { primitive_list->appendValues(l[j].v); primitive_list->appendValues(normal_indices[j]); - if (has_uvs) + if (has_uvs) { primitive_list->appendValues(texindex + j); + } - if (has_color) + if (has_color) { primitive_list->appendValues(texindex + j); + } } } @@ -484,8 +487,9 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me) { /* Find number of vertex color layers */ int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); - if (totlayer_mcol == 0) + if (totlayer_mcol == 0) { return; + } int map_index = 0; for (int a = 0; a < totlayer_mcol; a++) { diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 8bf7a220c4a..9b16d44d67f 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -52,8 +52,9 @@ bool MaterialsExporter::hasMaterials(Scene *sce) Material *ma = give_current_material(ob, a + 1); // no material, but check all of the slots - if (!ma) + if (!ma) { continue; + } return true; } diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index 027fba1f8ef..36047626ad2 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -68,8 +68,9 @@ template class ForEachMaterialFunctor { Material *ma = give_current_material(ob, a + 1); - if (!ma) + if (!ma) { continue; + } std::string translated_id = translate_id(id_name(ma)); if (find(mMat.begin(), mMat.end(), translated_id) == mMat.end()) { diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 00484295694..2ab6d12d96d 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -131,22 +131,25 @@ void WVDataWrapper::print() void UVDataWrapper::getUV(int uv_index, float *uv) { int stride = mVData->getStride(0); - if (stride == 0) + if (stride == 0) { stride = 2; + } switch (mVData->getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType *values = mVData->getFloatValues(); - if (values->empty()) + if (values->empty()) { return; + } uv[0] = (*values)[uv_index * stride]; uv[1] = (*values)[uv_index * stride + 1]; } break; case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: { COLLADAFW::ArrayPrimitiveType *values = mVData->getDoubleValues(); - if (values->empty()) + if (values->empty()) { return; + } uv[0] = (float)(*values)[uv_index * stride]; uv[1] = (float)(*values)[uv_index * stride + 1]; @@ -164,14 +167,16 @@ VCOLDataWrapper::VCOLDataWrapper(COLLADAFW::MeshVertexData &vdata) : mVData(&vda void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol) { int stride = mVData->getStride(0); - if (stride == 0) + if (stride == 0) { stride = 3; + } switch (mVData->getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType *values = mVData->getFloatValues(); - if (values->empty() || values->getCount() <= (v_index * stride + 2)) + if (values->empty() || values->getCount() <= (v_index * stride + 2)) { return; // xxx need to create an error instead + } mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]); mloopcol->g = unit_float_to_uchar_clamp((*values)[v_index * stride + 1]); @@ -180,8 +185,9 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol) case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: { COLLADAFW::ArrayPrimitiveType *values = mVData->getDoubleValues(); - if (values->empty() || values->getCount() <= (v_index * stride + 2)) + if (values->empty() || values->getCount() <= (v_index * stride + 2)) { return; // xxx need to create an error instead + } mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]); mloopcol->g = unit_float_to_uchar_clamp((*values)[v_index * stride + 1]); @@ -340,8 +346,9 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me) } int stride = pos.getStride(0); - if (stride == 0) + if (stride == 0) { stride = 3; + } me->totvert = pos.getFloatValues()->getCount() / stride; me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert); @@ -368,8 +375,9 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) int normals_count = mp->getNormalIndices().getCount(); if (normals_count > 0) { int index_count = mp->getPositionIndices().getCount(); - if (index_count == normals_count) + if (index_count == normals_count) { has_useable_normals = true; + } else { fprintf(stderr, "Warning: Number of normals %d is different from the number of vertices %d, " @@ -562,8 +570,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) MEdge *medge; int totedge; - if (len == 0) + if (len == 0) { return; + } totedge = mesh->totedge + len; @@ -571,8 +580,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge); CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge); - if (!CustomData_has_layer(&edata, CD_MEDGE)) + if (!CustomData_has_layer(&edata, CD_MEDGE)) { CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + } CustomData_free(&mesh->edata, mesh->totedge); mesh->edata = edata; @@ -580,8 +590,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) /* set default flags */ medge = &mesh->medge[mesh->totedge]; - for (int i = 0; i < len; i++, medge++) + for (int i = 0; i < len; i++, medge++) { medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT; + } mesh->totedge = totedge; } @@ -688,8 +699,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) // the same for vertces normals unsigned int vertex_normal_indices[3] = { first_normal, normal_indices[1], normal_indices[2]}; - if (!is_flat_face(vertex_normal_indices, nor, 3)) + if (!is_flat_face(vertex_normal_indices, nor, 3)) { mpoly->flag |= ME_SMOOTH; + } normal_indices++; } @@ -700,8 +712,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) } // Moving cursor to the next triangle fan. - if (mp_has_normals) + if (mp_has_normals) { normal_indices += 2; + } position_indices += 2; } @@ -752,8 +765,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) } if (mp_has_normals) { - if (!is_flat_face(normal_indices, nor, vcount)) + if (!is_flat_face(normal_indices, nor, vcount)) { mpoly->flag |= ME_SMOOTH; + } } if (mp->hasColorIndices()) { @@ -783,8 +797,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) start_index += vcount; prim.totpoly++; - if (mp_has_normals) + if (mp_has_normals) { normal_indices += vcount; + } position_indices += vcount; } @@ -801,8 +816,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) continue; // read the lines later after all the rest is done } - if (mp_has_faces) + if (mp_has_faces) { mat_prim_map[mp->getMaterialId()].push_back(prim); + } } geom_uid_mat_mapping_map[collada_mesh->getUniqueId()] = mat_prim_map; @@ -815,8 +831,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i, switch (arr.getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType *values = arr.getFloatValues(); - if (values->empty()) + if (values->empty()) { return; + } v[0] = (*values)[i++]; v[1] = (*values)[i++]; @@ -830,8 +847,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i, } break; case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: { COLLADAFW::ArrayPrimitiveType *values = arr.getDoubleValues(); - if (values->empty()) + if (values->empty()) { return; + } v[0] = (float)(*values)[i++]; v[1] = (float)(*values)[i++]; @@ -862,8 +880,9 @@ bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData &n float dp = dot_v3v3(a, b); - if (dp < 0.99999f || dp > 1.00001f) + if (dp < 0.99999f || dp > 1.00001f) { return false; + } } return true; @@ -871,22 +890,25 @@ bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData &n Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) { - if (uid_object_map.find(geom_uid) != uid_object_map.end()) + if (uid_object_map.find(geom_uid) != uid_object_map.end()) { return uid_object_map[geom_uid]; + } return NULL; } Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &mesh_uid) { - if (uid_mesh_map.find(mesh_uid) != uid_mesh_map.end()) + if (uid_mesh_map.find(mesh_uid) != uid_mesh_map.end()) { return uid_mesh_map[mesh_uid]; + } return NULL; } std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) { - if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) + if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) { return &this->mesh_geom_map[mesh_name]; + } return NULL; } @@ -897,18 +919,23 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) */ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2) { - if (ob1->totcol != ob2->totcol) + if (ob1->totcol != ob2->totcol) { return false; // not same number of materials - if (ob1->totcol == 0) + } + if (ob1->totcol == 0) { return false; // no material at all + } for (int index = 0; index < ob1->totcol; index++) { - if (ob1->matbits[index] != ob2->matbits[index]) + if (ob1->matbits[index] != ob2->matbits[index]) { return false; // shouldn't happen - if (ob1->matbits[index] == 0) + } + if (ob1->matbits[index] == 0) { return false; // shouldn't happen - if (ob1->mat[index] != ob2->mat[index]) + } + if (ob1->mat[index] != ob2->mat[index]) { return false; // different material assignment + } } return true; } @@ -955,8 +982,9 @@ std::vector MeshImporter::get_all_users_of(Mesh *reference_mesh) if (bc_is_marked(ob)) { bc_remove_mark(ob); Mesh *me = (Mesh *)ob->data; - if (me == reference_mesh) + if (me == reference_mesh) { mesh_users.push_back(ob); + } } } return mesh_users; @@ -1098,8 +1126,9 @@ Object *MeshImporter::create_mesh_object( return NULL; } } - if (!uid_mesh_map[*geom_uid]) + if (!uid_mesh_map[*geom_uid]) { return NULL; + } // name Object const std::string &id = node->getName().size() ? node->getName() : node->getOriginalId(); diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 7bf6a145886..01854bef328 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -223,8 +223,9 @@ void SceneExporter::writeNode(Object *ob) colladaNode.addExtraTechniqueChildParameter("blender", con_tag, "target_id", tar_id); } - if (cti->flush_constraint_targets) + if (cti->flush_constraint_targets) { cti->flush_constraint_targets(con, &targets, 1); + } } con = con->next; diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 3b5ea90d459..d8804a1e831 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -111,8 +111,9 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData * /* cannot transfer data for FloatOrDoubleArray, copy values manually */ const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights(); - for (unsigned int i = 0; i < weight.getValuesCount(); i++) + for (unsigned int i = 0; i < weight.getValuesCount(); i++) { weights.push_back(bc_get_float_value(weight, i)); + } unit_converter->dae_matrix_to_mat4_(bind_shape_matrix, skin->getBindShapeMatrix()); } @@ -162,8 +163,9 @@ Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_lay Object *SkinInfo::set_armature(Object *ob_arm) { - if (this->ob_arm) + if (this->ob_arm) { return this->ob_arm; + } this->ob_arm = ob_arm; return ob_arm; @@ -203,14 +205,16 @@ bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node) const COLLADAFW::UniqueId &uid = node->getUniqueId(); std::vector::iterator it; for (it = joint_data.begin(); it != joint_data.end(); it++) { - if ((*it).joint_uid == uid) + if ((*it).joint_uid == uid) { return true; + } } COLLADAFW::NodePointerArray &children = node->getChildNodes(); for (unsigned int i = 0; i < children.getCount(); i++) { - if (uses_joint_or_descendant(children[i])) + if (uses_joint_or_descendant(children[i])) { return true; + } } return false; @@ -255,8 +259,9 @@ void SkinInfo::link_armature(bContext *C, const char *name = "Group"; /* skip joints that have invalid UID */ - if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) + if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) { continue; + } /* name group by joint node name */ @@ -326,8 +331,9 @@ void SkinInfo::find_root_joints(const std::vector &root_joint /* find if joint node is in the tree belonging to the root_joint */ if (find_node_in_tree(joint, root)) { - if (std::find(result.begin(), result.end(), root) == result.end()) + if (std::find(result.begin(), result.end(), root) == result.end()) { result.push_back(root); + } } } } @@ -336,13 +342,15 @@ void SkinInfo::find_root_joints(const std::vector &root_joint bool SkinInfo::find_node_in_tree(COLLADAFW::Node *node, COLLADAFW::Node *tree_root) { - if (node == tree_root) + if (node == tree_root) { return true; + } COLLADAFW::NodePointerArray &children = tree_root->getChildNodes(); for (unsigned int i = 0; i < children.getCount(); i++) { - if (find_node_in_tree(node, children[i])) + if (find_node_in_tree(node, children[i])) { return true; + } } return false; diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 560ce8a359f..acf7d3c78b4 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -86,8 +86,9 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node, UnitConverter converter; double d_obmat[4][4]; converter.mat4_to_dae_double(d_obmat, f_obmat); - if (limit_precision) + if (limit_precision) { bc_sanitize_mat(d_obmat, LIMITTED_PRECISION); + } node.addMatrix("transform", d_obmat); break; } diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 294d105befd..ea5600aa850 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -73,10 +73,12 @@ int collada_export(bContext *C, ExportSettings *export_settings) ViewLayer *view_layer = blender_context.get_view_layer(); int includeFilter = OB_REL_NONE; - if (export_settings->include_armatures) + if (export_settings->include_armatures) { includeFilter |= OB_REL_MOD_ARMATURE; - if (export_settings->include_children) + } + if (export_settings->include_children) { includeFilter |= OB_REL_CHILDREN_RECURSIVE; + } /* Fetch the complete set of exported objects * ATTENTION: Invisible objects will not be exported @@ -98,8 +100,9 @@ int collada_export(bContext *C, ExportSettings *export_settings) } } else { - if (export_settings->sort_by_name) + if (export_settings->sort_by_name) { bc_bubble_sort_by_Object_name(export_settings->export_set); + } } DocumentExporter exporter(blender_context, export_settings); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index b95a51e5273..a97b5e0eca1 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -94,9 +94,11 @@ void UnitConverter::mat4_to_dae_double(double out[4][4], float in[4][4]) mat4_to_dae(mat, in); - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { out[i][j] = mat[i][j]; + } + } } float (&UnitConverter::get_rotation())[4][4] diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 9e8896c2b9f..9e480e7faf0 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -83,13 +83,16 @@ extern "C" { float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned int index) { - if (index >= array.getValuesCount()) + if (index >= array.getValuesCount()) { return 0.0f; + } - if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) + if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) { return array.getFloatValues()->getData()[index]; - else + } + else { return array.getDoubleValues()->getData()[index]; + } } /* copied from /editors/object/object_relations.c */ @@ -97,10 +100,12 @@ int bc_test_parent_loop(Object *par, Object *ob) { /* test if 'ob' is a parent somewhere in par's parents */ - if (par == NULL) + if (par == NULL) { return 0; - if (ob == par) + } + if (ob == par) { return 1; + } return bc_test_parent_loop(par->parent, ob); } @@ -110,18 +115,22 @@ bool bc_validateConstraints(bConstraint *con) const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); /* these we can skip completely (invalid constraints...) */ - if (cti == NULL) + if (cti == NULL) { return false; - if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) + } + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) { return false; + } /* these constraints can't be evaluated anyway */ - if (cti->evaluate_constraint == NULL) + if (cti->evaluate_constraint == NULL) { return false; + } /* influence == 0 should be ignored */ - if (con->enforce == 0.0f) + if (con->enforce == 0.0f) { return false; + } /* validation passed */ return true; @@ -171,10 +180,12 @@ std::string bc_get_action_id(std::string action_name, std::string axis_separator) { std::string result = action_name + "_" + channel_type; - if (ob_name.length() > 0) + if (ob_name.length() > 0) { result = ob_name + "_" + result; - if (axis_name.length() > 0) + } + if (axis_name.length() > 0) { result += axis_separator + axis_name; + } return translate_id(result); } @@ -314,14 +325,16 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) Bone *root = NULL; Bone *bone = aBone; while (bone) { - if (!(bone->flag & BONE_NO_DEFORM)) + if (!(bone->flag & BONE_NO_DEFORM)) { root = bone; + } bone = bone->parent; } return (aBone == root); } - else + else { return !(aBone->parent); + } } int bc_get_active_UVLayer(Object *ob) @@ -455,8 +468,9 @@ void bc_triangulate_mesh(Mesh *me) bool bc_is_leaf_bone(Bone *bone) { for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { - if (child->flag & BONE_CONNECTED) + if (child->flag & BONE_CONNECTED) { return false; + } } return true; } @@ -466,8 +480,9 @@ EditBone *bc_get_edit_bone(bArmature *armature, char *name) EditBone *eBone; for (eBone = (EditBone *)armature->edbo->first; eBone; eBone = eBone->next) { - if (STREQ(name, eBone->name)) + if (STREQ(name, eBone->name)) { return eBone; + } } return NULL; @@ -481,10 +496,12 @@ int bc_set_layer(int bitfield, int layer, bool enable) { int bit = 1u << layer; - if (enable) + if (enable) { bitfield |= bit; - else + } + else { bitfield &= ~bit; + } return bitfield; } @@ -513,8 +530,9 @@ BoneExtensionManager::~BoneExtensionManager() for (BoneExtensionMap::iterator ext_it = extended_bones->begin(); ext_it != extended_bones->end(); ++ext_it) { - if (ext_it->second != NULL) + if (ext_it->second != NULL) { delete ext_it->second; + } } extended_bones->clear(); delete extended_bones; @@ -609,8 +627,9 @@ float *BoneExtended::get_tail() inline bool isInteger(const std::string &s) { - if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) + if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) { return false; + } char *p; strtol(s.c_str(), &p, 10); @@ -706,9 +725,11 @@ void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4]) IDProperty *data = IDP_New(IDP_ARRAY, &val, key); float *array = (float *)IDP_Array(data); - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { array[4 * i + j] = mat[i][j]; + } + } IDP_AddToGroup(idgroup, data); } @@ -782,9 +803,11 @@ bool bc_get_property_matrix(Bone *bone, std::string key, float mat[4][4]) IDProperty *property = bc_get_IDProperty(bone, key); if (property && property->type == IDP_ARRAY && property->len == 16) { float *array = (float *)IDP_Array(property); - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { mat[i][j] = array[4 * i + j]; + } + } return true; } return false; @@ -805,8 +828,9 @@ void bc_get_property_vector(Bone *bone, std::string key, float val[3], const flo */ static bool has_custom_props(Bone *bone, bool enabled, std::string key) { - if (!enabled) + if (!enabled) { return false; + } return (bc_get_IDProperty(bone, key + "_x") || bc_get_IDProperty(bone, key + "_y") || bc_get_IDProperty(bone, key + "_z")); @@ -817,15 +841,18 @@ void bc_enable_fcurves(bAction *act, char *bone_name) FCurve *fcu; char prefix[200]; - if (bone_name) + if (bone_name) { BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name); + } for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) { if (bone_name) { - if (STREQLEN(fcu->rna_path, prefix, strlen(prefix))) + if (STREQLEN(fcu->rna_path, prefix, strlen(prefix))) { fcu->flag &= ~FCURVE_DISABLED; - else + } + else { fcu->flag |= FCURVE_DISABLED; + } } else { fcu->flag &= ~FCURVE_DISABLED; @@ -853,8 +880,9 @@ bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_open invert_m4_m4(ipar, parchan->pose_mat); mul_m4_m4m4(mat, ipar, pchan->pose_mat); } - else + else { copy_m4_m4(mat, pchan->pose_mat); + } /* OPEN_SIM_COMPATIBILITY * AFAIK animation to second life is via BVH, but no @@ -882,8 +910,9 @@ bool bc_is_animated(BCMatrixSampleMap &values) { static float MIN_DISTANCE = 0.00001; - if (values.size() < 2) + if (values.size() < 2) { return false; /* need at least 2 entries to be not flat */ + } BCMatrixSampleMap::iterator it; const BCMatrix *refmat = NULL; @@ -895,8 +924,9 @@ bool bc_is_animated(BCMatrixSampleMap &values) continue; } - if (!matrix->in_range(*refmat, MIN_DISTANCE)) + if (!matrix->in_range(*refmat, MIN_DISTANCE)) { return true; + } } return false; } @@ -906,21 +936,25 @@ bool bc_has_animations(Object *ob) /* Check for object, light and camera transform animations */ if ((bc_getSceneObjectAction(ob) && bc_getSceneObjectAction(ob)->curves.first) || (bc_getSceneLightAction(ob) && bc_getSceneLightAction(ob)->curves.first) || - (bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first)) + (bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first)) { return true; + } /* Check Material Effect parameter animations. */ for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a + 1); - if (!ma) + if (!ma) { continue; - if (ma->adt && ma->adt->action && ma->adt->action->curves.first) + } + if (ma->adt && ma->adt->action && ma->adt->action->curves.first) { return true; + } } Key *key = BKE_key_from_object(ob); - if ((key && key->adt && key->adt->action) && key->adt->action->curves.first) + if ((key && key->adt && key->adt->action) && key->adt->action->curves.first) { return true; + } return false; } @@ -932,8 +966,9 @@ bool bc_has_animations(Scene *sce, LinkNode *export_set) for (node = export_set; node; node = node->next) { Object *ob = (Object *)node->link; - if (bc_has_animations(ob)) + if (bc_has_animations(ob)) { return true; + } } } return false; @@ -1032,12 +1067,15 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, } if (export_settings.get_keep_bind_info()) { - if (bc_get_IDProperty(bone, "restpose_rot_x")) + if (bc_get_IDProperty(bone, "restpose_rot_x")) { rot[0] = DEG2RADF(bc_get_property(bone, "restpose_rot_x", 0)); - if (bc_get_IDProperty(bone, "restpose_rot_y")) + } + if (bc_get_IDProperty(bone, "restpose_rot_y")) { rot[1] = DEG2RADF(bc_get_property(bone, "restpose_rot_y", 0)); - if (bc_get_IDProperty(bone, "restpose_rot_z")) + } + if (bc_get_IDProperty(bone, "restpose_rot_z")) { rot[2] = DEG2RADF(bc_get_property(bone, "restpose_rot_z", 0)); + } } if (export_settings.get_keep_bind_info()) { @@ -1052,12 +1090,13 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, */ void bc_sanitize_mat(float mat[4][4], int precision) { - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { double val = (double)mat[i][j]; val = double_round(val, precision); mat[i][j] = (float)val; } + } } void bc_sanitize_v3(float v[3], int precision) @@ -1071,9 +1110,11 @@ void bc_sanitize_v3(float v[3], int precision) void bc_sanitize_mat(double mat[4][4], int precision) { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { mat[i][j] = double_round(mat[i][j], precision); + } + } } void bc_sanitize_v3(double v[3], int precision) @@ -1085,23 +1126,29 @@ void bc_sanitize_v3(double v[3], int precision) void bc_copy_m4_farray(float r[4][4], float *a) { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { r[i][j] = *a++; + } + } } void bc_copy_farray_m4(float *r, float a[4][4]) { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { *r++ = a[i][j]; + } + } } void bc_copy_darray_m4d(double *r, double a[4][4]) { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { *r++ = a[i][j]; + } + } } void bc_copy_v44_m4d(std::vector> &r, double (&a)[4][4]) diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index ca40de6fc1d..240e6200cf3 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -92,8 +92,9 @@ inline bAction *bc_getSceneObjectAction(Object *ob) /* Returns Light Action or NULL */ inline bAction *bc_getSceneLightAction(Object *ob) { - if (ob->type != OB_LAMP) + if (ob->type != OB_LAMP) { return NULL; + } Light *lamp = (Light *)ob->data; return (lamp->adt && lamp->adt->action) ? lamp->adt->action : NULL; @@ -102,8 +103,9 @@ inline bAction *bc_getSceneLightAction(Object *ob) /* Return Camera Action or NULL */ inline bAction *bc_getSceneCameraAction(Object *ob) { - if (ob->type != OB_CAMERA) + if (ob->type != OB_CAMERA) { return NULL; + } Camera *camera = (Camera *)ob->data; return (camera->adt && camera->adt->action) ? camera->adt->action : NULL; @@ -112,16 +114,18 @@ inline bAction *bc_getSceneCameraAction(Object *ob) /* returns material action or NULL */ inline bAction *bc_getSceneMaterialAction(Material *ma) { - if (ma == NULL) + if (ma == NULL) { return NULL; + } return (ma->adt && ma->adt->action) ? ma->adt->action : NULL; } inline void bc_setSceneObjectAction(bAction *action, Object *ob) { - if (ob->adt) + if (ob->adt) { ob->adt->action = action; + } } std::string bc_get_action_id(std::string action_name, @@ -167,8 +171,9 @@ inline std::string bc_string_after(const std::string &s, const char c) inline bool bc_startswith(std::string const &value, std::string const &starting) { - if (starting.size() > value.size()) + if (starting.size() > value.size()) { return false; + } return (value.substr(0, starting.size()) == starting); } -- cgit v1.2.3