Fix T51559: Update draw cache when changing flat/smooth shading

This also renames some flags/variables to be more generic for updating
purposes. The call used here was previously only used for updating
paint data, but as it was reused here, flags and variables were renamed
to accomodate more clearly to the new usages.
This commit is contained in:
2017-06-26 14:52:59 +02:00
parent 37593b6a42
commit bafb904807
10 changed files with 21 additions and 20 deletions

View File

@@ -405,7 +405,7 @@ void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
BKE_MESH_BATCH_DIRTY_SELECT,
BKE_MESH_BATCH_DIRTY_PAINT,
BKE_MESH_BATCH_DIRTY_NOCHECK,
};
void BKE_mesh_batch_cache_dirty(struct Mesh *me, int mode);
void BKE_mesh_batch_cache_free(struct Mesh *me);

View File

@@ -74,7 +74,7 @@ bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
BLI_addtail(&ob->defbase, defgroup);
defgroup_unique_name(defgroup, ob);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
return defgroup;
}

View File

@@ -407,7 +407,7 @@ void BKE_object_defgroup_remove(Object *ob, bDeformGroup *defgroup)
else
object_defgroup_remove_object_mode(ob, defgroup);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
}
/**

View File

@@ -1392,7 +1392,7 @@ typedef struct MeshBatchCache {
/* settings to determine if cache is invalid */
bool is_dirty;
bool is_paint_dirty;
bool is_really_dirty; /* Instantly invalidates cache, skipping mesh check */
int edge_len;
int tri_len;
int poly_len;
@@ -1420,7 +1420,7 @@ static bool mesh_batch_cache_valid(Mesh *me)
return false;
}
if (cache->is_paint_dirty) {
if (cache->is_really_dirty) {
return false;
}
@@ -1467,7 +1467,7 @@ static void mesh_batch_cache_init(Mesh *me)
cache->mat_len = mesh_render_mat_len_get(me);
cache->is_dirty = false;
cache->is_paint_dirty = false;
cache->is_really_dirty = false;
}
static MeshBatchCache *mesh_batch_cache_get(Mesh *me)
@@ -1500,8 +1500,8 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
BATCH_DISCARD_ALL_SAFE(cache->overlay_facedots);
break;
case BKE_MESH_BATCH_DIRTY_PAINT:
cache->is_paint_dirty = true;
case BKE_MESH_BATCH_DIRTY_NOCHECK:
cache->is_really_dirty = true;
break;
default:
BLI_assert(0);

View File

@@ -92,7 +92,7 @@ static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata))
if (e_data.actdef != draw_ctx->obact->actdef) {
e_data.actdef = draw_ctx->obact->actdef;
BKE_mesh_batch_cache_dirty(draw_ctx->obact->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(draw_ctx->obact->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
}
if (!e_data.weight_face_shader) {

View File

@@ -107,7 +107,7 @@ void paintface_flush_flags(Object *ob, short flag)
GPU_drawobject_free(dm);
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_NOCHECK);
}
void paintface_hide(Object *ob, const bool unselected)
@@ -518,7 +518,7 @@ void paintvert_flush_flags(Object *ob)
}
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_NOCHECK);
}
/* note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)

View File

@@ -1263,6 +1263,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
if (ob->type == OB_MESH) {
BKE_mesh_smooth_flag_set(ob, !clear);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);

View File

@@ -1823,7 +1823,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
ED_vgroup_sync_from_pose(ob);
}
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
/* Weightpaint works by overriding colors in mesh,
* so need to make sure we recalc on enter and
@@ -2385,7 +2385,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* also needed for "View Selected" on last stroke */
paint_last_stroke_update(scene, vc->ar, mval);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
DEG_id_tag_update(ob->data, 0);
ED_region_tag_redraw(vc->ar);
@@ -2592,7 +2592,7 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_init(scene, ePaintVertex, PAINT_CURSOR_VERTEX_PAINT);
}
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
/* update modifier stack for mapping requirements */
DEG_id_tag_update(&me->id, 0);
@@ -2866,7 +2866,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* also needed for "View Selected" on last stroke */
paint_last_stroke_update(scene, vc->ar, mval);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
ED_region_tag_redraw(vc->ar);

View File

@@ -240,7 +240,7 @@ static void rna_Mesh_update_data_edit_color(Main *bmain, Scene *scene, PointerRN
static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
{
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_NOCHECK);
rna_Mesh_update_data(bmain, scene, ptr);
}
@@ -248,7 +248,7 @@ static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerR
static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr)
{
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_NOCHECK);
rna_Mesh_update_data(bmain, scene, ptr);
}
@@ -278,7 +278,7 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_FACE_SEL;
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_NOCHECK);
rna_Mesh_update_draw(bmain, scene, ptr);
}
@@ -290,7 +290,7 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_VERT_SEL;
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_NOCHECK);
rna_Mesh_update_draw(bmain, scene, ptr);
}

View File

@@ -2649,7 +2649,7 @@ static void rna_LayerCollectionEngineSettings_wire_update(bContext *C, PointerRN
Object *ob = OBACT_NEW;
if (ob != NULL && ob->type == OB_MESH) {
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK);
}
/* TODO(sergey): Use proper flag for tagging here. */