[Bf-blender-cvs] [f8a0a5a3504] master: PointCloud: Fix viewport issue when using radius attrib after not using it

Clément Foucault noreply at git.blender.org
Mon Jul 27 14:56:44 CEST 2020


Commit: f8a0a5a350406e18cf07b4e2285c2d094a6fc321
Author: Clément Foucault
Date:   Mon Jul 27 15:39:56 2020 +0200
Branches: master
https://developer.blender.org/rBf8a0a5a350406e18cf07b4e2285c2d094a6fc321

PointCloud: Fix viewport issue when using radius attrib after not using it

This was a simple issue with the static GPUVertFormat being the same for
both cases.

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

M	source/blender/draw/intern/draw_cache_impl_pointcloud.c

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

diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.c b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
index 0a1687524f5..5807b779113 100644
--- a/source/blender/draw/intern/draw_cache_impl_pointcloud.c
+++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
@@ -158,9 +158,10 @@ static void pointcloud_batch_cache_ensure_pos(Object *ob, PointCloudBatchCache *
   /* Assume points always have a radius for now.
    * TODO: Check if the logic below makes sense when there are multiple point clouds, some that
    * have a radius and others that don't. */
-  const bool has_radius = true;
+  const bool has_radius = pointcloud->radius != NULL;
 
   static GPUVertFormat format = {0};
+  static GPUVertFormat format_no_radius = {0};
   static uint pos;
   if (format.attr_len == 0) {
     /* initialize vertex format */
@@ -170,11 +171,11 @@ static void pointcloud_batch_cache_ensure_pos(Object *ob, PointCloudBatchCache *
      * If the vertex shader has more components than the array provides, the extras are given
      * values from the vector (0, 0, 0, 1) for the missing XYZW components.
      */
-    int comp_len = has_radius ? 4 : 3;
-    pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, comp_len, GPU_FETCH_FLOAT);
+    pos = GPU_vertformat_attr_add(&format_no_radius, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+    pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
   }
 
-  cache->pos = GPU_vertbuf_create_with_format(&format);
+  cache->pos = GPU_vertbuf_create_with_format(has_radius ? &format : &format_no_radius);
   GPU_vertbuf_data_alloc(cache->pos, pointcloud->totpoint);
 
   if (has_radius) {



More information about the Bf-blender-cvs mailing list