Page MenuHome

Fix T97533: Extrapolation regions of NLA strips outside of the current viewport are not rendered.
ClosedPublic

Authored by Colin Basnett (cmbasnett) on Apr 23 2022, 9:40 PM.

Details

Summary

This patch fixes T97533: Extrapolation regions of NLA strips outside of the current viewport are not rendered.

The problem before was that tracks not immediately visible would not be drawn at all. This was problematic because the nla_draw_strip is responsible for drawing the extrapolation region.

The strategy for fixing this was to simply include strips that are visible only because of their extrapolation mode.

To do this, there is now a new function get_visible_nla_strips which gives a first and last NlaStrip that needs to be drawn for a given NlaTrack.

Tagging along with this is the removal of the strip index indicator from the name on meta tracks. Because of the new structure of the code, it would incur a performance penalty to restore the previous behavior (requiring a linear search for the index). Since this number is of virtually no utility to the user anyways (it has the look & feel of developer debugging information), this is something I think we can safely remove without regret.

Old:

New:

Diff Detail

Repository
rB Blender

Event Timeline

Colin Basnett (cmbasnett) requested review of this revision.Apr 23 2022, 9:40 PM
Colin Basnett (cmbasnett) created this revision.

Added the entire file to the diff.

Colin Basnett (cmbasnett) retitled this revision from Fix T97533: Extrapolation regions of NLA strips outside of the current viewport are now rendered to Fix T97533: Extrapolation regions of NLA strips outside of the current viewport are not rendered..May 30 2022, 10:35 AM
Sybren A. Stüvel (sybren) requested changes to this revision.May 30 2022, 12:26 PM

This patch fixes T97533

Thanks! I was already confused by this when testing another NLA patch, so good to see it's solved :)

Tagging along with this is the removal of the strip index indicator from the name on meta tracks. I'm not sure what the point of it is supposed to be, it just seems like debugging information that has no relevance to the user.

At least document why this is removed in the patch description. That way the motivation will find its way into the commit message.

source/blender/editors/space_nla/nla_draw.c
704–707

Comments should be English sentences, so including capitalisation and punctuation. Same for the other comments.

708

static void

708

See https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Naming on naming of function arguments.

Having said that, I think it's better to have this function return a ListBase /* NlaStrip */ instead.

717

Many comments refer to tracks, when they should refer to strips.

725–727

This means that the if and else blocks should just be their own function.

731

if the strips are stored in order, you should be able to break here.

743

This is not what happens in the code. The comment suggests comparison between distances, which doesn't happen.

761

use LISTBASE_FOREACH

762–764

This considers each and every strip that's after the current frame, and if it's preceeded by an extending strip, returns that preceeding strip. This will produce false positives, namely when the actual strip just left of the viewport is NOT extending, but some later strip actually is.

This revision now requires changes to proceed.May 30 2022, 12:26 PM
Colin Basnett (cmbasnett) marked 8 inline comments as done.May 31 2022, 11:57 AM
Colin Basnett (cmbasnett) added inline comments.
source/blender/editors/space_nla/nla_draw.c
725–727

I'm not sure what you mean here. Perhaps the naming was confusing? I've changed it in the updated diff.

762–764

Very good catch. This is a very subtle bug that doesn't actually visually manifest.

Colin Basnett (cmbasnett) marked an inline comment as done.

Addressed feedback by @Sybren A. Stüvel (sybren).

Fixed another warning.

Sybren A. Stüvel (sybren) requested changes to this revision.Jun 2 2022, 11:12 AM
Sybren A. Stüvel (sybren) added inline comments.
source/blender/editors/space_nla/nla_draw.c
711–718

I think the code will clean up a bit if you defer the ListBase construction to a spot later in the function. That way you can do something like this:

if (BLI_listbase_is_empty(&nlt->strips)) {
  ListBase empty = {NULL, NULL};
  return empty;
}

NlaStrip *first = NULL;
NlaStrip *last = NULL;

// ... Do stuff, set first/last

ListBase visible_strips = {first, last};
return visible_strips;

This also makes breaking up this function into smaller bits easier as you can just do something like this, without having to bother passing first and last around:

if (has_strips_within_bounds) {
  return the_first_function(...);
}
return the_other_function(...);
725–727

What I mean is that the need to comments blocks of code, to explain what they do, can be used as an indicator that that particular block should actually be in its own function. Looking at the maximum indentation level of the code below, I think that's actually a good idea.

This revision now requires changes to proceed.Jun 2 2022, 11:12 AM

Addressed feedback to reduce the amount of pointer dereferencing.

Sybren A. Stüvel (sybren) added inline comments.
source/blender/editors/space_nla/nla_draw.c
826

Touching means updating to latest code style ;-)
So start with capital letter and end in a period. I can do this while landing the patch.

This revision is now accepted and ready to land.Jun 21 2022, 3:36 PM