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:
Diffstat (limited to 'source/blender/blenkernel/intern/armature_pose.cc')
-rw-r--r--source/blender/blenkernel/intern/armature_pose.cc56
1 files changed, 11 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc
index 2b2268c6302..a62a32d9633 100644
--- a/source/blender/blenkernel/intern/armature_pose.cc
+++ b/source/blender/blenkernel/intern/armature_pose.cc
@@ -23,8 +23,9 @@
* \ingroup bke
*/
+#include "BKE_action.hh"
#include "BKE_animsys.h"
-#include "BKE_armature.h"
+#include "BKE_armature.hh"
#include "BLI_function_ref.hh"
#include "BLI_set.hh"
@@ -36,14 +37,14 @@
#include "RNA_access.h"
+using namespace blender::bke;
+
namespace {
-using BoneNameSet = blender::Set<std::string>;
using ActionApplier =
blender::FunctionRef<void(PointerRNA *, bAction *, const AnimationEvalContext *)>;
/* Forward declarations. */
-BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose);
void pose_apply_disable_fcurves_for_unselected_bones(bAction *action,
const BoneNameSet &selected_bone_names);
void pose_apply_restore_fcurves(bAction *action);
@@ -102,7 +103,7 @@ void pose_apply(struct Object *ob,
}
const bArmature *armature = (bArmature *)ob->data;
- const BoneNameSet selected_bone_names = pose_apply_find_selected_bones(armature, pose);
+ const BoneNameSet selected_bone_names = BKE_armature_find_selected_bone_names(armature);
const bool limit_to_selected_bones = !selected_bone_names.is_empty();
if (limit_to_selected_bones) {
@@ -122,30 +123,6 @@ void pose_apply(struct Object *ob,
}
}
-BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose)
-{
- BoneNameSet selected_bone_names;
- bool all_bones_selected = true;
- bool no_bones_selected = true;
-
- LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
- const bool is_selected = PBONE_SELECTED(armature, pchan->bone);
- all_bones_selected &= is_selected;
- no_bones_selected &= !is_selected;
-
- if (is_selected) {
- /* Bone names are unique, so no need to check for duplicates. */
- selected_bone_names.add_new(pchan->name);
- }
- }
-
- /* If no bones are selected, act as if all are. */
- if (all_bones_selected || no_bones_selected) {
- return BoneNameSet(); /* An empty set means "ignore bone selection". */
- }
- return selected_bone_names;
-}
-
void pose_apply_restore_fcurves(bAction *action)
{
/* TODO(Sybren): Restore the FCurve flags, instead of just erasing the 'disabled' flag. */
@@ -157,24 +134,13 @@ void pose_apply_restore_fcurves(bAction *action)
void pose_apply_disable_fcurves_for_unselected_bones(bAction *action,
const BoneNameSet &selected_bone_names)
{
- LISTBASE_FOREACH (FCurve *, fcu, &action->curves) {
- if (!fcu->rna_path || !strstr(fcu->rna_path, "pose.bones[")) {
- continue;
- }
-
- /* 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) {
- continue;
- }
- const bool is_selected = selected_bone_names.contains(bone_name);
- MEM_freeN(bone_name);
- if (is_selected) {
- continue;
+ auto disable_unselected_fcurve = [&](FCurve *fcu, const char *bone_name) {
+ const bool is_bone_selected = selected_bone_names.contains(bone_name);
+ if (!is_bone_selected) {
+ fcu->flag |= FCURVE_DISABLED;
}
-
- fcu->flag |= FCURVE_DISABLED;
- }
+ };
+ BKE_action_find_fcurves_with_bones(action, disable_unselected_fcurve);
}
} // namespace