This commit is contained in:
2011-08-16 18:59:45 +00:00
parent 360fcd73fe
commit c7fce6be2e
200 changed files with 16204 additions and 14830 deletions

View File

@@ -37,8 +37,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
extern void PyC_LineSpit(void);
#define MAX_DIMENSIONS 4
/* Swizzle axes get packed into a single value that is used as a closure. Each
@@ -1161,28 +1159,18 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
}
else if (vec1) {
if (MatrixObject_Check(v2)) {
extern void PyC_LineSpit(void);
/* VEC * MATRIX */
/* this is deprecated!, use the reverse instead */
float tvec[MAX_DIMENSIONS];
/* ------ to be removed ------*/
#ifndef MATH_STANDALONE
#ifdef WITH_ASSERT_ABORT
#if 1
PyErr_SetString(PyExc_ValueError,
"(Vector * Matrix) is now removed, reverse the "
"order (promoted to an Error for Debug builds)");
return NULL;
#else
printf("Warning: (Vector * Matrix) is now deprecated, "
"reverse the multiplication order in the script.\n");
PyC_LineSpit();
#endif
#endif /* ifndef MATH_STANDALONE */
/* ------ to be removed ------*/
/* VEC * MATRIX */
/* this is deprecated!, use the reverse instead */
float tvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
@@ -1191,9 +1179,18 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
}
return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1));
#endif
/* ------ to be removed ------*/
}
else if (QuaternionObject_Check(v2)) {
/* VEC * QUAT */
/* ------ to be removed ------*/
#if 1
PyErr_SetString(PyExc_ValueError,
"(Vector * Quat) is now removed, reverse the "
"order (promoted to an Error for Debug builds)");
return NULL;
#else
QuaternionObject *quat2 = (QuaternionObject*)v2;
float tvec[3];
@@ -1207,26 +1204,11 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
return NULL;
}
/* ------ to be removed ------*/
#ifndef MATH_STANDALONE
#ifdef WITH_ASSERT_ABORT
PyErr_SetString(PyExc_ValueError,
"(Vector * Quat) is now removed, reverse the "
"order (promoted to an Error for Debug builds)");
return NULL;
#else
printf("Warning: (Vector * Quat) is now deprecated, "
"reverse the multiplication order in the script.\n");
PyC_LineSpit();
#endif
#endif /* ifndef MATH_STANDALONE */
/* ------ to be removed ------*/
copy_v3_v3(tvec, vec1->vec);
mul_qt_v3(quat2->quat, tvec);
return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1));
#endif
/* ------ to be removed ------*/
}
else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC * FLOAT */
return vector_mul_float(vec1, scalar);
@@ -1260,6 +1242,14 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
/* only support vec*=float and vec*=mat
vec*=vec result is a float so that wont work */
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) "
"and uses the non in-place multiplication.");
return NULL;
#else
float rvec[MAX_DIMENSIONS];
if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
@@ -1267,28 +1257,21 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1)
return NULL;
/* ------ to be removed ------*/
#ifndef MATH_STANDALONE
#ifdef WITH_ASSERT_ABORT
PyErr_SetString(PyExc_ValueError,
"(Vector *= Matrix) is now removed, reverse the "
"order (promoted to an Error for Debug builds) "
"and uses the non in-place multiplication.");
return NULL;
#else
printf("Warning: (Vector *= Matrix) is now deprecated, "
"reverse the (non in-place) multiplication order in the script.\n");
PyC_LineSpit();
#endif
#endif /* ifndef MATH_STANDALONE */
/* ------ to be removed ------*/
memcpy(vec->vec, rvec, sizeof(float) * vec->size);
#endif
/* ------ to be removed ------*/
}
else if (QuaternionObject_Check(v2)) {
/* VEC *= QUAT */
/* ------ to be removed ------*/
#if 1
PyErr_SetString(PyExc_ValueError,
"(Vector *= Quat) is now removed, reverse the "
"order (promoted to an Error for Debug builds) "
"and uses the non in-place multiplication.");
return NULL;
#else
QuaternionObject *quat2 = (QuaternionObject*)v2;
if(vec->size != 3) {
@@ -1302,25 +1285,9 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
return NULL;
}
/* ------ to be removed ------*/
#ifndef MATH_STANDALONE
#ifdef WITH_ASSERT_ABORT
PyErr_SetString(PyExc_ValueError,
"(Vector *= Quat) is now removed, reverse the "
"order (promoted to an Error for Debug builds) "
"and uses the non in-place multiplication.");
return NULL;
#else
printf("Warning: (Vector *= Quat) is now deprecated, "
"reverse the (non in-place) multiplication order in the script.\n");
PyC_LineSpit();
#endif
#endif /* ifndef MATH_STANDALONE */
/* ------ to be removed ------*/
mul_qt_v3(quat2->quat, vec->vec);
#endif
/* ------ to be removed ------*/
}
else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */
mul_vn_fl(vec->vec, vec->size, scalar);
@@ -1728,6 +1695,21 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
return 0;
}
/* vector.length_squared */
static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure))
{
double dot = 0.0f;
int i;
if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++){
dot += (double)(self->vec[i] * self->vec[i]);
}
return PyFloat_FromDouble(dot);
}
/* Get a new Vector according to the provided swizzle. This function has little
error checking, as we are in control of the inputs: the closure is set by us
in Vector_createSwizzleGetSeter. */
@@ -1851,6 +1833,7 @@ static PyGetSetDef Vector_getseters[] = {
{(char *)"z", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2},
{(char *)"w", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3},
{(char *)"length", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL},
{(char *)"length_squared", (getter)Vector_getLengthSquared, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL},
{(char *)"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL},
{(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL},