Pose: support wpaint+pose w/ object-lock enabled

Mode locking made it nearly impossible to enter wpaint + object mode.

Now enter pose mode when entering wpaint mode
when the pose object is selected.
This commit is contained in:
Campbell Barton 2018-11-23 10:16:08 +11:00
parent 7b4f545e28
commit 73547952a9
1 changed files with 17 additions and 0 deletions

View File

@ -58,6 +58,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
#include "BKE_paint.h"
@ -71,6 +72,7 @@
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "ED_armature.h"
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_screen.h"
@ -1261,6 +1263,21 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_toolslots_brush_validate(bmain, &ts->wpaint->paint);
}
/* When locked, it's almost impossible to select the pose then the object to enter weight paint mode.
* In this case move our pose object in/out of pose mode.
* This is in fits with the convention of selecting multiple objects and entering a mode. */
if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) {
Object *ob_arm = modifiers_isDeformedByArmature(ob);
if (ob_arm && (ob_arm->base_flag & BASE_SELECTED)) {
if (ob_arm->mode & OB_MODE_POSE) {
ED_object_posemode_exit_ex(bmain, ob_arm);
}
else {
ED_object_posemode_enter_ex(bmain, ob_arm);
}
}
}
/* Weightpaint works by overriding colors in mesh,
* so need to make sure we recalc on enter and
* exit (exit needs doing regardless because we