Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-06 09:06:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-06 10:03:28 +0300
commitc7fecab2efd3b28a18b56dbd321616728d8b7cce (patch)
tree0169ab63925ce3d6730f519a4a54822e7f77c652 /source/blender/editors/object/object_vgroup.c
parentef11113399e3273ee647b3710b346356a2b5f8f0 (diff)
Object Mode: Use eval_ctx mode for drawing, paint & modifiers
Diffstat (limited to 'source/blender/editors/object/object_vgroup.c')
-rw-r--r--source/blender/editors/object/object_vgroup.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 8a172f86624..035d3d38436 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -84,9 +84,9 @@
#include "object_intern.h"
/************************ Exported Functions **********************/
-static bool vertex_group_use_vert_sel(Object *ob)
+static bool vertex_group_use_vert_sel(const Object *ob)
{
- if (ob->mode == OB_MODE_EDIT) {
+ if (BKE_object_is_in_editmode(ob)) {
return true;
}
else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) {
@@ -107,13 +107,15 @@ static Lattice *vgroup_edit_lattice(Object *ob)
bool ED_vgroup_sync_from_pose(Object *ob)
{
Object *armobj = BKE_object_pose_armature_get(ob);
- if (armobj && (armobj->mode & OB_MODE_POSE)) {
+ if (armobj) {
struct bArmature *arm = armobj->data;
- if (arm->act_bone) {
- int def_num = defgroup_name_index(ob, arm->act_bone->name);
- if (def_num != -1) {
- ob->actdef = def_num + 1;
- return true;
+ if (arm->flag & ARM_POSEMODE) {
+ if (arm->act_bone) {
+ int def_num = defgroup_name_index(ob, arm->act_bone->name);
+ if (def_num != -1) {
+ ob->actdef = def_num + 1;
+ return true;
+ }
}
}
}
@@ -2537,6 +2539,8 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
/* editmode _or_ weight paint vertex sel */
static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
@@ -2550,9 +2554,9 @@ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const
if (BKE_object_is_in_editmode_vgroup(ob)) {
return true;
}
- else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ else if (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) {
if (needs_select) {
- if (BKE_object_is_in_wpaint_select_vert(ob)) {
+ if (BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)) {
return true;
}
else {
@@ -2604,8 +2608,10 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C)
if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
return 0;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
if (!(BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob)))
+ BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)))
{
return 0;
}
@@ -2631,8 +2637,11 @@ static int vertex_group_vert_select_mesh_poll(bContext *C)
if (ob->type != OB_MESH)
return 0;
+
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
return (BKE_object_is_in_editmode_vgroup(ob) ||
- BKE_object_is_in_wpaint_select_vert(ob));
+ BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob));
}
static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3516,7 +3525,8 @@ static char *vgroup_init_remap(Object *ob)
return name_array;
}
-static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
+static int vgroup_do_remap(
+ const EvaluationContext *eval_ctx, Object *ob, const char *name_array, wmOperator *op)
{
MDeformVert *dvert = NULL;
bDeformGroup *def;
@@ -3537,7 +3547,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
BLI_assert(sort_map[i] != -1);
}
- if (ob->mode == OB_MODE_EDIT) {
+ if (eval_ctx->object_mode == OB_MODE_EDIT) {
if (ob->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -3635,6 +3645,8 @@ enum {
static int vertex_group_sort_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
char *name_array;
int ret;
@@ -3654,7 +3666,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
}
/*remap vgroup data to map to correct names*/
- ret = vgroup_do_remap(ob, name_array, op);
+ ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -3690,6 +3702,8 @@ void OBJECT_OT_vertex_group_sort(wmOperatorType *ot)
static int vgroup_move_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_context(C);
bDeformGroup *def;
char *name_array;
@@ -3704,7 +3718,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
name_array = vgroup_init_remap(ob);
if (BLI_listbase_link_move(&ob->defbase, def, dir)) {
- ret = vgroup_do_remap(ob, name_array, op);
+ ret = vgroup_do_remap(&eval_ctx, ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);