diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-08-15 14:37:26 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-08-15 14:37:26 +0400 |
commit | 674d1b8d68330113967fd0bb6b34edaf9c619cae (patch) | |
tree | dc32f16eb7244ec12fe22de21ccdf09db32a3dc1 /source/blender/editors/object/object_select.c | |
parent | c8ae881b619ec2d2d05b3c55283ca1f4c69828ca (diff) |
Select by Keying Set...
* Split off code to refresh relative/builtin KeyingSets for the
current context before they get used to a separate function.
* Hooked this up to a new PyAPI/RNA function: KeyingSet.refresh().
Call this before checking the paths that a Keying Set has, especially
if it is not "absolute"
* Added option for "Select Grouped" operator (for Objects), which will
select all objects affected by the active Keying Set. This is probably
more useful for absolute KeyingSets, where changing the selection is
less likely to affect the result.
- The equivalent for bones is currently still in development, but is
likely to be more useful for animators, where rigs are the primary
animation entities they deal with
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r-- | source/blender/editors/object/object_select.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index a3bd399a60c..b3c4ffc0ac9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" @@ -65,6 +66,7 @@ #include "ED_object.h" #include "ED_screen.h" +#include "ED_keyframing.h" #include "UI_interface.h" #include "UI_resources.h" @@ -363,6 +365,7 @@ static EnumPropertyItem prop_select_grouped_types[] = { {9, "PASS", 0, "Pass", "Render pass Index"}, {10, "COLOR", 0, "Color", "Object Color"}, {11, "PROPERTIES", 0, "Properties", "Game Properties"}, + {12, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"}, {0, NULL, 0, NULL, NULL} }; @@ -574,6 +577,42 @@ static short select_grouped_gameprops(bContext *C, Object *ob) return changed; } +static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) +{ + KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); + short changed = 0; + + /* firstly, validate KeyingSet */ + if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0)) + return 0; + + /* select each object that Keying Set refers to */ + // TODO: perhaps to be more in line with the rest of these, we should only take objects + // if the passed in object is included in this too + CTX_DATA_BEGIN(C, Base*, base, selectable_bases) + { + /* only check for this object if it isn't selected already, to limit time wasted */ + if ((base->flag & SELECT) == 0) { + KS_Path *ksp; + + /* this is the slow way... we could end up with > 500 items here, + * with none matching, but end up doing this on 1000 objects... + */ + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + /* if id matches, select then stop looping (match found) */ + if (ksp->id == base->object) { + ED_base_object_select(base, BA_SELECT); + changed = 1; + break; + } + } + } + } + CTX_DATA_END; + + return changed; +} + static int object_select_grouped_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); @@ -608,6 +647,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) else if(nr==9) changed |= select_grouped_index_object(C, ob); else if(nr==10) changed |= select_grouped_color(C, ob); else if(nr==11) changed |= select_grouped_gameprops(C, ob); + else if(nr==12) changed |= select_grouped_keyingset(C, ob); if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); |