Edit Mode overlay: Update cache on selection

This commit is contained in:
Clément Foucault
2017-03-06 03:58:08 +01:00
parent 33c093ef70
commit d4e7288af9
3 changed files with 36 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ struct Batch;
struct Mesh;
void BKE_mesh_batch_cache_dirty(struct Mesh *me);
void BKE_mesh_batch_selection_dirty(struct Mesh *me);
void BKE_mesh_batch_cache_clear(struct Mesh *me);
void BKE_mesh_batch_cache_free(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_all_edges(struct Mesh *me);

View File

@@ -811,6 +811,30 @@ void BKE_mesh_batch_cache_dirty(struct Mesh *me)
}
}
void BKE_mesh_batch_selection_dirty(struct Mesh *me)
{
MeshBatchCache *cache = me->batch_cache;
if (cache) {
/* TODO Separate Flag vbo */
if (cache->overlay_triangles) {
Batch_discard_all(cache->overlay_triangles);
cache->overlay_triangles = NULL;
}
if (cache->overlay_loose_verts) {
Batch_discard_all(cache->overlay_loose_verts);
cache->overlay_loose_verts = NULL;
}
if (cache->overlay_loose_edges) {
Batch_discard_all(cache->overlay_loose_edges);
cache->overlay_loose_edges = NULL;
}
if (cache->overlay_facedots) {
Batch_discard_all(cache->overlay_facedots);
cache->overlay_facedots = NULL;
}
}
}
void BKE_mesh_batch_cache_clear(Mesh *me)
{
MeshBatchCache *cache = me->batch_cache;

View File

@@ -47,6 +47,7 @@
#include "BKE_icons.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh_render.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
@@ -893,9 +894,18 @@ static void view3d_main_region_listener(bScreen *sc, ScrArea *sa, ARegion *ar, w
break;
case NC_GEOM:
switch (wmn->data) {
case ND_SELECT:
{
if (scene->obedit) {
Object *ob = scene->obedit;
if (ob->type == OB_MESH) {
struct Mesh *me = ob->data;
BKE_mesh_batch_selection_dirty(me);
}
}
}
case ND_DATA:
case ND_VERTEX_GROUP:
case ND_SELECT:
ED_region_tag_redraw(ar);
break;
}