-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Simplify the animation logic within Scene #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Naveen M K <naveen@syrusdark.website>
Do you think this can wait until after the release? Given that we don't have enough tests for all the CLI flags, I'm a bit hesitant to touch the rendering logic right before a release. |
Sure, but we can still get the review done until then. Depends on #148 |
I feel like the dep bot is never working 😕 |
if file_writer_config["skip_animations"]: | ||
# TODO, run this call in for each animation? | ||
self.update_mobjects(self.get_run_time(animations)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick question about these removed lines.
Suppose that animation n is skipped, but not animation n+1, and animation n+1 uses some stuff that were supposedly updated by animation n, in any way. Will this work without these lines? The mobject that was supposed to be updated in animation n wouldn't have been.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manim handles animation skipping by setting the time progression used in the animation loop to one which holds a single value, the length of the animations being played.
Lines 562 to 566 in 3b6519a
if file_writer_config["skip_animations"] and not override_skip_animations: | |
times = [run_time] | |
else: | |
step = 1 / self.renderer.camera.frame_rate | |
times = np.arange(0, run_time, step) |
so the relevant mobjects will have already been updated by the time they reach this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from a missing docstring, this looks good to me, thank you for your effort with this cleanup!
I don't necessarily agree with you overriding the "2 reviewers"-rule and merging this without any approvals. To be fair, you asked several times and I could have indicated that I planned looking at this. At the same time I don't think it would have halted any further progress if this PR would have been open for a little longer.
@@ -530,6 +530,23 @@ def get_moving_mobjects(self, *animations): | |||
return mobjects[i:] | |||
return [] | |||
|
|||
def get_moving_and_static_mobjects(self, animations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New methods added should have at least a basic docstring (oneline summary); and in the ideal case a list of parameters.
**kwargs : named parameters affecting what was passed in *args e.g run_time, lag_ratio etc. | ||
**kwargs : named parameters affecting what was passed in *args e.g | ||
run_time, lag_ratio etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These argument lists are not correctly formatted at all. (But this is fixed in #576, AFAIR.)
from our documentation renders as Same thing if the call to |
Where in our documentation is this example? |
It's not yet included, it will be added with #576. |
Major changes include:
Removed the
background
argument fromCairoRenderer.update_frame()
. It was only used once, to return a static image which was later passed back to theCairoRenderer
and composed with an image that moved as the animation progressed. I replaced its functionality withCairoRenderer.save_static_mobject_data()
, which saves the image to the renderer instead.Added
Scene.get_moving_and_static_mobjects()
to simplify the logic prior to beginning the animation loop in which static and moving mobjects are separated.Removed
Scene.begin_animations()
,Scene.finish_animations()
,Scene.clean_up_animations()
,Scene.progress_through_animations()
, andScene.update_animation_to_time()
. They were each only used once and were not very complicated, so I moved their contents intoScene.play_internal()
.Removed these lines from the logic that was previously in
Scene.finish_animations()
. AFAICT hey don't do anything.Removed several instance variables from Scene.
Scene.mobjects_from_last_animation
was only used once,Scene.last_t
was only used in an antipattern way to pass data to a function.Depends on #148