py api
- mathutils.Color.hsv attribute. eg. material.diffuse_color.hsv = 0.2, 0.8, 0.4 - Vector/Euler/Quaternion/Color now only take a single seq arg. - internal function for parsing arrays. (cleanup messy internal list/vector/tuple/seq parsing) - didnt update rigify yet.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
/* Note: Changes to Mathutils since 2.4x
|
||||
* use radians rather then degrees
|
||||
* - Mathutils.Vector/Euler/Quaternion(), now only take single sequence arguments.
|
||||
* - Mathutils.MidpointVecs --> vector.lerp(other, fac)
|
||||
* - Mathutils.AngleBetweenVecs --> vector.angle(other)
|
||||
* - Mathutils.ProjectVecs --> vector.project(other)
|
||||
@@ -55,6 +56,42 @@
|
||||
static char M_Mathutils_doc[] =
|
||||
"This module provides access to matrices, eulers, quaternions and vectors.";
|
||||
|
||||
/* helper functionm returns length of the 'value', -1 on error */
|
||||
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
|
||||
{
|
||||
PyObject *value_fast= NULL;
|
||||
|
||||
int i, size;
|
||||
|
||||
/* non list/tuple cases */
|
||||
if(!(value_fast=PySequence_Fast(value, error_prefix))) {
|
||||
/* PySequence_Fast sets the error */
|
||||
return -1;
|
||||
}
|
||||
|
||||
size= PySequence_Fast_GET_SIZE(value_fast);
|
||||
|
||||
if(size > array_max || size < array_min) {
|
||||
if (array_max == array_min) PyErr_Format(PyExc_ValueError, "%.200s: sequence size is %d, expected %d", error_prefix, size, array_max);
|
||||
else PyErr_Format(PyExc_ValueError, "%.200s: sequence size is %d, expected [%d - %d]", error_prefix, size, array_min, array_max);
|
||||
Py_DECREF(value_fast);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i= size;
|
||||
do {
|
||||
i--;
|
||||
if(((array[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i))) == -1.0) && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_ValueError, "%.200s: sequence index %d is not a float", error_prefix, i);
|
||||
Py_DECREF(value_fast);
|
||||
return -1;
|
||||
}
|
||||
} while(i);
|
||||
|
||||
Py_XDECREF(value_fast);
|
||||
return size;
|
||||
}
|
||||
|
||||
//-----------------------------METHODS----------------------------
|
||||
//-----------------quat_rotation (internal)-----------
|
||||
//This function multiplies a vector/point * quat or vice versa
|
||||
|
||||
Reference in New Issue
Block a user