Cycles: svn merge -r39132:39457 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
@@ -52,6 +52,9 @@
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
@@ -359,15 +362,18 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
|
||||
static PyObject *pyop_dir(PyObject *UNUSED(self))
|
||||
{
|
||||
GHashIterator *iter= WM_operatortype_iter();
|
||||
PyObject *list= PyList_New(0), *name;
|
||||
wmOperatorType *ot;
|
||||
|
||||
for(ot= WM_operatortype_first(); ot; ot= ot->next) {
|
||||
|
||||
for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
|
||||
|
||||
name= PyUnicode_FromString(ot->idname);
|
||||
PyList_Append(list, name);
|
||||
Py_DECREF(name);
|
||||
}
|
||||
|
||||
BLI_ghashIterator_free(iter);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@@ -856,7 +856,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
|
||||
if(type==PROP_COLLECTION) {
|
||||
len= pyrna_prop_collection_length(self);
|
||||
}
|
||||
else if (RNA_property_array_check(&self->ptr, self->prop)) {
|
||||
else if (RNA_property_array_check(self->prop)) {
|
||||
len= pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
|
||||
}
|
||||
|
||||
@@ -1224,7 +1224,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
||||
PyObject *ret;
|
||||
int type= RNA_property_type(prop);
|
||||
|
||||
if (RNA_property_array_check(ptr, prop)) {
|
||||
if (RNA_property_array_check(prop)) {
|
||||
return pyrna_py_from_array(ptr, prop);
|
||||
}
|
||||
|
||||
@@ -1369,7 +1369,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
int type= RNA_property_type(prop);
|
||||
|
||||
|
||||
if (RNA_property_array_check(ptr, prop)) {
|
||||
if (RNA_property_array_check(prop)) {
|
||||
/* done getting the length */
|
||||
if(pyrna_py_to_array(ptr, prop, data, value, error_prefix) == -1) {
|
||||
return -1;
|
||||
@@ -4088,7 +4088,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
|
||||
int type= RNA_property_type(prop);
|
||||
int flag= RNA_property_flag(prop);
|
||||
|
||||
if(RNA_property_array_check(ptr, prop)) {
|
||||
if(RNA_property_array_check(prop)) {
|
||||
int a, len;
|
||||
|
||||
if (flag & PROP_DYNAMIC) {
|
||||
@@ -5519,7 +5519,7 @@ PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
BPy_PropertyRNA *pyrna;
|
||||
|
||||
if (RNA_property_array_check(ptr, prop) == 0) {
|
||||
if (RNA_property_array_check(prop) == 0) {
|
||||
PyTypeObject *type;
|
||||
|
||||
if (RNA_property_type(prop) != PROP_COLLECTION) {
|
||||
|
@@ -107,7 +107,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(RNA_property_array_check(&r_ptr, prop) == 0) {
|
||||
if(RNA_property_array_check(prop) == 0) {
|
||||
if((*index) == -1) {
|
||||
*index= 0;
|
||||
}
|
||||
|
@@ -285,17 +285,20 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int
|
||||
int totdim= RNA_property_array_dimension(ptr, prop, NULL);
|
||||
const int seq_size= PySequence_Size(seq);
|
||||
|
||||
/* General note for 'data' being NULL or PySequence_GetItem() failing.
|
||||
/* Regarding PySequence_GetItem() failing.
|
||||
*
|
||||
* This should never be NULL since we validated it, _but_ some triky python
|
||||
* developer could write their own sequence type which succeeds on
|
||||
* validating but fails later somehow, so include checks for safety. */
|
||||
* validating but fails later somehow, so include checks for safety.
|
||||
*/
|
||||
|
||||
/* Note that 'data can be NULL' */
|
||||
|
||||
if(seq_size == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i= 0; (i < seq_size) && data; i++) {
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
if(item) {
|
||||
if (dim + 1 < totdim) {
|
||||
|
@@ -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},
|
||||
|
Reference in New Issue
Block a user