GP: Remove DEG_get_original_id() from draw manager
Only keep this function when drawing to avoid COW overhead that reduce performance. After some changes I did some time ago, the use of original ID was not required and this only added depsgraph overhead and problems. This change solves the problems with updates in render mode. Related to T57484 and the changes requested by Sergey.
This commit is contained in:
@@ -42,7 +42,6 @@
|
||||
#include "draw_cache_impl.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
/* add a gpencil object to cache to defer drawing */
|
||||
tGPencilObjectCache *gpencil_object_cache_add(
|
||||
@@ -72,9 +71,8 @@ tGPencilObjectCache *gpencil_object_cache_add(
|
||||
cache_elem = &cache_array[*gp_cache_used];
|
||||
memset(cache_elem, 0, sizeof(*cache_elem));
|
||||
|
||||
Object *ob_orig = (Object *)DEG_get_original_id(&ob->id);
|
||||
cache_elem->ob = ob_orig;
|
||||
cache_elem->gpd = (bGPdata *)ob_orig->data;
|
||||
cache_elem->ob = ob;
|
||||
cache_elem->gpd = (bGPdata *)ob->data;
|
||||
copy_v3_v3(cache_elem->loc, ob->obmat[3]);
|
||||
copy_m4_m4(cache_elem->obmat, ob->obmat);
|
||||
cache_elem->idx = *gp_cache_used;
|
||||
@@ -85,7 +83,7 @@ tGPencilObjectCache *gpencil_object_cache_add(
|
||||
|
||||
/* save FXs */
|
||||
cache_elem->pixfactor = cache_elem->gpd->pixfactor;
|
||||
cache_elem->shader_fx = ob_orig->shader_fx;
|
||||
cache_elem->shader_fx = ob->shader_fx;
|
||||
|
||||
/* shgrp array */
|
||||
cache_elem->tot_layers = 0;
|
||||
@@ -171,8 +169,7 @@ GpencilBatchGroup *gpencil_group_cache_add(
|
||||
/* get current cache data */
|
||||
static GpencilBatchCache *gpencil_batch_get_element(Object *ob)
|
||||
{
|
||||
Object *ob_orig = (Object *)DEG_get_original_id(&ob->id);
|
||||
return ob_orig->runtime.gpencil_cache;
|
||||
return ob->runtime.gpencil_cache;
|
||||
}
|
||||
|
||||
/* verify if cache is valid */
|
||||
@@ -214,14 +211,13 @@ static bool gpencil_batch_cache_valid(GpencilBatchCache *cache, bGPdata *gpd, in
|
||||
/* cache init */
|
||||
static GpencilBatchCache *gpencil_batch_cache_init(Object *ob, int cfra)
|
||||
{
|
||||
Object *ob_orig = (Object *)DEG_get_original_id(&ob->id);
|
||||
bGPdata *gpd = (bGPdata *)ob_orig->data;
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
||||
GpencilBatchCache *cache = gpencil_batch_get_element(ob);
|
||||
|
||||
if (!cache) {
|
||||
cache = MEM_callocN(sizeof(*cache), __func__);
|
||||
ob_orig->runtime.gpencil_cache = cache;
|
||||
ob->runtime.gpencil_cache = cache;
|
||||
}
|
||||
else {
|
||||
memset(cache, 0, sizeof(*cache));
|
||||
@@ -277,8 +273,7 @@ static void gpencil_batch_cache_clear(GpencilBatchCache *cache)
|
||||
/* get cache */
|
||||
GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
|
||||
{
|
||||
Object *ob_orig = (Object *)DEG_get_original_id(&ob->id);
|
||||
bGPdata *gpd = (bGPdata *)ob_orig->data;
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
||||
GpencilBatchCache *cache = gpencil_batch_get_element(ob);
|
||||
if (!gpencil_batch_cache_valid(cache, gpd, cfra)) {
|
||||
@@ -295,8 +290,7 @@ GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
|
||||
/* set cache as dirty */
|
||||
void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
|
||||
{
|
||||
bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&gpd->id);
|
||||
gpd_orig->flag |= GP_DATA_CACHE_IS_DIRTY;
|
||||
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
|
||||
}
|
||||
|
||||
/* free batch cache */
|
||||
|
||||
@@ -1537,8 +1537,7 @@ void DRW_gpencil_populate_datablock(
|
||||
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(draw_ctx->depsgraph);
|
||||
Scene *scene = draw_ctx->scene;
|
||||
|
||||
bGPdata *gpd_eval = (bGPdata *)ob->data;
|
||||
bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
int cfra_eval = (int)DEG_get_ctime(draw_ctx->depsgraph);
|
||||
|
||||
Reference in New Issue
Block a user