Page MenuHome

Blend To Neighbour Implementation
ClosedPublic

Authored by Christoph Lendenfeld (ChrisLend) on Oct 28 2020, 4:40 PM.
Tokens
"Love" token, awarded by hitrpr."Pterodactyl" token, awarded by shader."Like" token, awarded by erickblender."Love" token, awarded by Juangra_Membata."Pterodactyl" token, awarded by Gavriel5578."Love" token, awarded by looch.

Details

Summary

This patch adds the blend to neighbour operator to the Graph editor.

The operator acts like the blend to neighbour operator for a pose context, just working on keyframes

Diff Detail

Repository
rB Blender

Event Timeline

Christoph Lendenfeld (ChrisLend) requested review of this revision.Oct 28 2020, 4:40 PM
Christoph Lendenfeld (ChrisLend) created this revision.
Wayde Moss (GuiltyGhost) added inline comments.
source/blender/editors/animation/keyframes_general.c
379–387

Since this is duplicated in a few other patches and likely all future patches with a similar setup, this can potentially be refactored to:

target_bezt = fcurve_segment_start_bezt_get(...)
and
target_bezt = fcurve_segment_end_bezt_get(...)

You can use better names than those if desired.

390–391

There is a lerp function already: (math_base_inline.c) interpf().

397–416

Comparing with the other patches, this duplicated section isn't necessary in any of them. You can refactor them all by creating a variation of find_fcurve_segment that returns a list of all the fcurve segments.

Then the below code can be placed in blend_to_neighbour_graph_keys().

/* Loop through filtered data and blend keys. */
for (ale = anim_data.first; ale; ale = ale->next) {

    ListBase *fcurve_segments = find_fcurve_segments_to_list(...);
    LISTBASE_FOREACH(FCurveSegment* ... segment){
        blend_to_neighbour_fcurve_segment(ale->key_data, segment->start_idx,segment->len, percentage);
    }
    BLI_freelistN(fcurve_segements);
    MEM_freeN(fcurve_segments);

    ale->update |= ANIM_UPDATE_DEFAULT;
}

Which can be further refactored to:

for (ale = anim_data.first; ale; ale = ale->next) {
    process_fcurve_segments(fcu, blend_to_neighbour_fcurve_segment);
    ale->update |= ANIM_UPDATE_DEFAULT;
}

For those that need to do pre/post processing (decimate and sample), they can be kept in specific BLEND_FUNC_fcurve(...) functions so they can be properly re-used.

  • update to latest master
  • extract fcurve_segment_start_get and fcurve_segment_end_get
  • use interpf
Christoph Lendenfeld (ChrisLend) marked 2 inline comments as done.Dec 5 2021, 5:18 PM
  • rename percentage to factor
  • use new function to get list of segments created in D13531
  • factor in blend_to_neighbour_exec can be const
Sybren A. Stüvel (sybren) requested changes to this revision.Dec 13 2021, 3:54 PM

It's really nice to play with this in the graph editor :)
I know for a fact that @Pablo Fournier (pablico) is already waiting for this patch to land.

Everywhere: neighbour → neighbor. I almost missed it, I'm usually also writing (at least trying to write) UK English. Blender is in US English, though ;-)

source/blender/editors/space_graph/graph_slider_ops.c
602

Here you can just declare ale inside the for statement. More modern C, just declare where you need instead of at the top.

609

This is missing a call to BLI_freelistN(&segments);, causing a memory leak.

This revision now requires changes to proceed.Dec 13 2021, 3:54 PM
  • fix memory leak. Thanks for spotting that
  • adapt way of getting segment list after changes to D13531
  • pass FCurveSegment to blend_to_neighbour_fcurve_segment, instead of components separate, as suggested in D9479
  • fix factor property not set in modal

When trying out the slider, I'm getting the warning "Fcurve Slider: Can't work on baked channels. Unbake them and try again." (from graph_slider_invoke()). There are a few issues here:

  1. It's shown as warning, but the operation cannot continue. This means it should be an error, not a warning.
  2. There are no baked channels in my test, so the assumption that gso->bezt_arr_list.first == NULL means "channels are baked" doesn't hold. It just means that store_original_bezt_arrays() didn't find any curves, which could have other reasons as well. It's probably better to change the message to reflect this (like "no editable, selected curves found", or something along those lines). In my particular case, I didn't have any FCurves selected, which means that the ANIMFILTER_SEL flag did its thing.

Apart from that, it's cool to play with :)

Since this is separate from this operator, I submitted a new patch D13655

However this raises something that I did not realise. You can only work on keys if the fcurve is also selected.
It is a separate issue, but I will need to do a test build for others to use and feed back to me.

LGTM, but do do a search & replace "neighbour" → "neighbor" -- Blender uses en_US spelling.

This revision is now accepted and ready to land.Dec 23 2021, 3:48 PM
This revision was automatically updated to reflect the committed changes.