Skip to content

Commit 952c8c8

Browse files
Deep SharanDeep Sharan
authored andcommitted
Fix caching issue with always_redraw causing incorrect object placement
- When animations are cached and skipped, ensure proper final state interpolation - Call scene.update_to_time(scene.duration) to set animations to their end state - Update all mobjects after interpolation to reflect final animation values - Ensures ValueTrackers and always_redraw functions have correct values on cached renders - Fixes #4160
1 parent 89c031b commit 952c8c8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

manim/renderer/opengl_renderer.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,16 @@ def play(
452452
self.animation_elapsed_time = scene.duration
453453

454454
else:
455-
scene.play_internal()
455+
# If animations are being skipped due to caching, we still need to
456+
# properly interpolate animations to their end state to ensure
457+
# ValueTrackers and always_redraw functions have correct values
458+
if self.skip_animations:
459+
# Ensure all animations reach their final state
460+
scene.update_to_time(scene.duration)
461+
# Update all mobjects to reflect the final animation state
462+
scene.update_mobjects(0)
463+
else:
464+
scene.play_internal()
456465

457466
self.file_writer.end_animation(not self.skip_animations)
458467
self.time += scene.duration

0 commit comments

Comments
 (0)