From 4d46fac65d9946382c4be5b3842660e77468f00b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2022 12:04:20 +1100 Subject: Cleanup: use count or num instead of nbr Follow conventions from T85728. --- source/blender/editors/gpencil/gpencil_convert.c | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'source/blender/editors/gpencil') diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index d4518f21586..4f9468cc9c4 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -207,7 +207,7 @@ typedef struct tGpTimingData { int seed; /* Data set from points, used to compute final timing FCurve */ - int num_points, cur_point; + int points_num, cur_point; /* Distances */ float *dists; @@ -229,29 +229,29 @@ typedef struct tGpTimingData { /* Init point buffers for timing data. * Note this assumes we only grow those arrays! */ -static void gpencil_timing_data_set_nbr(tGpTimingData *gtd, const int nbr) +static void gpencil_timing_data_set_num(tGpTimingData *gtd, const int num) { float *tmp; - BLI_assert(nbr > gtd->num_points); + BLI_assert(num > gtd->points_num); /* distances */ tmp = gtd->dists; - gtd->dists = MEM_callocN(sizeof(float) * nbr, __func__); + gtd->dists = MEM_callocN(sizeof(float) * num, __func__); if (tmp) { - memcpy(gtd->dists, tmp, sizeof(float) * gtd->num_points); + memcpy(gtd->dists, tmp, sizeof(float) * gtd->points_num); MEM_freeN(tmp); } /* times */ tmp = gtd->times; - gtd->times = MEM_callocN(sizeof(float) * nbr, __func__); + gtd->times = MEM_callocN(sizeof(float) * num, __func__); if (tmp) { - memcpy(gtd->times, tmp, sizeof(float) * gtd->num_points); + memcpy(gtd->times, tmp, sizeof(float) * gtd->points_num); MEM_freeN(tmp); } - gtd->num_points = nbr; + gtd->points_num = num; } /* add stroke point to timing buffers */ @@ -297,15 +297,15 @@ static void gpencil_timing_data_add_point(tGpTimingData *gtd, static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx, - const int nbr_gaps, - int *nbr_done_gaps, + const int gaps_count, + int *gaps_done_count, const float tot_gaps_time, const float delta_time, float *next_delta_time) { int j; - for (j = idx + 1; j < gtd->num_points; j++) { + for (j = idx + 1; j < gtd->points_num; j++) { if (gtd->times[j] < 0) { gtd->times[j] = -gtd->times[j]; if (gtd->mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { @@ -316,7 +316,7 @@ static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd, /* We want gaps that are in gtd->gap_duration +/- gtd->gap_randomness range, * and which sum to exactly tot_gaps_time... */ - int rem_gaps = nbr_gaps - (*nbr_done_gaps); + int rem_gaps = gaps_count - (*gaps_done_count); if (rem_gaps < 2) { /* Last gap, just give remaining time! */ *next_delta_time = tot_gaps_time; @@ -327,7 +327,7 @@ static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd, /* This code ensures that if the first gaps * have been shorter than average gap_duration, next gaps * will tend to be longer (i.e. try to recover the lateness), and vice-versa! */ - delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps)); + delta = delta_time - (gtd->gap_duration * (*gaps_done_count)); /* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */ min = -gtd->gap_randomness - delta; @@ -343,7 +343,7 @@ static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd, *next_delta_time += gtd->gap_duration; } } - (*nbr_done_gaps)++; + (*gaps_done_count)++; break; } } @@ -353,14 +353,14 @@ static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd, static void gpencil_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rng, - int *nbr_gaps, + int *gaps_count, float *r_tot_gaps_time) { float delta_time = 0.0f; - for (int i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->points_num; i++) { if (gtd->times[i] < 0 && i) { - (*nbr_gaps)++; + (*gaps_count)++; gtd->times[i] = -gtd->times[i] - delta_time; delta_time += gtd->times[i] - gtd->times[i - 1]; gtd->times[i] = -gtd->times[i - 1]; /* Temp marker, values *have* to be different! */ @@ -371,7 +371,7 @@ static void gpencil_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, } gtd->tot_time -= delta_time; - *r_tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration; + *r_tot_gaps_time = (float)(*gaps_count) * gtd->gap_duration; gtd->tot_time += *r_tot_gaps_time; if (gtd->gap_randomness > 0.0f) { BLI_rng_srandom(rng, gtd->seed); @@ -387,7 +387,7 @@ static void gpencil_stroke_path_animation_add_keyframes(ReportList *reports, tGpTimingData *gtd, RNG *rng, const float time_range, - const int nbr_gaps, + const int gaps_count, const float tot_gaps_time) { /* Use actual recorded timing! */ @@ -399,20 +399,20 @@ static void gpencil_stroke_path_animation_add_keyframes(ReportList *reports, /* CustomGaps specific */ float delta_time = 0.0f, next_delta_time = 0.0f; - int nbr_done_gaps = 0; + int gaps_done_count = 0; /* This is a bit tricky, as: * - We can't add arbitrarily close points on FCurve (in time). * - We *must* have all "caps" points of all strokes in FCurve, as much as possible! */ - for (int i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->points_num; i++) { /* If new stroke... */ if (i > end_stroke_idx) { start_stroke_idx = i; delta_time = next_delta_time; /* find end of that new stroke */ end_stroke_idx = gpencil_find_end_of_stroke_idx( - gtd, rng, i, nbr_gaps, &nbr_done_gaps, tot_gaps_time, delta_time, &next_delta_time); + gtd, rng, i, gaps_count, &gaps_done_count, tot_gaps_time, delta_time, &next_delta_time); /* This one should *never* be negative! */ end_stroke_time = time_start + ((gtd->times[end_stroke_idx] + delta_time) / gtd->tot_time * time_range); @@ -502,7 +502,7 @@ static void gpencil_stroke_path_animation(bContext *C, FCurve *fcu; PointerRNA ptr; PropertyRNA *prop = NULL; - int nbr_gaps = 0; + int gaps_count = 0; if (gtd->mode == GP_STROKECONVERT_TIMING_NONE) { return; @@ -571,7 +571,7 @@ static void gpencil_stroke_path_animation(bContext *C, /* Pre-process gaps, in case we don't want to keep their original timing */ if (gtd->mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { - gpencil_stroke_path_animation_preprocess_gaps(gtd, rng, &nbr_gaps, &tot_gaps_time); + gpencil_stroke_path_animation_preprocess_gaps(gtd, rng, &gaps_count, &tot_gaps_time); } if (gtd->realtime) { @@ -582,7 +582,7 @@ static void gpencil_stroke_path_animation(bContext *C, } gpencil_stroke_path_animation_add_keyframes( - reports, ptr, prop, depsgraph, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); + reports, ptr, prop, depsgraph, fcu, cu, gtd, rng, time_range, gaps_count, tot_gaps_time); BLI_rng_free(rng); } @@ -684,7 +684,7 @@ static void gpencil_stroke_to_path(bContext *C, } if (do_gtd) { - gpencil_timing_data_set_nbr(gtd, nu->pntsu); + gpencil_timing_data_set_num(gtd, nu->pntsu); } /* If needed, make the link between both strokes with two zero-radius additional points */ @@ -929,7 +929,7 @@ static void gpencil_stroke_to_bezier(bContext *C, } if (do_gtd) { - gpencil_timing_data_set_nbr(gtd, nu->pntsu); + gpencil_timing_data_set_num(gtd, nu->pntsu); } tot = gps->totpoints; @@ -1536,7 +1536,7 @@ static int gpencil_convert_layer_exec(bContext *C, wmOperator *op) gtd.gap_randomness = RNA_float_get(op->ptr, "gap_randomness"); gtd.gap_randomness = min_ff(gtd.gap_randomness, gtd.gap_duration); gtd.seed = RNA_int_get(op->ptr, "seed"); - gtd.num_points = gtd.cur_point = 0; + gtd.points_num = gtd.cur_point = 0; gtd.dists = gtd.times = NULL; gtd.tot_dist = gtd.tot_time = gtd.gap_tot_time = 0.0f; gtd.inittime = 0.0; -- cgit v1.2.3