Fix moving-object detection for nested AnimationGroups with z-indexed mobjects#4389
Merged
behackl merged 9 commits intoManimCommunity:mainfrom Feb 22, 2026
Merged
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
3 tasks
behackl
reviewed
Aug 11, 2025
Member
behackl
left a comment
There was a problem hiding this comment.
Thanks! Please take a look at my suggestion.
behackl
approved these changes
Feb 22, 2026
Member
behackl
left a comment
There was a problem hiding this comment.
Thanks again!
I took a closer look at the earlier suggested fix, and it turns out that correctly handling nested AnimationGroups requires recursively traversing subanimations. For simplicity, that recursive helper is now implemented locally inside the moving-object detection method (get_moving_mobjects) rather than as a separate scene method.
I also ran the relevant negative z-index graphical tests locally, and they pass. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
Fixes an AnimationGroup behaviour with negative z_index Mobjects. More about this problem you can see in these issues:
#3334 and #3914
Motivation and Explanation: Why and how do your changes improve the library?
Mobjects with negative z_index have problems with playing in animations. This PR fixes it
Links to added or changed documentation pages
There are no changes to the documentation
Further Information and Comments
I had already opened a pull request, but I decided to close it due to many issues with the previous solution. I have taken all the shortcomings, now there are no performance or graphical test issues.
Related issues
Closes #3334
Closes #3914
Reviewer Checklist