forked from bartvdbraak/blender
Fix T66950: WeightPaint Bone Selection Overlay
In weightpaint it is possible to enable the bone selection mode. During drawing the overlay was rendered, but during selection this was ignored. Users needed to double click in order to select bones even when the overlay was enabled. This patch makes bone selection possible during weight painting using the pose mode bone selection overlay with a single click. Reviewed By: fclem, campbellbarton Differential Revision: https://developer.blender.org/D5629
This commit is contained in:
parent
97f7f5fdbb
commit
fc99297411
@ -96,7 +96,7 @@ typedef struct bContextStore {
|
||||
|
||||
/* for the context's rna mode enum
|
||||
* keep aligned with data_mode_strings in context.c */
|
||||
enum eContextObjectMode {
|
||||
typedef enum eContextObjectMode {
|
||||
CTX_MODE_EDIT_MESH = 0,
|
||||
CTX_MODE_EDIT_CURVE,
|
||||
CTX_MODE_EDIT_SURFACE,
|
||||
@ -115,7 +115,7 @@ enum eContextObjectMode {
|
||||
CTX_MODE_EDIT_GPENCIL,
|
||||
CTX_MODE_SCULPT_GPENCIL,
|
||||
CTX_MODE_WEIGHT_GPENCIL,
|
||||
};
|
||||
} eContextObjectMode;
|
||||
#define CTX_MODE_NUM (CTX_MODE_WEIGHT_GPENCIL + 1)
|
||||
|
||||
/* Context */
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "BKE_anim.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_global.h"
|
||||
@ -41,6 +42,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_mball.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_paint.h"
|
||||
@ -2204,24 +2206,43 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
|
||||
drw_state_prepare_clean_for_draw(&DST);
|
||||
|
||||
bool use_obedit = false;
|
||||
int obedit_mode = 0;
|
||||
/* obedit_ctx_mode is used for selecting the right draw engines */
|
||||
eContextObjectMode obedit_ctx_mode;
|
||||
/* object_mode is used for filtering objects in the depsgraph */
|
||||
eObjectMode object_mode;
|
||||
int object_type = 0;
|
||||
if (obedit != NULL) {
|
||||
object_type = obedit->type;
|
||||
object_mode = obedit->mode;
|
||||
if (obedit->type == OB_MBALL) {
|
||||
use_obedit = true;
|
||||
obedit_mode = CTX_MODE_EDIT_METABALL;
|
||||
obedit_ctx_mode = CTX_MODE_EDIT_METABALL;
|
||||
}
|
||||
else if (obedit->type == OB_ARMATURE) {
|
||||
use_obedit = true;
|
||||
obedit_mode = CTX_MODE_EDIT_ARMATURE;
|
||||
obedit_ctx_mode = CTX_MODE_EDIT_ARMATURE;
|
||||
}
|
||||
}
|
||||
if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) {
|
||||
if (!(v3d->flag2 & V3D_HIDE_OVERLAYS)) {
|
||||
/* Note: don't use "BKE_object_pose_armature_get" here, it breaks selection. */
|
||||
Object *obpose = OBPOSE_FROM_OBACT(obact);
|
||||
if (obpose == NULL) {
|
||||
Object *obweight = OBWEIGHTPAINT_FROM_OBACT(obact);
|
||||
if (obweight) {
|
||||
/* Only use Armature pose selection, when connected armature is in pose mode. */
|
||||
Object *ob_armature = modifiers_isDeformedByArmature(obweight);
|
||||
if (ob_armature && ob_armature->mode == OB_MODE_POSE) {
|
||||
obpose = ob_armature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obpose) {
|
||||
use_obedit = true;
|
||||
obedit_mode = CTX_MODE_POSE;
|
||||
object_type = obpose->type;
|
||||
object_mode = obpose->mode;
|
||||
obedit_ctx_mode = CTX_MODE_POSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2235,8 +2256,8 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
|
||||
|
||||
/* Get list of enabled engines */
|
||||
if (use_obedit) {
|
||||
drw_engines_enable_from_paint_mode(obedit_mode);
|
||||
drw_engines_enable_from_mode(obedit_mode);
|
||||
drw_engines_enable_from_paint_mode(obedit_ctx_mode);
|
||||
drw_engines_enable_from_mode(obedit_ctx_mode);
|
||||
}
|
||||
else if (!draw_surface) {
|
||||
/* grease pencil selection */
|
||||
@ -2283,7 +2304,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
|
||||
drw_engines_world_update(scene);
|
||||
|
||||
if (use_obedit) {
|
||||
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, obact->type, obact->mode, ob_iter) {
|
||||
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, object_type, object_mode, ob_iter) {
|
||||
drw_engines_cache_populate(ob_iter);
|
||||
}
|
||||
FOREACH_OBJECT_IN_MODE_END;
|
||||
|
@ -2002,6 +2002,8 @@ extern const char *RE_engine_id_CYCLES;
|
||||
(((workspace)->object_mode & OD_MODE_EDIT) ? OBACT(_view_layer) : NULL)
|
||||
#define OBEDIT_FROM_OBACT(ob) ((ob) ? (((ob)->mode & OB_MODE_EDIT) ? ob : NULL) : NULL)
|
||||
#define OBPOSE_FROM_OBACT(ob) ((ob) ? (((ob)->mode & OB_MODE_POSE) ? ob : NULL) : NULL)
|
||||
#define OBWEIGHTPAINT_FROM_OBACT(ob) \
|
||||
((ob) ? (((ob)->mode & OB_MODE_WEIGHT_PAINT) ? ob : NULL) : NULL)
|
||||
#define OBEDIT_FROM_VIEW_LAYER(view_layer) OBEDIT_FROM_OBACT(OBACT(view_layer))
|
||||
|
||||
#define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user