GP: Optimize Instances drawing loop
This commit is contained in:
parent
80ef7fbeb1
commit
7618851f74
|
@ -1780,18 +1780,24 @@ void DRW_gpencil_populate_datablock(
|
|||
cache->is_dirty = false;
|
||||
}
|
||||
|
||||
void DRW_gpencil_populate_particles(GPENCIL_e_data *e_data, void *vedata)
|
||||
void DRW_gpencil_populate_particles(GPENCIL_e_data *e_data, GHash *gh_objects, void *vedata)
|
||||
{
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
|
||||
/* add particles */
|
||||
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
|
||||
tGPencilObjectCache *cache_ob = &stl->g_data->gp_object_cache[i];
|
||||
Object *ob = cache_ob->ob;
|
||||
if (cache_ob->is_dup_ob) {
|
||||
GpencilBatchCache *cache = ob->runtime.gpencil_cache;
|
||||
if (cache != NULL) {
|
||||
DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
|
||||
/* reasign duplicate objects because memory for particles is not available
|
||||
* and need to use the original datablock and runtime data */
|
||||
Object *ob = (Object *)BLI_ghash_lookup(gh_objects, cache_ob->name);
|
||||
if (ob) {
|
||||
cache_ob->ob = ob;
|
||||
cache_ob->gpd = (bGPdata *)ob->data;
|
||||
GpencilBatchCache *cache = ob->runtime.gpencil_cache;
|
||||
if (cache != NULL) {
|
||||
DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -651,21 +651,12 @@ void GPENCIL_cache_finish(void *vedata)
|
|||
BLI_ghash_insert(gh_objects, ob->id.name, cache_ob->ob);
|
||||
}
|
||||
}
|
||||
/* reasign duplicate objects because memory for particles is not available
|
||||
* and need to use the original datablock and runtime data */
|
||||
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
|
||||
cache_ob = &stl->g_data->gp_object_cache[i];
|
||||
if (cache_ob->is_dup_ob) {
|
||||
Object *ob_orig = (Object *)BLI_ghash_lookup(gh_objects, cache_ob->name);
|
||||
cache_ob->ob = ob_orig;
|
||||
cache_ob->gpd = (bGPdata *)ob_orig->data;
|
||||
}
|
||||
}
|
||||
|
||||
BLI_ghash_free(gh_objects, NULL, NULL);
|
||||
|
||||
/* draw particles */
|
||||
DRW_gpencil_populate_particles(&e_data, vedata);
|
||||
DRW_gpencil_populate_particles(&e_data, gh_objects, vedata);
|
||||
|
||||
/* free hash */
|
||||
BLI_ghash_free(gh_objects, NULL, NULL);
|
||||
|
||||
if (stl->g_data->session_flag & (GP_DRW_PAINT_IDLE | GP_DRW_PAINT_FILLING)) {
|
||||
stl->storage->framebuffer_flag |= GP_FRAMEBUFFER_DRAW;
|
||||
|
|
|
@ -387,7 +387,7 @@ void DRW_gpencil_populate_multiedit(
|
|||
struct GPENCIL_e_data *e_data, void *vedata,
|
||||
struct Object *ob, struct tGPencilObjectCache *cache_ob);
|
||||
void DRW_gpencil_triangulate_stroke_fill(struct Object *ob, struct bGPDstroke *gps);
|
||||
void DRW_gpencil_populate_particles(struct GPENCIL_e_data *e_data, void *vedata);
|
||||
void DRW_gpencil_populate_particles(struct GPENCIL_e_data *e_data, struct GHash *gh_objects, void *vedata);
|
||||
|
||||
void DRW_gpencil_multisample_ensure(struct GPENCIL_Data *vedata, int rect_w, int rect_h);
|
||||
|
||||
|
|
Loading…
Reference in New Issue