[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42875] trunk/blender/source/blender/ python/mathutils: formatting edits & minor corrections
Campbell Barton
ideasman42 at gmail.com
Mon Dec 26 01:42:42 CET 2011
Revision: 42875
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42875
Author: campbellbarton
Date: 2011-12-26 00:42:35 +0000 (Mon, 26 Dec 2011)
Log Message:
-----------
formatting edits & minor corrections
Modified Paths:
--------------
trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Euler.c 2011-12-26 00:13:03 UTC (rev 42874)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Euler.c 2011-12-26 00:42:35 UTC (rev 42875)
@@ -198,7 +198,7 @@
float angle = 0.0f;
int axis; /* actually a character */
- if (!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)) {
+ if (!PyArg_ParseTuple(args, "Cf:rotate_axis", &axis, &angle)) {
PyErr_SetString(PyExc_TypeError,
"Euler.rotate_axis(): "
"expected an axis 'X', 'Y', 'Z' and an angle (float)");
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2011-12-26 00:13:03 UTC (rev 42874)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2011-12-26 00:42:35 UTC (rev 42875)
@@ -432,13 +432,12 @@
const char *axis = NULL;
int matSize;
double angle; /* use double because of precision problems at high values */
- 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 (!PyArg_ParseTuple(args, "di|O", &angle, &matSize, &vec)) {
- PyErr_SetString(PyExc_TypeError,
- "Matrix.Rotation(angle, size, axis): "
- "expected float int and a string or vector");
+ if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) {
return NULL;
}
@@ -552,8 +551,10 @@
float tvec[3];
float factor;
int matSize;
- 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 (!PyArg_ParseTuple(args, "fi|O:Matrix.Scale", &factor, &matSize, &vec)) {
return NULL;
@@ -566,7 +567,9 @@
}
if (vec) {
vec_size = (matSize == 2 ? 2 : 3);
- if (mathutils_array_parse(tvec, vec_size, vec_size, vec, "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == -1) {
+ if (mathutils_array_parse(tvec, vec_size, vec_size, vec,
+ "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == -1)
+ {
return NULL;
}
}
@@ -638,8 +641,10 @@
int matSize, x;
float norm = 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 (!PyArg_ParseTuple(args, "Oi:Matrix.OrthoProjection", &axis, &matSize)) {
return NULL;
@@ -757,8 +762,10 @@
int matSize;
const char *plane;
PyObject *fac;
- 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 (!PyArg_ParseTuple(args, "siO:Matrix.Shear", &plane, &matSize, &fac)) {
return NULL;
@@ -1751,8 +1758,11 @@
/* parse each sub sequence */
PyObject *item = PySequence_Fast_GET_ITEM(value_fast, row - begin);
- if (mathutils_array_parse(vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") < 0)
+ if (mathutils_array_parse(vec, self->num_col, self->num_col, item,
+ "matrix[begin:end] = value assignment") < 0)
+ {
return -1;
+ }
for (col = 0; col < self->num_col; col++) {
mat[col * self->num_row + row] = vec[col];
@@ -1866,7 +1876,7 @@
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
- double dot = 0.0f;
+
int col, row, item;
if (mat1->num_col != mat2->num_row) {
@@ -1878,11 +1888,11 @@
for (col = 0; col < mat2->num_col; col++) {
for (row = 0; row < mat1->num_row; row++) {
+ double dot = 0.0f;
for (item = 0; item < mat1->num_col; item++) {
dot += MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col);
}
mat[(col * mat1->num_row) + row] = (float)dot;
- dot = 0.0f;
}
}
@@ -2119,8 +2129,9 @@
return -1;
}
- if ((mathutils_array_parse(tvec, 3, 3, value, "Matrix.translation")) == -1)
+ if ((mathutils_array_parse(tvec, 3, 3, value, "Matrix.translation")) == -1) {
return -1;
+ }
copy_v3_v3(((float (*)[4])self->matrix)[3], tvec);
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c 2011-12-26 00:13:03 UTC (rev 42874)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c 2011-12-26 00:42:35 UTC (rev 42875)
@@ -194,8 +194,10 @@
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);
return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self));
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Vector.c 2011-12-26 00:13:03 UTC (rev 42874)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Vector.c 2011-12-26 00:42:35 UTC (rev 42875)
@@ -279,7 +279,9 @@
return NULL;
}
- if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) {
+ if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value,
+ "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1)
+ {
PyMem_Free(iter_vec);
return NULL;
}
@@ -1489,7 +1491,6 @@
int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
{
float vec_cpy[MAX_DIMENSIONS];
- double dot = 0.0f;
int row, col, z = 0;
if (mat->num_col != vec->size) {
@@ -1510,11 +1511,11 @@
r_vec[3] = 1.0f;
for (row = 0; row < mat->num_row; row++) {
+ double dot = 0.0f;
for (col = 0; col < mat->num_col; col++) {
dot += (double)(MATRIX_ITEM(mat, row, col) * vec_cpy[col]);
}
r_vec[z++] = (float)dot;
- dot = 0.0f;
}
return 0;
@@ -2625,7 +2626,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)
+static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
{
float vec_cpy[MAX_DIMENSIONS];
int row, col, z = 0, vec_size = vec->size;
@@ -2647,14 +2648,14 @@
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
- rvec[3] = 1.0f;
+ r_vec[3] = 1.0f;
//muliplication
for (col = 0; col < mat->num_col; col++) {
double dot = 0.0;
for (row = 0; row < mat->num_row; row++) {
dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row];
}
- rvec[z++] = (float)dot;
+ r_vec[z++] = (float)dot;
}
return 0;
}
More information about the Bf-blender-cvs
mailing list