From 0dd9e55d211453a6571fb5d3838c7d736434c8ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Nov 2019 03:11:56 +1100 Subject: Fix T71247: Outliner pose toggle looses bone selection The outliner didn't account for weight-paint + pose-mode, making it consider all pose bones unselected. When syncing selection, bones were unselected. This adds a context argument to passed to drawing functions since finding the weight-paint pose-object in the drawing loop isn't efficient. --- .../editors/space_outliner/outliner_utils.c | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/blender/editors/space_outliner/outliner_utils.c') diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 31d930ce2e6..c3984ab16fa 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -21,6 +21,8 @@ * \ingroup spoutliner */ +#include + #include "BLI_utildefines.h" #include "DNA_action_types.h" @@ -30,6 +32,7 @@ #include "BKE_context.h" #include "BKE_outliner_treehash.h" #include "BKE_layer.h" +#include "BKE_object.h" #include "ED_armature.h" #include "ED_outliner.h" @@ -39,6 +42,33 @@ #include "outliner_intern.h" +/* -------------------------------------------------------------------- */ +/** \name Tree View Context + * \{ */ + +void outliner_viewcontext_init(const bContext *C, TreeViewContext *tvc) +{ + memset(tvc, 0, sizeof(*tvc)); + + /* Scene level. */ + tvc->scene = CTX_data_scene(C); + tvc->view_layer = CTX_data_view_layer(C); + + /* Objects. */ + tvc->obact = OBACT(tvc->view_layer); + if (tvc->obact != NULL) { + tvc->ob_edit = OBEDIT_FROM_OBACT(tvc->obact); + + if ((tvc->obact->type == OB_ARMATURE) || + /* This could be made into it's own function. */ + ((tvc->obact->type == OB_MESH) && tvc->obact->mode & OB_MODE_WEIGHT_PAINT)) { + tvc->ob_pose = BKE_object_pose_armature_get(tvc->obact); + } + } +} + +/** \} */ + /** * Try to find an item under y-coordinate \a view_co_y (view-space). * \note Recursive -- cgit v1.2.3