diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-26 23:38:52 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-26 23:38:52 +0300 |
commit | 82cf2aebba1c340c1c4fffde1e89fc80a4591fea (patch) | |
tree | 18d58c3ce61401b4fcd077f902e06235cab737be /source/blender/blenloader | |
parent | 254fc41b56e8c4f828e9721a045c8c5108044d0a (diff) |
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 28 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 8 |
2 files changed, 26 insertions, 10 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2ef315d6841..9de56801dea 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1345,11 +1345,12 @@ static void test_pointer_array(FileData *fd, void **mat) /* ************ READ ID Properties *************** */ -void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, void *fd); -void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, void *fd); +void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd); +void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd); -static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, void *fd) +static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd) { + IDProperty **array; int i; /*since we didn't save the extra buffer, set totallen to len.*/ @@ -1357,26 +1358,33 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, void *fd) prop->data.pointer = newdataadr(fd, prop->data.pointer); if (switch_endian) { - if (prop->subtype != IDP_DOUBLE) { + if(prop->subtype == IDP_GROUP) { + test_pointer_array(fd, prop->data.pointer); + array= prop->data.pointer; + + for(i=0; i<prop->len; i++) + IDP_DirectLinkProperty(array[i], switch_endian, fd); + } + else if(prop->subtype == IDP_DOUBLE) { for (i=0; i<prop->len; i++) { - SWITCH_INT(((int*)prop->data.pointer)[i]); + SWITCH_LONGINT(((double*)prop->data.pointer)[i]); } } else { for (i=0; i<prop->len; i++) { - SWITCH_LONGINT(((double*)prop->data.pointer)[i]); + SWITCH_INT(((int*)prop->data.pointer)[i]); } } } } -static void IDP_DirectLinkString(IDProperty *prop, int switch_endian, void *fd) +static void IDP_DirectLinkString(IDProperty *prop, int switch_endian, FileData *fd) { /*since we didn't save the extra string buffer, set totallen to len.*/ prop->totallen = prop->len; prop->data.pointer = newdataadr(fd, prop->data.pointer); } -static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, void *fd) +static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *fd) { ListBase *lb = &prop->data.group; IDProperty *loop; @@ -1389,7 +1397,7 @@ static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, void *fd) } } -void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, void *fd) +void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd) { switch (prop->type) { case IDP_GROUP: @@ -1423,7 +1431,7 @@ void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, void *fd) } /*stub function*/ -void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, void *fd) +void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd) { } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 33f33c79e31..7c7325ab8fa 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -390,6 +390,14 @@ static void IDP_WriteArray(IDProperty *prop, void *wd) /*REMEMBER to set totalen to len in the linking code!!*/ if (prop->data.pointer) { writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer); + + if(prop->type == IDP_GROUP) { + IDProperty **array= prop->data.pointer; + int a; + + for(a=0; a<prop->len; a++) + IDP_WriteProperty(array[a], wd); + } } } |