mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Small changes to Mobject.upate
This commit is contained in:
parent
0212fa27e7
commit
b5c60ecd0a
1 changed files with 13 additions and 8 deletions
|
@ -125,6 +125,7 @@ class Mobject(Container):
|
||||||
copy_mobject.submobjects = [
|
copy_mobject.submobjects = [
|
||||||
submob.copy() for submob in self.submobjects
|
submob.copy() for submob in self.submobjects
|
||||||
]
|
]
|
||||||
|
copy_mobject.updaters = list(self.updaters)
|
||||||
family = self.get_family()
|
family = self.get_family()
|
||||||
for attr, value in list(self.__dict__.items()):
|
for attr, value in list(self.__dict__.items()):
|
||||||
if isinstance(value, Mobject) and value in family and value is not self:
|
if isinstance(value, Mobject) and value in family and value is not self:
|
||||||
|
@ -147,13 +148,14 @@ class Mobject(Container):
|
||||||
# Updating
|
# Updating
|
||||||
|
|
||||||
def update(self, dt=0, recursive=True):
|
def update(self, dt=0, recursive=True):
|
||||||
if not self.updating_suspended:
|
if self.updating_suspended:
|
||||||
for updater in self.updaters:
|
return self
|
||||||
parameters = get_parameters(updater)
|
for updater in self.updaters:
|
||||||
if "dt" in parameters:
|
parameters = get_parameters(updater)
|
||||||
updater(self, dt)
|
if "dt" in parameters:
|
||||||
else:
|
updater(self, dt)
|
||||||
updater(self)
|
else:
|
||||||
|
updater(self)
|
||||||
if recursive:
|
if recursive:
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.update(dt, recursive)
|
submob.update(dt, recursive)
|
||||||
|
@ -182,8 +184,11 @@ class Mobject(Container):
|
||||||
self.updaters.remove(update_function)
|
self.updaters.remove(update_function)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def clear_updaters(self):
|
def clear_updaters(self, recursive=True):
|
||||||
self.updaters = []
|
self.updaters = []
|
||||||
|
if recursive:
|
||||||
|
for submob in self.submobjects:
|
||||||
|
submob.clear_updaters()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def suspend_updating(self, recursive=True):
|
def suspend_updating(self, recursive=True):
|
||||||
|
|
Loading…
Add table
Reference in a new issue