From 16732def37c5a66f3ea28dbe247b09cc6bca6677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Nov 2020 17:49:09 +0100 Subject: Cleanup: Clang-Tidy modernize-use-nullptr Replace `NULL` with `nullptr` in C++ code. No functional changes. --- source/blender/io/collada/AnimationExporter.cpp | 6 +-- source/blender/io/collada/AnimationImporter.cpp | 44 +++++++-------- source/blender/io/collada/ArmatureExporter.cpp | 4 +- source/blender/io/collada/ArmatureImporter.cpp | 54 +++++++++---------- source/blender/io/collada/BCAnimationCurve.cpp | 22 ++++---- source/blender/io/collada/BCAnimationSampler.cpp | 14 ++--- source/blender/io/collada/BCSampleData.cpp | 2 +- source/blender/io/collada/ControllerExporter.cpp | 14 ++--- source/blender/io/collada/DocumentExporter.cpp | 8 +-- source/blender/io/collada/DocumentImporter.cpp | 68 ++++++++++++------------ source/blender/io/collada/ExtraHandler.cpp | 6 +-- source/blender/io/collada/GeometryExporter.cpp | 6 +-- source/blender/io/collada/ImageExporter.cpp | 6 +-- source/blender/io/collada/Materials.cpp | 10 ++-- source/blender/io/collada/MeshImporter.cpp | 32 +++++------ source/blender/io/collada/SceneExporter.cpp | 4 +- source/blender/io/collada/SkinInfo.cpp | 6 +-- source/blender/io/collada/TransformReader.cpp | 2 +- source/blender/io/collada/TransformWriter.cpp | 4 +- source/blender/io/collada/collada.cpp | 2 +- source/blender/io/collada/collada_utils.cpp | 44 +++++++-------- 21 files changed, 179 insertions(+), 179 deletions(-) (limited to 'source/blender/io/collada') diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp index 9ecb890b649..73952b06bc9 100644 --- a/source/blender/io/collada/AnimationExporter.cpp +++ b/source/blender/io/collada/AnimationExporter.cpp @@ -228,7 +228,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler & if (keep_flat_curves || is_animated) { bAction *action = bc_getSceneObjectAction(ob); std::string name = encode_xml(id_name(ob)); - std::string action_name = (action == NULL) ? name + "-action" : id_name(action); + std::string action_name = (action == nullptr) ? name + "-action" : id_name(action); std::string channel_type = "transform"; std::string axis; std::string id = bc_get_action_id(action_name, name, channel_type, axis); @@ -290,7 +290,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob, BCAnimationCurveMap &curves) { std::string channel_type = curve.get_channel_type(); - BCAnimationCurve *mcurve = NULL; + BCAnimationCurve *mcurve = nullptr; if (channel_type == "lens") { /* Create an xfov curve */ @@ -302,7 +302,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob, BCValueMap lens_values; curve.get_value_map(lens_values); - BCAnimationCurve *sensor_curve = NULL; + BCAnimationCurve *sensor_curve = nullptr; BCCurveKey sensor_key(BC_ANIMATION_TYPE_CAMERA, "sensor_width", 0); BCAnimationCurveMap::iterator cit = curves.find(sensor_key); if (cit != curves.end()) { diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index df81e638c68..2e7977d89bb 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -228,7 +228,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, } if (ob->type == OB_ARMATURE) { - bActionGroup *grp = NULL; + bActionGroup *grp = nullptr; const char *bone_name = bc_get_joint_name(animated->node); if (bone_name) { @@ -236,7 +236,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ - if (grp == NULL) { + if (grp == nullptr) { /* Add a new group, and make it active */ grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); @@ -662,7 +662,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi BLI_strncpy(rna_path, anim_type, sizeof(rna_path)); const COLLADAFW::AnimationList *animlist = animlist_map[listid]; - if (animlist == NULL) { + if (animlist == nullptr) { fprintf(stderr, "Collada: No animlist found for ID: %s of type %s\n", listid.toAscii().c_str(), @@ -818,7 +818,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, COLLADAFW::Transformation *tm) { bool is_joint = node->getType() == COLLADAFW::Node::JOINT; - const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; + const char *bone_name = is_joint ? bc_get_joint_name(node) : nullptr; char joint_path[200]; if (is_joint) { armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); @@ -847,7 +847,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, /* new curves to assign matrix transform animation */ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */ unsigned int totcu = 10; - const char *tm_str = NULL; + const char *tm_str = nullptr; char rna_path[200]; for (int i = 0; i < totcu; i++) { @@ -910,7 +910,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, float temp[4][4], par[4][4]; /* calc M */ - calc_joint_parent_mat_rest(par, NULL, root, node); + calc_joint_parent_mat_rest(par, nullptr, root, node); mul_m4_m4m4(temp, par, matfra); #if 0 @@ -1218,7 +1218,7 @@ void AnimationImporter::translate_Animations( for (unsigned int j = 0; j < matBinds.getCount(); j++) { const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial(); const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]); - if (ef != NULL) { /* can be NULL T28909. */ + if (ef != nullptr) { /* can be NULL T28909. */ Material *ma = uid_material_map[matuid]; if (!ma) { fprintf(stderr, @@ -1303,7 +1303,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, /* new curves to assign matrix transform animation */ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale. */ unsigned int totcu = 10; - const char *tm_str = NULL; + const char *tm_str = nullptr; char rna_path[200]; for (int i = 0; i < totcu; i++) { @@ -1358,7 +1358,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, Matrix temp, par; /* calc M */ - calc_joint_parent_mat_rest(par, NULL, root, node); + calc_joint_parent_mat_rest(par, nullptr, root, node); mul_m4_m4m4(temp, par, matfra); /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */ @@ -1442,7 +1442,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type( for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; - if (camera == NULL) { + if (camera == nullptr) { /* Can happen if the node refers to an unknown camera. */ continue; } @@ -1476,7 +1476,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type( for (unsigned int j = 0; j < matBinds.getCount(); j++) { const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial(); const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]); - if (ef != NULL) { /* can be NULL T28909. */ + if (ef != nullptr) { /* can be NULL T28909. */ const COLLADAFW::CommonEffectPointerArray &commonEffects = ef->getCommonEffects(); if (!commonEffects.empty()) { COLLADAFW::EffectCommon *efc = commonEffects[0]; @@ -1597,10 +1597,10 @@ Object *AnimationImporter::translate_animation_OLD( root_map[node->getUniqueId()]; Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()]; - const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; + const char *bone_name = is_joint ? bc_get_joint_name(node) : nullptr; if (!ob) { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); - return NULL; + return nullptr; } /* frames at which to sample */ @@ -1620,7 +1620,7 @@ Object *AnimationImporter::translate_animation_OLD( Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); - return NULL; + return nullptr; } unit_m4(rest); @@ -1628,7 +1628,7 @@ Object *AnimationImporter::translate_animation_OLD( invert_m4_m4(irest, rest); } - Object *job = NULL; + Object *job = nullptr; #ifdef ARMATURE_TEST FCurve *job_curves[10]; @@ -1641,7 +1641,7 @@ Object *AnimationImporter::translate_animation_OLD( std::sort(frames.begin(), frames.end()); - const char *tm_str = NULL; + const char *tm_str = nullptr; switch (tm_type) { case COLLADAFW::Transformation::ROTATE: tm_str = "rotation_quaternion"; @@ -1726,7 +1726,7 @@ Object *AnimationImporter::translate_animation_OLD( float temp[4][4], par[4][4]; /* calc M */ - calc_joint_parent_mat_rest(par, NULL, root, node); + calc_joint_parent_mat_rest(par, nullptr, root, node); mul_m4_m4m4(temp, par, matfra); /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */ @@ -2071,8 +2071,8 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4], if (!armature_importer->get_joint_bind_mat(mat, node)) { float par[4][4], m[4][4]; - calc_joint_parent_mat_rest(par, NULL, root, node); - get_node_mat(m, node, NULL, NULL); + calc_joint_parent_mat_rest(par, nullptr, root, node); + get_node_mat(m, node, nullptr, nullptr); mul_m4_m4m4(mat, par, m); } } @@ -2094,11 +2094,11 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], if (!armature_importer->get_joint_bind_mat(m, node)) { if (par) { float temp[4][4]; - get_node_mat(temp, node, NULL, NULL); + get_node_mat(temp, node, nullptr, nullptr); mul_m4_m4m4(m, par, temp); } else { - get_node_mat(m, node, NULL, NULL); + get_node_mat(m, node, nullptr, nullptr); } } @@ -2202,7 +2202,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv bActionGroup *grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ - if (grp == NULL) { + if (grp == nullptr) { /* Add a new group, and make it active */ grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp index 6aeffd22bbd..9bf1a4ae830 100644 --- a/source/blender/io/collada/ArmatureExporter.cpp +++ b/source/blender/io/collada/ArmatureExporter.cpp @@ -50,7 +50,7 @@ void ArmatureExporter::add_armature_bones(Object *ob_arm, /* write bone nodes */ bArmature *armature = (bArmature *)ob_arm->data; - bool is_edited = armature->edbo != NULL; + bool is_edited = armature->edbo != nullptr; if (!is_edited) { ED_armature_to_edit(armature); @@ -315,7 +315,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: BCMatrix::sanitize(mat, LIMITTED_PRECISION); } - TransformWriter::add_joint_transform(node, mat, NULL, this->export_settings, has_restmat); + TransformWriter::add_joint_transform(node, mat, nullptr, this->export_settings, has_restmat); } std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob) diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index af6558da3b4..aa3b6615444 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -56,7 +56,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv, view_layer(view_layer), unit_converter(conv), import_settings(import_settings), - empty(NULL), + empty(nullptr), mesh_importer(mesh) { } @@ -139,7 +139,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, /* create a bone even if there's no joint data for it (i.e. it has no influence) */ if (!bone_is_skinned) { - get_node_mat(mat, node, NULL, NULL, parent_mat); + get_node_mat(mat, node, nullptr, nullptr, parent_mat); } if (parent) { @@ -174,14 +174,14 @@ int ArmatureImporter::create_bone(SkinInfo *skin, else { float angle; mat4_to_loc_rot_size(loc, rot, size, mat); - mat3_to_vec_roll(rot, NULL, &angle); + mat3_to_vec_roll(rot, nullptr, &angle); bone->roll = angle; } copy_v3_v3(bone->head, mat[3]); if (bone_is_skinned && this->import_settings->keep_bind_info) { float rest_mat[4][4]; - get_node_mat(rest_mat, node, NULL, NULL, NULL); + get_node_mat(rest_mat, node, nullptr, nullptr, nullptr); bc_set_IDPropertyMatrix(bone, "bind_mat", joint_bind_mat); bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat); } @@ -230,7 +230,7 @@ void ArmatureImporter::fix_leaf_bone_hierarchy(bArmature *armature, Bone *bone, bool fix_orientation) { - if (bone == NULL) { + if (bone == nullptr) { return; } @@ -251,14 +251,14 @@ void ArmatureImporter::fix_leaf_bone(bArmature *armature, BoneExtended *be, bool fix_orientation) { - if (be == NULL || !be->has_tail()) { + if (be == nullptr || !be->has_tail()) { /* Collada only knows Joints, Here we guess a reasonable leaf bone length */ float leaf_length = (leaf_bone_length == FLT_MAX) ? 1.0 : leaf_bone_length; float vec[3]; - if (fix_orientation && ebone->parent != NULL) { + if (fix_orientation && ebone->parent != nullptr) { EditBone *parent = ebone->parent; sub_v3_v3v3(vec, ebone->head, parent->head); if (len_squared_v3(vec) < MINIMUM_BONE_LENGTH) { @@ -279,7 +279,7 @@ 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 == nullptr) { return; } @@ -297,18 +297,18 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, int max_chain_length) { BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature); - BoneExtended *dominant_child = NULL; + BoneExtended *dominant_child = nullptr; int maxlen = 0; - if (parentbone == NULL) { + if (parentbone == nullptr) { return; } Bone *child = (Bone *)parentbone->childbase.first; - if (child && (import_settings->find_chains || child->next == NULL)) { + if (child && (import_settings->find_chains || child->next == nullptr)) { for (; child; child = child->next) { BoneExtended *be = extended_bones[child->name]; - if (be != NULL) { + if (be != nullptr) { int chain_len = be->get_chain_length(); if (chain_len <= max_chain_length) { if (chain_len > maxlen) { @@ -316,7 +316,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, maxlen = chain_len; } else if (chain_len == maxlen) { - dominant_child = NULL; + dominant_child = nullptr; } } } @@ -324,7 +324,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, } BoneExtended *pbe = extended_bones[parentbone->name]; - if (dominant_child != NULL) { + if (dominant_child != nullptr) { /* Found a valid chain. Now connect current bone with that chain.*/ EditBone *pebone = bc_get_edit_bone(armature, parentbone->name); EditBone *cebone = bc_get_edit_bone(armature, dominant_child->get_name()); @@ -429,7 +429,7 @@ Object *ArmatureImporter::get_empty_for_leaves() return empty; } - empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, NULL); + empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, nullptr); empty->empty_drawtype = OB_EMPTY_SPHERE; return empty; @@ -480,7 +480,7 @@ 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++) { COLLADAFW::Node *node = *ri; - if (get_armature_for_joint(node) != NULL) { + if (get_armature_for_joint(node) != nullptr) { continue; } @@ -506,7 +506,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector ED_armature_to_edit(armature); armature->layer = 0; /* layer is set according to imported bone set in create_bone() */ - create_bone(NULL, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels); + create_bone(nullptr, node, nullptr, node->getChildNodes().getCount(), nullptr, armature, layer_labels); if (this->import_settings->find_chains) { connect_bone_chains(armature, (Bone *)armature->bonebase.first, UNLIMITED_CHAIN_MAX); } @@ -543,7 +543,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) * - exit edit mode * - set a sphere shape to leaf bones */ - Object *ob_arm = NULL; + Object *ob_arm = nullptr; /* * find if there's another skin sharing at least one bone with this skin @@ -579,14 +579,14 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) */ SkinInfo *a = &skin; - Object *shared = NULL; + Object *shared = nullptr; std::vector skin_root_joints; std::vector layer_labels; 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() == nullptr) { continue; } @@ -603,7 +603,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) } } - if (shared != NULL) { + if (shared != nullptr) { break; } } @@ -651,7 +651,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) if (skin.uses_joint_or_descendant(node)) { create_bone( - &skin, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels); + &skin, node, nullptr, node->getChildNodes().getCount(), nullptr, armature, layer_labels); if (joint_parent_map.find(node->getUniqueId()) != joint_parent_map.end() && !skin.get_parent()) { @@ -707,7 +707,7 @@ void ArmatureImporter::set_pose(Object *ob_arm, float obmat[4][4]; /* object-space */ - get_node_mat(obmat, root_node, NULL, NULL); + get_node_mat(obmat, root_node, nullptr, nullptr); bool is_decomposed = node_is_decomposed(root_node); // if (*edbone) @@ -804,7 +804,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector &object /* link armature with a mesh object */ const COLLADAFW::UniqueId &uid = skin.get_controller_uid(); const COLLADAFW::UniqueId *guid = get_geometry_uid(uid); - if (guid != NULL) { + if (guid != nullptr) { Object *ob = mesh_importer->get_object_by_geom_uid(*guid); if (ob) { skin.link_armature(C, ob, joint_by_uid, this); @@ -1001,7 +1001,7 @@ 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()) { - return NULL; + return nullptr; } return &geom_uid_by_controller_uid[controller_uid]; @@ -1024,7 +1024,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) return arm->second; } } - return NULL; + return nullptr; } void ArmatureImporter::set_tags_map(TagsMap &tags_map) @@ -1065,7 +1065,7 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, extended_bones[bone->name] = be; TagsMap::iterator etit; - ExtraTags *et = 0; + ExtraTags *et = nullptr; etit = uid_tags_map.find(node->getUniqueId().toAscii()); bool has_connect = false; diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp index 46439bb3556..33eaf3376cd 100644 --- a/source/blender/io/collada/BCAnimationCurve.cpp +++ b/source/blender/io/collada/BCAnimationCurve.cpp @@ -22,7 +22,7 @@ BCAnimationCurve::BCAnimationCurve() { this->curve_key.set_object_type(BC_ANIMATION_TYPE_OBJECT); - this->fcurve = NULL; + this->fcurve = nullptr; this->curve_is_local_copy = false; } @@ -53,7 +53,7 @@ BCAnimationCurve::BCAnimationCurve(BCCurveKey key, Object *ob, FCurve *fcu) BCAnimationCurve::BCAnimationCurve(const BCCurveKey &key, Object *ob) { this->curve_key = key; - this->fcurve = NULL; + this->fcurve = nullptr; this->curve_is_local_copy = false; init_pointer_rna(ob); } @@ -120,7 +120,7 @@ BCAnimationCurve::~BCAnimationCurve() if (curve_is_local_copy && fcurve) { // fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path); delete_fcurve(fcurve); - this->fcurve = NULL; + this->fcurve = nullptr; } } @@ -169,7 +169,7 @@ std::string BCAnimationCurve::get_animation_name(Object *ob) const } break; case BC_ANIMATION_TYPE_BONE: { - if (fcurve == NULL || fcurve->rna_path == NULL) { + if (fcurve == nullptr || fcurve->rna_path == nullptr) { name = ""; } else { @@ -218,7 +218,7 @@ std::string BCAnimationCurve::get_rna_path() const int BCAnimationCurve::sample_count() const { - if (fcurve == NULL) { + if (fcurve == nullptr) { return 0; } return fcurve->totvert; @@ -226,7 +226,7 @@ int BCAnimationCurve::sample_count() const int BCAnimationCurve::closest_index_above(const float sample_frame, const int start_at) const { - if (fcurve == NULL) { + if (fcurve == nullptr) { return -1; } @@ -240,7 +240,7 @@ int BCAnimationCurve::closest_index_above(const float sample_frame, const int st int BCAnimationCurve::closest_index_below(const float sample_frame) const { - if (fcurve == NULL) { + if (fcurve == nullptr) { return -1; } @@ -304,14 +304,14 @@ FCurve *BCAnimationCurve::get_edit_fcurve() void BCAnimationCurve::clean_handles() { - if (fcurve == NULL) { + if (fcurve == nullptr) { fcurve = get_edit_fcurve(); } /* Keep old bezt data for copy)*/ BezTriple *old_bezts = fcurve->bezt; int totvert = fcurve->totvert; - fcurve->bezt = NULL; + fcurve->bezt = nullptr; fcurve->totvert = 0; for (int i = 0; i < totvert; i++) { @@ -492,7 +492,7 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index) void BCAnimationCurve::get_value_map(BCValueMap &value_map) { value_map.clear(); - if (fcurve == NULL) { + if (fcurve == nullptr) { return; } @@ -533,7 +533,7 @@ bool BCAnimationCurve::is_animated() bool BCAnimationCurve::is_keyframe(int frame) { - if (this->fcurve == NULL) { + if (this->fcurve == nullptr) { return false; } diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index 6bada9950b9..abc770ceef5 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -116,7 +116,7 @@ static bool is_object_keyframe(Object *ob, int frame_index) static void add_keyframes_from(bAction *action, BCFrameSet &frameset) { if (action) { - FCurve *fcu = NULL; + FCurve *fcu = nullptr; for (fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt = fcu->bezt; for (int i = 0; i < fcu->totvert; bezt++, i++) { @@ -237,7 +237,7 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob, { bConstraint *con; for (con = (bConstraint *)conlist->first; con; con = con->next) { - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); @@ -468,7 +468,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object * } /* Add curves on Object->data actions */ - action = NULL; + action = nullptr; if (ob->type == OB_CAMERA) { action = bc_getSceneCameraAction(ob); object_type = BC_ANIMATION_TYPE_CAMERA; @@ -520,7 +520,7 @@ const BCSample *BCSampleFrame::get_sample(Object *ob) const { BCSampleMap::const_iterator it = sampleMap.find(ob); if (it == sampleMap.end()) { - return NULL; + return nullptr; } return it->second; } @@ -529,7 +529,7 @@ const BCMatrix *BCSampleFrame::get_sample_matrix(Object *ob) const { BCSampleMap::const_iterator it = sampleMap.find(ob); if (it == sampleMap.end()) { - return NULL; + return nullptr; } BCSample *sample = it->second; return &sample->get_matrix(); @@ -540,7 +540,7 @@ const BCMatrix *BCSampleFrame::get_sample_matrix(Object *ob, Bone *bone) const { BCSampleMap::const_iterator it = sampleMap.find(ob); if (it == sampleMap.end()) { - return NULL; + return nullptr; } BCSample *sample = it->second; @@ -577,7 +577,7 @@ BCSample &BCSampleFrameContainer::add(Object *ob, int frame_index) BCSampleFrame *BCSampleFrameContainer::get_frame(int frame_index) { BCSampleFrameMap::iterator it = sample_frames.find(frame_index); - BCSampleFrame *frame = (it == sample_frames.end()) ? NULL : &it->second; + BCSampleFrame *frame = (it == sample_frames.end()) ? nullptr : &it->second; return frame; } diff --git a/source/blender/io/collada/BCSampleData.cpp b/source/blender/io/collada/BCSampleData.cpp index f099e250565..339dc829742 100644 --- a/source/blender/io/collada/BCSampleData.cpp +++ b/source/blender/io/collada/BCSampleData.cpp @@ -86,7 +86,7 @@ const BCMatrix *BCSample::get_matrix(Bone *bone) const { BCBoneMatrixMap::const_iterator it = bonemats.find(bone); if (it == bonemats.end()) { - return NULL; + return nullptr; } return it->second; } diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 1d8d0f2b389..52d4bbf122e 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -47,7 +47,7 @@ bool ControllerExporter::is_skinned_mesh(Object *ob) { - return bc_get_assigned_armature(ob) != NULL; + return bc_get_assigned_armature(ob) != nullptr; } void ControllerExporter::write_bone_URLs(COLLADASW::InstanceController &ins, @@ -175,7 +175,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) bool use_instantiation = this->export_settings.get_use_object_instantiation(); Mesh *me; - if (((Mesh *)ob->data)->dvert == NULL) { + if (((Mesh *)ob->data)->dvert == nullptr) { return; } @@ -272,7 +272,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id); add_vertex_weights_element(weights_source_id, joints_source_id, vcounts, joints); - BKE_id_free(NULL, me); + BKE_id_free(nullptr, me); closeSkin(); closeController(); @@ -312,7 +312,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, morph_weights_id))); targets.add(); - BKE_id_free(NULL, me); + BKE_id_free(nullptr, me); /* support for animations * can also try the base element and param alternative */ @@ -530,7 +530,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, float loc[3]; float rot[3] = {0, 0, 0}; float scale[3]; - bc_decompose(bind_mat, loc, NULL, NULL, scale); + bc_decompose(bind_mat, loc, nullptr, nullptr, scale); /* Only translations, no rotation vs armature */ loc_eulO_size_to_mat4(bind_mat, loc, rot, scale, 6); @@ -571,12 +571,12 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, Bone *ControllerExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name); - return pchan ? pchan->bone : NULL; + return pchan ? pchan->bone : nullptr; } bool ControllerExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup *def) { - return get_bone_from_defgroup(ob_arm, def) != NULL; + return get_bone_from_defgroup(ob_arm, def) != nullptr; } std::string ControllerExporter::add_weights_source(Mesh *me, diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 65c71b0edef..241afbd4034 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -127,7 +127,7 @@ char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int { int layer_index = CustomData_get_layer_index(data, type); if (layer_index < 0) { - return NULL; + return nullptr; } return data->layers[layer_index + n].name; @@ -138,7 +138,7 @@ 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) { - return NULL; + return nullptr; } return data->layers[layer_index].name; @@ -155,7 +155,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char * { char tempfile[FILE_MAX]; - if (name == NULL) { + if (name == nullptr) { name = "untitled"; } @@ -184,7 +184,7 @@ int DocumentExporter::exportCurrentScene() clear_global_id_map(); - COLLADABU::NativeString native_filename = make_temp_filepath(NULL, ".dae"); + COLLADABU::NativeString native_filename = make_temp_filepath(nullptr, ".dae"); COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename); /* open */ diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index f7f9bf3f2f9..b85a96d89de 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -224,7 +224,7 @@ void DocumentImporter::finish() fprintf(stderr, "+-- Import Scene --------\n"); const COLLADAFW::NodePointerArray &roots = (*sit)->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { - std::vector *objects_done = write_node(roots[i], NULL, sce, NULL, false); + std::vector *objects_done = write_node(roots[i], nullptr, sce, nullptr, false); objects_to_scale->insert( objects_to_scale->end(), objects_done->begin(), objects_done->end()); delete objects_done; @@ -247,7 +247,7 @@ void DocumentImporter::finish() const COLLADAFW::NodePointerArray &roots = (*vsit)->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { - translate_anim_recursive(roots[i], NULL, NULL); + translate_anim_recursive(roots[i], nullptr, nullptr); } } @@ -270,12 +270,12 @@ void DocumentImporter::finish() /* update scene */ DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, nullptr); } void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, - COLLADAFW::Node *par = NULL, - Object *parob = NULL) + COLLADAFW::Node *par = nullptr, + Object *parob = nullptr) { /* The split in T29246, rootmap must point at actual root when * calculating bones in apply_curves_as_matrix. - actual root is the root node. @@ -306,7 +306,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, #endif unsigned int i; - if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) { + if (node->getType() == COLLADAFW::Node::JOINT && par == nullptr) { /* For Skeletons without root node we have to simulate the * root node here and recursively enter the same function * XXX: maybe this can be made more elegant. */ @@ -317,7 +317,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, node, root_map, object_map, FW_object_map, uid_material_map); COLLADAFW::NodePointerArray &children = node->getChildNodes(); for (i = 0; i < children.getCount(); i++) { - translate_anim_recursive(children[i], node, NULL); + translate_anim_recursive(children[i], node, nullptr); } } } @@ -375,11 +375,11 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera const COLLADAFW::UniqueId &cam_uid = camera->getInstanciatedObjectId(); if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) { // fprintf(stderr, "Couldn't find camera by UID.\n"); - return NULL; + return nullptr; } Main *bmain = CTX_data_main(mContext); - Object *ob = bc_add_object(bmain, sce, view_layer, OB_CAMERA, NULL); + Object *ob = bc_add_object(bmain, sce, view_layer, OB_CAMERA, nullptr); Camera *cam = uid_camera_map[cam_uid]; Camera *old_cam = (Camera *)ob->data; ob->data = cam; @@ -392,11 +392,11 @@ Object *DocumentImporter::create_light_object(COLLADAFW::InstanceLight *lamp, Sc const COLLADAFW::UniqueId &lamp_uid = lamp->getInstanciatedObjectId(); if (uid_light_map.find(lamp_uid) == uid_light_map.end()) { fprintf(stderr, "Couldn't find light by UID.\n"); - return NULL; + return nullptr; } Main *bmain = CTX_data_main(mContext); - Object *ob = bc_add_object(bmain, sce, view_layer, OB_LAMP, NULL); + Object *ob = bc_add_object(bmain, sce, view_layer, OB_LAMP, nullptr); Light *la = uid_light_map[lamp_uid]; Light *old_light = (Light *)ob->data; ob->data = la; @@ -456,7 +456,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, continue; } COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes(); - Object *new_child = NULL; + Object *new_child = nullptr; if (inodes.getCount()) { /* \todo loop through instance nodes */ const COLLADAFW::UniqueId &id = inodes[0]->getInstanciatedObjectId(); fprintf(stderr, "Doing %d child nodes\n", (int)node_map.count(id)); @@ -465,7 +465,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, } else { new_child = create_instance_node( - object_map.find(child_id)->second, child_node, NULL, sce, is_library_node); + object_map.find(child_id)->second, child_node, nullptr, sce, is_library_node); } bc_set_parent(new_child, obn, mContext, true); @@ -509,7 +509,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, bool is_library_node) { Main *bmain = CTX_data_main(mContext); - Object *ob = NULL; + Object *ob = nullptr; bool is_joint = node->getType() == COLLADAFW::Node::JOINT; bool read_transform = true; std::string id = node->getOriginalId(); @@ -525,7 +525,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, stderr, "| %s id='%s', name='%s'\n", is_joint ? "JOINT" : "NODE ", id.c_str(), name.c_str()); if (is_joint) { - if (parent_node == NULL && !is_library_node) { + if (parent_node == nullptr && !is_library_node) { /* A Joint on root level is a skeleton without root node. * Here we add the armature "on the fly": */ par = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, std::string("Armature").c_str()); @@ -534,11 +534,11 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, object_map.insert(std::pair(node->getUniqueId(), par)); node_map[node->getUniqueId()] = node; } - if (parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT) { + if (parent_node == nullptr || parent_node->getType() != COLLADAFW::Node::JOINT) { armature_importer.add_root_joint(node, par); } - if (parent_node == NULL) { + if (parent_node == nullptr) { /* for skeletons without root node all has been done above. * Skeletons with root node are handled further down. */ goto finally; @@ -561,12 +561,12 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, * sure... */ while (geom_done < geom.getCount()) { ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map); - if (ob == NULL) { + if (ob == nullptr) { report_unknown_reference(*node, "instance_mesh"); } else { objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -574,12 +574,12 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, } while (camera_done < camera.getCount()) { ob = create_camera_object(camera[camera_done], sce); - if (ob == NULL) { + if (ob == nullptr) { report_unknown_reference(*node, "instance_camera"); } else { objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -587,12 +587,12 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, } while (lamp_done < lamp.getCount()) { ob = create_light_object(lamp[lamp_done], sce); - if (ob == NULL) { + if (ob == nullptr) { report_unknown_reference(*node, "instance_light"); } else { objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -602,12 +602,12 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *) controller[controller_done]; ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map); - if (ob == NULL) { + if (ob == nullptr) { report_unknown_reference(*node, "instance_controller"); } else { objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -620,7 +620,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, fprintf(stderr, "Cannot find object for node referenced by .\n", inst_node[inst_done]->getName().c_str()); - ob = NULL; + ob = nullptr; } else { std::pair::iterator, @@ -633,7 +633,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *source_node = node_map[node_id]; ob = create_instance_node(source_ob, source_node, node, sce, is_library_node); objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -651,10 +651,10 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, ob = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, name.c_str()); } else { - ob = bc_add_object(bmain, sce, view_layer, OB_EMPTY, NULL); + ob = bc_add_object(bmain, sce, view_layer, OB_EMPTY, nullptr); } objects_done->push_back(ob); - if (parent_node == NULL) { + if (parent_node == nullptr) { root_objects->push_back(ob); } } @@ -701,7 +701,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, } if (objects_done->empty()) { - ob = NULL; + ob = nullptr; } else { ob = *objects_done->begin(); @@ -763,7 +763,7 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN fprintf(stderr, "+-- Read Library nodes ----------\n"); for (unsigned int i = 0; i < nodes.getCount(); i++) { std::vector *child_objects; - child_objects = write_node(nodes[i], NULL, sce, NULL, true); + child_objects = write_node(nodes[i], nullptr, sce, nullptr, true); delete child_objects; } return true; @@ -876,7 +876,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) } Main *bmain = CTX_data_main(mContext); - Camera *cam = NULL; + Camera *cam = nullptr; std::string cam_id, cam_name; ExtraTags *et = getExtraTags(camera->getUniqueId()); @@ -1029,7 +1029,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) } Main *bmain = CTX_data_main(mContext); - Light *lamp = NULL; + Light *lamp = nullptr; std::string la_id, la_name; ExtraTags *et = getExtraTags(light->getUniqueId()); @@ -1237,7 +1237,7 @@ bool DocumentImporter::writeKinematicsScene(const COLLADAFW::KinematicsScene *ki ExtraTags *DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid) { if (uid_tags_map.find(uid.toAscii()) == uid_tags_map.end()) { - return NULL; + return nullptr; } return uid_tags_map[uid.toAscii()]; } diff --git a/source/blender/io/collada/ExtraHandler.cpp b/source/blender/io/collada/ExtraHandler.cpp index acfa74f34af..9bed200676f 100644 --- a/source/blender/io/collada/ExtraHandler.cpp +++ b/source/blender/io/collada/ExtraHandler.cpp @@ -23,7 +23,7 @@ #include "ExtraHandler.h" -ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : currentExtraTags(0) +ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : currentExtraTags(nullptr) { this->dimp = dimp; this->aimp = aimp; @@ -50,7 +50,7 @@ bool ExtraHandler::textData(const char *text, size_t textLength) { char buf[1024]; - if (currentElement.length() == 0 || currentExtraTags == 0) { + if (currentElement.length() == 0 || currentExtraTags == nullptr) { return false; } @@ -64,7 +64,7 @@ bool ExtraHandler::parseElement(const char *profileName, const COLLADAFW::UniqueId &uniqueId) { /* implement for backwards compatibility, new version added object parameter */ - return parseElement(profileName, elementHash, uniqueId, NULL); + return parseElement(profileName, elementHash, uniqueId, nullptr); } bool ExtraHandler::parseElement(const char *profileName, diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 332390845c7..def7caabf32 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -140,7 +140,7 @@ void GeometryExporter::operator()(Object *ob) } } - BKE_id_free(NULL, me); + BKE_id_free(nullptr, me); } void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) @@ -350,7 +350,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, return; } - Material *ma = ob->totcol ? BKE_object_material_get(ob, material_index + 1) : NULL; + Material *ma = ob->totcol ? BKE_object_material_get(ob, material_index + 1) : nullptr; COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW); /* sets count attribute in */ @@ -636,7 +636,7 @@ void GeometryExporter::create_normals(std::vector &normals, MVert *verts = me->mvert; MLoop *mloops = me->mloop; - float(*lnors)[3] = NULL; + float(*lnors)[3] = nullptr; bool use_custom_normals = false; BKE_mesh_calc_normals_split(me); diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 51d753db03f..bb7b3bf0631 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -53,7 +53,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) std::string name(id_name(image)); std::string translated_name(translate_id(name)); - ImBuf *imbuf = BKE_image_acquire_ibuf(image, NULL, NULL); + ImBuf *imbuf = BKE_image_acquire_ibuf(image, nullptr, nullptr); if (!imbuf) { fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->filepath); return; @@ -106,7 +106,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) /* make absolute source path */ BLI_strncpy(source_path, image->filepath, sizeof(source_path)); BLI_path_abs(source_path, ID_BLEND_PATH_FROM_GLOBAL(&image->id)); - BLI_path_normalize(NULL, source_path); + BLI_path_normalize(nullptr, source_path); if (use_copies) { @@ -145,7 +145,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) img.add(mSW); fprintf(stdout, "Collada export: Added image: %s\n", export_file); - BKE_image_release_ibuf(image, imbuf, NULL); + BKE_image_release_ibuf(image, imbuf, nullptr); } void ImagesExporter::exportImages(Scene *sce) diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index a97b7dfcfd6..644ecc18e9b 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -96,10 +96,10 @@ bNodeTree *MaterialNode::prepare_material_nodetree() { if (material->nodetree) { ntree = material->nodetree; - return NULL; + return nullptr; } - material->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree"); + material->nodetree = ntreeAddTree(nullptr, "Shader Nodetree", "ShaderNodeTree"); material->use_nodes = true; ntree = material->nodetree; return ntree; @@ -225,7 +225,7 @@ void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot) } else if (cot.isTexture()) { bNode *texture_node = add_texture_node(cot, -300, locy, "Base Color"); - if (texture_node != NULL) { + if (texture_node != nullptr) { add_link(texture_node, 0, shader_node, 0); } } @@ -320,7 +320,7 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot) // texture else if (cot.isTexture()) { bNode *texture_node = add_texture_node(cot, -300, locy, "Emission"); - if (texture_node != NULL) { + if (texture_node != nullptr) { add_link(texture_node, 0, shader_node, 0); } } @@ -392,7 +392,7 @@ bNode *MaterialNode::add_texture_node(COLLADAFW::ColorOrTexture &cot, if (image_map.find(ima_uid) == image_map.end()) { fprintf(stderr, "Couldn't find an image by UID.\n"); - return NULL; + return nullptr; } Image *ima = image_map[ima_uid]; diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 72a265db287..196dafc19cf 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -346,7 +346,7 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me) } me->totvert = pos.getFloatValues()->getCount() / stride; - me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert); + me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, me->totvert); MVert *mvert; int i; @@ -469,8 +469,8 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) if (total_poly_count > 0) { me->totpoly = total_poly_count; me->totloop = total_loop_count; - me->mpoly = (MPoly *)CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, me->totpoly); - me->mloop = (MLoop *)CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, me->totloop); + me->mpoly = (MPoly *)CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, nullptr, me->totpoly); + me->mloop = (MLoop *)CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, nullptr, me->totloop); unsigned int totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount(); for (int i = 0; i < totuvset; i++) { @@ -487,7 +487,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) COLLADAFW::String &uvname = info->mName; /* Allocate space for UV_data */ CustomData_add_layer_named( - &me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, uvname.c_str()); + &me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, uvname.c_str()); } /* activate the first uv map */ me->mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0); @@ -500,7 +500,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) collada_mesh->getColors().getInputInfosArray()[i]; COLLADAFW::String colname = extract_vcolname(info->mName); CustomData_add_layer_named( - &me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, colname.c_str()); + &me->ldata, CD_MLOOPCOL, CD_DEFAULT, nullptr, me->totloop, colname.c_str()); } me->mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_MLOOPCOL, 0); } @@ -576,7 +576,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge); if (!CustomData_has_layer(&edata, CD_MEDGE)) { - CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge); } CustomData_free(&mesh->edata, mesh->totedge); @@ -744,7 +744,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index]; MLoopUV *mloopuv = (MLoopUV *)CustomData_get_layer_named( &me->ldata, CD_MLOOPUV, index_list.getName().c_str()); - if (mloopuv == NULL) { + if (mloopuv == nullptr) { fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n", me->id.name, @@ -774,7 +774,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) COLLADAFW::String colname = extract_vcolname(color_index_list.getName()); MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_named( &me->ldata, CD_MLOOPCOL, colname.c_str()); - if (mloopcol == NULL) { + if (mloopcol == nullptr) { fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n", me->id.name, @@ -888,7 +888,7 @@ Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid if (uid_object_map.find(geom_uid) != uid_object_map.end()) { return uid_object_map[geom_uid]; } - return NULL; + return nullptr; } Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) @@ -896,7 +896,7 @@ Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) if (uid_mesh_map.find(geom_uid) != uid_mesh_map.end()) { return uid_mesh_map[geom_uid]; } - return NULL; + return nullptr; } std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) @@ -904,7 +904,7 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) { return &this->mesh_geom_map[mesh_name]; } - return NULL; + return nullptr; } /** @@ -959,7 +959,7 @@ static void bc_remove_materials_from_object(Object *ob, Mesh *me) { for (int index = 0; index < ob->totcol; index++) { ob->matbits[index] = 0; - ob->mat[index] = NULL; + ob->mat[index] = nullptr; } } @@ -1109,7 +1109,7 @@ Object *MeshImporter::create_mesh_object( if (!geom_uid) { fprintf(stderr, "Couldn't find a mesh UID by controller's UID.\n"); - return NULL; + return nullptr; } } else { @@ -1118,16 +1118,16 @@ Object *MeshImporter::create_mesh_object( /* this could happen if a mesh was not created * (e.g. if it contains unsupported geometry) */ fprintf(stderr, "Couldn't find a mesh by UID.\n"); - return NULL; + return nullptr; } } if (!uid_mesh_map[*geom_uid]) { - return NULL; + return nullptr; } /* name Object */ const std::string &id = node->getName().empty() ? node->getOriginalId() : node->getName(); - const char *name = (id.length()) ? id.c_str() : NULL; + const char *name = (id.length()) ? id.c_str() : nullptr; /* add object */ Object *ob = bc_add_object(m_bmain, scene, view_layer, OB_MESH, name); diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index b8de5bbd91e..01c270518e9 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -107,7 +107,7 @@ void SceneExporter::writeNode(Object *ob) bool armature_exported = false; Object *ob_arm = bc_get_assigned_armature(ob); - if (ob_arm != NULL) { + if (ob_arm != nullptr) { armature_exported = bc_is_in_Export_set( this->export_settings.get_export_set(), ob_arm, view_layer); if (armature_exported && bc_is_marked(ob_arm)) { @@ -207,7 +207,7 @@ void SceneExporter::writeNode(Object *ob) * No real mapping in the .dae * Need support for multiple target objects also. */ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index 726127a1532..24ae1f0de11 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -75,7 +75,7 @@ SkinInfo::SkinInfo(const SkinInfo &skin) transfer_int_array_data_const(skin.joint_indices, joint_indices); } -SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL) +SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(nullptr), parent(nullptr) { } @@ -157,7 +157,7 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co) /* called from write_controller */ Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer) { - ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, NULL); + ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, nullptr); return ob_arm; } @@ -228,7 +228,7 @@ void SkinInfo::link_armature(bContext *C, Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature); + ModifierData *md = ED_object_modifier_add(nullptr, bmain, scene, ob, nullptr, eModifierType_Armature); ArmatureModifierData *amd = (ArmatureModifierData *)md; amd->object = ob_arm; diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp index 393393be65b..81b0ffc340a 100644 --- a/source/blender/io/collada/TransformReader.cpp +++ b/source/blender/io/collada/TransformReader.cpp @@ -33,7 +33,7 @@ void TransformReader::get_node_mat(float mat[4][4], std::map *animation_map, Object *ob) { - get_node_mat(mat, node, animation_map, ob, NULL); + get_node_mat(mat, node, animation_map, ob, nullptr); } void TransformReader::get_node_mat(float mat[4][4], diff --git a/source/blender/io/collada/TransformWriter.cpp b/source/blender/io/collada/TransformWriter.cpp index 7c9d26e4fde..c22631e7bd3 100644 --- a/source/blender/io/collada/TransformWriter.cpp +++ b/source/blender/io/collada/TransformWriter.cpp @@ -54,7 +54,7 @@ void TransformWriter::add_joint_transform(COLLADASW::Node &node, } else { float loc[3], rot[3], scale[3]; - bc_decompose(local, loc, rot, NULL, scale); + bc_decompose(local, loc, rot, nullptr, scale); add_transform(node, loc, rot, scale); } } @@ -90,7 +90,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node, } case BC_TRANSFORMATION_TYPE_DECOMPOSED: { float loc[3], rot[3], scale[3]; - bc_decompose(f_obmat, loc, rot, NULL, scale); + bc_decompose(f_obmat, loc, rot, nullptr, scale); if (limit_precision) { bc_sanitize_v3(loc, LIMITTED_PRECISION); bc_sanitize_v3(rot, LIMITTED_PRECISION); diff --git a/source/blender/io/collada/collada.cpp b/source/blender/io/collada/collada.cpp index bf1ebbfa669..f3c69c7d3d0 100644 --- a/source/blender/io/collada/collada.cpp +++ b/source/blender/io/collada/collada.cpp @@ -109,7 +109,7 @@ int collada_export(bContext *C, ExportSettings *export_settings) DocumentExporter exporter(blender_context, export_settings); int status = exporter.exportCurrentScene(); - BLI_linklist_free(export_settings->export_set, NULL); + BLI_linklist_free(export_settings->export_set, nullptr); return (status) ? -1 : export_count; } diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index d050554d916..58b579f5ac0 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -97,7 +97,7 @@ 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 == nullptr) { return 0; } if (ob == par) { @@ -112,7 +112,7 @@ 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 == nullptr) { return false; } if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) { @@ -120,7 +120,7 @@ bool bc_validateConstraints(bConstraint *con) } /* these constraints can't be evaluated anyway */ - if (cti->evaluate_constraint == NULL) { + if (cti->evaluate_constraint == nullptr) { return false; } @@ -144,7 +144,7 @@ bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) mul_m4_m4m4(ob->obmat, par->obmat, ob->obmat); } - bool ok = ED_object_parent_set(NULL, C, scene, ob, par, partype, xmirror, keep_transform, NULL); + bool ok = ED_object_parent_set(nullptr, C, scene, ob, par, partype, xmirror, keep_transform, nullptr); return ok; } @@ -222,7 +222,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context, bool triangulate) { CustomData_MeshMasks mask = CD_MASK_MESH; - Mesh *tmpmesh = NULL; + Mesh *tmpmesh = nullptr; if (apply_modifiers) { #if 0 /* Not supported by new system currently... */ switch (export_mesh_type) { @@ -246,7 +246,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context, tmpmesh = (Mesh *)ob->data; } - tmpmesh = (Mesh *)BKE_id_copy_ex(NULL, &tmpmesh->id, NULL, LIB_ID_COPY_LOCALIZE); + tmpmesh = (Mesh *)BKE_id_copy_ex(nullptr, &tmpmesh->id, nullptr, LIB_ID_COPY_LOCALIZE); if (triangulate) { bc_triangulate_mesh(tmpmesh); @@ -257,7 +257,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context, Object *bc_get_assigned_armature(Object *ob) { - Object *ob_arm = NULL; + Object *ob_arm = nullptr; if (ob->parent && ob->partype == PARSKEL && ob->parent->type == OB_ARMATURE) { ob_arm = ob->parent; @@ -319,7 +319,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) { if (deform_bones_only) { - Bone *root = NULL; + Bone *root = nullptr; Bone *bone = aBone; while (bone) { if (!(bone->flag & BONE_NO_DEFORM)) { @@ -381,7 +381,7 @@ void bc_match_scale(std::vector *objects_done, for (std::vector::iterator it = objects_done->begin(); it != objects_done->end(); ++it) { Object *ob = *it; - if (ob->parent == NULL) { + if (ob->parent == nullptr) { bc_match_scale(*it, bc_unit, scale_to_scene); } } @@ -450,11 +450,11 @@ void bc_triangulate_mesh(Mesh *me) BMeshFromMeshParams bm_from_me_params = {0}; bm_from_me_params.calc_face_normal = true; BM_mesh_bm_from_me(bm, me, &bm_from_me_params); - BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, NULL, NULL, NULL); + BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, nullptr, nullptr, nullptr); BMeshToMeshParams bm_to_me_params = {0}; bm_to_me_params.calc_object_remap = false; - BM_mesh_bm_to_me(NULL, bm, me, &bm_to_me_params); + BM_mesh_bm_to_me(nullptr, bm, me, &bm_to_me_params); BM_mesh_free(bm); } @@ -481,7 +481,7 @@ EditBone *bc_get_edit_bone(bArmature *armature, char *name) } } - return NULL; + return nullptr; } int bc_set_layer(int bitfield, int layer) { @@ -511,7 +511,7 @@ BoneExtensionMap &BoneExtensionManager::getExtensionMap(bArmature *armature) { std::string key = armature->id.name; BoneExtensionMap *result = extended_bone_maps[key]; - if (result == NULL) { + if (result == nullptr) { result = new BoneExtensionMap(); extended_bone_maps[key] = result; } @@ -706,7 +706,7 @@ int BoneExtended::get_use_connect() void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4]) { IDProperty *idgroup = (IDProperty *)ebone->prop; - if (idgroup == NULL) { + if (idgroup == nullptr) { IDPropertyTemplate val = {0}; idgroup = IDP_New(IDP_GROUP, &val, "RNA_EditBone ID properties"); ebone->prop = idgroup; @@ -754,7 +754,7 @@ static void bc_set_IDProperty(EditBone *ebone, const char *key, float value) */ IDProperty *bc_get_IDProperty(Bone *bone, std::string key) { - return (bone->prop == NULL) ? NULL : IDP_GetPropertyFromGroup(bone->prop, key.c_str()); + return (bone->prop == nullptr) ? nullptr : IDP_GetPropertyFromGroup(bone->prop, key.c_str()); } /** @@ -895,7 +895,7 @@ bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_open mul_m4_m4m4(mat, temp, mat); } } - bc_enable_fcurves(action, NULL); + bc_enable_fcurves(action, nullptr); return true; } @@ -908,11 +908,11 @@ bool bc_is_animated(BCMatrixSampleMap &values) } BCMatrixSampleMap::iterator it; - const BCMatrix *refmat = NULL; + const BCMatrix *refmat = nullptr; for (it = values.begin(); it != values.end(); ++it) { const BCMatrix *matrix = it->second; - if (refmat == NULL) { + if (refmat == nullptr) { refmat = matrix; continue; } @@ -1040,7 +1040,7 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, return; } - bc_decompose(from_mat, loc, rot, NULL, scale); + bc_decompose(from_mat, loc, rot, nullptr, scale); loc_eulO_size_to_mat4(to_mat, loc, rot, scale, 6); if (export_settings.get_keep_bind_info()) { @@ -1192,8 +1192,8 @@ std::string bc_find_bonename_in_path(std::string path, std::string probe) static bNodeTree *prepare_material_nodetree(Material *ma) { - if (ma->nodetree == NULL) { - ma->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree"); + if (ma->nodetree == nullptr) { + ma->nodetree = ntreeAddTree(nullptr, "Shader Nodetree", "ShaderNodeTree"); ma->use_nodes = true; } return ma->nodetree; @@ -1450,7 +1450,7 @@ bNode *bc_get_master_shader(Material *ma) } } } - return NULL; + return nullptr; } COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a) -- cgit v1.2.3