From 03b2371387dcae9f801cabbc1819b1d7e3350829 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Aug 2019 23:29:46 +1000 Subject: Cleanup: move trailing comments to avoid wrapping code Some statements were split across multiple lines because of their trailing comments. In most cases it's clearer to put the comments above. --- source/blender/blenkernel/intern/armature.c | 5 ++-- source/blender/blenkernel/intern/collection.c | 5 ++-- source/blender/blenkernel/intern/curve.c | 6 +++-- source/blender/blenkernel/intern/dynamicpaint.c | 12 ++++++--- source/blender/blenkernel/intern/effect.c | 5 ++-- source/blender/blenkernel/intern/fcurve.c | 6 +++-- source/blender/blenkernel/intern/fmodifier.c | 6 +++-- source/blender/blenkernel/intern/gpencil.c | 6 +++-- .../blender/blenkernel/intern/library_override.c | 6 ++--- source/blender/blenkernel/intern/library_query.c | 9 +++---- source/blender/blenkernel/intern/main.c | 26 +++++++++++------- source/blender/blenkernel/intern/mask.c | 10 +++---- source/blender/blenkernel/intern/nla.c | 17 ++++++------ source/blender/blenkernel/intern/object_dupli.c | 4 +-- source/blender/blenkernel/intern/particle.c | 5 ++-- source/blender/blenkernel/intern/pointcache.c | 31 +++++++++------------- source/blender/blenkernel/intern/softbody.c | 22 +++++++++------ source/blender/blenkernel/intern/unit.c | 10 ++++--- 18 files changed, 107 insertions(+), 84 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 742e3634bf1..ea927ca9333 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2707,8 +2707,9 @@ void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, cob = BKE_constraints_make_evalob(depsgraph, scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); /* Solve PoseChannel's Constraints */ - BKE_constraints_solve( - depsgraph, &pchan->constraints, cob, ctime); /* ctime doesn't alter objects */ + + /* ctime doesn't alter objects. */ + BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* cleanup after Constraint Solving * - applies matrix back to pchan, and frees temporary struct used diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 25f2797915a..2031576190e 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -239,8 +239,9 @@ static Collection *collection_duplicate_recursive(Main *bmain, if (!do_hierarchy || collection_old->id.newid == NULL) { BKE_id_copy(bmain, &collection_old->id, (ID **)&collection_new); - id_us_min( - &collection_new->id); /* Copying add one user by default, need to get rid of that one. */ + + /* Copying add one user by default, need to get rid of that one. */ + id_us_min(&collection_new->id); if (do_hierarchy) { ID_NEW_SET(collection_old, collection_new); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index efdfa2c19bb..980e8043a42 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2737,8 +2737,10 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) /* check if we will calculate tilt data */ do_tilt = CU_DO_TILT(cu, nu); - do_radius = CU_DO_RADIUS( - cu, nu); /* normal display uses the radius, better just to calculate them */ + + /* Normal display uses the radius, better just to calculate them. */ + do_radius = CU_DO_RADIUS(cu, nu); + do_weight = true; /* check we are a single point? also check we are not a surface and that the orderu is sane, diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 1fb25375159..04cbdbb6bcd 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -4061,8 +4061,10 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( hit_found = HIT_VOLUME; /* Mark hit info */ - madd_v3_v3v3fl( - hitCoord, ray_start, ray_dir, hit.dist); /* Calculate final hit coordinates */ + + /* Calculate final hit coordinates */ + madd_v3_v3v3fl(hitCoord, ray_start, ray_dir, hit.dist); + depth += dist * sample_factor; hitTri = f_index; } @@ -4113,8 +4115,10 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( treeData->tree, ray_start, proj_ray, 0.0f, &hit, mesh_tris_spherecast_dp, treeData); if (hit.index != -1) { proxDist = hit.dist; - madd_v3_v3v3fl( - hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */ + + /* Calculate final hit coordinates */ + madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); + tri = hit.index; } } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 7cbd5b6b050..ffab82b75af 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1338,8 +1338,9 @@ void BKE_sim_debug_data_clear_category(const char *category) BLI_ghashIterator_init(&iter, _sim_debug_data->gh); while (!BLI_ghashIterator_done(&iter)) { const SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); - BLI_ghashIterator_step( - &iter); /* removing invalidates the current iterator, so step before removing */ + + /* Removing invalidates the current iterator, so step before removing. */ + BLI_ghashIterator_step(&iter); if (elem->category_hash == category_hash) { BLI_ghash_remove(_sim_debug_data->gh, elem, NULL, debug_element_free); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 140d1f0d26c..9580ea763fb 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -506,8 +506,10 @@ static int binarysearch_bezt_index_ex( */ for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / - 2); /* we calculate the midpoint this way to avoid int overflows... */ + + /* We calculate the midpoint this way to avoid int overflows... */ + int mid = start + ((end - start) / 2); + float midfra = array[mid].vec[1][0]; /* check if exactly equal to midpoint */ diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 4295a44098c..48c0258bf47 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -555,8 +555,10 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], */ for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / - 2); /* we calculate the midpoint this way to avoid int overflows... */ + + /* we calculate the midpoint this way to avoid int overflows... */ + int mid = start + ((end - start) / 2); + float midfra = array[mid].time; /* check if exactly equal to midpoint */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index ed4c6848751..728f4890189 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -642,8 +642,10 @@ void BKE_gpencil_copy_data(bGPdata *gpd_dst, const bGPdata *gpd_src, const int U BLI_listbase_clear(&gpd_dst->layers); for (const bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) { /* make a copy of source layer and its data */ - bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate( - gpl_src); /* TODO here too could add unused flags... */ + + /* TODO here too could add unused flags... */ + bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src); + BLI_addtail(&gpd_dst->layers, gpl_dst); } } diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c index fed90ad8982..e435f07e38d 100644 --- a/source/blender/blenkernel/intern/library_override.c +++ b/source/blender/blenkernel/intern/library_override.c @@ -703,9 +703,9 @@ void BKE_override_library_update(Main *bmain, ID *local) local->tag |= LIB_TAG_OVERRIDE_LIBRARY_REFOK; /* Full rebuild of Depsgraph! */ - DEG_on_visible_update( - bmain, - true); /* XXX Is this actual valid replacement for old DAG_relations_tag_update(bmain) ? */ + + /* XXX Is this actual valid replacement for old DAG_relations_tag_update(bmain) ? */ + DEG_on_visible_update(bmain, true); } /** Update all overrides from given \a bmain. */ diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index bf77c1417ea..ca3da0d89c7 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -1168,10 +1168,8 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) case ID_CA: return ELEM(id_type_used, ID_OB); case ID_KE: - return ELEM(id_type_used, - ID_ME, - ID_CU, - ID_LT); /* Warning! key->from, could be more types in future? */ + /* Warning! key->from, could be more types in future? */ + return ELEM(id_type_used, ID_ME, ID_CU, ID_LT); case ID_SCR: return ELEM(id_type_used, ID_SCE); case ID_WO: @@ -1190,7 +1188,8 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) case ID_MC: return ELEM(id_type_used, ID_GD, ID_IM); case ID_MSK: - return ELEM(id_type_used, ID_MC); /* WARNING! mask->parent.id, not typed. */ + /* WARNING! mask->parent.id, not typed. */ + return ELEM(id_type_used, ID_MC); case ID_LS: return (ELEM(id_type_used, ID_TE, ID_OB)); case ID_LP: diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 170b8d0ab93..8e2c3a11ac0 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -485,16 +485,23 @@ int set_listbasepointers(Main *bmain, ListBase **lb) /* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last. * This is important because freeing data decreases user-counts of other data-blocks, * if this data is its self freed it can crash. */ - lb[INDEX_ID_LI] = &( - bmain->libraries); /* Libraries may be accessed from pretty much any other ID... */ + + /* Libraries may be accessed from pretty much any other ID. */ + lb[INDEX_ID_LI] = &(bmain->libraries); + lb[INDEX_ID_IP] = &(bmain->ipo); - lb[INDEX_ID_AC] = &( - bmain->actions); /* moved here to avoid problems when freeing with animato (aligorith) */ + + /* Moved here to avoid problems when freeing with animato (aligorith). */ + lb[INDEX_ID_AC] = &(bmain->actions); + lb[INDEX_ID_KE] = &(bmain->shapekeys); - lb[INDEX_ID_PAL] = &( - bmain->palettes); /* referenced by gpencil, so needs to be before that to avoid crashes */ - lb[INDEX_ID_GD] = &( - bmain->gpencils); /* referenced by nodes, objects, view, scene etc, before to free after. */ + + /* Referenced by gpencil, so needs to be before that to avoid crashes. */ + lb[INDEX_ID_PAL] = &(bmain->palettes); + + /* Referenced by nodes, objects, view, scene etc, before to free after. */ + lb[INDEX_ID_GD] = &(bmain->gpencils); + lb[INDEX_ID_NT] = &(bmain->nodetrees); lb[INDEX_ID_IM] = &(bmain->images); lb[INDEX_ID_TE] = &(bmain->textures); @@ -502,8 +509,7 @@ int set_listbasepointers(Main *bmain, ListBase **lb) lb[INDEX_ID_VF] = &(bmain->fonts); /* Important!: When adding a new object type, - * the specific data should be inserted here - */ + * the specific data should be inserted here. */ lb[INDEX_ID_AR] = &(bmain->armatures); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 8f8150b6a64..b6d61563fe8 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -892,8 +892,8 @@ void BKE_mask_copy_data(Main *UNUSED(bmain), { BLI_listbase_clear(&mask_dst->masklayers); - BKE_mask_layer_copy_list(&mask_dst->masklayers, - &mask_src->masklayers); /* TODO add unused flag to those as well. */ + /* TODO add unused flag to those as well. */ + BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers); /* enable fake user by default */ id_fake_user_set(&mask_dst->id); @@ -1766,10 +1766,10 @@ static void interp_weights_uv_v2_calc(float r_uv[2], { float pt_on_line[2]; r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b); + r_uv[1] = (len_v2v2(pt_on_line, pt) / len_v2v2(pt_a, pt_b)) * - ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? - -1.0f : - 1.0f); /* this line only sets the sign */ + /* This line only sets the sign. */ + ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f); } static void interp_weights_uv_v2_apply(const float uv[2], diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 0b06bfab2ab..2cc1083aba3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -448,8 +448,9 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short if (IS_EQF(strip->scale, 0.0f)) { strip->scale = 1.0f; } - scale = fabsf( - strip->scale); /* scale must be positive - we've got a special flag for reversing */ + + /* Scale must be positive - we've got a special flag for reversing. */ + scale = fabsf(strip->scale); /* length of referenced action */ actlength = strip->actend - strip->actstart; @@ -1280,9 +1281,9 @@ static void nlastrip_fix_resize_overlaps(NlaStrip *strip) * then offset everything else by the remaining defict to give the strip room */ nls->start = nls->end - 1.0f; - offset = ceilf( - strip->end - - nls->start); /* XXX: review whether preventing fractionals is good here... */ + + /* XXX: review whether preventing fractionals is good here... */ + offset = ceilf(strip->end - nls->start); /* apply necessary offset to ensure that the strip has enough space */ for (; nls; nls = nls->next) { @@ -1329,9 +1330,9 @@ static void nlastrip_fix_resize_overlaps(NlaStrip *strip) * then offset everything else by the remaining defict to give the strip room */ nls->end = nls->start + 1.0f; - offset = ceilf( - nls->end - - strip->start); /* XXX: review whether preventing fractionals is good here... */ + + /* XXX: review whether preventing fractionals is good here... */ + offset = ceilf(nls->end - strip->start); /* apply necessary offset to ensure that the strip has enough space */ for (; nls; nls = nls->next) { diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 0dedbb7e934..7983fe54be5 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -762,8 +762,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem no_draw_flag |= PARS_NO_DISP; } - ctime = DEG_get_ctime( - ctx->depsgraph); /* NOTE: in old animsys, used parent object's timeoffset... */ + /* NOTE: in old animsys, used parent object's timeoffset... */ + ctime = DEG_get_ctime(ctx->depsgraph); totpart = psys->totpart; totchild = psys->totchild; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index da00a044009..ffeba0148a2 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1764,8 +1764,9 @@ void psys_particle_on_dm(Mesh *mesh_final, copy_v3_v3(nor, tmpnor); } - normalize_v3( - tmpnor); /* XXX Why not normalize tmpnor before copying it into nor??? -- mont29 */ + /* XXX Why not normalize tmpnor before copying it into nor??? -- mont29 */ + normalize_v3(tmpnor); + mul_v3_fl(tmpnor, -foffset); add_v3_v3(vec, tmpnor); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 2d42406520d..13d0f1adb84 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2073,10 +2073,9 @@ static int ptcache_path(PTCacheID *pid, char *filename) file[i - 6] = '\0'; } - BLI_snprintf(filename, - MAX_PTCACHE_PATH, - "//" PTCACHE_PATH "%s", - file); /* add blend file name to pointcache dir */ + /* Add blend file name to pointcache dir. */ + BLI_snprintf(filename, MAX_PTCACHE_PATH, "//" PTCACHE_PATH "%s", file); + BLI_path_abs(filename, blendfilename); return BLI_add_slash(filename); /* new strlen() */ } @@ -2130,24 +2129,17 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p if (pid->cache->flag & PTCACHE_EXTERNAL) { if (pid->cache->index >= 0) { - BLI_snprintf(newname, - MAX_PTCACHE_FILE, - "_%06d_%02u%s", - cfra, - pid->stack_index, - ext); /* always 6 chars */ + /* Always 6 chars. */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext); } else { - BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d%s", cfra, ext); /* always 6 chars */ + /* Always 6 chars. */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d%s", cfra, ext); } } else { - BLI_snprintf(newname, - MAX_PTCACHE_FILE, - "_%06d_%02u%s", - cfra, - pid->stack_index, - ext); /* always 6 chars */ + /* Always 6 chars. */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext); } len += 16; } @@ -2178,8 +2170,9 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) fp = BLI_fopen(filename, "rb"); } else if (mode == PTCACHE_FILE_WRITE) { - BLI_make_existing_file( - filename); /* will create the dir if needs be, same as //textures is created */ + /* Will create the dir if needs be, same as "//textures" is created. */ + BLI_make_existing_file(filename); + fp = BLI_fopen(filename, "wb"); } else if (mode == PTCACHE_FILE_UPDATE) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 2024a507ebb..20736e28a53 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1731,8 +1731,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], /* switch origin to be nv2*/ sub_v3_v3v3(edge1, nv1, nv2); sub_v3_v3v3(edge2, nv3, nv2); - sub_v3_v3v3( - dv1, opco, nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ + /* Abuse dv1 to have vertex in question at *origin* of triangle. */ + sub_v3_v3v3(dv1, opco, nv2); cross_v3_v3v3(d_nvect, edge2, edge1); /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect); @@ -2087,9 +2087,12 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { float gravity[3]; copy_v3_v3(gravity, scene->physics_settings.gravity); + + /* Individual mass of node here. */ mul_v3_fl(gravity, sb_grav_force_scale(ob) * _final_mass(ob, bp) * - sb->effector_weights->global_gravity); /* individual mass of node here */ + sb->effector_weights->global_gravity); + add_v3_v3(bp->force, gravity); } @@ -2099,8 +2102,10 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, float kd; float force[3] = {0.0f, 0.0f, 0.0f}; float speed[3] = {0.0f, 0.0f, 0.0f}; - float eval_sb_fric_force_scale = sb_fric_force_scale( - ob); /* just for calling function once */ + + /* just for calling function once */ + float eval_sb_fric_force_scale = sb_fric_force_scale(ob); + pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint - bp, &epoint); BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, speed); @@ -2743,9 +2748,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob) build_bps_springlist(ob); /* scan for springs attached to bodypoints ONCE */ /* insert *other second order* springs if desired */ if (sb->secondspring > 0.0000001f) { - add_2nd_order_springs( - ob, sb->secondspring); /* exploits the first run of build_bps_springlist(ob);*/ - build_bps_springlist(ob); /* yes we need to do it again*/ + /* exploits the first run of build_bps_springlist(ob); */ + add_2nd_order_springs(ob, sb->secondspring); + /* yes we need to do it again. */ + build_bps_springlist(ob); } springs_from_mesh(ob); /* write the 'rest'-length of the springs */ if (ob->softflag & OB_SB_SELF) { diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 375721057c3..e30ea687b13 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -734,8 +734,9 @@ static int unit_scale_str(char *str, len_name = strlen(replace_str); len_move = (len - (found_ofs + len_name)) + 1; /* 1+ to copy the string terminator */ - len_num = BLI_snprintf( - str_tmp, TEMP_STR_SIZE, "*%.9g" SEP_STR, unit->scalar / scale_pref); /* # removed later */ + + /* # removed later */ + len_num = BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%.9g" SEP_STR, unit->scalar / scale_pref); if (len_num > len_max) { len_num = len_max; @@ -748,8 +749,9 @@ static int unit_scale_str(char *str, if (len_move > 0) { /* resize the last part of the string */ - memmove( - str_found + len_num, str_found + len_name, len_move); /* may grow or shrink the string */ + + /* May grow or shrink the string. */ + memmove(str_found + len_num, str_found + len_name, len_move); } if (found_ofs + len_num > len_max) { -- cgit v1.2.3