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:
@@ -196,7 +196,7 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
|
|||||||
|
|
||||||
|
|
||||||
/* editface.c */
|
/* 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);
|
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);
|
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_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
|
||||||
|
|||||||
@@ -53,11 +53,13 @@
|
|||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
#include "GPU_buffers.h"
|
||||||
|
|
||||||
/* own include */
|
/* own include */
|
||||||
|
|
||||||
/* copy the face flags, most importantly selection from the mesh to the final derived mesh,
|
/* copy the face flags, most importantly selection from the mesh to the final derived mesh,
|
||||||
* use in object mode when selecting faces (while painting) */
|
* 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);
|
Mesh *me = BKE_mesh_from_object(ob);
|
||||||
DerivedMesh *dm = ob->derivedFinal;
|
DerivedMesh *dm = ob->derivedFinal;
|
||||||
@@ -66,6 +68,8 @@ void paintface_flush_flags(Object *ob)
|
|||||||
int totpoly;
|
int totpoly;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
|
||||||
|
|
||||||
if (me == NULL)
|
if (me == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -73,7 +77,9 @@ void paintface_flush_flags(Object *ob)
|
|||||||
|
|
||||||
/* we could call this directly in all areas that change selection,
|
/* we could call this directly in all areas that change selection,
|
||||||
* since this could become slow for realtime updates (circle-select for eg) */
|
* 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)
|
if (dm == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -90,9 +96,15 @@ void paintface_flush_flags(Object *ob)
|
|||||||
/* Copy flags onto the final derived poly from the original mesh poly */
|
/* Copy flags onto the final derived poly from the original mesh poly */
|
||||||
mp_orig = me->mpoly + index_array[i];
|
mp_orig = me->mpoly + index_array[i];
|
||||||
polys[i].flag = mp_orig->flag;
|
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)
|
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);
|
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);
|
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. */
|
/* 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);
|
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)
|
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) {
|
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 */
|
/* image window redraw */
|
||||||
|
|
||||||
paintface_flush_flags(ob);
|
paintface_flush_flags(ob, SELECT);
|
||||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
|
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
|
ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
|
||||||
return true;
|
return true;
|
||||||
@@ -454,7 +466,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
|
|||||||
glReadBuffer(GL_BACK);
|
glReadBuffer(GL_BACK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
paintface_flush_flags(vc->obact);
|
paintface_flush_flags(vc->obact, SELECT);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
|
|||||||
|
|
||||||
EDBM_backbuf_free();
|
EDBM_backbuf_free();
|
||||||
|
|
||||||
paintface_flush_flags(ob);
|
paintface_flush_flags(ob, SELECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -2462,7 +2462,7 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons
|
|||||||
if (bbsel) {
|
if (bbsel) {
|
||||||
edbm_backbuf_check_and_select_tfaces(me, select);
|
edbm_backbuf_check_and_select_tfaces(me, select);
|
||||||
EDBM_backbuf_free();
|
EDBM_backbuf_free();
|
||||||
paintface_flush_flags(ob);
|
paintface_flush_flags(ob, SELECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user