Blender V4.3
armature_select.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_string_utils.hh"
#include "BKE_action.hh"
#include "BKE_armature.hh"
#include "BKE_context.hh"
#include "BKE_layer.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BKE_report.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_armature.hh"
#include "ED_object.hh"
#include "ED_outliner.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_view3d.hh"
#include "DEG_depsgraph.hh"
#include "GPU_select.hh"
#include "ANIM_bone_collections.hh"
#include "ANIM_bonecolor.hh"
#include "armature_intern.hh"

Go to the source code of this file.

Macros

#define EBONE_PREV_FLAG_GET(ebone)   ((void)0, (ebone)->temp.i)
 
#define EBONE_PREV_FLAG_SET(ebone, val)   ((ebone)->temp.i = val)
 
#define CHECK_PARENT(ebone)
 
#define STRUCT_SIZE_AND_OFFSET(_struct, _member)    sizeof(_struct::_member), offsetof(_struct, _member)
 

Functions

Select Buffer Queries for PoseMode & EditMode
BaseED_armature_base_and_ebone_from_select_buffer (const Span< Base * > bases, const uint select_id, EditBone **r_ebone)
 
ObjectED_armature_object_and_ebone_from_select_buffer (const Span< Object * > objects, const uint select_id, EditBone **r_ebone)
 
BaseED_armature_base_and_pchan_from_select_buffer (const Span< Base * > bases, const uint select_id, bPoseChannel **r_pchan)
 
BaseED_armature_base_and_bone_from_select_buffer (const Span< Base * > bases, const uint select_id, Bone **r_bone)
 
Cursor Pick from Select Buffer API
static void * ed_armature_pick_bone_from_selectbuffer_impl (const bool is_editmode, const Span< Base * > bases, const Span< GPUSelectResult > hit_results, bool findunsel, bool do_nearest, Base **r_base)
 
EditBoneED_armature_pick_ebone_from_selectbuffer (const Span< Base * > bases, const GPUSelectResult *hit_results, const int hits, bool findunsel, bool do_nearest, Base **r_base)
 
bPoseChannelED_armature_pick_pchan_from_selectbuffer (const Span< Base * > bases, const GPUSelectResult *hit_results, const int hits, bool findunsel, bool do_nearest, Base **r_base)
 
BoneED_armature_pick_bone_from_selectbuffer (const Span< Base * > bases, const GPUSelectResult *hit_results, const int hits, bool findunsel, bool do_nearest, Base **r_base)
 
Cursor Pick API
static void * ed_armature_pick_bone_impl (const bool is_editmode, bContext *C, const int xy[2], bool findunsel, Base **r_base)
 
EditBoneED_armature_pick_ebone (bContext *C, const int xy[2], bool findunsel, Base **r_base)
 
bPoseChannelED_armature_pick_pchan (bContext *C, const int xy[2], bool findunsel, Base **r_base)
 
BoneED_armature_pick_bone (bContext *C, const int xy[2], bool findunsel, Base **r_base)
 
Select Linked Implementation

Shared logic for select linked all/pick.

Use BONE_DONE flag to select linked.

static bool armature_select_linked_impl (Object *ob, const bool select, const bool all_forks)
 
Select Linked Operator
static int armature_select_linked_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_select_linked (wmOperatorType *ot)
 
Select Linked (Cursor Pick) Operator
static int armature_select_linked_pick_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static bool armature_select_linked_pick_poll (bContext *C)
 
void ARMATURE_OT_select_linked_pick (wmOperatorType *ot)
 
Select Buffer Queries EditMode
static int selectbuffer_ret_hits_12 (blender::MutableSpan< GPUSelectResult >, const int hits12)
 
static int selectbuffer_ret_hits_5 (blender::MutableSpan< GPUSelectResult > hit_results, const int hits12, const int hits5)
 
static EditBoneget_nearest_editbonepoint (ViewContext *vc, bool findunsel, bool use_cycle, Base **r_base, int *r_selmask)
 
Select Utility Functions
bool ED_armature_edit_deselect_all (Object *obedit)
 
bool ED_armature_edit_deselect_all_visible (Object *obedit)
 
bool ED_armature_edit_deselect_all_multi_ex (const Span< Base * > bases)
 
bool ED_armature_edit_deselect_all_visible_multi_ex (const Span< Base * > bases)
 
bool ED_armature_edit_deselect_all_visible_multi (bContext *C)
 
Select Cursor Pick API
bool ED_armature_edit_select_pick_bone (bContext *C, Base *basact, EditBone *ebone, const int selmask, const SelectPick_Params *params)
 
bool ED_armature_edit_select_pick (bContext *C, const int mval[2], const SelectPick_Params *params)
 
Select Op From Tagged
static bool armature_edit_select_op_apply (bArmature *arm, EditBone *ebone, const eSelectOp sel_op, int is_ignore_flag, int is_inside_flag)
 
bool ED_armature_edit_select_op_from_tagged (bArmature *arm, const int sel_op)
 
(De)Select All Operator
static int armature_de_select_all_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_select_all (wmOperatorType *ot)
 
Select More/Less Implementation
static void armature_select_more (bArmature *arm, EditBone *ebone)
 
static void armature_select_less (bArmature *, EditBone *ebone)
 
static void armature_select_more_less (Object *ob, bool more)
 
Select More Operator
static int armature_de_select_more_exec (bContext *C, wmOperator *)
 
void ARMATURE_OT_select_more (wmOperatorType *ot)
 
Select Less Operator
static int armature_de_select_less_exec (bContext *C, wmOperator *)
 
void ARMATURE_OT_select_less (wmOperatorType *ot)
 
Select Hierarchy Operator
static int armature_select_hierarchy_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_select_hierarchy (wmOperatorType *ot)
 
Select Mirror Operator
static int armature_select_mirror_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_select_mirror (wmOperatorType *ot)
 
Select Path Operator
static bool armature_shortest_path_select (bArmature *arm, EditBone *ebone_parent, EditBone *ebone_child, bool use_parent, bool is_test)
 
static int armature_shortest_path_pick_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void ARMATURE_OT_shortest_path_pick (wmOperatorType *ot)
 

Select Similar

enum  {
  SIMEDBONE_CHILDREN = 1 , SIMEDBONE_CHILDREN_IMMEDIATE , SIMEDBONE_SIBLINGS , SIMEDBONE_LENGTH ,
  SIMEDBONE_DIRECTION , SIMEDBONE_PREFIX , SIMEDBONE_SUFFIX , SIMEDBONE_COLLECTION ,
  SIMEDBONE_COLOR , SIMEDBONE_SHAPE
}
 
static const EnumPropertyItem prop_similar_types []
 
static float bone_length_squared_worldspace_get (Object *ob, EditBone *ebone)
 
static void select_similar_length (bContext *C, const float thresh)
 
static void bone_direction_worldspace_get (Object *ob, EditBone *ebone, float *r_dir)
 
static void select_similar_direction (bContext *C, const float thresh)
 
static void select_similar_bone_collection (bContext *C)
 
static void select_similar_bone_color (bContext *C)
 
static void select_similar_prefix (bContext *C)
 
static void select_similar_suffix (bContext *C)
 
static void select_similar_data_pchan (bContext *C, const size_t bytes_size, const int offset)
 
static void is_ancestor (EditBone *bone, EditBone *ancestor)
 
static void select_similar_children (bContext *C)
 
static void select_similar_children_immediate (bContext *C)
 
static void select_similar_siblings (bContext *C)
 
static int armature_select_similar_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_select_similar (wmOperatorType *ot)
 

Detailed Description

API's and Operators for selecting armature bones in EditMode.

Definition in file armature_select.cc.

Macro Definition Documentation

◆ CHECK_PARENT

#define CHECK_PARENT ( ebone)
Value:
\
(((ebone)->flag & BONE_CONNECTED) && \
((ebone)->parent ? EBONE_SELECTABLE(arm, (ebone)->parent) : false))
@ BONE_CONNECTED
#define EBONE_SELECTABLE(arm, ebone)
uint8_t flag
Definition wm_window.cc:138

Referenced by armature_select_linked_impl().

◆ EBONE_PREV_FLAG_GET

#define EBONE_PREV_FLAG_GET ( ebone)    ((void)0, (ebone)->temp.i)

◆ EBONE_PREV_FLAG_SET

#define EBONE_PREV_FLAG_SET ( ebone,
val )   ((ebone)->temp.i = val)

Definition at line 57 of file armature_select.cc.

Referenced by armature_select_mirror_exec(), and armature_select_more_less().

◆ STRUCT_SIZE_AND_OFFSET

#define STRUCT_SIZE_AND_OFFSET ( _struct,
_member )    sizeof(_struct::_member), offsetof(_struct, _member)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SIMEDBONE_CHILDREN 
SIMEDBONE_CHILDREN_IMMEDIATE 
SIMEDBONE_SIBLINGS 
SIMEDBONE_LENGTH 
SIMEDBONE_DIRECTION 
SIMEDBONE_PREFIX 
SIMEDBONE_SUFFIX 
SIMEDBONE_COLLECTION 
SIMEDBONE_COLOR 
SIMEDBONE_SHAPE 

Definition at line 1573 of file armature_select.cc.

Function Documentation

◆ armature_de_select_all_exec()

◆ armature_de_select_less_exec()

◆ armature_de_select_more_exec()

◆ armature_edit_select_op_apply()

static bool armature_edit_select_op_apply ( bArmature * arm,
EditBone * ebone,
const eSelectOp sel_op,
int is_ignore_flag,
int is_inside_flag )
static

◆ ARMATURE_OT_select_all()

◆ ARMATURE_OT_select_hierarchy()

◆ ARMATURE_OT_select_less()

◆ ARMATURE_OT_select_linked()

◆ ARMATURE_OT_select_linked_pick()

◆ ARMATURE_OT_select_mirror()

◆ ARMATURE_OT_select_more()

◆ ARMATURE_OT_select_similar()

◆ ARMATURE_OT_shortest_path_pick()

◆ armature_select_hierarchy_exec()

◆ armature_select_less()

◆ armature_select_linked_exec()

◆ armature_select_linked_impl()

static bool armature_select_linked_impl ( Object * ob,
const bool select,
const bool all_forks )
static
Parameters
all_forksControl how chains are stepped over. true: select all connected bones traveling up & down forks. false: select all parents and all children, but not the children of the root bone.

Definition at line 389 of file armature_select.cc.

References BONE_DONE, CHECK_PARENT, Object::data, DEG_id_tag_update(), ED_armature_ebone_select_set(), ED_armature_edit_sync_selection(), bArmature::edbo, EditBone::i, bArmature::id, ID_RECALC_SYNC_TO_EVAL, LISTBASE_FOREACH, NA_EDITED, NC_GPENCIL, ND_DATA, EditBone::parent, select(), EditBone::temp, and WM_main_add_notifier().

Referenced by armature_select_linked_exec(), and armature_select_linked_pick_invoke().

◆ armature_select_linked_pick_invoke()

◆ armature_select_linked_pick_poll()

static bool armature_select_linked_pick_poll ( bContext * C)
static

◆ armature_select_mirror_exec()

◆ armature_select_more()

◆ armature_select_more_less()

◆ armature_select_similar_exec()

◆ armature_shortest_path_pick_invoke()

◆ armature_shortest_path_select()

static bool armature_shortest_path_select ( bArmature * arm,
EditBone * ebone_parent,
EditBone * ebone_child,
bool use_parent,
bool is_test )
static

◆ bone_direction_worldspace_get()

static void bone_direction_worldspace_get ( Object * ob,
EditBone * ebone,
float * r_dir )
static

◆ bone_length_squared_worldspace_get()

static float bone_length_squared_worldspace_get ( Object * ob,
EditBone * ebone )
static

◆ ED_armature_base_and_bone_from_select_buffer()

Base * ED_armature_base_and_bone_from_select_buffer ( const Span< Base * > bases,
const uint select_id,
Bone ** r_bone )

◆ ED_armature_base_and_ebone_from_select_buffer()

Base * ED_armature_base_and_ebone_from_select_buffer ( const Span< Base * > bases,
const uint select_id,
EditBone ** r_ebone )

◆ ED_armature_base_and_pchan_from_select_buffer()

Base * ED_armature_base_and_pchan_from_select_buffer ( const Span< Base * > bases,
const uint select_id,
bPoseChannel ** r_pchan )

◆ ED_armature_edit_deselect_all()

◆ ED_armature_edit_deselect_all_multi_ex()

bool ED_armature_edit_deselect_all_multi_ex ( const Span< Base * > bases)

◆ ED_armature_edit_deselect_all_visible()

◆ ED_armature_edit_deselect_all_visible_multi()

◆ ED_armature_edit_deselect_all_visible_multi_ex()

bool ED_armature_edit_deselect_all_visible_multi_ex ( const Span< Base * > bases)

Definition at line 934 of file armature_select.cc.

References ED_armature_edit_deselect_all_visible().

Referenced by do_armature_box_select().

◆ ED_armature_edit_select_op_from_tagged()

bool ED_armature_edit_select_op_from_tagged ( bArmature * arm,
int sel_op )

Perform a selection operation on elements which have been 'touched', use for lasso & border select but can be used elsewhere too.

Tagging is done via #EditBone.temp.i using: BONESEL_ROOT, BONESEL_TIP, BONESEL_BONE And optionally ignoring end-points using the BONESEL_ROOT, BONESEL_TIP right shifted 16 bits. (used when the values are clipped outside the view).

Parameters
sel_opeSelectOp type.
Note
Visibility checks must be done by the caller.

Definition at line 1224 of file armature_select.cc.

References armature_edit_select_op_apply(), BONE_CONNECTED, BONE_DONE, BONE_ROOTSEL, BONE_SELECTED, BONE_TIPSEL, BONESEL_BONE, BONESEL_ROOT, BONESEL_TIP, ED_armature_edit_sync_selection(), bArmature::edbo, ELEM, and LISTBASE_FOREACH.

Referenced by do_armature_box_select(), and do_lasso_select_armature().

◆ ED_armature_edit_select_pick()

bool ED_armature_edit_select_pick ( bContext * C,
const int mval[2],
const SelectPick_Params * params )

◆ ED_armature_edit_select_pick_bone()

◆ ED_armature_object_and_ebone_from_select_buffer()

Object * ED_armature_object_and_ebone_from_select_buffer ( const Span< Object * > objects,
const uint select_id,
EditBone ** r_ebone )

Definition at line 86 of file armature_select.cc.

References BLI_findlink(), Object::data, and bArmature::edbo.

◆ ED_armature_pick_bone()

Bone * ED_armature_pick_bone ( bContext * C,
const int xy[2],
bool findunsel,
Base ** r_base )

Definition at line 368 of file armature_select.cc.

References bPoseChannel::bone, ED_armature_pick_pchan(), and xy.

Referenced by pose_select_connected_invoke().

◆ ED_armature_pick_bone_from_selectbuffer()

Bone * ED_armature_pick_bone_from_selectbuffer ( const Span< Base * > bases,
const GPUSelectResult * hit_results,
const int hits,
bool findunsel,
bool do_nearest,
Base ** r_base )

◆ ed_armature_pick_bone_from_selectbuffer_impl()

static void * ed_armature_pick_bone_from_selectbuffer_impl ( const bool is_editmode,
const Span< Base * > bases,
const Span< GPUSelectResult > hit_results,
bool findunsel,
bool do_nearest,
Base ** r_base )
static

◆ ed_armature_pick_bone_impl()

◆ ED_armature_pick_ebone()

EditBone * ED_armature_pick_ebone ( bContext * C,
const int xy[2],
bool findunsel,
Base ** r_base )

◆ ED_armature_pick_ebone_from_selectbuffer()

EditBone * ED_armature_pick_ebone_from_selectbuffer ( const Span< Base * > bases,
const GPUSelectResult * hit_results,
const int hits,
bool findunsel,
bool do_nearest,
Base ** r_base )

◆ ED_armature_pick_pchan()

bPoseChannel * ED_armature_pick_pchan ( bContext * C,
const int xy[2],
bool findunsel,
Base ** r_base )

◆ ED_armature_pick_pchan_from_selectbuffer()

bPoseChannel * ED_armature_pick_pchan_from_selectbuffer ( const Span< Base * > bases,
const GPUSelectResult * hit_results,
const int hits,
bool findunsel,
bool do_nearest,
Base ** r_base )

◆ get_nearest_editbonepoint()

◆ is_ancestor()

static void is_ancestor ( EditBone * bone,
EditBone * ancestor )
static

Definition at line 1879 of file armature_select.cc.

References EditBone::ebone, ELEM, is_ancestor(), and EditBone::temp.

Referenced by is_ancestor(), and select_similar_children().

◆ select_similar_bone_collection()

◆ select_similar_bone_color()

◆ select_similar_children()

◆ select_similar_children_immediate()

◆ select_similar_data_pchan()

◆ select_similar_direction()

◆ select_similar_length()

◆ select_similar_prefix()

◆ select_similar_siblings()

◆ select_similar_suffix()

◆ selectbuffer_ret_hits_12()

static int selectbuffer_ret_hits_12 ( blender::MutableSpan< GPUSelectResult > ,
const int hits12 )
static

Definition at line 622 of file armature_select.cc.

Referenced by get_nearest_editbonepoint().

◆ selectbuffer_ret_hits_5()

static int selectbuffer_ret_hits_5 ( blender::MutableSpan< GPUSelectResult > hit_results,
const int hits12,
const int hits5 )
static

Variable Documentation

◆ prop_similar_types

const EnumPropertyItem prop_similar_types[]
static
Initial value:
= {
{SIMEDBONE_CHILDREN, "CHILDREN", 0, "Children", ""},
{SIMEDBONE_CHILDREN_IMMEDIATE, "CHILDREN_IMMEDIATE", 0, "Immediate Children", ""},
{SIMEDBONE_SIBLINGS, "SIBLINGS", 0, "Siblings", ""},
{SIMEDBONE_LENGTH, "LENGTH", 0, "Length", ""},
{SIMEDBONE_DIRECTION, "DIRECTION", 0, "Direction (Y Axis)", ""},
{SIMEDBONE_PREFIX, "PREFIX", 0, "Prefix", ""},
{SIMEDBONE_SUFFIX, "SUFFIX", 0, "Suffix", ""},
{SIMEDBONE_COLLECTION, "BONE_COLLECTION", 0, "Bone Collection", ""},
{SIMEDBONE_COLOR, "COLOR", 0, "Color", ""},
{SIMEDBONE_SHAPE, "SHAPE", 0, "Shape", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ SIMEDBONE_CHILDREN
@ SIMEDBONE_COLLECTION
@ SIMEDBONE_SUFFIX
@ SIMEDBONE_PREFIX
@ SIMEDBONE_DIRECTION
@ SIMEDBONE_LENGTH
@ SIMEDBONE_SIBLINGS
@ SIMEDBONE_SHAPE
@ SIMEDBONE_CHILDREN_IMMEDIATE
@ SIMEDBONE_COLOR

Definition at line 1586 of file armature_select.cc.

Referenced by ARMATURE_OT_select_similar().