Merged changes in the trunk up to revision 34201.

This commit is contained in:
2011-01-09 17:56:26 +00:00
32 changed files with 543 additions and 580 deletions

View File

@@ -129,7 +129,7 @@ option(WITH_PYTHON_INSTALL "Copy system python into the blender install fo
option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF) option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
mark_as_advanced(WITH_CXX_GUARDEDALLOC) mark_as_advanced(WITH_CXX_GUARDEDALLOC)
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BKE_assert()" OFF) option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
mark_as_advanced(WITH_ASSERT_ABORT) mark_as_advanced(WITH_ASSERT_ABORT)
if(APPLE) if(APPLE)

View File

@@ -851,7 +851,7 @@ Factory_filter(Factory* self, PyObject* args)
return NULL; return NULL;
} }
if(!PySequence_Length(py_b) || (py_a != NULL && !PySequence_Length(py_a))) if(!PySequence_Size(py_b) || (py_a != NULL && !PySequence_Size(py_a)))
{ {
PyErr_SetString(PyExc_ValueError, "The sequence has to contain at least one value!"); PyErr_SetString(PyExc_ValueError, "The sequence has to contain at least one value!");
return NULL; return NULL;
@@ -862,7 +862,7 @@ Factory_filter(Factory* self, PyObject* args)
float value; float value;
int result; int result;
for(int i = 0; i < PySequence_Length(py_b); i++) for(int i = 0; i < PySequence_Size(py_b); i++)
{ {
py_value = PySequence_GetItem(py_b, i); py_value = PySequence_GetItem(py_b, i);
result = PyArg_Parse(py_value, "f:filter", &value); result = PyArg_Parse(py_value, "f:filter", &value);
@@ -876,7 +876,7 @@ Factory_filter(Factory* self, PyObject* args)
if(py_a) if(py_a)
{ {
for(int i = 0; i < PySequence_Length(py_a); i++) for(int i = 0; i < PySequence_Size(py_a); i++)
{ {
py_value = PySequence_GetItem(py_a, i); py_value = PySequence_GetItem(py_a, i);
result = PyArg_Parse(py_value, "f:filter", &value); result = PyArg_Parse(py_value, "f:filter", &value);

View File

@@ -76,7 +76,10 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0):
file.write("%s{\n" % indent_str) file.write("%s{\n" % indent_str)
file.write("%s\tOFFSET %.6f %.6f %.6f\n" % (indent_str, loc.x * global_scale, loc.y * global_scale, loc.z * global_scale)) file.write("%s\tOFFSET %.6f %.6f %.6f\n" % (indent_str, loc.x * global_scale, loc.y * global_scale, loc.z * global_scale))
file.write("%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n" % indent_str) if bone.use_connect and bone.parent:
file.write("%s\tCHANNELS 3 Xrotation Yrotation Zrotation\n" % indent_str)
else:
file.write("%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n" % indent_str)
if my_children: if my_children:
# store the location for the children # store the location for the children
@@ -133,6 +136,7 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0):
"rest_arm_imat", # rest_arm_mat inverted "rest_arm_imat", # rest_arm_mat inverted
"rest_local_imat", # rest_local_mat inverted "rest_local_imat", # rest_local_mat inverted
"prev_euler", # last used euler to preserve euler compability in between keyframes "prev_euler", # last used euler to preserve euler compability in between keyframes
"connected", # is the bone connected to the parent bone?
) )
def __init__(self, bone_name): def __init__(self, bone_name):
@@ -153,6 +157,7 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0):
self.parent = None self.parent = None
self.prev_euler = Euler((0.0, 0.0, 0.0)) self.prev_euler = Euler((0.0, 0.0, 0.0))
self.connected = (self.rest_bone.use_connect and self.rest_bone.parent)
def update_posedata(self): def update_posedata(self):
self.pose_mat = self.pose_bone.matrix self.pose_mat = self.pose_bone.matrix
@@ -206,7 +211,9 @@ def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0):
# keep eulers compatible, no jumping on interpolation. # keep eulers compatible, no jumping on interpolation.
rot = mat_final.rotation_part().invert().to_euler('XYZ', dbone.prev_euler) rot = mat_final.rotation_part().invert().to_euler('XYZ', dbone.prev_euler)
file.write("%.6f %.6f %.6f " % (loc * global_scale)[:]) if not dbone.connected:
file.write("%.6f %.6f %.6f " % (loc * global_scale)[:])
file.write("%.6f %.6f %.6f " % (-degrees(rot[0]), -degrees(rot[1]), -degrees(rot[2]))) file.write("%.6f %.6f %.6f " % (-degrees(rot[0]), -degrees(rot[1]), -degrees(rot[2])))
dbone.prev_euler = rot dbone.prev_euler = rot

View File

@@ -612,11 +612,11 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
data = list( struct.unpack('<ffffffffffff', temp_data) ) data = list( struct.unpack('<ffffffffffff', temp_data) )
new_chunk.bytes_read += STRUCT_SIZE_4x3MAT new_chunk.bytes_read += STRUCT_SIZE_4x3MAT
contextMatrix_rot = mathutils.Matrix(\ contextMatrix_rot = mathutils.Matrix((data[:3] + [0], \
data[:3] + [0],\ data[3:6] + [0], \
data[3:6] + [0],\ data[6:9] + [0], \
data[6:9] + [0],\ data[9:] + [1], \
data[9:] + [1]) ))
elif (new_chunk.ID == MAT_MAP_FILEPATH): elif (new_chunk.ID == MAT_MAP_FILEPATH):
texture_name, read_str_len = read_string(file) texture_name, read_str_len = read_string(file)

File diff suppressed because it is too large Load Diff

View File

@@ -73,12 +73,11 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
me = obj.create_mesh(scene, True, 'PREVIEW') me = obj.create_mesh(scene, True, 'PREVIEW')
#Flip y and z #Flip y and z
mat_flip = mathutils.Matrix(\ mat_flip = mathutils.Matrix(((1.0, 0.0, 0.0, 0.0), \
[1.0, 0.0, 0.0, 0.0],\ (0.0, 0.0, 1.0, 0.0), \
[0.0, 0.0, 1.0, 0.0],\ (0.0, 1.0, 0.0, 0.0), \
[0.0, 1.0, 0.0, 0.0],\ (0.0, 0.0, 0.0, 1.0), \
[0.0, 0.0, 0.0, 1.0],\ ))
)
numverts = len(me.vertices) numverts = len(me.vertices)

View File

@@ -78,11 +78,7 @@ def pointInTri2D(v, v1, v2, v3):
nor = side1.cross(side2) nor = side1.cross(side2)
l1 = [side1[0], side1[1], side1[2]] mtx = Matrix((side1, side2, nor))
l2 = [side2[0], side2[1], side2[2]]
l3 = [nor[0], nor[1], nor[2]]
mtx = Matrix(l1, l2, l3)
# Zero area 2d tri, even tho we throw away zerop area faces # Zero area 2d tri, even tho we throw away zerop area faces
# the projection UV can result in a zero area UV. # the projection UV can result in a zero area UV.

View File

@@ -2452,7 +2452,7 @@ void DAG_id_tag_update(ID *id, short flag)
} }
} }
else { else {
BKE_assert(!"invalid flag for this 'idtype'"); BLI_assert(!"invalid flag for this 'idtype'");
} }
} }
} }

View File

@@ -552,7 +552,7 @@ static short key_pointer_size(const Key *key, const int mode, int *poinsize, int
break; break;
default: default:
BKE_assert(!"invalid 'key->from' ID type"); BLI_assert(!"invalid 'key->from' ID type");
return FALSE; return FALSE;
} }
@@ -641,7 +641,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
/* should never happen */ /* should never happen */
if(freek1) MEM_freeN(freek1); if(freek1) MEM_freeN(freek1);
if(freekref) MEM_freeN(freekref); if(freekref) MEM_freeN(freekref);
BKE_assert(!"invalid 'cp[1]'"); BLI_assert(!"invalid 'cp[1]'");
return; return;
} }
@@ -777,7 +777,7 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
/* should never happen */ /* should never happen */
if(freefrom) MEM_freeN(freefrom); if(freefrom) MEM_freeN(freefrom);
if(freereffrom) MEM_freeN(freereffrom); if(freereffrom) MEM_freeN(freereffrom);
BKE_assert(!"invalid 'cp[1]'"); BLI_assert(!"invalid 'cp[1]'");
return; return;
} }
@@ -944,7 +944,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
if(freek2) MEM_freeN(freek2); if(freek2) MEM_freeN(freek2);
if(freek3) MEM_freeN(freek3); if(freek3) MEM_freeN(freek3);
if(freek4) MEM_freeN(freek4); if(freek4) MEM_freeN(freek4);
BKE_assert(!"invalid 'cp[1]'"); BLI_assert(!"invalid 'cp[1]'");
return; return;
} }

View File

@@ -2562,7 +2562,7 @@ void object_handle_update(Scene *scene, Object *ob)
{ {
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' #if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
BKE_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
if(em) { if(em) {
makeDerivedMesh(scene, ob, em, scene->customdata_mask); /* was CD_MASK_BAREMESH */ makeDerivedMesh(scene, ob, em, scene->customdata_mask); /* was CD_MASK_BAREMESH */
BKE_mesh_end_editmesh(ob->data, em); BKE_mesh_end_editmesh(ob->data, em);

View File

@@ -181,7 +181,7 @@
#endif #endif
/* BKE_assert(), default only to print /* BLI_assert(), default only to print
* for aborting need to define WITH_ASSERT_ABORT * for aborting need to define WITH_ASSERT_ABORT
*/ */
#if !defined NDEBUG #if !defined NDEBUG
@@ -191,28 +191,28 @@
# define _dummy_abort() (void)0 # define _dummy_abort() (void)0
# endif # endif
# ifdef __GNUC__ /* just want to check if __func__ is available */ # ifdef __GNUC__ /* just want to check if __func__ is available */
# define BKE_assert(a) \ # define BLI_assert(a) \
do { \ do { \
if (0 == (a)) { \ if (0 == (a)) { \
fprintf(stderr, \ fprintf(stderr, \
"BKE_assert failed: %s, %s(), %d at \'%s\'\n", \ "BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
__FILE__, __func__, __LINE__, STRINGIFY(a)); \ __FILE__, __func__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \ _dummy_abort(); \
} \ } \
} while (0) } while (0)
# else # else
# define BKE_assert(a) \ # define BLI_assert(a) \
do { \ do { \
if (0 == (a)) { \ if (0 == (a)) { \
fprintf(stderr, \ fprintf(stderr, \
"BKE_assert failed: %s, %d at \'%s\'\n", \ "BLI_assert failed: %s, %d at \'%s\'\n", \
__FILE__, __LINE__, STRINGIFY(a)); \ __FILE__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \ _dummy_abort(); \
} \ } \
} while (0) } while (0)
# endif # endif
#else #else
# define BKE_assert(a) (void)0 # define BLI_assert(a) (void)0
#endif #endif
#endif // BLI_UTILDEFINES_H #endif // BLI_UTILDEFINES_H

View File

@@ -851,7 +851,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
/* sanity check */ /* sanity check */
if(w<=0 || h<=0 || w>2000 || h>2000) { if(w<=0 || h<=0 || w>2000 || h>2000) {
printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h); printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h);
BKE_assert(!"invalid icon size"); BLI_assert(!"invalid icon size");
return; return;
} }

View File

@@ -981,7 +981,7 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
dst_col[2]= src_col[2]>209?255:src_col[2]+46; dst_col[2]= src_col[2]>209?255:src_col[2]+46;
break; break;
default: default:
BKE_assert(!"invalid axis arg"); BLI_assert(!"invalid axis arg");
} }
} }

View File

@@ -3326,13 +3326,15 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
vec[1]=vec[2]=0.0; vec[1]=vec[2]=0.0;
mul_qt_v3(state->rot,vec); mul_qt_v3(state->rot,vec);
if(draw_as==PART_DRAW_AXIS) { if(draw_as==PART_DRAW_AXIS) {
cd[1]=cd[2]=cd[4]=cd[5]=0.0; if(cd) {
cd[0]=cd[3]=1.0; cd[1]=cd[2]=cd[4]=cd[5]=0.0;
cd[6]=cd[8]=cd[9]=cd[11]=0.0; cd[0]=cd[3]=1.0;
cd[7]=cd[10]=1.0; cd[6]=cd[8]=cd[9]=cd[11]=0.0;
cd[13]=cd[12]=cd[15]=cd[16]=0.0; cd[7]=cd[10]=1.0;
cd[14]=cd[17]=1.0; cd[13]=cd[12]=cd[15]=cd[16]=0.0;
pdd->cd+=18; cd[14]=cd[17]=1.0;
pdd->cd+=18;
}
copy_v3_v3(vec2,state->co); copy_v3_v3(vec2,state->co);
} }

View File

@@ -734,7 +734,7 @@ static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned c
col[2]= 220; col[2]= 220;
break; break;
default: default:
BKE_assert(!"invalid axis arg"); BLI_assert(!"invalid axis arg");
} }
} }

View File

@@ -3348,7 +3348,7 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee
IDProperty *iter; IDProperty *iter;
int i; int i;
BKE_assert(haystack->type == IDP_GROUP); BLI_assert(haystack->type == IDP_GROUP);
link.up= parent_link; link.up= parent_link;
link.name= NULL; link.name= NULL;
@@ -3408,7 +3408,7 @@ static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr)
IDProperty *haystack; IDProperty *haystack;
IDProperty *needle; IDProperty *needle;
BKE_assert(ptr->id.data != NULL); BLI_assert(ptr->id.data != NULL);
RNA_id_pointer_create(ptr->id.data, &id_ptr); RNA_id_pointer_create(ptr->id.data, &id_ptr);
haystack= RNA_struct_idprops(&id_ptr, FALSE); haystack= RNA_struct_idprops(&id_ptr, FALSE);

View File

@@ -261,7 +261,7 @@ static int idp_sequence_type(PyObject *seq)
PyObject *item; PyObject *item;
int type= IDP_INT; int type= IDP_INT;
int i, len = PySequence_Length(seq); int i, len = PySequence_Size(seq);
for (i=0; i < len; i++) { for (i=0; i < len; i++) {
item = PySequence_GetItem(seq, i); item = PySequence_GetItem(seq, i);
if (PyFloat_Check(item)) { if (PyFloat_Check(item)) {
@@ -331,7 +331,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
we assume IDP_INT unless we hit a float we assume IDP_INT unless we hit a float
number; then we assume it's */ number; then we assume it's */
val.array.len = PySequence_Length(ob); val.array.len = PySequence_Size(ob);
switch(val.array.type) { switch(val.array.type) {
case IDP_DOUBLE: case IDP_DOUBLE:

View File

@@ -207,7 +207,7 @@ static PyObject *Method_Buffer (PyObject *UNUSED(self), PyObject *args)
ndimensions= 1; ndimensions= 1;
dimensions[0]= PyLong_AsLong(length_ob); dimensions[0]= PyLong_AsLong(length_ob);
} else if (PySequence_Check(length_ob)) { } else if (PySequence_Check(length_ob)) {
ndimensions= PySequence_Length(length_ob); ndimensions= PySequence_Size(length_ob);
if (ndimensions > MAX_DIMENSIONS) { if (ndimensions > MAX_DIMENSIONS) {
PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is 256"); PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is 256");
return NULL; return NULL;
@@ -360,8 +360,8 @@ static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq)
return -1; return -1;
} }
if (PySequence_Length(seq)!=(end-begin)) { if (PySequence_Size(seq)!=(end-begin)) {
int seq_len = PySequence_Length(seq); int seq_len = PySequence_Size(seq);
char err_str[128]; char err_str[128];
sprintf(err_str, "size mismatch in assignment. Expected size: %d (size provided: %d)", seq_len, (end-begin)); sprintf(err_str, "size mismatch in assignment. Expected size: %d (size provided: %d)", seq_len, (end-begin));
PyErr_SetString(PyExc_TypeError, err_str); PyErr_SetString(PyExc_TypeError, err_str);

View File

@@ -31,7 +31,7 @@
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject *value);
/* matrix vector callbacks */ /* matrix vector callbacks */
int mathutils_matrix_vector_cb_index= -1; int mathutils_matrix_vector_cb_index= -1;
@@ -109,80 +109,42 @@ Mathutils_Callback mathutils_matrix_vector_cb = {
//create a new matrix type //create a new matrix type
static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
PyObject *argObject, *m, *s;
MatrixObject *mat;
int argSize, seqSize = 0, i, j;
float matrix[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 scalar;
if(kwds && PyDict_Size(kwds)) { if(kwds && PyDict_Size(kwds)) {
PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): takes no keyword args"); PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): takes no keyword args");
return NULL; return NULL;
} }
argSize = PyTuple_GET_SIZE(args); switch(PyTuple_GET_SIZE(args)) {
if(argSize > MATRIX_MAX_DIM) { //bad arg nums case 0:
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, type);
return NULL; case 1:
} else if (argSize == 0) { //return empty 4D matrix {
return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, type); PyObject *arg= PyTuple_GET_ITEM(args, 0);
}else if (argSize == 1){
//copy constructor for matrix objects
argObject = PyTuple_GET_ITEM(args, 0);
if(MatrixObject_Check(argObject)){
mat = (MatrixObject*)argObject;
if(!BaseMath_ReadCallback(mat))
return NULL;
memcpy(matrix, mat->contigPtr, sizeof(float) * mat->rowSize * mat->colSize); const unsigned short row_size= PySequence_Size(arg); /* -1 is an error, size checks will accunt for this */
argSize = mat->rowSize;
seqSize = mat->colSize; if(IN_RANGE_INCL(row_size, 2, 4)) {
} PyObject *item= PySequence_GetItem(arg, 0);
}else{ //2-4 arguments (all seqs? all same size?) const unsigned short col_size= PySequence_Size(item);
for(i =0; i < argSize; i++){ Py_XDECREF(item);
argObject = PyTuple_GET_ITEM(args, i);
if (PySequence_Check(argObject)) { //seq? if(IN_RANGE_INCL(col_size, 2, 4)) {
if(seqSize){ //0 at first /* sane row & col size, new matrix and assign as slice */
if(PySequence_Length(argObject) != seqSize){ //seq size not same PyObject *matrix= newMatrixObject(NULL, row_size, col_size, Py_NEW, type);
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); if(Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) {
return NULL; return matrix;
}
else { /* matrix ok, slice assignment not */
Py_DECREF(matrix);
} }
} }
seqSize = PySequence_Length(argObject);
}else{ //arg not a sequence
PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size");
return NULL;
}
}
//all is well... let's continue parsing
for (i = 0; i < argSize; i++){
m = PyTuple_GET_ITEM(args, i);
if (m == NULL) { // Failed to read sequence
PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments");
return NULL;
}
for (j = 0; j < seqSize; j++) {
s = PySequence_GetItem(m, j);
if (s == NULL) { // Failed to read sequence
PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments");
return NULL;
}
scalar= (float)PyFloat_AsDouble(s);
Py_DECREF(s);
if(scalar==-1 && PyErr_Occurred()) { // parsed item is not a number
PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size");
return NULL;
}
matrix[(seqSize*i)+j]= scalar;
} }
} }
} }
return newMatrixObject(matrix, argSize, seqSize, Py_NEW, type);
/* will overwrite error */
PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): expects no args or 2-4 numeric sequences");
return NULL;
} }
/*-----------------------CLASS-METHODS----------------------------*/ /*-----------------------CLASS-METHODS----------------------------*/
@@ -1554,7 +1516,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
} }
} }
else { else {
BKE_assert(!"internal error"); BLI_assert(!"internal error");
} }
PyErr_Format(PyExc_TypeError, "Matrix multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); PyErr_Format(PyExc_TypeError, "Matrix multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name);
@@ -1847,7 +1809,7 @@ self->matrix[1][1] = self->contigPtr[4] */
(i.e. it was allocated elsewhere by MEM_mallocN()) (i.e. it was allocated elsewhere by MEM_mallocN())
pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
(i.e. it must be created here with PyMEM_malloc())*/ (i.e. it must be created here with PyMEM_malloc())*/
PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type, PyTypeObject *base_type) PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type)
{ {
MatrixObject *self; MatrixObject *self;
int x, row, col; int x, row, col;

View File

@@ -49,7 +49,7 @@ be stored in py_data) or be a wrapper for data allocated through
blender (stored in blend_data). This is an either/or struct not both*/ blender (stored in blend_data). This is an either/or struct not both*/
/*prototypes*/ /*prototypes*/
PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type, PyTypeObject *base_type); PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type);
PyObject *newMatrixObject_cb(PyObject *user, int rowSize, int colSize, int cb_type, int cb_subtype); PyObject *newMatrixObject_cb(PyObject *user, int rowSize, int colSize, int cb_type, int cb_subtype);
extern int mathutils_matrix_vector_cb_index; extern int mathutils_matrix_vector_cb_index;

View File

@@ -684,7 +684,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
} }
} }
else { else {
BKE_assert(!"internal error"); BLI_assert(!"internal error");
} }
PyErr_Format(PyExc_TypeError, "Quaternion multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); PyErr_Format(PyExc_TypeError, "Quaternion multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name);

View File

@@ -844,7 +844,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end,
CLAMP(end, 0, self->size); CLAMP(end, 0, self->size);
begin = MIN2(begin,end); begin = MIN2(begin,end);
size = PySequence_Length(seq); size = PySequence_Size(seq);
if(size != (end - begin)){ if(size != (end - begin)){
PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: size mismatch in slice assignment"); PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: size mismatch in slice assignment");
return -1; return -1;
@@ -1129,7 +1129,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
} }
} }
else { else {
BKE_assert(!"internal error"); BLI_assert(!"internal error");
} }
PyErr_Format(PyExc_TypeError, "Vector multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); PyErr_Format(PyExc_TypeError, "Vector multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);

View File

@@ -269,7 +269,7 @@ void BPY_python_start( int argc, char **argv )
Py_DECREF(mod); Py_DECREF(mod);
} }
else { else {
BKE_assert(!"unable to load 'imp' module."); BLI_assert(!"unable to load 'imp' module.");
} }
} }
@@ -319,7 +319,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
PyObject *py_dict= NULL, *py_result= NULL; PyObject *py_dict= NULL, *py_result= NULL;
PyGILState_STATE gilstate; PyGILState_STATE gilstate;
BKE_assert(fn || text); BLI_assert(fn || text);
if (fn==NULL && text==NULL) { if (fn==NULL && text==NULL) {
return 0; return 0;

View File

@@ -552,7 +552,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, PyObject *def, int
return NULL; return NULL;
} }
seq_len= PySequence_Length(value); seq_len= PySequence_Size(value);
if(is_enum_flag) { if(is_enum_flag) {
if(seq_len > RNA_ENUM_BITFLAG_SIZE) { if(seq_len > RNA_ENUM_BITFLAG_SIZE) {

View File

@@ -75,7 +75,7 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
else pyname= "<UNKNOWN>"; else pyname= "<UNKNOWN>";
/* make a nice string error */ /* make a nice string error */
BKE_assert(idtype != NULL); BLI_assert(idtype != NULL);
PyErr_Format(PyExc_RuntimeError, "Writing to ID classes in this context is not allowed: %.200s, %.200s datablock, error setting %.200s.%.200s", id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname); PyErr_Format(PyExc_RuntimeError, "Writing to ID classes in this context is not allowed: %.200s, %.200s datablock, error setting %.200s.%.200s", id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname);
return TRUE; return TRUE;
@@ -1250,7 +1250,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
return -1; return -1;
} }
seq_len = PySequence_Length(value); seq_len = PySequence_Size(value);
for(i=0; i<seq_len; i++) { for(i=0; i<seq_len; i++) {
item= PySequence_GetItem(value, i); item= PySequence_GetItem(value, i);
@@ -1572,7 +1572,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
break; break;
} }
default: default:
BKE_assert(!"Invalid array type"); BLI_assert(!"Invalid array type");
PyErr_SetString(PyExc_TypeError, "not an array type"); PyErr_SetString(PyExc_TypeError, "not an array type");
Py_DECREF(tuple); Py_DECREF(tuple);
@@ -2779,7 +2779,7 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname )
break; break;
default: default:
/* should never happen */ /* should never happen */
BKE_assert(!"Invalid context type"); BLI_assert(!"Invalid context type");
PyErr_Format(PyExc_AttributeError, "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", newtype, name); PyErr_Format(PyExc_AttributeError, "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", newtype, name);
ret= NULL; ret= NULL;
@@ -3279,7 +3279,7 @@ static int foreach_parse_args(
return -1; return -1;
} }
*tot= PySequence_Length(*seq); // TODO - buffer may not be a sequence! array.array() is tho. *tot= PySequence_Size(*seq); // TODO - buffer may not be a sequence! array.array() is tho.
if(*tot>0) { if(*tot>0) {
foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed); foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed);
@@ -3400,7 +3400,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
break; break;
case PROP_RAW_UNSET: case PROP_RAW_UNSET:
/* should never happen */ /* should never happen */
BKE_assert(!"Invalid array type - set"); BLI_assert(!"Invalid array type - set");
break; break;
} }
@@ -3455,7 +3455,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
break; break;
case PROP_RAW_UNSET: case PROP_RAW_UNSET:
/* should never happen */ /* should never happen */
BKE_assert(!"Invalid array type - get"); BLI_assert(!"Invalid array type - get");
break; break;
} }
@@ -3813,7 +3813,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
void *retdata_single= NULL; void *retdata_single= NULL;
/* Should never happen but it does in rare cases */ /* Should never happen but it does in rare cases */
BKE_assert(self_ptr != NULL); BLI_assert(self_ptr != NULL);
if(self_ptr==NULL) { if(self_ptr==NULL) {
PyErr_SetString(PyExc_RuntimeError, "rna functions internal rna pointer is NULL, this is a bug. aborting"); PyErr_SetString(PyExc_RuntimeError, "rna functions internal rna pointer is NULL, this is a bug. aborting");

View File

@@ -57,7 +57,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
if (dim + 1 < totdim) { if (dim + 1 < totdim) {
/* check that a sequence contains dimsize[dim] items */ /* check that a sequence contains dimsize[dim] items */
for (i= 0; i < PySequence_Length(seq); i++) { for (i= 0; i < PySequence_Size(seq); i++) {
PyObject *item; PyObject *item;
int ok= 1; int ok= 1;
item= PySequence_GetItem(seq, i); item= PySequence_GetItem(seq, i);
@@ -72,7 +72,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
dimsize[2]=5 dimsize[2]=5
dim=0 */ dim=0 */
else if (PySequence_Length(item) != dimsize[dim + 1]) { else if (PySequence_Size(item) != dimsize[dim + 1]) {
/* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)dimsize[dim + 1]); */ /* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)dimsize[dim + 1]); */
PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)dimsize[dim + 1]); PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)dimsize[dim + 1]);
ok= 0; ok= 0;
@@ -89,7 +89,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
} }
else { else {
/* check that items are of correct type */ /* check that items are of correct type */
for (i= 0; i < PySequence_Length(seq); i++) { for (i= 0; i < PySequence_Size(seq); i++) {
PyObject *item= PySequence_GetItem(seq, i); PyObject *item= PySequence_GetItem(seq, i);
if (!check_item_type(item)) { if (!check_item_type(item)) {
@@ -114,7 +114,7 @@ static int count_items(PyObject *seq)
if (PySequence_Check(seq)) { if (PySequence_Check(seq)) {
int i; int i;
for (i= 0; i < PySequence_Length(seq); i++) { for (i= 0; i < PySequence_Size(seq); i++) {
PyObject *item= PySequence_GetItem(seq, i); PyObject *item= PySequence_GetItem(seq, i);
totitem += count_items(item); totitem += count_items(item);
Py_DECREF(item); Py_DECREF(item);
@@ -211,7 +211,7 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int
unsigned int i; unsigned int i;
int totdim= RNA_property_array_dimension(ptr, prop, NULL); int totdim= RNA_property_array_dimension(ptr, prop, NULL);
for (i= 0; i < PySequence_Length(seq); i++) { for (i= 0; i < PySequence_Size(seq); i++) {
PyObject *item= PySequence_GetItem(seq, i); PyObject *item= PySequence_GetItem(seq, i);
if (dim + 1 < totdim) { if (dim + 1 < totdim) {

View File

@@ -341,7 +341,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
} }
else { else {
BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name); BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name);
BKE_assert(!"invalid 'retval'"); BLI_assert(!"invalid 'retval'");
} }
WM_cursor_wait(0); WM_cursor_wait(0);

View File

@@ -80,7 +80,7 @@ static PyObject * getColor (PyFilter * self, void * closure)
static int setColor (PyFilter * self, PyObject * value, void * closure) static int setColor (PyFilter * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 3
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2))) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
@@ -107,7 +107,7 @@ static PyObject * getLimits (PyFilter * self, void * closure)
static int setLimits (PyFilter * self, PyObject * value, void * closure) static int setLimits (PyFilter * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{ {

View File

@@ -129,14 +129,14 @@ static int setMatrix (PyFilter * self, PyObject * value, void * closure)
ColorMatrix mat; ColorMatrix mat;
// check validity of parameter // check validity of parameter
bool valid = value != NULL && PySequence_Check(value) bool valid = value != NULL && PySequence_Check(value)
&& PySequence_Length(value) == 4; && PySequence_Size(value) == 4;
// check rows // check rows
for (int r = 0; valid && r < 4; ++r) for (int r = 0; valid && r < 4; ++r)
{ {
// get row object // get row object
PyObject * row = PySequence_Fast_GET_ITEM(value, r); PyObject * row = PySequence_Fast_GET_ITEM(value, r);
// check sequence // check sequence
valid = PySequence_Check(row) && PySequence_Length(row) == 5; valid = PySequence_Check(row) && PySequence_Size(row) == 5;
// check items // check items
for (int c = 0; valid && c < 5; ++c) for (int c = 0; valid && c < 5; ++c)
{ {
@@ -262,14 +262,14 @@ static int setLevels (PyFilter * self, PyObject * value, void * closure)
ColorLevel lev; ColorLevel lev;
// check validity of parameter // check validity of parameter
bool valid = value != NULL && PySequence_Check(value) bool valid = value != NULL && PySequence_Check(value)
&& PySequence_Length(value) == 4; && PySequence_Size(value) == 4;
// check rows // check rows
for (int r = 0; valid && r < 4; ++r) for (int r = 0; valid && r < 4; ++r)
{ {
// get row object // get row object
PyObject * row = PySequence_Fast_GET_ITEM(value, r); PyObject * row = PySequence_Fast_GET_ITEM(value, r);
// check sequence // check sequence
valid = PySequence_Check(row) && PySequence_Length(row) == 2; valid = PySequence_Check(row) && PySequence_Size(row) == 2;
// check items // check items
for (int c = 0; valid && c < 2; ++c) for (int c = 0; valid && c < 2; ++c)
{ {

View File

@@ -336,7 +336,7 @@ PyObject * getBackground (PyImage * self, void * closure)
static int setBackground (PyImage * self, PyObject * value, void * closure) static int setBackground (PyImage * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 4 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 4
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2))

View File

@@ -225,7 +225,7 @@ static PyObject * ImageViewport_getPosition (PyImage * self, void * closure)
static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure) static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{ {
@@ -253,7 +253,7 @@ PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure)
int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure) int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{ {

View File

@@ -147,7 +147,7 @@ PyObject * Video_getRange (PyImage * self, void * closure)
int Video_setRange (PyImage * self, PyObject * value, void * closure) int Video_setRange (PyImage * self, PyObject * value, void * closure)
{ {
// check validity of parameter // check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
|| !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1))) || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1)))
{ {