[Bf-blender-cvs] [a8a9a08bf78] blender-v3.0-release: Fix T84710: Instances with only mesh edges or vertices are invisible

Hans Goudey noreply at git.blender.org
Tue Jan 11 09:00:06 CET 2022


Commit: a8a9a08bf7865dc6d2495e12b456751b458cae40
Author: Hans Goudey
Date:   Wed Dec 1 21:47:57 2021 -0500
Branches: blender-v3.0-release
https://developer.blender.org/rBa8a9a08bf7865dc6d2495e12b456751b458cae40

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

===================================================================

M	source/blender/draw/engines/overlay/overlay_wireframe.c

===================================================================

diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c
index fde376beeb2..449130c4c5b 100644
--- a/source/blender/draw/engines/overlay/overlay_wireframe.c
+++ b/source/blender/draw/engines/overlay/overlay_wireframe.c
@@ -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)



More information about the Bf-blender-cvs mailing list