Removed separate_moving_and_static from scenes in place of cleaner get_moving_mobjects approach

This commit is contained in:
Grant Sanderson 2018-01-17 22:13:38 -08:00
parent 8e747ddc14
commit 024a9dd3d4
3 changed files with 8 additions and 15 deletions

View file

@ -229,19 +229,15 @@ class Scene(object):
)
to_remove = self.camera.extract_mobject_family_members(mobjects)
self.mobjects = list_difference_update(self.mobjects, to_remove)
self.remove_foreground_mobjects(*to_remove)
self.mobjects = self.get_restructured_mobject_list(self.mobjects, to_remove)
self.foreground_mobjects = self.get_restructured_mobject_list(
self.foreground_mobjects, to_remove
)
self.continual_animations = filter(
lambda ca : ca not in continual_animations and \
ca.mobject not in to_remove,
self.continual_animations
)
return self
def get_restructured_mobject_list(self, mobjects, to_remove):
@ -276,7 +272,7 @@ class Scene(object):
return self.add_foreground_mobjects(mobject)
def remove_foreground_mobjects(self, *mobjects):
self.foreground_mobjects = list_difference_update(
self.foreground_mobjects = get_restructured_mobject_list(
self.foreground_mobjects,
self.camera.extract_mobject_family_members(mobjects)
)

View file

@ -122,15 +122,13 @@ class ZoomedScene(Scene):
self.zoomed_camera.capture_mobjects(
mobjects, **kwargs
)
def separate_moving_and_static_mobjects(self, *animations):
moving_mobjects, static_mobjects = Scene.separate_moving_and_static_mobjects(
self, *animations
)
def get_moving_mobjects(self, *animations):
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
if self.zoom_activated and self.little_rectangle in moving_mobjects:
# When the camera is moving, so is everything,
return self.get_mobjects(), []
return self.mobjects
else:
return moving_mobjects, static_mobjects
return moving_mobjects

View file

@ -175,11 +175,10 @@ class ThreeDScene(Scene):
if is_camera_rotating:
self.add(self.ambient_camera_rotation)
def separate_moving_and_static_mobjects(self, *animations):
moving, static = Scene.separate_moving_and_static_mobjects(self, *animations)
def get_moving_mobjects(self, *animations):
if self.camera.rotation_mobject in moving:
return moving + static, []
return moving, static
return self.mobjects
return Scene.get_moving_mobjects(self, *animations)
##############