2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edarmature
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstring>
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2025-05-16 14:45:46 +02:00
|
|
|
#include "DNA_action_types.h"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2025-02-11 16:59:42 +01:00
|
|
|
#include "BLI_listbase.h"
|
2025-05-16 14:45:46 +02:00
|
|
|
#include "BLI_map.hh"
|
2025-01-26 20:08:00 +01:00
|
|
|
#include "BLI_string.h"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2024-09-10 14:55:47 +02:00
|
|
|
#include "BKE_action.hh"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_armature.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
#include "BKE_constraint.h"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2024-01-23 15:18:09 -05:00
|
|
|
#include "BKE_layer.hh"
|
2023-11-14 09:30:40 +01:00
|
|
|
#include "BKE_modifier.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2024-02-10 18:34:29 +01:00
|
|
|
#include "BKE_report.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2017-06-08 10:14:53 +02:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_define.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_armature.hh"
|
|
|
|
|
#include "ED_keyframing.hh"
|
|
|
|
|
#include "ED_mesh.hh"
|
|
|
|
|
#include "ED_object.hh"
|
2024-03-26 21:51:09 -04:00
|
|
|
#include "ED_object_vgroup.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_outliner.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_select_utils.hh"
|
|
|
|
|
#include "ED_view3d.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2025-05-16 14:45:46 +02:00
|
|
|
#include "ANIM_armature.hh"
|
2023-09-18 16:36:20 +02:00
|
|
|
#include "ANIM_bonecolor.hh"
|
2024-05-02 12:00:37 +02:00
|
|
|
#include "ANIM_keyingsets.hh"
|
Anim: replace Bone Groups & Armature Layers with Bone Collections
Armature layers (the 32 little dots) and bone groups are replaced with
Bone Collections:
- Bone collections are stored on the armature, and have a name that is
unique within that armature.
- An armature can have an arbitrary number of bone collections (instead
of the fixed 32 layers).
- Bones can be assigned to zero or more bone collections.
- Bone collections have a visibility setting, just like objects in scene
collections.
- When a bone is in at least one collection, and all its collections in
are hidden, the bone is hidden. In other cases (in any visible
collection, or in no collection at all), the bone visibility is
determined by its own 'hidden' flag.
- For now, bone collections cannot be nested; they are a flat list just
like bone groups were. Nestability of bone collections is intended to
be implemented in a later 4.x release.
- Since bone collections are defined on the armature, they can be used
from both pose mode and edit mode.
Versioning converts bone groups and armature layers to new bone
collections. Layers that do not contain any bones are skipped. The old
data structures remain in DNA and are unaltered, for limited forward
compatibility. That way at least a save with Blender 4.0 will not
immediately erase the bone group and armature layers and their bone
assignments.
Shortcuts:
- M/Shift+M in pose/edit mode: move to collection (M) and add to
collection (shift+M). This works similar to the M/Shift+M menus for
objects & scene collections.
- Ctrl+G in pose mode shows a port of the old 'bone groups' menu. This
is likely to be removed in the near future, as the functionality
overlaps with the M/Shift+M menus.
This is the first commit of a series; the bone collections feature will
be improved before the Blender 4.0 release. See #108941 for more info.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 12:15:54 +02:00
|
|
|
|
2024-01-24 11:32:26 -05:00
|
|
|
#include "armature_intern.hh"
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
using blender::Span;
|
|
|
|
|
using blender::Vector;
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* ***************** Pose Select Utilities ********************* */
|
|
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: SEL_TOGGLE is assumed to have already been handled! */
|
2014-08-01 02:03:09 +10:00
|
|
|
static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode)
|
|
|
|
|
{
|
2014-07-29 15:02:28 +02:00
|
|
|
/* select pchan only if selectable, but deselect works always */
|
|
|
|
|
switch (select_mode) {
|
|
|
|
|
case SEL_SELECT:
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!(pchan->bone->flag & BONE_UNSELECTABLE)) {
|
2014-07-29 15:02:28 +02:00
|
|
|
pchan->bone->flag |= BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2014-07-29 15:02:28 +02:00
|
|
|
break;
|
|
|
|
|
case SEL_DESELECT:
|
|
|
|
|
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
break;
|
|
|
|
|
case SEL_INVERT:
|
|
|
|
|
if (pchan->bone->flag & BONE_SELECTED) {
|
|
|
|
|
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
}
|
|
|
|
|
else if (!(pchan->bone->flag & BONE_UNSELECTABLE)) {
|
|
|
|
|
pchan->bone->flag |= BONE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-28 16:17:37 +10:00
|
|
|
void ED_pose_bone_select_tag_update(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_ARMATURE);
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2018-08-28 16:17:37 +10:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, ob);
|
|
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, ob);
|
|
|
|
|
|
|
|
|
|
if (arm->flag & ARM_HAS_VIZ_DEPS) {
|
|
|
|
|
/* mask modifier ('armature' mode), etc. */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2018-08-28 16:17:37 +10:00
|
|
|
}
|
|
|
|
|
|
2019-01-22 20:24:33 +01:00
|
|
|
DEG_id_tag_update(&arm->id, ID_RECALC_SELECT);
|
2018-08-28 16:17:37 +10:00
|
|
|
}
|
|
|
|
|
|
2023-05-05 17:46:05 +02:00
|
|
|
void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select, bool change_active)
|
2013-10-17 14:19:03 +00:00
|
|
|
{
|
|
|
|
|
bArmature *arm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-17 14:19:03 +00:00
|
|
|
/* sanity checks */
|
|
|
|
|
/* XXX: actually, we can probably still get away with no object - at most we have no updates */
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ELEM(nullptr, ob, ob->pose, pchan, pchan->bone)) {
|
2013-10-17 14:19:03 +00:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
arm = static_cast<bArmature *>(ob->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-17 14:19:03 +00:00
|
|
|
/* can only change selection state if bone can be modified */
|
|
|
|
|
if (PBONE_SELECTABLE(arm, pchan->bone)) {
|
2013-10-18 14:15:08 +00:00
|
|
|
/* change selection state - activate too if selected */
|
|
|
|
|
if (select) {
|
2013-10-17 14:19:03 +00:00
|
|
|
pchan->bone->flag |= BONE_SELECTED;
|
2023-05-05 17:46:05 +02:00
|
|
|
if (change_active) {
|
|
|
|
|
arm->act_bone = pchan->bone;
|
|
|
|
|
}
|
2013-10-18 14:15:08 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-10-17 14:19:03 +00:00
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
2023-05-05 17:46:05 +02:00
|
|
|
if (change_active) {
|
2023-07-05 20:03:41 +02:00
|
|
|
arm->act_bone = nullptr;
|
2023-05-05 17:46:05 +02:00
|
|
|
}
|
2013-10-18 14:15:08 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-17 14:19:03 +00:00
|
|
|
/* TODO: select and activate corresponding vgroup? */
|
2018-08-28 16:17:37 +10:00
|
|
|
ED_pose_bone_select_tag_update(ob);
|
2013-10-17 14:19:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
bool ED_armature_pose_select_pick_bone(const Scene *scene,
|
2022-09-14 21:30:20 +02:00
|
|
|
ViewLayer *view_layer,
|
2021-04-08 17:21:01 +02:00
|
|
|
View3D *v3d,
|
|
|
|
|
Object *ob,
|
|
|
|
|
Bone *bone,
|
2025-05-08 13:50:14 +10:00
|
|
|
const SelectPick_Params ¶ms)
|
2021-04-08 17:21:01 +02:00
|
|
|
{
|
2022-03-15 21:03:04 +11:00
|
|
|
bool found = false;
|
|
|
|
|
bool changed = false;
|
2021-04-08 17:21:01 +02:00
|
|
|
|
2024-04-04 10:55:19 +11:00
|
|
|
if (ob->pose) {
|
2022-03-15 21:03:04 +11:00
|
|
|
if (bone && ((bone->flag & BONE_UNSELECTABLE) == 0)) {
|
|
|
|
|
found = true;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 13:50:14 +10:00
|
|
|
if (params.sel_op == SEL_OP_SET) {
|
|
|
|
|
if ((found && params.select_passthrough) && (bone->flag & BONE_SELECTED)) {
|
2022-03-17 14:37:20 +11:00
|
|
|
found = false;
|
|
|
|
|
}
|
2025-05-08 13:50:14 +10:00
|
|
|
else if (found || params.deselect_all) {
|
2022-03-17 14:37:20 +11:00
|
|
|
/* Deselect everything. */
|
2025-04-26 11:17:13 +00:00
|
|
|
/* Don't use #BKE_object_pose_base_array_get_unique
|
2022-03-17 14:37:20 +11:00
|
|
|
* because we may be selecting from object mode. */
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_VISIBLE_BASE_BEGIN (scene, view_layer, v3d, base_iter) {
|
2022-03-17 14:37:20 +11:00
|
|
|
Object *ob_iter = base_iter->object;
|
|
|
|
|
if ((ob_iter->type == OB_ARMATURE) && (ob_iter->mode & OB_MODE_POSE)) {
|
|
|
|
|
if (ED_pose_deselect_all(ob_iter, SEL_DESELECT, true)) {
|
|
|
|
|
ED_pose_bone_select_tag_update(ob_iter);
|
|
|
|
|
}
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-17 14:37:20 +11:00
|
|
|
FOREACH_VISIBLE_BASE_END;
|
|
|
|
|
changed = true;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
|
|
|
|
|
if (found) {
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *ob_act = BKE_view_layer_active_object_get(view_layer);
|
2023-07-05 20:03:41 +02:00
|
|
|
BLI_assert(BKE_view_layer_edit_object_get(view_layer) == nullptr);
|
2022-03-15 21:03:04 +11:00
|
|
|
|
|
|
|
|
/* If the bone cannot be affected, don't do anything. */
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2022-03-15 21:03:04 +11:00
|
|
|
|
|
|
|
|
/* Since we do unified select, we don't shift+select a bone if the
|
|
|
|
|
* armature object was not active yet.
|
2023-02-09 11:30:25 +11:00
|
|
|
* NOTE(@ideasman42): special exception for armature mode so we can do multi-select
|
2022-03-15 21:03:04 +11:00
|
|
|
* we could check for multi-select explicitly but think its fine to
|
|
|
|
|
* always give predictable behavior in weight paint mode. */
|
2023-07-05 20:03:41 +02:00
|
|
|
if ((ob_act == nullptr) || ((ob_act != ob) && (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) == 0))
|
|
|
|
|
{
|
2022-03-15 21:03:04 +11:00
|
|
|
/* When we are entering into posemode via toggle-select,
|
|
|
|
|
* from another active object - always select the bone. */
|
2025-05-08 13:50:14 +10:00
|
|
|
if (params.sel_op == SEL_OP_SET) {
|
2022-03-15 21:03:04 +11:00
|
|
|
/* Re-select the bone again later in this function. */
|
|
|
|
|
bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
}
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
|
2025-05-08 13:50:14 +10:00
|
|
|
switch (params.sel_op) {
|
2022-03-15 21:03:04 +11:00
|
|
|
case SEL_OP_ADD: {
|
|
|
|
|
bone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
arm->act_bone = bone;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SEL_OP_SUB: {
|
|
|
|
|
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SEL_OP_XOR: {
|
|
|
|
|
if (bone->flag & BONE_SELECTED) {
|
|
|
|
|
/* If not active, we make it active. */
|
|
|
|
|
if (bone != arm->act_bone) {
|
|
|
|
|
arm->act_bone = bone;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
}
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2022-03-15 21:03:04 +11:00
|
|
|
bone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
arm->act_bone = bone;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
break;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
case SEL_OP_SET: {
|
2021-04-08 17:21:01 +02:00
|
|
|
bone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
arm->act_bone = bone;
|
2022-03-15 21:03:04 +11:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SEL_OP_AND: {
|
|
|
|
|
BLI_assert_unreachable(); /* Doesn't make sense for picking. */
|
|
|
|
|
break;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 21:03:04 +11:00
|
|
|
if (ob_act) {
|
2023-09-03 21:35:03 +10:00
|
|
|
/* In weight-paint we select the associated vertex group too. */
|
2022-03-15 21:03:04 +11:00
|
|
|
if (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) {
|
|
|
|
|
if (bone == arm->act_bone) {
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::vgroup_select_by_name(ob_act, bone->name);
|
2022-03-15 21:03:04 +11:00
|
|
|
DEG_id_tag_update(&ob_act->id, ID_RECALC_GEOMETRY);
|
|
|
|
|
}
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
/* If there are some dependencies for visualizing armature state
|
|
|
|
|
* (e.g. Mask Modifier in 'Armature' mode), force update.
|
2021-04-08 17:21:01 +02:00
|
|
|
*/
|
2022-03-15 21:03:04 +11:00
|
|
|
else if (arm->flag & ARM_HAS_VIZ_DEPS) {
|
|
|
|
|
/* NOTE: ob not ob_act here is intentional - it's the source of the
|
2023-02-12 14:37:16 +11:00
|
|
|
* bones being selected [#37247].
|
2022-03-15 21:03:04 +11:00
|
|
|
*/
|
|
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-19 15:54:08 +01:00
|
|
|
/* Tag armature for copy-on-evaluation update (since act_bone is in armature not object). */
|
|
|
|
|
DEG_id_tag_update(&arm->id, ID_RECALC_SYNC_TO_EVAL);
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
|
2022-03-15 21:03:04 +11:00
|
|
|
changed = true;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
2022-03-15 21:03:04 +11:00
|
|
|
|
|
|
|
|
return changed || found;
|
2021-04-08 17:21:01 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 21:30:20 +02:00
|
|
|
bool ED_armature_pose_select_pick_with_buffer(const Scene *scene,
|
|
|
|
|
ViewLayer *view_layer,
|
2018-11-25 09:50:34 -02:00
|
|
|
View3D *v3d,
|
|
|
|
|
Base *base,
|
2023-11-30 21:27:15 +01:00
|
|
|
const GPUSelectResult *hit_results,
|
|
|
|
|
const int hits,
|
2025-05-08 13:50:14 +10:00
|
|
|
const SelectPick_Params ¶ms,
|
2017-03-02 02:14:02 +11:00
|
|
|
bool do_nearest)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
Bone *nearBone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!ob || !ob->pose) {
|
2023-07-22 11:36:59 +10:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/* Callers happen to already get the active base */
|
2023-07-05 20:03:41 +02:00
|
|
|
Base *base_dummy = nullptr;
|
2020-04-03 15:45:57 +11:00
|
|
|
nearBone = ED_armature_pick_bone_from_selectbuffer(
|
2024-01-24 18:18:14 +01:00
|
|
|
{base}, hit_results, hits, true, do_nearest, &base_dummy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-14 21:30:20 +02:00
|
|
|
return ED_armature_pose_select_pick_bone(scene, view_layer, v3d, ob, nearBone, params);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
void ED_armature_pose_select_in_wpaint_mode(const Scene *scene,
|
2022-09-14 21:30:20 +02:00
|
|
|
ViewLayer *view_layer,
|
|
|
|
|
Base *base_select)
|
2019-07-18 14:18:43 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(base_select && (base_select->object->type == OB_ARMATURE));
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *ob_active = BKE_view_layer_active_object_get(view_layer);
|
2020-09-03 14:59:34 +02:00
|
|
|
BLI_assert(ob_active && (ob_active->mode & OB_MODE_ALL_WEIGHT_PAINT));
|
|
|
|
|
|
2024-07-29 10:37:29 +02:00
|
|
|
VirtualModifierData virtual_modifier_data;
|
|
|
|
|
ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob_active, &virtual_modifier_data);
|
|
|
|
|
for (; md; md = md->next) {
|
|
|
|
|
if (md->type == eModifierType_Armature) {
|
2025-03-17 19:49:45 +01:00
|
|
|
ArmatureModifierData *amd = reinterpret_cast<ArmatureModifierData *>(md);
|
2024-07-29 10:37:29 +02:00
|
|
|
Object *ob_arm = amd->object;
|
|
|
|
|
if (ob_arm != nullptr) {
|
|
|
|
|
Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm);
|
|
|
|
|
if ((base_arm != nullptr) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED))
|
|
|
|
|
{
|
|
|
|
|
blender::ed::object::base_select(base_arm, blender::ed::object::BA_DESELECT);
|
2019-07-18 14:18:43 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((base_select->flag & BASE_SELECTED) == 0) {
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::base_select(base_select, blender::ed::object::BA_SELECT);
|
2019-07-18 14:18:43 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-28 16:17:37 +10:00
|
|
|
bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* we call this from outliner too */
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ob->pose == nullptr) {
|
2018-08-28 16:17:37 +10:00
|
|
|
return false;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-23 11:51:19 +01:00
|
|
|
/* Determine if we're selecting or deselecting */
|
2014-07-29 15:02:28 +02:00
|
|
|
if (select_mode == SEL_TOGGLE) {
|
|
|
|
|
select_mode = SEL_SELECT;
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
2025-05-16 14:45:46 +02:00
|
|
|
if (ignore_visibility || blender::animrig::bone_is_visible_pchan(arm, pchan)) {
|
2014-07-29 15:02:28 +02:00
|
|
|
if (pchan->bone->flag & BONE_SELECTED) {
|
|
|
|
|
select_mode = SEL_DESELECT;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
break;
|
2014-07-29 15:02:28 +02:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-29 15:02:28 +02:00
|
|
|
/* Set the flags accordingly */
|
2018-08-28 16:17:37 +10:00
|
|
|
bool changed = false;
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
|
2025-05-16 14:45:46 +02:00
|
|
|
if (ignore_visibility || blender::animrig::bone_is_visible_pchan(arm, pchan)) {
|
2018-08-28 16:17:37 +10:00
|
|
|
int flag_prev = pchan->bone->flag;
|
2014-07-29 15:02:28 +02:00
|
|
|
pose_do_bone_select(pchan, select_mode);
|
2018-08-28 16:17:37 +10:00
|
|
|
changed = (changed || flag_prev != pchan->bone->flag);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-08-28 16:17:37 +10:00
|
|
|
return changed;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
|
|
|
|
|
{
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
2025-05-16 14:45:46 +02:00
|
|
|
if (ignore_visibility || blender::animrig::bone_is_visible_pchan(arm, pchan)) {
|
2018-04-16 16:27:55 +02:00
|
|
|
if (pchan->bone->flag & BONE_SELECTED) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
static bool ed_pose_is_any_selected_multi(const Span<Base *> bases, bool ignore_visibility)
|
2018-04-16 16:27:55 +02:00
|
|
|
{
|
2024-01-24 18:18:14 +01:00
|
|
|
for (Base *base : bases) {
|
|
|
|
|
Object *ob_iter = base->object;
|
2018-04-16 16:27:55 +02:00
|
|
|
if (ed_pose_is_any_selected(ob_iter, ignore_visibility)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
bool ED_pose_deselect_all_multi_ex(const Span<Base *> bases,
|
2019-03-26 18:47:55 +11:00
|
|
|
int select_mode,
|
|
|
|
|
const bool ignore_visibility)
|
2018-04-16 16:27:55 +02:00
|
|
|
{
|
|
|
|
|
if (select_mode == SEL_TOGGLE) {
|
2024-01-24 18:18:14 +01:00
|
|
|
select_mode = ed_pose_is_any_selected_multi(bases, ignore_visibility) ? SEL_DESELECT :
|
|
|
|
|
SEL_SELECT;
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 18:47:55 +11:00
|
|
|
bool changed_multi = false;
|
2024-01-24 18:18:14 +01:00
|
|
|
for (Base *base : bases) {
|
|
|
|
|
Object *ob_iter = base->object;
|
2018-08-28 16:17:37 +10:00
|
|
|
if (ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility)) {
|
|
|
|
|
ED_pose_bone_select_tag_update(ob_iter);
|
2019-03-26 18:47:55 +11:00
|
|
|
changed_multi = true;
|
2018-05-24 14:54:56 +02:00
|
|
|
}
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2019-03-26 18:47:55 +11:00
|
|
|
return changed_multi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ED_pose_deselect_all_multi(bContext *C, int select_mode, const bool ignore_visibility)
|
|
|
|
|
{
|
2019-09-18 17:19:07 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2023-10-17 10:34:59 +02:00
|
|
|
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
2019-10-25 00:40:21 +11:00
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
Vector<Base *> bases = BKE_object_pose_base_array_get_unique(vc.scene, vc.view_layer, vc.v3d);
|
|
|
|
|
return ED_pose_deselect_all_multi_ex(bases, select_mode, ignore_visibility);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* ***************** Selections ********************** */
|
|
|
|
|
|
|
|
|
|
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
|
|
|
|
|
{
|
2014-07-05 01:05:50 +12:00
|
|
|
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (extend) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
bone->flag &= ~BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
bone->flag |= BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
selectconnected_posebonechildren(ob, curBone, extend);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* within active object context */
|
|
|
|
|
/* previously known as "selectconnected_posearmature" */
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_connected_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *event)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2023-07-05 20:03:41 +02:00
|
|
|
Bone *bone, *curBone, *next = nullptr;
|
2013-11-26 06:39:14 +11:00
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-02-04 21:17:14 +11:00
|
|
|
view3d_operator_needs_gpu(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
Base *base = nullptr;
|
2020-04-03 15:45:57 +11:00
|
|
|
bone = ED_armature_pick_bone(C, event->mval, !extend, &base);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!bone) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* Select parents */
|
|
|
|
|
for (curBone = bone; curBone; curBone = next) {
|
|
|
|
|
/* ignore bone if cannot be selected */
|
|
|
|
|
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (extend) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
curBone->flag &= ~BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
curBone->flag |= BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (curBone->flag & BONE_CONNECTED) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
next = curBone->parent;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2023-07-05 20:03:41 +02:00
|
|
|
next = nullptr;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-22 09:19:45 +10:00
|
|
|
else {
|
2023-07-05 20:03:41 +02:00
|
|
|
next = nullptr;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* Select children */
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
|
2018-04-16 16:27:55 +02:00
|
|
|
selectconnected_posebonechildren(base->object, curBone, extend);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
2018-08-28 16:17:37 +10:00
|
|
|
ED_pose_bone_select_tag_update(base->object);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 15:41:22 +02:00
|
|
|
static bool pose_select_linked_pick_poll(bContext *C)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
return (ED_operator_view3d_active(C) && ED_operator_posemode(C));
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 15:41:22 +02:00
|
|
|
void POSE_OT_select_linked_pick(wmOperatorType *ot)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2021-08-25 17:59:47 +10:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Connected";
|
2020-04-27 15:41:22 +02:00
|
|
|
ot->idname = "POSE_OT_select_linked_pick";
|
|
|
|
|
ot->description = "Select bones linked by parent/child connections under the mouse cursor";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-23 14:49:44 +02:00
|
|
|
/* callbacks */
|
2013-07-28 17:06:31 +00:00
|
|
|
/* leave 'exec' unset */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->invoke = pose_select_connected_invoke;
|
2020-04-27 15:41:22 +02:00
|
|
|
ot->poll = pose_select_linked_pick_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* props */
|
2021-08-25 17:59:47 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
|
|
|
|
false,
|
|
|
|
|
"Extend",
|
|
|
|
|
"Extend selection instead of deselecting everything first");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_linked_exec(bContext *C, wmOperator * /*op*/)
|
2020-04-27 15:41:22 +02:00
|
|
|
{
|
2023-07-05 20:03:41 +02:00
|
|
|
Bone *curBone, *next = nullptr;
|
2020-04-27 15:41:22 +02:00
|
|
|
|
|
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
|
|
|
|
|
if ((pchan->bone->flag & BONE_SELECTED) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2020-04-27 15:41:22 +02:00
|
|
|
|
|
|
|
|
/* Select parents */
|
|
|
|
|
for (curBone = pchan->bone; curBone; curBone = next) {
|
|
|
|
|
if (PBONE_SELECTABLE(arm, curBone)) {
|
|
|
|
|
curBone->flag |= BONE_SELECTED;
|
|
|
|
|
|
|
|
|
|
if (curBone->flag & BONE_CONNECTED) {
|
|
|
|
|
next = curBone->parent;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2023-07-05 20:03:41 +02:00
|
|
|
next = nullptr;
|
2020-04-27 15:41:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2023-07-05 20:03:41 +02:00
|
|
|
next = nullptr;
|
2020-04-27 15:41:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Select children */
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (Bone *, curBone, &pchan->bone->childbase) {
|
2020-04-27 15:41:22 +02:00
|
|
|
selectconnected_posebonechildren(ob, curBone, false);
|
|
|
|
|
}
|
|
|
|
|
ED_pose_bone_select_tag_update(ob);
|
|
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
|
|
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_linked(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Connected";
|
|
|
|
|
ot->idname = "POSE_OT_select_linked";
|
|
|
|
|
ot->description = "Select all bones linked by parent/child connections to the current selection";
|
|
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
|
ot->exec = pose_select_linked_exec;
|
|
|
|
|
ot->poll = ED_operator_posemode;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_de_select_all_exec(bContext *C, wmOperator *op)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
int multipaint = scene->toolsettings->multipaint;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
if (action == SEL_TOGGLE) {
|
|
|
|
|
action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
Object *ob_prev = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-29 16:33:51 +11:00
|
|
|
/* Set the flags. */
|
2019-04-21 04:40:16 +10:00
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2014-07-29 15:02:28 +02:00
|
|
|
pose_do_bone_select(pchan, action);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
if (ob_prev != ob) {
|
2023-09-03 21:35:03 +10:00
|
|
|
/* Weight-paint or mask modifiers need depsgraph updates. */
|
2018-04-16 16:27:55 +02:00
|
|
|
if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2018-05-07 19:03:29 +02:00
|
|
|
/* need to tag armature for cow updates, or else selection doesn't update */
|
2024-02-19 15:54:08 +01:00
|
|
|
DEG_id_tag_update(&arm->id, ID_RECALC_SYNC_TO_EVAL);
|
2018-04-16 16:27:55 +02:00
|
|
|
ob_prev = ob;
|
|
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_all(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "(De)select All";
|
|
|
|
|
ot->idname = "POSE_OT_select_all";
|
|
|
|
|
ot->description = "Toggle selection status of all bones";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->exec = pose_de_select_all_exec;
|
|
|
|
|
ot->poll = ED_operator_posemode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
WM_operator_properties_select_all(ot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_parent_exec(bContext *C, wmOperator * /*op*/)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2018-10-12 18:02:02 -03:00
|
|
|
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
2025-03-17 19:49:45 +01:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2018-10-12 18:02:02 -03:00
|
|
|
bPoseChannel *pchan, *parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-12 18:02:02 -03:00
|
|
|
/* Determine if there is an active bone */
|
|
|
|
|
pchan = CTX_data_active_pose_bone(C);
|
|
|
|
|
if (pchan) {
|
|
|
|
|
parent = pchan->parent;
|
|
|
|
|
if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) {
|
|
|
|
|
parent->bone->flag |= BONE_SELECTED;
|
|
|
|
|
arm->act_bone = parent->bone;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-10-12 18:02:02 -03:00
|
|
|
else {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
2018-10-12 18:02:02 -03:00
|
|
|
ED_pose_bone_select_tag_update(ob);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_parent(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Parent Bone";
|
|
|
|
|
ot->idname = "POSE_OT_select_parent";
|
|
|
|
|
ot->description = "Select bones that are parents of the currently selected bones";
|
|
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->exec = pose_select_parent_exec;
|
|
|
|
|
ot->poll = ED_operator_posemode;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_constraint_target_exec(bContext *C, wmOperator * /*op*/)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2025-04-15 02:07:40 +00:00
|
|
|
bool found = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 09:38:21 -03:00
|
|
|
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
if (pchan->bone->flag & BONE_SELECTED) {
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
|
2023-07-05 20:03:41 +02:00
|
|
|
ListBase targets = {nullptr, nullptr};
|
2020-11-23 23:42:05 +03:00
|
|
|
if (BKE_constraint_targets_get(con, &targets)) {
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
|
2018-10-19 09:38:21 -03:00
|
|
|
Object *ob = ct->tar;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 09:38:21 -03:00
|
|
|
/* Any armature that is also in pose mode should be selected. */
|
2023-07-05 20:03:41 +02:00
|
|
|
if ((ct->subtarget[0] != '\0') && (ob != nullptr) && (ob->type == OB_ARMATURE) &&
|
2018-10-19 09:38:21 -03:00
|
|
|
(ob->mode == OB_MODE_POSE))
|
|
|
|
|
{
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget);
|
|
|
|
|
if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) {
|
|
|
|
|
pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
2018-10-19 09:38:21 -03:00
|
|
|
ED_pose_bone_select_tag_update(ob);
|
2025-04-15 02:07:40 +00:00
|
|
|
found = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-22 11:36:59 +10:00
|
|
|
BKE_constraint_targets_flush(con, &targets, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!found) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_constraint_target(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Constraint Target";
|
|
|
|
|
ot->idname = "POSE_OT_select_constraint_target";
|
|
|
|
|
ot->description = "Select bones used as targets for the currently selected bones";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->exec = pose_select_constraint_target_exec;
|
|
|
|
|
ot->poll = ED_operator_posemode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2018-10-12 13:24:01 -03:00
|
|
|
/* No need to convert to multi-objects. Just like we keep the non-active bones
|
|
|
|
|
* selected we then keep the non-active objects untouched (selected/unselected). */
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_hierarchy_exec(bContext *C, wmOperator *op)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2015-03-20 01:37:29 +11:00
|
|
|
bPoseChannel *pchan_act;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
int direction = RNA_enum_get(op->ptr, "direction");
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
|
2015-03-20 01:37:29 +11:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-29 10:59:06 +02:00
|
|
|
pchan_act = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
2023-07-05 20:03:41 +02:00
|
|
|
if (pchan_act == nullptr) {
|
2015-03-20 01:37:29 +11:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
if (direction == BONE_SELECT_PARENT) {
|
|
|
|
|
if (pchan_act->parent) {
|
|
|
|
|
Bone *bone_parent;
|
|
|
|
|
bone_parent = pchan_act->parent->bone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
if (PBONE_SELECTABLE(arm, bone_parent)) {
|
|
|
|
|
if (!add_to_sel) {
|
|
|
|
|
pchan_act->bone->flag &= ~BONE_SELECTED;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2015-03-20 01:37:29 +11:00
|
|
|
bone_parent->flag |= BONE_SELECTED;
|
|
|
|
|
arm->act_bone = bone_parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { /* direction == BONE_SELECT_CHILD */
|
2023-07-05 20:03:41 +02:00
|
|
|
Bone *bone_child = nullptr;
|
2015-03-20 01:37:29 +11:00
|
|
|
int pass;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
/* first pass, only connected bones (the logical direct child) */
|
2023-07-05 20:03:41 +02:00
|
|
|
for (pass = 0; pass < 2 && (bone_child == nullptr); pass++) {
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan_iter, &ob->pose->chanbase) {
|
2015-03-20 01:37:29 +11:00
|
|
|
/* possible we have multiple children, some invisible */
|
|
|
|
|
if (PBONE_SELECTABLE(arm, pchan_iter->bone)) {
|
|
|
|
|
if (pchan_iter->parent == pchan_act) {
|
|
|
|
|
if ((pass == 1) || (pchan_iter->bone->flag & BONE_CONNECTED)) {
|
|
|
|
|
bone_child = pchan_iter->bone;
|
|
|
|
|
break;
|
|
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
if (bone_child) {
|
|
|
|
|
arm->act_bone = bone_child;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
if (!add_to_sel) {
|
|
|
|
|
pchan_act->bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
bone_child->flag |= BONE_SELECTED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
changed = true;
|
|
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-20 01:37:29 +11:00
|
|
|
if (changed == false) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2015-03-20 01:37:29 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
2018-08-28 16:17:37 +10:00
|
|
|
ED_pose_bone_select_tag_update(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_hierarchy(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
|
|
|
|
|
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
|
2023-07-05 20:03:41 +02:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Hierarchy";
|
|
|
|
|
ot->idname = "POSE_OT_select_hierarchy";
|
|
|
|
|
ot->description = "Select immediate parent/children of selected bones";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->exec = pose_select_hierarchy_exec;
|
|
|
|
|
ot->poll = ED_operator_posemode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* props */
|
|
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
|
ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
|
|
|
|
|
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2025-04-24 13:26:56 +02:00
|
|
|
/* Modes for the `select_grouped` operator. */
|
|
|
|
|
enum class SelectRelatedMode {
|
|
|
|
|
SAME_COLLECTION = 0,
|
|
|
|
|
SAME_COLOR,
|
|
|
|
|
SAME_KEYINGSET,
|
2025-05-20 10:19:31 +02:00
|
|
|
CHILDREN,
|
|
|
|
|
IMMEDIATE_CHILDREN,
|
|
|
|
|
PARENT,
|
|
|
|
|
SIBLINGS,
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2014-06-26 16:40:35 +12:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
static bool pose_select_same_color(bContext *C, const bool extend)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2023-09-18 16:36:20 +02:00
|
|
|
/* Get a set of all the colors of the selected bones. */
|
|
|
|
|
blender::Set<blender::animrig::BoneColor> used_colors;
|
|
|
|
|
blender::Set<Object *> updated_objects;
|
|
|
|
|
bool changed_any_selection = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
/* Old approach that we may want to reinstate behind some option at some point. This will match
|
|
|
|
|
* against the colors of all selected bones, instead of just the active one. It also explains why
|
|
|
|
|
* there is a set of colors to begin with.
|
|
|
|
|
*
|
|
|
|
|
* CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
|
|
|
|
|
* auto color = blender::animrig::ANIM_bonecolor_posebone_get(pchan);
|
|
|
|
|
* used_colors.add(color);
|
|
|
|
|
* }
|
|
|
|
|
* CTX_DATA_END;
|
|
|
|
|
*/
|
|
|
|
|
if (!extend) {
|
|
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
|
|
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
updated_objects.add(ob);
|
|
|
|
|
changed_any_selection = true;
|
2018-10-19 11:53:48 -03:00
|
|
|
}
|
2023-09-18 16:36:20 +02:00
|
|
|
CTX_DATA_END;
|
2018-10-19 11:53:48 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
/* Use the color of the active pose bone. */
|
|
|
|
|
bPoseChannel *active_pose_bone = CTX_data_active_pose_bone(C);
|
|
|
|
|
auto color = blender::animrig::ANIM_bonecolor_posebone_get(active_pose_bone);
|
|
|
|
|
used_colors.add(color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
/* Select all visible bones that have the same color. */
|
2019-08-23 09:52:12 +02:00
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
|
2023-09-18 16:36:20 +02:00
|
|
|
Bone *bone = pchan->bone;
|
|
|
|
|
if (bone->flag & (BONE_UNSELECTABLE | BONE_SELECTED)) {
|
|
|
|
|
/* Skip bones that are unselectable or already selected. */
|
|
|
|
|
continue;
|
2018-10-19 11:53:48 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
auto color = blender::animrig::ANIM_bonecolor_posebone_get(pchan);
|
|
|
|
|
if (!used_colors.contains(color)) {
|
|
|
|
|
continue;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
bone->flag |= BONE_SELECTED;
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
updated_objects.add(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
if (!changed_any_selection) {
|
|
|
|
|
return false;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 16:36:20 +02:00
|
|
|
for (Object *ob : updated_objects) {
|
|
|
|
|
ED_pose_bone_select_tag_update(ob);
|
2018-10-19 11:53:48 -03:00
|
|
|
}
|
2023-09-18 16:36:20 +02:00
|
|
|
return true;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
static bool pose_select_same_collection(bContext *C, const bool extend)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2023-09-18 15:29:03 +02:00
|
|
|
bool changed_any_selection = false;
|
|
|
|
|
blender::Set<Object *> updated_objects;
|
2019-10-25 00:40:21 +11:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
/* Refuse to do anything if there is no active pose bone. */
|
|
|
|
|
bPoseChannel *active_pchan = CTX_data_active_pose_bone(C);
|
|
|
|
|
if (!active_pchan) {
|
|
|
|
|
return false;
|
2018-10-19 12:44:33 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
if (!extend) {
|
|
|
|
|
/* Deselect all the bones. */
|
|
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
2023-09-18 15:29:03 +02:00
|
|
|
updated_objects.add(ob);
|
|
|
|
|
changed_any_selection = true;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2023-09-18 15:29:03 +02:00
|
|
|
CTX_DATA_END;
|
2018-10-19 12:44:33 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
/* Build a set of bone collection names, to allow cross-Armature selection. */
|
|
|
|
|
blender::Set<std::string> collection_names;
|
|
|
|
|
LISTBASE_FOREACH (BoneCollectionReference *, bcoll_ref, &active_pchan->bone->runtime.collections)
|
|
|
|
|
{
|
|
|
|
|
collection_names.add(bcoll_ref->bcoll->name);
|
2018-10-19 12:44:33 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
/* Select all bones that match any of the collection names. */
|
2019-04-21 04:40:16 +10:00
|
|
|
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
|
2023-09-18 15:29:03 +02:00
|
|
|
Bone *bone = pchan->bone;
|
|
|
|
|
if (bone->flag & (BONE_UNSELECTABLE | BONE_SELECTED)) {
|
|
|
|
|
continue;
|
2018-10-19 12:44:33 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
LISTBASE_FOREACH (BoneCollectionReference *, bcoll_ref, &bone->runtime.collections) {
|
|
|
|
|
if (!collection_names.contains(bcoll_ref->bcoll->name)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bone->flag |= BONE_SELECTED;
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
updated_objects.add(ob);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
for (Object *ob : updated_objects) {
|
|
|
|
|
ED_pose_bone_select_tag_update(ob);
|
2018-10-19 12:44:33 -03:00
|
|
|
}
|
|
|
|
|
|
2023-09-18 15:29:03 +02:00
|
|
|
return changed_any_selection;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2025-05-20 10:19:31 +02:00
|
|
|
/* Useful to get the selection before modifying it. */
|
|
|
|
|
static blender::Set<bPoseChannel *> get_selected_pose_bones(Object *pose_object)
|
|
|
|
|
{
|
|
|
|
|
blender::Set<bPoseChannel *> selected_pose_bones;
|
|
|
|
|
bArmature *arm = static_cast<bArmature *>((pose_object) ? pose_object->data : nullptr);
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose_object->pose->chanbase) {
|
|
|
|
|
if (PBONE_SELECTED(arm, pchan->bone)) {
|
|
|
|
|
selected_pose_bones.add(pchan);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return selected_pose_bones;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool pose_bone_is_below_one_of(bPoseChannel &bone,
|
|
|
|
|
const blender::Set<bPoseChannel *> &potential_parents)
|
|
|
|
|
{
|
|
|
|
|
bPoseChannel *bone_iter = &bone;
|
|
|
|
|
while (bone_iter) {
|
|
|
|
|
if (potential_parents.contains(bone_iter)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
bone_iter = bone_iter->parent;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void deselect_pose_bones(const blender::Set<bPoseChannel *> &pose_bones)
|
|
|
|
|
{
|
|
|
|
|
for (bPoseChannel *pose_bone : pose_bones) {
|
|
|
|
|
if (!pose_bone) {
|
|
|
|
|
/* There may be a nullptr in the set if selecting siblings of root bones. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
pose_bone->bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Selects children of currently selected bones in all objects in pose mode. If `all` is true, a
|
|
|
|
|
* bone will be selected if any bone in it's parent hierarchy is selected. If false, only bones
|
|
|
|
|
* whose direct parent is selected are changed. */
|
|
|
|
|
static bool pose_select_children(bContext *C, const bool all, const bool extend)
|
|
|
|
|
{
|
|
|
|
|
Vector<Object *> objects = BKE_object_pose_array_get_unique(
|
|
|
|
|
CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_view3d(C));
|
|
|
|
|
|
|
|
|
|
bool changed_any_selection = false;
|
|
|
|
|
|
|
|
|
|
for (Object *pose_object : objects) {
|
|
|
|
|
bArmature *arm = static_cast<bArmature *>(pose_object->data);
|
|
|
|
|
BLI_assert(arm);
|
|
|
|
|
blender::Set<bPoseChannel *> selected_pose_bones = get_selected_pose_bones(pose_object);
|
|
|
|
|
if (!extend) {
|
|
|
|
|
deselect_pose_bones(selected_pose_bones);
|
|
|
|
|
}
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose_object->pose->chanbase) {
|
|
|
|
|
if (!PBONE_SELECTABLE(arm, pchan->bone)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (all) {
|
|
|
|
|
if (pose_bone_is_below_one_of(*pchan, selected_pose_bones)) {
|
|
|
|
|
pose_do_bone_select(pchan, SEL_SELECT);
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (selected_pose_bones.contains(pchan->parent)) {
|
|
|
|
|
pose_do_bone_select(pchan, SEL_SELECT);
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ED_pose_bone_select_tag_update(pose_object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed_any_selection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool pose_select_parents(bContext *C, const bool extend)
|
|
|
|
|
{
|
|
|
|
|
Vector<Object *> objects = BKE_object_pose_array_get_unique(
|
|
|
|
|
CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_view3d(C));
|
|
|
|
|
|
|
|
|
|
bool changed_any_selection = false;
|
|
|
|
|
for (Object *pose_object : objects) {
|
|
|
|
|
bArmature *arm = static_cast<bArmature *>(pose_object->data);
|
|
|
|
|
BLI_assert(arm);
|
|
|
|
|
blender::Set<bPoseChannel *> selected_pose_bones = get_selected_pose_bones(pose_object);
|
|
|
|
|
if (!extend) {
|
|
|
|
|
deselect_pose_bones(selected_pose_bones);
|
|
|
|
|
}
|
|
|
|
|
for (bPoseChannel *pchan : selected_pose_bones) {
|
|
|
|
|
if (!pchan->parent) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!PBONE_SELECTABLE(arm, pchan->parent->bone)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
pose_do_bone_select(pchan->parent, SEL_SELECT);
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
}
|
|
|
|
|
ED_pose_bone_select_tag_update(pose_object);
|
|
|
|
|
}
|
|
|
|
|
return changed_any_selection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool pose_select_siblings(bContext *C, const bool extend)
|
|
|
|
|
{
|
|
|
|
|
Vector<Object *> objects = BKE_object_pose_array_get_unique(
|
|
|
|
|
CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_view3d(C));
|
|
|
|
|
|
|
|
|
|
bool changed_any_selection = false;
|
|
|
|
|
for (Object *pose_object : objects) {
|
|
|
|
|
bArmature *arm = static_cast<bArmature *>(pose_object->data);
|
|
|
|
|
BLI_assert(arm);
|
|
|
|
|
blender::Set<bPoseChannel *> parents_of_selected;
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose_object->pose->chanbase) {
|
|
|
|
|
if (PBONE_SELECTED(arm, pchan->bone)) {
|
|
|
|
|
parents_of_selected.add(pchan->parent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!extend) {
|
|
|
|
|
deselect_pose_bones(parents_of_selected);
|
|
|
|
|
}
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose_object->pose->chanbase) {
|
|
|
|
|
if (!PBONE_SELECTABLE(arm, pchan->bone)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* Checking if the bone is already selected so `changed_any_selection` stays true to its
|
|
|
|
|
* word. */
|
|
|
|
|
if (parents_of_selected.contains(pchan->parent) && !PBONE_SELECTED(arm, pchan->bone)) {
|
|
|
|
|
pose_do_bone_select(pchan, SEL_SELECT);
|
|
|
|
|
changed_any_selection = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ED_pose_bone_select_tag_update(pose_object);
|
|
|
|
|
}
|
|
|
|
|
return changed_any_selection;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-19 15:44:04 -03:00
|
|
|
static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool extend)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2024-11-15 10:51:41 +01:00
|
|
|
using namespace blender::animrig;
|
2022-09-14 21:30:20 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-10-19 15:44:04 -03:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
|
bool changed_multi = false;
|
2024-11-15 10:51:41 +01:00
|
|
|
KeyingSet *ks = scene_get_active_keyingset(CTX_data_scene(C));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* sanity checks: validate Keying Set and object */
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ks == nullptr) {
|
2014-06-26 16:46:19 +12:00
|
|
|
BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-11-15 10:51:41 +01:00
|
|
|
if (validate_keyingset(C, nullptr, ks) != ModifyKeyReturn::SUCCESS) {
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ks->paths.first == nullptr) {
|
2014-06-26 16:46:19 +12:00
|
|
|
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
|
2018-06-04 09:31:30 +02:00
|
|
|
BKE_report(reports,
|
|
|
|
|
RPT_ERROR,
|
2014-06-26 16:46:19 +12:00
|
|
|
"Use another Keying Set, as the active one depends on the currently "
|
|
|
|
|
"selected items or cannot find any targets due to unsuitable context");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Keying Set does not contain any paths");
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-06-26 16:46:19 +12:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* if not extending selection, deselect all selected first */
|
2013-03-19 23:17:44 +00:00
|
|
|
if (extend == false) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
Vector<Object *> objects = BKE_object_pose_array_get_unique(scene, view_layer, CTX_wm_view3d(C));
|
2019-10-25 00:40:21 +11:00
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
for (const int ob_index : objects.index_range()) {
|
2018-10-19 15:44:04 -03:00
|
|
|
Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>((ob) ? ob->data : nullptr);
|
|
|
|
|
bPose *pose = (ob) ? ob->pose : nullptr;
|
2018-10-19 15:44:04 -03:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 15:44:04 -03:00
|
|
|
/* Sanity checks. */
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ELEM(nullptr, ob, pose, arm)) {
|
2018-10-19 15:44:04 -03:00
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 15:44:04 -03:00
|
|
|
/* iterate over elements in the Keying Set, setting selection depending on whether
|
|
|
|
|
* that bone is visible or not...
|
|
|
|
|
*/
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
2018-10-19 15:44:04 -03:00
|
|
|
/* only items related to this object will be relevant */
|
2023-07-05 20:03:41 +02:00
|
|
|
if ((ksp->id == &ob->id) && (ksp->rna_path != nullptr)) {
|
|
|
|
|
bPoseChannel *pchan = nullptr;
|
2021-09-04 14:22:44 +10:00
|
|
|
char boneName[sizeof(pchan->name)];
|
|
|
|
|
if (!BLI_str_quoted_substr(ksp->rna_path, "bones[", boneName, sizeof(boneName))) {
|
2021-09-01 15:23:56 +10:00
|
|
|
continue;
|
|
|
|
|
}
|
2021-09-04 14:22:44 +10:00
|
|
|
pchan = BKE_pose_channel_find_name(pose, boneName);
|
2021-09-01 15:23:56 +10:00
|
|
|
|
|
|
|
|
if (pchan) {
|
|
|
|
|
/* select if bone is visible and can be affected */
|
|
|
|
|
if (PBONE_SELECTABLE(arm, pchan->bone)) {
|
|
|
|
|
pchan->bone->flag |= BONE_SELECTED;
|
|
|
|
|
changed = true;
|
2018-10-19 15:44:04 -03:00
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 15:44:04 -03:00
|
|
|
if (changed || !extend) {
|
|
|
|
|
ED_pose_bone_select_tag_update(ob);
|
|
|
|
|
changed_multi = true;
|
|
|
|
|
}
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-19 15:44:04 -03:00
|
|
|
return changed_multi;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_grouped_exec(bContext *C, wmOperator *op)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
2025-04-24 13:26:56 +02:00
|
|
|
const SelectRelatedMode mode = SelectRelatedMode(RNA_enum_get(op->ptr, "type"));
|
2013-11-26 06:39:14 +11:00
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
|
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* sanity check */
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ob->pose == nullptr) {
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-06-26 16:40:35 +12:00
|
|
|
/* selection types */
|
2025-04-24 13:26:56 +02:00
|
|
|
switch (mode) {
|
|
|
|
|
case SelectRelatedMode::SAME_COLLECTION:
|
2023-09-18 15:29:03 +02:00
|
|
|
changed = pose_select_same_collection(C, extend);
|
2014-06-26 16:40:35 +12:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-24 13:26:56 +02:00
|
|
|
case SelectRelatedMode::SAME_COLOR:
|
2023-09-18 16:36:20 +02:00
|
|
|
changed = pose_select_same_color(C, extend);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-24 13:26:56 +02:00
|
|
|
case SelectRelatedMode::SAME_KEYINGSET:
|
2018-10-19 15:44:04 -03:00
|
|
|
changed = pose_select_same_keyingset(C, op->reports, extend);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-20 10:19:31 +02:00
|
|
|
case SelectRelatedMode::CHILDREN:
|
|
|
|
|
changed = pose_select_children(C, true, extend);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SelectRelatedMode::IMMEDIATE_CHILDREN:
|
|
|
|
|
changed = pose_select_children(C, false, extend);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SelectRelatedMode::PARENT:
|
|
|
|
|
changed = pose_select_parents(C, extend);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SelectRelatedMode::SIBLINGS:
|
|
|
|
|
changed = pose_select_siblings(C, extend);
|
|
|
|
|
break;
|
|
|
|
|
|
2014-06-26 16:40:35 +12:00
|
|
|
default:
|
2025-04-24 13:26:56 +02:00
|
|
|
printf("pose_select_grouped() - Unknown selection type %d\n", int(mode));
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* report done status */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (changed) {
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-07-03 14:52:32 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void POSE_OT_select_grouped(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem prop_select_grouped_types[] = {
|
2025-04-24 13:26:56 +02:00
|
|
|
{int(SelectRelatedMode::SAME_COLLECTION),
|
2023-09-18 15:29:03 +02:00
|
|
|
"COLLECTION",
|
|
|
|
|
0,
|
|
|
|
|
"Collection",
|
|
|
|
|
"Same collections as the active bone"},
|
2025-04-24 13:26:56 +02:00
|
|
|
{int(SelectRelatedMode::SAME_COLOR), "COLOR", 0, "Color", "Same color as the active bone"},
|
|
|
|
|
{int(SelectRelatedMode::SAME_KEYINGSET),
|
2014-06-26 16:40:35 +12:00
|
|
|
"KEYINGSET",
|
|
|
|
|
0,
|
|
|
|
|
"Keying Set",
|
|
|
|
|
"All bones affected by active Keying Set"},
|
2025-05-20 10:19:31 +02:00
|
|
|
{int(SelectRelatedMode::CHILDREN),
|
|
|
|
|
"CHILDREN",
|
|
|
|
|
0,
|
|
|
|
|
"Children",
|
|
|
|
|
"Select all children of currently selected bones"},
|
|
|
|
|
{int(SelectRelatedMode::IMMEDIATE_CHILDREN),
|
|
|
|
|
"CHILDREN_IMMEDIATE",
|
|
|
|
|
0,
|
|
|
|
|
"Immediate Children",
|
|
|
|
|
"Select direct children of currently selected bones"},
|
|
|
|
|
{int(SelectRelatedMode::PARENT),
|
|
|
|
|
"PARENT",
|
|
|
|
|
0,
|
|
|
|
|
"Parents",
|
|
|
|
|
"Select the parents of currently selected bones"},
|
|
|
|
|
{int(SelectRelatedMode::SIBLINGS),
|
|
|
|
|
"SIBILINGS",
|
|
|
|
|
0,
|
|
|
|
|
"Siblings",
|
|
|
|
|
"Select all bones that have the same parent as currently selected bones"},
|
2023-07-05 20:03:41 +02:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Grouped";
|
|
|
|
|
ot->description = "Select all visible bones grouped by similar properties";
|
|
|
|
|
ot->idname = "POSE_OT_select_grouped";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = pose_select_grouped_exec;
|
2023-09-18 15:29:03 +02:00
|
|
|
ot->poll = ED_operator_posemode; /* TODO: expand to support edit mode as well. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* properties */
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
|
|
|
|
false,
|
|
|
|
|
"Extend",
|
|
|
|
|
"Extend selection instead of deselecting everything first");
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
2025-04-01 14:38:05 +02:00
|
|
|
/* Add the given selection flags to the bone flags. */
|
|
|
|
|
static void bone_selection_flags_add(bPoseChannel *pchan, const eBone_Flag new_selection_flags)
|
|
|
|
|
{
|
|
|
|
|
pchan->bone->flag |= (new_selection_flags & BONE_SELECTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the bone flags to the given selection flags. */
|
|
|
|
|
static void bone_selection_flags_set(bPoseChannel *pchan, const eBone_Flag new_selection_flags)
|
|
|
|
|
{
|
|
|
|
|
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
|
|
|
|
pchan->bone->flag |= (new_selection_flags & BONE_SELECTED);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 05:18:10 +11:00
|
|
|
/**
|
|
|
|
|
* \note clone of #armature_select_mirror_exec keep in sync
|
|
|
|
|
*/
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus pose_select_mirror_exec(bContext *C, wmOperator *op)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = CTX_data_scene(C);
|
2018-04-25 17:52:02 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2018-10-02 17:22:43 +00:00
|
|
|
Object *ob_active = CTX_data_active_object(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-02 17:22:43 +00:00
|
|
|
const bool is_weight_paint = (ob_active->mode & OB_MODE_WEIGHT_PAINT) != 0;
|
|
|
|
|
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
|
|
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-01 14:38:05 +02:00
|
|
|
const auto set_bone_selection_flags = extend ? bone_selection_flags_add :
|
|
|
|
|
bone_selection_flags_set;
|
|
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
Vector<Object *> objects = BKE_object_pose_array_get_unique(scene, view_layer, CTX_wm_view3d(C));
|
|
|
|
|
for (Object *ob : objects) {
|
2023-07-05 20:03:41 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(ob->data);
|
2023-08-04 08:51:13 +10:00
|
|
|
bPoseChannel *pchan_mirror_act = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-01 14:38:05 +02:00
|
|
|
/* Remember the pre-mirroring selection flags of the bones. */
|
|
|
|
|
blender::Map<bPoseChannel *, eBone_Flag> old_selection_flags;
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
2025-04-01 15:00:45 +02:00
|
|
|
/* Treat invisible bones as deselected. */
|
2025-05-16 14:45:46 +02:00
|
|
|
const int flags = blender::animrig::bone_is_visible_pchan(arm, pchan) ? pchan->bone->flag :
|
|
|
|
|
0;
|
2025-04-01 15:00:45 +02:00
|
|
|
|
|
|
|
|
old_selection_flags.add_new(pchan, eBone_Flag(flags));
|
2018-04-25 17:52:02 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
2025-04-01 14:38:05 +02:00
|
|
|
if (!PBONE_SELECTABLE(arm, pchan->bone)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-01 14:38:05 +02:00
|
|
|
bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name);
|
2025-04-01 15:00:45 +02:00
|
|
|
if (!pchan_mirror) {
|
|
|
|
|
/* If a bone cannot be mirrored, keep its flags as-is. This makes it possible to select
|
|
|
|
|
* the spine and an arm, and still flip the selection to the other arm (without losing
|
|
|
|
|
* the selection on the spine). */
|
2025-04-01 14:38:05 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-01 14:38:05 +02:00
|
|
|
if (pchan->bone == arm->act_bone) {
|
|
|
|
|
pchan_mirror_act = pchan_mirror;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-04-01 15:00:45 +02:00
|
|
|
/* If active-only, don't touch unrelated bones. */
|
2025-04-01 14:38:05 +02:00
|
|
|
if (active_only && !ELEM(arm->act_bone, pchan->bone, pchan_mirror->bone)) {
|
|
|
|
|
continue;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2025-04-01 14:38:05 +02:00
|
|
|
|
|
|
|
|
const eBone_Flag flags_mirror = old_selection_flags.lookup(pchan_mirror);
|
|
|
|
|
set_bone_selection_flags(pchan, flags_mirror);
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-25 17:52:02 +02:00
|
|
|
if (pchan_mirror_act) {
|
|
|
|
|
arm->act_bone = pchan_mirror_act->bone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-03 21:35:03 +10:00
|
|
|
/* In weight-paint we select the associated vertex group too. */
|
2018-10-02 17:22:43 +00:00
|
|
|
if (is_weight_paint) {
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::vgroup_select_by_name(ob_active, pchan_mirror_act->name);
|
2019-11-16 03:32:23 +11:00
|
|
|
DEG_id_tag_update(&ob_active->id, ID_RECALC_GEOMETRY);
|
2018-04-25 17:52:02 +02:00
|
|
|
}
|
2013-11-17 05:18:10 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-25 17:52:02 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-02 17:22:43 +00:00
|
|
|
/* Need to tag armature for cow updates, or else selection doesn't update. */
|
2024-02-19 15:54:08 +01:00
|
|
|
DEG_id_tag_update(&arm->id, ID_RECALC_SYNC_TO_EVAL);
|
2018-04-25 17:52:02 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-07 22:27:07 -06:00
|
|
|
ED_outliner_select_sync_from_pose_bone_tag(C);
|
|
|
|
|
|
2013-11-17 05:18:10 +11:00
|
|
|
return OPERATOR_FINISHED;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-17 05:18:10 +11:00
|
|
|
void POSE_OT_select_mirror(wmOperatorType *ot)
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2021-04-12 14:18:05 -04:00
|
|
|
ot->name = "Select Mirror";
|
2013-11-17 05:18:10 +11:00
|
|
|
ot->idname = "POSE_OT_select_mirror";
|
|
|
|
|
ot->description = "Mirror the bone selection";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-17 09:18:03 +10:00
|
|
|
/* API callbacks. */
|
2013-11-17 05:18:10 +11:00
|
|
|
ot->exec = pose_select_mirror_exec;
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
ot->poll = ED_operator_posemode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-17 04:41:37 +11:00
|
|
|
/* properties */
|
|
|
|
|
RNA_def_boolean(
|
|
|
|
|
ot->srna, "only_active", false, "Active Only", "Only operate on the active bone");
|
|
|
|
|
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
|
Code Maintenance - Splitting up Armature/Pose Editing Files
This commit splits editarmature.c and poseobject.c into several files, such that
certain types of functionality are (mostly) self-contained within particular
files (instead of being mixed in with other functionality in a large file).
In particular, this was done so that:
1) Armature EditMode tools are now in the armature_*.c files only, and Pose Mode
tools in pose_*.c files only.
- In one or two cases, this hasn't been possible as the two modes rely on
much of the same shared infrastructure.
2) The "clear loc/rot/scale" operators and pose show/hide are no longer housed
in editarmature.c
3) Selection operators, Transform operators, structural (add/delete) operators,
and supporting utilities for the modes (enter/exit/roll-calculations) are not
all interleaved in an ad-hoc manner
Notes:
* I've tried to ensure that the history of the new files has been maintained by
doing
svn copy {editarmature.c/poseobject.c} {armature_*.c/pose_*.c}
Unfortunately, this means that the diffs are a bit messy.
* There should be no functional/logic changes here. Just code moving around and
cosmetic comment tweaks where needed.
* #includes have largely been untouched for now, but could be cleaned up later
* CMake changes untested, but should work in theory.
2013-02-27 23:34:29 +00:00
|
|
|
}
|