Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fcurve.c
| Context not available. | |||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_context.h" | |||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| Context not available. | |||||
| FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, bool *r_driven) | FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, bool *r_driven) | ||||
| { | { | ||||
| return rna_get_fcurve_context_ui(NULL, ptr, prop, rnaindex, action, r_driven); | |||||
| } | |||||
| FCurve *rna_get_fcurve_context_ui(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, | |||||
| bAction **action, bool *r_driven) | |||||
| { | |||||
| FCurve *fcu = NULL; | FCurve *fcu = NULL; | ||||
| PointerRNA tptr = *ptr; | |||||
| *r_driven = false; | *r_driven = false; | ||||
| /* there must be some RNA-pointer + property combon */ | /* there must be some RNA-pointer + property combon */ | ||||
| if (prop && tptr.id.data && RNA_property_animateable(&tptr, prop)) { | if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { | ||||
| AnimData *adt = BKE_animdata_from_id(tptr.id.data); | AnimData *adt = BKE_animdata_from_id(ptr->id.data); | ||||
| int step = C ? 2 : 1; /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */ | char *path; | ||||
| char *path = NULL; | |||||
| if (!adt && C) { | if (adt) { | ||||
| path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL); | |||||
| adt = BKE_animdata_from_id(tptr.id.data); | |||||
| step--; | |||||
| } | |||||
| while (adt && step--) { | |||||
| if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { | if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { | ||||
| /* XXX this function call can become a performance bottleneck */ | /* XXX this function call can become a performance bottleneck */ | ||||
| if (step) { | path = RNA_path_from_ID_to_property(ptr, prop); | ||||
| path = RNA_path_from_ID_to_property(&tptr, prop); | |||||
| } | |||||
| if (path) { | if (path) { | ||||
| /* animation takes priority over drivers */ | /* animation takes priority over drivers */ | ||||
| Context not available. | |||||
| *r_driven = true; | *r_driven = true; | ||||
| } | } | ||||
| if (fcu && action) { | if (fcu && action) | ||||
| *action = adt->action; | *action = adt->action; | ||||
| break; | |||||
| } | MEM_freeN(path); | ||||
| else if (step) { | |||||
| char *tpath = BKE_animdata_driver_path_hack(C, &tptr, prop, path); | |||||
| if (tpath && tpath != path) { | |||||
| MEM_freeN(path); | |||||
| path = tpath; | |||||
| adt = BKE_animdata_from_id(tptr.id.data); | |||||
| } | |||||
| else { | |||||
| adt = NULL; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| MEM_SAFE_FREE(path); | |||||
| } | } | ||||
| return fcu; | return fcu; | ||||
| Context not available. | |||||