forked from blender/blender
me-main #1
@ -36,10 +36,10 @@ struct PropertyRNA;
|
|||||||
/* Data Management */
|
/* Data Management */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
|
* Frees the given NLA strip, and calls #BKE_nlastrip_remove_and_free to
|
||||||
* and the strip itself.
|
* remove and free all children strips.
|
||||||
*/
|
*/
|
||||||
void BKE_nlastrip_free(ListBase *strips, struct NlaStrip *strip, bool do_id_user);
|
void BKE_nlastrip_free(struct NlaStrip *strip, bool do_id_user);
|
||||||
/**
|
/**
|
||||||
* Remove the given NLA track from the set of NLA tracks, free the track's data,
|
* Remove the given NLA track from the set of NLA tracks, free the track's data,
|
||||||
* and the track itself.
|
* and the track itself.
|
||||||
@ -94,10 +94,22 @@ void BKE_nla_tracks_copy_from_adt(struct Main *bmain,
|
|||||||
struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt,
|
struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt,
|
||||||
struct NlaTrack *prev,
|
struct NlaTrack *prev,
|
||||||
bool is_liboverride);
|
bool is_liboverride);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a NLA Strip referencing the given Action.
|
* Create a NLA Strip referencing the given Action.
|
||||||
*/
|
*/
|
||||||
struct NlaStrip *BKE_nlastrip_new(struct bAction *act);
|
struct NlaStrip *BKE_nlastrip_new(struct bAction *act);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes the given NLA strip from the list of strips provided.
|
||||||
|
*/
|
||||||
|
void BKE_nlastrip_remove(ListBase *strips, struct NlaStrip *strip);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes the given NLA strip from the list of strips provided, and frees it's memory.
|
||||||
|
*/
|
||||||
|
void BKE_nlastrip_remove_and_free(ListBase *strips, struct NlaStrip *strip, const bool do_id_user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add new NLA-strip to the top of the NLA stack - i.e.
|
* Add new NLA-strip to the top of the NLA stack - i.e.
|
||||||
* into the last track if space, or a new one otherwise.
|
* into the last track if space, or a new one otherwise.
|
||||||
@ -139,13 +151,9 @@ void BKE_nlastrips_sort_strips(ListBase *strips);
|
|||||||
void BKE_nlastrips_add_strip_unsafe(ListBase *strips, struct NlaStrip *strip);
|
void BKE_nlastrips_add_strip_unsafe(ListBase *strips, struct NlaStrip *strip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief NULL checks incoming strip and verifies no overlap / invalid
|
* NULL checks incoming strip and verifies no overlap / invalid
|
||||||
* configuration against other strips in NLA Track.
|
* configuration against other strips in NLA Track before calling
|
||||||
*
|
* #BKE_nlastrips_add_strip_unsafe.
|
||||||
* \param strips:
|
|
||||||
* \param strip:
|
|
||||||
* \return true
|
|
||||||
* \return false
|
|
||||||
*/
|
*/
|
||||||
bool BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
|
bool BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
|
||||||
|
|
||||||
@ -215,11 +223,16 @@ bool BKE_nlatrack_has_space(struct NlaTrack *nlt, float start, float end);
|
|||||||
void BKE_nlatrack_sort_strips(struct NlaTrack *nlt);
|
void BKE_nlatrack_sort_strips(struct NlaTrack *nlt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given NLA-Strip to the given NLA-Track, assuming that it
|
* Add the given NLA-Strip to the given NLA-Track.
|
||||||
* isn't currently attached to another one.
|
* Calls #BKE_nlastrips_add_strip to check if strip can be added.
|
||||||
*/
|
*/
|
||||||
bool BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip, bool is_liboverride);
|
bool BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip, bool is_liboverride);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the NLA-Strip from the given NLA-Track.
|
||||||
|
*/
|
||||||
|
void BKE_nlatrack_remove_strip(struct NlaTrack *track, struct NlaStrip *strip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extents of the given NLA-Track including gaps between strips,
|
* Get the extents of the given NLA-Track including gaps between strips,
|
||||||
* returning whether this succeeded or not
|
* returning whether this succeeded or not
|
||||||
|
@ -61,7 +61,7 @@ static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks,
|
|||||||
|
|
||||||
/* Freeing ------------------------------------------- */
|
/* Freeing ------------------------------------------- */
|
||||||
|
|
||||||
void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
|
void BKE_nlastrip_free(NlaStrip *strip, const bool do_id_user)
|
||||||
{
|
{
|
||||||
NlaStrip *cs, *csn;
|
NlaStrip *cs, *csn;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
|
|||||||
/* free child-strips */
|
/* free child-strips */
|
||||||
for (cs = strip->strips.first; cs; cs = csn) {
|
for (cs = strip->strips.first; cs; cs = csn) {
|
||||||
csn = cs->next;
|
csn = cs->next;
|
||||||
BKE_nlastrip_free(&strip->strips, cs, do_id_user);
|
BKE_nlastrip_remove_and_free(&strip->strips, cs, do_id_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove reference to action */
|
/* remove reference to action */
|
||||||
@ -81,10 +81,6 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
|
|||||||
id_us_min(&strip->act->id);
|
id_us_min(&strip->act->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free remapping info */
|
|
||||||
// if (strip->remap)
|
|
||||||
// BKE_animremap_free();
|
|
||||||
|
|
||||||
/* free own F-Curves */
|
/* free own F-Curves */
|
||||||
BKE_fcurves_free(&strip->fcurves);
|
BKE_fcurves_free(&strip->fcurves);
|
||||||
|
|
||||||
@ -92,12 +88,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
|
|||||||
free_fmodifiers(&strip->modifiers);
|
free_fmodifiers(&strip->modifiers);
|
||||||
|
|
||||||
/* free the strip itself */
|
/* free the strip itself */
|
||||||
if (strips) {
|
MEM_freeN(strip);
|
||||||
BLI_freelinkN(strips, strip);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MEM_freeN(strip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
|
void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
|
||||||
@ -112,7 +103,7 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
|
|||||||
/* free strips */
|
/* free strips */
|
||||||
for (strip = nlt->strips.first; strip; strip = stripn) {
|
for (strip = nlt->strips.first; strip; strip = stripn) {
|
||||||
stripn = strip->next;
|
stripn = strip->next;
|
||||||
BKE_nlastrip_free(&nlt->strips, strip, do_id_user);
|
BKE_nlastrip_remove_and_free(&nlt->strips, strip, do_id_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free NLA track itself now */
|
/* free NLA track itself now */
|
||||||
@ -875,7 +866,7 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free the meta-strip now */
|
/* free the meta-strip now */
|
||||||
BKE_nlastrip_free(strips, strip, true);
|
BKE_nlastrip_remove_and_free(strips, strip, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
|
void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
|
||||||
@ -1190,6 +1181,12 @@ bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip, const bool is_libove
|
|||||||
return BKE_nlastrips_add_strip(&nlt->strips, strip);
|
return BKE_nlastrips_add_strip(&nlt->strips, strip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_nlatrack_remove_strip(NlaTrack *track, NlaStrip *strip)
|
||||||
|
{
|
||||||
|
BLI_assert(track);
|
||||||
|
BKE_nlastrip_remove(&track->strips, strip);
|
||||||
|
}
|
||||||
|
|
||||||
bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
|
bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
|
||||||
{
|
{
|
||||||
NlaStrip *strip;
|
NlaStrip *strip;
|
||||||
@ -1318,6 +1315,18 @@ NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt)
|
|||||||
return nlastrip_find_active(&nlt->strips);
|
return nlastrip_find_active(&nlt->strips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_nlastrip_remove(ListBase *strips, NlaStrip *strip)
|
||||||
|
{
|
||||||
|
BLI_assert(strips);
|
||||||
|
BLI_remlink(strips, strip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_nlastrip_remove_and_free(ListBase *strips, NlaStrip *strip, const bool do_id_user)
|
||||||
|
{
|
||||||
|
BKE_nlastrip_remove(strips, strip);
|
||||||
|
BKE_nlastrip_free(strip, do_id_user);
|
||||||
|
}
|
||||||
|
|
||||||
void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
|
void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
|
||||||
{
|
{
|
||||||
NlaTrack *nlt;
|
NlaTrack *nlt;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
* Copyright 2023 Blender Foundation. All rights reserved. */
|
* Copyright 2023 Blender Foundation. All rights reserved. */
|
||||||
|
|
||||||
|
#include "BLI_listbase.h"
|
||||||
|
|
||||||
#include "BKE_nla.h"
|
#include "BKE_nla.h"
|
||||||
|
|
||||||
#include "DNA_anim_types.h"
|
#include "DNA_anim_types.h"
|
||||||
@ -20,19 +22,19 @@ TEST(nla_strip, BKE_nlastrip_recalculate_blend)
|
|||||||
strip.start = 1;
|
strip.start = 1;
|
||||||
strip.end = 10;
|
strip.end = 10;
|
||||||
|
|
||||||
/* Scaling a strip up doesn't affect the blend in/out value */
|
/* Scaling a strip up doesn't affect the blend in/out value. */
|
||||||
strip.end = 20;
|
strip.end = 20;
|
||||||
BKE_nlastrip_recalculate_blend(&strip);
|
BKE_nlastrip_recalculate_blend(&strip);
|
||||||
EXPECT_FLOAT_EQ(strip.blendin, 4.0);
|
EXPECT_FLOAT_EQ(strip.blendin, 4.0);
|
||||||
EXPECT_FLOAT_EQ(strip.blendout, 5.0);
|
EXPECT_FLOAT_EQ(strip.blendout, 5.0);
|
||||||
|
|
||||||
/* Scaling a strip down affects the blend-in value before the blend-out value */
|
/* Scaling a strip down affects the blend-in value before the blend-out value. */
|
||||||
strip.end = 7;
|
strip.end = 7;
|
||||||
BKE_nlastrip_recalculate_blend(&strip);
|
BKE_nlastrip_recalculate_blend(&strip);
|
||||||
EXPECT_FLOAT_EQ(strip.blendin, 1.0);
|
EXPECT_FLOAT_EQ(strip.blendin, 1.0);
|
||||||
EXPECT_FLOAT_EQ(strip.blendout, 5.0);
|
EXPECT_FLOAT_EQ(strip.blendout, 5.0);
|
||||||
|
|
||||||
/* Scaling a strip down to nothing updates the blend in/out values accordingly */
|
/* Scaling a strip down to nothing updates the blend in/out values accordingly. */
|
||||||
strip.end = 1.1;
|
strip.end = 1.1;
|
||||||
BKE_nlastrip_recalculate_blend(&strip);
|
BKE_nlastrip_recalculate_blend(&strip);
|
||||||
EXPECT_FLOAT_EQ(strip.blendin, 0.0);
|
EXPECT_FLOAT_EQ(strip.blendin, 0.0);
|
||||||
@ -63,4 +65,31 @@ TEST(nla_strip, BKE_nlastrips_add_strip)
|
|||||||
EXPECT_TRUE(BKE_nlastrips_add_strip(&strips, &strip2));
|
EXPECT_TRUE(BKE_nlastrips_add_strip(&strips, &strip2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(nla_track, BKE_nlatrack_remove_strip)
|
||||||
|
{
|
||||||
|
NlaTrack track{};
|
||||||
|
ListBase strips{};
|
||||||
|
NlaStrip strip1{};
|
||||||
|
strip1.start = 0;
|
||||||
|
strip1.end = 10;
|
||||||
|
|
||||||
|
NlaStrip strip2{};
|
||||||
|
strip2.start = 11;
|
||||||
|
strip2.end = 20;
|
||||||
|
|
||||||
|
// Add NLA strips to the NLATrack.
|
||||||
|
BKE_nlastrips_add_strip(&strips, &strip1);
|
||||||
|
BKE_nlastrips_add_strip(&strips, &strip2);
|
||||||
|
track.strips = strips;
|
||||||
|
|
||||||
|
// ensure we have 2 strips in the track.
|
||||||
|
EXPECT_EQ(2, BLI_listbase_count(&track.strips));
|
||||||
|
|
||||||
|
BKE_nlatrack_remove_strip(&track, &strip2);
|
||||||
|
EXPECT_EQ(1, BLI_listbase_count(&track.strips));
|
||||||
|
// ensure the correct strip was removed.
|
||||||
|
EXPECT_EQ(-1, BLI_findindex(&track.strips, &strip2));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender::bke::tests
|
} // namespace blender::bke::tests
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ void ED_animedit_unlink_action(
|
|||||||
|
|
||||||
if (strip->act == act) {
|
if (strip->act == act) {
|
||||||
/* Remove this strip, and the track too if it doesn't have anything else */
|
/* Remove this strip, and the track too if it doesn't have anything else */
|
||||||
BKE_nlastrip_free(&nlt->strips, strip, true);
|
BKE_nlastrip_remove_and_free(&nlt->strips, strip, true);
|
||||||
|
|
||||||
if (nlt->strips.first == NULL) {
|
if (nlt->strips.first == NULL) {
|
||||||
BLI_assert(nstrip == NULL);
|
BLI_assert(nstrip == NULL);
|
||||||
|
@ -1305,15 +1305,15 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
if (strip->flag & NLASTRIP_FLAG_SELECT) {
|
if (strip->flag & NLASTRIP_FLAG_SELECT) {
|
||||||
/* if a strip either side of this was a transition, delete those too */
|
/* if a strip either side of this was a transition, delete those too */
|
||||||
if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
|
if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
|
||||||
BKE_nlastrip_free(&nlt->strips, strip->prev, true);
|
BKE_nlastrip_remove_and_free(&nlt->strips, strip->prev, true);
|
||||||
}
|
}
|
||||||
if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
|
if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
|
||||||
nstrip = nstrip->next;
|
nstrip = nstrip->next;
|
||||||
BKE_nlastrip_free(&nlt->strips, strip->next, true);
|
BKE_nlastrip_remove_and_free(&nlt->strips, strip->next, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finally, delete this strip */
|
/* finally, delete this strip */
|
||||||
BKE_nlastrip_free(&nlt->strips, strip, true);
|
BKE_nlastrip_remove_and_free(&nlt->strips, strip, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1824,7 +1824,7 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) {
|
if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) {
|
||||||
/* remove from its current track, and add to the one above
|
/* remove from its current track, and add to the one above
|
||||||
* (it 'should' work, so no need to worry) */
|
* (it 'should' work, so no need to worry) */
|
||||||
BLI_remlink(&nlt->strips, strip);
|
BKE_nlatrack_remove_strip(nlt, strip);
|
||||||
BKE_nlatrack_add_strip(nltn, strip, is_liboverride);
|
BKE_nlatrack_add_strip(nltn, strip, is_liboverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1916,7 +1916,7 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) {
|
if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) {
|
||||||
/* remove from its current track, and add to the one above
|
/* remove from its current track, and add to the one above
|
||||||
* (it 'should' work, so no need to worry) */
|
* (it 'should' work, so no need to worry) */
|
||||||
BLI_remlink(&nlt->strips, strip);
|
BKE_nlatrack_remove_strip(nlt, strip);
|
||||||
BKE_nlatrack_add_strip(nltp, strip, is_liboverride);
|
BKE_nlatrack_add_strip(nltp, strip, is_liboverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ static void recalcData_nla(TransInfo *t)
|
|||||||
if (BKE_nlatrack_has_space(track, strip->start, strip->end) &&
|
if (BKE_nlatrack_has_space(track, strip->start, strip->end) &&
|
||||||
!BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) {
|
!BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) {
|
||||||
/* move strip to this track */
|
/* move strip to this track */
|
||||||
BLI_remlink(&tdn->nlt->strips, strip);
|
BKE_nlatrack_remove_strip(tdn->nlt, strip);
|
||||||
BKE_nlatrack_add_strip(track, strip, is_liboverride);
|
BKE_nlatrack_add_strip(track, strip, is_liboverride);
|
||||||
|
|
||||||
tdn->nlt = track;
|
tdn->nlt = track;
|
||||||
@ -477,7 +477,7 @@ static void recalcData_nla(TransInfo *t)
|
|||||||
if (BKE_nlatrack_has_space(track, strip->start, strip->end) &&
|
if (BKE_nlatrack_has_space(track, strip->start, strip->end) &&
|
||||||
!BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) {
|
!BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) {
|
||||||
/* move strip to this track */
|
/* move strip to this track */
|
||||||
BLI_remlink(&tdn->nlt->strips, strip);
|
BKE_nlatrack_remove_strip(tdn->nlt, strip);
|
||||||
BKE_nlatrack_add_strip(track, strip, is_liboverride);
|
BKE_nlatrack_add_strip(track, strip, is_liboverride);
|
||||||
|
|
||||||
tdn->nlt = track;
|
tdn->nlt = track;
|
||||||
|
@ -544,7 +544,7 @@ static NlaStrip *rna_NlaStrip_new(ID *id,
|
|||||||
reports,
|
reports,
|
||||||
RPT_ERROR,
|
RPT_ERROR,
|
||||||
"Unable to add strip (the track does not have any space to accommodate this new strip)");
|
"Unable to add strip (the track does not have any space to accommodate this new strip)");
|
||||||
BKE_nlastrip_free(NULL, strip, true);
|
BKE_nlastrip_free(strip, true);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ static void rna_NlaStrip_remove(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_nlastrip_free(&track->strips, strip, true);
|
BKE_nlastrip_remove_and_free(&track->strips, strip, true);
|
||||||
RNA_POINTER_INVALIDATE(strip_ptr);
|
RNA_POINTER_INVALIDATE(strip_ptr);
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user