Merging r57954 through r57961 from trunk into soc-2013-depsgraph_mt
This commit is contained in:
@@ -366,6 +366,7 @@ void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData
|
||||
const int numTex, const int numCol, const int hasPCol, const int hasOrigSpace);
|
||||
|
||||
void BKE_mesh_poly_edgehash_insert(struct EdgeHash *ehash, const struct MPoly *mp, const struct MLoop *mloop);
|
||||
void BKE_mesh_poly_edgebitmap_insert(unsigned int *edge_bitmap, const struct MPoly *mp, const struct MLoop *mloop);
|
||||
|
||||
void BKE_mesh_do_versions_cd_flag_init(struct Mesh *mesh);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_scanfill.h"
|
||||
#include "BLI_array.h"
|
||||
|
||||
@@ -3813,6 +3814,19 @@ void BKE_mesh_poly_edgehash_insert(EdgeHash *ehash, const MPoly *mp, const MLoop
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mesh_poly_edgebitmap_insert(unsigned int *edge_bitmap, const MPoly *mp, const MLoop *mloop)
|
||||
{
|
||||
const MLoop *ml;
|
||||
int i = mp->totloop;
|
||||
|
||||
ml = mloop;
|
||||
|
||||
while (i-- != 0) {
|
||||
BLI_BITMAP_SET(edge_bitmap, ml->e);
|
||||
ml++;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
|
||||
{
|
||||
if (UNLIKELY(mesh->cd_flag)) {
|
||||
|
||||
@@ -204,7 +204,7 @@ void paintface_flush_flags(struct Object *ob);
|
||||
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
|
||||
int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
|
||||
void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
|
||||
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], int mode);
|
||||
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
|
||||
bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
|
||||
|
||||
void paintface_hide(struct Object *ob, const bool unselected);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_bitmap.h"
|
||||
|
||||
#include "BLF_translation.h"
|
||||
|
||||
@@ -44,6 +45,7 @@
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
@@ -182,29 +184,22 @@ void paintface_reveal(Object *ob)
|
||||
|
||||
/* Set tface seams based on edge data, uses hash table to find seam edges. */
|
||||
|
||||
static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
|
||||
static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, const bool select)
|
||||
{
|
||||
EdgeHash *ehash, *seamhash;
|
||||
MPoly *mp;
|
||||
MLoop *ml;
|
||||
MEdge *med;
|
||||
char *linkflag;
|
||||
int a, b, mark = 0;
|
||||
int a, b;
|
||||
bool do_it = true;
|
||||
bool mark = false;
|
||||
|
||||
ehash = BLI_edgehash_new();
|
||||
seamhash = BLI_edgehash_new();
|
||||
linkflag = MEM_callocN(sizeof(char) * me->totpoly, "linkflaguv");
|
||||
BLI_bitmap edge_tag = BLI_BITMAP_NEW(me->totedge, __func__);
|
||||
BLI_bitmap poly_tag = BLI_BITMAP_NEW(me->totpoly, __func__);
|
||||
|
||||
for (med = me->medge, a = 0; a < me->totedge; a++, med++)
|
||||
if (med->flag & ME_SEAM)
|
||||
BLI_edgehash_insert(seamhash, med->v1, med->v2, NULL);
|
||||
|
||||
if (mode == 0 || mode == 1) {
|
||||
if (index != (unsigned int)-1) {
|
||||
/* only put face under cursor in array */
|
||||
mp = ((MPoly *)me->mpoly) + index;
|
||||
BKE_mesh_poly_edgehash_insert(ehash, mp, me->mloop + mp->loopstart);
|
||||
linkflag[index] = 1;
|
||||
mp = &me->mpoly[index];
|
||||
BKE_mesh_poly_edgebitmap_insert(edge_tag, mp, me->mloop + mp->loopstart);
|
||||
BLI_BITMAP_SET(poly_tag, index);
|
||||
}
|
||||
else {
|
||||
/* fill array by selection */
|
||||
@@ -214,8 +209,8 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
|
||||
/* pass */
|
||||
}
|
||||
else if (mp->flag & ME_FACE_SEL) {
|
||||
BKE_mesh_poly_edgehash_insert(ehash, mp, me->mloop + mp->loopstart);
|
||||
linkflag[a] = 1;
|
||||
BKE_mesh_poly_edgebitmap_insert(edge_tag, mp, me->mloop + mp->loopstart);
|
||||
BLI_BITMAP_SET(poly_tag, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,75 +224,54 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
|
||||
if (mp->flag & ME_HIDE)
|
||||
continue;
|
||||
|
||||
if (!linkflag[a]) {
|
||||
MLoop *mnextl;
|
||||
mark = 0;
|
||||
if (!BLI_BITMAP_GET(poly_tag, a)) {
|
||||
mark = false;
|
||||
|
||||
ml = me->mloop + mp->loopstart;
|
||||
for (b = 0; b < mp->totloop; b++, ml++) {
|
||||
mnextl = b < mp->totloop - 1 ? ml - 1 : me->mloop + mp->loopstart;
|
||||
if (!BLI_edgehash_haskey(seamhash, ml->v, mnextl->v))
|
||||
if (!BLI_edgehash_haskey(ehash, ml->v, mnextl->v))
|
||||
mark = 1;
|
||||
if ((me->medge[ml->e].flag & ME_SEAM) == 0) {
|
||||
if (BLI_BITMAP_GET(edge_tag, ml->e)) {
|
||||
mark = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mark) {
|
||||
linkflag[a] = 1;
|
||||
BKE_mesh_poly_edgehash_insert(ehash, mp, me->mloop + mp->loopstart);
|
||||
BLI_BITMAP_SET(poly_tag, a);
|
||||
BKE_mesh_poly_edgebitmap_insert(edge_tag, mp, me->mloop + mp->loopstart);
|
||||
do_it = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BLI_edgehash_free(ehash, NULL);
|
||||
BLI_edgehash_free(seamhash, NULL);
|
||||
MEM_freeN(edge_tag);
|
||||
|
||||
if (mode == 0 || mode == 2) {
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++)
|
||||
if (linkflag[a])
|
||||
mp->flag |= ME_FACE_SEL;
|
||||
else
|
||||
mp->flag &= ~ME_FACE_SEL;
|
||||
}
|
||||
else if (mode == 1) {
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++)
|
||||
if (linkflag[a] && (mp->flag & ME_FACE_SEL))
|
||||
break;
|
||||
|
||||
if (a < me->totpoly) {
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++)
|
||||
if (linkflag[a])
|
||||
mp->flag &= ~ME_FACE_SEL;
|
||||
}
|
||||
else {
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++)
|
||||
if (linkflag[a])
|
||||
mp->flag |= ME_FACE_SEL;
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) {
|
||||
if (BLI_BITMAP_GET(poly_tag, a)) {
|
||||
BKE_BIT_TEST_SET(mp->flag, select, ME_FACE_SEL);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(linkflag);
|
||||
MEM_freeN(poly_tag);
|
||||
}
|
||||
|
||||
void paintface_select_linked(bContext *UNUSED(C), Object *ob, const int UNUSED(mval[2]), int mode)
|
||||
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select)
|
||||
{
|
||||
Mesh *me;
|
||||
unsigned int index = 0;
|
||||
unsigned int index = (unsigned int)-1;
|
||||
|
||||
me = BKE_mesh_from_object(ob);
|
||||
if (me == NULL || me->totpoly == 0) return;
|
||||
|
||||
if (mode == 0 || mode == 1) {
|
||||
/* XXX - Causes glitches, not sure why */
|
||||
#if 0
|
||||
if (!ED_mesh_pick_face(C, me, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
|
||||
if (mval) {
|
||||
if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
select_linked_tfaces_with_seams(mode, me, index);
|
||||
select_linked_tfaces_with_seams(me, index, select);
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
}
|
||||
|
||||
@@ -1295,7 +1295,10 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_face_select_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0);
|
||||
kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", false);
|
||||
kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", true);
|
||||
|
||||
keymap = WM_keymap_find(keyconf, "UV Sculpt", 0, 0);
|
||||
keymap->poll = uv_sculpt_poll;
|
||||
|
||||
@@ -431,8 +431,9 @@ void PAINT_OT_face_select_linked(wmOperatorType *ot)
|
||||
|
||||
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int mode = RNA_boolean_get(op->ptr, "extend") ? 1 : 0;
|
||||
paintface_select_linked(C, CTX_data_active_object(C), event->mval, mode);
|
||||
const bool select = !RNA_boolean_get(op->ptr, "deselect");
|
||||
view3d_operator_needs_opengl(C);
|
||||
paintface_select_linked(C, CTX_data_active_object(C), event->mval, select);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -448,7 +449,7 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection");
|
||||
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user