Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-05-11 09:18:49 +0400
committerJoshua Leung <aligorith@gmail.com>2009-05-11 09:18:49 +0400
commit2ed242656ad8d65dd8e246728fff03ee968c44a4 (patch)
tree63f34dafa81e8b258177736d61cfdf0eade8549f
parent8e3356793a24994c1188aabfb57cb2feca20daf5 (diff)
2.5 - RNA Bugfix 2 (for Keyframing):
Now properties in nested structs should be able to be keyframed (i.e. AO in World, and SSS in Materials). Added an extra method to RNA for this to work.
-rw-r--r--source/blender/makesrna/intern/rna_access.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index fe6f4c13d9b..cfe1778db41 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -382,6 +382,30 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
return prop;
}
+/* Find the property which uses the given nested struct */
+PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna)
+{
+ CollectionPropertyIterator iter;
+ PropertyRNA *iterprop, *prop;
+ int i = 0;
+
+ iterprop= RNA_struct_iterator_property(ptr->type);
+ RNA_property_collection_begin(ptr, iterprop, &iter);
+ prop= NULL;
+
+ for(; iter.valid; RNA_property_collection_next(&iter), i++) {
+ /* This assumes that there can only be one user of this nested struct */
+ if (RNA_property_pointer_type(iter.ptr.data) == srna) {
+ prop= iter.ptr.data;
+ break;
+ }
+ }
+
+ RNA_property_collection_end(&iter);
+
+ return prop;
+}
+
const struct ListBase *RNA_struct_defined_properties(StructRNA *srna)
{
return &srna->cont.properties;
@@ -1718,18 +1742,27 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
return NULL;
if(!RNA_struct_is_ID(ptr->type)) {
- if(ptr->type && ptr->type->nested) {
- //StructRNA *nestedType= ptr->type->nested;
-
- printf("RNA - struct is nested \n");
- // TODO: how do we get the identifier of the way this is nested into the main?
+ if(ptr->type->path) {
+ /* if type has a path to some ID, use it */
+ ptrpath= ptr->type->path(ptr);
}
- else {
- if(ptr->type->path)
- ptrpath= ptr->type->path(ptr);
+ else if(ptr->type->nested) {
+ PointerRNA parentptr;
+ PropertyRNA *userprop;
+
+ /* find the property in the struct we're nested in that references this struct, and
+ * use its identifier as the first part of the path used...
+ */
+ RNA_pointer_create(ptr->id.data, ptr->type->nested, ptr->data, &parentptr);
+ userprop= RNA_struct_find_nested(&parentptr, ptr->type);
+
+ if(userprop)
+ ptrpath= BLI_strdup(RNA_property_identifier(userprop));
else
- return NULL;
+ return NULL; // can't do anything about this case yet...
}
+ else
+ return NULL;
}
propname= RNA_property_identifier(prop);