diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-28 14:32:16 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-28 14:32:16 +0300 |
commit | dd92220f0ba56bede8465bc7e137f0a8397980cc (patch) | |
tree | 0b89648300ec1c1b59fb13edac4caf25e8053132 /source/blender/blenkernel/intern | |
parent | 5639dcef62344a52c9da95d46b56b4691fc53035 (diff) | |
parent | 7d281a4f7d354d270fc9c9f3c7a65b4409362aa0 (diff) |
Merge branch 'master' into temp-attribute-processor
Diffstat (limited to 'source/blender/blenkernel/intern')
91 files changed, 628 insertions, 437 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 6caed3936d4..1d5eebf0abe 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -960,7 +960,7 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md, mesh_output = mesh_component.release(); } - /* Return an empty mesh instead of null. */ + /* Return an empty mesh instead of null. */ if (mesh_output == nullptr) { mesh_output = BKE_mesh_new_nomain(0, 0, 0, 0, 0); BKE_mesh_copy_parameters_for_eval(mesh_output, input_mesh); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 71d242e9c79..fdf3558abed 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -370,7 +370,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) /* Sync colors used for action/bone group with theme settings */ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp) { - /* only do color copying if using a custom color (i.e. not default color) */ + /* Only do color copying if using a custom color (i.e. not default color). */ if (grp->customCol) { if (grp->customCol > 0) { /* copy theme colors on-to group's custom color in case user tries to edit color */ @@ -486,8 +486,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) /* If grp is NULL, that means we fell through, and this F-Curve should be added as the new * first since group is (effectively) the first group. Thus, the existing first F-Curve becomes - * the second in the chain, etc. etc. - */ + * the second in the chain, etc. */ if (grp == NULL) { BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve); } @@ -1856,7 +1855,7 @@ void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm) /* Write channels */ LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) { /* Write ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this.*/ + * of library blocks that implement this. */ if (chan->prop) { IDP_BlendWrite(writer, chan->prop); } diff --git a/source/blender/blenkernel/intern/action_mirror.c b/source/blender/blenkernel/intern/action_mirror.c index c975d2bfb9c..69e0091444b 100644 --- a/source/blender/blenkernel/intern/action_mirror.c +++ b/source/blender/blenkernel/intern/action_mirror.c @@ -343,7 +343,7 @@ static void action_flip_pchan(Object *ob_arm, } \ ((void)0) - /* Write the values back the the F-curves. */ + /* Write the values back the F-curves. */ WRITE_ARRAY_FLT(loc); WRITE_ARRAY_FLT(eul); WRITE_ARRAY_FLT(quat); diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 44b760aefc8..2f71dda17f2 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -946,7 +946,7 @@ static bool nlastrips_path_rename_fix(ID *owner_id, is_changed |= fcurves_path_rename_fix( owner_id, prefix, oldName, newName, oldKey, newKey, &strip->act->curves, verify_paths); } - /* Ignore own F-Curves, since those are local. */ + /* Ignore own F-Curves, since those are local. */ /* Check sub-strips (if meta-strips). */ is_changed |= nlastrips_path_rename_fix( owner_id, prefix, oldName, newName, oldKey, newKey, &strip->strips, verify_paths); @@ -1422,7 +1422,7 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]> * i.e. pose.bones["Bone"] */ -/* TODO: use BKE_animdata_main_cb for looping over all data */ +/* TODO: use BKE_animdata_main_cb for looping over all data. */ void BKE_animdata_fix_paths_rename_all_ex(Main *bmain, ID *ref_id, const char *prefix, diff --git a/source/blender/blenkernel/intern/anim_path.c b/source/blender/blenkernel/intern/anim_path.c index af2b386a30a..e2c2708101b 100644 --- a/source/blender/blenkernel/intern/anim_path.c +++ b/source/blender/blenkernel/intern/anim_path.c @@ -327,7 +327,7 @@ bool BKE_where_on_path(const Object *ob, } const Nurb *nu = nurbs->first; - /* make sure that first and last frame are included in the vectors here */ + /* Make sure that first and last frame are included in the vectors here. */ if (ELEM(nu->type, CU_POLY, CU_BEZIER, CU_NURBS)) { key_curve_position_weights(frac, w, KEY_LINEAR); } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e347306e0ae..08a3f3fcf4f 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -852,7 +852,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, /* loop over strips, checking if they fall within the range */ for (strip = strips->first; strip; strip = strip->next) { - /* check if current time occurs within this strip */ + /* Check if current time occurs within this strip. */ if (IN_RANGE_INCL(ctime, strip->start, strip->end) || (strip->flag & NLASTRIP_FLAG_NO_TIME_MAP)) { /* this strip is active, so try to use it */ @@ -1564,7 +1564,7 @@ static bool nla_blend_get_inverted_strip_value(const int blendmode, } } -/** \returns true if solution exists and output is written to. */ +/** \returns true if solution exists and output is written to. */ static bool nla_combine_get_inverted_strip_value(const int mix_mode, float base_value, const float lower_value, @@ -2017,7 +2017,7 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li { FModifier *fcm1, *fcm2; - /* if list1 is invalid... */ + /* if list1 is invalid... */ if (ELEM(NULL, list1, list1->first)) { if (list2 && list2->first) { result->first = list2->first; diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index bcfd34ab42f..579f671e2b0 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -200,7 +200,7 @@ bool BKE_appdir_folder_documents(char *dir) return true; } - /* Ghost couldn't give us a documents path, let's try if we can find it ourselves.*/ + /* Ghost couldn't give us a documents path, let's try if we can find it ourselves. */ const char *home_path = BKE_appdir_folder_home(); if (!home_path || !BLI_is_dir(home_path)) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index a57e1d6b2dd..5799f82bf94 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -198,7 +198,7 @@ static void write_bone(BlendWriter *writer, Bone *bone) BLO_write_struct(writer, Bone, bone); /* Write ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this.*/ + * of library blocks that implement this. */ if (bone->prop) { IDP_BlendWrite(writer, bone->prop); } @@ -1627,7 +1627,7 @@ void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float o return; } - /* get inverse of (armature) object's matrix */ + /* Get inverse of (armature) object's matrix. */ invert_m4_m4(obmat, ob->obmat); /* multiply given matrix by object's-inverse to find pose-space matrix */ @@ -2063,9 +2063,11 @@ void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], * Used for Objects and Pose Channels, since both can have multiple rotation representations. * \{ */ -/* Called from RNA when rotation mode changes +/** + * Called from RNA when rotation mode changes * - the result should be that the rotations given in the provided pointers have had conversions - * applied (as appropriate), such that the rotation of the element hasn't 'visually' changed */ + * applied (as appropriate), such that the rotation of the element hasn't 'visually' changed. + */ void BKE_rotMode_change_values( float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode) { @@ -2333,7 +2335,7 @@ void BKE_armature_where_is_bone(Bone *bone, const Bone *bone_parent, const bool /* yoffs(b-1) + root(b) + bonemat(b) */ BKE_bone_offset_matrix_get(bone, offs_bone); - /* Compose the matrix for this bone */ + /* Compose the matrix for this bone. */ mul_m4_m4m4(bone->arm_mat, bone_parent->arm_mat, offs_bone); } else { diff --git a/source/blender/blenkernel/intern/armature_test.cc b/source/blender/blenkernel/intern/armature_test.cc index 366bbe3e37c..589337d9d01 100644 --- a/source/blender/blenkernel/intern/armature_test.cc +++ b/source/blender/blenkernel/intern/armature_test.cc @@ -121,7 +121,7 @@ TEST(vec_roll_to_mat3_normalized, Rotationmatrix) /* TODO: This test will pass after fixing T82455) */ /* If normalized_vector is close to -Y and * it has X and Z values above a threshold, - * apply the special case. */ + * apply the special case. */ { const float expected_roll_mat[3][3] = {{0.000000f, -9.99999975e-06f, 1.000000f}, {9.99999975e-06f, -0.999999881f, 9.99999975e-06f}, diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 4504f10967c..0f8956a1a91 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -837,7 +837,7 @@ void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *ob BIK_init_tree(depsgraph, scene, object, ctime); /* construct the Spline IK trees * - this is not integrated as an IK plugin, since it should be able - * to function in conjunction with standard IK. */ + * to function in conjunction with standard IK. */ BKE_pose_splineik_init_tree(scene, object, ctime); } diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 8bbb3014dac..aa0af294bc3 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -1197,7 +1197,7 @@ static blender::bke::OutputAttribute create_output_attribute( cpp_type->size() * domain_size, cpp_type->alignment(), __func__); if (ignore_old_values) { /* This does nothing for trivially constructible types, but is necessary for correctness. */ - cpp_type->construct_default_n(data, domain); + cpp_type->default_construct_n(data, domain); } else { /* Fill the temporary array with values from the existing attribute. */ diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c index c8fedc086b8..9c9f898afef 100644 --- a/source/blender/blenkernel/intern/blender_copybuffer.c +++ b/source/blender/blenkernel/intern/blender_copybuffer.c @@ -87,7 +87,8 @@ bool BKE_copybuffer_read(Main *bmain_dst, ReportList *reports, const uint64_t id_types_mask) { - BlendHandle *bh = BLO_blendhandle_from_file(libname, &(BlendFileReadReport){.reports = reports}); + BlendFileReadReport bf_reports = {.reports = reports}; + BlendHandle *bh = BLO_blendhandle_from_file(libname, &bf_reports); if (bh == NULL) { /* Error reports will have been made by BLO_blendhandle_from_file(). */ return false; @@ -133,7 +134,8 @@ int BKE_copybuffer_paste(bContext *C, BlendHandle *bh; const int id_tag_extra = 0; - bh = BLO_blendhandle_from_file(libname, &(BlendFileReadReport){.reports = reports}); + BlendFileReadReport bf_reports = {.reports = reports}; + bh = BLO_blendhandle_from_file(libname, &bf_reports); if (bh == NULL) { /* error reports will have been made by BLO_blendhandle_from_file() */ diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 6f47cd1336e..411ece21599 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -78,10 +78,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, if (UNDO_DISK) { const struct BlendFileReadParams params = {0}; - struct BlendFileData *bfd = BKE_blendfile_read( - mfu->filename, ¶ms, &(BlendFileReadReport){NULL}); + BlendFileReadReport bf_reports = {.reports = NULL}; + struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, ¶ms, &bf_reports); if (bfd != NULL) { - BKE_blendfile_read_setup(C, bfd, ¶ms, &(BlendFileReadReport){NULL}); + BKE_blendfile_read_setup(C, bfd, ¶ms, &bf_reports); success = true; } } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 9ea1c8fedda..f31d8f5ade7 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -272,7 +272,7 @@ static void setup_app_data(bContext *C, /* We need to tag this here because events may be handled immediately after. * only the current screen is important because we won't have to handle - * events from multiple screens at once.*/ + * events from multiple screens at once. */ if (curscreen) { BKE_screen_gizmo_tag_refresh(curscreen); } diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 116e6279657..4659c464099 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -1143,7 +1143,7 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon, bool insert = looptri_mask ? BLI_BITMAP_TEST_BOOL(looptri_mask, i) : true; if (insert) { - /* No reason found to block hit-testing the triangle for snap, so insert it now.*/ + /* No reason found to block hit-testing the triangle for snap, so insert it now. */ float co[3][3]; copy_v3_v3(co[0], ltri[0]->v->co); copy_v3_v3(co[1], ltri[1]->v->co); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index bab9e2a5592..5172b067eba 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -615,7 +615,7 @@ static void camera_frame_fit_data_init(const Scene *scene, BKE_camera_params_init(params); BKE_camera_params_from_object(params, ob); - /* compute matrix, viewplane, .. */ + /* Compute matrix, view-plane, etc. */ if (scene) { BKE_camera_params_compute_viewplane( params, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp); @@ -975,7 +975,7 @@ void BKE_camera_multiview_window_matrix(const RenderData *rd, BKE_camera_params_from_object(¶ms, camera); BKE_camera_multiview_params(rd, ¶ms, camera, viewname); - /* Compute matrix, viewplane, .. */ + /* Compute matrix, view-plane, etc. */ BKE_camera_params_compute_viewplane(¶ms, rd->xsch, rd->ysch, rd->xasp, rd->yasp); BKE_camera_params_compute_matrix(¶ms); diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index aa51ee0017e..fdffe7dca57 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -710,7 +710,7 @@ Collection *BKE_collection_duplicate(Main *bmain, * unless its duplication is a sub-process of another one. */ collection_new->id.tag &= ~LIB_TAG_NEW; - /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/ + /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */ BKE_libblock_relink_to_newid(&collection_new->id); #ifndef NDEBUG @@ -1458,7 +1458,7 @@ bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection) } /* Find possible objects in collection or its children, that would instantiate the given ancestor - * collection (that would also make a fully invalid cycle of dependencies) .*/ + * collection (that would also make a fully invalid cycle of dependencies). */ return collection_instance_find_recursive(collection, new_ancestor); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index f30fcc54b23..df2277387ce 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1280,12 +1280,12 @@ static void save_sample_line( { float yuv[3]; - /* vectorscope*/ + /* Vector-scope. */ rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709); scopes->vecscope[idx + 0] = yuv[1]; scopes->vecscope[idx + 1] = yuv[2]; - /* waveform */ + /* Waveform. */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: case SCOPES_WAVEFRM_RGB_PARADE: @@ -1497,7 +1497,7 @@ static void scopes_update_cb(void *__restrict userdata, mul_v3_fl(ycc, INV_255); minmax_v3v3_v3(min, max, ycc); } - /* increment count for histo*/ + /* Increment count for histo. */ bin_lum[get_bin_float(luma)]++; bin_r[get_bin_float(rgba[0])]++; bin_g[get_bin_float(rgba[1])]++; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 826c79c3764..1d5cfa752a4 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -222,7 +222,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob) /* XXX This would seem to be in wrong order. However, it does not work in 'right' order - * would be nice to understand why premul is needed here instead of usual postmul? * In any case, we **do not get a delta** here (e.g. startmat & matrix having same location, - * still gives a 'delta' with non-null translation component :/ ).*/ + * still gives a 'delta' with non-null translation component :/ ). */ mul_m4_m4m4(delta, cob->matrix, imat); /* copy matrices back to source */ @@ -272,7 +272,7 @@ void BKE_constraint_mat_convertspace(Object *ob, float diff_mat[4][4]; float imat[4][4]; - /* prevent crashes in these unlikely events */ + /* Prevent crashes in these unlikely events. */ if (ob == NULL || mat == NULL) { return; } @@ -1491,7 +1491,7 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph), dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, - NULL)) { /* quat_pt is quat or NULL*/ + NULL)) { /* quat_pt is quat or NULL. */ float totmat[4][4]; unit_m4(totmat); @@ -2361,7 +2361,7 @@ static void pycon_new_data(void *cdata) { bPythonConstraint *data = (bPythonConstraint *)cdata; - /* everything should be set correctly by calloc, except for the prop->type constant.*/ + /* Everything should be set correctly by calloc, except for the prop->type constant. */ data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps"); data->prop->type = IDP_GROUP; } @@ -3523,7 +3523,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t scale[0] = 1.0; scale[2] = 1.0; break; - default: /* should not happen, but in case*/ + default: /* Should not happen, but in case. */ return; } /* switch (data->volmode) */ @@ -3536,34 +3536,34 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t damptrack_do_transform(cob->matrix, vec, TRACK_Y); break; case PLANE_X: - /* new Y aligns object target connection*/ + /* New Y aligns object target connection. */ copy_v3_v3(cob->matrix[1], vec); - /* build new Z vector */ - /* othogonal to "new Y" "old X! plane */ + /* Build new Z vector. */ + /* Orthogonal to "new Y" "old X! plane. */ cross_v3_v3v3(orth, xx, vec); normalize_v3(orth); - /* new Z*/ + /* New Z. */ copy_v3_v3(cob->matrix[2], orth); - /* we decided to keep X plane*/ + /* We decided to keep X plane. */ cross_v3_v3v3(xx, vec, orth); normalize_v3_v3(cob->matrix[0], xx); break; case PLANE_Z: - /* new Y aligns object target connection*/ + /* New Y aligns object target connection. */ copy_v3_v3(cob->matrix[1], vec); - /* build new X vector */ - /* othogonal to "new Y" "old Z! plane */ + /* Build new X vector. */ + /* Orthogonal to "new Y" "old Z! plane. */ cross_v3_v3v3(orth, zz, vec); normalize_v3(orth); - /* new X */ + /* New X. */ negate_v3_v3(cob->matrix[0], orth); - /* we decided to keep Z */ + /* We decided to keep Z. */ cross_v3_v3v3(zz, vec, orth); normalize_v3_v3(cob->matrix[2], zz); break; @@ -4678,7 +4678,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta } } - /* find the pivot-point to use */ + /* Find the pivot-point to use. */ if (VALID_CONS_TARGET(ct)) { /* apply offset to target location */ add_v3_v3v3(pivot, ct->matrix[3], data->offset); @@ -6297,7 +6297,7 @@ void BKE_constraint_blend_write(BlendWriter *writer, ListBase *conlist) } /* Write ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this.*/ + * of library blocks that implement this. */ IDP_BlendWrite(writer, data->prop); break; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 81830f5bb61..1028790856c 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1225,8 +1225,11 @@ enum eContextObjectMode CTX_data_mode_enum(const bContext *C) return CTX_data_mode_enum_ex(obedit, obact, obact ? obact->mode : OB_MODE_OBJECT); } -/* would prefer if we can use the enum version below over this one - Campbell */ -/* must be aligned with above enum */ +/** + * Would prefer if we can use the enum version below over this one - Campbell. + * + * \note Must be aligned with above enum. + */ static const char *data_mode_strings[] = { "mesh_edit", "curve_edit", "surface_edit", "text_edit", "armature_edit", "mball_edit", "lattice_edit", "posemode", diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 65cdb8503a4..1849ca03b50 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1926,7 +1926,7 @@ static int cu_isectLL(const float v1[3], static bool bevelinside(const BevList *bl1, const BevList *bl2) { /* is bl2 INSIDE bl1 ? with left-right method and "lambda's" */ - /* returns '1' if correct hole */ + /* returns '1' if correct hole. */ BevPoint *bevp, *prevbevp; float min, max, vec[3], hvec1[3], hvec2[3], lab, mu; int nr, links = 0, rechts = 0, mode; @@ -1941,7 +1941,7 @@ static bool bevelinside(const BevList *bl1, const BevList *bl2) hvec2[0] += 1000; /* test it with all edges of potential surrounding poly */ - /* count number of transitions left-right */ + /* count number of transitions left-right. */ bevp = bl1->bevpoints; nr = bl1->nr; @@ -2133,7 +2133,7 @@ static void tilt_bezpart(const BezTriple *prevbezt, } if (weight_array) { - /* basic interpolation for now, could copy tilt interp too */ + /* Basic interpolation for now, could copy tilt interp too. */ *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac); @@ -2684,7 +2684,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) 1; #endif - /* STEP 1: MAKE POLYS */ + /* STEP 1: MAKE POLYS */ BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev); if (cu->editnurb && ob->type != OB_FONT) { @@ -4361,7 +4361,7 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code) else { char h_new = HD_FREE; - /* there is 1 handle not FREE: FREE it all, else make ALIGNED */ + /* There is 1 handle not FREE: FREE it all, else make ALIGNED. */ if (code == 5) { h_new = HD_ALIGN; } @@ -4932,7 +4932,7 @@ bool BKE_nurb_type_convert(Nurb *nu, int a, c, nr; if (nu->type == CU_POLY) { - if (type == CU_BEZIER) { /* to Bezier with vecthandles */ + if (type == CU_BEZIER) { /* To Bezier with vecthandles. */ nr = nu->pntsu; bezt = (BezTriple *)MEM_calloc_arrayN(nr, sizeof(BezTriple), "setsplinetype2"); nu->bezt = bezt; @@ -5135,7 +5135,7 @@ void BKE_curve_nurb_vert_active_set(Curve *cu, const Nurb *nu, const void *vert) } } -/* Get points to active active nurb and active vert for curve */ +/* Get points to the active nurb and active vert for curve. */ bool BKE_curve_nurb_vert_active_get(Curve *cu, Nurb **r_nu, void **r_vert) { Nurb *nu = NULL; diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c index 7f2cdfa59d3..d205d8cca46 100644 --- a/source/blender/blenkernel/intern/curve_bevel.c +++ b/source/blender/blenkernel/intern/curve_bevel.c @@ -97,7 +97,7 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu, * in a consistent direction. * * These should be small enough for stack allocations because the current limit - * for #Curve.bevresol is 32. */ + * for #Curve.bevresol is 32. */ float *quarter_coords_x = alloca(sizeof(float) * (cu->bevresol + 1)); float *quarter_coords_y = alloca(sizeof(float) * (cu->bevresol + 1)); bevel_quarter_fill(cu, quarter_coords_x, quarter_coords_y); diff --git a/source/blender/blenkernel/intern/curve_decimate.c b/source/blender/blenkernel/intern/curve_decimate.c index e4647908b58..62de7c74183 100644 --- a/source/blender/blenkernel/intern/curve_decimate.c +++ b/source/blender/blenkernel/intern/curve_decimate.c @@ -32,8 +32,8 @@ struct Knot { struct Knot *next, *prev; - uint point_index; /* index in point array */ - uint knot_index; /* index in knot array*/ + uint point_index; /* Index in point array. */ + uint knot_index; /* Index in knot array. */ float tan[2][3]; float handles[2]; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index b1bb8b9715e..08d0af45e92 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2099,7 +2099,7 @@ bool CustomData_merge(const struct CustomData *source, eCDAllocType alloctype, int totelem) { - /*const LayerTypeInfo *typeInfo;*/ + // const LayerTypeInfo *typeInfo; CustomDataLayer *layer, *newlayer; int lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0; int number = 0, maxnumber = -1; @@ -2107,7 +2107,7 @@ bool CustomData_merge(const struct CustomData *source, for (int i = 0; i < source->totlayer; i++) { layer = &source->layers[i]; - /*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/ + // typeInfo = layerType_getInfo(layer->type); /* UNUSED */ int type = layer->type; int flag = layer->flag; @@ -2631,7 +2631,7 @@ void *CustomData_add_layer( return NULL; } -/*same as above but accepts a name*/ +/* Same as above but accepts a name. */ void *CustomData_add_layer_named(CustomData *data, int type, eCDAllocType alloctype, @@ -2813,6 +2813,14 @@ void *CustomData_duplicate_referenced_layer_named(CustomData *data, return customData_duplicate_referenced_layer_index(data, layer_index, totelem); } +void CustomData_duplicate_referenced_layers(CustomData *data, int totelem) +{ + for (int i = 0; i < data->totlayer; i++) { + CustomDataLayer *layer = &data->layers[i]; + layer->data = customData_duplicate_referenced_layer_index(data, i, totelem); + } +} + bool CustomData_is_referenced_layer(struct CustomData *data, int type) { /* get the layer index of the first layer of type */ @@ -3559,7 +3567,7 @@ bool CustomData_bmesh_merge(const CustomData *source, if (iter_type != BM_LOOPS_OF_FACE) { BMHeader *h; BMIter iter; - /*ensure all current elements follow new customdata layout*/ + /* Ensure all current elements follow new customdata layout. */ BM_ITER_MESH (h, &iter, bm, iter_type) { void *tmp = NULL; CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp); @@ -3573,7 +3581,7 @@ bool CustomData_bmesh_merge(const CustomData *source, BMIter iter; BMIter liter; - /*ensure all current elements follow new customdata layout*/ + /* Ensure all current elements follow new customdata layout. */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { void *tmp = NULL; @@ -3797,7 +3805,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int return POINTER_OFFSET(block, data->layers[layer_index + n].offset); } -/*gets from the layer at physical index n, note: doesn't check type.*/ +/* Gets from the layer at physical index n, note: doesn't check type. */ void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n) { if (n < 0 || n >= data->totlayer) { @@ -3879,7 +3887,7 @@ bool CustomData_has_referenced(const struct CustomData *data) } /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to - * another, while not overwriting anything else (e.g. flags)*/ + * another, while not overwriting anything else (e.g. flags). */ void CustomData_data_copy_value(int type, const void *source, void *dest) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -3897,7 +3905,7 @@ void CustomData_data_copy_value(int type, const void *source, void *dest) } /* Mixes the "value" (e.g. mloopuv uv or mloopcol colors) from one block into - * another, while not overwriting anything else (e.g. flags)*/ + * another, while not overwriting anything else (e.g. flags). */ void CustomData_data_mix_value( int type, const void *source, void *dest, const int mixmode, const float mixfactor) { diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c index 2bf58d9e764..12269cf0d51 100644 --- a/source/blender/blenkernel/intern/data_transfer.c +++ b/source/blender/blenkernel/intern/data_transfer.c @@ -1260,7 +1260,7 @@ void BKE_object_data_transfer_layout(struct Depsgraph *depsgraph, me_dst = ob_dst->data; - /* Get source evaluated mesh.*/ + /* Get source evaluated mesh. */ BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask); me_src = mesh_get_eval_final(depsgraph, scene, ob_src, &me_src_mask); if (!me_src) { @@ -1441,7 +1441,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, } } - /* Get source evaluated mesh.*/ + /* Get source evaluated mesh. */ BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask); BKE_mesh_remap_calc_source_cddata_masks_from_map_modes( map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode, &me_src_mask); diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 70355f3883d..65251ac1807 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -323,7 +323,7 @@ static void curve_to_displist(const Curve *cu, /* Check that there are more than two points so the curve doesn't loop back on itself. This * needs to be separate from `is_cyclic` because cyclic sampling can work with two points - * and resolution > 1. */ + * and resolution > 1. */ const bool use_cyclic_sample = is_cyclic && (samples_len != 2); DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 788a51257bf..2eb18a06799 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1757,7 +1757,7 @@ void dynamicPaint_clearSurface(const Scene *scene, DynamicPaintSurface *surface) } } -/* completely (re)initializes surface (only for point cache types)*/ +/* Completely (re)initializes surface (only for point cache types). */ bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface) { int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface); @@ -4145,7 +4145,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( /* mix final sample strength depending on brush settings */ if (hit_found) { - /* if "negate volume" enabled, negate all factors within volume*/ + /* If "negate volume" enabled, negate all factors within volume. */ if (brush->collision == MOD_DPAINT_COL_VOLDIST && brush->flags & MOD_DPAINT_NEGATE_VOLUME) { volume_factor = 1.0f - volume_factor; if (inner_proximity) { diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index b512309a773..49c2a2cbd89 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -222,7 +222,7 @@ void BKE_editmesh_free_derivedmesh(BMEditMesh *em) MEM_SAFE_FREE(em->bb_cage); } -/*does not free the BMEditMesh struct itself*/ +/* Does not free the #BMEditMesh struct itself. */ void BKE_editmesh_free(BMEditMesh *em) { BKE_editmesh_free_derivedmesh(em); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index e39749225ea..ff0fc4754e3 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -773,7 +773,7 @@ int get_effector_data(EffectorCache *eff, /* use center of object for distance calculus */ const Object *ob = eff->ob; - /* use z-axis as normal*/ + /* Use z-axis as normal. */ normalize_v3_v3(efd->nor, ob->obmat[2]); if (eff->pd && ELEM(eff->pd->shape, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_LINE)) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 68ed3c239ef..18dac2fb679 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1309,7 +1309,7 @@ void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag) * - Need bezier keys. * - Only bezier-interpolation has handles (for now). */ - if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/) { + if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN) */) { return; } @@ -2322,7 +2322,7 @@ void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers) FMod_Python *data = fcm->data; /* Write ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this.*/ + * of library blocks that implement this. */ IDP_BlendWrite(writer, data->prop); break; diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 553575b5c7b..947417af55d 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4395,7 +4395,7 @@ static void manta_smoke_calc_transparency(FluidDomainSettings *fds, ViewLayer *v int cell[3]; float t_ray = 1.0; - /* Reset shadow value.*/ + /* Reset shadow value. */ shadow[index] = -1.0f; voxel_center[0] = (float)x; @@ -5023,7 +5023,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd, /* viscosity options */ tfds->viscosity_value = fds->viscosity_value; - /* diffusion options*/ + /* Diffusion options. */ tfds->surface_tension = fds->surface_tension; tfds->viscosity_base = fds->viscosity_base; tfds->viscosity_exponent = fds->viscosity_exponent; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 8d1e6b26d4d..b9f0b97ab46 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -875,7 +875,7 @@ static void fcm_python_new_data(void *mdata) { FMod_Python *data = (FMod_Python *)mdata; - /* everything should be set correctly by calloc, except for the prop->type constant.*/ + /* Everything should be set correctly by calloc, except for the prop->type constant. */ data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps"); data->prop->type = IDP_GROUP; } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 92cc3c763b6..95de9a9d636 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1271,7 +1271,7 @@ static bool vfont_to_curve(Object *ob, MEM_freeN(i_textbox_array); /* TEXT ON CURVE */ - /* Note: Only OB_CURVE objects could have a path */ + /* NOTE: Only OB_CURVE objects could have a path. */ if (cu->textoncurve && cu->textoncurve->type == OB_CURVE) { BLI_assert(cu->textoncurve->runtime.curve_cache != NULL); if (cu->textoncurve->runtime.curve_cache != NULL && @@ -1746,7 +1746,7 @@ void BKE_vfont_clipboard_set(const char32_t *text_buf, const CharInfo *info_buf, char32_t *text; CharInfo *info; - /* clean previous buffers*/ + /* Clean previous buffers. */ BKE_vfont_clipboard_free(); text = MEM_malloc_arrayN((len + 1), sizeof(*text), __func__); diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 42f3a854aec..28e46aab732 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -29,7 +29,7 @@ #include "attribute_access_intern.hh" -/* Can't include BKE_object_deform.h right now, due to an enum forward declaration. */ +/* Can't include BKE_object_deform.h right now, due to an enum forward declaration. */ extern "C" MDeformVert *BKE_object_defgroup_data_create(ID *id); using blender::fn::GVArray; diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 3d85118deee..07b4e715ea9 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -199,20 +199,6 @@ std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set) return stream; } -/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by - * the CPPType system. */ -bool operator==(const GeometrySet &UNUSED(a), const GeometrySet &UNUSED(b)) -{ - return false; -} - -/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by - * the CPPType system. */ -uint64_t GeometrySet::hash() const -{ - return reinterpret_cast<uint64_t>(this); -} - /* Remove all geometry components from the geometry set. */ void GeometrySet::clear() { diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 8cf08d05d9d..3c50b966f04 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -264,7 +264,7 @@ static bool instances_attribute_foreach_recursive(const GeometrySet &geometry_se } } - /* Now that this this geometry set is visited, increase the count and check with the limit. */ + /* Now that this geometry set is visited, increase the count and check with the limit. */ if (limit > 0 && count++ > limit) { return false; } @@ -535,7 +535,7 @@ static void join_attributes(Span<GeometryInstanceGroup> set_groups, const void *src_buffer = src_span.data(); for (const int UNUSED(i) : set_group.transforms.index_range()) { void *dst_buffer = dst_span[offset]; - cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size); + cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size); offset += domain_size; } } diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index a66c3cf3573..459fc5e4c68 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -195,12 +195,12 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd) { - /* we must firstly have some grease-pencil data to link! */ + /* We must firstly have some grease-pencil data to link! */ if (gpd == NULL) { return; } - /* relink animdata */ + /* Relink anim-data. */ BLO_read_data_address(reader, &gpd->adt); BKE_animdata_blend_read_data(reader, gpd->adt); @@ -219,7 +219,7 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd) gpd->runtime.sbuffer_size = 0; gpd->runtime.tot_cp_points = 0; - /* relink palettes (old palettes deprecated, only to convert old files) */ + /* Relink palettes (old palettes deprecated, only to convert old files). */ BLO_read_list(reader, &gpd->palettes); if (gpd->palettes.first != NULL) { LISTBASE_FOREACH (bGPDpalette *, palette, &gpd->palettes) { @@ -227,14 +227,14 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd) } } - /* materials */ + /* Materials. */ BLO_read_pointer_array(reader, (void **)&gpd->mat); - /* relink layers */ + /* Relink layers. */ BLO_read_list(reader, &gpd->layers); LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { - /* relink frames */ + /* Relink frames. */ BLO_read_list(reader, &gpl->frames); BLO_read_data_address(reader, &gpl->actframe); @@ -245,23 +245,23 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd) BLO_read_list(reader, &gpl->mask_layers); LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { - /* relink strokes (and their points) */ + /* Relink strokes (and their points). */ BLO_read_list(reader, &gpf->strokes); LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { - /* relink stroke points array */ + /* Relink stroke points array. */ BLO_read_data_address(reader, &gps->points); - /* Relink geometry*/ + /* Relink geometry. */ BLO_read_data_address(reader, &gps->triangles); - /* relink stroke edit curve. */ + /* Relink stroke edit curve. */ BLO_read_data_address(reader, &gps->editcurve); if (gps->editcurve != NULL) { - /* relink curve point array */ + /* Relink curve point array. */ BLO_read_data_address(reader, &gps->editcurve->curve_points); } - /* relink weight data */ + /* Relink weight data. */ if (gps->dvert) { BLO_read_data_address(reader, &gps->dvert); BKE_defvert_blend_read(reader, gps->totpoints, gps->dvert); @@ -458,7 +458,7 @@ void BKE_gpencil_free_frames(bGPDlayer *gpl) void BKE_gpencil_free_layer_masks(bGPDlayer *gpl) { - /* Free masks.*/ + /* Free masks. */ bGPDlayer_Mask *mask_next = NULL; for (bGPDlayer_Mask *mask = gpl->mask_layers.first; mask; mask = mask_next) { mask_next = mask->next; @@ -482,7 +482,7 @@ void BKE_gpencil_free_layers(ListBase *list) /* free layers and their data */ BKE_gpencil_free_frames(gpl); - /* Free masks.*/ + /* Free masks. */ BKE_gpencil_free_layer_masks(gpl); BLI_freelinkN(list, gpl); @@ -1076,12 +1076,7 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src, gpl_dst->prev = gpl_dst->next = NULL; /* Copy masks. */ - BLI_listbase_clear(&gpl_dst->mask_layers); - LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) { - bGPDlayer_Mask *mask_dst = MEM_dupallocN(mask_src); - mask_dst->prev = mask_dst->next = NULL; - BLI_addtail(&gpl_dst->mask_layers, mask_dst); - } + BKE_gpencil_layer_mask_copy(gpl_src, gpl_dst); /* copy frames */ BLI_listbase_clear(&gpl_dst->frames); @@ -1122,13 +1117,8 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds copy_v3_v3(gpl_dst->scale, gpl_src->scale); copy_m4_m4(gpl_dst->layer_mat, gpl_src->layer_mat); copy_m4_m4(gpl_dst->layer_invmat, gpl_src->layer_invmat); - /* Use Lights flag. */ - if (gpl_src->flag & GP_LAYER_USE_LIGHTS) { - gpl_dst->flag |= GP_LAYER_USE_LIGHTS; - } - else { - gpl_dst->flag &= ~GP_LAYER_USE_LIGHTS; - } + gpl_dst->blend_mode = gpl_src->blend_mode; + gpl_dst->flag = gpl_src->flag; } /** @@ -1647,6 +1637,41 @@ void BKE_gpencil_layer_mask_sort_all(bGPdata *gpd) } } +/** + * Make a copy of a given gpencil mask layers. + */ +void BKE_gpencil_layer_mask_copy(const bGPDlayer *gpl_src, bGPDlayer *gpl_dst) +{ + BLI_listbase_clear(&gpl_dst->mask_layers); + LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) { + bGPDlayer_Mask *mask_dst = MEM_dupallocN(mask_src); + mask_dst->prev = mask_dst->next = NULL; + BLI_addtail(&gpl_dst->mask_layers, mask_dst); + } +} + +/** + * Clean any invalid mask layer. + */ +void BKE_gpencil_layer_mask_cleanup(bGPdata *gpd, bGPDlayer *gpl) +{ + LISTBASE_FOREACH_MUTABLE (bGPDlayer_Mask *, mask, &gpl->mask_layers) { + if (BKE_gpencil_layer_named_get(gpd, mask->name) == NULL) { + BKE_gpencil_layer_mask_remove(gpl, mask); + } + } +} + +/** + * Clean any invalid mask layer for all layers. + */ +void BKE_gpencil_layer_mask_cleanup_all_layers(bGPdata *gpd) +{ + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + BKE_gpencil_layer_mask_cleanup(gpd, gpl); + } +} + static int gpencil_cb_cmp_frame(void *thunk, const void *a, const void *b) { const bGPDframe *frame_a = a; diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 906d0fb0792..344be7bc0f5 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -242,8 +242,8 @@ static int gpencil_get_stroke_material_fromcurve( float color_fill[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* If the curve has 2 materials, the first is considered as Fill and the second as Stroke. - * If the has only one material, if the name contains _stroke, the is used - * as stroke, else as fill.*/ + * If the has only one material, if the name contains "_stroke", + * it's used as a stroke, otherwise as fill. */ if (ob_cu->totcol >= 2) { *do_stroke = true; *do_fill = true; @@ -350,7 +350,7 @@ static void gpencil_convert_spline(Main *bmain, /* Assign material index to stroke. */ gps->mat_nr = r_idx; - /* Add stroke to frame.*/ + /* Add stroke to frame. */ BLI_addtail(&gpf->strokes, gps); float *coord_array = NULL; diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 982fc2abd65..2b16bbb10b2 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -793,6 +793,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf) { bGPDspoint *pt = &gps->points[i]; float sco[3] = {0.0f}; + const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0; /* Do nothing if not enough points to smooth out */ if (gps->totpoints <= 2) { @@ -802,7 +803,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf) /* Only affect endpoints by a fraction of the normal strength, * to prevent the stroke from shrinking too much */ - if (ELEM(i, 0, gps->totpoints - 1)) { + if (!is_cyclic && ELEM(i, 0, gps->totpoints - 1)) { inf *= 0.1f; } @@ -828,8 +829,22 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf) int before = i - step; int after = i + step; - CLAMP_MIN(before, 0); - CLAMP_MAX(after, gps->totpoints - 1); + if (is_cyclic) { + if (before < 0) { + /* Sub to end point (before is already negative). */ + before = gps->totpoints + before; + CLAMP(before, 0, gps->totpoints - 1); + } + if (after > gps->totpoints - 1) { + /* Add to start point. */ + after = after - gps->totpoints; + CLAMP(after, 0, gps->totpoints - 1); + } + } + else { + CLAMP_MIN(before, 0); + CLAMP_MAX(after, gps->totpoints - 1); + } pt1 = &gps->points[before]; pt2 = &gps->points[after]; @@ -855,6 +870,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf) bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float influence) { bGPDspoint *ptb = &gps->points[point_index]; + const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0; /* Do nothing if not enough points */ if ((gps->totpoints <= 2) || (point_index < 1)) { @@ -862,7 +878,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float } /* Only affect endpoints by a fraction of the normal influence */ float inf = influence; - if (ELEM(point_index, 0, gps->totpoints - 1)) { + if (!is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) { inf *= 0.01f; } /* Limit max influence to reduce pop effect. */ @@ -884,9 +900,22 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float int before = point_index - step; int after = point_index + step; - CLAMP_MIN(before, 0); - CLAMP_MAX(after, gps->totpoints - 1); - + if (is_cyclic) { + if (before < 0) { + /* Sub to end point (before is already negative). */ + before = gps->totpoints + before; + CLAMP(before, 0, gps->totpoints - 1); + } + if (after > gps->totpoints - 1) { + /* Add to start point. */ + after = after - gps->totpoints; + CLAMP(after, 0, gps->totpoints - 1); + } + } + else { + CLAMP_MIN(before, 0); + CLAMP_MAX(after, gps->totpoints - 1); + } pt1 = &gps->points[before]; pt2 = &gps->points[after]; @@ -919,6 +948,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float influence) { bGPDspoint *ptb = &gps->points[point_index]; + const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0; /* Do nothing if not enough points */ if ((gps->totpoints <= 2) || (point_index < 1)) { @@ -926,7 +956,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float } /* Only affect endpoints by a fraction of the normal influence */ float inf = influence; - if (ELEM(point_index, 0, gps->totpoints - 1)) { + if (!is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) { inf *= 0.01f; } /* Limit max influence to reduce pop effect. */ @@ -948,9 +978,22 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float int before = point_index - step; int after = point_index + step; - CLAMP_MIN(before, 0); - CLAMP_MAX(after, gps->totpoints - 1); - + if (is_cyclic) { + if (before < 0) { + /* Sub to end point (before is already negative). */ + before = gps->totpoints + before; + CLAMP(before, 0, gps->totpoints - 1); + } + if (after > gps->totpoints - 1) { + /* Add to start point. */ + after = after - gps->totpoints; + CLAMP(after, 0, gps->totpoints - 1); + } + } + else { + CLAMP_MIN(before, 0); + CLAMP_MAX(after, gps->totpoints - 1); + } pt1 = &gps->points[before]; pt2 = &gps->points[after]; @@ -982,6 +1025,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float bool BKE_gpencil_stroke_smooth_uv(bGPDstroke *gps, int point_index, float influence) { bGPDspoint *ptb = &gps->points[point_index]; + const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0; /* Do nothing if not enough points */ if (gps->totpoints <= 2) { @@ -993,9 +1037,22 @@ bool BKE_gpencil_stroke_smooth_uv(bGPDstroke *gps, int point_index, float influe int before = point_index - 1; int after = point_index + 1; - CLAMP_MIN(before, 0); - CLAMP_MAX(after, gps->totpoints - 1); - + if (is_cyclic) { + if (before < 0) { + /* Sub to end point (before is already negative). */ + before = gps->totpoints + before; + CLAMP(before, 0, gps->totpoints - 1); + } + if (after > gps->totpoints - 1) { + /* Add to start point. */ + after = after - gps->totpoints; + CLAMP(after, 0, gps->totpoints - 1); + } + } + else { + CLAMP_MIN(before, 0); + CLAMP_MAX(after, gps->totpoints - 1); + } pta = &gps->points[before]; ptc = &gps->points[after]; @@ -1993,7 +2050,7 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, bGPDstroke *gps, int level, int MEM_SAFE_FREE(temp_points); MEM_SAFE_FREE(temp_dverts); - /* move points to smooth stroke (not simple type )*/ + /* Move points to smooth stroke (not simple type). */ if (type != GP_SUBDIV_SIMPLE) { /* duplicate points in a temp area with the new subdivide data */ temp_points = MEM_dupallocN(gps->points); @@ -2076,7 +2133,7 @@ void BKE_gpencil_stroke_merge_distance(bGPdata *gpd, else { pt->flag |= GP_SPOINT_TAG; } - /* Jump to next pair of points, keeping first point segment equals.*/ + /* Jump to next pair of points, keeping first point segment equals. */ step++; } else { @@ -2811,7 +2868,7 @@ static void gpencil_stroke_join_islands(bGPdata *gpd, MDeformVert *dvert_src = NULL; MDeformVert *dvert_dst = NULL; - /* Copy weights (last before)*/ + /* Copy weights (last before). */ e1 = 0; e2 = 0; for (int i = 0; i < totpoints; i++) { @@ -3751,11 +3808,11 @@ static ListBase *gpencil_stroke_perimeter_ex(const bGPdata *gpd, last_prev_pt[0] -= 1.0f; } - /* generate points for start cap */ + /* Generate points for start cap. */ num_perimeter_points += generate_perimeter_cap( first_pt, first_next_pt, first_radius, perimeter_right_side, subdivisions, gps->caps[0]); - /* generate perimeter points */ + /* Generate perimeter points. */ float curr_pt[3], next_pt[3], prev_pt[3]; float vec_next[2], vec_prev[2]; float nvec_next[2], nvec_prev[2]; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 58715ac2e05..a67e78ceea0 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -54,15 +54,15 @@ static CLG_LogRef LOG = {"bke.idprop"}; -/*local size table.*/ +/* Local size table. */ static size_t idp_size_table[] = { 1, /*strings*/ sizeof(int), sizeof(float), - sizeof(float[3]), /*Vector type, deprecated*/ - sizeof(float[16]), /*Matrix type, deprecated*/ - 0, /*arrays don't have a fixed size*/ - sizeof(ListBase), /*Group type*/ + sizeof(float[3]), /* Vector type, deprecated. */ + sizeof(float[16]), /* Matrix type, deprecated. */ + 0, /* Arrays don't have a fixed size. */ + sizeof(ListBase), /* Group type. */ sizeof(void *), sizeof(double), }; @@ -99,12 +99,12 @@ IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag) narray->data.pointer = MEM_dupallocN(array->data.pointer); for (int i = 0; i < narray->len; i++) { - /* ok, the copy functions always allocate a new structure, + /* OK, the copy functions always allocate a new structure, * which doesn't work here. instead, simply copy the * contents of the new structure into the array cell, * then free it. this makes for more maintainable * code than simply re-implementing the copy functions - * in this loop.*/ + * in this loop. */ IDProperty *tmp = IDP_CopyProperty_ex(GETPROP(narray, i), flag); memcpy(GETPROP(narray, i), tmp, sizeof(IDProperty)); MEM_freeN(tmp); @@ -228,7 +228,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr) } } -/*this function works for strings too!*/ +/* This function works for strings too! */ void IDP_ResizeArray(IDProperty *prop, int newlen) { const bool is_grow = newlen >= prop->len; @@ -390,8 +390,8 @@ void IDP_ConcatStringC(IDProperty *prop, const char *st) BLI_assert(prop->type == IDP_STRING); int newlen = prop->len + (int)strlen(st); - /* we have to remember that prop->len includes the null byte for strings. - * so there's no need to add +1 to the resize function.*/ + /* We have to remember that prop->len includes the null byte for strings. + * so there's no need to add +1 to the resize function. */ IDP_ResizeArray(prop, newlen); strcat(prop->data.pointer, st); } @@ -400,8 +400,8 @@ void IDP_ConcatString(IDProperty *str1, IDProperty *append) { BLI_assert(append->type == IDP_STRING); - /* since ->len for strings includes the NULL byte, we have to subtract one or - * we'll get an extra null byte after each concatenation operation.*/ + /* Since ->len for strings includes the NULL byte, we have to subtract one or + * we'll get an extra null byte after each concatenation operation. */ int newlen = str1->len + append->len - 1; IDP_ResizeArray(str1, newlen); strcat(str1->data.pointer, append->data.pointer); @@ -775,10 +775,10 @@ IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed) if (create_if_needed) { id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty"); id->properties->type = IDP_GROUP; - /* don't overwrite the data's name and type + /* NOTE(campbell): Don't overwrite the data's name and type * some functions might need this if they - * don't have a real ID, should be named elsewhere - Campbell */ - /* strcpy(id->name, "top_level_group");*/ + * don't have a real ID, should be named elsewhere. */ + // strcpy(id->name, "top_level_group"); } return id->properties; } @@ -1106,7 +1106,7 @@ void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer); static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer) { - /*REMEMBER to set totalen to len in the linking code!!*/ + /* Remember to set #IDProperty.totallen to len in the linking code! */ if (prop->data.pointer) { BLO_write_raw(writer, MEM_allocN_len(prop->data.pointer), prop->data.pointer); @@ -1123,7 +1123,7 @@ static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer) static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer) { - /*REMEMBER to set totalen to len in the linking code!!*/ + /* Remember to set #IDProperty.totallen to len in the linking code! */ if (prop->data.pointer) { const IDProperty *array = prop->data.pointer; @@ -1137,7 +1137,7 @@ static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer) static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer) { - /*REMEMBER to set totalen to len in the linking code!!*/ + /* Remember to set #IDProperty.totallen to len in the linking code! */ BLO_write_raw(writer, (size_t)prop->len, prop->data.pointer); } @@ -1219,7 +1219,7 @@ static void IDP_DirectLinkArray(IDProperty *prop, BlendDataReader *reader) static void IDP_DirectLinkString(IDProperty *prop, BlendDataReader *reader) { - /*since we didn't save the extra string buffer, set totallen to len.*/ + /* Since we didn't save the extra string buffer, set totallen to len. */ prop->totallen = prop->len; BLO_read_data_address(reader, &prop->data.pointer); } @@ -1230,7 +1230,7 @@ static void IDP_DirectLinkGroup(IDProperty *prop, BlendDataReader *reader) BLO_read_list(reader, lb); - /*Link child id properties now*/ + /* Link child id properties now. */ LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { IDP_DirectLinkProperty(loop, reader); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7a3619154a6..740c9b3864c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1056,9 +1056,11 @@ Image *BKE_image_add_generated(Main *bmain, return ima; } -/* Create an image image from ibuf. The refcount of ibuf is increased, +/** + * Create an image from ibuf. The refcount of ibuf is increased, * caller should take care to drop its reference by calling - * IMB_freeImBuf if needed. */ + * #IMB_freeImBuf if needed. + */ Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name) { /* on save, type is changed to FILE in editsima.c */ @@ -3208,7 +3210,7 @@ Image *BKE_image_ensure_viewer(Main *bmain, int type, const char *name) ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type); } - /* happens on reload, imagewindow cannot be image user when hidden*/ + /* Happens on reload, imagewindow cannot be image user when hidden. */ if (ima->id.us == 0) { id_us_ensure_real(&ima->id); } @@ -4349,7 +4351,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i BKE_image_user_file_path(&iuser_t, ima, str); - /* FIXME: make several stream accessible in image editor, too*/ + /* FIXME: make several stream accessible in image editor, too. */ ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name); /* let's initialize this user */ @@ -5188,7 +5190,7 @@ bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser) return ibuf != NULL; } -/* ******** Pool for image buffers ******** */ +/* ******** Pool for image buffers ******** */ typedef struct ImagePoolItem { struct ImagePoolItem *next, *prev; diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c index e571499ba8e..b68cd9e4d2d 100644 --- a/source/blender/blenkernel/intern/image_save.c +++ b/source/blender/blenkernel/intern/image_save.c @@ -207,7 +207,7 @@ static bool image_save_single(ReportList *reports, goto cleanup; } - /* it shouldn't ever happen*/ + /* It shouldn't ever happen. */ if ((BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)) == NULL) || (BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == NULL)) { BKE_reportf(reports, diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index bdc763cf4ca..f365e759221 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -262,7 +262,7 @@ static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *to /* Object types */ static const char *ob_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -377,7 +377,7 @@ static const char *ob_adrcodes_to_paths(int adrcode, int *array_index) */ static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -434,7 +434,7 @@ static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index) /* Constraint types */ static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -605,7 +605,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) /* Texture types */ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -692,7 +692,7 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index) /* Material Types */ static const char *material_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -785,7 +785,7 @@ static const char *material_adrcodes_to_paths(int adrcode, int *array_index) /* Camera Types */ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -830,7 +830,7 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index) /* Light Types */ static const char *light_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -875,7 +875,7 @@ static const char *light_adrcodes_to_paths(int adrcode, int *array_index) /* Sound Types */ static const char *sound_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -901,7 +901,7 @@ static const char *sound_adrcodes_to_paths(int adrcode, int *array_index) /* World Types */ static const char *world_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ @@ -947,7 +947,7 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index) /* Particle Types */ static const char *particle_adrcodes_to_paths(int adrcode, int *array_index) { - /* set array index like this in-case nothing sets it correctly */ + /* Set array index like this in-case nothing sets it correctly. */ *array_index = 0; /* result depends on adrcode */ diff --git a/source/blender/blenkernel/intern/keyconfig.c b/source/blender/blenkernel/intern/keyconfig.c index 552760c9b34..d25f475c140 100644 --- a/source/blender/blenkernel/intern/keyconfig.c +++ b/source/blender/blenkernel/intern/keyconfig.c @@ -55,7 +55,7 @@ wmKeyConfigPref *BKE_keyconfig_pref_ensure(UserDef *userdef, const char *kc_idna } if (kpt->prop == NULL) { IDPropertyTemplate val = {0}; - kpt->prop = IDP_New(IDP_GROUP, &val, kc_idname); /* name is unimportant */ + kpt->prop = IDP_New(IDP_GROUP, &val, kc_idname); /* name is unimportant. */ } return kpt; } diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c index a8126cb5538..a3133b58a0a 100644 --- a/source/blender/blenkernel/intern/lattice_deform.c +++ b/source/blender/blenkernel/intern/lattice_deform.c @@ -93,18 +93,18 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob /* for example with a particle system: (ob == NULL) */ if (ob == NULL) { - /* in deformspace, calc matrix */ + /* In deform-space, calc matrix. */ invert_m4_m4(latmat, oblatt->obmat); /* back: put in deform array */ invert_m4_m4(imat, latmat); } else { - /* in deformspace, calc matrix */ + /* In deform-space, calc matrix. */ invert_m4_m4(imat, oblatt->obmat); mul_m4_m4m4(latmat, imat, ob->obmat); - /* back: put in deform array */ + /* back: put in deform array. */ invert_m4_m4(imat, latmat); } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index fb9c38f51b7..1edf83b6685 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -819,7 +819,7 @@ static void layer_collection_sync(ViewLayer *view_layer, } /* We separate restrict viewport and visible view layer because a layer collection can be - * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted).*/ + * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted). */ if (child_restrict & COLLECTION_RESTRICT_VIEWPORT) { lc->runtime_flag |= LAYER_COLLECTION_RESTRICT_VIEWPORT; } @@ -1827,7 +1827,7 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter)) /** \} */ -/* Evaluation */ +/* Evaluation. */ /* Applies object's restrict flags on top of flags coming from the collection * and stores those in base->flag. BASE_VISIBLE_DEPSGRAPH ignores viewport flags visibility diff --git a/source/blender/blenkernel/intern/lib_id_eval.c b/source/blender/blenkernel/intern/lib_id_eval.c new file mode 100644 index 00000000000..140fe403ac3 --- /dev/null +++ b/source/blender/blenkernel/intern/lib_id_eval.c @@ -0,0 +1,48 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup bke + * + * Contains management of ID's and libraries + * allocate and free of all library data + */ + +#include "DNA_ID.h" +#include "DNA_mesh_types.h" + +#include "BLI_utildefines.h" + +#include "BKE_lib_id.h" +#include "BKE_mesh.h" + +/** + * Copy relatives parameters, from `id` to `id_cow`. + * Use handle the #ID_RECALC_PARAMETERS tag. + * \note Keep in sync with #ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW. + */ +void BKE_id_eval_properties_copy(ID *id_cow, ID *id) +{ + const ID_Type id_type = GS(id->name); + BLI_assert((id_cow->tag & LIB_TAG_COPIED_ON_WRITE) && !(id->tag & LIB_TAG_COPIED_ON_WRITE)); + BLI_assert(ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type)); + if (id_type == ID_ME) { + BKE_mesh_copy_parameters((Mesh *)id_cow, (const Mesh *)id); + } + else { + BLI_assert_unreachable(); + } +} diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 270d7ca358a..9a45f484581 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -471,11 +471,14 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, typedef struct LibOverrideGroupTagData { Main *bmain; + Scene *scene; ID *id_root; uint tag; uint missing_tag; /* Whether we are looping on override data, or their references (linked) one. */ bool is_override; + /* Whether we are creating new override, or resyncing existing one. */ + bool is_resync; } LibOverrideGroupTagData; /* Tag all IDs in dependency relationships within an override hierarchy/group. @@ -596,7 +599,9 @@ static void lib_override_linked_group_tag_recursive(LibOverrideGroupTagData *dat static void lib_override_linked_group_tag(LibOverrideGroupTagData *data) { Main *bmain = data->bmain; + Scene *scene = data->scene; ID *id_root = data->id_root; + const bool is_resync = data->is_resync; BLI_assert(!data->is_override); if ((id_root->tag & LIB_TAG_MISSING)) { @@ -621,6 +626,43 @@ static void lib_override_linked_group_tag(LibOverrideGroupTagData *data) } } } + + /* For each object tagged for override, ensure we get at least one local or liboverride + * collection to host it. Avoids getting a bunch of random object in the scene's master + * collection when all objects' dependencies are not properly 'packed' into a single root + * collection. */ + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ID_IS_LINKED(ob) && (ob->id.tag & data->tag) != 0) { + Collection *instantiating_collection = NULL; + Collection *instantiating_collection_override_candidate = NULL; + /* Loop over all collections instantiating the object, if we already have a 'locale' one we + * have nothing to do, otherwise try to find a 'linked' one that we can override too. */ + while ((instantiating_collection = BKE_collection_object_find( + bmain, scene, instantiating_collection, ob)) != NULL) { + /* In (recursive) resync case, if a collection of a 'parent' lib instantiates the linked + * object, it is also fine. */ + if (!ID_IS_LINKED(instantiating_collection) || + (is_resync && ID_IS_LINKED(id_root) && + instantiating_collection->id.lib->temp_index < id_root->lib->temp_index)) { + break; + } + else if (ID_IS_LINKED(instantiating_collection) && + (!is_resync || instantiating_collection->id.lib == id_root->lib)) { + instantiating_collection_override_candidate = instantiating_collection; + } + } + + if (instantiating_collection == NULL && + instantiating_collection_override_candidate != NULL) { + if ((instantiating_collection_override_candidate->id.tag & LIB_TAG_MISSING)) { + instantiating_collection_override_candidate->id.tag |= data->missing_tag; + } + else { + instantiating_collection_override_candidate->id.tag |= data->tag; + } + } + } + } } } @@ -699,14 +741,16 @@ static void lib_override_overrides_group_tag(LibOverrideGroupTagData *data) lib_override_overrides_group_tag_recursive(data); } -static bool lib_override_library_create_do(Main *bmain, ID *id_root) +static bool lib_override_library_create_do(Main *bmain, Scene *scene, ID *id_root) { BKE_main_relations_create(bmain, 0); LibOverrideGroupTagData data = {.bmain = bmain, + .scene = scene, .id_root = id_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, - .is_override = false}; + .is_override = false, + .is_resync = false}; lib_override_linked_group_tag(&data); BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false); @@ -867,7 +911,7 @@ bool BKE_lib_override_library_create(Main *bmain, *r_id_root_override = NULL; } - const bool success = lib_override_library_create_do(bmain, id_root); + const bool success = lib_override_library_create_do(bmain, scene, id_root); if (!success) { return success; @@ -971,10 +1015,12 @@ bool BKE_lib_override_library_resync(Main *bmain, BKE_main_relations_create(bmain, 0); LibOverrideGroupTagData data = {.bmain = bmain, + .scene = scene, .id_root = id_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, - .is_override = true}; + .is_override = true, + .is_resync = true}; lib_override_overrides_group_tag(&data); BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false); @@ -1468,10 +1514,12 @@ static void lib_override_library_main_resync_on_library_indirect_level( } LibOverrideGroupTagData data = {.bmain = bmain, + .scene = scene, .id_root = id->override_library->reference, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, - .is_override = false}; + .is_override = false, + .is_resync = true}; lib_override_linked_group_tag(&data); BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false); lib_override_hierarchy_dependencies_recursive_tag(&data); @@ -1710,10 +1758,12 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root) /* Tag all library overrides in the chains of dependencies from the given root one. */ BKE_main_relations_create(bmain, 0); LibOverrideGroupTagData data = {.bmain = bmain, + .scene = NULL, .id_root = id_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, - .is_override = true}; + .is_override = true, + .is_resync = false}; lib_override_overrides_group_tag(&data); BKE_main_relations_free(bmain); diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index b748061ef8a..9d2552777bf 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -83,7 +83,7 @@ bool BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int ID *old_id = *id_pp; /* Update the callback flags with the ones defined (or forbidden) in `data` by the generic - * caller code. */ + * caller code. */ cb_flag = ((cb_flag | data->cb_flag) & ~data->cb_flag_clear); /* Update the callback flags with some extra information regarding overrides: all 'loopback', diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a3f122115d8..371af2a95ed 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1923,7 +1923,7 @@ static void interp_weights_uv_v2_apply(const float uv[2], r_pt[1] += dvec[0] * uv[1]; } -/* when a new points added - resize all shapekey array */ +/* When a new points added - resize all shape-key array. */ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, bool do_init, diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 6bef11dea76..f5d898e801b 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -158,7 +158,7 @@ static void metaball_blend_read_data(BlendDataReader *reader, ID *id) mb->editelems = NULL; /* Must always be cleared (meta's don't have their own edit-data). */ mb->needs_flush_to_id = 0; - /* mb->edit_elems.first= mb->edit_elems.last= NULL;*/ + // mb->edit_elems.first = mb->edit_elems.last = NULL; mb->lastelem = NULL; mb->batch_cache = NULL; } diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index bb46c7b16c0..413cefd2271 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -272,20 +272,20 @@ static void build_bvh_spatial(PROCESS *process, * any and all purposes, provided that this notice appears in all copies. */ -#define L 0 /* left direction: -x, -i */ -#define R 1 /* right direction: +x, +i */ -#define B 2 /* bottom direction: -y, -j */ -#define T 3 /* top direction: +y, +j */ -#define N 4 /* near direction: -z, -k */ -#define F 5 /* far direction: +z, +k */ -#define LBN 0 /* left bottom near corner */ -#define LBF 1 /* left bottom far corner */ -#define LTN 2 /* left top near corner */ -#define LTF 3 /* left top far corner */ -#define RBN 4 /* right bottom near corner */ -#define RBF 5 /* right bottom far corner */ -#define RTN 6 /* right top near corner */ -#define RTF 7 /* right top far corner */ +#define L 0 /* Left direction: -x, -i. */ +#define R 1 /* Right direction: +x, +i. */ +#define B 2 /* Bottom direction: -y, -j. */ +#define T 3 /* Top direction: +y, +j. */ +#define N 4 /* Near direction: -z, -k. */ +#define F 5 /* Far direction: +z, +k. */ +#define LBN 0 /* Left bottom near corner. */ +#define LBF 1 /* Left bottom far corner. */ +#define LTN 2 /* Left top near corner. */ +#define LTF 3 /* Left top far corner. */ +#define RBN 4 /* Right bottom near corner. */ +#define RBF 5 /* Right bottom far corner. */ +#define RTN 6 /* Right top near corner. */ +#define RTF 7 /* Right top far corner. */ /** * the LBN corner of cube (i, j, k), corresponds with location @@ -293,7 +293,8 @@ static void build_bvh_spatial(PROCESS *process, */ #define HASHBIT (5) -#define HASHSIZE (size_t)(1 << (3 * HASHBIT)) /*! < hash table size (32768) */ +/** Hash table size (32768). */ +#define HASHSIZE (size_t)(1 << (3 * HASHBIT)) #define HASH(i, j, k) ((((((i)&31) << 5) | ((j)&31)) << 5) | ((k)&31)) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 08d3236f3a9..b518f35fac7 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -413,8 +413,7 @@ static const char *cmpcode_to_str(int code) } } -/* thresh is threshold for comparing vertices, uvs, vertex colors, - * weights, etc.*/ +/** Thresh is threshold for comparing vertices, UV's, vertex colors, weights, etc. */ static int customdata_compare( CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, const float thresh) { @@ -479,11 +478,11 @@ static int customdata_compare( if (len_squared_v3v3(v1->co, v2->co) > thresh_sq) { return MESHCMP_VERTCOMISMATCH; } - /* I don't care about normals, let's just do coordinates */ + /* I don't care about normals, let's just do coordinates. */ } } - /*we're order-agnostic for edges here*/ + /* We're order-agnostic for edges here. */ if (l1->type == CD_MEDGE) { MEdge *e1 = l1->data; MEdge *e2 = l2->data; @@ -748,12 +747,14 @@ bool BKE_mesh_clear_facemap_customdata(struct Mesh *me) return changed; } -/* this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or +/** + * This ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or * mloopcol and mcol) have the same relative active/render/clone/mask indices. * - * note that for undo mesh data we want to skip 'ensure_tess_cd' call since + * NOTE(campbell): that for undo mesh data we want to skip 'ensure_tess_cd' call since * we don't want to store memory for tessface when its only used for older - * versions of the mesh. - campbell*/ + * Versions of the mesh. + */ static void mesh_update_linked_customdata(Mesh *me, const bool do_ensure_tess_cd) { if (do_ensure_tess_cd) { @@ -811,7 +812,7 @@ static void mesh_clear_geometry(Mesh *mesh) /* Note that materials and shape keys are not freed here. This is intentional, as freeing * shape keys requires tagging the depsgraph for updated relations, which is expensive. - * Material slots should be kept in sync with the object.*/ + * Material slots should be kept in sync with the object. */ mesh->totvert = 0; mesh->totedge = 0; @@ -2087,6 +2088,14 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals) SplitFaceNewVert *new_verts = NULL; SplitFaceNewEdge *new_edges = NULL; + /* Ensure we own the layers, we need to do this before split_faces_prepare_new_verts as it will + * directly assign new indices to existing edges and loops. */ + CustomData_duplicate_referenced_layers(&mesh->vdata, mesh->totvert); + CustomData_duplicate_referenced_layers(&mesh->edata, mesh->totedge); + CustomData_duplicate_referenced_layers(&mesh->ldata, mesh->totloop); + /* Update pointers in case we duplicated referenced layers. */ + BKE_mesh_update_customdata_pointers(mesh, false); + /* Detect loop normal spaces (a.k.a. smooth fans) that will need a new vert. */ const int num_new_verts = split_faces_prepare_new_verts( mesh, &lnors_spacearr, &new_verts, memarena); diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index cfb1c192afe..c162458ffb9 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -304,7 +304,7 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes, r_info->mesh_edge_offset[mi] = e; r_info->mesh_poly_offset[mi] = f; /* Get matrix that transforms a coordinate in objects[mi]'s local space - * to the target space space.*/ + * to the target space space. */ const float4x4 objn_mat = (obmats[mi] == nullptr) ? float4x4::identity() : clean_obmat(*obmats[mi]); r_info->to_target_transform[mi] = inv_target_mat * objn_mat; @@ -776,7 +776,7 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim) /** * Do a mesh boolean operation directly on meshes (without going back and forth to BMesh). - * \param meshes: An array of of Mesh pointers. + * \param meshes: An array of Mesh pointers. * \param obmats: An array of pointers to the obmat matrices that transform local * coordinates to global ones. It is allowed for the pointers to be null, meaning the * transformation is the identity. diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 2260ffc668a..961c10ea5d3 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -3280,8 +3280,8 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, i = totpoly; for (mp = mpoly; i--; mp++) { - /* assume if its selected its not hidden and none of its verts/edges are hidden - * (a common assumption)*/ + /* Assume if its selected its not hidden and none of its verts/edges are hidden + * (a common assumption). */ if (mp->flag & ME_FACE_SEL) { const MLoop *ml; int j; diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index d4119f48193..c469a65449d 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -535,7 +535,7 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, * * This has the advantage that it can operate on any data-types. * - * \param totsource: The total number of elements the that \a final_origindex points to. + * \param totsource: The total number of elements that \a final_origindex points to. * \param totfinal: The size of \a final_origindex * \param final_origindex: The size of the final array. * diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c index fb73152cb8e..1e51ee73c7c 100644 --- a/source/blender/blenkernel/intern/mesh_merge.c +++ b/source/blender/blenkernel/intern/mesh_merge.c @@ -109,7 +109,7 @@ static int cddm_poly_compare(MLoop *mloop_array, i_loop_source++; if (i_loop_source == mpoly_source->totloop) { - /* End of loops for source, must match end of loop for target. */ + /* End of loops for source, must match end of loop for target. */ if (i_loop_target_offset == mpoly_target->totloop - 1) { compare_completed = true; same_loops = true; @@ -597,7 +597,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, mp_new->loopstart = STACK_SIZE(mloop) - c; STACK_PUSH(oldp, i); - } /* end of the loop that tests polys */ + } /* End of the loop that tests polys. */ if (poly_gset) { // printf("hash quality %.6f\n", BLI_gset_calc_quality(poly_gset)); @@ -606,11 +606,11 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, MEM_freeN(poly_keys); } - /*create new cddm*/ + /* Create new cddm. */ result = BKE_mesh_new_nomain_from_template( mesh, STACK_SIZE(mvert), STACK_SIZE(medge), 0, STACK_SIZE(mloop), STACK_SIZE(mpoly)); - /*update edge indices and copy customdata*/ + /* Update edge indices and copy customdata. */ med = medge; for (i = 0; i < result->totedge; i++, med++) { BLI_assert(newv[med->v1] != -1); @@ -624,7 +624,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, CustomData_copy_data(&mesh->edata, &result->edata, olde[i], i, 1); } - /*update loop indices and copy customdata*/ + /* Update loop indices and copy customdata. */ ml = mloop; for (i = 0; i < result->totloop; i++, ml++) { /* Edge remapping has already be done in main loop handling part above. */ @@ -634,19 +634,19 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, CustomData_copy_data(&mesh->ldata, &result->ldata, oldl[i], i, 1); } - /*copy vertex customdata*/ + /* Copy vertex customdata. */ mv = mvert; for (i = 0; i < result->totvert; i++, mv++) { CustomData_copy_data(&mesh->vdata, &result->vdata, oldv[i], i, 1); } - /*copy poly customdata*/ + /* Copy poly customdata. */ mp = mpoly; for (i = 0; i < result->totpoly; i++, mp++) { CustomData_copy_data(&mesh->pdata, &result->pdata, oldp[i], i, 1); } - /*copy over data. CustomData_add_layer can do this, need to look it up.*/ + /* Copy over data. #CustomData_add_layer can do this, need to look it up. */ memcpy(result->mvert, mvert, sizeof(MVert) * STACK_SIZE(mvert)); memcpy(result->medge, medge, sizeof(MEdge) * STACK_SIZE(medge)); memcpy(result->mloop, mloop, sizeof(MLoop) * STACK_SIZE(mloop)); diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index 3d30c218fba..9aeaa1ada52 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -70,9 +70,9 @@ Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mm /* Define bisecting plane (aka mirror plane). */ float plane[4]; if (!do_bisect_flip_axis) { - /* That reversed condition is a tad weird, but for some reason that's how you keep - * the part of the mesh which is on the non-mirrored side when flip option is disabled, - * think that that is the expected behavior. */ + /* That reversed condition is a little weird, but for some reason that's how you keep + * the part of the mesh which is on the non-mirrored side when flip option is disabled. + * I think this is the expected behavior. */ negate_v3(plane_no); } plane_from_point_normal_v3(plane, plane_co, plane_no); diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index df84cf6607f..bfdbf844a26 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -1105,7 +1105,7 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_ &changed); if (changed) { - DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES); return true; } @@ -1183,7 +1183,7 @@ bool BKE_mesh_validate_material_indices(Mesh *me) } if (!is_valid) { - DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES); return true; } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 0f2f56f4f2b..3a7910d1a9f 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1320,7 +1320,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf( clip->lastframe = framenr; real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]); - /* postprocess frame and put to cache if needed*/ + /* Post-process frame and put to cache if needed. */ if (need_postprocess) { ImBuf *tmpibuf = ibuf; ibuf = postprocess_frame(clip, user, tmpibuf, flag, postprocess_flag); @@ -2128,9 +2128,9 @@ GPUTexture *BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser) void BKE_movieclip_free_gputexture(struct MovieClip *clip) { - /* number of gpu textures to keep around as cache + /* Number of gpu textures to keep around as cache. * We don't want to keep too many GPU textures for - * movie clips around, as they can be large.*/ + * movie clips around, as they can be large. */ const int MOVIECLIP_NUM_GPUTEXTURES = 1; while (BLI_listbase_count(&clip->runtime.gputextures) > MOVIECLIP_NUM_GPUTEXTURES) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 45ac20ef154..54f0da30a2b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -994,7 +994,7 @@ static void multiresModifier_disp_run( } } - /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/ + // numGrids = dm->getNumGrids(dm); /* UNUSED */ gridSize = dm->getGridSize(dm); gridData = dm->getGridData(dm); gridOffset = dm->getGridOffset(dm); @@ -1285,7 +1285,7 @@ DerivedMesh *multires_make_derived_from_derived( multires_set_tot_mdisps(me, mmd->totlvl); multiresModifier_ensure_external_read(me, mmd); - /*run displacement*/ + /* Run displacement. */ multiresModifier_disp_run(result, ob->data, dm, APPLY_DISPLACEMENTS, subGridData, mmd->totlvl); /* copy hidden elements for this level */ @@ -1514,7 +1514,7 @@ void multires_topology_changed(Mesh *me) * * Since the multires data files only contain displacement vectors without knowledge about * subdivision level some extra work is needed. Namely make is to all displacement grids have - * proper level and number of displacement vectors set. */ + * proper level and number of displacement vectors set. */ void multires_ensure_external_read(struct Mesh *mesh, int top_level) { if (!CustomData_external_test(&mesh->ldata, CD_MDISPS)) { diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c index 04ad78ec0de..bd52d70b223 100644 --- a/source/blender/blenkernel/intern/multires_reshape.c +++ b/source/blender/blenkernel/intern/multires_reshape.c @@ -235,7 +235,7 @@ void multiresModifier_subdivide_to_level(struct Object *object, /* Free original grids which makes it so smoothing with details thinks all the details were * added against base mesh's limit surface. This is similar behavior to as if we've done all - * displacement in sculpt mode at the old top level and then propagated to the new top level.*/ + * displacement in sculpt mode at the old top level and then propagated to the new top level. */ multires_reshape_free_original_grids(&reshape_context); if (ELEM(mode, MULTIRES_SUBDIVIDE_LINEAR, MULTIRES_SUBDIVIDE_SIMPLE)) { diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index f10aae18142..aed8c3122a2 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -55,7 +55,7 @@ /* Surface refers to a simplified and lower-memory footprint representation of the limit surface. * * Used to store pre-calculated information which is expensive or impossible to evaluate when - * traversing the final limit surface. */ + * traversing the final limit surface. */ typedef struct SurfacePoint { float P[3]; @@ -1027,7 +1027,7 @@ static void converter_init(const MultiresReshapeSmoothContext *reshape_smooth_co converter->user_data = (void *)reshape_smooth_context; } -/* Create subdiv descriptor created for topology at a reshape level, */ +/* Create subdiv descriptor created for topology at a reshape level. */ static void reshape_subdiv_create(MultiresReshapeSmoothContext *reshape_smooth_context) { const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context; @@ -1050,7 +1050,7 @@ typedef void(ReshapeSubdivCoarsePositionCb)( const Vertex *vertex, float r_P[3]); -/* Refine subdivision surface topology at a reshape level for new coarse vertices positions. */ +/* Refine subdivision surface topology at a reshape level for new coarse vertices positions. */ static void reshape_subdiv_refine(const MultiresReshapeSmoothContext *reshape_smooth_context, ReshapeSubdivCoarsePositionCb coarse_position_cb) { diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c index 02b9bb852d6..4210f26a694 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.c +++ b/source/blender/blenkernel/intern/multires_unsubdivide.c @@ -312,7 +312,7 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i /* Also try from the different 4 vertices of a quad in the current * disconnected element ID. If a solution exists the search should return a valid solution from - * one of these vertices.*/ + * one of these vertices. */ BMFace *f, *init_face = NULL; BMVert *v; BMIter iter_a, iter_b; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 92e21183acb..bf18765aa94 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1289,7 +1289,7 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip) return; } - /* loop over tracks, deactivating*/ + /* Loop over tracks, deactivating. */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (nls = nlt->strips.first; nls; nls = nls->next) { if (nls != strip) { @@ -1560,7 +1560,7 @@ bool BKE_nlatracks_have_animated_strips(ListBase *tracks) return false; } -/* Validate the NLA-Strips 'control' F-Curves based on the flags set*/ +/* Validate the NLA-Strips 'control' F-Curves based on the flags set. */ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) { FCurve *fcu; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 35470010aa8..f3a2ed737ca 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -907,7 +907,7 @@ void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this.*/ + * of library blocks that implement this. */ IDP_BlendReadLib(reader, node->prop); BLO_read_id_address(reader, lib, &node->id); @@ -2400,7 +2400,7 @@ static void nodeUnMuteLink(bNodeLink *link) link->tosock->flag |= SOCK_IN_USE; } -/* Upstream muting. Always happens when unmuting but checks when muting. O(n^2) algorithm.*/ +/* Upstream muting. Always happens when unmuting but checks when muting. O(n^2) algorithm. */ static void nodeMuteRerouteInputLinks(bNodeTree *ntree, bNode *node, const bool mute) { if (node->type != NODE_REROUTE) { @@ -2423,7 +2423,7 @@ static void nodeMuteRerouteInputLinks(bNodeTree *ntree, bNode *node, const bool } } -/* Downstream muting propagates when reaching reroute nodes. O(n^2) algorithm.*/ +/* Downstream muting propagates when reaching reroute nodes. O(n^2) algorithm. */ static void nodeMuteRerouteOutputLinks(bNodeTree *ntree, bNode *node, const bool mute) { if (node->type != NODE_REROUTE) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8cfd75b015c..a5e16172e75 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2759,7 +2759,7 @@ Object *BKE_object_duplicate(Main *bmain, } if (!is_subprocess) { - /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/ + /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */ BKE_libblock_relink_to_newid(&obn->id); #ifndef NDEBUG @@ -2854,7 +2854,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target) else { /* only on local objects because this causes indirect links * 'a -> b -> c', blend to point directly to a.blend - * when a.blend has a proxy that's linked into c.blend */ + * when a.blend has a proxy that's linked into `c.blend`. */ if (!ID_IS_LINKED(ob)) { id_lib_extern((ID *)dtar->id); } @@ -3212,12 +3212,11 @@ void BKE_object_to_mat3(Object *ob, float r_mat[3][3]) /* no parent */ { float smat[3][3]; float rmat[3][3]; - /*float q1[4];*/ - /* scale */ + /* Scale. */ BKE_object_scale_to_mat3(ob, smat); - /* rot */ + /* Rotation. */ BKE_object_rot_to_mat3(ob, rmat, true); mul_m3_m3m3(r_mat, rmat, smat); } @@ -4476,7 +4475,7 @@ Mesh *BKE_object_get_pre_modified_mesh(const Object *object) } /** - * Get a mesh which corresponds to very very original mesh from #Main. + * Get a mesh which corresponds to the very original mesh from #Main. * - For original objects it will be object->data. * - For evaluated objects it will be same mesh as corresponding original * object uses as data. @@ -5304,7 +5303,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) tot = 0; tree = BLI_kdtree_3d_new(totvert); - /* we don't how how many verts from the DM we can use */ + /* We don't how many verts from the DM we can use. */ for (i = 0; i < totvert; i++) { if (index[i] != ORIGINDEX_NONE) { float co[3]; diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 9d53dad8d03..2e7152302c7 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -248,7 +248,7 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u, float if (oc->_do_normals) { ocr->normal[0] = BILERP(oc->_N_x); - ocr->normal[1] = oc->_N_y /*BILERP(oc->_N_y) (MEM01)*/; + ocr->normal[1] = oc->_N_y /* BILERP(oc->_N_y) (MEM01) */; ocr->normal[2] = BILERP(oc->_N_z); } @@ -347,7 +347,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u } if (oc->_do_normals) { ocr->normal[0] = INTERP(oc->_N_x); - ocr->normal[1] = oc->_N_y /*INTERP(oc->_N_y) (MEM01)*/; + ocr->normal[1] = oc->_N_y /* INTERP(oc->_N_y) (MEM01) */; ocr->normal[2] = INTERP(oc->_N_z); } if (oc->_do_chop) { @@ -1052,7 +1052,7 @@ void BKE_ocean_free_data(struct Ocean *oc) fftw_destroy_plan(oc->_N_x_plan); fftw_destroy_plan(oc->_N_z_plan); MEM_freeN(oc->_N_x); - /*fftwf_free(oc->_N_y); (MEM01)*/ + /* fftwf_free(oc->_N_y); (MEM01) */ MEM_freeN(oc->_N_z); } @@ -1437,9 +1437,9 @@ void BKE_ocean_bake(struct Ocean *o, rgb_to_rgba_unit_alpha(&ibuf_disp->rect_float[4 * (res_x * y + x)], ocr.disp); if (o->_do_jacobian) { - /* TODO, cleanup unused code - campbell */ + /* TODO: cleanup unused code - campbell */ - float /*r, */ /* UNUSED */ pr = 0.0f, foam_result; + float /* r, */ /* UNUSED */ pr = 0.0f, foam_result; float neg_disp, neg_eplus; ocr.foam = BKE_ocean_jminus_to_foam(ocr.Jminus, och->foam_coverage); @@ -1449,9 +1449,9 @@ void BKE_ocean_bake(struct Ocean *o, pr = prev_foam[res_x * y + x]; } - /* r = BLI_rng_get_float(rng); */ /* UNUSED */ /* randomly reduce foam */ + // r = BLI_rng_get_float(rng); /* UNUSED */ /* randomly reduce foam */ - /* pr = pr * och->foam_fade; */ /* overall fade */ + // pr = pr * och->foam_fade; /* overall fade */ /* Remember ocean coord sys is Y up! * break up the foam where height (Y) is low (wave valley), @@ -1475,7 +1475,7 @@ void BKE_ocean_bake(struct Ocean *o, prev_foam[res_x * y + x] = foam_result; - /*foam_result = min_ff(foam_result, 1.0f); */ + // foam_result = min_ff(foam_result, 1.0f); value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4 * (res_x * y + x)], foam_result); diff --git a/source/blender/blenkernel/intern/ocean_intern.h b/source/blender/blenkernel/intern/ocean_intern.h index b55b211fa33..4ebd03789af 100644 --- a/source/blender/blenkernel/intern/ocean_intern.h +++ b/source/blender/blenkernel/intern/ocean_intern.h @@ -99,7 +99,7 @@ typedef struct Ocean { double *_N_x; /* init w sim w via plan? */ /* all member of this array has same values, * so convert this array to a float to reduce memory usage (MEM01). */ - /*float * _N_y; */ + // float * _N_y; double _N_y; /* sim w ********* can be rearranged? */ double *_N_z; /* init w sim w via plan? */ double *_disp_x; /* init w sim w via plan? */ diff --git a/source/blender/blenkernel/intern/ocean_spectrum.c b/source/blender/blenkernel/intern/ocean_spectrum.c index 1f7cc56f1a9..7ed70234baf 100644 --- a/source/blender/blenkernel/intern/ocean_spectrum.c +++ b/source/blender/blenkernel/intern/ocean_spectrum.c @@ -122,7 +122,7 @@ static float jonswap(const Ocean *oc, const float k2) float val = alpha_beta_spectrum(m_alpha, beta, GRAVITY, omega, m_peakomega); - /* Peak sharpening */ + /* Peak sharpening. */ val *= peak_sharpen(m_omega, m_peakomega, m_gamma); return val; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 3494630e1fa..a7c6dc2deb9 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1810,7 +1810,7 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object) CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, orig_me->totvert); BKE_mesh_update_customdata_pointers(orig_me, true); - DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES); } /** \warning Expects a fully evaluated depsgraph. */ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 021121034f1..d386967bf8b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2462,7 +2462,7 @@ int do_guides(Depsgraph *depsgraph, (int)(data->strength * guidetime * 100.0f), 100)); } - else { /* curve size*/ + else { /* Curve size. */ if (cu->flag & CU_PATH_RADIUS) { mul_v3_fl(vec_to_point, radius); } diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index 6e0965650d3..2231731287d 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -785,7 +785,7 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx, return; } if (part->twist == 0.0f) { - /* No twist along the strand. */ + /* No twist along the strand. */ return; } /* Dependent on whether it's threaded update or not, curve comes diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index 13f0cb28428..1fd99bb2cbd 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -142,7 +142,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys) size[(axis + 1) % 3] = (int)ceil(delta[(axis + 1) % 3] / d); size[(axis + 2) % 3] = (int)ceil(delta[(axis + 2) % 3] / d); - /* float errors grrr.. */ + /* float errors grrr. */ size[(axis + 1) % 3] = MIN2(size[(axis + 1) % 3], res); size[(axis + 2) % 3] = MIN2(size[(axis + 2) % 3], res); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index d236dbbf101..c35f703b072 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -250,7 +250,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) if (psys->particles) { totsaved = MIN2(psys->totpart, totpart); - /*save old pars*/ + /* Save old pars. */ if (totsaved) { memcpy(newpars, psys->particles, totsaved * sizeof(ParticleData)); @@ -607,8 +607,8 @@ void init_particle(ParticleSimulationData *sim, ParticleData *pa) pa->time = part->sta + (part->end - part->sta) * birth_time; pa->hair_index = 0; - /* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */ - /* usage other than straight after distribute has to handle this index by itself - jahka*/ + /* We can't reset to -1 anymore since we've figured out correct index in #distribute_particles + * usage other than straight after distribute has to handle this index by itself - jahka. */ // pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */ } @@ -840,7 +840,7 @@ void psys_get_birth_coords( copy_v3_v3(state->co, loc); - /* boids don't get any initial velocity */ + /* boids don't get any initial velocity. */ zero_v3(state->vel); /* boids store direction in ave */ @@ -1473,7 +1473,7 @@ static void integrate_particle( force_func(forcedata, states + i, force, impulse); - /* force to acceleration*/ + /* Force to acceleration. */ mul_v3_v3fl(acceleration, force, 1.0f / pa_mass); if (external_acceleration) { @@ -1920,7 +1920,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa } } - /* Artificial buoyancy force in negative gravity direction */ + /* Artificial buoyancy force in negative gravity direction. */ if (fluid->buoyancy > 0.0f && gravity) { madd_v3_v3fl(force, gravity, fluid->buoyancy * (density - rest_density)); } @@ -2095,7 +2095,7 @@ static void sphclassical_force_cb(void *sphdata_v, } } - /* Artificial buoyancy force in negative gravity direction */ + /* Artificial buoyancy force in negative gravity direction. */ if (fluid->buoyancy > 0.0f && gravity) { madd_v3_v3fl(force, gravity, fluid->buoyancy * (pa->sphdensity - rest_density)); } @@ -2226,7 +2226,7 @@ static void sph_integrate(ParticleSimulationData *sim, sphdata->pass = 0; // sphdata.element_size and sphdata.flow are set in the callback. - /* restore previous state and treat gravity & effectors as external acceleration*/ + /* Restore previous state and treat gravity & effectors as external acceleration. */ sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel); mul_v3_fl(effector_acceleration, 1.0f / dtime); @@ -3001,7 +3001,7 @@ static int collision_response(ParticleSimulationData *sim, /* get back to global coordinates */ add_v3_v3(v1_tan, vc_tan); - /* convert to angular velocity*/ + /* Convert to angular velocity. */ cross_v3_v3v3(ave, vr_tan, pce->nor); mul_v3_fl(ave, 1.0f / MAX2(pa->size, 0.001f)); @@ -3369,7 +3369,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim, /* XXX placeholder for more flexible future hair settings */ hair_radius = part->size; - /* make vgroup for pin roots etc.. */ + /* Make vgroup for pin roots etc. */ hair_index = 1; LOOP_PARTICLES { @@ -3927,7 +3927,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) pa->alive = PARS_DYING; } else if (birthtime <= cfra && birthtime >= psys->cfra) { - /* particle is born some time between this and last step*/ + /* Particle is born some time between this and last step. */ reset_particle(sim, pa, dfra * timestep, cfra); pa->alive = PARS_ALIVE; pa->state.time = cfra - birthtime; @@ -3936,7 +3936,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* nothing to be done when particle is dead */ } - /* only reset unborn particles if they're shown or if the particle is born soon*/ + /* Only reset unborn particles if they're shown or if the particle is born soon. */ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) { reset_particle(sim, pa, dtime, cfra); @@ -4104,7 +4104,7 @@ static void update_children(ParticleSimulationData *sim, const bool use_render_p psys_free_children(sim->psys); } } -/* updates cached particles' alive & other flags etc..*/ +/* Updates cached particles' alive & other flags etc. */ static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_render_params) { ParticleSystem *psys = sim->psys; diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 09e4ad93baa..c2483b265a5 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -180,7 +180,7 @@ static BMVert *bm_vert_hash_lookup_chain(GHash *deleted_verts, BMVert *v) while (true) { BMVert **v_next_p = (BMVert **)BLI_ghash_lookup_p(deleted_verts, v); if (v_next_p == NULL) { - /* not remapped*/ + /* Not remapped. */ return v; } if (*v_next_p == NULL) { @@ -2316,7 +2316,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh) vert_count++; } - /* if totvert differs from number of verts inside the hash. hash-totvert is checked above */ + /* If totvert differs from number of verts inside the hash. hash-totvert is checked above. */ BLI_assert(vert_count == pbvh->bm->totvert); # endif diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index be206f8a642..a05eb6962ce 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2632,7 +2632,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) } #endif - /*if (!G.relbase_valid) return; */ /* save blend file before using pointcache */ + // if (!G.relbase_valid) return; /* Save blend file before using pointcache. */ /* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */ switch (mode) { @@ -2659,8 +2659,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) ptcache_filename_ext_append(pid, ext, 0, false, 0); while ((de = readdir(dir)) != NULL) { - if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ + if (strstr(de->d_name, ext)) { /* Do we have the right extension? */ + if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */ if (mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); @@ -2695,7 +2695,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) PTCacheMem *link = NULL; if (mode == PTCACHE_CLEAR_ALL) { - /*we want startframe if the cache starts before zero*/ + /* We want startframe if the cache starts before zero. */ pid->cache->last_exact = MIN2(pid->cache->startframe, 0); for (; pm; pm = pm->next) { ptcache_mem_clear(pm); @@ -2856,8 +2856,8 @@ void BKE_ptcache_id_time( ptcache_filename_ext_append(pid, ext, 0, false, 0); while ((de = readdir(dir)) != NULL) { - if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ + if (strstr(de->d_name, ext)) { /* Do we have the right extension? */ + if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */ /* read the number of the file */ const int frame = ptcache_frame_from_filename(de->d_name, ext); @@ -3038,7 +3038,7 @@ void BKE_ptcache_remove(void) if (FILENAME_IS_CURRPAR(de->d_name)) { /* do nothing */ } - else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/ + else if (strstr(de->d_name, PTCACHE_EXT)) { /* Do we have the right extension? */ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); BLI_delete(path_full, false, false); } @@ -3050,7 +3050,7 @@ void BKE_ptcache_remove(void) closedir(dir); } else { - rmdir = 0; /* path doesn't exist */ + rmdir = 0; /* Path doesn't exist. */ } if (rmdir) { @@ -3569,8 +3569,8 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name)); while ((de = readdir(dir)) != NULL) { - if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (STREQLEN(old_filename, de->d_name, len)) { /* do we have the right prefix */ + if (strstr(de->d_name, ext)) { /* Do we have the right extension? */ + if (STREQLEN(old_filename, de->d_name, len)) { /* Do we have the right prefix. */ /* read the number of the file */ const int frame = ptcache_frame_from_filename(de->d_name, ext); @@ -3589,7 +3589,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c void BKE_ptcache_load_external(PTCacheID *pid) { - /*todo*/ + /* TODO: */ PointCache *cache = pid->cache; int len; /* store the length of the string */ int info = 0; @@ -3626,8 +3626,8 @@ void BKE_ptcache_load_external(PTCacheID *pid) } while ((de = readdir(dir)) != NULL) { - if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ + if (strstr(de->d_name, ext)) { /* Do we have the right extension? */ + if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */ /* read the number of the file */ const int frame = ptcache_frame_from_filename(de->d_name, ext); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 21b86aa8148..2d4cce4b953 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -668,7 +668,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) radius = max_fff(size[0], size[1], size[2]) * 0.5f; } - /* calculate volume as appropriate */ + /* Calculate volume as appropriate. */ switch (rbo->shape) { case RB_SHAPE_BOX: volume = size[0] * size[1] * size[2]; @@ -744,10 +744,10 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3]) * (i.e. Object pivot is centralized in boundbox) * - boundbox gives full width */ - /* XXX: all dimensions are auto-determined now... later can add stored settings for this */ + /* XXX: all dimensions are auto-determined now... later can add stored settings for this. */ BKE_object_dimensions_get(ob, size); - /* calculate volume as appropriate */ + /* Calculate volume as appropriate. */ switch (rbo->shape) { case RB_SHAPE_BOX: case RB_SHAPE_SPHERE: diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 41f70db3fba..791116682c8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2013,7 +2013,7 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type) bmain, NULL, sce_copy->master_collection, duplicate_flags, LIB_ID_DUPLICATE_IS_SUBPROCESS); if (!is_subprocess) { - /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/ + /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */ BKE_libblock_relink_to_newid(&sce_copy->id); #ifndef NDEBUG @@ -3379,7 +3379,7 @@ static bool depsgraph_key_compare(const void *key_a_v, const void *key_b_v) { const DepsgraphKey *key_a = key_a_v; const DepsgraphKey *key_b = key_b_v; - /* TODO(sergey): Compare rest of */ + /* TODO(sergey): Compare rest of. */ return !(key_a->view_layer == key_b->view_layer); } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 7a5892baaf6..608317933f5 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -1703,9 +1703,9 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area) BLO_read_list(reader, &sconsole->scrollback); BLO_read_list(reader, &sconsole->history); - /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression, + /* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression, * from left to right. the right-most expression sets the result of the comma - * expression as a whole*/ + * expression as a whole. */ LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) { BLO_read_data_address(reader, &cl->line); if (cl->line) { diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index ae39b200b56..aeb8133974e 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -546,7 +546,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata, } if (calc->vert != NULL && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { - /* calc->vert contains verts from evaluated mesh. */ + /* calc->vert contains verts from evaluated mesh. */ /* These coordinates are deformed by vertexCos only for normal projection * (to get correct normals) for other cases calc->verts contains undeformed coordinates and * vertexCos should be used */ diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index fcc1afbc59b..123843c88db 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -109,11 +109,11 @@ typedef struct ReferenceVert { } ReferenceVert; typedef struct ReferenceState { - float com[3]; /* center of mass*/ - ReferenceVert *ivert; /* list of initial values */ + float com[3]; /* Center of mass. */ + ReferenceVert *ivert; /* List of initial values. */ } ReferenceState; -/*private scratch pad for caching and other data only needed when alive*/ +/* Private scratch pad for caching and other data only needed when alive. */ typedef struct SBScratch { GHash *colliderhash; short needstobuildcollider; @@ -150,11 +150,11 @@ typedef struct SB_thread_context { #define BSF_INTERSECT 1 /* edge intersects collider face */ /* private definitions for bodypoint states */ -#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy */ -#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide */ +#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy. */ +#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide. */ -#define BFF_INTERSECT 1 /* collider edge intrudes face */ -#define BFF_CLOSEVERT 2 /* collider vertex repulses face */ +#define BFF_INTERSECT 1 /* collider edge intrudes face. */ +#define BFF_CLOSEVERT 2 /* collider vertex repulses face. */ /* humm .. this should be calculated from sb parameters and sizes. */ static float SoftHeunTol = 1.0f; @@ -162,9 +162,9 @@ static float SoftHeunTol = 1.0f; /* local prototypes */ static void free_softbody_intern(SoftBody *sb); -/*+++ frame based timing +++*/ +/*+++ frame based timing +++ */ -/*physical unit of force is [kg * m / sec^2]*/ +/* Physical unit of force is `kg * m / sec^2`. */ /** * Since unit of g is [m/sec^2] and F = mass * g we re-scale unit mass of node to 1 gram @@ -207,7 +207,7 @@ static float sb_time_scale(Object *ob) } /*--- frame based timing ---*/ -/* helper functions for everything is animatable jow_go_for2_5 +++++++*/ +/* helper functions for everything is animatable jow_go_for2_5 +++++++ */ /* introducing them here, because i know: steps in properties ( at frame timing ) * will cause unwanted responses of the softbody system (which does inter frame calculations ) * so first 'cure' would be: interpolate linear in time .. @@ -217,7 +217,7 @@ static float sb_time_scale(Object *ob) */ /* animate sb->maxgoal, sb->mingoal */ -static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */ +static float _final_goal(Object *ob, BodyPoint *bp) /* jow_go_for2_5 */ { float f = -1999.99f; if (ob) { @@ -235,7 +235,7 @@ static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */ } } CLOG_ERROR(&LOG, "sb or bp == NULL"); - return f; /*using crude but spot able values some times helps debuggin */ + return f; /* Using crude but spot able values some times helps debugging. */ } static float _final_mass(Object *ob, BodyPoint *bp) @@ -251,7 +251,7 @@ static float _final_mass(Object *ob, BodyPoint *bp) } /* helper functions for everything is animateble jow_go_for2_5 ------*/ -/*+++ collider caching and dicing +++*/ +/* +++ collider caching and dicing +++ */ /* * for each target object/face the axis aligned bounding box (AABB) is stored @@ -311,7 +311,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) /* blow it up with forcefield ranges */ hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft); - /* alloc and copy verts*/ + /* Allocate and copy verts. */ pccd_M->mvert = MEM_dupallocN(cmd->xnew); /* note that xnew coords are already in global space, */ /* determine the ortho BB */ @@ -328,7 +328,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull); pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull); } - /* alloc and copy faces*/ + /* Allocate and copy faces. */ pccd_M->tri = MEM_dupallocN(cmd->tri); /* OBBs for idea1 */ @@ -401,7 +401,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M) MEM_freeN((void *)pccd_M->mprevvert); } pccd_M->mprevvert = pccd_M->mvert; - /* alloc and copy verts*/ + /* Allocate and copy verts. */ pccd_M->mvert = MEM_dupallocN(cmd->xnew); /* note that xnew coords are already in global space, */ /* determine the ortho BB */ @@ -598,7 +598,7 @@ static int count_mesh_quads(Mesh *me) static void add_mesh_quad_diag_springs(Object *ob) { Mesh *me = ob->data; - /*BodyPoint *bp;*/ /*UNUSED*/ + // BodyPoint *bp; /* UNUSED */ int a; if (ob->soft) { @@ -618,7 +618,7 @@ static void add_mesh_quad_diag_springs(Object *ob) /* fill the tail */ a = 0; bs = &ob->soft->bspring[ob->soft->totspring]; - /*bp= ob->soft->bpoint; */ /*UNUSED*/ + // bp = ob->soft->bpoint; /* UNUSED */ for (a = me->totpoly; a > 0; a--, mp++) { if (mp->totloop == 4) { bs->v1 = mloop[mp->loopstart + 0].v; @@ -640,7 +640,7 @@ static void add_mesh_quad_diag_springs(Object *ob) static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *counter, int addsprings) { - /*assume we have a softbody*/ + /* Assume we have a softbody. */ SoftBody *sb = ob->soft; /* is supposed to be there */ BodyPoint *bp, *bpo; BodySpring *bs, *bs2, *bs3 = NULL; @@ -654,7 +654,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count bs3 = ob->soft->bspring + ob->soft->totspring; } for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) { - /*scan for neighborhood*/ + /* Scan for neighborhood. */ bpo = NULL; v0 = (sb->totpoint - a); for (b = bp->nofsprings; b > 0; b--) { @@ -678,7 +678,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count for (c = bpo->nofsprings; c > 0; c--) { bs2 = sb->bspring + bpo->springs[c - 1]; if ((bs2->v1 != notthis) && (bs2->v1 > v0)) { - (*counter)++; /*hit */ + (*counter)++; /* hit */ if (addsprings) { bs3->v1 = v0; bs3->v2 = bs2->v1; @@ -698,7 +698,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count } } } - /*scan for neighborhood done*/ + /* Scan for neighborhood done. */ } } @@ -772,8 +772,8 @@ static void build_bps_springlist(Object *ob) if (((sb->totpoint - a) == bs->v2)) { add_bp_springlist(bp, sb->totspring - b); } - } /*for springs*/ - } /*for bp*/ + } /* For springs. */ + } /* For bp. */ } static void calculate_collision_balls(Object *ob) @@ -825,7 +825,7 @@ static void calculate_collision_balls(Object *ob) else { bp->colball = 0; } - } /*for bp*/ + } /* For bp. */ } /* creates new softbody if didn't exist yet, makes new points and springs arrays */ @@ -905,7 +905,7 @@ static void free_scratch(SoftBody *sb) if (sb->scratch->colliderhash) { BLI_ghash_free(sb->scratch->colliderhash, NULL, - (GHashValFreeFP)ccd_mesh_free); /*this hoepfully will free all caches*/ + (GHashValFreeFP)ccd_mesh_free); /* This hopefully will free all caches. */ sb->scratch->colliderhash = NULL; } if (sb->scratch->bodyface) { @@ -976,7 +976,7 @@ static void free_softbody_intern(SoftBody *sb) * since that would only valid for 'slow' moving collision targets and dito particles */ -/* +++ dependency information functions*/ +/* +++ dependency information functions. */ /** * \note collection overrides scene when not NULL. @@ -990,9 +990,9 @@ static int query_external_colliders(Depsgraph *depsgraph, Collection *collection return (numobjects != 0); } -/* --- dependency information functions*/ +/* --- dependency information functions. */ -/* +++ the aabb "force" section*/ +/* +++ the aabb "force" section. */ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), struct Object *vertexowner, float UNUSED(time)) @@ -1036,7 +1036,7 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), deflected = 2; } else { - /*aye that should be cached*/ + /* Aye that should be cached. */ CLOG_ERROR(&LOG, "missing cache error"); BLI_ghashIterator_step(ihash); continue; @@ -1048,9 +1048,9 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), BLI_ghashIterator_free(ihash); return deflected; } -/* --- the aabb section*/ +/* --- the aabb section. */ -/* +++ the face external section*/ +/* +++ the face external section. */ static int sb_detect_face_pointCached(const float face_v1[3], const float face_v2[3], const float face_v3[3], @@ -1104,13 +1104,13 @@ static int sb_detect_face_pointCached(const float face_v1[3], } } else { - /*aye that should be cached*/ + /* Aye that should be cached. */ CLOG_ERROR(&LOG, "missing cache error"); BLI_ghashIterator_step(ihash); continue; } - /* use mesh*/ + /* Use mesh. */ if (mvert) { while (a) { copy_v3_v3(nv1, mvert[a - 1].co); @@ -1118,7 +1118,7 @@ static int sb_detect_face_pointCached(const float face_v1[3], mul_v3_fl(nv1, time); madd_v3_v3fl(nv1, mprevvert[a - 1].co, 1.0f - time); } - /* origin to face_v2*/ + /* Origin to face_v2. */ sub_v3_v3(nv1, face_v2); facedist = dot_v3v3(nv1, d_nvect); if (fabsf(facedist) < outerfacethickness) { @@ -1139,7 +1139,7 @@ static int sb_detect_face_pointCached(const float face_v1[3], } } a--; - } /* while (a)*/ + } /* while (a) */ } /* if (mvert) */ } /* if (ob->pd && ob->pd->deflect) */ BLI_ghashIterator_step(ihash); @@ -1201,13 +1201,13 @@ static int sb_detect_face_collisionCached(const float face_v1[3], } } else { - /*aye that should be cached*/ + /* Aye that should be cached. */ CLOG_ERROR(&LOG, "missing cache error"); BLI_ghashIterator_step(ihash); continue; } - /* use mesh*/ + /* Use mesh. */ while (a--) { if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) || @@ -1235,7 +1235,7 @@ static int sb_detect_face_collisionCached(const float face_v1[3], } } - /* switch origin to be nv2*/ + /* Switch origin to be nv2. */ sub_v3_v3v3(edge1, nv1, nv2); sub_v3_v3v3(edge2, nv3, nv2); cross_v3_v3v3(d_nvect, edge2, edge1); @@ -1272,7 +1272,7 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) bf = sb->scratch->bodyface; for (a = 0; a < sb->scratch->totface; a++, bf++) { bf->ext_force[0] = bf->ext_force[1] = bf->ext_force[2] = 0.0f; - /*+++edges intruding*/ + /*+++edges intruding. */ bf->flag &= ~BFF_INTERSECT; zero_v3(feedback); if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos, @@ -1289,9 +1289,9 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) bf->flag |= BFF_INTERSECT; choke = min_ff(max_ff(damp, choke), 1.0f); } - /*---edges intruding*/ + /*---edges intruding. */ - /*+++ close vertices*/ + /*+++ close vertices. */ if ((bf->flag & BFF_INTERSECT) == 0) { bf->flag &= ~BFF_CLOSEVERT; tune = -1.0f; @@ -1311,7 +1311,7 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) choke = min_ff(max_ff(damp, choke), 1.0f); } } - /*--- close vertices*/ + /*--- close vertices. */ } bf = sb->scratch->bodyface; for (a = 0; a < sb->scratch->totface; a++, bf++) { @@ -1324,9 +1324,9 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) } } -/* --- the face external section*/ +/* --- the face external section. */ -/* +++ the spring external section*/ +/* +++ the spring external section. */ static int sb_detect_edge_collisionCached(const float edge_v1[3], const float edge_v2[3], @@ -1377,13 +1377,13 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3], } } else { - /*aye that should be cached*/ + /* Aye that should be cached. */ CLOG_ERROR(&LOG, "missing cache error"); BLI_ghashIterator_step(ihash); continue; } - /* use mesh*/ + /* Use mesh. */ while (a--) { if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) || @@ -1411,7 +1411,7 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3], } } - /* switch origin to be nv2*/ + /* Switch origin to be nv2. */ sub_v3_v3v3(edge1, nv1, nv2); sub_v3_v3v3(edge2, nv3, nv2); @@ -1469,12 +1469,12 @@ static void _scan_for_ext_spring_forces( } /* ---- springs colliding */ - /* +++ springs seeing wind ... n stuff depending on their orientation*/ - /* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/ + /* +++ springs seeing wind ... n stuff depending on their orientation. */ + /* NOTE: we don't use `sb->mediafrict` but use `sb->aeroedge` for magnitude of effect. */ if (sb->aeroedge) { float vel[3], sp[3], pr[3], force[3]; float f, windfactor = 0.25f; - /*see if we have wind*/ + /* See if we have wind. */ if (effectors) { EffectedPoint epoint; float speed[3] = {0.0f, 0.0f, 0.0f}; @@ -1543,7 +1543,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, /* figure the number of threads while preventing pretty pointless threading overhead */ totthread = BKE_scene_num_threads(scene); - /* what if we got zillions of CPUs running but less to spread*/ + /* What if we got zillions of CPUs running but less to spread. */ while ((totsprings / totthread < lowsprings) && (totthread > 1)) { totthread--; } @@ -1590,7 +1590,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, BKE_effectors_free(effectors); } -/* --- the spring external section*/ +/* --- the spring external section. */ static int choose_winner( float *w, float *pos, float *a, float *b, float *c, float *ca, float *cb, float *cc) @@ -1683,7 +1683,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], } } else { - /*aye that should be cached*/ + /* Aye that should be cached. */ CLOG_ERROR(&LOG, "missing cache error"); BLI_ghashIterator_step(ihash); continue; @@ -1697,7 +1697,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], fa *= fa; fa = 1.0f / fa; avel[0] = avel[1] = avel[2] = 0.0f; - /* use mesh*/ + /* Use mesh. */ while (a--) { if ((opco[0] < mima->minx) || (opco[0] > mima->maxx) || (opco[1] < mima->miny) || (opco[1] > mima->maxy) || (opco[2] < mima->minz) || (opco[2] > mima->maxz)) { @@ -1733,7 +1733,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], } } - /* switch origin to be nv2*/ + /* Switch origin to be nv2. */ sub_v3_v3v3(edge1, nv1, nv2); sub_v3_v3v3(edge2, nv3, nv2); /* Abuse dv1 to have vertex in question at *origin* of triangle. */ @@ -2068,7 +2068,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, bp->force[1] += -ks * (auxvect[1]); bp->force[2] += -ks * (auxvect[2]); - /* calculate damping forces generated by goals*/ + /* Calculate damping forces generated by goals. */ sub_v3_v3v3(velgoal, bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob); add_v3_v3v3(auxvect, velgoal, bp->vec); @@ -2113,7 +2113,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint - bp, &epoint); BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, NULL, speed); - /* apply forcefield*/ + /* Apply force-field. */ mul_v3_fl(force, fieldfactor * eval_sb_fric_force_scale); add_v3_v3(bp->force, force); @@ -2125,7 +2125,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, /* now we'll have nice centrifugal effect for vortex */ } else { - /* BP friction in media (not) moving*/ + /* BP friction in media (not) moving. */ float kd = sb->mediafrict * sb_fric_force_scale(ob); /* assume it to be proportional to actual velocity */ bp->force[0] -= bp->vec[0] * kd; @@ -2160,7 +2160,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, /* +++springs */ iks = 1.0f / (1.0f - sb->inspring) - 1.0f; /* inner spring constants function */ if (ob->softflag & OB_SB_EDGES) { - if (sb->bspring) { /* spring list exists at all ? */ + if (sb->bspring) { /* Spring list exists at all? */ int b; BodySpring *bs; for (b = bp->nofsprings; b > 0; b--) { @@ -2173,13 +2173,13 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, } // sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime) sb_spring_force(ob, ilast - bb, bs, iks, forcetime); - } /* loop springs */ - } /* existing spring list */ - } /*any edges*/ + } /* loop springs. */ + } /* existing spring list. */ + } /* Any edges. */ /* ---springs */ - } /*omit on snap */ - } /*loop all bp's*/ - return 0; /*done fine*/ + } /* Omit on snap. */ + } /* Loop all bp's. */ + return 0; /* Done fine. */ } static void *exec_softbody_calc_forces(void *data) @@ -2220,7 +2220,7 @@ static void sb_cf_threads_run(Scene *scene, /* figure the number of threads while preventing pretty pointless threading overhead */ totthread = BKE_scene_num_threads(scene); - /* what if we got zillions of CPUs running but less to spread*/ + /* What if we got zillions of CPUs running but less to spread. */ while ((totpoint / totthread < lowpoints) && (totthread > 1)) { totthread--; } @@ -2275,11 +2275,11 @@ static void softbody_calc_forces( * this will ruin adaptive stepsize AKA heun! (BM) */ SoftBody *sb = ob->soft; /* is supposed to be there */ - /*BodyPoint *bproot;*/ /* UNUSED */ - /* float gravity; */ /* UNUSED */ - /* float iks; */ + // BodyPoint *bproot; /* UNUSED */ + // float gravity; /* UNUSED */ + // float iks; float fieldfactor = -1.0f, windfactor = 0.25; - int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero; + int do_deflector /*, do_selfcollision */, do_springcollision, do_aero; /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ @@ -2292,8 +2292,8 @@ static void softbody_calc_forces( (ob->softflag & OB_SB_EDGECOLL); do_aero = ((sb->aeroedge) && (ob->softflag & OB_SB_EDGES)); - /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */ - /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ + // iks = 1.0f / (1.0f - sb->inspring) - 1.0f; /* Inner spring constants function. */ /* UNUSED */ + // bproot = sb->bpoint; /* Need this for proper spring addressing. */ /* UNUSED */ if (do_springcollision || do_aero) { sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL); @@ -2344,7 +2344,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * aabbmin[0] = aabbmin[1] = aabbmin[2] = 1e20f; aabbmax[0] = aabbmax[1] = aabbmax[2] = -1e20f; - /* old one with homogeneous masses */ + /* old one with homogeneous masses */ /* claim a minimum mass for vertex */ #if 0 if (sb->nodemass > 0.009999f) { @@ -2489,7 +2489,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* used by heun when it overshoots */ static void softbody_restore_prev_step(Object *ob) { - SoftBody *sb = ob->soft; /* is supposed to be there*/ + SoftBody *sb = ob->soft; /* is supposed to be there. */ BodyPoint *bp; int a; @@ -2502,7 +2502,7 @@ static void softbody_restore_prev_step(Object *ob) #if 0 static void softbody_store_step(Object *ob) { - SoftBody *sb = ob->soft; /* is supposed to be there*/ + SoftBody *sb = ob->soft; /* is supposed to be there. */ BodyPoint *bp; int a; @@ -2515,7 +2515,7 @@ static void softbody_store_step(Object *ob) /* used by predictors and correctors */ static void softbody_store_state(Object *ob, float *ppos, float *pvel) { - SoftBody *sb = ob->soft; /* is supposed to be there*/ + SoftBody *sb = ob->soft; /* is supposed to be there. */ BodyPoint *bp; int a; float *pp = ppos, *pv = pvel; @@ -2533,7 +2533,7 @@ static void softbody_store_state(Object *ob, float *ppos, float *pvel) /* used by predictors and correctors */ static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel) { - SoftBody *sb = ob->soft; /* is supposed to be there*/ + SoftBody *sb = ob->soft; /* is supposed to be there. */ BodyPoint *bp; int a; float *pp = ppos, *pv = pvel; @@ -2551,7 +2551,7 @@ static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel) /* used by predictors and correctors */ static void softbody_swap_state(Object *ob, float *ppos, float *pvel) { - SoftBody *sb = ob->soft; /* is supposed to be there*/ + SoftBody *sb = ob->soft; /* is supposed to be there. */ BodyPoint *bp; int a; float *pp = ppos, *pv = pvel; @@ -2773,7 +2773,7 @@ static void mesh_faces_to_scratch(Object *ob) MLoopTri *looptri, *lt; BodyFace *bodyface; int a; - /* alloc and copy faces*/ + /* Allocate and copy faces. */ sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop); looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__); @@ -3000,8 +3000,8 @@ static void curve_surf_to_softbody(Object *ob) bp = sb->bpoint; bs = sb->bspring; - /* weights from bpoints, same code used as for mesh vertices */ - /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/ + /* Weights from bpoints, same code used as for mesh vertices. */ + /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack. */ /* new! take the weights from curve vertex anyhow */ if (ob->softflag & OB_SB_GOAL) { setgoal = 1; @@ -3022,10 +3022,10 @@ static void curve_surf_to_softbody(Object *ob) if (setgoal) { bp->goal *= bezt->weight; - /* all three triples */ + /* All three triples. */ (bp + 1)->goal = bp->goal; (bp + 2)->goal = bp->goal; - /*do not collide handles */ + /* Do not collide handles. */ (bp + 1)->loc_flag |= SBF_OUTOFCOLLISION; (bp + 2)->loc_flag |= SBF_OUTOFCOLLISION; } @@ -3137,7 +3137,7 @@ SoftBody *sbNew(void) sb->inspring = 0.5f; sb->infrict = 0.5f; - /*todo backward file compat should copy inspring to inpush while reading old files*/ + /* TODO: backward file compat should copy `inspring` to `inpush` while reading old files. */ sb->inpush = 0.5f; sb->colball = 0.49f; @@ -3150,7 +3150,7 @@ SoftBody *sbNew(void) sb->choke = 3; sb_new_scratch(sb); - /*todo backward file compat should set sb->shearstiff = 1.0f while reading old files*/ + /* TODO: backward file compat should set `sb->shearstiff = 1.0f` while reading old files. */ sb->shearstiff = 1.0f; sb->solverflags |= SBSO_OLDERR; @@ -3311,7 +3311,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int for (a = 0, bp = sb->bpoint; a < numVerts; a++, bp++) { copy_v3_v3(bp->pos, vertexCos[a]); - mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ + mul_m4_v3(ob->obmat, bp->pos); /* Yep, soft-body is global coords. */ copy_v3_v3(bp->origS, bp->pos); copy_v3_v3(bp->origE, bp->pos); copy_v3_v3(bp->origT, bp->pos); @@ -3493,18 +3493,18 @@ static void softbody_step( else if (sb->solver_ID == 2) { /* do semi "fake" implicit euler */ /* removed */ - } /*SOLVER SELECT*/ + } /* SOLVER SELECT */ else if (sb->solver_ID == 4) { /* do semi "fake" implicit euler */ - } /*SOLVER SELECT*/ + } /* SOLVER SELECT */ else if (sb->solver_ID == 3) { /* do "stupid" semi "fake" implicit euler */ /* removed */ - } /*SOLVER SELECT*/ + } /* SOLVER SELECT */ else { CLOG_ERROR(&LOG, "softbody no valid solver ID!"); - } /*SOLVER SELECT*/ + } /* SOLVER SELECT */ if (sb->plastic) { apply_spring_memory(ob); } diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc index 85fb9730e83..76d046337c0 100644 --- a/source/blender/blenkernel/intern/spline_nurbs.cc +++ b/source/blender/blenkernel/intern/spline_nurbs.cc @@ -45,7 +45,7 @@ void NURBSpline::copy_data(Spline &dst) const nurbs.positions_ = positions_; nurbs.weights_ = weights_; nurbs.knots_ = knots_; - nurbs.knots_dirty_ = false; + nurbs.knots_dirty_ = knots_dirty_; nurbs.radii_ = radii_; nurbs.tilts_ = tilts_; } diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 4ca6f93b014..8b672b2cb49 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -63,7 +63,7 @@ void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg, /** \name Generally useful internal helpers * \{ */ -/* Number of floats in per-vertex elements. */ +/* Number of floats in per-vertex elements. */ static int num_element_float_get(const SubdivCCG *subdiv_ccg) { /* We always have 3 floats for coordinate. */ @@ -1116,7 +1116,7 @@ typedef struct AverageGridsCornerData { SubdivCCG *subdiv_ccg; CCGKey *key; - /* Optional lookup table. Maps task range index to index in subdiv_ccg->adjacent_vertices*/ + /* Optional lookup table. Maps task range index to index in `subdiv_ccg->adjacent_vertices`. */ const int *adjacent_vert_index_map; } AverageGridsCornerData; @@ -1489,7 +1489,7 @@ BLI_INLINE SubdivCCGCoord coord_at_next_col(const SubdivCCG *subdiv_ccg, return result; } -/* For the input coordinate which is at the boundary of the grid do one step inside. */ +/* For the input coordinate which is at the boundary of the grid do one step inside. */ static SubdivCCGCoord coord_step_inside_from_boundary(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord) diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c index 201d308e096..693827f99ac 100644 --- a/source/blender/blenkernel/intern/subdiv_eval.c +++ b/source/blender/blenkernel/intern/subdiv_eval.c @@ -282,7 +282,7 @@ static void buffer_apply_offset(void **buffer, const int offset) *buffer = ((unsigned char *)*buffer) + offset; } -/* Write given number of floats to the beginning of given buffer. */ +/* Write given number of floats to the beginning of given buffer. */ static void buffer_write_float_value(void **buffer, const float *values_buffer, int num_values) { memcpy(*buffer, values_buffer, sizeof(float) * num_values); diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 4400e9c976f..061c196df2a 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -1749,7 +1749,7 @@ static void subdiv_foreach_vertices_of_loose_edges_task(void *__restrict userdat /* Subdivision vertices which corresponds to edge's v1 and v2. */ const int subdiv_v1_index = ctx->vertices_corner_offset + coarse_edge->v1; const int subdiv_v2_index = ctx->vertices_corner_offset + coarse_edge->v2; - /* First subdivided inner vertex of the edge. */ + /* First subdivided inner vertex of the edge. */ const int subdiv_start_vertex = ctx->vertices_edge_offset + coarse_edge_index * num_subdiv_vertices_per_coarse_edge; /* Perform interpolation. */ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 23eccbfba9b..0dbfeaaaadb 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -580,16 +580,16 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss, #endif MVert *mvert = dm->getVertArray(dm); MEdge *medge = dm->getEdgeArray(dm); - /* MFace *mface = dm->getTessFaceArray(dm); */ /* UNUSED */ + // MFace *mface = dm->getTessFaceArray(dm); /* UNUSED */ MVert *mv; MEdge *me; MLoop *mloop = dm->getLoopArray(dm), *ml; MPoly *mpoly = dm->getPolyArray(dm), *mp; - /*MFace *mf;*/ /*UNUSED*/ + // MFace *mf; /* UNUSED */ int totvert = dm->getNumVerts(dm); int totedge = dm->getNumEdges(dm); - /*int totface = dm->getNumTessFaces(dm);*/ /*UNUSED*/ - /*int totpoly = dm->getNumFaces(dm);*/ /*UNUSED*/ + // int totface = dm->getNumTessFaces(dm); /* UNUSED */ + // int totpoly = dm->getNumFaces(dm); /* UNUSED */ int i, j; int *index; @@ -641,10 +641,10 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss, fVerts[j] = POINTER_FROM_UINT(ml->v); } - /* this is very bad, means mesh is internally inconsistent. + /* This is very bad, means mesh is internally inconsistent. * it is not really possible to continue without modifying * other parts of code significantly to handle missing faces. - * since this really shouldn't even be possible we just bail.*/ + * since this really shouldn't even be possible we just bail. */ if (ccgSubSurf_syncFace(ss, POINTER_FROM_INT(i), mp->totloop, fVerts, &f) == eCCGError_InvalidValue) { static int hasGivenError = 0; @@ -1008,11 +1008,11 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) int gridFaces = gridSideEdges * gridSideEdges; int i; CCGFace *f; - /*int numVerts;*/ + // int numVerts; int offset; int grid; int x, y; - /*int lastface = ccgSubSurf_getNumFaces(ss) - 1;*/ /*UNUSED*/ + // int lastface = ccgSubSurf_getNumFaces(ss) - 1; /* UNUSED */ DMFlagMat *faceFlags = ccgdm->faceFlags; memset(mf, 0, sizeof(*mf)); @@ -1023,7 +1023,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) i = ccgdm->reverseFaceMap[faceNum]; f = ccgdm->faceMap[i].face; - /*numVerts = ccgSubSurf_getFaceNumVerts(f);*/ /*UNUSED*/ + // numVerts = ccgSubSurf_getFaceNumVerts(f); /* UNUSED */ offset = faceNum - ccgdm->faceMap[i].startFace; grid = offset / gridFaces; @@ -1781,7 +1781,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) numGrids = ccgDM_getNumGrids(dm); numFaces = ccgSubSurf_getNumFaces(ss); - /*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/ + // gridSize = ccgDM_getGridSize(dm); /* UNUSED */ /* compute offset into grid array for each face */ gridOffset = MEM_mallocN(sizeof(int) * numFaces, "ccgdm.gridOffset"); @@ -2089,7 +2089,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm, vertidx[s] = POINTER_AS_INT(ccgSubSurf_getVertVertHandle(v)); } - /*I think this is for interpolating the center vert?*/ + /* I think this is for interpolating the center vert? */ w2 = w; // + numVerts*(g2_wid-1) * (g2_wid-1); //numVerts*((g2_wid-1) * g2_wid+g2_wid-1); DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2, numVerts, vertNum); if (vertOrigIndex) { @@ -2099,7 +2099,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm, vertNum++; - /*interpolate per-vert data*/ + /* Interpolate per-vert data. */ for (s = 0; s < numVerts; s++) { for (x = 1; x < gridFaces; x++) { w2 = w + s * numVerts * g2_wid * g2_wid + x * numVerts; @@ -2114,7 +2114,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm, } } - /*interpolate per-vert data*/ + /* Interpolate per-vert data. */ for (s = 0; s < numVerts; s++) { for (y = 1; y < gridFaces; y++) { for (x = 1; x < gridFaces; x++) { @@ -2138,7 +2138,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm, } for (s = 0; s < numVerts; s++) { - /*interpolate per-face data*/ + /* Interpolate per-face data. */ for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts; @@ -2161,10 +2161,10 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm, &dm->loopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2); loopindex2++; - /*copy over poly data, e.g. mtexpoly*/ + /* Copy over poly data, e.g. mtexpoly. */ CustomData_copy_data(&dm->polyData, &ccgdm->dm.polyData, origIndex, faceNum, 1); - /*set original index data*/ + /* Set original index data. */ if (faceOrigIndex) { /* reference the index in 'polyOrigIndex' */ *faceOrigIndex = faceNum; diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index 46589a578a8..3dff750edfb 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -1381,7 +1381,7 @@ ImBuf *BKE_tracking_stabilize_frame( return ibuf; } - /* Allocate frame for stabilization result, copy alpha mode and colorspace. */ + /* Allocate frame for stabilization result, copy alpha mode and colorspace. */ ibuf_flags = 0; if (ibuf->rect) { ibuf_flags |= IB_rect; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index c2fb5ef4238..290b880934e 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -744,10 +744,10 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_ * * "1m1cm+2mm" - Original value. * "1*1#1*0.01#+2*0.001#" - Replace numbers. - * "1*1+1*0.01 +2*0.001 " - Add add signs if ( + - * / | & ~ < > ^ ! = % ) not found in between. + * "1*1+1*0.01 +2*0.001 " - Add plus signs if ( + - * / | & ~ < > ^ ! = % ) not found in between. */ -/* Not too strict, (+ - * /) are most common. */ +/* Not too strict, (+ - * /) are most common. */ static bool ch_is_op(char op) { switch (op) { @@ -917,7 +917,7 @@ static int unit_scale_str(char *str, return 0; } - /* XXX - investigate, does not respect len_max properly. */ + /* XXX - investigate, does not respect len_max properly. */ char *str_found = (char *)unit_find_str(str, replace_str, case_sensitive); if (str_found == NULL) { diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 5fc55aad6a2..272ecc71833 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -1224,7 +1224,7 @@ const VolumeGrid *BKE_volume_grid_active_get_for_read(const Volume *volume) return BKE_volume_grid_get_for_read(volume, index); } -/* Tries to find a grid with the given name. Make sure that that the volume has been loaded. */ +/* Tries to find a grid with the given name. Make sure that the volume has been loaded. */ const VolumeGrid *BKE_volume_grid_find_for_read(const Volume *volume, const char *name) { int num_grids = BKE_volume_num_grids(volume); diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index be67b2370e3..533107b2bf6 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -105,8 +105,8 @@ static void workspace_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_list(reader, &workspace->tools); LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) { - /* parent pointer does not belong to workspace data and is therefore restored in lib_link step - * of window manager.*/ + /* Parent pointer does not belong to workspace data and is therefore restored in lib_link step + * of window manager. */ BLO_read_data_address(reader, &relation->value); } |