forked from bartvdbraak/blender
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.
This commit is contained in:
parent
8e3356793a
commit
2ed242656a
@ -382,6 +382,30 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
|
|||||||
return prop;
|
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)
|
const struct ListBase *RNA_struct_defined_properties(StructRNA *srna)
|
||||||
{
|
{
|
||||||
return &srna->cont.properties;
|
return &srna->cont.properties;
|
||||||
@ -1718,19 +1742,28 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if(!RNA_struct_is_ID(ptr->type)) {
|
if(!RNA_struct_is_ID(ptr->type)) {
|
||||||
if(ptr->type && ptr->type->nested) {
|
if(ptr->type->path) {
|
||||||
//StructRNA *nestedType= ptr->type->nested;
|
/* if type has a path to some ID, use it */
|
||||||
|
|
||||||
printf("RNA - struct is nested \n");
|
|
||||||
// TODO: how do we get the identifier of the way this is nested into the main?
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(ptr->type->path)
|
|
||||||
ptrpath= ptr->type->path(ptr);
|
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; // can't do anything about this case yet...
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
propname= RNA_property_identifier(prop);
|
propname= RNA_property_identifier(prop);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user