From 5a221dd0dea81fbe31f5e6431911288e8e3f4b53 Mon Sep 17 00:00:00 2001 From: Andrew Hale Date: Thu, 2 Feb 2012 01:07:04 +0000 Subject: [PATCH 01/24] Fix for possible memory leak on creation of a vector using Vector.Range. It was possible to allocate an array of size<2 which would then raise an error on vector creation without freeing. Fix to ensure the behaviour of Vector.Range was the same as for builtin range() function. When specifying 3 arguments, the step argument wasn't being used to correctly calculate the vector size. Minor formatting edits for error messages. --- .../python/mathutils/mathutils_Vector.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 5848e6e8c75..0ca8878c96a 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -174,7 +174,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) case 2: if (start >= stop) { PyErr_SetString(PyExc_RuntimeError, - "Start value is larger" + "Start value is larger " "than the stop value"); return NULL; } @@ -184,16 +184,27 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) default: if (start >= stop) { PyErr_SetString(PyExc_RuntimeError, - "Start value is larger" + "Start value is larger " "than the stop value"); return NULL; } - size = (stop - start)/step; - if (size%step) - size++; + + size = (stop - start); + + if ((size % step) != 0) + size += step; + + size /= step; + break; } + if (size < 2) { + PyErr_SetString(PyExc_RuntimeError, + "Vector(): invalid size"); + return NULL; + } + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { From 697e77a49457d90821ffdfc21f0fcf60843eee05 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 04:43:35 +0000 Subject: [PATCH 02/24] fix [#29666] Duplicate entries in bpy.types Python operator subclasses and operator types each get their own SRNA, causing double ups for bpy.types.__dir__() From the operator type - these share names. * ot->ext.srna * ot->srna Note that this conflict is still there, this only disables 'ot->ext.srna' from being included in dir(bpy.types). --- source/blender/makesrna/intern/rna_wm.c | 8 ++++++- source/blender/python/intern/bpy_rna.c | 30 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 52a4a1db36b..b5c24ec568e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1050,6 +1050,9 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * rna_Operator_unregister(bmain, ot->ext.srna); } + /* XXX, this doubles up with the operator name [#29666] + * for now just remove from dir(bpy.types) */ + /* create a new operator type */ dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator"); RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */ @@ -1126,7 +1129,10 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, v rna_Operator_unregister(bmain, ot->ext.srna); } - /* create a new menu type */ + /* XXX, this doubles up with the operator name [#29666] + * for now just remove from dir(bpy.types) */ + + /* create a new operator type */ dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator"); dummyot.ext.data= data; dummyot.ext.call= call; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index bfb79ea6531..11e79fdee2a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -6298,6 +6298,8 @@ static struct PyMethodDef pyrna_basetype_methods[] = { {NULL, NULL, 0, NULL} }; +/* used to call ..._keys() direct, but we need to filter out operator subclasses */ +#if 0 static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self) { PyObject *list; @@ -6318,6 +6320,34 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self) return list; } +#else + +static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self) +{ + PyObject *ret = PyList_New(0); + PyObject *item; + + RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) { + StructRNA *srna = itemptr.data; + StructRNA *srna_base = RNA_struct_base(itemptr.data); + /* skip own operators, these double up [#29666] */ + if (srna_base == &RNA_Operator) { + /* do nothing */ + } + else { + /* add to python list */ + item = PyUnicode_FromString(RNA_struct_identifier(srna)); + PyList_Append(ret, item); + Py_DECREF(item); + } + } + RNA_PROP_END; + + return ret; +} + +#endif + static PyTypeObject pyrna_basetype_Type = BLANK_PYTHON_TYPE; PyObject *BPY_rna_types(void) From 369ae3d28d54cf2723ca8eddf1a76a7737b3fbe1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 04:59:30 +0000 Subject: [PATCH 03/24] internal cleanup, check. * remove duplicate operator, wasnt used. * added check for duplicate types for CTest. --- .../editors/animation/anim_channels_edit.c | 27 ++----------------- source/tests/bl_run_operators.py | 18 +++++++++++++ 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index a7c37d371e5..8ac7406462d 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1529,7 +1529,7 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - +/* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) { /* identifiers */ @@ -1551,7 +1551,7 @@ static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) /* setting to set */ ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } - +/* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) { /* identifiers */ @@ -1574,28 +1574,6 @@ static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } -static void ANIM_OT_channels_setting_invert (wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Invert Channel Setting"; - ot->idname= "ANIM_OT_channels_setting_toggle"; - ot->description= "Invert specified setting on all selected animation channels"; - - /* api callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= animchannels_setflag_exec; - ot->poll= animedit_poll_channels_active; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* props */ - /* flag-setting mode */ - RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_INVERT, "Mode", ""); - /* setting to set */ - ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); -} - static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) { /* identifiers */ @@ -2401,7 +2379,6 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_setting_enable); WM_operatortype_append(ANIM_OT_channels_setting_disable); - WM_operatortype_append(ANIM_OT_channels_setting_invert); WM_operatortype_append(ANIM_OT_channels_setting_toggle); WM_operatortype_append(ANIM_OT_channels_delete); diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index b64055df252..476ccc30b54 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -137,7 +137,25 @@ def ctx_weightpaint(): bpy.ops.object.mode_set(mode='WEIGHT_PAINT') +def bpy_check_type_duplicates(): + # non essential sanity check + bl_types = dir(bpy.types) + bl_types_unique = set(bl_types) + + if len(bl_types) != len(bl_types_unique): + print("Error, found duplicates in 'bpy.types'") + for t in sorted(bl_types_unique): + tot = bl_types.count(t) + if tot > 1: + print(" '%s', %d" % (t, tot)) + import sys + sys.exit(1) + + def main(): + + bpy_check_type_duplicates() + # bpy.ops.wm.read_factory_settings() import bpy operators = [] From d8c4e59f673cae8a2090a2821730fc01d1287518 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 05:11:42 +0000 Subject: [PATCH 04/24] * fix for error in shape transfer (wrong var name). * fix for error alligning object to the view when no space was set. also added blenderplayer start to CTest operator blacklist. --- release/scripts/modules/bpy_extras/object_utils.py | 2 +- release/scripts/startup/bl_operators/object.py | 9 ++++++--- source/tests/bl_run_operators.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index c9c1dc05476..66b774e6301 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -44,7 +44,7 @@ def add_object_align_init(context, operator): properties = operator.properties if operator is not None else None space_data = context.space_data - if space_data.type != 'VIEW_3D': + if space_data and space_data.type != 'VIEW_3D': space_data = None # location diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 2c329de3644..923a259c69c 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -20,7 +20,10 @@ import bpy from bpy.types import Operator -from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty +from bpy.props import (StringProperty, + BoolProperty, + EnumProperty, + IntProperty) class SelectPattern(Operator): @@ -54,7 +57,7 @@ class SelectPattern(Operator): pattern_match = fnmatch.fnmatchcase else: pattern_match = (lambda a, b: - fnmatch.fnmatchcase(a.upper(), b.upper())) + fnmatch.fnmatchcase(a.upper(), b.upper())) is_ebone = False obj = context.object if obj and obj.mode == 'POSE': @@ -490,7 +493,7 @@ class ShapeTransfer(Operator): def execute(self, context): ob_act = context.active_object - objects = [ob for ob in C.selected_editable_objects if ob != ob_act] + objects = [ob for ob in context.selected_editable_objects if ob != ob_act] if 1: # swap from/to, means we cant copy to many at once. if len(objects) != 1: diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index 476ccc30b54..b3781e94696 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -37,6 +37,7 @@ op_blacklist = ( "render.render", "*.*_export", "*.*_import", + "wm.blenderplayer_start", "wm.url_open", "wm.doc_view", "wm.path_open", From dd86ae6e3be80131e6975aa54353e5e7454bd5b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 05:55:01 +0000 Subject: [PATCH 05/24] fix [#28296] File selector crash when with filepath property disable browsing a file property within the file selector to avoid a crash. --- source/blender/editors/space_buttons/buttons_ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index b1a25d093d2..26516bcda99 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -43,6 +43,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_report.h" #include "WM_api.h" #include "WM_types.h" @@ -160,6 +161,11 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) FileBrowseOp *fbo; char *str; + if (CTX_wm_space_file(C)) { + BKE_report(op->reports, RPT_ERROR, "Can't activate a file selector, one already open"); + return OPERATOR_CANCELLED; + } + uiFileBrowseContextProperty(C, &ptr, &prop); if(!prop) From 38ad71f0fa1a7f91aa8721445b36ae11ff9a6f93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 07:37:44 +0000 Subject: [PATCH 06/24] Cleanup Only: replace numbers with defines. --- .../blender/makesrna/intern/rna_constraint.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index a3825531b19..8a1c56abedf 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -78,24 +78,24 @@ EnumPropertyItem constraint_type_items[] ={ {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem target_space_pchan_items[] = { - {0, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, - {2, "POSE", 0, "Pose Space", "The transformation of the target is only evaluated in the Pose Space, the target armature object transformation is ignored"}, - {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", "The transformation of the target bone is evaluated relative its local coordinate system, with the parent transformation added"}, - {1, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, + {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, + {CONSTRAINT_SPACE_POSE, "POSE", 0, "Pose Space", "The transformation of the target is only evaluated in the Pose Space, the target armature object transformation is ignored"}, + {CONSTRAINT_SPACE_PARLOCAL, "LOCAL_WITH_PARENT", 0, "Local With Parent", "The transformation of the target bone is evaluated relative its local coordinate system, with the parent transformation added"}, + {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem owner_space_pchan_items[] = { - {0, "WORLD", 0, "World Space", "The constraint is applied relative to the world coordinate system"}, - {2, "POSE", 0, "Pose Space", "The constraint is applied in Pose Space, the object transformation is ignored"}, - {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", "The constraint is applied relative to the local coordinate system of the object, with the parent transformation added"}, - {1, "LOCAL", 0, "Local Space", "The constraint is applied relative to the local coordinate sytem of the object"}, + {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space", "The constraint is applied relative to the world coordinate system"}, + {CONSTRAINT_SPACE_POSE, "POSE", 0, "Pose Space", "The constraint is applied in Pose Space, the object transformation is ignored"}, + {CONSTRAINT_SPACE_PARLOCAL, "LOCAL_WITH_PARENT", 0, "Local With Parent", "The constraint is applied relative to the local coordinate system of the object, with the parent transformation added"}, + {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", "The constraint is applied relative to the local coordinate sytem of the object"}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME static EnumPropertyItem space_object_items[] = { - {0, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, - {1, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, + {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, + {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, {0, NULL, 0, NULL, NULL}}; #include "BKE_animsys.h" From ab4dbc6d7844f49292d1811bef1fa782e1002f4e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 08:04:06 +0000 Subject: [PATCH 07/24] fix [#30051] Copy Scale constraint overrides Inherit Scale from parent space conversion in constraint code ignored inherit scale option. --- source/blender/blenkernel/intern/constraint.c | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 59667743520..59374985d7d 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -287,8 +287,17 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 invert_m4_m4(imat, diff_mat); } else { + if (pchan->bone->flag & BONE_NO_SCALE) { + float tmat[4][4]; + copy_m4_m4(tmat, pchan->parent->pose_mat); + normalize_m4(tmat); + mult_m4_m4m4(diff_mat, tmat, offs_bone); + } + else { + mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); + } + /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); invert_m4_m4(imat, diff_mat); } } @@ -348,7 +357,16 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 } else { /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); + if (pchan->bone->flag & BONE_NO_SCALE) { + float tmat[4][4]; + copy_m4_m4(tmat, pchan->parent->pose_mat); + normalize_m4(tmat); + mult_m4_m4m4(diff_mat, tmat, offs_bone); + } + else { + mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); + } + copy_m4_m4(tempmat, mat); mult_m4_m4m4(mat, diff_mat, tempmat); } From 722e0d38ac34923be344443651b8c7c39a9d86b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 08:47:46 +0000 Subject: [PATCH 08/24] Code Cleanup: de-duplicate bone space calculation ~(35 sloc) --- source/blender/blenkernel/intern/constraint.c | 139 +++++++----------- 1 file changed, 51 insertions(+), 88 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 59374985d7d..33b17f27ac8 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -220,6 +220,50 @@ void constraints_clear_evalob (bConstraintOb *cob) /* -------------- Space-Conversion API -------------- */ +static void constraint_pchan_diff_mat(bPoseChannel *pchan, float diff_mat[4][4]) +{ + if (pchan->parent) { + float offs_bone[4][4]; + + /* construct offs_bone the same way it is done in armature.c */ + copy_m4_m3(offs_bone, pchan->bone->bone_mat); + copy_v3_v3(offs_bone[3], pchan->bone->head); + offs_bone[3][1] += pchan->bone->parent->length; + + if (pchan->bone->flag & BONE_HINGE) { + /* pose_mat = par_pose-space_location * chan_mat */ + float tmat[4][4]; + + /* the rotation of the parent restposition */ + copy_m4_m4(tmat, pchan->bone->parent->arm_mat); + + /* the location of actual parent transform */ + copy_v3_v3(tmat[3], offs_bone[3]); + zero_v3(offs_bone[3]); + mul_m4_v3(pchan->parent->pose_mat, tmat[3]); + + mult_m4_m4m4(diff_mat, tmat, offs_bone); + } + else { + /* pose_mat = par_pose_mat * bone_mat * chan_mat */ + if (pchan->bone->flag & BONE_NO_SCALE) { + float tmat[4][4]; + copy_m4_m4(tmat, pchan->parent->pose_mat); + normalize_m4(tmat); + mult_m4_m4m4(diff_mat, tmat, offs_bone); + } + else { + mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); + } + } + } + else { + /* pose_mat = chan_mat * arm_mat */ + copy_m4_m4(diff_mat, pchan->bone->arm_mat); + } +} + + /* This function is responsible for the correct transformations/conversions * of a matrix from one space to another for constraint evaluation. * For now, this is only implemented for Objects and PoseChannels. @@ -263,49 +307,10 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* pose to local */ else if (to == CONSTRAINT_SPACE_LOCAL) { if (pchan->bone) { - if (pchan->parent) { - float offs_bone[4][4]; - - /* construct offs_bone the same way it is done in armature.c */ - copy_m4_m3(offs_bone, pchan->bone->bone_mat); - copy_v3_v3(offs_bone[3], pchan->bone->head); - offs_bone[3][1]+= pchan->bone->parent->length; - - if (pchan->bone->flag & BONE_HINGE) { - /* pose_mat = par_pose-space_location * chan_mat */ - float tmat[4][4]; - - /* the rotation of the parent restposition */ - copy_m4_m4(tmat, pchan->bone->parent->arm_mat); - - /* the location of actual parent transform */ - copy_v3_v3(tmat[3], offs_bone[3]); - offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - - mult_m4_m4m4(diff_mat, tmat, offs_bone); - invert_m4_m4(imat, diff_mat); - } - else { - if (pchan->bone->flag & BONE_NO_SCALE) { - float tmat[4][4]; - copy_m4_m4(tmat, pchan->parent->pose_mat); - normalize_m4(tmat); - mult_m4_m4m4(diff_mat, tmat, offs_bone); - } - else { - mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); - } + constraint_pchan_diff_mat(pchan, diff_mat); + + invert_m4_m4(imat, diff_mat); - /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - invert_m4_m4(imat, diff_mat); - } - } - else { - /* pose_mat = chan_mat * arm_mat */ - invert_m4_m4(imat, pchan->bone->arm_mat); - } - copy_m4_m4(tempmat, mat); mult_m4_m4m4(mat, imat, tempmat); @@ -330,53 +335,11 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 { /* local to pose - do inverse procedure that was done for pose to local */ if (pchan->bone) { - /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */ - if (pchan->parent) { - float offs_bone[4][4]; - - /* construct offs_bone the same way it is done in armature.c */ - copy_m4_m3(offs_bone, pchan->bone->bone_mat); - copy_v3_v3(offs_bone[3], pchan->bone->head); - offs_bone[3][1]+= pchan->bone->parent->length; - - if (pchan->bone->flag & BONE_HINGE) { - /* pose_mat = par_pose-space_location * chan_mat */ - float tmat[4][4]; - - /* the rotation of the parent restposition */ - copy_m4_m4(tmat, pchan->bone->parent->arm_mat); - - /* the location of actual parent transform */ - copy_v3_v3(tmat[3], offs_bone[3]); - zero_v3(offs_bone[3]); - mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - - mult_m4_m4m4(diff_mat, tmat, offs_bone); - copy_m4_m4(tempmat, mat); - mult_m4_m4m4(mat, diff_mat, tempmat); - } - else { - /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - if (pchan->bone->flag & BONE_NO_SCALE) { - float tmat[4][4]; - copy_m4_m4(tmat, pchan->parent->pose_mat); - normalize_m4(tmat); - mult_m4_m4m4(diff_mat, tmat, offs_bone); - } - else { - mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); - } + /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */ + constraint_pchan_diff_mat(pchan, diff_mat); - copy_m4_m4(tempmat, mat); - mult_m4_m4m4(mat, diff_mat, tempmat); - } - } - else { - copy_m4_m4(diff_mat, pchan->bone->arm_mat); - - copy_m4_m4(tempmat, mat); - mult_m4_m4m4(mat, diff_mat, tempmat); - } + copy_m4_m4(tempmat, mat); + mult_m4_m4m4(mat, diff_mat, tempmat); } /* use pose-space as stepping stone for other spaces */ From 6a30321434089fb4a4e189d72d0c4c1355c534a3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2012 08:48:43 +0000 Subject: [PATCH 09/24] Fix #29381: Navmeshs frees not guarded allocated memory and leaked There were two issues discovered: - Triangles mapping didn't free in buildNavMeshData if there's no recast data for an object - KX_NavMeshObject used not-guarded allocation for polygons storage, but used guarded freeing stuff to free used memory, producing error messages in the console and leading to memory leak. Wasn't actually harmful for users -- there was no memory corruptions and error happens only when object was set up in a way when navmesh can't work in theory. --- source/blender/blenkernel/intern/navmesh_conversion.c | 4 +++- source/gameengine/Ketsji/KX_NavMeshObject.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index e3b5b83964e..e6749730fc9 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -344,7 +344,7 @@ int buildNavMeshData(const int nverts, const float* verts, int *vertsPerPoly_r, int **dtrisToPolysMap_r, int **dtrisToTrisMap_r) { - int *trisMapping = MEM_callocN(sizeof(int)*ntris, "buildNavMeshData trisMapping"); + int *trisMapping; int i; struct SortContext context; int validTriStart, prevPolyIdx, curPolyIdx, newPolyIdx, prevpolyidx; @@ -360,6 +360,8 @@ int buildNavMeshData(const int nverts, const float* verts, return 0; } + trisMapping = MEM_callocN(sizeof(int)*ntris, "buildNavMeshData trisMapping"); + //sort the triangles by polygon idx for (i=0; i Date: Thu, 2 Feb 2012 10:34:44 +0000 Subject: [PATCH 10/24] Patch #29705: Collada export didn't export mesh name. Added name= parameter to geometry nodes in Collada export --- source/blender/collada/GeometryExporter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 8bc9755faae..4a838e928da 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -65,6 +65,7 @@ void GeometryExporter::operator()(Object *ob) #endif Mesh *me = (Mesh*)ob->data; std::string geom_id = get_geometry_id(ob); + std::string geom_name = id_name(ob->data); std::vector nor; std::vector norind; @@ -78,7 +79,7 @@ void GeometryExporter::operator()(Object *ob) create_normals(nor, norind, me); // openMesh(geoId, geoName, meshId) - openMesh(geom_id); + openMesh(geom_id, geom_name); // writes for vertex coords createVertsSource(geom_id, me); From 2c5d936c3a29992b7420098b482e11f396461c8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 11:08:48 +0000 Subject: [PATCH 11/24] patch from Peter Stern to fix CMake building on OSX (without manual editing of configuration) --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb6b946b0c6..fb66c1cc7b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,6 +249,12 @@ if(APPLE) "Choose the minimum OSX version required: 10.4 or 10.5" FORCE) endif() + if(${CMAKE_GENERATOR} MATCHES "Xcode" AND (${XCODE_VERSION} VERSION_GREATER 3)) + # Xcode 4 defaults to the Apple LLVM Compiler. + # Override the default compiler selection because Blender only compiles with gcc + set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") + message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION}) + endif() option(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON) option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF) option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF) From 45155785e382cb27254bebbcec6a0123b89b7694 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 11:12:41 +0000 Subject: [PATCH 12/24] own attempted simplification to previous patch was incorrect. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb66c1cc7b5..47d40bb48c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,7 @@ if(APPLE) "Choose the minimum OSX version required: 10.4 or 10.5" FORCE) endif() - if(${CMAKE_GENERATOR} MATCHES "Xcode" AND (${XCODE_VERSION} VERSION_GREATER 3)) + if(${CMAKE_GENERATOR} MATCHES "Xcode" AND (${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4)) # Xcode 4 defaults to the Apple LLVM Compiler. # Override the default compiler selection because Blender only compiles with gcc set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") From 01d0e279dba2cba3f07d0e3ed3d4a685cebcc3c4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Feb 2012 13:21:38 +0000 Subject: [PATCH 13/24] Fix related to #30053: crash rendering scene strips without a scene (due to missing library). --- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/render/intern/source/pipeline.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 08b53115919..d18a71d3c55 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -745,7 +745,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->scene = sce; } - seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; + seq->len= (seq->scene)? seq->scene->r.efra - seq->scene->r.sfra + 1: 0; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 604ba189dcf..100b12aa169 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1745,7 +1745,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) check_comp= 0; while(seq) { - if(seq->type == SEQ_SCENE) { + if(seq->type == SEQ_SCENE && seq->scene) { if(!seq->scene_camera) { if(!seq->scene->camera && !scene_find_camera(seq->scene)) { if(seq->scene == scene) { From 8f01ad9bf884f15c9cd6d19971f8ab3a1e1e176c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Feb 2012 13:35:19 +0000 Subject: [PATCH 14/24] Fix #29056: keymapping NDOF motion events not working correct. Motion even type was missing in python. --- source/blender/makesrna/intern/rna_wm.c | 63 +++++++++++++------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index b5c24ec568e..8ae597f2d1c 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -295,43 +295,44 @@ EnumPropertyItem event_type_items[] = { {TIMER1, "TIMER1", 0, "Timer 1", ""}, {TIMER2, "TIMER2", 0, "Timer 2", ""}, {0, "", 0, NULL, NULL}, + {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", ""}, /* buttons on all 3dconnexion devices */ - {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "Menu", ""}, - {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "Fit", ""}, + {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", ""}, + {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", ""}, /* view buttons */ - {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "Top", ""}, - {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "Bottom", ""}, - {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "Left", ""}, - {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "Right", ""}, - {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "Front", ""}, - {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "Back", ""}, + {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", ""}, + {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", ""}, + {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", ""}, + {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", ""}, + {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", ""}, + {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", ""}, /* more views */ - {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "ISO 1", ""}, - {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "ISO 2", ""}, + {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF ISO 1", ""}, + {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF ISO 2", ""}, /* 90 degree rotations */ - {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "Roll CW", ""}, - {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "Roll CCW", ""}, - {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "Spin CW", ""}, - {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "Spin CCW", ""}, - {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "Tilt CW", ""}, - {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "Tilt CCW", ""}, + {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", ""}, + {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", ""}, + {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", ""}, + {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", ""}, + {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", ""}, + {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", ""}, /* device control */ - {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "Rotate", ""}, - {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "Pan/Zoom", ""}, - {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "Dominant", ""}, - {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "Plus", ""}, - {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "Minus", ""}, + {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", ""}, + {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", ""}, + {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", ""}, + {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", ""}, + {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", ""}, /* general-purpose buttons */ - {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "Button 1", ""}, - {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "Button 2", ""}, - {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "Button 3", ""}, - {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "Button 4", ""}, - {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "Button 5", ""}, - {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "Button 6", ""}, - {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "Button 7", ""}, - {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "Button 8", ""}, - {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "Button 9", ""}, - {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "Button 10", ""}, + {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", ""}, + {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", ""}, + {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", ""}, + {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", ""}, + {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", ""}, + {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", ""}, + {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", ""}, + {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", ""}, + {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", ""}, + {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", ""}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem keymap_propvalue_items[] = { From 4aaf59324e0ea5fecf28c1e9d54b1aed9b135dc5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Feb 2012 14:07:24 +0000 Subject: [PATCH 15/24] Fix #27213: editing color ramp "Pos:" number value did not update the ramp properly, when moving the current point before another. --- source/blender/blenkernel/BKE_texture.h | 2 +- source/blender/blenkernel/intern/texture.c | 32 ++++++++++++------- .../editors/interface/interface_handlers.c | 27 +--------------- .../editors/interface/interface_templates.c | 14 ++++++++ 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 7f321abf48e..a67a06ef9fb 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -69,9 +69,9 @@ void init_colorband(struct ColorBand *coba, int rangetype); struct ColorBand *add_colorband(int rangetype); int do_colorband(const struct ColorBand *coba, float in, float out[4]); void colorband_table_RGBA(struct ColorBand *coba, float **array, int *size); -int vergcband(const void *a1, const void *a2); struct CBData *colorband_element_add(struct ColorBand *coba, float position); int colorband_element_remove(struct ColorBand *coba, int index); +void colorband_update_sort(struct ColorBand *coba); void default_tex(struct Tex *tex); struct Tex *add_texture(const char *name); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 88858c9ff51..f854397ef05 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -478,6 +478,26 @@ int vergcband(const void *a1, const void *a2) return 0; } +void colorband_update_sort(ColorBand *coba) +{ + int a; + + if(coba->tot<2) + return; + + for(a=0; atot; a++) + coba->data[a].cur= a; + + qsort(coba->data, coba->tot, sizeof(CBData), vergcband); + + for(a=0; atot; a++) { + if(coba->data[a].cur==coba->cur) { + coba->cur= a; + break; + } + } +} + CBData *colorband_element_add(struct ColorBand *coba, float position) { int a; @@ -503,17 +523,7 @@ CBData *colorband_element_add(struct ColorBand *coba, float position) coba->tot++; coba->cur = coba->tot-1; - for(a = 0; a < coba->tot; a++) - coba->data[a].cur = a; - - qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - - for(a = 0; a < coba->tot; a++) { - if(coba->data[a].cur == coba->cur) { - coba->cur = a; - break; - } - } + colorband_update_sort(coba); return coba->data + coba->cur; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cfb375c2558..cadc57c9881 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3607,31 +3607,6 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle } -static int verg_colorband(const void *a1, const void *a2) -{ - const CBData *x1=a1, *x2=a2; - - if( x1->pos > x2->pos ) return 1; - else if( x1->pos < x2->pos) return -1; - return WM_UI_HANDLER_CONTINUE; -} - -static void ui_colorband_update(ColorBand *coba) -{ - int a; - - if(coba->tot<2) return; - - for(a=0; atot; a++) coba->data[a].cur= a; - qsort(coba->data, coba->tot, sizeof(CBData), verg_colorband); - for(a=0; atot; a++) { - if(coba->data[a].cur==coba->cur) { - coba->cur= a; - break; - } - } -} - static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx) { float dx; @@ -3644,7 +3619,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); - ui_colorband_update(data->coba); + colorband_update_sort(data->coba); data->dragcbd= data->coba->data + data->coba->cur; /* because qsort */ data->draglastx= mx; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1f6165852d7..4a797b0e960 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1305,6 +1305,16 @@ static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v) rna_update_cb(C, cb_v, NULL); } +static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v) +{ + uiBut *bt= bt_v; + ColorBand *coba= coba_v; + + /* sneaky update here, we need to sort the colorband points to be in order, + however the RNA pointer then is wrong, so we update it */ + colorband_update_sort(coba); + bt->rnapoin.data = coba->data + coba->cur; +} /* offset aligns from bottom, standard width 300, height 115 */ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb) @@ -1348,7 +1358,11 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); row= uiLayoutRow(layout, 0); + uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE); + bt= block->buttons.last; + uiButSetFunc(bt, colorband_update_cb, bt, coba); + uiItemR(row, &ptr, "color", 0, "", ICON_NONE); } From aef11b52d06766aa09342051bee3bb2a14c049cc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2012 15:15:52 +0000 Subject: [PATCH 16/24] Added option to fill caps of bevelled curves. It can be found in Shape panel below Fill label. If this option is enabled, caps of curve will be filled. --- .../startup/bl_ui/properties_data_curve.py | 3 +- source/blender/blenkernel/intern/displist.c | 93 ++++++++++++++----- source/blender/makesdna/DNA_curve_types.h | 1 + source/blender/makesrna/intern/rna_curve.c | 9 +- 4 files changed, 79 insertions(+), 27 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 79d722eb19d..f6fcb0a89cd 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -111,7 +111,8 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel): sub = col.column() sub.active = (curve.dimensions == '2D' or (curve.bevel_object is None and curve.dimensions == '3D')) sub.prop(curve, "fill_mode", text="") - col.prop(curve, "use_fill_deform", text="Fill Deformed") + col.prop(curve, "use_fill_deform") + col.prop(curve, "use_fill_caps") class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel): diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index e0f76917368..71dcc1a69a6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1179,6 +1179,63 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, forRender, originalVerts, deformedVerts); } +static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r) +{ + float *fp, *data = *data_r; + int b; + + fp = dlb->verts; + for (b = 0; bnr; b++,fp += 3,data += 3) { + if(cu->flag & CU_3D) { + float vec[3]; + + vec[0] = fp[1]+widfac; + vec[1] = fp[2]; + vec[2 ]= 0.0; + + mul_qt_v3(bevp->quat, vec); + + data[0] = bevp->vec[0] + fac*vec[0]; + data[1] = bevp->vec[1] + fac*vec[1]; + data[2] = bevp->vec[2] + fac*vec[2]; + } + else { + data[0] = bevp->vec[0] + fac*(widfac+fp[1])*bevp->sina; + data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa; + data[2] = bevp->vec[2] + fac*fp[2]; + } + } + + *data_r = data; +} + +static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, int flipnormal, ListBase *dispbase) +{ + ListBase tmpdisp = {NULL, NULL}; + DispList *dl; + float *data; + + dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); + dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); + + dl->type= DL_POLY; + + dl->parts= 1; + dl->nr= dlb->nr; + dl->col= nu->mat_nr; + dl->charidx= nu->charidx; + + /* dl->rt will be used as flag for render face and */ + /* CU_2D conflicts with R_NOPUNOFLIP */ + dl->rt= nu->flag & ~CU_2D; + + rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); + + BLI_addtail(&tmpdisp, dl); + filldisplist(&tmpdisp, dispbase, flipnormal); + freedisplist(&tmpdisp); +} + static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, int forRender, int forOrco) { @@ -1223,9 +1280,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba for (; bl && nu; bl=bl->next,nu=nu->next) { DispList *dl; - float *fp1, *data; + float *data; BevPoint *bevp; - int a,b; + int a; if (bl->nr) { /* blank bevel lists can happen */ @@ -1264,7 +1321,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba DispList *dlb; for (dlb=dlbev.first; dlb; dlb=dlb->next) { - + ListBase capbase = {NULL, NULL}; + /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); @@ -1302,32 +1360,19 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); } - /* rotate bevel piece and write in data */ - fp1= dlb->verts; - for (b=0; bnr; b++,fp1+=3,data+=3) { - if(cu->flag & CU_3D) { - float vec[3]; - - vec[0]= fp1[1]+widfac; - vec[1]= fp1[2]; - vec[2]= 0.0; + /* rotate bevel piece and write in data */ + rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); - mul_qt_v3(bevp->quat, vec); - - data[0]= bevp->vec[0] + fac*vec[0]; - data[1]= bevp->vec[1] + fac*vec[1]; - data[2]= bevp->vec[2] + fac*vec[2]; - } - else { - data[0]= bevp->vec[0] + fac*(widfac+fp1[1])*bevp->sina; - data[1]= bevp->vec[1] + fac*(widfac+fp1[1])*bevp->cosa; - data[2]= bevp->vec[2] + fac*fp1[2]; - } + if (cu->flag & CU_FILL_CAPS) { + if (a == 0 || a == bl->nr - 1) + fillBevelCap(cu, nu, bevp, dlb, fac, widfac, a == 0, &capbase); } } - + /* gl array drawing: using indices */ displist_surf_indices(dl); + + BLI_movelisttolist(dispbase, &capbase); } } } diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index ffcc516f393..455738c840b 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -260,6 +260,7 @@ typedef struct Curve { #define CU_DS_EXPAND 2048 #define CU_PATH_RADIUS 4096 /* make use of the path radius if this is enabled (default for new curves) */ #define CU_DEFORM_FILL 8192 /* fill 2d curve after deformation */ +#define CU_FILL_CAPS 16384 /* fill bevel caps */ /* twist mode */ #define CU_TWIST_Z_UP 0 diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 5fd67efba1d..088f2dba0bb 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1386,9 +1386,14 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "use_fill_deform", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_DEFORM_FILL); - RNA_def_property_ui_text(prop, "Fill deformed", "Fill curve after applying shape keys and all modifiers"); + RNA_def_property_ui_text(prop, "Fill Deformed", "Fill curve after applying shape keys and all modifiers"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - + + prop= RNA_def_property(srna, "use_fill_caps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FILL_CAPS); + RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for bevelled curves"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + /* texture space */ prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE); From 1471a1983c4814467aab583303d50fdb0c059c5c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2012 18:50:44 +0000 Subject: [PATCH 17/24] Fix for recent bevel cap option "Holes" used to be ignored (i.e. when using "Text" as bevel object "e" wouldn't have a "hole"). Resolved by collecting all polys needed for top and bottom cap and filling them at once --- source/blender/blenkernel/intern/displist.c | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 71dcc1a69a6..3c3a043e593 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1209,9 +1209,8 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid *data_r = data; } -static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, int flipnormal, ListBase *dispbase) +static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, ListBase *dispbase) { - ListBase tmpdisp = {NULL, NULL}; DispList *dl; float *data; @@ -1231,9 +1230,7 @@ static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, flo rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); - BLI_addtail(&tmpdisp, dl); - filldisplist(&tmpdisp, dispbase, flipnormal); - freedisplist(&tmpdisp); + BLI_addtail(dispbase, dl); } static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, @@ -1319,10 +1316,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } else { DispList *dlb; + ListBase bottom_capbase = {NULL, NULL}; + ListBase top_capbase = {NULL, NULL}; for (dlb=dlbev.first; dlb; dlb=dlb->next) { - ListBase capbase = {NULL, NULL}; - /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); @@ -1364,15 +1361,22 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); if (cu->flag & CU_FILL_CAPS) { - if (a == 0 || a == bl->nr - 1) - fillBevelCap(cu, nu, bevp, dlb, fac, widfac, a == 0, &capbase); + if (a == 0) + fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &bottom_capbase); + else if (a == bl->nr - 1) + fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &top_capbase); } } /* gl array drawing: using indices */ displist_surf_indices(dl); + } - BLI_movelisttolist(dispbase, &capbase); + if(bottom_capbase.first) { + filldisplist(&bottom_capbase, dispbase, 1); + filldisplist(&top_capbase, dispbase, 0); + freedisplist(&bottom_capbase); + freedisplist(&top_capbase); } } } From 3b3d811bf0a7e1a69a863d6b248be6dff74ada44 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2012 19:20:51 +0000 Subject: [PATCH 18/24] Disallow fill caps for curves without bevel object. It's getting complicated to detect which part of curve is actually a cap in cases like extruded 2d curve with non-zero depth. --- release/scripts/startup/bl_ui/properties_data_curve.py | 5 ++++- source/blender/blenkernel/intern/displist.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index f6fcb0a89cd..f8e3d48d40c 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -112,7 +112,6 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel): sub.active = (curve.dimensions == '2D' or (curve.bevel_object is None and curve.dimensions == '3D')) sub.prop(curve, "fill_mode", text="") col.prop(curve, "use_fill_deform") - col.prop(curve, "use_fill_caps") class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel): @@ -166,6 +165,10 @@ class DATA_PT_geometry_curve(CurveButtonsPanel, Panel): col.label(text="Bevel Object:") col.prop(curve, "bevel_object", text="") + row = col.row() + row.active = curve.bevel_object != None + row.prop(curve, "use_fill_caps") + class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel): bl_label = "Path Animation" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3c3a043e593..b14b9b43cf3 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1360,7 +1360,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* rotate bevel piece and write in data */ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); - if (cu->flag & CU_FILL_CAPS) { + if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { if (a == 0) fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &bottom_capbase); else if (a == bl->nr - 1) From 60dc2f521b05794901109a55caa5c810be6b6128 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2012 19:37:50 +0000 Subject: [PATCH 19/24] Camera tracking: fix for Clean Tracks operator which used to always use properties values from previous operator run instead of using values from tool settings. --- source/blender/editors/space_clip/tracking_ops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 935dda864bf..6a9c2755330 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -3417,15 +3417,15 @@ static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - int frames= RNA_int_get(op->ptr, "frames"); - float error= RNA_float_get(op->ptr, "error"); - int action= RNA_enum_get(op->ptr, "action"); - if(frames==0 && error==0 && action==0) { + if(!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); + + if(!RNA_struct_property_is_set(op->ptr, "error")) RNA_float_set(op->ptr, "error", clip->tracking.settings.clean_error); + + if(!RNA_struct_property_is_set(op->ptr, "action")) RNA_enum_set(op->ptr, "action", clip->tracking.settings.clean_action); - } return clean_tracks_exec(C, op); } From e3958015db99927329604044094be1e6d3453e2d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 21:07:56 +0000 Subject: [PATCH 20/24] Code Cleanup: check is / is not when comparing singletons. --- doc/blender_file_format/BlendFileDnaExporter_25.py | 6 +++--- doc/blender_file_format/BlendFileReader.py | 2 +- intern/cycles/app/io_export_cycles_xml.py | 2 +- release/scripts/startup/bl_ui/properties_data_curve.py | 2 +- source/blender/python/rna_dump.py | 2 +- source/tests/bl_mesh_modifiers.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py index bc5b2e73c7e..a201f618fbb 100755 --- a/doc/blender_file_format/BlendFileDnaExporter_25.py +++ b/doc/blender_file_format/BlendFileDnaExporter_25.py @@ -206,13 +206,13 @@ class DNACatalogHTML: ${size} """ - if field.Type.Structure == None or field.Name.IsPointer(): + if field.Type.Structure is None or field.Name.IsPointer(): # ${reference} reference = field.Name.AsReference(parentReference) # ${struct} - if parentReference != None: + if parentReference is not None: struct = '{0}'.format(structure.Type.Name) else: struct = structure.Type.Name @@ -240,7 +240,7 @@ class DNACatalogHTML: structure_field = Template(structure_field_template).substitute(d) - elif field.Type.Structure != None: + elif field.Type.Structure is not None: reference = field.Name.AsReference(parentReference) structure_field = self.StructureFields(field.Type.Structure, reference, offset) diff --git a/doc/blender_file_format/BlendFileReader.py b/doc/blender_file_format/BlendFileReader.py index 313c8c7ff5d..88eb71b3ce2 100644 --- a/doc/blender_file_format/BlendFileReader.py +++ b/doc/blender_file_format/BlendFileReader.py @@ -329,7 +329,7 @@ class DNAName: self.Name = name def AsReference(self, parent): - if parent == None: + if parent is None: result = "" else: result = parent+"." diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py index 2314d935214..3ba9e201d11 100644 --- a/intern/cycles/app/io_export_cycles_xml.py +++ b/intern/cycles/app/io_export_cycles_xml.py @@ -93,7 +93,7 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper): @classmethod def poll(cls, context): - return context.active_object != None + return (context.active_object is not None) def execute(self, context): filepath = bpy.path.ensure_ext(self.filepath, ".xml") diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index f8e3d48d40c..3aa995353b2 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -166,7 +166,7 @@ class DATA_PT_geometry_curve(CurveButtonsPanel, Panel): col.prop(curve, "bevel_object", text="") row = col.row() - row.active = curve.bevel_object != None + row.active = (curve.bevel_object is not None) row.prop(curve, "use_fill_caps") diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py index df902886f30..489f011e693 100644 --- a/source/blender/python/rna_dump.py +++ b/source/blender/python/rna_dump.py @@ -79,7 +79,7 @@ def seek(r, txt, recurs): except: keys = None - if keys != None: + if keys is not None: if PRINT_DATA: print(txt + '.keys() - ' + str(r.keys())) diff --git a/source/tests/bl_mesh_modifiers.py b/source/tests/bl_mesh_modifiers.py index 917ccbc0d24..0495f5d9f98 100644 --- a/source/tests/bl_mesh_modifiers.py +++ b/source/tests/bl_mesh_modifiers.py @@ -74,7 +74,7 @@ def render_gl(context, filepath, shade): def render_gl_all_modes(context, obj, filepath=""): - assert(obj != None) + assert(obj is not None) assert(filepath != "") scene = context.scene From 5c9ad8653a99d8a0aa247e63ba25d0291328535e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Feb 2012 21:46:11 +0000 Subject: [PATCH 21/24] Fix #29921: render rasterization error in a corner case, only happened on 32bit builds because of extended float precision, slightly tweaked code to avoid that, so that it works the same as on 64bit. --- source/blender/render/intern/source/zbuf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index a46b3791693..0d5aed7dadb 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -212,9 +212,9 @@ void fillrect(int *rect, int x, int y, int val) } /* based on Liang&Barsky, for clipping of pyramidical volume */ -static short cliptestf(float p, float q, float *u1, float *u2) +static short cliptestf(float a, float b, float c, float d, float *u1, float *u2) { - float r; + float p= a + b, q= c + d, r; if(p<0.0f) { if(q Date: Thu, 2 Feb 2012 21:46:29 +0000 Subject: [PATCH 22/24] Fix #30043: typing ctrl+Z in text field adds a square. For ascii these control characters were already filtered out, do the same now for utf-8. --- source/blender/windowmanager/intern/wm_event_system.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 079833f693f..621e5449223 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2684,9 +2684,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } event.utf8_buf[0]= '\0'; } - else if (event.ascii<32 && event.ascii > 0) { - event.ascii= '\0'; - /* TODO. should this also zero utf8?, dont for now, campbell */ + else { + if (event.ascii<32 && event.ascii > 0) + event.ascii= '\0'; + if (event.utf8_buf[0]<32 && event.utf8_buf[0] > 0) + event.utf8_buf[0]= '\0'; } if (event.utf8_buf[0]) { From 07919930300e6055c5452ec2b54150e70babd5fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Feb 2012 23:58:46 +0000 Subject: [PATCH 23/24] Minor Speedup: avoid for() loop over all faces in fluidsim by passing an example face to the mesh read function (also avoid a lot of int -> short/char conversions). --- source/blender/blenkernel/intern/texture.c | 2 - .../modifiers/intern/MOD_fluidsim_util.c | 47 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index f854397ef05..4c40dca3365 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -500,8 +500,6 @@ void colorband_update_sort(ColorBand *coba) CBData *colorband_element_add(struct ColorBand *coba, float position) { - int a; - if(coba->tot==MAXCOLORBAND) { return NULL; } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 38909a2671a..0cdb2c8b057 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -152,9 +152,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) void fluidsim_free(FluidsimModifierData *fluidmd) { -#ifdef WITH_MOD_FLUID - if(fluidmd) - { + if(fluidmd) { if(fluidmd->fss->meshVelocities) { MEM_freeN(fluidmd->fss->meshVelocities); @@ -162,16 +160,13 @@ void fluidsim_free(FluidsimModifierData *fluidmd) } MEM_freeN(fluidmd->fss); } -#else - (void)fluidmd; /* unused */ -#endif return; } #ifdef WITH_MOD_FLUID /* read .bobj.gz file into a fluidsimDerivedMesh struct */ -static DerivedMesh *fluidsim_read_obj(const char *filename) +static DerivedMesh *fluidsim_read_obj(const char *filename, const MFace *mf_example) { int wri = 0,i; int gotBytes; @@ -183,6 +178,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename) short *normals, *no_s; float no[3]; + const short mf_mat_nr = mf_example->mat_nr; + const char mf_flag = mf_example->flag; + // ------------------------------------------------ // get numverts + numfaces first // ------------------------------------------------ @@ -287,6 +285,10 @@ static DerivedMesh *fluidsim_read_obj(const char *filename) gotBytes = gzread(gzf, face, sizeof(int) * 3); + /* initialize from existing face */ + mf->mat_nr = mf_mat_nr; + mf->flag = mf_flag; + // check if 3rd vertex has index 0 (not allowed in blender) if(face[2]) { @@ -452,8 +454,8 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim FluidsimSettings *fss = fluidmd->fss; DerivedMesh *dm = NULL; MFace *mface; - int numfaces; - int mat_nr, flag, i; + MFace mf_example = {0}; + if(!useRenderParams) { displaymode = fss->guiDisplayMode; @@ -481,7 +483,15 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - dm = fluidsim_read_obj(targetFile); + // assign material + flags to new dm + // if there's no faces in original dm, keep materials and flags unchanged + mface = orgdm->getFaceArray(orgdm); + if (mface) { + mf_example = *mface; + } + /* else leave NULL'd */ + + dm = fluidsim_read_obj(targetFile, &mf_example); if(!dm) { @@ -502,23 +512,6 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim return NULL; } - // assign material + flags to new dm - // if there's no faces in original dm, keep materials and flags unchanged - mface = orgdm->getFaceArray(orgdm); - - if(mface) { - mat_nr = mface[0].mat_nr; - flag = mface[0].flag; - - mface = dm->getFaceArray(dm); - numfaces = dm->getNumFaces(dm); - for(i=0; i Date: Fri, 3 Feb 2012 01:06:32 +0000 Subject: [PATCH 24/24] fix [#27953] VSE: weird drawing and placement issues strips during 'E' was calculating meta / effect in wrong order causing delay, now calculate selected meta's, then all effects after tramsforming. --- .../editors/transform/transform_conversions.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index ced6bb8da63..86b5ab9421b 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2303,12 +2303,17 @@ void flushTransSeq(TransInfo *t) if (ELEM(t->mode, TFM_SEQ_SLIDE, TFM_TIME_TRANSLATE)) { /* originally TFM_TIME_EXTEND, transform changes */ /* Special annoying case here, need to calc metas with TFM_TIME_EXTEND only */ - seq= seqbasep->first; - while(seq) { - if (seq->type == SEQ_META && seq->flag & SELECT) + /* calc all meta's then effects [#27953] */ + for (seq = seqbasep->first; seq; seq = seq->next) { + if (seq->type == SEQ_META && seq->flag & SELECT) { calc_sequence(t->scene, seq); - seq= seq->next; + } + } + for (seq = seqbasep->first; seq; seq = seq->next) { + if (seq->seq1 || seq->seq2 || seq->seq3) { + calc_sequence(t->scene, seq); + } } }