Skip to content
Snippets Groups Projects
Commit 1d1d7928 authored by Campbell Barton's avatar Campbell Barton
Browse files

demo mode fixes

* redraw before rendering (workaround for bug)
* play the first file once on init (before first file was assumed to be first file in demo_config.py which often isnt the case)
parent 5b8fd09b
No related branches found
No related tags found
No related merge requests found
...@@ -131,6 +131,12 @@ def demo_mode_auto_select(): ...@@ -131,6 +131,12 @@ def demo_mode_auto_select():
def demo_mode_next_file(step=1): def demo_mode_next_file(step=1):
# support for temp
if global_config_files[global_state["demo_index"]].get("is_tmp"):
del global_config_files[global_state["demo_index"]]
global_state["demo_index"] -= 1
print(global_state["demo_index"]) print(global_state["demo_index"])
global_state["demo_index"] = (global_state["demo_index"] + step) % len(global_config_files) global_state["demo_index"] = (global_state["demo_index"] + step) % len(global_config_files)
print(global_state["demo_index"], "....") print(global_state["demo_index"], "....")
...@@ -159,6 +165,22 @@ def demo_mode_load_file(): ...@@ -159,6 +165,22 @@ def demo_mode_load_file():
bpy.ops.wm.demo_mode('EXEC_DEFAULT') bpy.ops.wm.demo_mode('EXEC_DEFAULT')
def demo_mode_temp_file():
""" Initialize a temp config for the duration of the play time.
Use this so we can initialize the demo intro screen but not show again.
"""
assert(global_state["demo_index"] == 0)
temp_config = global_config_fallback.copy()
temp_config["anim_time_min"] = 0.0
temp_config["anim_time_max"] = 60.0
temp_config["anim_cycles"] = 1
temp_config["mode"] = 'PLAY'
temp_config["is_tmp"] = True
global_config_files.insert(0, temp_config)
def demo_mode_init(): def demo_mode_init():
print("func:demo_mode_init") print("func:demo_mode_init")
DemoKeepAlive.ensure() DemoKeepAlive.ensure()
...@@ -189,6 +211,8 @@ def demo_mode_init(): ...@@ -189,6 +211,8 @@ def demo_mode_init():
scene.render.use_file_extension = False scene.render.use_file_extension = False
scene.render.use_placeholder = False scene.render.use_placeholder = False
try: try:
# XXX - without this rendering will crash because of a bug in blender!
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
if global_config["anim_render"]: if global_config["anim_render"]:
bpy.ops.render.render('INVOKE_DEFAULT', animation=True) bpy.ops.render.render('INVOKE_DEFAULT', animation=True)
else: else:
...@@ -346,6 +370,8 @@ class DemoMode(bpy.types.Operator): ...@@ -346,6 +370,8 @@ class DemoMode(bpy.types.Operator):
# load config if not loaded # load config if not loaded
if not global_config_files: if not global_config_files:
load_config() load_config()
demo_mode_temp_file() # play this once through then never again
if not global_config_files: if not global_config_files:
self.report({'INFO'}, "No configuration found with text or file: %s. Run File -> Demo Mode Setup" % DEMO_CFG) self.report({'INFO'}, "No configuration found with text or file: %s. Run File -> Demo Mode Setup" % DEMO_CFG)
return {'CANCELLED'} return {'CANCELLED'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment