From 1b95e74b8a6b00c6c0d635252c753ebde0db309a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 7 Nov 2023 17:24:36 +0100 Subject: [PATCH] Cleanup: comment style in animrig No functional changes. Functions moved to animrig recently did not adhere to the comment style guidelines Pull Request: https://projects.blender.org/blender/blender/pulls/114586 --- source/blender/animrig/ANIM_fcurve.hh | 6 ++- source/blender/animrig/intern/action.cc | 2 +- source/blender/animrig/intern/animdata.cc | 16 +++--- source/blender/animrig/intern/fcurve.cc | 63 +++++++++++------------ 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/source/blender/animrig/ANIM_fcurve.hh b/source/blender/animrig/ANIM_fcurve.hh index 9908231f7eb..54c87782891 100644 --- a/source/blender/animrig/ANIM_fcurve.hh +++ b/source/blender/animrig/ANIM_fcurve.hh @@ -29,7 +29,9 @@ bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra); * memory for the array if needed, and will insert the #BezTriple into a * suitable place in chronological order. * - * \note any recalculate of the F-Curve that needs to be done will need to be done by the caller. + * \returns The index of the keyframe array into which the bezt has been added. + * + * \note Any recalculate of the F-Curve that needs to be done will need to be done by the caller. */ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag); @@ -44,6 +46,8 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) * adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet. * It returns the index at which the keyframe was added. * + * \returns The index of the keyframe array into which the bezt has been added. + * * \param keyframe_type: The type of keyframe (#eBezTriple_KeyframeType). * \param flag: Optional flags (#eInsertKeyFlags) for controlling how keys get added * and/or whether updates get done. diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index 9ddcf7bb363..fa3df36a38f 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -36,7 +36,7 @@ FCurve *action_fcurve_ensure(Main *bmain, return nullptr; } - /* try to find f-curve matching for this setting + /* Try to find f-curve matching for this setting. * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ diff --git a/source/blender/animrig/intern/animdata.cc b/source/blender/animrig/intern/animdata.cc index 539cefd8aa6..9b9ff598f7c 100644 --- a/source/blender/animrig/intern/animdata.cc +++ b/source/blender/animrig/intern/animdata.cc @@ -22,35 +22,34 @@ namespace blender::animrig { void animdata_fcurve_delete(bAnimContext *ac, AnimData *adt, FCurve *fcu) { - /* - if no AnimData, we've got nowhere to remove the F-Curve from + /* - If no AnimData, we've got nowhere to remove the F-Curve from * (this doesn't guarantee that the F-Curve is in there, but at least we tried - * - if no F-Curve, there is nothing to remove + * - If no F-Curve, there is nothing to remove */ if (ELEM(nullptr, adt, fcu)) { return; } - /* remove from whatever list it came from + /* Remove from whatever list it came from * - Action Group * - Action * - Drivers * - TODO... some others? */ if ((ac) && (ac->datatype == ANIMCONT_DRIVERS)) { - /* driver F-Curve */ BLI_remlink(&adt->drivers, fcu); } else if (adt->action) { bAction *act = adt->action; - /* remove from group or action, whichever one "owns" the F-Curve */ + /* Remove from group or action, whichever one "owns" the F-Curve. */ if (fcu->grp) { bActionGroup *agrp = fcu->grp; - /* remove F-Curve from group+action */ + /* Remove F-Curve from group+action. */ action_groups_remove_channel(act, fcu); - /* if group has no more channels, remove it too, + /* If group has no more channels, remove it too, * otherwise can have many dangling groups #33541. */ if (BLI_listbase_is_empty(&agrp->channels)) { @@ -61,7 +60,7 @@ void animdata_fcurve_delete(bAnimContext *ac, AnimData *adt, FCurve *fcu) BLI_remlink(&act->curves, fcu); } - /* if action has no more F-Curves as a result of this, unlink it from + /* If action has no more F-Curves as a result of this, unlink it from * AnimData if it did not come from a NLA Strip being tweaked. * * This is done so that we don't have dangling Object+Action entries in @@ -71,7 +70,6 @@ void animdata_fcurve_delete(bAnimContext *ac, AnimData *adt, FCurve *fcu) animdata_remove_empty_action(adt); } - /* free the F-Curve itself */ BKE_fcurve_free(fcu); } diff --git a/source/blender/animrig/intern/fcurve.cc b/source/blender/animrig/intern/fcurve.cc index 67f1e67888e..51efc3ccc2d 100644 --- a/source/blender/animrig/intern/fcurve.cc +++ b/source/blender/animrig/intern/fcurve.cc @@ -47,10 +47,10 @@ bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra) /* Change the Y position of a keyframe to match the input, adjusting handles. */ static void replace_bezt_keyframe_ypos(BezTriple *dst, const BezTriple *bezt) { - /* just change the values when replacing, so as to not overwrite handles */ + /* Just change the values when replacing, so as to not overwrite handles. */ float dy = bezt->vec[1][1] - dst->vec[1][1]; - /* just apply delta value change to the handle values */ + /* Just apply delta value change to the handle values. */ dst->vec[0][1] += dy; dst->vec[1][1] += dy; dst->vec[2][1] += dy; @@ -66,14 +66,14 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) { int i = 0; - /* are there already keyframes? */ + /* Are there already keyframes? */ if (fcu->bezt) { bool replace; i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace); - /* replace an existing keyframe? */ + /* Replace an existing keyframe? */ if (replace) { - /* sanity check: 'i' may in rare cases exceed arraylen */ + /* 'i' may in rare cases exceed arraylen. */ if ((i >= 0) && (i < fcu->totvert)) { if (flag & INSERTKEY_OVERWRITE_FULL) { fcu->bezt[i] = *bezt; @@ -94,7 +94,7 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) } /* Keyframing modes allow not replacing the keyframe. */ else if ((flag & INSERTKEY_REPLACE) == 0) { - /* insert new - if we're not restricted to replacing keyframes only */ + /* Insert new - if we're not restricted to replacing keyframes only. */ BezTriple *newb = static_cast( MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple")); @@ -104,15 +104,15 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) memcpy(newb, fcu->bezt, i * sizeof(BezTriple)); } - /* add beztriple to paste at index i */ + /* Add beztriple to paste at index i. */ *(newb + i) = *bezt; - /* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */ + /* Add the beztriples that occur after the beztriple to be pasted (originally in fcu). */ if (i < fcu->totvert) { memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple)); } - /* replace (+ free) old with new, only if necessary to do so */ + /* Replace (+ free) old with new, only if necessary to do so. */ MEM_freeN(fcu->bezt); fcu->bezt = newb; @@ -122,26 +122,26 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) return -1; } } - /* no keyframes already, but can only add if... + /* No keyframes yet, but can only add if... * 1) keyframing modes say that keyframes can only be replaced, so adding new ones won't know * 2) there are no samples on the curve * NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, * but for now, having both is asking for trouble */ else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == nullptr)) { - /* create new keyframes array */ + /* Create new keyframes array. */ fcu->bezt = static_cast(MEM_callocN(sizeof(BezTriple), "beztriple")); *(fcu->bezt) = *bezt; fcu->totvert = 1; } - /* cannot add anything */ + /* Cannot add anything. */ else { - /* return error code -1 to prevent any misunderstandings */ + /* Return error code -1 to prevent any misunderstandings. */ return -1; } - /* we need to return the index, so that some tools which do post-processing can - * detect where we added the BezTriple in the array + /* We need to return the index, so that some tools which do post-processing can + * detect where we added the BezTriple in the array. */ return i; } @@ -205,7 +205,7 @@ int insert_vert_fcurve( uint oldTot = fcu->totvert; int a; - /* set all three points, for nicer start position + /* Set all three points, for nicer start position. * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... */ beztr.vec[0][0] = x - 1.0f; @@ -216,23 +216,23 @@ int insert_vert_fcurve( beztr.vec[2][1] = y; beztr.f1 = beztr.f2 = beztr.f3 = SELECT; - /* set default handle types and interpolation mode */ + /* Set default handle types and interpolation mode. */ if (flag & INSERTKEY_NO_USERPREF) { - /* for Py-API, we want scripts to have predictable behavior, - * hence the option to not depend on the userpref defaults + /* For Py-API, we want scripts to have predictable behavior, + * hence the option to not depend on the userpref defaults. */ beztr.h1 = beztr.h2 = HD_AUTO_ANIM; beztr.ipo = BEZT_IPO_BEZ; } else { /* For UI usage - defaults should come from the user-preferences and/or tool-settings. */ - beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */ + beztr.h1 = beztr.h2 = U.keyhandles_new; /* Use default handle type here. */ - /* use default interpolation mode, with exceptions for int/discrete values */ + /* Use default interpolation mode, with exceptions for int/discrete values. */ beztr.ipo = U.ipo_new; } - /* interpolation type used is constrained by the type of values the curve can take */ + /* Interpolation type used is constrained by the type of values the curve can take. */ if (fcu->flag & FCURVE_DISCRETE_VALUES) { beztr.ipo = BEZT_IPO_CONST; } @@ -240,31 +240,30 @@ int insert_vert_fcurve( beztr.ipo = BEZT_IPO_LIN; } - /* set keyframe type value (supplied), which should come from the scene settings in most cases */ + /* Set keyframe type value (supplied), which should come from the scene + * settings in most cases. */ BEZKEYTYPE(&beztr) = keyframe_type; - /* set default values for "easing" interpolation mode settings + /* Set default values for "easing" interpolation mode settings. * NOTE: Even if these modes aren't currently used, if users switch * to these later, we want these to work in a sane way out of * the box. */ - /* "back" easing - this value used to be used when overshoot=0, but that + /* "back" easing - This value used to be used when overshoot=0, but that * introduced discontinuities in how the param worked. */ beztr.back = 1.70158f; - /* "elastic" easing - values here were hand-optimized for a default duration of + /* "elastic" easing - Values here were hand-optimized for a default duration of * ~10 frames (typical mograph motion length) */ beztr.amplitude = 0.8f; beztr.period = 4.1f; - /* add temp beztriple to keyframes */ + /* Add temp beztriple to keyframes. */ a = insert_bezt_fcurve(fcu, &beztr, flag); BKE_fcurve_active_keyframe_set(fcu, &fcu->bezt[a]); - /* what if 'a' is a negative index? - * for now, just exit to prevent any segfaults - */ + /* If `a` is negative return to avoid segfaults. */ if (a < 0) { return -1; } @@ -292,7 +291,7 @@ int insert_vert_fcurve( } } - /* don't recalculate handles if fast is set + /* Don't recalculate handles if fast is set. * - this is a hack to make importers faster * - we may calculate twice (due to auto-handle needing to be calculated twice) */ @@ -300,7 +299,7 @@ int insert_vert_fcurve( BKE_fcurve_handles_recalc(fcu); } - /* return the index at which the keyframe was added */ + /* Return the index at which the keyframe was added. */ return a; }