Cleanup: remove redundant strstr calls
Rely on BLI_str_quoted_substrN to detect if the prefix exists since this function exists early there is no need to check before calling.
This commit is contained in:
parent
838b6ec48a
commit
90dac47717
|
@ -349,7 +349,7 @@ int BKE_fcurves_filter(ListBase *dst, ListBase *src, const char *dataPrefix, con
|
|||
/* Search each F-Curve one by one. */
|
||||
for (fcu = src->first; fcu; fcu = fcu->next) {
|
||||
/* Check if quoted string matches the path. */
|
||||
if (fcu->rna_path == NULL || !strstr(fcu->rna_path, dataPrefix)) {
|
||||
if (fcu->rna_path == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,19 +207,14 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale)
|
|||
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 = SEQ_editing_get(scene, false);
|
||||
|
||||
/* get strip name, and check if this strip is selected */
|
||||
/* Only affect if F-Curve involves sequence_editor.sequences. */
|
||||
char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
|
||||
if (seq_name == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if this strip is selected. */
|
||||
Editing *ed = SEQ_editing_get(scene, false);
|
||||
Sequence *seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
|
||||
MEM_freeN(seq_name);
|
||||
|
||||
|
|
|
@ -1061,20 +1061,16 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
|
|||
|
||||
if (GS(owner_id->name) == ID_OB) {
|
||||
Object *ob = (Object *)owner_id;
|
||||
char *bone_name;
|
||||
|
||||
/* only consider if F-Curve involves pose.bones */
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) {
|
||||
|
||||
/* get bone-name, and check if this bone is selected */
|
||||
bPoseChannel *pchan = NULL;
|
||||
char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
|
||||
if (bone_name) {
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
|
||||
MEM_freeN(bone_name);
|
||||
}
|
||||
/* Only consider if F-Curve involves `pose.bones`. */
|
||||
if (fcu->rna_path && (bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["))) {
|
||||
/* Get bone-name, and check if this bone is selected. */
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
|
||||
MEM_freeN(bone_name);
|
||||
|
||||
/* check whether to continue or skip */
|
||||
if ((pchan) && (pchan->bone)) {
|
||||
if (pchan && pchan->bone) {
|
||||
/* If only visible channels,
|
||||
* skip if bone not visible unless user wants channels from hidden data too. */
|
||||
if (skip_hidden) {
|
||||
|
@ -1101,22 +1097,19 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
|
|||
}
|
||||
else if (GS(owner_id->name) == ID_SCE) {
|
||||
Scene *scene = (Scene *)owner_id;
|
||||
char *seq_name;
|
||||
|
||||
/* only consider if F-Curve involves sequence_editor.sequences */
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
|
||||
Editing *ed = SEQ_editing_get(scene, false);
|
||||
/* Only consider if F-Curve involves `sequence_editor.sequences`. */
|
||||
if (fcu->rna_path && (seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["))) {
|
||||
/* Get strip name, and check if this strip is selected. */
|
||||
Sequence *seq = NULL;
|
||||
|
||||
Editing *ed = SEQ_editing_get(scene, false);
|
||||
if (ed) {
|
||||
/* get strip name, and check if this strip is selected */
|
||||
char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
|
||||
if (seq_name) {
|
||||
seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
|
||||
MEM_freeN(seq_name);
|
||||
}
|
||||
seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
|
||||
}
|
||||
MEM_freeN(seq_name);
|
||||
|
||||
/* can only add this F-Curve if it is selected */
|
||||
/* Can only add this F-Curve if it is selected. */
|
||||
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
|
||||
if ((seq == NULL) || (seq->flag & SELECT) == 0) {
|
||||
return true;
|
||||
|
@ -1126,22 +1119,21 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
|
|||
}
|
||||
else if (GS(owner_id->name) == ID_NT) {
|
||||
bNodeTree *ntree = (bNodeTree *)owner_id;
|
||||
char *node_name;
|
||||
|
||||
/* check for selected nodes */
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
|
||||
/* Check for selected nodes. */
|
||||
if (fcu->rna_path && (node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["))) {
|
||||
bNode *node = NULL;
|
||||
/* Get strip name, and check if this strip is selected. */
|
||||
node = nodeFindNodebyName(ntree, node_name);
|
||||
MEM_freeN(node_name);
|
||||
|
||||
/* get strip name, and check if this strip is selected */
|
||||
char *node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
|
||||
if (node_name) {
|
||||
node = nodeFindNodebyName(ntree, node_name);
|
||||
MEM_freeN(node_name);
|
||||
}
|
||||
|
||||
/* can only add this F-Curve if it is selected */
|
||||
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
|
||||
if ((node) && (node->flag & NODE_SELECT) == 0) {
|
||||
return true;
|
||||
/* Can only add this F-Curve if it is selected. */
|
||||
if (node) {
|
||||
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
|
||||
if ((node->flag & NODE_SELECT) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2216,9 +2216,8 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
/* in pose mode, only delete the F-Curve if it belongs to a selected bone */
|
||||
if (ob->mode & OB_MODE_POSE) {
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) {
|
||||
|
||||
/* get bone-name, and check if this bone is selected */
|
||||
if (fcu->rna_path) {
|
||||
/* Get bone-name, and check if this bone is selected. */
|
||||
char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
|
||||
if (bone_name) {
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
|
||||
|
@ -2320,16 +2319,18 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
|
|||
* NOTE: This is only done in pose mode.
|
||||
* In object mode, we're dealing with the entire object.
|
||||
*/
|
||||
if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
|
||||
if (ob->mode & OB_MODE_POSE) {
|
||||
bPoseChannel *pchan = NULL;
|
||||
|
||||
/* get bone-name, and check if this bone is selected */
|
||||
/* Get bone-name, and check if this bone is selected. */
|
||||
char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
|
||||
if (bone_name) {
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
|
||||
MEM_freeN(bone_name);
|
||||
if (bone_name == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
|
||||
MEM_freeN(bone_name);
|
||||
|
||||
/* skip if bone is not selected */
|
||||
if ((pchan) && (pchan->bone)) {
|
||||
/* bones are only selected/editable if visible... */
|
||||
|
|
|
@ -1106,20 +1106,18 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
|
|||
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
|
||||
/* only items related to this object will be relevant */
|
||||
if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) {
|
||||
if (strstr(ksp->rna_path, "bones")) {
|
||||
char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
|
||||
char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
|
||||
if (boneName == NULL) {
|
||||
continue;
|
||||
}
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
|
||||
MEM_freeN(boneName);
|
||||
|
||||
if (boneName) {
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
|
||||
MEM_freeN(boneName);
|
||||
|
||||
if (pchan) {
|
||||
/* select if bone is visible and can be affected */
|
||||
if (PBONE_SELECTABLE(arm, pchan->bone)) {
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (pchan) {
|
||||
/* select if bone is visible and can be affected */
|
||||
if (PBONE_SELECTABLE(arm, pchan->bone)) {
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,31 +145,29 @@ static void autokeyframe_pose(
|
|||
if (act) {
|
||||
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
||||
/* only insert keyframes for this F-Curve if it affects the current bone */
|
||||
if (strstr(fcu->rna_path, "bones") == NULL) {
|
||||
char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones[");
|
||||
if (pchanName == NULL) {
|
||||
continue;
|
||||
}
|
||||
char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones[");
|
||||
|
||||
/* only if bone name matches too...
|
||||
* NOTE: this will do constraints too, but those are ok to do here too?
|
||||
*/
|
||||
if (pchanName) {
|
||||
if (STREQ(pchanName, pchan->name)) {
|
||||
insert_keyframe(bmain,
|
||||
reports,
|
||||
id,
|
||||
act,
|
||||
((fcu->grp) ? (fcu->grp->name) : (NULL)),
|
||||
fcu->rna_path,
|
||||
fcu->array_index,
|
||||
&anim_eval_context,
|
||||
ts->keyframe_type,
|
||||
&nla_cache,
|
||||
flag);
|
||||
}
|
||||
|
||||
MEM_freeN(pchanName);
|
||||
if (STREQ(pchanName, pchan->name)) {
|
||||
insert_keyframe(bmain,
|
||||
reports,
|
||||
id,
|
||||
act,
|
||||
((fcu->grp) ? (fcu->grp->name) : (NULL)),
|
||||
fcu->rna_path,
|
||||
fcu->array_index,
|
||||
&anim_eval_context,
|
||||
ts->keyframe_type,
|
||||
&nla_cache,
|
||||
flag);
|
||||
}
|
||||
|
||||
MEM_freeN(pchanName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue