From 683e6faf81d763b75dee3237a03ecda0705a18ba Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 16 Nov 2011 02:14:39 +0000 Subject: Partial Bugfix 2: [#29229] Outliner RMB commands unexpected results RenderLayers and RenderPasses don't show the generic Hide/Unhide/Select/Deselect popup which is irrelevant for this use case. I've included a commented-out call here that can be replaced when we have some operations which can be performed on this data (*) (*) For new devs looking to get into blender dev, this could be a nice little project to work on. --- source/blender/editors/space_outliner/outliner_tools.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index a7f7e36b182..27ad2c4fd6d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -1218,6 +1218,8 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); else if (datalevel == TSE_DRIVER_BASE) /* do nothing... no special ops needed yet */; + else if ELEM3(datalevel, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS) + /*WM_operator_name_call(C, "OUTLINER_OT_renderdata_operation", WM_OP_INVOKE_REGION_WIN, NULL)*/; else WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL); } -- cgit v1.2.3 From 9d31c99c26956ecedf0bdcf9e02ce412d313257b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 03:44:08 +0000 Subject: support for creating project files in utf8 paths (was defaulting to ascii and throwing errors) --- build_files/cmake/cmake_qtcreator_project.py | 6 +++--- build_files/cmake/project_info.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index a89bcd01523..07ffa659437 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -89,7 +89,7 @@ def create_qtc_project_main(): f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w', encoding='utf-8') f.write("\n".join(sorted(includes))) qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME) @@ -104,7 +104,7 @@ def create_qtc_project_main(): defines_final += cmake_compiler_defines() f.write("\n".join(defines_final)) - print("Blender project file written to: %s" % qtc_prj) + print("Blender project file written to: %r" % qtc_prj) # --- end @@ -133,7 +133,7 @@ def create_qtc_project_python(): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") - print("Python project file written to: %s" % qtc_prj) + print("Python project file written to: %r" % qtc_prj) def main(): diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py index eed002ce7ba..0b922979a63 100755 --- a/build_files/cmake/project_info.py +++ b/build_files/cmake/project_info.py @@ -186,7 +186,7 @@ def cmake_advanced_info(): def cmake_cache_var(var): - cache_file = open(join(CMAKE_DIR, "CMakeCache.txt")) + cache_file = open(join(CMAKE_DIR, "CMakeCache.txt"), encoding='utf-8') lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")] cache_file.close() -- cgit v1.2.3 From ba7fbf6ae73ff488300b1e22d440cba0b0bd89cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 03:56:34 +0000 Subject: formatting edits & doc correction, no functional changes. --- source/blender/python/mathutils/mathutils_Color.c | 8 +- source/blender/python/mathutils/mathutils_Matrix.c | 21 +- .../python/mathutils/mathutils_Quaternion.c | 3 +- source/blender/python/mathutils/mathutils_Vector.c | 236 ++++++++++----------- .../blender/python/mathutils/mathutils_geometry.c | 2 - 5 files changed, 138 insertions(+), 132 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 3e7aeef3044..79628cf5ae9 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -834,18 +834,18 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) self= base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : (ColorObject *)PyObject_GC_New(ColorObject, &color_Type); - if(self) { + if (self) { /* init callbacks as NULL */ self->cb_user= NULL; self->cb_type= self->cb_subtype= 0; - if(type == Py_WRAP) { + if (type == Py_WRAP) { self->col = col; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { self->col = PyMem_Malloc(COLOR_SIZE * sizeof(float)); - if(col) + if (col) copy_v3_v3(self->col, col); else zero_v3(self->col); @@ -863,7 +863,7 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL); - if(self) { + if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; self->cb_type= (unsigned char)cb_type; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 293a960e0a6..1472b6886f6 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -941,8 +941,10 @@ static PyObject *Matrix_invert(MatrixObject *self) int x, y, z = 0; float det = 0.0f; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -964,9 +966,11 @@ static PyObject *Matrix_invert(MatrixObject *self) mat[1] = -self->matrix[0][1]; mat[2] = -self->matrix[1][0]; mat[3] = self->matrix[0][0]; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->contigPtr); - } else if (self->row_size == 4) { + } + else if (self->row_size == 4) { adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->contigPtr); } /*divide by determinate*/ @@ -1183,7 +1187,8 @@ static PyObject *Matrix_transpose(MatrixObject *self) t = self->matrix[1][0]; self->matrix[1][0] = self->matrix[0][1]; self->matrix[0][1] = t; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { transpose_m3((float (*)[3])self->contigPtr); } else { @@ -1253,7 +1258,8 @@ static PyObject *Matrix_identity(MatrixObject *self) self->matrix[0][1] = 0.0f; self->matrix[1][0] = 0.0f; self->matrix[1][1] = 1.0f; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { unit_m3((float (*)[3])self->contigPtr); } else { @@ -1657,7 +1663,8 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) if (i < 0) i += self->row_size; return Matrix_item(self, i); - } else if (PySlice_Check(item)) { + } + else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, self->row_size, &start, &stop, &step, &slicelength) < 0) diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index a8585f386d5..8a6c4909e94 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -639,7 +639,8 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) if (i < 0) i += QUAT_SIZE; return Quaternion_item(self, i); - } else if (PySlice_Check(item)) { + } + else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 66dda6a9623..f70bd42e2b6 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -61,7 +61,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED case 0: break; case 1: - if((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) + if ((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) return NULL; break; default: @@ -77,7 +77,7 @@ static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *sel { PyObject *ret= Vector_copy(self); PyObject *ret_dummy= vec_func(ret); - if(ret_dummy) { + if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; } @@ -97,7 +97,7 @@ static PyObject *Vector_zero(VectorObject *self) { fill_vn(self->vec, self->size, 0.0f); - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return NULL; Py_RETURN_NONE; @@ -119,7 +119,7 @@ static PyObject *Vector_normalize(VectorObject *self) int i; float norm = 0.0f; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -156,13 +156,13 @@ PyDoc_STRVAR(Vector_resize_2d_doc, ); static PyObject *Vector_resize_2d(VectorObject *self) { - if(self->wrapped==Py_WRAP) { + if (self->wrapped==Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize a vector that has an owner"); @@ -170,7 +170,7 @@ static PyObject *Vector_resize_2d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_2d(): " "problem allocating pointer space"); @@ -197,7 +197,7 @@ static PyObject *Vector_resize_3d(VectorObject *self) "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize a vector that has an owner"); @@ -205,14 +205,14 @@ static PyObject *Vector_resize_3d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_3d(): " "problem allocating pointer space"); return NULL; } - if(self->size == 2) + if (self->size == 2) self->vec[2] = 0.0f; self->size = 3; @@ -229,13 +229,13 @@ PyDoc_STRVAR(Vector_resize_4d_doc, ); static PyObject *Vector_resize_4d(VectorObject *self) { - if(self->wrapped==Py_WRAP) { + if (self->wrapped==Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize a vector that has an owner"); @@ -243,18 +243,18 @@ static PyObject *Vector_resize_4d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_4d(): " "problem allocating pointer space"); return NULL; } - if(self->size == 2) { + if (self->size == 2) { self->vec[2] = 0.0f; self->vec[3] = 1.0f; } - else if(self->size == 3) { + else if (self->size == 3) { self->vec[3] = 1.0f; } self->size = 4; @@ -270,7 +270,7 @@ PyDoc_STRVAR(Vector_to_2d_doc, ); static PyObject *Vector_to_2d(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self)); @@ -287,7 +287,7 @@ static PyObject *Vector_to_3d(VectorObject *self) { float tvec[3]= {0.0f}; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3)); @@ -305,7 +305,7 @@ static PyObject *Vector_to_4d(VectorObject *self) { float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f}; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4)); @@ -330,7 +330,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) ret= PyTuple_New(self->size); - if(ndigits >= 0) { + if (ndigits >= 0) { for (i = 0; i < self->size; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits))); } @@ -348,20 +348,20 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) { int ndigits= 0; - if(!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) + if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) return NULL; - if(ndigits > 22 || ndigits < 0) { + if (ndigits > 22 || ndigits < 0) { PyErr_SetString(PyExc_ValueError, "Vector.to_tuple(ndigits): " "ndigits must be between 0 and 21"); return NULL; } - if(PyTuple_GET_SIZE(args)==0) + if (PyTuple_GET_SIZE(args)==0) ndigits= -1; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return Vector_to_tuple_ext(self, ndigits); @@ -385,7 +385,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) const char *strack, *sup; short track = 2, up = 1; - if(!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) + if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) return NULL; if (self->size != 3) { @@ -395,7 +395,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) return NULL; } - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; if (strack) { @@ -508,10 +508,10 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) float reflect[3] = {0.0f}; float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) + if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) return NULL; mirror[0] = tvec[0]; @@ -547,10 +547,10 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) VectorObject *ret; float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) return NULL; ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self)); @@ -574,10 +574,10 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) double dot = 0.0; int x; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) return NULL; for (x = 0; x < self->size; x++) { @@ -611,13 +611,13 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) int x; PyObject *fallback= NULL; - if(!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) + if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1) return NULL; for (x = 0; x < size; x++) { @@ -626,7 +626,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) } if (!test_v1 || !test_v2) { /* avoid exception */ - if(fallback) { + if (fallback) { Py_INCREF(fallback); return fallback; } @@ -648,7 +648,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) } PyDoc_STRVAR(Vector_rotation_difference_doc, -".. function:: difference(other)\n" +".. function:: rotation_difference(other)\n" "\n" " Returns a quaternion representing the rotational difference between this\n" " vector and another.\n" @@ -664,17 +664,17 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) { float quat[4], vec_a[3], vec_b[3]; - if(self->size < 3) { + if (self->size < 3) { PyErr_SetString(PyExc_ValueError, "vec.difference(value): " "expects both vectors to be size 3 or 4"); return NULL; } - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) return NULL; normalize_v3_v3(vec_a, self->vec); @@ -703,13 +703,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) double dot = 0.0f, dot2 = 0.0f; int x; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; //get dot products @@ -745,13 +745,13 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) float tvec[MAX_DIMENSIONS], vec[MAX_DIMENSIONS]; int x; - if(!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) + if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; ifac= 1.0f - fac; @@ -774,13 +774,13 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value) { float other_rmat[3][3]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) + if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) return NULL; - if(self->size < 3) { + if (self->size < 3) { PyErr_SetString(PyExc_ValueError, "Vector must be 3D or 4D"); return NULL; @@ -805,7 +805,7 @@ PyDoc_STRVAR(Vector_copy_doc, ); static PyObject *Vector_copy(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); @@ -815,7 +815,7 @@ static PyObject *Vector_repr(VectorObject *self) { PyObject *ret, *tuple; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; tuple= Vector_to_tuple_ext(self, -1); @@ -833,10 +833,10 @@ static int Vector_len(VectorObject *self) /* sequence accessor (get): vector[index] */ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_attr) { - if(i<0) i= self->size-i; + if (i<0) i= self->size-i; - if(i < 0 || i >= self->size) { - if(is_attr) { + if (i < 0 || i >= self->size) { + if (is_attr) { PyErr_Format(PyExc_AttributeError, "Vector.%c: unavailable on %dd vector", *(((char *)"xyzw") + i), self->size); @@ -848,7 +848,7 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_at return NULL; } - if(BaseMath_ReadIndexCallback(self, i) == -1) + if (BaseMath_ReadIndexCallback(self, i) == -1) return NULL; return PyFloat_FromDouble(self->vec[i]); @@ -862,17 +862,17 @@ static PyObject *Vector_item(VectorObject *self, int i) static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const int is_attr) { float scalar; - if((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "vector[index] = x: " "index argument not a number"); return -1; } - if(i<0) i= self->size-i; + if (i<0) i= self->size-i; - if(i < 0 || i >= self->size) { - if(is_attr) { + if (i < 0 || i >= self->size) { + if (is_attr) { PyErr_Format(PyExc_AttributeError, "Vector.%c = x: unavailable on %dd vector", *(((char *)"xyzw") + i), self->size); @@ -886,7 +886,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, } self->vec[i] = scalar; - if(BaseMath_WriteIndexCallback(self, i) == -1) + if (BaseMath_WriteIndexCallback(self, i) == -1) return -1; return 0; } @@ -902,7 +902,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) PyObject *tuple; int count; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; CLAMP(begin, 0, self->size); @@ -923,7 +923,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se int y, size = 0; float vec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; CLAMP(begin, 0, self->size); @@ -931,7 +931,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se begin = MIN2(begin, end); size = (end - begin); - if(mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1) + if (mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1) return -1; /*parsed well - now set in vector*/ @@ -939,7 +939,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se self->vec[begin + y] = vec[y]; } - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return -1; return 0; @@ -962,11 +962,11 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; /*VECTOR + VECTOR*/ - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); @@ -993,14 +993,14 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); return NULL; } - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; add_vn_vn(vec1->vec, vec2->vec, vec1->size); @@ -1026,10 +1026,10 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); @@ -1056,14 +1056,14 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); return NULL; } - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; sub_vn_vn(vec1->vec, vec2->vec, vec1->size); @@ -1091,8 +1091,8 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec, double dot = 0.0f; int x, y, z = 0; - if(mat->row_size != vec->size) { - if(mat->row_size == 4 && vec->size == 3) { + if (mat->row_size != vec->size) { + if (mat->row_size == 4 && vec->size == 3) { vec_cpy[3] = 1.0f; } else { @@ -1133,12 +1133,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) if VectorObject_Check(v1) { vec1= (VectorObject *)v1; - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; } if VectorObject_Check(v2) { vec2= (VectorObject *)v2; - if(BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec2) == -1) return NULL; } @@ -1148,7 +1148,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) int i; double dot = 0.0f; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); @@ -1166,9 +1166,9 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) /* VEC * MATRIX */ float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback((MatrixObject *)v2) == -1) + if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) return NULL; - if(row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { + if (row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { return NULL; } @@ -1186,13 +1186,13 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) QuaternionObject *quat2 = (QuaternionObject*)v2; float tvec[3]; - if(vec1->size != 3) { + if (vec1->size != 3) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; } - if(BaseMath_ReadCallback(quat2) == -1) { + if (BaseMath_ReadCallback(quat2) == -1) { return NULL; } @@ -1228,7 +1228,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) VectorObject *vec = (VectorObject *)v1; float scalar; - if(BaseMath_ReadCallback(vec) == -1) + if (BaseMath_ReadCallback(vec) == -1) return NULL; /* only support vec*=float and vec*=mat @@ -1243,10 +1243,10 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) return NULL; #else float rvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback((MatrixObject *)v2) == -1) + if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) return NULL; - if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1) + if (column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1) return NULL; memcpy(vec->vec, rvec, sizeof(float) * vec->size); @@ -1266,14 +1266,14 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) #else QuaternionObject *quat2 = (QuaternionObject*)v2; - if(vec->size != 3) { + if (vec->size != 3) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; } - if(BaseMath_ReadCallback(quat2) == -1) { + if (BaseMath_ReadCallback(quat2) == -1) { return NULL; } @@ -1304,7 +1304,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) float vec[4], scalar; VectorObject *vec1 = NULL; - if(!VectorObject_Check(v1)) { /* not a vector */ + if (!VectorObject_Check(v1)) { /* not a vector */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); @@ -1312,17 +1312,17 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) } vec1 = (VectorObject*)v1; /* vector */ - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if(scalar==0.0f) { + if (scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); @@ -1342,17 +1342,17 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) float scalar; VectorObject *vec1 = (VectorObject*)v1; - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if(scalar==0.0f) { + if (scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); @@ -1374,7 +1374,7 @@ static PyObject *Vector_neg(VectorObject *self) { float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; negate_vn_vn(tvec, self->vec, self->size); @@ -1418,7 +1418,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa vecA = (VectorObject*)objectA; vecB = (VectorObject*)objectB; - if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) + if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) return NULL; if (vecA->size != vecB->size) { @@ -1434,14 +1434,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa case Py_LT: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA < lenB) { + if (lenA < lenB) { result = 1; } break; case Py_LE: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA < lenB) { + if (lenA < lenB) { result = 1; } else { @@ -1457,14 +1457,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa case Py_GT: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA > lenB) { + if (lenA > lenB) { result = 1; } break; case Py_GE: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA > lenB) { + if (lenA > lenB) { result = 1; } else { @@ -1632,7 +1632,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) double dot = 0.0f; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -1646,10 +1646,10 @@ static int Vector_setLength(VectorObject *self, PyObject *value) double dot = 0.0f, param; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; - if((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { + if ((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "length must be set to a number"); return -1; @@ -1694,7 +1694,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur double dot = 0.0f; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -1713,7 +1713,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) float vec[MAX_DIMENSIONS]; unsigned int swizzleClosure; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; /* Unpack the axes from the closure into an array. */ @@ -1722,7 +1722,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_from = swizzleClosure & SWIZZLE_AXIS; - if(axis_from >= self->size) { + if (axis_from >= self->size) { PyErr_SetString(PyExc_AttributeError, "Vector swizzle: " "specified axis not present"); @@ -1760,7 +1760,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) float tvec[MAX_DIMENSIONS]; float vec_assign[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; /* Check that the closure can be used with this vector: even 2D vectors have @@ -1787,11 +1787,11 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) size_from= axis_from; } - else if(PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { + else if (PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { return -1; } - if(axis_from != size_from) { + if (axis_from != size_from) { PyErr_SetString(PyExc_AttributeError, "Vector swizzle: size does not match swizzle"); return -1; @@ -1811,7 +1811,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) memcpy(self->vec, tvec, axis_from * sizeof(float)); /* continue with BaseMathObject_WriteCallback at the end */ - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return -1; else return 0; @@ -2223,8 +2223,8 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v double dot = 0.0f; int x, y, z= 0, vec_size= vec->size; - if(mat->col_size != vec_size) { - if(mat->col_size == 4 && vec_size != 3) { + if (mat->col_size != vec_size) { + if (mat->col_size == 4 && vec_size != 3) { PyErr_SetString(PyExc_ValueError, "vector * matrix: matrix column size " "and the vector size must be the same"); @@ -2235,7 +2235,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v } } - if(BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) + if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) return -1; memcpy(vec_cpy, vec->vec, vec_size * sizeof(float)); @@ -2263,7 +2263,7 @@ PyDoc_STRVAR(Vector_negate_doc, ); static PyObject *Vector_negate(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; negate_vn(self->vec, self->size); @@ -2406,7 +2406,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje { VectorObject *self; - if(size > 4 || size < 2) { + if (size > 4 || size < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); return NULL; @@ -2415,25 +2415,25 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje self= base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); - if(self) { + if (self) { self->size = size; /* init callbacks as NULL */ self->cb_user= NULL; self->cb_type= self->cb_subtype= 0; - if(type == Py_WRAP) { + if (type == Py_WRAP) { self->vec = vec; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { self->vec= PyMem_Malloc(size * sizeof(float)); - if(vec) { + if (vec) { memcpy(self->vec, vec, size * sizeof(float)); } else { /* new empty */ fill_vn(self->vec, size, 0.0f); - if(size == 4) { /* do the homogenous thing */ + if (size == 4) { /* do the homogenous thing */ self->vec[3] = 1.0f; } } @@ -2450,7 +2450,7 @@ PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_su { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ VectorObject *self= (VectorObject *)newVectorObject(dummy, size, Py_NEW, NULL); - if(self) { + if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; self->cb_type= (unsigned char)cb_type; diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index dfa1c98b94b..3bf2997e8c9 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -48,8 +48,6 @@ #include "BLI_utildefines.h" #define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp -#define eps 0.000001 - /*-------------------------DOC STRINGS ---------------------------*/ PyDoc_STRVAR(M_Geometry_doc, -- cgit v1.2.3 From 01af54c4647f838e3e48bf7ffeb19e1729fc0c93 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Nov 2011 10:00:02 +0000 Subject: Camera tracking: forbid focal length=0 and small code cleanup --- extern/libmv/libmv-capi.cpp | 13 +++++-------- source/blender/makesrna/intern/rna_tracking.c | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index 9d6cfd5d17a..8c453944e9d 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -368,14 +368,11 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra intrinsics->SetPrincipalPoint(principal_x, principal_y); intrinsics->SetRadialDistortion(k1, k2, k3); - if(focal_length) { - /* do a lens undistortion if focal length is non-zero only */ - for (int i = 0; i < markers.size(); ++i) { - intrinsics->InvertIntrinsics(markers[i].x, - markers[i].y, - &(markers[i].x), - &(markers[i].y)); - } + for (int i = 0; i < markers.size(); ++i) { + intrinsics->InvertIntrinsics(markers[i].x, + markers[i].y, + &(markers[i].x), + &(markers[i].y)); } libmv::Tracks normalized_tracks(markers); diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 368359925c4..73b2914fba1 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -169,7 +169,8 @@ static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value) if(clip->lastsize[0]) value= clip->lastsize[0]*value/camera->sensor_width; - camera->focal= value; + if(value>=0.0001) + camera->focal= value; } static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), void *data) @@ -372,7 +373,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna) /* Focal Length */ prop= RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "focal"); - RNA_def_property_range(prop, 0.0f, 5000.0f); + RNA_def_property_range(prop, 0.0001f, 5000.0f); RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_mm_get", "rna_trackingCamera_focal_mm_set", NULL); RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length"); RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL); -- cgit v1.2.3 From bb04fc124611355f97be8b6ecbf983aca07adee5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 16 Nov 2011 11:52:31 +0000 Subject: CLIP_OT_delete_proxy missed a space-type test in its poll func (was noisy with the space-menu in 3D views :P ). --- release/scripts/startup/bl_operators/clip.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 091e3defbf8..7900cb46e95 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -124,6 +124,9 @@ class CLIP_OT_delete_proxy(Operator): @classmethod def poll(cls, context): + if context.space_data.type != 'CLIP_EDITOR': + return False + sc = context.space_data return sc.clip -- cgit v1.2.3 From eff7e18dc50587a853093d2ddf27e551786e05a1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 12:27:24 +0000 Subject: Fix #29288: armature draw type wire + manipulator draw issue. --- source/blender/editors/space_view3d/drawarmature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index c0046b089af..bbc72500df4 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1946,7 +1946,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, index+= 0x10000; } /* restore things */ - if ((arm->drawtype!=ARM_LINE)&& (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE)) + if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(rv3d->dist, 0.0); } -- cgit v1.2.3 From 391f40e8c9647c2c436ef8681061d57300d2f287 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 16 Nov 2011 12:43:12 +0000 Subject: Default cache file paths for ocean and fluidsim modifiers are now "/ocean_cache/" and "/fluid_cache/" when the file is not saved yet at the time the modifiers are created. If it has been saved, the file paths are relative to the .blend: "//ocean_cache/" and "//fluid_cache/". This should at least partially fix bug #29273. Particle external point caches are not changed. http://projects.blender.org/tracker/?func=detail&atid=498&aid=29273&group_id=9 --- source/blender/modifiers/intern/MOD_fluidsim_util.c | 18 +++++++++++++++++- source/blender/modifiers/intern/MOD_ocean.c | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 1baa03d2063..15e1cdfcb62 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -69,6 +69,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) if(fluidmd) { FluidsimSettings *fss = MEM_callocN(sizeof(FluidsimSettings), "fluidsimsettings"); + int surfdataPathMax = FILE_MAX; fluidmd->fss = fss; @@ -104,7 +105,22 @@ void fluidsim_init(FluidsimModifierData *fluidmd) /* elubie: changed this to default to the same dir as the render output to prevent saving to C:\ on Windows */ - BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), FILE_MAX); + if (G.relbase_valid) { /* is the .blend saved? */ + /* subfolder next to saved file */ + BLI_strncpy(fss->surfdataPath, "//fluid_cache", surfdataPathMax); + BLI_add_slash(fss->surfdataPath); + } + else { + /* subfolder in temp. directory */ + BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), surfdataPathMax); + surfdataPathMax -= strlen(fss->surfdataPath); + if (surfdataPathMax > 1) { + BLI_strncpy(fss->surfdataPath+strlen(fss->surfdataPath), "fluid_cache", surfdataPathMax); + surfdataPathMax -= strlen("fluid_cache"); + if (surfdataPathMax > 1) + BLI_add_slash(fss->surfdataPath); + } + } // first init of bounding box // no bounding box needed diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index a61cc856662..55d121737c1 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -34,10 +34,12 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" +#include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_ocean.h" #include "BKE_utildefines.h" +#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_math_inline.h" #include "BLI_utildefines.h" @@ -95,6 +97,7 @@ static void initData(ModifierData *md) { #ifdef WITH_OCEANSIM OceanModifierData *omd = (OceanModifierData*) md; + int cachepathmax = sizeof(omd->cachepath); omd->resolution = 7; omd->spatial_size = 50; @@ -122,7 +125,22 @@ static void initData(ModifierData *md) omd->repeat_x = 1; omd->repeat_y = 1; - BLI_strncpy(omd->cachepath, "//ocean_cache", sizeof(omd->cachepath)); + if (G.relbase_valid) { /* is the .blend saved? */ + /* subfolder next to saved file */ + BLI_strncpy(omd->cachepath, "//ocean_cache", cachepathmax); + BLI_add_slash(omd->cachepath); + } + else { + /* subfolder in temp. directory */ + BLI_strncpy(omd->cachepath, BLI_temporary_dir(), cachepathmax); + cachepathmax -= strlen(omd->cachepath); + if (cachepathmax > 1) { + BLI_strncpy(omd->cachepath+strlen(omd->cachepath), "ocean_cache", cachepathmax); + cachepathmax -= strlen("ocean_cache"); + if (cachepathmax > 1) + BLI_add_slash(omd->cachepath); + } + } omd->cached = 0; omd->bakestart = 1; -- cgit v1.2.3 From c4e029a274b04ec6adb5e16a6c1ee5bea67fa01e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 12:47:37 +0000 Subject: Fix #29287: cycles and other external render engines did not print correct frame number in background render. --- source/blender/editors/render/render_internal.c | 7 +++++-- source/blender/render/intern/source/external_engine.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index cc1c8843015..6931b0b86db 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -322,10 +322,13 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) spos+= sprintf(spos, "%s ", rs->statstr); } else { - spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface); + spos+= sprintf(spos, "Fra:%d ", (scene->r.cfra)); + if(rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert); + if(rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface); if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo); if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand); - spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory, megs_peak_memory); + if(rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp); + spos+= sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory); if(rs->curfield) spos+= sprintf(spos, "Field %d ", rs->curfield); diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b7f89e260a8..38ace8d5121 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -283,6 +283,11 @@ int RE_engine_render(Render *re, int do_all) if(re->result==NULL) return 1; + /* set render info */ + re->i.cfra= re->scene->r.cfra; + BLI_strncpy(re->i.scenename, re->scene->id.name+2, sizeof(re->i.scenename)); + re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0; + /* render */ engine = RE_engine_create(type); engine->re= re; -- cgit v1.2.3 From 7177ee0245713ed22fda6e9ffbbac4e6391910c8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Nov 2011 13:39:58 +0000 Subject: Pep8 changes for motion tracking py scripts --- release/scripts/startup/bl_operators/clip.py | 7 +++++-- release/scripts/startup/bl_ui/space_clip.py | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 7900cb46e95..b805178bdc8 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -36,6 +36,7 @@ def CLIP_track_view_selected(sc, track): return False + class CLIP_OT_track_to_empty(Operator): """Create an Empty object which will be copying movement of active track""" @@ -190,7 +191,8 @@ class CLIP_OT_delete_proxy(Operator): class CLIP_OT_set_viewport_background(Operator): - """Set current movie clip as a camera background in 3D viewport (works only when a 3D viewport is visible)""" + """Set current movie clip as a camera background in 3D viewport \ +(works only when a 3D viewport is visible)""" bl_idname = "clip.set_viewport_background" bl_label = "Set as Background" @@ -239,7 +241,8 @@ class CLIP_OT_set_viewport_background(Operator): class CLIP_OT_constraint_to_fcurve(Operator): - """Create F-Curves for object which will copy object's movement caused by this constraint""" + """Create F-Curves for object which will copy \ +object's movement caused by this constraint""" bl_idname = "clip.constraint_to_fcurve" bl_label = "Constraint to F-Curve" diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c6af6bab1d1..aa1ffe4ca36 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -54,7 +54,8 @@ class CLIP_HT_header(Header): row = layout.row(align=True) if sc.show_filters: - row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', text="Filters") + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', + text="Filters") sub = row.column() sub.active = clip.tracking.reconstruction.is_valid @@ -62,7 +63,8 @@ class CLIP_HT_header(Header): row.prop(sc, "show_graph_tracks", icon='ANIM', text="") else: - row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', text="Filters") + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', + text="Filters") row = layout.row() row.template_ID(sc, "clip", open='clip.open') @@ -719,7 +721,8 @@ class CLIP_MT_track(Menu): props = layout.operator("clip.clear_track_path", text="Clear Before") props.action = 'UPTO' - props = layout.operator("clip.clear_track_path", text="Clear Track Path") + props = layout.operator("clip.clear_track_path", + text="Clear Track Path") props.action = 'ALL' layout.separator() -- cgit v1.2.3 From ed5815fc7fb6be111fca613d0500418c4955e217 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 13:49:51 +0000 Subject: Fix #29243: unlink texture datablock from material node in texture properties could crash, RNA pointer from context was invalid. --- source/blender/editors/space_buttons/buttons_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 9de804d275f..4c028612320 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -805,7 +805,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if(ma) { bNode *node= give_current_material_texture_node(ma); - CTX_data_pointer_set(result, &ma->id, &RNA_Node, node); + CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } } -- cgit v1.2.3 From 004cb6ba1b96e3a4857f08255f2be9fe873b69fb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 14:13:43 +0000 Subject: Fix #29160: material node "Texture" didn't use default texture coordinates anymore when nothing was connected to the socket. --- source/blender/nodes/shader/nodes/node_shader_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index dbf9fdbdb7e..c26cf2451df 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -51,6 +51,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b if(data && node->id) { ShadeInput *shi= ((ShaderCallData *)data)->shi; TexResult texres; + bNodeSocket *sock_vector= node->inputs.first; float vec[3], nor[3]={0.0f, 0.0f, 0.0f}; int retval; short which_output = node->custom1; @@ -63,7 +64,8 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b texres.nor= nor; texres.tr= texres.tg= texres.tb= 0.0f; - if(in[0]->hasinput) { + /* don't use in[0]->hasinput, see material node for explanation */ + if(sock_vector->link) { nodestack_get_vec(vec, SOCK_VECTOR, in[0]); if(in[0]->datatype==NS_OSA_VECTORS) { -- cgit v1.2.3 From c6bbe25c291b7729637871f6ddc1f4415b107763 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 15:47:25 +0000 Subject: Fix #29093: world zenith up and down texture influence were not working correct. These were decoupled from horizon influence for 2.5, but not actually used in the render engine. --- source/blender/render/intern/source/render_texture.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index bd323a5b2d3..323f04cbd04 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3007,7 +3007,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float *co, fact, stencilTin=1.0; float tempvec[3], texvec[3], dxt[3], dyt[3]; - int tex_nr, rgb= 0, ok; + int tex_nr, rgb= 0; if (R.r.scemode & R_NO_TEX) return; /* todo: add flag to test if there's a tex */ @@ -3171,18 +3171,21 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h texture_rgb_blend(hor, tcol, hor, texres.tin, mtex->colfac, mtex->blendtype); } if(mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) { - ok= 0; + float zenfac = 0.0f; + if(R.wrld.skytype & WO_SKYREAL) { if((skyflag & WO_ZENUP)) { - if(mtex->mapto & WOMAP_ZENUP) ok= 1; + if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; } - else if(mtex->mapto & WOMAP_ZENDOWN) ok= 1; + else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } - else ok= 1; - - if(ok) { - texture_rgb_blend(zen, tcol, zen, texres.tin, mtex->colfac, mtex->blendtype); + else { + if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; + else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } + + if(zenfac != 0.0f) + texture_rgb_blend(zen, tcol, zen, texres.tin, zenfac, mtex->blendtype); } } if(mtex->mapto & WOMAP_BLEND) { -- cgit v1.2.3 From cb09ad43e1a26f1c742d310e27e562c8084c0194 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 16:08:45 +0000 Subject: Fix #29293: NLA Strip modifiers don't survive save/reload. One letter can make a big difference :) --- source/blender/blenloader/intern/readfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1c4a4567401..79ab90d06fb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1979,7 +1979,7 @@ static void direct_link_nladata_strips(FileData *fd, ListBase *list) /* strip's F-Modifiers */ link_list(fd, &strip->modifiers); - direct_link_modifiers(fd, &strip->modifiers); + direct_link_fmodifiers(fd, &strip->modifiers); } } -- cgit v1.2.3 From b4d453212ae2142d537f0824b3ff0627fca85277 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 16:10:11 +0000 Subject: Fix #29292: cycles not loading linked image datablocks correctly. --- intern/cycles/blender/blender_util.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index c5cceff6242..ff6d55c6f3e 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -176,7 +176,13 @@ static inline string get_enum_identifier(PointerRNA& ptr, const char *name) static inline string blender_absolute_path(BL::BlendData b_data, BL::ID b_id, const string& path) { if(path.size() >= 2 && path[0] == '/' && path[1] == '/') { - string dirname = (b_id.library())? b_id.library().filepath(): b_data.filepath(); + string dirname; + + if(b_id.library()) + dirname = blender_absolute_path(b_data, b_id.library(), b_id.library().filepath()); + else + dirname = b_data.filepath(); + return path_join(path_dirname(dirname), path.substr(2)); } -- cgit v1.2.3 From 0566694f6e294e50030c61cbd2544b5d469651ce Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 16 Nov 2011 16:28:19 +0000 Subject: Cycles: cmake build system tweak, might solve compile issue. --- intern/cycles/blender/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt index f3da1a30eb2..ea46911ce16 100644 --- a/intern/cycles/blender/CMakeLists.txt +++ b/intern/cycles/blender/CMakeLists.txt @@ -1,4 +1,11 @@ +set(BLENDER_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/intern/guardedalloc + ${CMAKE_SOURCE_DIR}/source/blender/makesdna + ${CMAKE_SOURCE_DIR}/source/blender/makesrna + ${CMAKE_SOURCE_DIR}/source/blender/blenloader + ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern) + set(INC ../render ../device -- cgit v1.2.3 From 4d9766aacf274e42b940b04c6a13b2b57043ca64 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 16:38:37 +0000 Subject: minor cleanup - remove / comment unused python vars - replace mul_v3_fl(somevec, -1.0f); with negate_v3(somevec); --- build_files/cmake/Modules/FindPythonLibsUnix.cmake | 10 +++++----- intern/cycles/blender/addon/ui.py | 14 ++++++------- release/scripts/modules/bpy/path.py | 23 ++++++++++------------ release/scripts/presets/camera/Sony_A55.py | 1 - release/scripts/startup/bl_operators/clip.py | 7 +------ release/scripts/startup/bl_operators/image.py | 2 +- release/scripts/startup/bl_operators/wm.py | 2 +- .../bl_ui/properties_physics_dynamicpaint.py | 6 ------ release/scripts/startup/bl_ui/space_clip.py | 7 ------- release/scripts/startup/bl_ui/space_view3d.py | 17 +++++----------- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/particle.c | 4 ++-- source/blender/blenkernel/intern/particle_system.c | 4 ++-- 13 files changed, 35 insertions(+), 64 deletions(-) diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake index 8c3ff64d3f3..448e587e224 100644 --- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake +++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake @@ -139,9 +139,9 @@ IF(PYTHONLIBSUNIX_FOUND) # not used # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") - - MARK_AS_ADVANCED( - PYTHON_INCLUDE_DIR - PYTHON_LIBRARY - ) ENDIF() + +MARK_AS_ADVANCED( + PYTHON_INCLUDE_DIR + PYTHON_LIBRARY +) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index d96efe93cf8..00010bb7463 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -459,7 +459,7 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - world = context.world + # world = context.world return False # world and world.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): @@ -493,7 +493,7 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - mat = context.material + # mat = context.material return False # mat and mat.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): @@ -562,7 +562,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel): pin_id = space.pin_id use_pin_id = space.use_pin_id user = context.texture_user - node = context.texture_node + # node = context.texture_node if not use_pin_id or not isinstance(pin_id, bpy.types.Texture): pin_id = None @@ -638,7 +638,7 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel): def draw(self, context): layout = self.layout - tex = context.texture + # tex = context.texture node = context.texture_node mapping = node.texture_mapping @@ -664,15 +664,15 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - tex = context.texture - node = context.texture_node + # tex = context.texture + # node = context.texture_node return False #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout - tex = context.texture + # tex = context.texture node = context.texture_node mapping = node.color_mapping diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index e6d0fbb99a2..4173d71b39c 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -154,25 +154,23 @@ def resolve_ncase(path): returning a string with the path if found else return the original path. """ - import os - def _ncase_path_found(path): - if not path or os.path.exists(path): + if not path or _os.path.exists(path): return path, True # filename may be a directory or a file - filename = os.path.basename(path) - dirpath = os.path.dirname(path) + filename = _os.path.basename(path) + dirpath = _os.path.dirname(path) suffix = path[:0] # "" but ensure byte/str match if not filename: # dir ends with a slash? if len(dirpath) < len(path): suffix = path[:len(path) - len(dirpath)] - filename = os.path.basename(dirpath) - dirpath = os.path.dirname(dirpath) + filename = _os.path.basename(dirpath) + dirpath = _os.path.dirname(dirpath) - if not os.path.exists(dirpath): + if not _os.path.exists(dirpath): if dirpath == path: return path, False @@ -184,8 +182,8 @@ def resolve_ncase(path): # at this point, the directory exists but not the file # we are expecting 'dirpath' to be a directory, but it could be a file - if os.path.isdir(dirpath): - files = os.listdir(dirpath) + if _os.path.isdir(dirpath): + files = _os.listdir(dirpath) else: return path, False @@ -198,7 +196,7 @@ def resolve_ncase(path): break if f_iter_nocase: - return os.path.join(dirpath, f_iter_nocase) + suffix, True + return _os.path.join(dirpath, f_iter_nocase) + suffix, True else: # cant find the right one, just return the path as is. return path, False @@ -216,8 +214,7 @@ def ensure_ext(filepath, ext, case_sensitive=False): :arg case_sensitive: Check for matching case when comparing extensions. :type case_sensitive: bool """ - import os - fn_base, fn_ext = os.path.splitext(filepath) + fn_base, fn_ext = _os.path.splitext(filepath) if fn_base and fn_ext: if ((case_sensitive and ext == fn_ext) or (ext.lower() == fn_ext.lower())): diff --git a/release/scripts/presets/camera/Sony_A55.py b/release/scripts/presets/camera/Sony_A55.py index 0de8198972a..b0f172206fa 100644 --- a/release/scripts/presets/camera/Sony_A55.py +++ b/release/scripts/presets/camera/Sony_A55.py @@ -2,4 +2,3 @@ import bpy bpy.context.object.data.sensor_width = 23.4 bpy.context.object.data.sensor_height = 15.6 bpy.context.object.data.sensor_fit = 'HORIZONTAL' - diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index b805178bdc8..d5d9684bcf3 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -86,13 +86,8 @@ class CLIP_OT_tracks_to_mesh(Operator): @classmethod def poll(cls, context): - if context.space_data.type != 'CLIP_EDITOR': - return False - sc = context.space_data - clip = sc.clip - - return clip + return (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): sc = context.space_data diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 8c12a6442f7..c97f6eae6c7 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -147,7 +147,7 @@ class ProjectEdit(Operator): # opengl buffer may fail, we can't help this, but best report it. try: - ret = bpy.ops.paint.image_from_view() + bpy.ops.paint.image_from_view() except RuntimeError as err: self.report({'ERROR'}, str(err)) return {'CANCELLED'} diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index aa661b76512..14c9a090529 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -106,7 +106,7 @@ def operator_path_is_undo(context, data_path): # luckily we don't do this! # # When we cant find the data owner assume no undo is needed. - data_path_head, data_path_sep, data_path_tail = data_path.rpartition(".") + data_path_head = data_path.rpartition(".")[0] if not data_path_head: return False diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 4e6c4063d2c..68fa0cedaa3 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -46,7 +46,6 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): layout = self.layout md = context.dynamic_paint - ob = context.object layout.prop(md, "ui_type", expand=True) @@ -129,7 +128,6 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel): canvas = context.dynamic_paint.canvas_settings surface = canvas.canvas_surfaces.active - ob = context.object surface_type = surface.surface_type @@ -370,8 +368,6 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): md.canvas_settings.canvas_surfaces.active.is_cache_user) def draw(self, context): - layout = self.layout - surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active cache = surface.point_cache @@ -442,7 +438,6 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel): layout = self.layout brush = context.dynamic_paint.brush_settings - ob = context.object split = layout.split() @@ -478,7 +473,6 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel): layout = self.layout brush = context.dynamic_paint.brush_settings - ob = context.object layout.prop(brush, "wave_type") if brush.wave_type != 'REFLECT': diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index aa1ffe4ca36..237dd7f998d 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -115,7 +115,6 @@ class CLIP_PT_tools_tracking(Panel): def draw(self, context): layout = self.layout clip = context.space_data.clip - settings = clip.tracking.settings row = layout.row(align=True) @@ -641,7 +640,6 @@ class CLIP_PT_tools_clip(Panel): def draw(self, context): layout = self.layout - clip = context.space_data.clip layout.operator("clip.set_viewport_background") @@ -698,9 +696,6 @@ class CLIP_MT_proxy(Menu): def draw(self, context): layout = self.layout - sc = context.space_data - clip = sc.clip - layout.operator("clip.rebuild_proxy") layout.operator("clip.delete_proxy") @@ -805,8 +800,6 @@ class CLIP_MT_select(Menu): def draw(self, context): layout = self.layout - sc = context.space_data - layout.operator("clip.select_border") layout.operator("clip.select_circle") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 536936105e3..6bf8dd82c9b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2276,12 +2276,6 @@ class VIEW3D_PT_background_image(Panel): bl_label = "Background Images" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - view = context.space_data - #~ bg = context.space_data.background_image - return (view) - def draw_header(self, context): layout = self.layout view = context.space_data @@ -2315,16 +2309,15 @@ class VIEW3D_PT_background_image(Panel): row = box.row() row.prop(bg, "source", expand=True) - hasbg = False + has_bg = False if bg.source == 'IMAGE': row = box.row() row.template_ID(bg, "image", open="image.open") if (bg.image): box.template_image(bg, "image", bg.image_user, compact=True) - hasbg = True + has_bg = True elif bg.source == 'MOVIE': - has_clip = False box.prop(bg, 'use_camera_clip') column = box.column() @@ -2335,14 +2328,14 @@ class VIEW3D_PT_background_image(Panel): column.template_movieclip(bg, "clip", compact=True) if bg.use_camera_clip or bg.clip: - hasbg = True + has_bg = True column = box.column() - column.active = hasbg + column.active = has_bg column.prop(bg.clip_user, "proxy_render_size", text="") column.prop(bg.clip_user, "use_render_undistorted") - if hasbg: + if has_bg: box.prop(bg, "opacity", slider=True) if bg.view_axis != 'CAMERA': box.prop(bg, "size") diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 532e6f797dd..522aed439aa 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3235,7 +3235,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* Also cast a ray in opposite direction to make sure * point is at least surrounded by two brush faces */ - mul_v3_fl(ray_dir, -1.0f); + negate_v3(ray_dir); hit.index = -1; hit.dist = 9999; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d28fe8b8509..220068780a7 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1911,7 +1911,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float switch(type) { case PART_KINK_CURL: { - mul_v3_fl(par_vec, -1.f); + negate_v3(par_vec); if(flat > 0.f) { float proj[3]; @@ -1977,7 +1977,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float mul_qt_v3(par_rot, z_vec); } - mul_v3_fl(par_vec, -1.f); + negate_v3(par_vec); normalize_v3_v3(vec_one, par_vec); inp_y=dot_v3v3(y_vec, vec_one); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index cb12230615e..74fd8ff128b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2679,7 +2679,7 @@ static float nr_signed_distance_to_plane(float *p, float radius, ParticleCollisi } if(pce->inv_nor == 1) { - mul_v3_fl(nor, -1.f); + negate_v3(nor); d = -d; } @@ -2799,7 +2799,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce normalize_v3(nor); if(pce->inv_nor == 1) - mul_v3_fl(nor, -1.f); + negate_v3(nor); madd_v3_v3v3fl(co, pce->x0, nor, col->radius); madd_v3_v3fl(co, e1, pce->uv[0]); -- cgit v1.2.3 From 1af839081b7adcc3ceb13e5e7cc579b309e90915 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 16:50:30 +0000 Subject: minor edits, move mempool stack vars into the nested scope when they aren't likely to be used, also formatting edits (was quite un-blender like). --- source/blender/blenlib/intern/BLI_mempool.c | 77 ++++++++++++++++------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index b4dc5b73a65..7e79b9f65a1 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -39,25 +39,26 @@ #include "BLI_mempool.h" #include -typedef struct BLI_freenode{ +typedef struct BLI_freenode { struct BLI_freenode *next; -}BLI_freenode; +} BLI_freenode; -typedef struct BLI_mempool_chunk{ +typedef struct BLI_mempool_chunk { struct BLI_mempool_chunk *next, *prev; void *data; -}BLI_mempool_chunk; +} BLI_mempool_chunk; -typedef struct BLI_mempool{ +typedef struct BLI_mempool { struct ListBase chunks; int esize, csize, pchunk; /*size of elements and chunks in bytes and number of elements per chunk*/ struct BLI_freenode *free; /*free element list. Interleaved into chunk datas.*/ int totalloc, totused; /*total number of elements allocated in total, and currently in use*/ int use_sysmalloc; -}BLI_mempool; +} BLI_mempool; BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc) -{ BLI_mempool *pool = NULL; +{ + BLI_mempool *pool = NULL; BLI_freenode *lasttail = NULL, *curnode = NULL; int i,j, maxchunks; char *addr; @@ -69,7 +70,7 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmall pool = use_sysmalloc ? malloc(sizeof(BLI_mempool)) : MEM_mallocN(sizeof(BLI_mempool), "memory pool"); pool->esize = esize; pool->use_sysmalloc = use_sysmalloc; - pool->pchunk = pchunk; + pool->pchunk = pchunk; pool->csize = esize * pchunk; pool->chunks.first = pool->chunks.last = NULL; pool->totused= 0; @@ -77,21 +78,21 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmall maxchunks = tote / pchunk + 1; /*allocate the actual chunks*/ - for(i=0; i < maxchunks; i++){ + for (i=0; i < maxchunks; i++) { BLI_mempool_chunk *mpchunk = use_sysmalloc ? malloc(sizeof(BLI_mempool_chunk)) : MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk"); mpchunk->next = mpchunk->prev = NULL; mpchunk->data = use_sysmalloc ? malloc(pool->csize) : MEM_mallocN(pool->csize, "BLI Mempool Chunk Data"); BLI_addtail(&(pool->chunks), mpchunk); - if(i==0) pool->free = mpchunk->data; /*start of the list*/ + if (i==0) pool->free = mpchunk->data; /*start of the list*/ /*loop through the allocated data, building the pointer structures*/ - for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){ + for (addr = mpchunk->data, j=0; j < pool->pchunk; j++) { curnode = ((BLI_freenode*)addr); addr += pool->esize; curnode->next = (BLI_freenode*)addr; } /*final pointer in the previously allocated chunk is wrong.*/ - if(lasttail) lasttail->next = mpchunk->data; + if (lasttail) lasttail->next = mpchunk->data; /*set the end of this chunks memoryy to the new tail for next iteration*/ lasttail = curnode; @@ -101,15 +102,18 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmall curnode->next = NULL; return pool; } -void *BLI_mempool_alloc(BLI_mempool *pool){ + +void *BLI_mempool_alloc(BLI_mempool *pool) +{ void *retval=NULL; - BLI_freenode *curnode=NULL; - char *addr=NULL; - int j; pool->totused++; - if(!(pool->free)){ + if (!(pool->free)) { + BLI_freenode *curnode=NULL; + char *addr; + int j; + /*need to allocate a new chunk*/ BLI_mempool_chunk *mpchunk = pool->use_sysmalloc ? malloc(sizeof(BLI_mempool_chunk)) : MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk"); mpchunk->next = mpchunk->prev = NULL; @@ -117,7 +121,7 @@ void *BLI_mempool_alloc(BLI_mempool *pool){ BLI_addtail(&(pool->chunks), mpchunk); pool->free = mpchunk->data; /*start of the list*/ - for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){ + for (addr = mpchunk->data, j=0; j < pool->pchunk; j++) { curnode = ((BLI_freenode*)addr); addr += pool->esize; curnode->next = (BLI_freenode*)addr; @@ -133,19 +137,17 @@ void *BLI_mempool_alloc(BLI_mempool *pool){ return retval; } -void *BLI_mempool_calloc(BLI_mempool *pool){ - void *retval=NULL; - retval = BLI_mempool_alloc(pool); +void *BLI_mempool_calloc(BLI_mempool *pool) +{ + void *retval= BLI_mempool_alloc(pool); memset(retval, 0, pool->esize); return retval; } - -void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid! +/* doesnt protect against double frees, dont be stupid! */ +void BLI_mempool_free(BLI_mempool *pool, void *addr) +{ BLI_freenode *newhead = addr; - BLI_freenode *curnode=NULL; - char *tmpaddr=NULL; - int i; newhead->next = pool->free; pool->free = newhead; @@ -154,14 +156,18 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against d /*nothing is in use; free all the chunks except the first*/ if (pool->totused == 0) { - BLI_mempool_chunk *mpchunk=NULL, *first; + BLI_freenode *curnode=NULL; + char *tmpaddr=NULL; + int i; + + BLI_mempool_chunk *mpchunk=NULL; + BLI_mempool_chunk *first= pool->chunks.first; - first = pool->chunks.first; BLI_remlink(&pool->chunks, first); - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { - if(pool->use_sysmalloc) free(mpchunk->data); - else MEM_freeN(mpchunk->data); + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + if (pool->use_sysmalloc) free(mpchunk->data); + else MEM_freeN(mpchunk->data); } pool->use_sysmalloc ? BLI_freelist(&(pool->chunks)) : BLI_freelistN(&(pool->chunks)); @@ -170,7 +176,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against d pool->totalloc = pool->pchunk; pool->free = first->data; /*start of the list*/ - for(tmpaddr = first->data, i=0; i < pool->pchunk; i++){ + for (tmpaddr = first->data, i=0; i < pool->pchunk; i++) { curnode = ((BLI_freenode*)tmpaddr); tmpaddr += pool->esize; curnode->next = (BLI_freenode*)tmpaddr; @@ -182,15 +188,16 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against d void BLI_mempool_destroy(BLI_mempool *pool) { BLI_mempool_chunk *mpchunk=NULL; - if(pool->use_sysmalloc) { - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + + if (pool->use_sysmalloc) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { free(mpchunk->data); } BLI_freelist(&(pool->chunks)); free(pool); } else { - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { MEM_freeN(mpchunk->data); } BLI_freelistN(&(pool->chunks)); -- cgit v1.2.3