From 61bf51acb58f84338d5442141a2352039fa6d5da Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Nov 2019 10:53:47 +1100 Subject: [PATCH 1/3] Cleanup: pep8 for examples --- doc/manpage/blender.1.py | 2 +- doc/python_api/examples/bpy.app.timers.1.py | 2 ++ doc/python_api/examples/bpy.app.timers.2.py | 2 ++ doc/python_api/examples/bpy.app.timers.3.py | 2 ++ doc/python_api/examples/bpy.app.timers.4.py | 2 ++ doc/python_api/examples/bpy.types.Depsgraph.6.py | 2 +- .../examples/bpy.types.RenderEngine.py | 16 +++++++++------- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py index fc2200ab859..da83abe8442 100755 --- a/doc/manpage/blender.1.py +++ b/doc/manpage/blender.1.py @@ -62,7 +62,7 @@ if blender_date is None: # Happens when built without WITH_BUILD_INFO e.g. date_string = time.strftime("%B %d, %Y", time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))) else: - blender_date = blender_date.strip().partition(" ")[2] # remove 'date:' prefix + blender_date = blender_date.strip().partition(" ")[2] # remove 'date:' prefix date_string = time.strftime("%B %d, %Y", time.strptime(blender_date, "%Y-%m-%d")) outfile = open(outfilename, "w") diff --git a/doc/python_api/examples/bpy.app.timers.1.py b/doc/python_api/examples/bpy.app.timers.1.py index bae3b94b24a..a8ce7fde552 100644 --- a/doc/python_api/examples/bpy.app.timers.1.py +++ b/doc/python_api/examples/bpy.app.timers.1.py @@ -4,7 +4,9 @@ Run a Function in x Seconds """ import bpy + def in_5_seconds(): print("Hello World") + bpy.app.timers.register(in_5_seconds, first_interval=5) diff --git a/doc/python_api/examples/bpy.app.timers.2.py b/doc/python_api/examples/bpy.app.timers.2.py index c663959c209..e17d43cccd8 100644 --- a/doc/python_api/examples/bpy.app.timers.2.py +++ b/doc/python_api/examples/bpy.app.timers.2.py @@ -4,8 +4,10 @@ Run a Function every x Seconds """ import bpy + def every_2_seconds(): print("Hello World") return 2.0 + bpy.app.timers.register(every_2_seconds) diff --git a/doc/python_api/examples/bpy.app.timers.3.py b/doc/python_api/examples/bpy.app.timers.3.py index 79daf6a7740..a738f9ca01c 100644 --- a/doc/python_api/examples/bpy.app.timers.3.py +++ b/doc/python_api/examples/bpy.app.timers.3.py @@ -6,6 +6,7 @@ import bpy counter = 0 + def run_10_times(): global counter counter += 1 @@ -14,4 +15,5 @@ def run_10_times(): return None return 0.1 + bpy.app.timers.register(run_10_times) diff --git a/doc/python_api/examples/bpy.app.timers.4.py b/doc/python_api/examples/bpy.app.timers.4.py index 6cdee564bb5..c14bc15166c 100644 --- a/doc/python_api/examples/bpy.app.timers.4.py +++ b/doc/python_api/examples/bpy.app.timers.4.py @@ -5,8 +5,10 @@ Assign parameters to functions import bpy import functools + def print_message(message): print("Message:", message) + bpy.app.timers.register(functools.partial(print_message, "Hello"), first_interval=2.0) bpy.app.timers.register(functools.partial(print_message, "World"), first_interval=3.0) diff --git a/doc/python_api/examples/bpy.types.Depsgraph.6.py b/doc/python_api/examples/bpy.types.Depsgraph.6.py index 56e028e8813..1f809356b13 100644 --- a/doc/python_api/examples/bpy.types.Depsgraph.6.py +++ b/doc/python_api/examples/bpy.types.Depsgraph.6.py @@ -29,7 +29,7 @@ class OBJECT_OT_simple_exporter(bpy.types.Operator): # Happens for non-geometry objects. continue print(f"Exporting mesh with {len(mesh.vertices)} vertices " - f"at {object_instance.matrix_world}") + f"at {object_instance.matrix_world}") object_instace.to_mesh_clear() return {'FINISHED'} diff --git a/doc/python_api/examples/bpy.types.RenderEngine.py b/doc/python_api/examples/bpy.types.RenderEngine.py index 86ab4b3097d..45910194244 100644 --- a/doc/python_api/examples/bpy.types.RenderEngine.py +++ b/doc/python_api/examples/bpy.types.RenderEngine.py @@ -101,7 +101,7 @@ class CustomRenderEngine(bpy.types.RenderEngine): # Bind shader that converts from scene linear to display space, bgl.glEnable(bgl.GL_BLEND) - bgl.glBlendFunc(bgl.GL_ONE, bgl.GL_ONE_MINUS_SRC_ALPHA); + bgl.glBlendFunc(bgl.GL_ONE, bgl.GL_ONE_MINUS_SRC_ALPHA) self.bind_display_space_shader(scene) if not self.draw_data or self.draw_data.dimensions != dimensions: @@ -135,18 +135,18 @@ class CustomDrawData: # Bind shader that converts from scene linear to display space, # use the scene's color management settings. shader_program = bgl.Buffer(bgl.GL_INT, 1) - bgl.glGetIntegerv(bgl.GL_CURRENT_PROGRAM, shader_program); + bgl.glGetIntegerv(bgl.GL_CURRENT_PROGRAM, shader_program) # Generate vertex array self.vertex_array = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenVertexArrays(1, self.vertex_array) bgl.glBindVertexArray(self.vertex_array[0]) - texturecoord_location = bgl.glGetAttribLocation(shader_program[0], "texCoord"); - position_location = bgl.glGetAttribLocation(shader_program[0], "pos"); + texturecoord_location = bgl.glGetAttribLocation(shader_program[0], "texCoord") + position_location = bgl.glGetAttribLocation(shader_program[0], "pos") - bgl.glEnableVertexAttribArray(texturecoord_location); - bgl.glEnableVertexAttribArray(position_location); + bgl.glEnableVertexAttribArray(texturecoord_location) + bgl.glEnableVertexAttribArray(position_location) # Generate geometry buffers for drawing textured quad position = [0.0, 0.0, width, 0.0, width, height, 0.0, height] @@ -178,7 +178,7 @@ class CustomDrawData: bgl.glActiveTexture(bgl.GL_TEXTURE0) bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture[0]) bgl.glBindVertexArray(self.vertex_array[0]) - bgl.glDrawArrays(bgl.GL_TRIANGLE_FAN, 0, 4); + bgl.glDrawArrays(bgl.GL_TRIANGLE_FAN, 0, 4) bgl.glBindVertexArray(0) bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0) @@ -201,6 +201,7 @@ def get_panels(): return panels + def register(): # Register the RenderEngine bpy.utils.register_class(CustomRenderEngine) @@ -208,6 +209,7 @@ def register(): for panel in get_panels(): panel.COMPAT_ENGINES.add('CUSTOM') + def unregister(): bpy.utils.unregister_class(CustomRenderEngine) From c1f8268734af40a73661642b1bb3f8d27325dd96 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Nov 2019 11:22:04 +1100 Subject: [PATCH 2/3] Fix T60607: Spin tool duplicates after Spin Duplicate --- source/blender/editors/mesh/editmesh_extrude_spin.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index bf4403e49ee..7cad7e1e062 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -200,7 +200,10 @@ void MESH_OT_spin(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "steps", 9, 0, 1000000, "Steps", "Steps", 0, 1000); - RNA_def_boolean(ot->srna, "dupli", 0, "Duplicate", "Make Duplicates"); + + prop = RNA_def_boolean(ot->srna, "dupli", 0, "Use Duplicates", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_float(ot->srna, "angle", DEG2RADF(90.0f), From 1121e1f1a6215ecea76352295d39649662885433 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Fri, 1 Nov 2019 14:30:55 +0100 Subject: [PATCH 3/3] Fix T71251: Move Strokes to Layer slider gets wonky This parameter must be hidden. --- source/blender/editors/gpencil/gpencil_edit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c4f18c60f4d..3ab11f8f3f7 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1538,6 +1538,7 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) /* GPencil layer to use. */ ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX); + RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE); } /* ********************* Add Blank Frame *************************** */