diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-08-25 21:06:36 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-08-25 21:06:36 +0400 |
commit | 706a4c22b54ede250fbdb2c2bd772c63cdbf7d09 (patch) | |
tree | e9398918b950b98e3fa17741d67fe7b94915f89f /source/blender/editors | |
parent | 7288bacad9bbe5e670de3454c9a64dee0c3d920c (diff) |
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]
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_ipo_utils.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/drivers.c | 6 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 10 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 18 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 10 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner.c | 4 |
10 files changed, 31 insertions, 31 deletions
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index ecf0bdbf285..26edf930f0b 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -147,7 +147,7 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) propname= (char *)RNA_property_ui_name(prop); /* Array Index - only if applicable */ - if (RNA_property_array_length(prop)) { + if (RNA_property_array_length(&ptr, prop)) { char c= RNA_property_array_item_char(prop, fcu->array_index); /* we need to write the index to a temp buffer (in py syntax) */ diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 849e2d2eede..e7b7d785d7b 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -157,7 +157,7 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla /* fill in current value for python */ if(type == DRIVER_TYPE_PYTHON) { PropertyType proptype= RNA_property_type(prop); - int array= RNA_property_array_length(prop); + int array= RNA_property_array_length(&ptr, prop); char *expression= fcu->driver->expression; int val, maxlen= sizeof(fcu->driver->expression); float fval; @@ -241,7 +241,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if (length) index= 0; else length= 1; @@ -303,7 +303,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index b62c69c7b38..dc73011549c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -503,19 +503,19 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_boolean_get_index(ptr, prop, index); else value= (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= (float)RNA_property_int_get_index(ptr, prop, index); else value= (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(prop)) + if (RNA_property_array_length(ptr, prop)) value= RNA_property_float_get_index(ptr, prop, index); else value= RNA_property_float_get(ptr, prop); @@ -1313,7 +1313,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; @@ -1396,7 +1396,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (path) { if (all) { - length= RNA_property_array_length(prop); + length= RNA_property_array_length(&ptr, prop); if(length) index= 0; else length= 1; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index d22fe763ad4..21f969467aa 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -925,7 +925,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } /* we should do at least one step */ @@ -1048,7 +1048,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet * RNA_id_pointer_create(cks->id, &id_ptr); if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(prop); + arraylen= RNA_property_array_length(&ptr, prop); } /* for each possible index, perform operation diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9bd6c2577ff..3c6e12905d6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -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; diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 2993a1aba15..784d820ea52 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -217,7 +217,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but) pup= uiPupMenuBegin(C, RNA_property_ui_name(but->rnaprop), 0); layout= uiPupMenuLayout(pup); - length= RNA_property_array_length(but->rnaprop); + length= RNA_property_array_length(&but->rnapoin, but->rnaprop); if(but->flag & UI_BUT_ANIMATED_KEY) { if(length) { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3b4471bd4b9..a52afcb1a92 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -760,7 +760,7 @@ void uiItemO(uiLayout *layout, char *name, int icon, char *opname) /* RNA property items */ -static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *prop, int index, int *r_w, int *r_h) +static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int *r_w, int *r_h) { PropertyType type; PropertySubType subtype; @@ -769,7 +769,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA /* arbitrary extended width by type */ type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0]) name= "non-empty text"; @@ -819,7 +819,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper /* retrieve info */ type= RNA_property_type(prop); - len= RNA_property_array_length(prop); + len= RNA_property_array_length(ptr, prop); /* set name and icon */ if(!name) @@ -846,7 +846,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper expand= (flag & UI_ITEM_R_EXPAND); /* get size */ - ui_item_rna_size(layout, name, icon, prop, index, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, index, &w, &h); /* array property */ if(index == RNA_NO_INDEX && len > 0) @@ -1132,7 +1132,7 @@ void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *p /* create button */ block= uiLayoutGetBlock(layout); - ui_item_rna_size(layout, name, icon, prop, 0, &w, &h); + ui_item_rna_size(layout, name, icon, ptr, prop, 0, &w, &h); but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h); ui_but_add_search(but, ptr, prop, searchptr, searchprop); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 56badedaded..4cfc44e56c8 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1258,7 +1258,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be * - for now, only split into groups if if group will have at least 5 items */ - layers= RNA_property_array_length(prop); + layers= RNA_property_array_length(ptr, prop); cols= (layers / 2) + (layers % 2); groups= ((cols / 2) < 5) ? (1) : (cols / 2); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 997ac8b78c6..5b44f6544d1 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -72,7 +72,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { uiBut *but=NULL; const char *propname= RNA_property_identifier(prop); - int arraylen= RNA_property_array_length(prop); + int arraylen= RNA_property_array_length(ptr, prop); switch(RNA_property_type(prop)) { case PROP_BOOLEAN: { @@ -81,7 +81,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind if(arraylen && index == -1) return NULL; - length= RNA_property_array_length(prop); + length= RNA_property_array_length(ptr, prop); if(length) value= RNA_property_boolean_get_index(ptr, prop, index); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 762ad82344b..d564573a543 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1084,7 +1084,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->flag |= TE_LAZY_CLOSED; } else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(prop); + tot= RNA_property_array_length(ptr, prop); if(!(tselem->flag & TSE_CLOSED)) { for(a=0; a<tot; a++) @@ -3721,7 +3721,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* item is part of an array, so must set the array_index */ *array_index= te->index; } - else if (RNA_property_array_length(prop)) { + else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ *flag |= KSP_FLAG_WHOLE_ARRAY; } |