Use get_family_updaters to test if a mobject should be drawn during every frame of an animation

This commit is contained in:
Grant Sanderson
2019-04-04 14:29:52 -07:00
parent 26c7faabdd
commit 982d437267
2 changed files with 7 additions and 1 deletions

View File

@ -173,6 +173,12 @@ class Mobject(Container):
def get_updaters(self):
return self.updaters
def get_family_updaters(self):
return list(it.chain(*[
sm.get_updaters()
for sm in self.get_family()
]))
def add_updater(self, update_function, index=None, call_updater=True):
if index is None:
self.updaters.append(update_function)

View File

@ -288,7 +288,7 @@ class Scene(Container):
for i, mob in enumerate(mobjects):
update_possibilities = [
mob in animation_mobjects,
len(mob.get_updaters()) > 0,
len(mob.get_family_updaters()) > 0,
mob in self.foreground_mobjects
]
if any(update_possibilities):