Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-20 22:48:28 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-20 22:48:28 +0400
commita2c6db0b446cc3c8e54a0381e041056fe143472a (patch)
treeaf49a6005a22b1720f75ac25f86a2607ef3e8d28 /source/blender/python
parent153e4cad4be9455e47b823745c9fa6cbe0305e52 (diff)
parent0af633a36ce34fc2d80fb571f4b0e73233563827 (diff)
Cycles: svn merge -r40358:40411 ^/trunk/blender
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/SConscript3
-rw-r--r--source/blender/python/generic/CMakeLists.txt3
-rw-r--r--source/blender/python/generic/blf_py_api.c34
-rw-r--r--source/blender/python/intern/CMakeLists.txt1
-rw-r--r--source/blender/python/intern/bpy.h4
-rw-r--r--source/blender/python/intern/bpy_interface.c6
-rw-r--r--source/blender/python/intern/bpy_interface_atexit.c94
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c16
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c72
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c12
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c87
11 files changed, 235 insertions, 97 deletions
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript
index 9d7928c4432..5cc3f3bedc4 100644
--- a/source/blender/python/SConscript
+++ b/source/blender/python/SConscript
@@ -17,6 +17,9 @@ defs = []
if is_debug:
defs.append('_DEBUG')
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('INTERNATIONAL')
+
sources = env.Glob('generic/*.c')
env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [363,165]) # ketsji is 360
diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt
index 8dfbf476995..0a49036c15d 100644
--- a/source/blender/python/generic/CMakeLists.txt
+++ b/source/blender/python/generic/CMakeLists.txt
@@ -48,5 +48,8 @@ set(SRC
py_capi_utils.h
)
+if(WITH_INTERNATIONAL)
+ add_definitions(-DINTERNATIONAL)
+endif()
blender_add_lib(bf_python_ext "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 3cf0b0f1f27..87e4a301eff 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -31,9 +31,13 @@
#include "blf_py_api.h"
#include "../../blenfont/BLF_api.h"
+#include "../../blenfont/BLF_translation.h"
#include "BLI_utildefines.h"
+#ifdef INTERNATIONAL
+#include "DNA_userdef_types.h" /* is it bad level? */
+#endif
PyDoc_STRVAR(py_blf_position_doc,
@@ -367,6 +371,35 @@ static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
return PyLong_FromLong(BLF_load(filename));
}
+PyDoc_STRVAR(py_blf_gettext_doc,
+".. function:: gettext(msgid)\n"
+"\n"
+" Get a msg in local language.\n"
+"\n"
+" :arg msgid: the source string.\n"
+" :type msgid: string\n"
+" :return: the localized string.\n"
+" :rtype: string\n"
+);
+static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
+{
+#ifdef INTERNATIONAL
+ if ((U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE)) {
+ const char *msgid= _PyUnicode_AsString(value);
+ if(msgid == NULL) {
+ PyErr_SetString(PyExc_TypeError, "blf.gettext expects a single string argument");
+ return NULL;
+ }
+
+ return PyUnicode_FromString(BLF_gettext(msgid));
+ }
+ else
+#endif /* INTERNATIONAL */
+ {
+ return Py_INCREF(value), value;
+ }
+}
+
/*----------------------------MODULE INIT-------------------------*/
static PyMethodDef BLF_methods[] = {
{"aspect", (PyCFunction) py_blf_aspect, METH_VARARGS, py_blf_aspect_doc},
@@ -382,6 +415,7 @@ static PyMethodDef BLF_methods[] = {
{"shadow_offset", (PyCFunction) py_blf_shadow_offset, METH_VARARGS, py_blf_shadow_offset_doc},
{"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc},
{"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc},
+ {"gettext", (PyCFunction) py_blf_gettext, METH_O, py_blf_gettext_doc},
{NULL, NULL, 0, NULL}
};
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index d4ea7aec44d..807074b92ce 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRC
bpy_app_handlers.c
bpy_driver.c
bpy_interface.c
+ bpy_interface_atexit.c
bpy_intern_string.c
bpy_library.c
bpy_operator.c
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 0ebc6bb2438..f60146021d3 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -28,3 +28,7 @@
void BPy_init_modules(void);
extern PyObject *bpy_package_py;
+
+/* bpy_interface_atexit.c */
+void BPY_atexit_register(void);
+void BPY_atexit_unregister(void);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 3182836bf42..fcaaf2ff663 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -30,7 +30,7 @@
/* grr, python redefines */
#ifdef _POSIX_C_SOURCE
-#undef _POSIX_C_SOURCE
+# undef _POSIX_C_SOURCE
#endif
#include <Python.h>
@@ -246,6 +246,8 @@ void BPY_python_start(int argc, const char **argv)
pyrna_alloc_types();
+ BPY_atexit_register(); /* this can init any time */
+
#ifndef WITH_PYTHON_MODULE
py_tstate= PyGILState_GetThisThreadState();
PyEval_ReleaseThread(py_tstate);
@@ -265,6 +267,8 @@ void BPY_python_end(void)
bpy_intern_string_exit();
+ BPY_atexit_unregister(); /* without this we get recursive calls to WM_exit */
+
Py_Finalize();
#ifdef TIME_PY_RUN
diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c
new file mode 100644
index 00000000000..ac8c90198a0
--- /dev/null
+++ b/source/blender/python/intern/bpy_interface_atexit.c
@@ -0,0 +1,94 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/intern/bpy_interface_atexit.c
+ * \ingroup pythonintern
+ */
+
+
+#include <Python.h>
+
+#include "bpy_util.h"
+
+#include "WM_api.h"
+
+#include "BLI_utildefines.h"
+
+static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyObject *UNUSED(kw))
+{
+ /* close down enough of blender at least not to crash */
+ struct bContext *C= BPy_GetContext();
+
+ WM_exit_ext(C, 0);
+
+ Py_RETURN_NONE;
+}
+
+static PyMethodDef meth_bpy_atexit= {"bpy_atexit", (PyCFunction)bpy_atexit, METH_NOARGS, NULL};
+static PyObject *func_bpy_atregister= NULL; /* borrowed referebce, atexit holds */
+
+static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
+{
+ /* note - no error checking, if any of these fail we'll get a crash
+ * this is intended, but if its problematic it could be changed
+ * - campbell */
+
+ PyObject *atexit_mod= PyImport_ImportModuleLevel((char *)"atexit", NULL, NULL, NULL, 0);
+ PyObject *atexit_func= PyObject_GetAttrString(atexit_mod, func_name);
+ PyObject *args= PyTuple_New(1);
+ PyObject *ret;
+
+ PyTuple_SET_ITEM(args, 0, atexit_func_arg);
+ Py_INCREF(atexit_func_arg); /* only incref so we dont dec'ref along with 'args' */
+
+ ret= PyObject_CallObject(atexit_func, args);
+
+ Py_DECREF(atexit_mod);
+ Py_DECREF(atexit_func);
+ Py_DECREF(args);
+
+ if(ret) {
+ Py_DECREF(ret);
+ }
+ else { /* should never happen */
+ PyErr_Print();
+ }
+}
+
+void BPY_atexit_register(void)
+{
+ /* atexit module owns this new function reference */
+ BLI_assert(func_bpy_atregister == NULL);
+
+ func_bpy_atregister= (PyObject *)PyCFunction_New(&meth_bpy_atexit, NULL);
+ atexit_func_call("register", func_bpy_atregister);
+}
+
+void BPY_atexit_unregister(void)
+{
+ BLI_assert(func_bpy_atregister != NULL);
+
+ atexit_func_call("unregister", func_bpy_atregister);
+ func_bpy_atregister= NULL; /* don't really need to set but just incase */
+}
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 5c609d8961f..c96eafcd6ad 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -196,16 +196,18 @@ PyDoc_STRVAR(Euler_rotate_axis_doc,
static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
{
float angle = 0.0f;
- const char *axis;
+ int axis; /* actually a character */
- if(!PyArg_ParseTuple(args, "sf:rotate", &axis, &angle)){
+ if(!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)){
PyErr_SetString(PyExc_TypeError,
- "euler.rotate(): "
- "expected angle (float) and axis (x, y, z)");
+ "Euler.rotate_axis(): "
+ "expected an axis 'X', 'Y', 'Z' and an angle (float)");
return NULL;
}
- if(!(ELEM3(*axis, 'X', 'Y', 'Z') && axis[1]=='\0')){
- PyErr_SetString(PyExc_ValueError, "euler.rotate(): "
+
+ if(!(ELEM3(axis, 'X', 'Y', 'Z'))){
+ PyErr_SetString(PyExc_ValueError,
+ "Euler.rotate_axis(): "
"expected axis to be 'X', 'Y' or 'Z'");
return NULL;
}
@@ -214,7 +216,7 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
return NULL;
- rotate_eulO(self->eul, self->order, *axis, angle);
+ rotate_eulO(self->eul, self->order, (char)axis, angle);
(void)BaseMath_WriteCallback(self);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 2da96dc62e6..a2a15600965 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -119,7 +119,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
if(kwds && PyDict_Size(kwds)) {
PyErr_SetString(PyExc_TypeError,
- "mathutils.Matrix(): "
+ "Matrix(): "
"takes no keyword args");
return NULL;
}
@@ -155,7 +155,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* will overwrite error */
PyErr_SetString(PyExc_TypeError,
- "mathutils.Matrix(): "
+ "Matrix(): "
"expects no args or 2-4 numeric sequences");
return NULL;
}
@@ -216,7 +216,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
if(!PyArg_ParseTuple(args, "di|O", &angle, &matSize, &vec)) {
PyErr_SetString(PyExc_TypeError,
- "mathutils.RotationMatrix(angle, size, axis): "
+ "Matrix.Rotation(angle, size, axis): "
"expected float int and a string or vector");
return NULL;
}
@@ -225,7 +225,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
axis= _PyUnicode_AsString((PyObject *)vec);
if(axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') {
PyErr_SetString(PyExc_ValueError,
- "mathutils.RotationMatrix(): "
+ "Matrix.Rotation(): "
"3rd argument axis value must be a 3D vector "
"or a string in 'X', 'Y', 'Z'");
return NULL;
@@ -240,19 +240,19 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
if(matSize != 2 && matSize != 3 && matSize != 4) {
PyErr_SetString(PyExc_ValueError,
- "mathutils.RotationMatrix(): "
+ "Matrix.Rotation(): "
"can only return a 2x2 3x3 or 4x4 matrix");
return NULL;
}
if(matSize == 2 && (vec != NULL)) {
PyErr_SetString(PyExc_ValueError,
- "mathutils.RotationMatrix(): "
+ "Matrix.Rotation(): "
"cannot create a 2x2 rotation matrix around arbitrary axis");
return NULL;
}
if((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) {
PyErr_SetString(PyExc_ValueError,
- "mathutils.RotationMatrix(): "
+ "Matrix.Rotation(): "
"axis of rotation for 3d and 4d matrices is required");
return NULL;
}
@@ -261,7 +261,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
if(vec) {
float tvec[3];
- if (mathutils_array_parse(tvec, 3, 3, vec, "mathutils.RotationMatrix(angle, size, axis), invalid 'axis' arg") == -1)
+ if (mathutils_array_parse(tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1)
return NULL;
axis_angle_to_mat3((float (*)[3])mat, tvec, angle);
@@ -428,7 +428,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
}
if(matSize != 2 && matSize != 3 && matSize != 4) {
PyErr_SetString(PyExc_ValueError,
- "mathutils.Matrix.OrthoProjection(): "
+ "Matrix.OrthoProjection(): "
"can only return a 2x2 3x3 or 4x4 matrix");
return NULL;
}
@@ -445,7 +445,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
}
else {
PyErr_Format(PyExc_ValueError,
- "mathutils.Matrix.OrthoProjection(): "
+ "Matrix.OrthoProjection(): "
"unknown plane, expected: X, Y, not '%.200s'",
plane);
return NULL;
@@ -466,7 +466,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
}
else {
PyErr_Format(PyExc_ValueError,
- "mathutils.Matrix.OrthoProjection(): "
+ "Matrix.OrthoProjection(): "
"unknown plane, expected: XY, XZ, YZ, not '%.200s'",
plane);
return NULL;
@@ -545,7 +545,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
}
if(matSize != 2 && matSize != 3 && matSize != 4) {
PyErr_SetString(PyExc_ValueError,
- "mathutils.Matrix.Shear(): "
+ "Matrix.Shear(): "
"can only return a 2x2 3x3 or 4x4 matrix");
return NULL;
}
@@ -555,7 +555,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
if(factor==-1.0f && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
- "mathutils.Matrix.Shear(): "
+ "Matrix.Shear(): "
"the factor to be a float");
return NULL;
}
@@ -604,7 +604,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
}
else {
PyErr_SetString(PyExc_ValueError,
- "mathutils.Matrix.Shear(): "
+ "Matrix.Shear(): "
"expected: X, Y, XY, XZ, YZ");
return NULL;
}
@@ -663,7 +663,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
/*must be 3-4 cols, 3-4 rows, square matrix*/
if((self->col_size < 3) || (self->row_size < 3) || (self->col_size != self->row_size)) {
PyErr_SetString(PyExc_ValueError,
- "matrix.to_quat(): "
+ "Matrix.to_quat(): "
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
return NULL;
}
@@ -727,13 +727,13 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
}
else {
PyErr_SetString(PyExc_ValueError,
- "matrix.to_euler(): "
+ "Matrix.to_euler(): "
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
return NULL;
}
if(order_str) {
- order= euler_order_from_string(order_str, "matrix.to_euler()");
+ order= euler_order_from_string(order_str, "Matrix.to_euler()");
if(order == -1)
return NULL;
@@ -762,11 +762,13 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
if(self->wrapped==Py_WRAP){
PyErr_SetString(PyExc_TypeError,
+ "Matrix.resize_4x4(): "
"cannot resize wrapped data - make a copy and resize that");
return NULL;
}
if(self->cb_user){
PyErr_SetString(PyExc_TypeError,
+ "Matrix.resize_4x4(): "
"cannot resize owned data - make a copy and resize that");
return NULL;
}
@@ -774,7 +776,8 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
self->contigPtr = PyMem_Realloc(self->contigPtr, (sizeof(float) * 16));
if(self->contigPtr == NULL) {
PyErr_SetString(PyExc_MemoryError,
- "matrix.resize_4x4(): problem allocating pointer space");
+ "Matrix.resize_4x4(): "
+ "problem allocating pointer space");
return NULL;
}
/*set row pointers*/
@@ -835,7 +838,8 @@ static PyObject *Matrix_to_4x4(MatrixObject *self)
/* TODO, 2x2 matrix */
PyErr_SetString(PyExc_TypeError,
- "matrix.to_4x4(): inappropriate matrix size");
+ "Matrix.to_4x4(): "
+ "inappropriate matrix size");
return NULL;
}
@@ -856,7 +860,7 @@ static PyObject *Matrix_to_3x3(MatrixObject *self)
if((self->col_size < 3) || (self->row_size < 3)) {
PyErr_SetString(PyExc_TypeError,
- "matrix.to_3x3(): inappropriate matrix size");
+ "Matrix.to_3x3(): inappropriate matrix size");
return NULL;
}
@@ -880,7 +884,7 @@ static PyObject *Matrix_to_translation(MatrixObject *self)
if((self->col_size < 3) || self->row_size < 4){
PyErr_SetString(PyExc_TypeError,
- "matrix.to_translation(): "
+ "Matrix.to_translation(): "
"inappropriate matrix size");
return NULL;
}
@@ -910,7 +914,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self)
/*must be 3-4 cols, 3-4 rows, square matrix*/
if((self->col_size < 3) || (self->row_size < 3)) {
PyErr_SetString(PyExc_TypeError,
- "matrix.to_scale(): "
+ "Matrix.to_scale(): "
"inappropriate matrix size, 3x3 minimum size");
return NULL;
}
@@ -946,7 +950,7 @@ static PyObject *Matrix_invert(MatrixObject *self)
if(self->row_size != self->col_size){
PyErr_SetString(PyExc_TypeError,
- "matrix.invert(ed): "
+ "Matrix.invert(ed): "
"only square matrices are supported");
return NULL;
}
@@ -982,6 +986,7 @@ static PyObject *Matrix_invert(MatrixObject *self)
}
else {
PyErr_SetString(PyExc_ValueError,
+ "Matrix.invert(ed): "
"matrix does not have an inverse");
return NULL;
}
@@ -1027,7 +1032,8 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value)
if(self->col_size != 3 || self->row_size != 3) {
PyErr_SetString(PyExc_TypeError,
- "Matrix must have 3x3 dimensions");
+ "Matrix.rotate(): "
+ "must have 3x3 dimensions");
return NULL;
}
@@ -1059,7 +1065,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
if(self->col_size != 4 || self->row_size != 4) {
PyErr_SetString(PyExc_TypeError,
- "matrix.decompose(): "
+ "Matrix.decompose(): "
"inappropriate matrix size - expects 4x4 matrix");
return NULL;
}
@@ -1102,7 +1108,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
if(self->row_size != mat2->row_size || self->col_size != mat2->col_size) {
PyErr_SetString(PyExc_ValueError,
- "matrix.lerp(): "
+ "Matrix.lerp(): "
"expects both matrix objects of the same dimensions");
return NULL;
}
@@ -1119,7 +1125,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
}
else {
PyErr_SetString(PyExc_ValueError,
- "matrix.lerp(): "
+ "Matrix.lerp(): "
"only 3x3 and 4x4 matrices supported");
return NULL;
}
@@ -1145,7 +1151,7 @@ static PyObject *Matrix_determinant(MatrixObject *self)
if(self->row_size != self->col_size){
PyErr_SetString(PyExc_TypeError,
- "matrix.determinant: "
+ "Matrix.determinant(): "
"only square matrices are supported");
return NULL;
}
@@ -1169,7 +1175,7 @@ static PyObject *Matrix_transpose(MatrixObject *self)
if(self->row_size != self->col_size){
PyErr_SetString(PyExc_TypeError,
- "matrix.transpose(d): "
+ "Matrix.transpose(d): "
"only square matrices are supported");
return NULL;
}
@@ -1238,7 +1244,7 @@ static PyObject *Matrix_identity(MatrixObject *self)
if(self->row_size != self->col_size){
PyErr_SetString(PyExc_TypeError,
- "matrix.identity: "
+ "Matrix.identity(): "
"only square matrices are supported");
return NULL;
}
@@ -1771,7 +1777,7 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur
/*must be 3-4 cols, 3-4 rows, square matrix*/
if((self->col_size < 3) || (self->row_size < 3)) {
PyErr_SetString(PyExc_AttributeError,
- "matrix.median_scale: "
+ "Matrix.median_scale: "
"inappropriate matrix size, 3x3 minimum");
return NULL;
}
@@ -1793,7 +1799,7 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure
return PyBool_FromLong(is_negative_m3((float (*)[3])self->contigPtr));
else {
PyErr_SetString(PyExc_AttributeError,
- "matrix.is_negative: "
+ "Matrix.is_negative: "
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
return NULL;
}
@@ -1811,7 +1817,7 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->contigPtr));
else {
PyErr_SetString(PyExc_AttributeError,
- "matrix.is_orthogonal: "
+ "Matrix.is_orthogonal: "
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
return NULL;
}
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 2be258a1ef0..947e4425d3f 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -161,7 +161,7 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
if(BaseMath_ReadCallback(self) == -1)
return NULL;
- if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.cross(other), invalid 'other' arg") == -1)
+ if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
return NULL;
mul_qt_qtqt(quat, self->quat, tquat);
@@ -186,7 +186,7 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
if(BaseMath_ReadCallback(self) == -1)
return NULL;
- if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.dot(other), invalid 'other' arg") == -1)
+ if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
return NULL;
return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
@@ -209,7 +209,7 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject
if(BaseMath_ReadCallback(self) == -1)
return NULL;
- if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.difference(other), invalid 'other' arg") == -1)
+ if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
return NULL;
rotation_between_quats_to_quat(quat, self->quat, tquat);
@@ -244,7 +244,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
if(BaseMath_ReadCallback(self) == -1)
return NULL;
- if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.slerp(other), invalid 'other' arg") == -1)
+ if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
return NULL;
if(fac > 1.0f || fac < 0.0f) {
@@ -275,7 +275,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
if(BaseMath_ReadCallback(self) == -1)
return NULL;
- if(mathutils_any_to_rotmat(other_rmat, value, "quaternion.rotate(value)") == -1)
+ if(mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
return NULL;
length= normalize_qt_qt(tquat, self->quat);
@@ -909,7 +909,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
if(angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
- "quaternion.angle = value: float expected");
+ "Quaternion.angle = value: float expected");
return -1;
}
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 56c1334ecac..413df78f09e 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -48,6 +48,7 @@
static PyObject *Vector_copy(VectorObject *self);
static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits);
+static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat);
/* Supports 2D, 3D, and 4D vector objects both int and float values
* accepted. Mixed float and int values accepted. Ints are parsed to float
@@ -158,13 +159,13 @@ static PyObject *Vector_resize_2d(VectorObject *self)
{
if(self->wrapped==Py_WRAP) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_2d(): "
+ "Vector.resize_2d(): "
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_2d(): "
+ "Vector.resize_2d(): "
"cannot resize a vector that has an owner");
return NULL;
}
@@ -172,7 +173,7 @@ static PyObject *Vector_resize_2d(VectorObject *self)
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
if(self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
- "vector.resize_2d(): "
+ "Vector.resize_2d(): "
"problem allocating pointer space");
return NULL;
}
@@ -193,13 +194,13 @@ static PyObject *Vector_resize_3d(VectorObject *self)
{
if (self->wrapped==Py_WRAP) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_3d(): "
+ "Vector.resize_3d(): "
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_3d(): "
+ "Vector.resize_3d(): "
"cannot resize a vector that has an owner");
return NULL;
}
@@ -207,7 +208,7 @@ static PyObject *Vector_resize_3d(VectorObject *self)
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
if(self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
- "vector.resize_3d(): "
+ "Vector.resize_3d(): "
"problem allocating pointer space");
return NULL;
}
@@ -231,13 +232,13 @@ static PyObject *Vector_resize_4d(VectorObject *self)
{
if(self->wrapped==Py_WRAP) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_4d(): "
+ "Vector.resize_4d(): "
"cannot resize wrapped data - only python vectors");
return NULL;
}
if(self->cb_user) {
PyErr_SetString(PyExc_TypeError,
- "vector.resize_4d(): "
+ "Vector.resize_4d(): "
"cannot resize a vector that has an owner");
return NULL;
}
@@ -245,7 +246,7 @@ static PyObject *Vector_resize_4d(VectorObject *self)
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
if(self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
- "vector.resize_4d(): "
+ "Vector.resize_4d(): "
"problem allocating pointer space");
return NULL;
}
@@ -353,7 +354,7 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
if(ndigits > 22 || ndigits < 0) {
PyErr_SetString(PyExc_ValueError,
- "vector.to_tuple(ndigits): "
+ "Vector.to_tuple(ndigits): "
"ndigits must be between 0 and 21");
return NULL;
}
@@ -390,7 +391,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
if (self->size != 3) {
PyErr_SetString(PyExc_TypeError,
- "vector.to_track_quat(): "
+ "Vector.to_track_quat(): "
"only for 3D vectors");
return NULL;
}
@@ -511,7 +512,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
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];
@@ -550,7 +551,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
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));
@@ -577,7 +578,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
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++) {
@@ -617,7 +618,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
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++) {
@@ -632,7 +633,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
}
else {
PyErr_SetString(PyExc_ValueError,
- "vector.angle(other): "
+ "Vector.angle(other): "
"zero length vectors have no valid angle");
return NULL;
}
@@ -674,7 +675,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value)
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);
@@ -706,7 +707,7 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
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)
@@ -748,7 +749,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
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)
@@ -777,7 +778,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
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) {
@@ -838,7 +839,7 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_at
if(i < 0 || i >= self->size) {
if(is_attr) {
PyErr_Format(PyExc_AttributeError,
- "vector.%c: unavailable on %dd vector",
+ "Vector.%c: unavailable on %dd vector",
*(((char *)"xyzw") + i), self->size);
}
else {
@@ -874,7 +875,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
if(i < 0 || i >= self->size){
if(is_attr) {
PyErr_Format(PyExc_AttributeError,
- "vector.%c = x: unavailable on %dd vector",
+ "Vector.%c = x: unavailable on %dd vector",
*(((char *)"xyzw") + i), self->size);
}
else {
@@ -1159,28 +1160,16 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
}
else if (vec1) {
if (MatrixObject_Check(v2)) {
-
-/* ------ to be removed ------*/
-#if 1
- PyErr_SetString(PyExc_ValueError,
- "(Vector * Matrix) is now removed, reverse the "
- "order (promoted to an Error for Debug builds)");
- return NULL;
-#else
-
/* VEC * MATRIX */
- /* this is deprecated!, use the reverse instead */
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
- if(column_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) {
+ if(row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) {
return NULL;
}
return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1));
-#endif
-/* ------ to be removed ------*/
}
else if (QuaternionObject_Check(v2)) {
/* VEC * QUAT */
@@ -2219,20 +2208,19 @@ if len(unique) != len(items):
print "ERROR"
*/
-#if 0
-//ROW VECTOR Multiplication - Vector X Matrix
-//[x][y][z] * [1][4][7]
-// [2][5][8]
-// [3][6][9]
-//vector/matrix multiplication IS NOT COMMUTATIVE!!!!
-static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObject * mat)
+/* ROW VECTOR Multiplication - Vector X Matrix
+ * [x][y][z] * [1][4][7]
+ * [2][5][8]
+ * [3][6][9]
+ * vector/matrix multiplication IS NOT COMMUTATIVE!!!! */
+static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
{
- float vec_cpy[4];
+ float vec_cpy[MAX_DIMENSIONS];
double dot = 0.0f;
- int x, y, z = 0, vec_size = vec->size;
+ int x, y, z= 0, vec_size= vec->size;
- if(mat->colSize != vec_size){
- if(mat->colSize == 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");
@@ -2247,11 +2235,11 @@ static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObj
return -1;
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
-
+printf("asasas\n");
rvec[3] = 1.0f;
//muliplication
- for(x = 0; x < mat->rowSize; x++) {
- for(y = 0; y < mat->colSize; y++) {
+ for(x = 0; x < mat->row_size; x++) {
+ for(y = 0; y < mat->col_size; y++) {
dot += mat->matrix[x][y] * vec_cpy[y];
}
rvec[z++] = (float)dot;
@@ -2259,7 +2247,6 @@ static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObj
}
return 0;
}
-#endif
/*----------------------------Vector.negate() -------------------- */
PyDoc_STRVAR(Vector_negate_doc,