Cleanup: const pointers for FCurves where possible

This commit is contained in:
Campbell Barton
2024-05-21 13:13:09 +10:00
parent 9fdd31d331
commit 57707ca9ae
22 changed files with 46 additions and 43 deletions
+3 -3
View File
@@ -327,7 +327,7 @@ void BKE_keyingsets_blend_read_data(BlendDataReader *reader, ListBase *list)
/* ***************************************** */
/* Evaluation Data-Setting Backend */
static bool is_fcurve_evaluatable(FCurve *fcu)
static bool is_fcurve_evaluatable(const FCurve *fcu)
{
if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) {
return false;
@@ -2615,7 +2615,7 @@ static void nlasnapshot_from_action(PointerRNA *ptr,
const float modified_evaltime = evaluate_time_fmodifiers(
&storage, modifiers, nullptr, 0.0f, evaltime);
LISTBASE_FOREACH (FCurve *, fcu, &action->curves) {
LISTBASE_FOREACH (const FCurve *, fcu, &action->curves) {
if (!is_fcurve_evaluatable(fcu)) {
continue;
}
@@ -3087,7 +3087,7 @@ static void nla_eval_domain_action(PointerRNA *ptr,
return;
}
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
LISTBASE_FOREACH (const FCurve *, fcu, &act->curves) {
/* check if this curve should be skipped */
if (!is_fcurve_evaluatable(fcu)) {
continue;
+1 -1
View File
@@ -1173,7 +1173,7 @@ float BKE_tracking_track_get_weight_for_marker(MovieClip *clip,
MovieTrackingTrack *track,
MovieTrackingMarker *marker)
{
FCurve *weight_fcurve;
const FCurve *weight_fcurve;
float weight = track->weight;
weight_fcurve = id_data_find_fcurve(
+1 -1
View File
@@ -919,7 +919,7 @@ static bool add_driver_button_poll(bContext *C)
}
/* Don't do anything if there is an fcurve for animation without a driver. */
FCurve *fcu = BKE_fcurve_find_by_rna_context_ui(
const FCurve *fcu = BKE_fcurve_find_by_rna_context_ui(
C, &ptr, prop, index, nullptr, nullptr, &driven, &special);
return (fcu == nullptr || fcu->driver);
}
@@ -86,7 +86,7 @@ static PointerRNA *fmodifier_get_pointers(const bContext *C, const Panel *panel,
}
if (C != nullptr && CTX_wm_space_graph(C)) {
FCurve *fcu = ANIM_graph_context_fcurve(C);
const FCurve *fcu = ANIM_graph_context_fcurve(C);
uiLayoutSetActive(panel->layout, !(fcu->flag & FCURVE_MOD_OFF));
}
@@ -1635,7 +1635,7 @@ KeyframeEditFunc ANIM_editkeyframes_select(short selectmode)
static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
{
FCurve *fcu = ked->fcu;
const FCurve *fcu = ked->fcu;
char *map = static_cast<char *>(ked->data);
int i = ked->curIndex;
@@ -1670,7 +1670,7 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
{
FCurve *fcu = ked->fcu;
const FCurve *fcu = ked->fcu;
char *map = static_cast<char *>(ked->data);
int i = ked->curIndex;
@@ -333,7 +333,7 @@ void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
/* ---------------- */
float get_default_rna_value(FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr)
float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr)
{
const int len = RNA_property_array_length(ptr, prop);
@@ -1433,7 +1433,7 @@ static void flip_names(tAnimCopybufItem *aci, char **r_name)
/* ------------------- */
/* most strict method: exact matches only */
static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu,
static tAnimCopybufItem *pastebuf_match_path_full(const FCurve *fcu,
const short from_single,
const short to_simple,
bool flip)
@@ -1466,7 +1466,7 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu,
/* medium match strictness: path match only (i.e. ignore ID) */
static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
FCurve *fcu,
const FCurve *fcu,
const short from_single,
const short /*to_simple*/)
{
@@ -1517,7 +1517,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
}
/* least strict matching heuristic: indices only */
static tAnimCopybufItem *pastebuf_match_index_only(FCurve *fcu,
static tAnimCopybufItem *pastebuf_match_index_only(const FCurve *fcu,
const short from_single,
const short /*to_simple*/)
{
@@ -577,7 +577,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
*/
static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
{
FCurve *fcu_w = nullptr, *fcu_x = nullptr, *fcu_y = nullptr, *fcu_z = nullptr;
const FCurve *fcu_w = nullptr, *fcu_x = nullptr, *fcu_y = nullptr, *fcu_z = nullptr;
bPoseChannel *pchan = pfl->pchan;
LinkData *ld = nullptr;
char *path = nullptr;
@@ -1751,7 +1751,7 @@ static float find_last_key(ListBase *pflinks)
float target_frame = FLT_MIN;
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, pflinks) {
LISTBASE_FOREACH (LinkData *, ld, &pfl->fcurves) {
FCurve *fcu = (FCurve *)ld->data;
const FCurve *fcu = (const FCurve *)ld->data;
if (!fcu->bezt) {
continue;
}
@@ -323,7 +323,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con
/* check each link to see if the linked F-Curve has a matching path */
for (ld = first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
const FCurve *fcu = (const FCurve *)ld->data;
/* check if paths match */
if (STREQ(path, fcu->rna_path)) {
@@ -966,7 +966,8 @@ short ANIM_get_normalization_flags(SpaceLink *space_link);
/**
* Get unit conversion factor for given ID + F-Curve.
*/
float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag, float *r_offset);
float ANIM_unit_mapping_get_factor(
Scene *scene, const ID *id, FCurve *fcu, short flag, float *r_offset);
/** \} */
@@ -417,7 +417,7 @@ bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, con
/* Destructive Editing API `keyframes_general.cc`. */
bool duplicate_fcurve_keys(FCurve *fcu);
float get_default_rna_value(FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr);
float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr);
struct FCurveSegment {
FCurveSegment *next, *prev;
@@ -1045,7 +1045,7 @@ static void ui_context_fcurve_modifiers_via_fcurve(bContext *C,
}
r_lb->clear();
for (const PointerRNA &ptr : fcurve_links) {
FCurve *fcu = static_cast<FCurve *>(ptr.data);
const FCurve *fcu = static_cast<const FCurve *>(ptr.data);
LISTBASE_FOREACH (FModifier *, mod, &fcu->modifiers) {
if (STREQ(mod->name, source->name) && mod->type == source->type) {
r_lb->append(RNA_pointer_create(ptr.owner_id, &RNA_FModifier, mod));
@@ -1616,7 +1616,7 @@ blender::Vector<FCurve *> get_property_drivers(
* nullptr, return an empty vector for clarity. That way the caller gets
* either a useful result or an empty one. */
bool fetched_at_least_one = false;
for (FCurve *driver : drivers) {
for (const FCurve *driver : drivers) {
fetched_at_least_one |= driver != nullptr;
}
if (!fetched_at_least_one) {
+2 -2
View File
@@ -194,7 +194,7 @@ static void sound_update_animation_flags(Scene *scene);
static bool sound_update_animation_flags_fn(Sequence *seq, void *user_data)
{
FCurve *fcu;
const FCurve *fcu;
Scene *scene = (Scene *)user_data;
bool driven;
@@ -234,7 +234,7 @@ static bool sound_update_animation_flags_fn(Sequence *seq, void *user_data)
static void sound_update_animation_flags(Scene *scene)
{
FCurve *fcu;
const FCurve *fcu;
bool driven;
if (scene->id.tag & LIB_TAG_DOIT) {
@@ -47,13 +47,13 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu);
* drawing components for some F-Curve (fcu)
* - selected F-Curves should be more visible than partially visible ones
*/
static float fcurve_display_alpha(FCurve *fcu)
static float fcurve_display_alpha(const FCurve *fcu)
{
return (fcu->flag & FCURVE_SELECTED) ? 1.0f : U.fcu_inactive_alpha;
}
/** Get the first and last index to the bezt array that are just outside min and max. */
static blender::IndexRange get_bounding_bezt_index_range(FCurve *fcu,
static blender::IndexRange get_bounding_bezt_index_range(const FCurve *fcu,
const float min,
const float max)
{
@@ -415,7 +415,7 @@ static void draw_fcurve_vertices(ARegion *region,
/* Handles ---------------- */
static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
static bool draw_fcurve_handles_check(const SpaceGraph *sipo, const FCurve *fcu)
{
/* don't draw handle lines if handles are not to be shown */
if (/* handles shouldn't be shown anywhere */
@@ -437,7 +437,7 @@ static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
/* draw lines for F-Curve handles only (this is only done in EditMode)
* NOTE: draw_fcurve_handles_check must be checked before running this. */
static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, FCurve *fcu)
static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve *fcu)
{
using namespace blender;
@@ -538,7 +538,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, FCurve *fcu)
/* Samples ---------------- */
/* helper func - draw keyframe vertices only for an F-Curve */
static void draw_fcurve_samples(ARegion *region, FCurve *fcu, const float unit_scale)
static void draw_fcurve_samples(ARegion *region, const FCurve *fcu, const float unit_scale)
{
FPoint *first, *last;
float scale[2];
@@ -585,7 +585,7 @@ static void draw_fcurve_samples(ARegion *region, FCurve *fcu, const float unit_s
* (for drawing curves with modifiers). */
static void draw_fcurve_curve(bAnimContext *ac,
ID *id,
FCurve *fcu_,
const FCurve *fcu_,
View2D *v2d,
uint pos,
const bool use_nla_remap,
@@ -903,7 +903,7 @@ static void add_bezt_vertices(BezTriple *bezt,
MEM_freeN(bezier_diff_points);
}
static void add_extrapolation_point_left(FCurve *fcu,
static void add_extrapolation_point_left(const FCurve *fcu,
const float v2d_xmin,
blender::Vector<blender::float2> &curve_vertices)
{
@@ -940,7 +940,7 @@ static void add_extrapolation_point_left(FCurve *fcu,
curve_vertices.append(vertex_position);
}
static void add_extrapolation_point_right(FCurve *fcu,
static void add_extrapolation_point_right(const FCurve *fcu,
const float v2d_xmax,
blender::Vector<blender::float2> &curve_vertices)
{
@@ -703,8 +703,11 @@ static int rectf_curve_zone_y(const FCurve *fcu,
* only keyframes, but also all the interpolated values). This is done by sampling the curve at
* different points between the xmin and the xmax of the rectangle.
*/
static bool rectf_curve_intersection(
const float offset, const float unit_scale, const rctf *rectf, AnimData *adt, FCurve *fcu)
static bool rectf_curve_intersection(const float offset,
const float unit_scale,
const rctf *rectf,
AnimData *adt,
const FCurve *fcu)
{
/* 30 sampling points. This worked well in tests. */
int num_steps = 30;
@@ -159,7 +159,7 @@ static void store_original_bezt_arrays(tGraphSliderOp *gso)
/* Loop through filtered data and copy the curves. */
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
const FCurve *fcu = (const FCurve *)ale->key_data;
if (fcu->bezt == nullptr) {
/* This curve is baked, skip it. */
@@ -138,7 +138,7 @@ bool graphop_visible_keyframes_poll(bContext *C)
}
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->data;
const FCurve *fcu = (const FCurve *)ale->data;
/* visible curves for selection must fulfill the following criteria:
* - it has bezier keyframes
@@ -192,7 +192,7 @@ bool graphop_editable_keyframes_poll(bContext *C)
}
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->data;
const FCurve *fcu = (const FCurve *)ale->data;
/* editable curves must fulfill the following criteria:
* - it has bezier keyframes
@@ -247,7 +247,7 @@ bool graphop_active_fcurve_poll(bContext *C)
*/
has_fcurve = ((ale->data) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE));
if (has_fcurve) {
FCurve *fcu = (FCurve *)ale->data;
const FCurve *fcu = (const FCurve *)ale->data;
has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0;
}
+1 -1
View File
@@ -308,7 +308,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uin
/* influence -------------------------- */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
FCurve *fcu = BKE_fcurve_find(&strip->fcurves, "influence", 0);
const FCurve *fcu = BKE_fcurve_find(&strip->fcurves, "influence", 0);
/* plot the curve (over the strip's main region) */
if (fcu) {
@@ -502,7 +502,7 @@ static void draw_seq_waveform_overlay(TimelineDrawContext *timeline_ctx,
}
/* F-Curve lookup is quite expensive, so do this after precondition. */
FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, nullptr);
const FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, nullptr);
/* Draw zero line (when actual samples close to zero are drawn, they might not cover a pixel. */
uchar color[4] = {255, 255, 255, 127};
@@ -1394,7 +1394,7 @@ static void draw_seq_fcurve_overlay(TimelineDrawContext *timeline_ctx,
const int eval_step = max_ii(1, floor(timeline_ctx->pixelx));
uchar color[4] = {0, 0, 0, 38};
FCurve *fcu;
const FCurve *fcu;
if (strip_ctx->seq->type == SEQ_TYPE_SOUND_RAM) {
fcu = id_data_find_fcurve(&scene->id, strip_ctx->seq, &RNA_Sequence, "volume", 0, nullptr);
}
@@ -1336,7 +1336,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
COLLADABU::Math::Matrix4 matrix;
int mi = 0, mj = 0;
for (FCurve *curve : curves) {
for (const FCurve *curve : curves) {
matrix.setElement(mi, mj, evaluate_fcurve(curve, fra));
mj++;
if (mj == 4) {
@@ -101,7 +101,6 @@ static bool is_object_keyframe(Object *ob, int frame_index)
static void add_keyframes_from(bAction *action, BCFrameSet &frameset)
{
if (action) {
FCurve *fcu = nullptr;
LISTBASE_FOREACH (FCurve *, fcu, &action->curves) {
BezTriple *bezt = fcu->bezt;
for (int i = 0; i < fcu->totvert; bezt++, i++) {
+2 -2
View File
@@ -2190,7 +2190,7 @@ void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq)
return; /* Make COVERITY happy and check for (CID 598) input strip. */
}
FCurve *fcu = seq_effect_speed_speed_factor_curve_get(scene, seq);
const FCurve *fcu = seq_effect_speed_speed_factor_curve_get(scene, seq);
if (fcu == nullptr) {
return;
}
@@ -2249,7 +2249,7 @@ float seq_speed_effect_target_frame_get(Scene *scene,
break;
}
case SEQ_SPEED_MULTIPLY: {
FCurve *fcu = seq_effect_speed_speed_factor_curve_get(scene, seq_speed);
const FCurve *fcu = seq_effect_speed_speed_factor_curve_get(scene, seq_speed);
if (fcu != nullptr) {
seq_effect_speed_frame_map_ensure(scene, seq_speed);
target_frame = s->frameMap[frame_index];
+1 -1
View File
@@ -883,7 +883,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
float fac;
int i;
SeqEffectHandle sh = SEQ_effect_handle_get(seq);
FCurve *fcu = nullptr;
const FCurve *fcu = nullptr;
ImBuf *ibuf[3];
Sequence *input[3];
ImBuf *out = nullptr;