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:
authorBastien Montagne <mont29>2022-05-27 15:35:57 +0300
committerBastien Montagne <bastien@blender.org>2022-05-30 13:02:10 +0300
commit878a805ae8a1e541b2c227e7d51395a22ac68772 (patch)
tree771688d8f5d72d864e4fbd589a000ba3ae111109 /source/blender/blenkernel/intern/fcurve.c
parentfc3c589b18080640d483ed91c5be6efb945fc4c3 (diff)
Cleanup/simplify BKE_fcurve_find_by_rna_context_ui code.
From reading the code it looks like at some point the code was expecting the `tptr` PointerRNA to change during the loop? But currently it did not make any sense to have this complex looping and multi-checking of RNA path and animdata, since the RNA pointer (and therefore its `owner_id`) is never modified... NOTE: there could be much more cleanup done in that area, goal of this commit is mainly to simplify the logic by removing all the (seamingly) dead code. Differential Revision: https://developer.blender.org/D15026
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c99
1 files changed, 35 insertions, 64 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 34357c3e454..952d5df299c 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -351,8 +351,8 @@ FCurve *BKE_fcurve_find_by_rna(PointerRNA *ptr,
NULL, ptr, prop, rnaindex, r_adt, r_action, r_driven, r_special);
}
-FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
- PointerRNA *ptr,
+FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *UNUSED(C),
+ const PointerRNA *ptr,
PropertyRNA *prop,
int rnaindex,
AnimData **r_animdata,
@@ -361,7 +361,6 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
bool *r_special)
{
FCurve *fcu = NULL;
- PointerRNA tptr = *ptr;
*r_driven = false;
*r_special = false;
@@ -388,79 +387,51 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
}
/* There must be some RNA-pointer + property combo. */
- if (prop && tptr.owner_id && RNA_property_animateable(&tptr, prop)) {
- AnimData *adt = BKE_animdata_from_id(tptr.owner_id);
- int step = (
- /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
- C ? 2 : 1);
- char *path = NULL;
-
- if (!adt && C) {
- path = RNA_path_from_ID_to_property(&tptr, prop);
- adt = BKE_animdata_from_id(tptr.owner_id);
- step--;
- }
-
- /* Standard F-Curve - Animation (Action) or Drivers. */
- while (adt && step--) {
- if ((adt->action == NULL || adt->action->curves.first == NULL) &&
- (adt->drivers.first == NULL)) {
- continue;
- }
-
- /* XXX This function call can become a performance bottleneck. */
- if (step) {
- path = RNA_path_from_ID_to_property(&tptr, prop);
- }
- if (path == NULL) {
- continue;
- }
+ if (!prop || !ptr->owner_id || !RNA_property_animateable(ptr, prop)) {
+ return fcu;
+ }
- /* XXX: The logic here is duplicated with a function up above. */
- /* animation takes priority over drivers. */
- if (adt->action && adt->action->curves.first) {
- fcu = BKE_fcurve_find(&adt->action->curves, path, rnaindex);
+ AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
+ if (adt == NULL) {
+ return fcu;
+ }
- if (fcu && r_action) {
- *r_action = adt->action;
- }
- }
+ const bool has_action_fcurves = adt->action != NULL &&
+ !BLI_listbase_is_empty(&adt->action->curves);
+ const bool has_drivers = !BLI_listbase_is_empty(&adt->drivers);
- /* If not animated, check if driven. */
- if (!fcu && (adt->drivers.first)) {
- fcu = BKE_fcurve_find(&adt->drivers, path, rnaindex);
+ /* XXX This function call can become a performance bottleneck. */
+ char *path = RNA_path_from_ID_to_property(ptr, prop);
- if (fcu) {
- if (r_animdata) {
- *r_animdata = adt;
- }
- *r_driven = true;
- }
- }
+ /* Standard F-Curve - Animation (Action) or Drivers. */
+ /* Animation takes priority over drivers. */
+ /* XXX: The logic here is duplicated with a function up above. */
+ if (has_action_fcurves) {
+ fcu = BKE_fcurve_find(&adt->action->curves, path, rnaindex);
- if (fcu && r_action) {
- if (r_animdata) {
- *r_animdata = adt;
- }
+ if (fcu) {
+ if (r_action) {
*r_action = adt->action;
- break;
}
+ if (r_animdata) {
+ *r_animdata = adt;
+ }
+ }
+ }
- if (step) {
- char *tpath = path ? path : RNA_path_from_ID_to_property(&tptr, prop);
- if (tpath && tpath != path) {
- MEM_freeN(path);
- path = tpath;
- adt = BKE_animdata_from_id(tptr.owner_id);
- }
- else {
- adt = NULL;
- }
+ /* If not animated, check if driven. */
+ if (fcu == NULL && has_drivers) {
+ fcu = BKE_fcurve_find(&adt->drivers, path, rnaindex);
+
+ if (fcu) {
+ if (r_animdata) {
+ *r_animdata = adt;
}
+ *r_driven = true;
}
- MEM_SAFE_FREE(path);
}
+ MEM_SAFE_FREE(path);
return fcu;
}