mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
By default, don't recursively check for updaters unless there's something to find
This commit is contained in:
parent
5d371bfec9
commit
661b81ab17
1 changed files with 16 additions and 8 deletions
|
@ -67,7 +67,7 @@ class Mobject(Container):
|
||||||
self.name = self.__class__.__name__
|
self.name = self.__class__.__name__
|
||||||
self.time_based_updaters = []
|
self.time_based_updaters = []
|
||||||
self.non_time_updaters = []
|
self.non_time_updaters = []
|
||||||
self.updating_suspended = False
|
self.check_for_updaters = False
|
||||||
|
|
||||||
self.reset_points()
|
self.reset_points()
|
||||||
self.init_points()
|
self.init_points()
|
||||||
|
@ -114,6 +114,7 @@ class Mobject(Container):
|
||||||
def assemble_family(self):
|
def assemble_family(self):
|
||||||
sub_families = [sm.get_family() for sm in self.submobjects]
|
sub_families = [sm.get_family() for sm in self.submobjects]
|
||||||
self.family = [self, *it.chain(*sub_families)]
|
self.family = [self, *it.chain(*sub_families)]
|
||||||
|
self.refresh_check_for_updater_status()
|
||||||
for parent in self.parents:
|
for parent in self.parents:
|
||||||
parent.assemble_family()
|
parent.assemble_family()
|
||||||
return self
|
return self
|
||||||
|
@ -237,7 +238,7 @@ class Mobject(Container):
|
||||||
# Updating
|
# Updating
|
||||||
|
|
||||||
def update(self, dt=0, recursive=True):
|
def update(self, dt=0, recursive=True):
|
||||||
if self.updating_suspended:
|
if not self.check_for_updaters:
|
||||||
return self
|
return self
|
||||||
for updater in self.time_based_updaters:
|
for updater in self.time_based_updaters:
|
||||||
updater(self, dt)
|
updater(self, dt)
|
||||||
|
@ -274,8 +275,7 @@ class Mobject(Container):
|
||||||
else:
|
else:
|
||||||
updater_list.insert(index, update_function)
|
updater_list.insert(index, update_function)
|
||||||
|
|
||||||
if call_updater:
|
self.resume_updating(call_updater=call_updater)
|
||||||
self.update(0)
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def remove_updater(self, update_function):
|
def remove_updater(self, update_function):
|
||||||
|
@ -290,6 +290,7 @@ class Mobject(Container):
|
||||||
if recursive:
|
if recursive:
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.clear_updaters()
|
submob.clear_updaters()
|
||||||
|
self.suspend_updating(recursive)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def match_updaters(self, mobject):
|
def match_updaters(self, mobject):
|
||||||
|
@ -299,20 +300,27 @@ class Mobject(Container):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def suspend_updating(self, recursive=True):
|
def suspend_updating(self, recursive=True):
|
||||||
self.updating_suspended = True
|
self.check_for_updaters = False
|
||||||
if recursive:
|
if recursive:
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.suspend_updating(recursive)
|
submob.suspend_updating(recursive)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def resume_updating(self, recursive=True):
|
def resume_updating(self, recursive=True, call_updater=True):
|
||||||
self.updating_suspended = False
|
self.refresh_check_for_updater_status()
|
||||||
if recursive:
|
if recursive:
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.resume_updating(recursive)
|
submob.resume_updating(recursive)
|
||||||
|
for parent in self.parents:
|
||||||
|
parent.resume_updating(recursive=False, call_updater=False)
|
||||||
|
if call_updater:
|
||||||
self.update(dt=0, recursive=recursive)
|
self.update(dt=0, recursive=recursive)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def refresh_check_for_updater_status(self):
|
||||||
|
self.check_for_updaters = len(self.get_family_updaters()) > 0
|
||||||
|
return self
|
||||||
|
|
||||||
# Transforming operations
|
# Transforming operations
|
||||||
def set_points(self, points):
|
def set_points(self, points):
|
||||||
self.points = np.array(points)
|
self.points = np.array(points)
|
||||||
|
|
Loading…
Add table
Reference in a new issue