Fix T46867: Face-Mask hiding failed on mode switch
Since GPU refactor, hidden faces are cached. However this needs to be re-calculated when state of hidden faces changes.
This commit is contained in:
parent
d7d1fc5c74
commit
a9ddee0e56
Notes:
blender-bot
2023-02-14 08:24:09 +01:00
Referenced by issue #46867, Texture paint - "Face Selection Masking" doesn't reveal faces properly
|
@ -196,7 +196,7 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
|
|||
|
||||
|
||||
/* editface.c */
|
||||
void paintface_flush_flags(struct Object *ob);
|
||||
void paintface_flush_flags(struct Object *ob, short flag);
|
||||
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);
|
||||
|
|
|
@ -53,11 +53,13 @@
|
|||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "GPU_buffers.h"
|
||||
|
||||
/* own include */
|
||||
|
||||
/* copy the face flags, most importantly selection from the mesh to the final derived mesh,
|
||||
* use in object mode when selecting faces (while painting) */
|
||||
void paintface_flush_flags(Object *ob)
|
||||
void paintface_flush_flags(Object *ob, short flag)
|
||||
{
|
||||
Mesh *me = BKE_mesh_from_object(ob);
|
||||
DerivedMesh *dm = ob->derivedFinal;
|
||||
|
@ -66,6 +68,8 @@ void paintface_flush_flags(Object *ob)
|
|||
int totpoly;
|
||||
int i;
|
||||
|
||||
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
|
||||
|
||||
if (me == NULL)
|
||||
return;
|
||||
|
||||
|
@ -73,7 +77,9 @@ void paintface_flush_flags(Object *ob)
|
|||
|
||||
/* we could call this directly in all areas that change selection,
|
||||
* since this could become slow for realtime updates (circle-select for eg) */
|
||||
BKE_mesh_flush_select_from_polys(me);
|
||||
if (flag & SELECT) {
|
||||
BKE_mesh_flush_select_from_polys(me);
|
||||
}
|
||||
|
||||
if (dm == NULL)
|
||||
return;
|
||||
|
@ -90,9 +96,15 @@ void paintface_flush_flags(Object *ob)
|
|||
/* Copy flags onto the final derived poly from the original mesh poly */
|
||||
mp_orig = me->mpoly + index_array[i];
|
||||
polys[i].flag = mp_orig->flag;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag & ME_HIDE) {
|
||||
/* draw-object caches hidden faces, force re-generation T46867 */
|
||||
GPU_drawobject_free(dm);
|
||||
}
|
||||
}
|
||||
|
||||
void paintface_hide(Object *ob, const bool unselected)
|
||||
|
@ -122,7 +134,7 @@ void paintface_hide(Object *ob, const bool unselected)
|
|||
|
||||
BKE_mesh_flush_hidden_from_polys(me);
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT | ME_HIDE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,7 +159,7 @@ void paintface_reveal(Object *ob)
|
|||
|
||||
BKE_mesh_flush_hidden_from_polys(me);
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT | ME_HIDE);
|
||||
}
|
||||
|
||||
/* Set tface seams based on edge data, uses hash table to find seam edges. */
|
||||
|
@ -241,7 +253,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
|
|||
|
||||
select_linked_tfaces_with_seams(me, index, select);
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT);
|
||||
}
|
||||
|
||||
void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
|
||||
|
@ -287,7 +299,7 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
|
|||
}
|
||||
|
||||
if (flush_flags) {
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +388,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
|
|||
|
||||
/* image window redraw */
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
|
||||
ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
|
||||
return true;
|
||||
|
@ -454,7 +466,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
|
|||
glReadBuffer(GL_BACK);
|
||||
#endif
|
||||
|
||||
paintface_flush_flags(vc->obact);
|
||||
paintface_flush_flags(vc->obact, SELECT);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -784,7 +784,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
|
|||
|
||||
EDBM_backbuf_free();
|
||||
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -2462,7 +2462,7 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons
|
|||
if (bbsel) {
|
||||
edbm_backbuf_check_and_select_tfaces(me, select);
|
||||
EDBM_backbuf_free();
|
||||
paintface_flush_flags(ob);
|
||||
paintface_flush_flags(ob, SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue