Blender  V3.3
Macros
armature_select.c 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.h"
#include "BLI_rect.h"
#include "BLI_string_utils.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_layer.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_armature.h"
#include "ED_object.h"
#include "ED_outliner.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"
#include "GPU_select.h"
#include "armature_intern.h"

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 *)NULL)->_member), offsetof(_struct, _member)
 

Functions

Select Buffer Queries for PoseMode & EditMode
BaseED_armature_base_and_ebone_from_select_buffer (Base **bases, uint bases_len, const uint select_id, EditBone **r_ebone)
 
ObjectED_armature_object_and_ebone_from_select_buffer (Object **objects, uint objects_len, const uint select_id, EditBone **r_ebone)
 
BaseED_armature_base_and_pchan_from_select_buffer (Base **bases, uint bases_len, const uint select_id, bPoseChannel **r_pchan)
 
BaseED_armature_base_and_bone_from_select_buffer (Base **bases, uint bases_len, const uint select_id, Bone **r_bone)
 
Cursor Pick from Select Buffer API
static voided_armature_pick_bone_from_selectbuffer_impl (const bool is_editmode, Base **bases, uint bases_len, const GPUSelectResult *buffer, const short hits, bool findunsel, bool do_nearest, Base **r_base)
 
EditBoneED_armature_pick_ebone_from_selectbuffer (Base **bases, uint bases_len, const GPUSelectResult *buffer, const short hits, bool findunsel, bool do_nearest, Base **r_base)
 
bPoseChannelED_armature_pick_pchan_from_selectbuffer (Base **bases, uint bases_len, const GPUSelectResult *buffer, const short hits, bool findunsel, bool do_nearest, Base **r_base)
 
BoneED_armature_pick_bone_from_selectbuffer (Base **bases, uint bases_len, const GPUSelectResult *buffer, const short hits, bool findunsel, bool do_nearest, Base **r_base)
 
Cursor Pick API
static voided_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 (GPUSelectResult *UNUSED(buffer), const int hits12)
 
static int selectbuffer_ret_hits_5 (GPUSelectResult *buffer, 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 (struct Base **bases, uint bases_len)
 
bool ED_armature_edit_deselect_all_visible_multi_ex (struct Base **bases, uint bases_len)
 
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 struct SelectPick_Params *params)
 
bool ED_armature_edit_select_pick (bContext *C, const int mval[2], const struct 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 *UNUSED(arm), 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 *UNUSED(op))
 
void ARMATURE_OT_select_more (wmOperatorType *ot)
 
Select Less Operator
static int armature_de_select_less_exec (bContext *C, wmOperator *UNUSED(op))
 
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_LAYER ,
  SIMEDBONE_GROUP , 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_layer (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.c.

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)
Definition: ED_armature.h:52

◆ EBONE_PREV_FLAG_GET

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

Definition at line 47 of file armature_select.c.

◆ EBONE_PREV_FLAG_SET

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

Definition at line 48 of file armature_select.c.

◆ STRUCT_SIZE_AND_OFFSET

#define STRUCT_SIZE_AND_OFFSET (   _struct,
  _member 
)     sizeof(((_struct *)NULL)->_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_LAYER 
SIMEDBONE_GROUP 
SIMEDBONE_SHAPE 

Definition at line 1573 of file armature_select.c.

Function Documentation

◆ armature_de_select_all_exec()

static int armature_de_select_all_exec ( bContext C,
wmOperator op 
)
static

◆ armature_de_select_less_exec()

static int armature_de_select_less_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ armature_de_select_more_exec()

static int armature_de_select_more_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ 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()

void ARMATURE_OT_select_all ( wmOperatorType ot)

◆ ARMATURE_OT_select_hierarchy()

void ARMATURE_OT_select_hierarchy ( wmOperatorType ot)

◆ ARMATURE_OT_select_less()

void ARMATURE_OT_select_less ( wmOperatorType ot)

◆ ARMATURE_OT_select_linked()

void ARMATURE_OT_select_linked ( wmOperatorType ot)

◆ ARMATURE_OT_select_linked_pick()

void ARMATURE_OT_select_linked_pick ( wmOperatorType ot)

◆ ARMATURE_OT_select_mirror()

void ARMATURE_OT_select_mirror ( wmOperatorType ot)

◆ ARMATURE_OT_select_more()

void ARMATURE_OT_select_more ( wmOperatorType ot)

◆ ARMATURE_OT_select_similar()

void ARMATURE_OT_select_similar ( wmOperatorType ot)

◆ ARMATURE_OT_shortest_path_pick()

void ARMATURE_OT_shortest_path_pick ( wmOperatorType ot)

◆ armature_select_hierarchy_exec()

static int armature_select_hierarchy_exec ( bContext C,
wmOperator op 
)
static

◆ armature_select_less()

static void armature_select_less ( bArmature UNUSEDarm,
EditBone ebone 
)
static

◆ armature_select_linked_exec()

static int armature_select_linked_exec ( bContext C,
wmOperator op 
)
static

◆ 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 396 of file armature_select.c.

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_COPY_ON_WRITE, LISTBASE_FOREACH, NA_EDITED, NC_GPENCIL, ND_DATA, NULL, 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()

static int armature_select_linked_pick_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ armature_select_linked_pick_poll()

static bool armature_select_linked_pick_poll ( bContext C)
static

◆ armature_select_mirror_exec()

static int armature_select_mirror_exec ( bContext C,
wmOperator op 
)
static

◆ armature_select_more()

static void armature_select_more ( bArmature arm,
EditBone ebone 
)
static

◆ armature_select_more_less()

static void armature_select_more_less ( Object ob,
bool  more 
)
static

◆ armature_select_similar_exec()

static int armature_select_similar_exec ( bContext C,
wmOperator op 
)
static

◆ armature_shortest_path_pick_invoke()

static int armature_shortest_path_pick_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ 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 ( struct Base **  bases,
uint  bases_len,
unsigned int  select_id,
struct Bone **  r_bone 
)

For callers that don't need the pose channel.

Definition at line 128 of file armature_select.c.

References bPoseChannel::bone, ED_armature_base_and_pchan_from_select_buffer(), and NULL.

Referenced by do_pose_box_select().

◆ ED_armature_base_and_ebone_from_select_buffer()

Base* ED_armature_base_and_ebone_from_select_buffer ( Base **  bases,
uint  bases_len,
const uint  select_id,
EditBone **  r_ebone 
)

◆ ED_armature_base_and_pchan_from_select_buffer()

Base* ED_armature_base_and_pchan_from_select_buffer ( Base **  bases,
uint  bases_len,
const uint  select_id,
bPoseChannel **  r_pchan 
)

◆ ED_armature_edit_deselect_all()

bool ED_armature_edit_deselect_all ( Object obedit)

◆ ED_armature_edit_deselect_all_multi_ex()

bool ED_armature_edit_deselect_all_multi_ex ( struct Base **  bases,
uint  bases_len 
)

◆ ED_armature_edit_deselect_all_visible()

bool ED_armature_edit_deselect_all_visible ( Object obedit)

◆ ED_armature_edit_deselect_all_visible_multi()

bool ED_armature_edit_deselect_all_visible_multi ( bContext C)

◆ ED_armature_edit_deselect_all_visible_multi_ex()

bool ED_armature_edit_deselect_all_visible_multi_ex ( struct Base **  bases,
uint  bases_len 
)

Definition at line 921 of file armature_select.c.

References ED_armature_edit_deselect_all_visible(), and Base::object.

Referenced by do_armature_box_select().

◆ ED_armature_edit_select_op_from_tagged()

bool ED_armature_edit_select_op_from_tagged ( struct 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 1220 of file armature_select.c.

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(), ED_armature_edit_validate_active(), bArmature::edbo, ELEM, LISTBASE_FOREACH, and SWAP.

Referenced by do_armature_box_select(), and do_lasso_select_armature().

◆ ED_armature_edit_select_pick()

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

◆ ED_armature_edit_select_pick_bone()

bool ED_armature_edit_select_pick_bone ( struct bContext C,
struct Base basact,
struct EditBone ebone,
int  selmask,
const struct SelectPick_Params params 
)

◆ ED_armature_object_and_ebone_from_select_buffer()

Object* ED_armature_object_and_ebone_from_select_buffer ( Object **  objects,
uint  objects_len,
const uint  select_id,
EditBone **  r_ebone 
)

Definition at line 78 of file armature_select.c.

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

◆ ED_armature_pick_bone()

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

Definition at line 375 of file armature_select.c.

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

Referenced by pose_select_connected_invoke().

◆ ED_armature_pick_bone_from_selectbuffer()

Bone* ED_armature_pick_bone_from_selectbuffer ( Base **  bases,
uint  bases_len,
const GPUSelectResult buffer,
const short  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,
Base **  bases,
uint  bases_len,
const GPUSelectResult buffer,
const short  hits,
bool  findunsel,
bool  do_nearest,
Base **  r_base 
)
static

◆ ed_armature_pick_bone_impl()

static void* ed_armature_pick_bone_impl ( const bool  is_editmode,
bContext C,
const int  xy[2],
bool  findunsel,
Base **  r_base 
)
static

◆ 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 ( Base **  bases,
uint  bases_len,
const GPUSelectResult buffer,
const short  hits,
bool  findunsel,
bool  do_nearest,
Base **  r_base 
)

Definition at line 255 of file armature_select.c.

References buffer, and ed_armature_pick_bone_from_selectbuffer_impl().

◆ ED_armature_pick_pchan()

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

Definition at line 369 of file armature_select.c.

References C, ed_armature_pick_bone_impl(), and xy.

Referenced by ED_armature_pick_bone().

◆ ED_armature_pick_pchan_from_selectbuffer()

bPoseChannel* ED_armature_pick_pchan_from_selectbuffer ( Base **  bases,
uint  bases_len,
const GPUSelectResult buffer,
const short  hits,
bool  findunsel,
bool  do_nearest,
Base **  r_base 
)

◆ get_nearest_editbonepoint()

static EditBone* get_nearest_editbonepoint ( ViewContext vc,
bool  findunsel,
bool  use_cycle,
Base **  r_base,
int *  r_selmask 
)
static

◆ is_ancestor()

static void is_ancestor ( EditBone bone,
EditBone ancestor 
)
static

Definition at line 1842 of file armature_select.c.

References EditBone::ebone, ELEM, NULL, and EditBone::temp.

Referenced by select_similar_children().

◆ select_similar_children()

static void select_similar_children ( bContext C)
static

◆ select_similar_children_immediate()

static void select_similar_children_immediate ( bContext C)
static

◆ select_similar_data_pchan()

static void select_similar_data_pchan ( bContext C,
const size_t  bytes_size,
const int  offset 
)
static

◆ select_similar_direction()

static void select_similar_direction ( bContext C,
const float  thresh 
)
static

◆ select_similar_layer()

static void select_similar_layer ( bContext C)
static

◆ select_similar_length()

static void select_similar_length ( bContext C,
const float  thresh 
)
static

◆ select_similar_prefix()

static void select_similar_prefix ( bContext C)
static

◆ select_similar_siblings()

static void select_similar_siblings ( bContext C)
static

◆ select_similar_suffix()

static void select_similar_suffix ( bContext C)
static

◆ selectbuffer_ret_hits_12()

static int selectbuffer_ret_hits_12 ( GPUSelectResult UNUSEDbuffer,
const int  hits12 
)
static

Definition at line 625 of file armature_select.c.

Referenced by get_nearest_editbonepoint().

◆ selectbuffer_ret_hits_5()

static int selectbuffer_ret_hits_5 ( GPUSelectResult buffer,
const int  hits12,
const int  hits5 
)
static

Definition at line 630 of file armature_select.c.

References buffer.

Referenced by get_nearest_editbonepoint().

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_LAYER, "LAYER", 0, "Layer", ""},
{SIMEDBONE_GROUP, "GROUP", 0, "Group", ""},
{SIMEDBONE_SHAPE, "SHAPE", 0, "Shape", ""},
{0, NULL, 0, NULL, NULL},
}
@ SIMEDBONE_CHILDREN
@ SIMEDBONE_SUFFIX
@ SIMEDBONE_PREFIX
@ SIMEDBONE_DIRECTION
@ SIMEDBONE_LENGTH
@ SIMEDBONE_SIBLINGS
@ SIMEDBONE_SHAPE
@ SIMEDBONE_CHILDREN_IMMEDIATE
@ SIMEDBONE_GROUP
@ SIMEDBONE_LAYER

Definition at line 1586 of file armature_select.c.

Referenced by ARMATURE_OT_select_similar().