diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-16 17:27:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-16 18:56:50 +0300 |
commit | bfc9d426bb95e2bc0dd4541d6b4c5f802909149c (patch) | |
tree | 37702887bc3185309a13612613efd2752ebe0639 /source/blender/editors/screen/screen_context.c | |
parent | 80bb4254c6fb638cee0d33868c81c76c104817bf (diff) |
Multi-Object Editing
This adds initial multi-object editing support.
- Selected objects are used when entering edit & pose modes.
- Selection & tools work on all objects however many tools need porting
See: T54641 for remaining tasks.
Indentation will be done separately.
See patch: D3101
Diffstat (limited to 'source/blender/editors/screen/screen_context.c')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 343e615f76b..c023c5d90bc 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -30,6 +30,8 @@ #include <stdlib.h> #include <string.h> +#include "MEM_guardedalloc.h" + #include "DNA_object_types.h" #include "DNA_armature_types.h" #include "DNA_gpencil_types.h" @@ -42,7 +44,6 @@ #include "BLI_utildefines.h" - #include "BKE_context.h" #include "BKE_object.h" #include "BKE_action.h" @@ -209,6 +210,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult const bool editable_bones = CTX_data_equals(member, "editable_bones"); if (arm && arm->edbo) { + uint objects_len; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint i = 0; i < objects_len; i++) { + Object *ob = objects[i]; + arm = ob->data; + /* Attention: X-Axis Mirroring is also handled here... */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ @@ -241,6 +248,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } } + } + MEM_freeN(objects); + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } @@ -251,6 +261,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); if (arm && arm->edbo) { + uint objects_len; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint i = 0; i < objects_len; i++) { + Object *ob = objects[i]; + arm = ob->data; + /* Attention: X-Axis Mirroring is also handled here... */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ @@ -283,6 +299,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } } + } + MEM_freeN(objects); + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } @@ -293,12 +312,24 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + if (obpose != obact) { + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { + /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ + if (PBONE_VISIBLE(arm, pchan->bone)) { + CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + } } } + else if (obact->mode & OB_MODE_POSE) { + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obact->mode, ob_iter) { + for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ + if (PBONE_VISIBLE(arm, pchan->bone)) { + CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); + } + } + } FOREACH_OBJECT_IN_MODE_END; + } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } @@ -309,13 +340,28 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { - /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ - if (PBONE_VISIBLE(arm, pchan->bone)) { - if (pchan->bone->flag & BONE_SELECTED) - CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + if (obpose != obact) { + /* TODO(de-duplicate!) */ + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { + /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ + if (PBONE_VISIBLE(arm, pchan->bone)) { + if (pchan->bone->flag & BONE_SELECTED) + CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); + } } } + else if (obact->mode & OB_MODE_POSE) { + /* TODO(de-duplicate!) */ + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) { + for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ + if (PBONE_VISIBLE(arm, pchan->bone)) { + if (pchan->bone->flag & BONE_SELECTED) + CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); + } + } + } FOREACH_OBJECT_IN_MODE_END; + } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } |