Merge pull request #75 from 3b1b/fourier-work

Enable -n command on extract_scene.py to skip to a given animation in a scene
This commit is contained in:
Grant Sanderson 2018-01-18 21:28:29 -08:00 committed by GitHub
commit 15a832acec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View file

@ -66,6 +66,7 @@ def get_configuration():
for short_arg, long_arg in optional_args:
parser.add_argument(short_arg, long_arg, action = "store_true")
parser.add_argument("-o", "--output_name")
parser.add_argument("-n", "--skip_to_animation_number")
args = parser.parse_args()
except argparse.ArgumentError as err:
print(str(err))
@ -85,6 +86,7 @@ def get_configuration():
"quiet" : args.quiet or args.write_all,
"write_all" : args.write_all,
"output_name" : args.output_name,
"skip_to_animation_number" : args.skip_to_animation_number,
}
if args.low_quality or args.preview:
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
@ -96,12 +98,18 @@ def get_configuration():
config["camera_config"] = PRODUCTION_QUALITY_CAMERA_CONFIG
config["frame_duration"] = PRODUCTION_QUALITY_FRAME_DURATION
stan = config["skip_to_animation_number"]
if stan is not None:
config["skip_to_animation_number"] = int(stan)
#By default, write to file
actions = ["write_to_movie", "preview", "show_last_frame"]
if not any([config[key] for key in actions]):
config["write_to_movie"] = True
config["skip_animations"] = config["show_last_frame"] and not config["write_to_movie"]
config["skip_animations"] = any([
config["show_last_frame"] and not config["write_to_movie"],
config["skip_to_animation_number"],
])
return config
def handle_scene(scene, **config):
@ -203,7 +211,8 @@ def main():
"write_to_movie",
"save_frames",
"output_directory",
"save_pngs"
"save_pngs",
"skip_to_animation_number",
]
])

View file

@ -36,6 +36,7 @@ class Scene(object):
"name" : None,
"always_continually_update" : False,
"random_seed" : 0,
"skip_to_animation_number" : None,
}
def __init__(self, **kwargs):
digest_config(self, kwargs)
@ -59,6 +60,7 @@ class Scene(object):
self.construct(*self.construct_args)
if self.write_to_movie:
self.close_movie_pipe()
print("Played a total of %d animations"%self.num_plays)
def setup(self):
"""
@ -389,9 +391,13 @@ class Scene(object):
if len(args) == 0:
warnings.warn("Called Scene.play with no animations")
return
if self.skip_to_animation_number:
if self.num_plays + 1 == self.skip_to_animation_number:
self.skip_animations = False
if self.skip_animations:
kwargs["run_time"] = 0
animations = self.compile_play_args_to_animation_list(*args)
self.num_plays += 1