diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-23 17:24:50 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-23 17:24:50 +0300 |
commit | 85e3e3be5b845a4a40cc1a45901602970a24457f (patch) | |
tree | 8a8e1de4a3360de9e5fe325c0d9894cf1c045c35 | |
parent | 82d7234ed97f3ec1c0d4b7f8d752e69de2101d05 (diff) | |
parent | aea59428eba1322bbc413da7fc70d1a709162fa7 (diff) |
Merge branch 'blender-v3.2-release'
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 79 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/surface_lib.glsl | 4 |
2 files changed, 52 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 5d804f53779..a5f6c453ed4 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -244,24 +244,38 @@ void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, const ListBase *src, const } } -/* Set adt_dest->actstrip to the strip with the same index as adt_source->actstrip. */ -static void update_active_strip(AnimData *adt_dest, - NlaTrack *track_dest, - const AnimData *adt_source, - NlaTrack *track_source) +static void update_active_strip_from_listbase(AnimData *adt_dest, + NlaTrack *track_dest, + const NlaStrip *active_strip, + const ListBase /* NlaStrip */ *strips_source) { - BLI_assert(BLI_listbase_count(&track_source->strips) == BLI_listbase_count(&track_dest->strips)); - NlaStrip *strip_dest = track_dest->strips.first; - LISTBASE_FOREACH (NlaStrip *, strip_source, &track_source->strips) { - if (strip_source == adt_source->actstrip) { + LISTBASE_FOREACH (const NlaStrip *, strip_source, strips_source) { + if (strip_source == active_strip) { adt_dest->actstrip = strip_dest; + return; + } + + if (strip_source->type == NLASTRIP_TYPE_META) { + update_active_strip_from_listbase(adt_dest, track_dest, active_strip, &strip_source->strips); } strip_dest = strip_dest->next; } } +/* Set adt_dest->actstrip to the strip with the same index as adt_source->actstrip. */ +static void update_active_strip(AnimData *adt_dest, + NlaTrack *track_dest, + const AnimData *adt_source, + const NlaTrack *track_source) +{ + BLI_assert(BLI_listbase_count(&track_source->strips) == BLI_listbase_count(&track_dest->strips)); + + update_active_strip_from_listbase( + adt_dest, track_dest, adt_source->actstrip, &track_source->strips); +} + /* Set adt_dest->act_track to the track with the same index as adt_source->act_track. */ static void update_active_track(AnimData *adt_dest, const AnimData *adt_source) { @@ -272,20 +286,20 @@ static void update_active_track(AnimData *adt_dest, const AnimData *adt_source) LISTBASE_FOREACH (NlaTrack *, track_source, &adt_source->nla_tracks) { if (track_source == adt_source->act_track) { adt_dest->act_track = track_dest; - /* Assumption: the active strip is on the active track. */ - update_active_strip(adt_dest, track_dest, adt_source, track_source); } + update_active_strip(adt_dest, track_dest, adt_source, track_source); track_dest = track_dest->next; } - /* If the above assumption failed to hold, do a more thorough search for the active strip. */ - if (adt_source->actstrip != NULL && adt_dest->actstrip == NULL) { - nla_tweakmode_find_active(&adt_source->nla_tracks, &track_dest, &adt_dest->actstrip); +#ifndef NDEBUG + { + const bool source_has_actstrip = adt_source->actstrip != NULL; + const bool dest_has_actstrip = adt_dest->actstrip != NULL; + BLI_assert_msg(source_has_actstrip == dest_has_actstrip, + "Active strip did not copy correctly"); } - - BLI_assert_msg((adt_source->actstrip == NULL) == (adt_dest->actstrip == NULL), - "Active strip did not copy correctly"); +#endif } void BKE_nla_tracks_copy_from_adt(Main *bmain, @@ -1171,26 +1185,35 @@ bool BKE_nlatrack_is_nonlocal_in_liboverride(const ID *id, const NlaTrack *nlt) /* NLA Strips -------------------------------------- */ -NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt) +static NlaStrip *nlastrip_find_active(ListBase /* NlaStrip */ *strips) { - NlaStrip *strip; - - /* sanity check */ - if (ELEM(NULL, nlt, nlt->strips.first)) { - return NULL; - } - - /* try to find the first active strip */ - for (strip = nlt->strips.first; strip; strip = strip->next) { + LISTBASE_FOREACH (NlaStrip *, strip, strips) { if (strip->flag & NLASTRIP_FLAG_ACTIVE) { return strip; } + + if (strip->type != NLASTRIP_TYPE_META) { + continue; + } + + NlaStrip *inner_active = nlastrip_find_active(&strip->strips); + if (inner_active != NULL) { + return inner_active; + } } - /* none found */ return NULL; } +NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt) +{ + if (nlt == NULL) { + return NULL; + } + + return nlastrip_find_active(&nlt->strips); +} + void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip) { NlaTrack *nlt; diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl index 23324146b7e..8e1bafe8d92 100644 --- a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl @@ -108,9 +108,7 @@ GlobalData init_globals(void) # endif surf.barycentric_coords = vec2(0.0); surf.barycentric_dists = vec3(0.0); - if (!FrontFacing) { - surf.N = -surf.N; - } + surf.N = (FrontFacing) ? surf.N : -surf.N; # ifdef HAIR_SHADER vec3 V = cameraVec(surf.P); /* Shade as a cylinder. */ |