Fix T84710: Instances with only mesh edges or vertices are invisible

Wire-only meshes have a special case in the overlay drawing to give
the wire shader a special color (which avoids the lines being dashed,
somehow). The fast path for duplis didn't have that special case.

Differential Revision: https://developer.blender.org/D13196
This commit is contained in:
Hans Goudey 2021-12-01 21:47:57 -05:00
parent 70a7685d04
commit b869da0c10
Notes: blender-bot 2023-02-14 07:45:38 +01:00
Referenced by issue #93479, 3.0 Potential candidates for corrective releases
Referenced by issue #84710, Instances of only vertices/edges not properly shown in viewport
1 changed files with 28 additions and 10 deletions

View File

@ -237,7 +237,21 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
if (dupli && !init_dupli) {
if (dupli->wire_shgrp && dupli->wire_geom) {
if (dupli->base_flag == ob->base_flag) {
DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob);
/* Check for the special cases used below, assign specific theme colors to the shaders. */
OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob);
if (dupli->wire_shgrp == cb->extra_loose_points) {
float *color;
DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color);
OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->obmat, color);
}
else if (dupli->wire_shgrp == cb->extra_wire) {
float *color;
DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color);
OVERLAY_extra_wire(cb, dupli->wire_geom, ob->obmat, color);
}
else {
DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob);
}
return;
}
}
@ -268,6 +282,9 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
}
}
DRWShadingGroup *shgrp = NULL;
struct GPUBatch *geom = NULL;
/* Don't do that in edit Mesh mode, unless there is a modifier preview. */
if (use_wire && (!is_mesh || (!is_edit_mode || has_edit_mesh_cage))) {
const bool is_sculpt_mode = ((ob->mode & OB_MODE_SCULPT) != 0) && (ob->sculpt != NULL);
@ -275,8 +292,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
!DRW_state_is_image_render();
const bool use_coloring = (use_wire && !is_edit_mode && !is_sculpt_mode &&
!has_edit_mesh_cage);
DRWShadingGroup *shgrp = NULL;
struct GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob);
geom = DRW_cache_object_face_wireframe_get(ob);
if (geom || use_sculpt_pbvh) {
if (use_sculpt_pbvh) {
@ -300,11 +316,6 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
DRW_shgroup_call(shgrp, geom, ob);
}
}
if (dupli) {
dupli->wire_shgrp = shgrp;
dupli->wire_geom = geom;
}
}
else if (is_mesh && (!is_edit_mode || has_edit_mesh_cage)) {
OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob);
@ -313,18 +324,25 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
/* Draw loose geometry. */
if (is_mesh_verts_only) {
struct GPUBatch *geom = DRW_cache_mesh_all_verts_get(ob);
geom = DRW_cache_mesh_all_verts_get(ob);
if (geom) {
OVERLAY_extra_loose_points(cb, geom, ob->obmat, color);
shgrp = cb->extra_loose_points;
}
}
else {
struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob);
geom = DRW_cache_mesh_loose_edges_get(ob);
if (geom) {
OVERLAY_extra_wire(cb, geom, ob->obmat, color);
shgrp = cb->extra_wire;
}
}
}
if (dupli) {
dupli->wire_shgrp = shgrp;
dupli->wire_geom = geom;
}
}
void OVERLAY_wireframe_draw(OVERLAY_Data *data)