diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index cf6e17a895f..f33ba9edc56 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -272,7 +272,8 @@ def blend_bone_list(obj, apply_bones, from_bones, to_bones, target_bone=None, ta new_pbone = obj.pose.bones[new_bone_name] - if not new_pbone.bone.connected: + # if the bone is connected or its location is totally locked then dont add location blending. + if not (new_pbone.bone.connected or (False not in new_pbone.lock_location)): blend_location(new_pbone, from_bone_name, to_bone_name) blend_rotation(new_pbone, from_bone_name, to_bone_name) diff --git a/release/scripts/modules/rigify/neck.py b/release/scripts/modules/rigify/neck.py index d20c231c0f8..9c7e53fa52d 100644 --- a/release/scripts/modules/rigify/neck.py +++ b/release/scripts/modules/rigify/neck.py @@ -160,7 +160,7 @@ def main(obj, bone_definition, base_names): neck_e_parent = arm.edit_bones.new("MCH-rot_%s" % neck_e.name) neck_e_parent.head = neck_e.head neck_e_parent.tail = neck_e.head + ((mt.head_e.tail - mt.head_e.head).normalize() * neck_chain_segment_length / 2.0) - neck_e_parent.roll = neck_e.roll + neck_e_parent.roll = mt.head_e.roll orig_parent = neck_e.parent diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_array.c index f11c95e7ed5..5f228836b42 100644 --- a/source/blender/python/intern/bpy_array.c +++ b/source/blender/python/intern/bpy_array.c @@ -32,8 +32,6 @@ #include "BKE_global.h" -#include "MEM_guardedalloc.h" - #define MAX_ARRAY_DIMENSION 10 typedef void (*ItemConvertFunc)(PyObject *, char *); @@ -258,7 +256,7 @@ static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *p if (totitem) { if (!param_data || RNA_property_flag(prop) & PROP_DYNAMIC) - data= MEM_callocN(item_size * totitem, "pyrna primitive type array"); + data= PyMem_MALLOC(item_size * totitem); else data= param_data; @@ -273,7 +271,7 @@ static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *p else { /* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */ rna_set_array(ptr, prop, data); - MEM_freeN(data); + PyMem_FREE(data); } } @@ -513,3 +511,94 @@ PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop) return pyrna_prop_CreatePyObject(ptr, prop); } + +/* TODO, multi-dimensional arrays */ +int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) +{ + int len= RNA_property_array_length(ptr, prop); + int type; + int i; + + if(len==0) /* possible with dynamic arrays */ + return 0; + + if (RNA_property_array_dimension(ptr, prop, NULL) > 1) { + PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet"); + return -1; + } + + type= RNA_property_type(prop); + + switch (type) { + case PROP_FLOAT: + { + float value_f= PyFloat_AsDouble(value); + if(value_f==-1 && PyErr_Occurred()) { + PyErr_Clear(); + return 0; + } + else { + float tmp[32]; + float *tmp_arr; + + if(len * sizeof(float) > sizeof(tmp)) { + tmp_arr= PyMem_MALLOC(len * sizeof(float)); + } + else { + tmp_arr= tmp; + } + + RNA_property_float_get_array(ptr, prop, tmp_arr); + + for(i=0; i sizeof(tmp)) { + tmp_arr= PyMem_MALLOC(len * sizeof(int)); + } + else { + tmp_arr= tmp; + } + + if(type==PROP_BOOLEAN) + RNA_property_boolean_get_array(ptr, prop, tmp_arr); + else + RNA_property_int_get_array(ptr, prop, tmp_arr); + + for(i=0; iprop) == PROP_COLLECTION) { + /* key in dict style check */ + char *keyname = _PyUnicode_AsString(value); + + if(keyname==NULL) { + PyErr_SetString(PyExc_TypeError, "PropertyRNA - key in prop, key must be a string type"); + return -1; + } + + + if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) + return 1; + } + else if (RNA_property_array_check(&self->ptr, self->prop)) { + /* value in list style check */ + return pyrna_array_contains_py(&self->ptr, self->prop, value); + } + else { + PyErr_SetString(PyExc_TypeError, "PropertyRNA - type is not an array or a collection"); return -1; } - if (RNA_property_type(self->prop) != PROP_COLLECTION) { - PyErr_SetString(PyExc_TypeError, "PropertyRNA - key in prop, is only valid for collection types"); - return -1; - } - - - if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) - return 1; - return 0; } @@ -2264,6 +2271,9 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) } } + if(array) + PyMem_Free(array); + if(PyErr_Occurred()) { /* Maybe we could make our own error */ PyErr_Print(); @@ -2275,9 +2285,6 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) return NULL; } - if(array) - PyMem_Free(array); - Py_RETURN_NONE; } diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 0e40bf7258c..37f6af36726 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -103,5 +103,6 @@ int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, in PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop); PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index); PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop); +int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value); #endif