[Bf-blender-cvs] [058a69974ab] master: Cleanup: split `animchan_sync_fcurve()` into smaller functions
Sybren A. Stüvel
noreply at git.blender.org
Mon Oct 12 17:00:23 CEST 2020
Commit: 058a69974abd602a788ebd972edca171ee8e100b
Author: Sybren A. Stüvel
Date: Mon Oct 12 16:56:49 2020 +0200
Branches: master
https://developer.blender.org/rB058a69974abd602a788ebd972edca171ee8e100b
Cleanup: split `animchan_sync_fcurve()` into smaller functions
Split `animchan_sync_fcurve()` into functions for handling Scenes and
Node Trees.
No functional changes.
===================================================================
M source/blender/editors/animation/anim_deps.c
===================================================================
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 831de3e7bc4..a9ab89c693d 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -199,6 +199,89 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
}
}
+static void animchan_sync_fcurve_scene(bAnimListElem *ale)
+{
+ ID *owner_id = ale->id;
+ BLI_assert(GS(owner_id->name) == ID_SCE);
+ Scene *scene = (Scene *)owner_id;
+ FCurve *fcu = (FCurve *)ale->data;
+
+ /* only affect if F-Curve involves sequence_editor.sequences */
+ if (!strstr(fcu->rna_path, "sequences_all")) {
+ return;
+ }
+
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ /* get strip name, and check if this strip is selected */
+ char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
+ Sequence *seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
+ if (seq_name) {
+ MEM_freeN(seq_name);
+ }
+
+ if (seq == NULL) {
+ return;
+ }
+
+ /* update selection status */
+ if (seq->flag & SELECT) {
+ fcu->flag |= FCURVE_SELECTED;
+ }
+ else {
+ fcu->flag &= ~FCURVE_SELECTED;
+ }
+}
+
+static void animchan_sync_fcurve_nodetree(bAnimListElem *ale, FCurve **active_fcurve)
+{
+ ID *owner_id = ale->id;
+ BLI_assert(GS(owner_id->name) == ID_NT);
+ bNodeTree *ntree = (bNodeTree *)owner_id;
+ FCurve *fcu = (FCurve *)ale->data;
+
+ /* check for selected nodes */
+ if (!strstr(fcu->rna_path, "nodes")) {
+ return;
+ }
+
+ /* get strip name, and check if this strip is selected */
+ char *node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
+ bNode *node = nodeFindNodebyName(ntree, node_name);
+ if (node_name) {
+ MEM_freeN(node_name);
+ }
+ if (node == NULL) {
+ return;
+ }
+
+ /* update selection status */
+ if (node->flag & NODE_SELECT) {
+ fcu->flag |= FCURVE_SELECTED;
+ }
+ else {
+ fcu->flag &= ~FCURVE_SELECTED;
+ }
+
+ /* update active status */
+ /* XXX: this may interfere with setting bones as active if both exist at once;
+ * then again, if that's the case, production setups aren't likely to be animating
+ * nodes while working with bones?
+ */
+ if (node->flag & NODE_ACTIVE) {
+ if (*active_fcurve == NULL) {
+ fcu->flag |= FCURVE_ACTIVE;
+ *active_fcurve = fcu;
+ }
+ else {
+ fcu->flag &= ~FCURVE_ACTIVE;
+ }
+ }
+ else {
+ fcu->flag &= ~FCURVE_ACTIVE;
+ }
+}
+
/* perform syncing updates for F-Curves */
static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
bAnimListElem *ale,
@@ -214,77 +297,15 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
return;
}
- if (GS(owner_id->name) == ID_SCE) {
- Scene *scene = (Scene *)owner_id;
-
- /* only affect if F-Curve involves sequence_editor.sequences */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- char *seq_name;
-
- /* get strip name, and check if this strip is selected */
- seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
- seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name) {
- MEM_freeN(seq_name);
- }
-
- /* update selection status */
- if (seq) {
- if (seq->flag & SELECT) {
- fcu->flag |= FCURVE_SELECTED;
- }
- else {
- fcu->flag &= ~FCURVE_SELECTED;
- }
- }
- }
- }
- else if (GS(owner_id->name) == ID_NT) {
- bNodeTree *ntree = (bNodeTree *)owner_id;
-
- /* check for selected nodes */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
- bNode *node;
- char *node_name;
-
- /* get strip name, and check if this strip is selected */
- node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
- node = nodeFindNodebyName(ntree, node_name);
- if (node_name) {
- MEM_freeN(node_name);
- }
-
- /* update selection/active status */
- if (node) {
- /* update selection status */
- if (node->flag & NODE_SELECT) {
- fcu->flag |= FCURVE_SELECTED;
- }
- else {
- fcu->flag &= ~FCURVE_SELECTED;
- }
-
- /* update active status */
- /* XXX: this may interfere with setting bones as active if both exist at once;
- * then again, if that's the case, production setups aren't likely to be animating
- * nodes while working with bones?
- */
- if (node->flag & NODE_ACTIVE) {
- if (*active_fcurve == NULL) {
- fcu->flag |= FCURVE_ACTIVE;
- *active_fcurve = fcu;
- }
- else {
- fcu->flag &= ~FCURVE_ACTIVE;
- }
- }
- else {
- fcu->flag &= ~FCURVE_ACTIVE;
- }
- }
- }
+ switch (GS(owner_id->name)) {
+ case ID_SCE:
+ animchan_sync_fcurve_scene(ale);
+ break;
+ case ID_NT:
+ animchan_sync_fcurve_nodetree(ale, active_fcurve);
+ break;
+ default:
+ break;
}
}
More information about the Bf-blender-cvs
mailing list