From 07ccb8b97c71eff0cbf1da4465fef5c46cd6d58f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Feb 2018 10:13:42 +0100 Subject: [PATCH 1/4] Fix crash with font on curve Was a mistake from recent texspace changes. Reported by Pablo here in the studio! --- source/blender/blenkernel/intern/font.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a314cc0a131..5545eba8764 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1080,8 +1080,13 @@ makebreak: float distfac, imat[4][4], imat3[3][3], cmat[3][3]; float minx, maxx, miny, maxy; float timeofs, sizefac; - - invert_m4_m4(imat, ob->obmat); + + if (ob != NULL) { + invert_m4_m4(imat, ob->obmat); + } + else { + unit_m4(imat); + } copy_m3_m4(imat3, imat); copy_m3_m4(cmat, cu->textoncurve->obmat); From 3c09077e3b88a33d103875a7e0fd0f7ca0736046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 8 Feb 2018 12:33:46 +0100 Subject: [PATCH 2/4] Paint Dirt: some small fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - normalize → average the vector: the vector isn't normalized here, because it doesn't necessarily becomes unit length. Instead, the sum is converted to an average vector. - angle is the acos()…: the dot product between the vertex normal and the average direction of the connected vertices is computed, and not the opposite. - The initial `con` list was discarded immediately and replaced by a new list. - File didn't end with a newline. --- .../scripts/startup/bl_operators/vertexpaint_dirt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index c006e8e6e92..7042f42744c 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -32,8 +32,6 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, vert_tone = array.array("f", [0.0]) * len(me.vertices) # create lookup table for each vertex's connected vertices (via edges) - con = [] - con = [[] for i in range(len(me.vertices))] # add connected verts @@ -50,7 +48,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, for c in con[i]: vec += (me.vertices[c].co - co).normalized() - # normalize the vector by dividing by the number of connected verts + # average the vector by dividing by the number of connected verts tot_con = len(con[i]) if tot_con == 0: @@ -58,7 +56,9 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, vec /= tot_con - # angle is the acos() of the dot product between vert and connected verts normals + # angle is the acos() of the dot product between normal and connected verts. + # > 90 degrees: convex + # < 90 degrees: concave ang = acos(no.dot(vec)) # enforce min/max @@ -186,4 +186,4 @@ class VertexPaintDirt(Operator): classes = ( VertexPaintDirt, -) \ No newline at end of file +) From 908ee2e0f2145cf8204501c99dc1eea431f933cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 9 Feb 2018 12:52:46 +0100 Subject: [PATCH 3/4] Paint Dirt: remove operator call from Python Instead of calling an operator I just call `collection.new()`. Moving the code into a separate function also simplifies it. In its new form there is also no undefined behaviour when me.vertex_colors is non-empty but without active layer. --- .../startup/bl_operators/vertexpaint_dirt.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index 7042f42744c..f12b76a76ba 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -21,7 +21,17 @@ # -# Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton +# Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton, Sybren A. Stüvel + + +def get_vcolor_layer_data(me): + for lay in me.vertex_colors: + if lay.active: + return lay.data + + lay = me.vertex_colors.new() + lay.active = True + return lay.data def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only): @@ -93,17 +103,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, else: tone_range = 1.0 / tone_range - active_col_layer = None - - if me.vertex_colors: - for lay in me.vertex_colors: - if lay.active: - active_col_layer = lay.data - else: - bpy.ops.mesh.vertex_color_add() - me.vertex_colors[0].active = True - active_col_layer = me.vertex_colors[0].data - + active_col_layer = get_vcolor_layer_data(me) if not active_col_layer: return {'CANCELLED'} From 97597ed6002211d55565d2a281da3c3fc1098ebb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 9 Feb 2018 12:04:29 +0100 Subject: [PATCH 4/4] Doc: attempt to document RNA's FunctionFlag. Tired of searching through code to find which is what, and how to use it in the C callback, everytime I need anot-so-common option... --- source/blender/makesrna/RNA_types.h | 40 +++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index ce2ca01ccfe..705d3914a52 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -398,22 +398,46 @@ typedef struct ParameterDynAlloc { /* Function */ typedef enum FunctionFlag { - FUNC_NO_SELF = (1 << 0), /* for static functions */ - FUNC_USE_SELF_TYPE = (1 << 1), /* for class methods, only used when FUNC_NO_SELF is set */ + /***** Options affecting callback signature. *****/ + /* Those add additionnal parameters at the beginning of the C callback, like that: + * rna_my_func([ID *_selfid], + * [ *self|StructRNA *type], + * [Main *bmain], + * [bContext *C], + * [ReportList *reports], + * ); + */ + /* Pass ID owning 'self' data (i.e. ptr->id.data, might be same as self in case data is an ID...). */ + FUNC_USE_SELF_ID = (1 << 11), + + /* Do not pass the object (DNA struct pointer) from which it is called, used to define static or class functions. */ + FUNC_NO_SELF = (1 << 0), + /* Pass RNA type, used to define class functions, only valid when FUNC_NO_SELF is set. */ + FUNC_USE_SELF_TYPE = (1 << 1), + + /* Pass Main, bContext and/or ReportList. */ FUNC_USE_MAIN = (1 << 2), FUNC_USE_CONTEXT = (1 << 3), FUNC_USE_REPORTS = (1 << 4), - FUNC_USE_SELF_ID = (1 << 11), + + + /***** Registering of python subclasses. *****/ + /* This function is part of the registerable class' interface, and can be implemented/redefined in python. */ + FUNC_REGISTER = (1 << 5), + /* Subclasses can choose not to implement this function. */ + FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6), + /* If not set, the python function implementing this call is not allowed to write into data-blocks. + * Except for WindowManager and Screen currently, see rna_id_write_error() in bpy_rna.c */ FUNC_ALLOW_WRITE = (1 << 12), - /* registering */ - FUNC_REGISTER = (1 << 5), - FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6), - - /* internal flags */ + /***** Internal flags. *****/ + /* UNUSED CURRENTLY? ??? */ FUNC_BUILTIN = (1 << 7), + /* UNUSED CURRENTLY. ??? */ FUNC_EXPORT = (1 << 8), + /* Function has been defined at runtime, not statically in RNA source code. */ FUNC_RUNTIME = (1 << 9), + /* UNUSED CURRENTLY? Function owns its identifier and description strings, and has to free them when deleted. */ FUNC_FREE_POINTERS = (1 << 10), } FunctionFlag;