Implemented dynamic and multidimensional array support in RNA.

Example code: http://www.pasteall.org/7332/c.
New API functions: http://www.pasteall.org/7330/c.

Maximum number of dimensions is currently limited to 3, but can be increased arbitrarily if needed.

What this means for ID property access:

* MeshFace.verts - dynamic array, size 3 or 4 depending on MFace.v4
* MeshTextureFace.uv - dynamic, 2-dimensional array, size depends on MFace.v4
* Object.matrix - 2-dimensional array

What this means for functions:

* more intuitive API possibility, for example:
  Mesh.add_vertices([(x, y, z), (x, y, z), ...])
  Mesh.add_faces([(1, 2, 3), (4, 5, 6), ...])

Python part is not complete yet, e.g. it is possible to:

MeshFace.verts = (1, 2, 3) # even if Mesh.verts is (1, 2, 3, 4) and vice-versa
MeshTextureFace.uv = [(0.0, 0.0)] * 4 # only if a corresponding MFace is a quad

but the following won't work:

MeshTextureFace.uv[3] = (0.0, 0.0) # setting uv[3] modifies MTFace.uv[1][0] instead of MTFace.uv[3]
This commit is contained in:
2009-08-25 17:06:36 +00:00
parent 7288bacad9
commit 706a4c22b5
24 changed files with 513 additions and 164 deletions

View File

@@ -1089,7 +1089,7 @@ void ui_get_but_vectorf(uiBut *but, float *vec)
vec[0]= vec[1]= vec[2]= 0.0f;
if(RNA_property_type(prop) == PROP_FLOAT) {
tot= RNA_property_array_length(prop);
tot= RNA_property_array_length(&but->rnapoin, prop);
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
@@ -1123,7 +1123,7 @@ void ui_set_but_vectorf(uiBut *but, float *vec)
prop= but->rnaprop;
if(RNA_property_type(prop) == PROP_FLOAT) {
tot= RNA_property_array_length(prop);
tot= RNA_property_array_length(&but->rnapoin, prop);
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
@@ -1181,19 +1181,19 @@ double ui_get_but_val(uiBut *but)
switch(RNA_property_type(prop)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_boolean_get(&but->rnapoin, prop);
break;
case PROP_INT:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_int_get(&but->rnapoin, prop);
break;
case PROP_FLOAT:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_float_get(&but->rnapoin, prop);
@@ -1245,19 +1245,19 @@ void ui_set_but_val(uiBut *but, double value)
if(RNA_property_editable(&but->rnapoin, prop)) {
switch(RNA_property_type(prop)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_boolean_set(&but->rnapoin, prop, value);
break;
case PROP_INT:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_int_set(&but->rnapoin, prop, value);
break;
case PROP_FLOAT:
if(RNA_property_array_length(prop))
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_float_set(&but->rnapoin, prop, value);
@@ -2414,7 +2414,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
but->rnapoin= *ptr;
but->rnaprop= prop;
if(RNA_property_array_length(but->rnaprop))
if(RNA_property_array_length(&but->rnapoin, but->rnaprop))
but->rnaindex= index;
else
but->rnaindex= 0;