[Bf-blender-cvs] [28a6ed88855] greasepencil-object: Remove use of LIB_TAG_NO_MAIN for temp objects
Antonio Vazquez
noreply at git.blender.org
Wed Mar 21 16:47:15 CET 2018
Commit: 28a6ed88855f9ae3d74bbc3491a223503bfd6a45
Author: Antonio Vazquez
Date: Wed Mar 21 16:47:01 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB28a6ed88855f9ae3d74bbc3491a223503bfd6a45
Remove use of LIB_TAG_NO_MAIN for temp objects
Instead to use the tag to identify temp objects, now a internal flag managed by cache is used.
This is required because the LIB_TAG_NO_MAIN created conflicts with depsgraph.
This solves any concern of D3111
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 8895642190d..3c2231e41a8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -75,7 +75,7 @@ tGPencilObjectCache *gpencil_object_cache_allocate(tGPencilObjectCache *cache, i
}
/* add a gpencil object to cache to defer drawing */
-void gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, int *gp_cache_used)
+void gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, bool temp, int *gp_cache_used)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
tGPencilObjectCache *cache = &cache_array[*gp_cache_used];
@@ -86,7 +86,8 @@ void gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, int
/* save object */
cache->ob = ob;
-
+ cache->temp = temp;
+
cache->init_grp = 0;
cache->end_grp = -1;
@@ -1340,7 +1341,6 @@ static void gp_array_modifier_make_instances(GPENCIL_StorageList *stl, Object *o
/* add object to cache */
newob = MEM_dupallocN(ob);
- newob->id.tag |= LIB_TAG_NO_MAIN; /* use this mark to delete later */
mul_m4_m4m4(newob->obmat, ob->obmat, mat);
/* apply scale */
@@ -1358,7 +1358,7 @@ static void gp_array_modifier_make_instances(GPENCIL_StorageList *stl, Object *o
/* add temp object to cache */
stl->g_data->gp_object_cache = gpencil_object_cache_allocate(stl->g_data->gp_object_cache, &stl->g_data->gp_cache_size, &stl->g_data->gp_cache_used);
- gpencil_object_cache_add(stl->g_data->gp_object_cache, newob, &stl->g_data->gp_cache_used);
+ gpencil_object_cache_add(stl->g_data->gp_object_cache, newob, true, &stl->g_data->gp_cache_used);
}
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 7eb810a7766..7e2791ea308 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -484,7 +484,7 @@ static void GPENCIL_cache_populate(void *vedata, Object *ob)
stl->g_data->gp_object_cache = gpencil_object_cache_allocate(stl->g_data->gp_object_cache, &stl->g_data->gp_cache_size, &stl->g_data->gp_cache_used);
/* add for drawing later */
- gpencil_object_cache_add(stl->g_data->gp_object_cache, ob, &stl->g_data->gp_cache_used);
+ gpencil_object_cache_add(stl->g_data->gp_object_cache, ob, false, &stl->g_data->gp_cache_used);
/* generate instances as separate cache objects for array modifiers
* with the "Make as Objects" option enabled
@@ -685,13 +685,11 @@ static void gpencil_free_obj_list(GPENCIL_StorageList *stl)
* while the draw manager draw the scene, but only to hold the strokes data.
* see: gp_array_modifier_make_instances()
*
- * the normal objects are not freed because they are not tagged with NO_MAIN
+ * the normal objects are not freed because they are not tagged as temp objects
*/
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
Object *ob = stl->g_data->gp_object_cache[i].ob;
- if (((ob->id.tag & LIB_TAG_COPY_ON_WRITE) == 0) &&
- (ob->id.tag & LIB_TAG_NO_MAIN))
- {
+ if (stl->g_data->gp_object_cache[i].temp) {
MEM_SAFE_FREE(ob);
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 6f1d274b887..fac838c876c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -127,6 +127,7 @@ typedef struct tGPencilObjectCache {
DRWShadingGroup *vfx_light_sh;
float zdepth;
+ bool temp;
} tGPencilObjectCache;
/* *********** LISTS *********** */
@@ -350,7 +351,7 @@ struct GPUTexture *DRW_gpencil_create_blank_texture(int width, int height);
bool gpencil_can_draw_stroke(const struct bGPDstroke *gps, const bool onion);
struct tGPencilObjectCache *gpencil_object_cache_allocate(struct tGPencilObjectCache *cache, int *gp_cache_size, int *gp_cache_used);
-void gpencil_object_cache_add(struct tGPencilObjectCache *cache, struct Object *ob, int *gp_cache_used);
+void gpencil_object_cache_add(struct tGPencilObjectCache *cache, struct Object *ob, bool temp, int *gp_cache_used);
void gpencil_array_modifiers(struct GPENCIL_StorageList *stl, struct Object *ob);
More information about the Bf-blender-cvs
mailing list