Paint API: add BKE_paint_select_elem_test: to check on paint selection
This commit is contained in:
@@ -103,8 +103,9 @@ void BKE_paint_brush_set(struct Paint *paint, struct Brush *br);
|
||||
/* testing face select mode
|
||||
* Texture paint could be removed since selected faces are not used
|
||||
* however hiding faces is useful */
|
||||
bool paint_facesel_test(struct Object *ob);
|
||||
bool paint_vertsel_test(struct Object *ob);
|
||||
bool BKE_paint_select_face_test(struct Object *ob);
|
||||
bool BKE_paint_select_vert_test(struct Object *ob);
|
||||
bool BKE_paint_select_elem_test(struct Object *ob);
|
||||
|
||||
/* partial visibility */
|
||||
bool paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert);
|
||||
|
||||
@@ -2223,7 +2223,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
|
||||
int build_shapekey_layers)
|
||||
{
|
||||
Object *obact = scene->basact ? scene->basact->object : NULL;
|
||||
int editing = paint_facesel_test(ob);
|
||||
bool editing = BKE_paint_select_face_test(ob);
|
||||
/* weight paint and face select need original indices because of selection buffer drawing */
|
||||
int needMapping = (ob == obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)));
|
||||
|
||||
@@ -2286,7 +2286,7 @@ static CustomDataMask object_get_datamask(Scene *scene, Object *ob)
|
||||
|
||||
if (ob == actob) {
|
||||
/* check if we need tfaces & mcols due to face select or texture paint */
|
||||
if (paint_facesel_test(ob) || (ob->mode & OB_MODE_TEXTURE_PAINT)) {
|
||||
if (BKE_paint_select_face_test(ob) || (ob->mode & OB_MODE_TEXTURE_PAINT)) {
|
||||
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ void BKE_paint_brush_set(Paint *p, Brush *br)
|
||||
}
|
||||
|
||||
/* are we in vertex paint or weight pain face select mode? */
|
||||
bool paint_facesel_test(Object *ob)
|
||||
bool BKE_paint_select_face_test(Object *ob)
|
||||
{
|
||||
return ( (ob != NULL) &&
|
||||
(ob->type == OB_MESH) &&
|
||||
@@ -276,7 +276,7 @@ bool paint_facesel_test(Object *ob)
|
||||
}
|
||||
|
||||
/* are we in weight paint vertex select mode? */
|
||||
bool paint_vertsel_test(Object *ob)
|
||||
bool BKE_paint_select_vert_test(Object *ob)
|
||||
{
|
||||
return ( (ob != NULL) &&
|
||||
(ob->type == OB_MESH) &&
|
||||
@@ -286,6 +286,16 @@ bool paint_vertsel_test(Object *ob)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* used to check if selection is possible
|
||||
* (when we don't care if its face or vert)
|
||||
*/
|
||||
bool BKE_paint_select_elem_test(Object *ob)
|
||||
{
|
||||
return (BKE_paint_select_vert_test(ob) ||
|
||||
BKE_paint_select_face_test(ob));
|
||||
}
|
||||
|
||||
void BKE_paint_init(Paint *p, const char col[3])
|
||||
{
|
||||
Brush *brush;
|
||||
|
||||
@@ -271,7 +271,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
|
||||
|
||||
/* method in use for face selecting too */
|
||||
if (vc->obedit == NULL) {
|
||||
if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) {
|
||||
if (!BKE_paint_select_elem_test(vc->obact)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
|
||||
|
||||
/* method in use for face selecting too */
|
||||
if (vc->obedit == NULL) {
|
||||
if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) {
|
||||
if (!BKE_paint_select_elem_test(vc->obact)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,16 +1128,16 @@ int image_texture_paint_poll(bContext *C)
|
||||
|
||||
int facemask_paint_poll(bContext *C)
|
||||
{
|
||||
return paint_facesel_test(CTX_data_active_object(C));
|
||||
return BKE_paint_select_face_test(CTX_data_active_object(C));
|
||||
}
|
||||
|
||||
int vert_paint_poll(bContext *C)
|
||||
{
|
||||
return paint_vertsel_test(CTX_data_active_object(C));
|
||||
return BKE_paint_select_vert_test(CTX_data_active_object(C));
|
||||
}
|
||||
|
||||
int mask_paint_poll(bContext *C)
|
||||
{
|
||||
return paint_facesel_test(CTX_data_active_object(C)) || paint_vertsel_test(CTX_data_active_object(C));
|
||||
return BKE_paint_select_elem_test(CTX_data_active_object(C));
|
||||
}
|
||||
|
||||
|
||||
@@ -630,7 +630,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
|
||||
if (ob->mode & OB_MODE_EDIT)
|
||||
return;
|
||||
else if (ob == OBACT)
|
||||
if (paint_facesel_test(ob) || paint_vertsel_test(ob))
|
||||
if (BKE_paint_select_elem_test(ob))
|
||||
return;
|
||||
|
||||
ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
@@ -3412,7 +3412,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
|
||||
int /* totvert,*/ totedge, totface;
|
||||
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
||||
const bool is_obact = (ob == OBACT);
|
||||
int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
|
||||
int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
|
||||
|
||||
if (!dm)
|
||||
return;
|
||||
@@ -3622,7 +3622,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
|
||||
}
|
||||
}
|
||||
|
||||
if (is_obact && paint_vertsel_test(ob)) {
|
||||
if (is_obact && BKE_paint_select_vert_test(ob)) {
|
||||
const int use_depth = (v3d->flag & V3D_ZBUF_SELECT);
|
||||
glColor3f(0.0f, 0.0f, 0.0f);
|
||||
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
||||
|
||||
@@ -1276,7 +1276,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
|
||||
|
||||
if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
|
||||
paint_facesel_test(base->object)))
|
||||
BKE_paint_select_face_test(base->object)))
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
@@ -2745,7 +2745,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (paint_facesel_test(ob)) {
|
||||
else if (BKE_paint_select_face_test(ob)) {
|
||||
ok = paintface_minmax(ob, min, max);
|
||||
}
|
||||
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
||||
|
||||
@@ -275,7 +275,7 @@ static int view3d_selectable_data(bContext *C)
|
||||
}
|
||||
else {
|
||||
if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
|
||||
!paint_facesel_test(ob) && !paint_vertsel_test(ob))
|
||||
!BKE_paint_select_elem_test(ob))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -820,9 +820,9 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if (vc->obedit == NULL) { /* Object Mode */
|
||||
if (paint_facesel_test(ob))
|
||||
if (BKE_paint_select_face_test(ob))
|
||||
do_lasso_select_paintface(vc, mcords, moves, extend, select);
|
||||
else if (paint_vertsel_test(ob))
|
||||
else if (BKE_paint_select_vert_test(ob))
|
||||
do_lasso_select_paintvert(vc, mcords, moves, extend, select);
|
||||
else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
|
||||
/* pass */
|
||||
@@ -2122,10 +2122,10 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
|
||||
if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
|
||||
ret = do_sculpt_mask_box_select(&vc, &rect, select, extend);
|
||||
}
|
||||
else if (vc.obact && paint_facesel_test(vc.obact)) {
|
||||
else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
|
||||
ret = do_paintface_box_select(&vc, &rect, select, extend);
|
||||
}
|
||||
else if (vc.obact && paint_vertsel_test(vc.obact)) {
|
||||
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
|
||||
ret = do_paintvert_box_select(&vc, &rect, select, extend);
|
||||
}
|
||||
else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
|
||||
@@ -2252,9 +2252,9 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
|
||||
return PE_mouse_particles(C, location, extend, deselect, toggle);
|
||||
else if (obact && paint_facesel_test(obact))
|
||||
else if (obact && BKE_paint_select_face_test(obact))
|
||||
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
|
||||
else if (paint_vertsel_test(obact))
|
||||
else if (BKE_paint_select_vert_test(obact))
|
||||
retval = mouse_weight_paint_vertex_select(C, location, extend, deselect, toggle, obact);
|
||||
else
|
||||
retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate, object);
|
||||
@@ -2766,7 +2766,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
|
||||
const int mval[2] = {RNA_int_get(op->ptr, "x"),
|
||||
RNA_int_get(op->ptr, "y")};
|
||||
|
||||
if (CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) ||
|
||||
if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) ||
|
||||
(obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
|
||||
{
|
||||
ViewContext vc;
|
||||
@@ -2779,11 +2779,11 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
|
||||
obedit_circle_select(&vc, select, mval, (float)radius);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
|
||||
}
|
||||
else if (paint_facesel_test(obact)) {
|
||||
else if (BKE_paint_select_face_test(obact)) {
|
||||
paint_facesel_circle_select(&vc, select, mval, (float)radius);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
|
||||
}
|
||||
else if (paint_vertsel_test(obact)) {
|
||||
else if (BKE_paint_select_vert_test(obact)) {
|
||||
paint_vertsel_circle_select(&vc, select, mval, (float)radius);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user