Use the ultimate depsgraph callback function
Note: when in edit mode this depsgraph update is not being called. We are using DerivedMesh in those cases, so it is fine. I would like to investigate this though
This commit is contained in:
parent
9023abbf27
commit
4c43dddeb7
|
@ -32,6 +32,7 @@
|
|||
struct Batch;
|
||||
struct Mesh;
|
||||
|
||||
void BKE_mesh_batch_cache_dirty(struct Mesh *me);
|
||||
void BKE_mesh_batch_cache_free(struct Mesh *me);
|
||||
struct Batch *BKE_mesh_batch_cache_get_all_edges(struct Mesh *me);
|
||||
struct Batch *BKE_mesh_batch_cache_get_all_triangles(struct Mesh *me);
|
||||
|
|
|
@ -234,7 +234,8 @@ typedef struct MeshBatchCache {
|
|||
Batch *fancy_edges; /* owns its vertex buffer (not shared) */
|
||||
Batch *overlay_edges; /* owns its vertex buffer */
|
||||
|
||||
/* TODO: settings, before DEPSGRAPH update */
|
||||
/* settings to determine if cache is invalid */
|
||||
bool is_dirty;
|
||||
int tot_edges;
|
||||
int tot_faces;
|
||||
int tot_polys;
|
||||
|
@ -261,13 +262,17 @@ static bool mesh_batch_cache_valid(Mesh *me)
|
|||
}
|
||||
}
|
||||
|
||||
/* TODO: temporary check, waiting for depsgraph update */
|
||||
if ((cache->tot_edges != mesh_render_get_num_edges(me)) ||
|
||||
(cache->tot_faces != mesh_render_get_num_faces(me)) ||
|
||||
(cache->tot_polys != mesh_render_get_num_polys(me)) ||
|
||||
(cache->tot_verts != mesh_render_get_num_verts(me)))
|
||||
{
|
||||
return false;
|
||||
if (cache->is_dirty == false) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if ((cache->tot_edges != mesh_render_get_num_edges(me)) ||
|
||||
(cache->tot_faces != mesh_render_get_num_faces(me)) ||
|
||||
(cache->tot_polys != mesh_render_get_num_polys(me)) ||
|
||||
(cache->tot_verts != mesh_render_get_num_verts(me)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -287,6 +292,8 @@ static void mesh_batch_cache_init(Mesh *me)
|
|||
DerivedMesh *dm = me->edit_btmesh->derivedFinal;
|
||||
dm->dirty |= DM_MESH_BATCH_CACHE;
|
||||
}
|
||||
|
||||
cache->is_dirty = false;
|
||||
}
|
||||
|
||||
static MeshBatchCache *mesh_batch_cache_get(Mesh *me)
|
||||
|
@ -378,6 +385,14 @@ static ElementList *mesh_batch_cache_get_triangles_in_order(Mesh *me)
|
|||
return cache->triangles_in_order;
|
||||
}
|
||||
|
||||
void BKE_mesh_batch_cache_dirty(struct Mesh *me)
|
||||
{
|
||||
MeshBatchCache *cache = me->batch_cache;
|
||||
if (cache) {
|
||||
cache->is_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mesh_batch_cache_free(Mesh *me)
|
||||
{
|
||||
MeshBatchCache *cache = me->batch_cache;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "BKE_key.h"
|
||||
#include "BKE_lamp.h"
|
||||
#include "BKE_lattice.h"
|
||||
#include "BKE_mesh_render.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
|
@ -347,4 +348,7 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
|
|||
void BKE_object_eval_shading(EvaluationContext *UNUSED(eval_ctx), Object *ob)
|
||||
{
|
||||
DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
|
||||
if (ob->type == OB_MESH) {
|
||||
BKE_mesh_batch_cache_dirty(ob->data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue