Fix T66295 Collection instance duplicates don't have selection outline

Was cause by shgroup reuse even if select state changed from previous dupli.

Also fixes T64438 Collection Instance object highlight wrong
This commit is contained in:
Clément Foucault 2019-07-02 16:03:49 +02:00
parent c362ca3b8a
commit 57c26453f8
Notes: blender-bot 2023-02-14 08:25:14 +01:00
Referenced by issue #66295, Collection instance duplicates don't have selection outline
Referenced by issue #64810, Wrong selection outline color for dupli-face instances
Referenced by issue #64438, Collection Instance object highlight wrong
2 changed files with 20 additions and 2 deletions

View File

@ -322,6 +322,7 @@ typedef struct OBJECT_DupliData {
GPUBatch *outline_geom;
DRWShadingGroup *extra_shgrp;
GPUBatch *extra_geom;
short base_flag;
} OBJECT_DupliData;
static struct {
@ -3398,6 +3399,10 @@ BLI_INLINE OBJECT_DupliData *OBJECT_duplidata_get(Object *ob, void *vedata, bool
*dupli_data = MEM_callocN(sizeof(OBJECT_DupliData), "OBJECT_DupliData");
*init = true;
}
else if ((*dupli_data)->base_flag != ob->base_flag) {
/* Select state might have change, reinit. */
*init = true;
}
return *dupli_data;
}
return NULL;
@ -3458,6 +3463,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if (dupli_data && !init_duplidata) {
geom = dupli_data->outline_geom;
shgroup = dupli_data->outline_shgrp;
/* TODO: Remove. Only here to increment outline id counter. */
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
shgroup = shgroup_theme_id_to_outline_or_null(stl, theme_id, ob->base_flag);
}
else {
if (stl->g_data->xray_enabled_and_not_wire || is_flat_object_viewed_from_side) {
@ -3665,6 +3673,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if (init_duplidata) {
dupli_data->extra_shgrp = shgroup;
dupli_data->extra_geom = geom;
dupli_data->base_flag = ob->base_flag;
}
}

View File

@ -50,6 +50,7 @@
typedef struct OVERLAY_DupliData {
DRWShadingGroup *shgrp;
struct GPUBatch *geom;
short base_flag;
} OVERLAY_DupliData;
typedef struct OVERLAY_StorageList {
@ -370,9 +371,16 @@ static void overlay_cache_populate(void *vedata, Object *ob)
}
else {
if ((*dupli_data)->shgrp && (*dupli_data)->geom) {
DRW_shgroup_call((*dupli_data)->shgrp, (*dupli_data)->geom, ob);
if ((*dupli_data)->base_flag == ob->base_flag) {
DRW_shgroup_call((*dupli_data)->shgrp, (*dupli_data)->geom, ob);
}
else {
/* Continue and create a new Shgroup. */
}
}
else {
return;
}
return;
}
}
@ -437,6 +445,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
if (dupli_data) {
(*dupli_data)->shgrp = shgrp;
(*dupli_data)->geom = geom;
(*dupli_data)->base_flag = ob->base_flag;
}
}
}