From f9aa6376f1a2b13ab12a77197257e9145f029792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 6 Jan 2022 11:37:31 +0100 Subject: Cleanup: anim, remove `const` declarations from pass-by-value params Remove `const` from pass-by-value parameters in function declarations. The variables passed as parameters can never be modified by the function anyway, so declaring them as `const` is meaningless. Having the declaration there could confuse, especially as it suggests it does have a meaning, training people to write meaningless code. --- source/blender/blenkernel/BKE_action.h | 12 +++++----- source/blender/blenkernel/BKE_anim_data.h | 11 ++++----- source/blender/blenkernel/BKE_animsys.h | 12 +++++----- source/blender/blenkernel/BKE_armature.h | 26 +++++++++++----------- source/blender/blenkernel/BKE_brush.h | 4 ++-- source/blender/blenkernel/BKE_constraint.h | 8 +++---- source/blender/blenkernel/BKE_fcurve.h | 26 +++++++++++----------- source/blender/blenkernel/BKE_nla.h | 20 ++++++++--------- source/blender/blenkernel/nla_private.h | 14 ++++++------ source/blender/editors/include/ED_keyframes_edit.h | 6 ++--- source/blender/editors/space_graph/graph_intern.h | 4 ++-- 11 files changed, 67 insertions(+), 76 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 5dd98dbb9a3..0b09bfd8730 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -235,9 +235,9 @@ void BKE_pose_free_ex(struct bPose *pose, bool do_id_user); */ void BKE_pose_copy_data_ex(struct bPose **dst, const struct bPose *src, - const int flag, - const bool copy_constraints); -void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, const bool copy_constraints); + int flag, + bool copy_constraints); +void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, bool copy_constraints); /** * Copy the internal members of each pose channel including constraints * and ID-Props, used when duplicating bones in edit-mode. @@ -266,7 +266,7 @@ bool BKE_pose_is_layer_visible(const struct bArmature *arm, const struct bPoseCh * \return #bPoseChannel if found or NULL. * \note #Object, not #bPose is used here, as we need info (layer/active bone) from Armature. */ -struct bPoseChannel *BKE_pose_channel_active(struct Object *ob, const bool check_arm_layer); +struct bPoseChannel *BKE_pose_channel_active(struct Object *ob, bool check_arm_layer); /** * Find the active pose-channel for an object if it is on a visible armature layer * (calls #BKE_pose_channel_active with check_arm_layer set to true) @@ -346,11 +346,11 @@ struct bActionGroup *BKE_pose_add_group(struct bPose *pose, const char *name); * Remove the given bone-group (expects 'virtual' index (+1 one, used by active_group etc.)) * index might be invalid ( < 1), in which case it will be find from grp. */ -void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, const int index); +void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, int index); /** * Remove the indexed bone-group (expects 'virtual' index (+1 one, used by active_group etc.)). */ -void BKE_pose_remove_group_index(struct bPose *pose, const int index); +void BKE_pose_remove_group_index(struct bPose *pose, int index); /* Assorted Evaluation ----------------- */ diff --git a/source/blender/blenkernel/BKE_anim_data.h b/source/blender/blenkernel/BKE_anim_data.h index a65efbd707c..bee8bde989c 100644 --- a/source/blender/blenkernel/BKE_anim_data.h +++ b/source/blender/blenkernel/BKE_anim_data.h @@ -46,7 +46,7 @@ struct bAction; /** * Check if the given ID-block can have AnimData. */ -bool id_type_can_have_animdata(const short id_type); +bool id_type_can_have_animdata(short id_type); bool id_can_have_animdata(const struct ID *id); /** @@ -84,7 +84,7 @@ bool BKE_animdata_action_ensure_idroot(const struct ID *owner, struct bAction *a /** * Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer. */ -void BKE_animdata_free(struct ID *id, const bool do_id_user); +void BKE_animdata_free(struct ID *id, bool do_id_user); /** * Return true if the ID-block has non-empty AnimData. @@ -103,17 +103,14 @@ void BKE_animdata_foreach_id(struct AnimData *adt, struct LibraryForeachIDData * * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h * \return The copied animdata. */ -struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag); +struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, int flag); /** * \param flag: Control ID pointers management, * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h * \return true is successfully copied. */ -bool BKE_animdata_copy_id(struct Main *bmain, - struct ID *id_to, - struct ID *id_from, - const int flag); +bool BKE_animdata_copy_id(struct Main *bmain, struct ID *id_to, struct ID *id_from, int flag); /** * Copy AnimData Actions. diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index d5183891296..4845807de39 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -184,9 +184,9 @@ void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain, const char *prefix, const char *oldName, const char *newName, - const int oldSubscript, - const int newSubscript, - const bool verify_paths); + int oldSubscript, + int newSubscript, + bool verify_paths); /** See #BKE_animdata_fix_paths_rename_all_ex */ void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, @@ -299,13 +299,13 @@ typedef enum eAnimData_Recalc { bool BKE_animsys_rna_path_resolve(struct PointerRNA *ptr, const char *rna_path, - const int array_index, + int array_index, struct PathResolvedRNA *r_result); bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value); /** * Write the given value to a setting using RNA, and return success. */ -bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, const float value); +bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value); /** * Evaluation loop for evaluation animation data @@ -318,7 +318,7 @@ void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, - const bool flush_to_original); + bool flush_to_original); /** * Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index fcba7d9d365..8584ce6f508 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -152,13 +152,13 @@ typedef struct PoseTree { struct bArmature *BKE_armature_add(struct Main *bmain, const char *name); struct bArmature *BKE_armature_from_object(struct Object *ob); int BKE_armature_bonelist_count(const struct ListBase *lb); -void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user); -void BKE_armature_editbonelist_free(struct ListBase *lb, const bool do_id_user); +void BKE_armature_bonelist_free(struct ListBase *lb, bool do_id_user); +void BKE_armature_editbonelist_free(struct ListBase *lb, bool do_id_user); void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst, const struct bArmature *armature_src); -void BKE_armature_transform(struct bArmature *arm, const float mat[4][4], const bool do_props); +void BKE_armature_transform(struct bArmature *arm, const float mat[4][4], bool do_props); /* Bounding box. */ struct BoundBox *BKE_armature_boundbox_get(struct Object *ob); @@ -206,7 +206,7 @@ void BKE_armature_where_is(struct bArmature *arm); */ void BKE_armature_where_is_bone(struct Bone *bone, const struct Bone *bone_parent, - const bool use_recursion); + bool use_recursion); /** * Clear pointers of object's pose * (needed in remap case, since we cannot always wait for a complete pose rebuild). @@ -217,7 +217,7 @@ void BKE_pose_remap_bone_pointers(struct bArmature *armature, struct bPose *pose * Update the links for the B-Bone handles from Bone data. */ void BKE_pchan_rebuild_bbone_handles(struct bPose *pose, struct bPoseChannel *pchan); -void BKE_pose_channels_clear_with_null_bone(struct bPose *pose, const bool do_id_user); +void BKE_pose_channels_clear_with_null_bone(struct bPose *pose, bool do_id_user); /** * Only after leave edit-mode, duplicating, validating older files, library syncing. * @@ -228,7 +228,7 @@ void BKE_pose_channels_clear_with_null_bone(struct bPose *pose, const bool do_id void BKE_pose_rebuild(struct Main *bmain, struct Object *ob, struct bArmature *arm, - const bool do_id_user); + bool do_id_user); /** * Ensures object's pose is rebuilt if needed. * @@ -237,7 +237,7 @@ void BKE_pose_rebuild(struct Main *bmain, void BKE_pose_ensure(struct Main *bmain, struct Object *ob, struct bArmature *arm, - const bool do_id_user); + bool do_id_user); /** * \note This is the only function adding poses. * \note This only reads anim data from channels, and writes to channels. @@ -279,12 +279,12 @@ void BKE_pose_apply_action_blend(struct Object *ob, struct AnimationEvalContext *anim_eval_context, float blend_factor); -void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]); +void vec_roll_to_mat3(const float vec[3], float roll, float r_mat[3][3]); /** * Calculates the rest matrix of a bone based on its vector and a roll around that vector. */ -void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]); +void vec_roll_to_mat3_normalized(const float nor[3], float roll, float r_mat[3][3]); /** * Computes vector and roll based on a rotation. * "mat" must contain only a rotation, and no scaling. @@ -484,7 +484,7 @@ void BKE_pchan_bbone_handles_get(struct bPoseChannel *pchan, * Compute B-Bone spline parameters for the given channel. */ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan, - const bool rest, + bool rest, struct BBoneSplineParameters *r_param); /** @@ -492,8 +492,8 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan, * This calculation is done within unit bone space. */ void BKE_pchan_bbone_spline_setup(struct bPoseChannel *pchan, - const bool rest, - const bool for_deform, + bool rest, + bool for_deform, Mat4 *result_array); /** @@ -511,7 +511,7 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param, * This calculation is done within unit bone space. */ int BKE_pchan_bbone_spline_compute(struct BBoneSplineParameters *param, - const bool for_deform, + bool for_deform, Mat4 *result_array); /** diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index a0f3733588a..bf672507c13 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -111,11 +111,11 @@ void BKE_brush_curve_preset(struct Brush *b, enum eCurveMappingPreset preset); /** * Uses the brush curve control to find a strength value between 0 and 1. */ -float BKE_brush_curve_strength_clamped(const struct Brush *br, float p, const float len); +float BKE_brush_curve_strength_clamped(const struct Brush *br, float p, float len); /** * Uses the brush curve control to find a strength value. */ -float BKE_brush_curve_strength(const struct Brush *br, float p, const float len); +float BKE_brush_curve_strength(const struct Brush *br, float p, float len); /* Sampling. */ diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 1f59efbb0f3..55e5cd0a149 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -162,9 +162,7 @@ void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list); /** * Allocate and duplicate a single constraint, outside of any object/pose context. */ -struct bConstraint *BKE_constraint_duplicate_ex(struct bConstraint *src, - const int flag, - const bool do_extern); +struct bConstraint *BKE_constraint_duplicate_ex(struct bConstraint *src, int flag, bool do_extern); /** * Add a copy of the given constraint for the given bone. @@ -188,7 +186,7 @@ void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool */ void BKE_constraints_copy_ex(struct ListBase *dst, const struct ListBase *src, - const int flag, + int flag, bool do_extern); /** * Run the given callback on all ID-blocks in list of constraints. @@ -319,7 +317,7 @@ void BKE_constraint_mat_convertspace(struct Object *ob, float mat[4][4], short from, short to, - const bool keep_scale); + bool keep_scale); /** * This function is a relic from the prior implementations of the constraints system, when all diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 1537d14ab01..121ec7f316b 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -143,7 +143,7 @@ const FModifierTypeInfo *fmodifier_get_typeinfo(const struct FModifier *fcm); * This function should be used for getting the appropriate type-info when only * a F-Curve modifier type is known. */ -const FModifierTypeInfo *get_fmodifier_typeinfo(const int type); +const FModifierTypeInfo *get_fmodifier_typeinfo(int type); /* ---------------------- */ @@ -266,7 +266,7 @@ void BKE_fcurve_foreach_id(struct FCurve *fcu, struct LibraryForeachIDData *data * Find the F-Curve affecting the given RNA-access path + index, * in the list of F-Curves provided. */ -struct FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_index); +struct FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index); /** * Quick way to loop over all f-curves of a given 'path'. @@ -322,8 +322,8 @@ struct FCurve *BKE_fcurve_find_by_rna_context_ui(struct bContext *C, * Returns the index to insert at (data already at that index will be offset if replace is 0) */ int BKE_fcurve_bezt_binarysearch_index(const struct BezTriple array[], - const float frame, - const int arraylen, + float frame, + int arraylen, bool *r_replace); /* fcurve_cache.c */ @@ -336,7 +336,7 @@ struct FCurvePathCache *BKE_fcurve_pathcache_create(ListBase *list); void BKE_fcurve_pathcache_destroy(struct FCurvePathCache *fcache); struct FCurve *BKE_fcurve_pathcache_find(struct FCurvePathCache *fcache, const char rna_path[], - const int array_index); + int array_index); /** * Fill in an array of F-Curve, leave NULL when not found. * @@ -351,7 +351,7 @@ int BKE_fcurve_pathcache_find_array(struct FCurvePathCache *fcache, * Calculate the extents of F-Curve's keyframes. */ bool BKE_fcurve_calc_range( - struct FCurve *fcu, float *min, float *max, const bool do_sel_only, const bool do_min_length); + struct FCurve *fcu, float *min, float *max, bool do_sel_only, bool do_min_length); /** * Calculate the extents of F-Curve's data. @@ -361,8 +361,8 @@ bool BKE_fcurve_calc_bounds(struct FCurve *fcu, float *xmax, float *ymin, float *ymax, - const bool do_sel_only, - const bool include_handles); + bool do_sel_only, + bool include_handles); /** * Return an array of keyed frames, rounded to `interval`. @@ -373,11 +373,11 @@ bool BKE_fcurve_calc_bounds(struct FCurve *fcu, * however this risks very small differences in float values being treated as separate keyframes. */ float *BKE_fcurves_calc_keyed_frames_ex(struct FCurve **fcurve_array, - const int fcurve_array_len, - const float interval, + int fcurve_array_len, + float interval, int *r_frames_len); float *BKE_fcurves_calc_keyed_frames(struct FCurve **fcurve_array, - const int fcurve_array_len, + int fcurve_array_len, int *r_frames_len); /** @@ -472,7 +472,7 @@ void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag); * \param use_handle: Check selection state of individual handles, otherwise always update both * handles if the key is selected. */ -void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_handle); +void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, bool use_handle); /** * This function sorts BezTriples so that they are arranged in chronological order, * as tools working on F-Curves expect that the BezTriples are in order. @@ -546,7 +546,7 @@ void fcurve_store_samples( /** * Convert baked/sampled f-curves into bezt/regular f-curves. */ -void fcurve_samples_to_keyframes(struct FCurve *fcu, const int start, const int end); +void fcurve_samples_to_keyframes(struct FCurve *fcu, int start, int end); /* ************* F-Curve .blend file API ******************** */ diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index b297851ad90..61431547bfb 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -71,8 +71,8 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user); */ struct NlaStrip *BKE_nlastrip_copy(struct Main *bmain, struct NlaStrip *strip, - const bool use_same_action, - const int flag); + bool use_same_action, + int flag); /** * Copy a single NLA Track. * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... @@ -80,14 +80,14 @@ struct NlaStrip *BKE_nlastrip_copy(struct Main *bmain, */ struct NlaTrack *BKE_nlatrack_copy(struct Main *bmain, struct NlaTrack *nlt, - const bool use_same_actions, - const int flag); + bool use_same_actions, + int flag); /** * Copy all NLA data. * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... * flags in BKE_lib_id.h */ -void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, const ListBase *src, const int flag); +void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, const ListBase *src, int flag); /** * Copy NLA tracks from #adt_source to #adt_dest, and update the active track/strip pointers to @@ -115,7 +115,7 @@ struct NlaStrip *BKE_nlastrip_new(struct bAction *act); */ struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt, struct bAction *act, - const bool is_liboverride); + bool is_liboverride); /** * Add a NLA Strip referencing the given speaker's sound. */ @@ -217,9 +217,7 @@ void BKE_nlatrack_sort_strips(struct NlaTrack *nlt); * Add the given NLA-Strip to the given NLA-Track, assuming that it * isn't currently attached to another one. */ -bool BKE_nlatrack_add_strip(struct NlaTrack *nlt, - struct NlaStrip *strip, - const bool is_liboverride); +bool BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip, bool is_liboverride); /** * Get the extents of the given NLA-Track including gaps between strips, @@ -309,7 +307,7 @@ bool BKE_nla_action_is_stashed(struct AnimData *adt, struct bAction *act); * "Stash" an action (i.e. store it as a track/layer in the NLA, but non-contributing) * to retain it in the file for future uses. */ -bool BKE_nla_action_stash(struct AnimData *adt, const bool is_liboverride); +bool BKE_nla_action_stash(struct AnimData *adt, bool is_liboverride); /* ............ */ @@ -321,7 +319,7 @@ bool BKE_nla_action_stash(struct AnimData *adt, const bool is_liboverride); * * TODO: maybe we should have checks for this too. */ -void BKE_nla_action_pushdown(struct AnimData *adt, const bool is_liboverride); +void BKE_nla_action_pushdown(struct AnimData *adt, bool is_liboverride); /** * Find the active strip + track combination, and set them up as the tweaking track, diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h index 93014c1b859..c338540b5f5 100644 --- a/source/blender/blenkernel/nla_private.h +++ b/source/blender/blenkernel/nla_private.h @@ -185,7 +185,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short index, const struct AnimationEvalContext *anim_eval_context, - const bool flush_to_original); + bool flush_to_original); /** * Evaluates the given evaluation strip. */ @@ -195,14 +195,14 @@ void nlastrip_evaluate(PointerRNA *ptr, NlaEvalStrip *nes, NlaEvalSnapshot *snapshot, const struct AnimationEvalContext *anim_eval_context, - const bool flush_to_original); + bool flush_to_original); /** * write the accumulated settings to. */ void nladata_flush_channels(PointerRNA *ptr, NlaEvalData *channels, NlaEvalSnapshot *snapshot, - const bool flush_to_original); + bool flush_to_original); void nlasnapshot_enable_all_blend_domain(NlaEvalSnapshot *snapshot); @@ -219,8 +219,8 @@ void nlasnapshot_ensure_channels(NlaEvalData *eval_data, NlaEvalSnapshot *snapsh void nlasnapshot_blend(NlaEvalData *eval_data, NlaEvalSnapshot *lower_snapshot, NlaEvalSnapshot *upper_snapshot, - const short upper_blendmode, - const float upper_influence, + short upper_blendmode, + float upper_influence, NlaEvalSnapshot *r_blended_snapshot); /** @@ -234,8 +234,8 @@ void nlasnapshot_blend(NlaEvalData *eval_data, void nlasnapshot_blend_get_inverted_upper_snapshot(NlaEvalData *eval_data, NlaEvalSnapshot *lower_snapshot, NlaEvalSnapshot *blended_snapshot, - const short upper_blendmode, - const float upper_influence, + short upper_blendmode, + float upper_influence, NlaEvalSnapshot *r_upper_snapshot); #ifdef __cplusplus diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index d08abf8aab8..a7b580d5257 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -398,10 +398,8 @@ void clean_fcurve(struct bAnimContext *ac, bool cleardefault); void blend_to_neighbor_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, - const float factor); -void breakdown_fcurve_segment(struct FCurve *fcu, - struct FCurveSegment *segment, - const float factor); + float factor); +void breakdown_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max); /** * Use a weighted moving-means method to reduce intensity of fluctuations. diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 286580b5629..243a4ee4b95 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -109,8 +109,8 @@ void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmax, float *ymin, float *ymax, - const bool do_sel_only, - const bool include_handles); + bool do_sel_only, + bool include_handles); void GRAPH_OT_previewrange_set(struct wmOperatorType *ot); void GRAPH_OT_view_all(struct wmOperatorType *ot); -- cgit v1.2.3