From 98b0bfa9e7dab45b49dbcfccbb2cae175e219bda Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Fri, 17 May 2024 15:56:57 +0200 Subject: [PATCH] Refactor: make yet more fcurve evaluation functions take const fcurves This follows on after #121788. Pull Request: https://projects.blender.org/blender/blender/pulls/121882 --- source/blender/animrig/ANIM_fcurve.hh | 2 +- source/blender/animrig/intern/fcurve.cc | 4 ++-- source/blender/blenkernel/BKE_fcurve.hh | 2 +- source/blender/blenkernel/intern/fcurve.cc | 2 +- source/blender/blenkernel/intern/tracking_solver.cc | 2 +- source/blender/blenkernel/intern/tracking_stabilize.cc | 2 +- source/blender/editors/animation/anim_draw.cc | 2 +- source/blender/editors/armature/pose_slide.cc | 2 +- source/blender/editors/space_graph/graph_select.cc | 7 +++++-- 9 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/blender/animrig/ANIM_fcurve.hh b/source/blender/animrig/ANIM_fcurve.hh index 32f8c5593fd..0c084f16d5d 100644 --- a/source/blender/animrig/ANIM_fcurve.hh +++ b/source/blender/animrig/ANIM_fcurve.hh @@ -94,7 +94,7 @@ SingleKeyingResult insert_vert_fcurve(FCurve *fcu, * \param r_samples: Is expected to be an array large enough to hold `sample_count`. */ void sample_fcurve_segment( - FCurve *fcu, float start_frame, float sample_rate, float *samples, int sample_count); + const FCurve *fcu, float start_frame, float sample_rate, float *samples, int sample_count); enum class BakeCurveRemove { NONE = 0, diff --git a/source/blender/animrig/intern/fcurve.cc b/source/blender/animrig/intern/fcurve.cc index c20d294a595..be06a8190ef 100644 --- a/source/blender/animrig/intern/fcurve.cc +++ b/source/blender/animrig/intern/fcurve.cc @@ -288,7 +288,7 @@ void initialize_bezt(BezTriple *beztr, * that, since that's not how the "only insert needed" feature is supposed to * work. */ -static bool new_key_needed(FCurve &fcu, const float frame, const float value) +static bool new_key_needed(const FCurve &fcu, const float frame, const float value) { if (fcu.totvert == 0) { return true; @@ -376,7 +376,7 @@ SingleKeyingResult insert_vert_fcurve(FCurve *fcu, return SingleKeyingResult::SUCCESS; } -void sample_fcurve_segment(FCurve *fcu, +void sample_fcurve_segment(const FCurve *fcu, const float start_frame, const float sample_rate, float *samples, diff --git a/source/blender/blenkernel/BKE_fcurve.hh b/source/blender/blenkernel/BKE_fcurve.hh index 5f4f6df77a0..25e8eff0f70 100644 --- a/source/blender/blenkernel/BKE_fcurve.hh +++ b/source/blender/blenkernel/BKE_fcurve.hh @@ -599,7 +599,7 @@ void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], con /* evaluate fcurve */ float evaluate_fcurve(const FCurve *fcu, float evaltime); -float evaluate_fcurve_only_curve(FCurve *fcu, float evaltime); +float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime); float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, FCurve *fcu, ChannelDriver *driver_orig, diff --git a/source/blender/blenkernel/intern/fcurve.cc b/source/blender/blenkernel/intern/fcurve.cc index 54198aad8af..19b177e4b40 100644 --- a/source/blender/blenkernel/intern/fcurve.cc +++ b/source/blender/blenkernel/intern/fcurve.cc @@ -2449,7 +2449,7 @@ float evaluate_fcurve(const FCurve *fcu, float evaltime) return evaluate_fcurve_ex(fcu, evaltime, 0.0); } -float evaluate_fcurve_only_curve(FCurve *fcu, float evaltime) +float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime) { /* Can be used to evaluate the (key-framed) f-curve only. * Also works for driver-f-curves when the driver itself is not relevant. diff --git a/source/blender/blenkernel/intern/tracking_solver.cc b/source/blender/blenkernel/intern/tracking_solver.cc index aa6239872b0..6484c696027 100644 --- a/source/blender/blenkernel/intern/tracking_solver.cc +++ b/source/blender/blenkernel/intern/tracking_solver.cc @@ -71,7 +71,7 @@ static libmv_Tracks *libmv_tracks_new(MovieClip *clip, ListBase *tracksbase, int track = static_cast(tracksbase->first); while (track) { - FCurve *weight_fcurve = id_data_find_fcurve( + const FCurve *weight_fcurve = id_data_find_fcurve( &clip->id, track, &RNA_MovieTrackingTrack, "weight", 0, nullptr); for (int a = 0; a < track->markersnr; a++) { diff --git a/source/blender/blenkernel/intern/tracking_stabilize.cc b/source/blender/blenkernel/intern/tracking_stabilize.cc index 886dcd61793..b54d6ac799f 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.cc +++ b/source/blender/blenkernel/intern/tracking_stabilize.cc @@ -137,7 +137,7 @@ static FCurve *retrieve_track_weight_animation(MovieClip *clip, MovieTrackingTra return id_data_find_fcurve(&clip->id, track, &RNA_MovieTrackingTrack, "weight_stab", 0, nullptr); } -static float fetch_from_fcurve(FCurve *animationCurve, +static float fetch_from_fcurve(const FCurve *animationCurve, int framenr, StabContext *ctx, float default_value) diff --git a/source/blender/editors/animation/anim_draw.cc b/source/blender/editors/animation/anim_draw.cc index 14672936322..6a115dd605f 100644 --- a/source/blender/editors/animation/anim_draw.cc +++ b/source/blender/editors/animation/anim_draw.cc @@ -332,7 +332,7 @@ short ANIM_get_normalization_flags(SpaceLink *space_link) } static void fcurve_scene_coord_range_get(Scene *scene, - FCurve *fcu, + const FCurve *fcu, float *r_min_coord, float *r_max_coord) { diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index 9b590d432b5..b233c5ca78a 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -331,7 +331,7 @@ static bool pose_frame_range_from_object_get(tPoseSlideOp *pso, /** * Helper for apply() - perform sliding for some value. */ -static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, float *val) +static void pose_slide_apply_val(tPoseSlideOp *pso, const FCurve *fcu, Object *ob, float *val) { float prev_frame, next_frame; float prev_weight, next_weight; diff --git a/source/blender/editors/space_graph/graph_select.cc b/source/blender/editors/space_graph/graph_select.cc index 83cef45e53b..cc8e3ad51a2 100644 --- a/source/blender/editors/space_graph/graph_select.cc +++ b/source/blender/editors/space_graph/graph_select.cc @@ -689,8 +689,11 @@ static short ok_bezier_always_ok(KeyframeEditData * /*ked*/, BezTriple * /*bezt* #define ABOVE 1 #define INSIDE 0 #define BELOW -1 -static int rectf_curve_zone_y( - FCurve *fcu, const rctf *rectf, const float offset, const float unit_scale, const float eval_x) +static int rectf_curve_zone_y(const FCurve *fcu, + const rctf *rectf, + const float offset, + const float unit_scale, + const float eval_x) { const float fcurve_y = (evaluate_fcurve(fcu, eval_x) + offset) * unit_scale; return fcurve_y < rectf->ymin ? BELOW : fcurve_y <= rectf->ymax ? INSIDE : ABOVE;