Merging animations places triggers after the animation merged before them

Appending moves the appended animation's triggers by the length merged so
far; prepending moves the target's triggers by the prepended length.
Replace and ignore keep trigger times. Goldens for prepend merges updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-06 02:03:20 -04:00
1 parent a440af3c95
commit ef5796d667
4 files changed
+39 -6

No files matched your search

+3 -3
View File
@@ -45,14 +45,14 @@
<NullAnimation NullId="1" Visible="true"/>
</NullAnimations>
<Triggers>
<Trigger EventId="0" AtFrame="0">
<Trigger EventId="0" AtFrame="1">
<Sound Id="0"/>
</Trigger>
<Trigger EventId="1" AtFrame="4">
<Trigger EventId="1" AtFrame="5">
<Sound Id="0"/>
<Sound Id="1"/>
</Trigger>
<Trigger AtFrame="6">
<Trigger AtFrame="7">
<Sound Id="1"/>
</Trigger>
</Triggers>
@@ -16,7 +16,7 @@
</Events>
</Content>
<Animations DefaultAnimation="Missing">
<Animation Name="A (Merged)" FrameNum="9" Loop="true">
<Animation Name="A (Merged)" FrameNum="10" Loop="true">
<RootAnimation>
<Frame XPosition="0" YPosition="0" Delay="4" Visible="true" XScale="100" YScale="100" ShearX="0" ShearY="0" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
</RootAnimation>
@@ -30,8 +30,8 @@
<LayerAnimation LayerId="99" Visible="true"/>
</LayerAnimations>
<Triggers>
<Trigger EventId="5" AtFrame="2"/>
<Trigger EventId="8" AtFrame="9"/>
<Trigger EventId="5" AtFrame="3"/>
<Trigger EventId="8" AtFrame="10"/>
</Triggers>
</Animation>
</Animations>
+24
View File
@@ -378,3 +378,27 @@ TEST_CASE("change all frame properties changes layer depth only")
CHECK(model.frame_get(layer)->depth == 1);
CHECK(model.frame_get(null)->depth == 0);
}
TEST_CASE("animations_merge moves triggers past the animation placed before them")
{
auto model_make = []()
{
auto model = fixture_load("01_minimal.anm2");
auto first = *model.animation_get(0);
first.frameNum = 10;
auto second = first;
second.uid = util::uid_next();
second.triggers.frames = {model::Frame{.atFrame = 5}};
model.animations.entries = {std::make_shared<const model::Animation>(first),
std::make_shared<const model::Animation>(second)};
return model;
};
auto appended = model_make();
edit::animations_merge(appended, 0, {0, 1}, types::merge::APPEND, false, {});
CHECK(appended.animation_get(0)->triggers.frames.at(0).atFrame == 15);
auto prepended = model_make();
edit::animations_merge(prepended, 1, {0, 1}, types::merge::PREPEND, false, {});
CHECK(prepended.animation_get(1)->triggers.frames.at(0).atFrame == 15);
}