Skip to content

Fix moving-object detection for nested AnimationGroups with z-indexed mobjects#4389

Merged
behackl merged 9 commits intoManimCommunity:mainfrom
Merzlikin-Matvey:fix_z_index
Feb 22, 2026
Merged

Fix moving-object detection for nested AnimationGroups with z-indexed mobjects#4389
behackl merged 9 commits intoManimCommunity:mainfrom
Merzlikin-Matvey:fix_z_index

Conversation

@Merzlikin-Matvey
Copy link
Copy Markdown
Contributor

@Merzlikin-Matvey Merzlikin-Matvey commented Aug 10, 2025

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

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

Copy link
Copy Markdown
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please take a look at my suggestion.

Comment thread manim/scene/scene.py Outdated
Copy link
Copy Markdown
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@behackl behackl added the enhancement Additions and improvements in general label Feb 22, 2026
@behackl behackl enabled auto-merge (squash) February 22, 2026 11:05
@behackl behackl added pr:bugfix Bug fix for use in PRs solving a specific issue:bug and removed enhancement Additions and improvements in general labels Feb 22, 2026
@behackl behackl changed the title Add support for negative z-index in AnimationGroup Fix moving-object detection for nested AnimationGroups with z-indexed mobjects Feb 22, 2026
@behackl behackl merged commit 87cd635 into ManimCommunity:main Feb 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bugfix Bug fix for use in PRs solving a specific issue:bug

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

LaggedStart animation bugs when z-index of animated mobject is non-positive AnimationGroup with negative z_index

2 participants