diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-27 16:39:56 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-27 16:41:16 +0300 |
commit | f8a0a5a350406e18cf07b4e2285c2d094a6fc321 (patch) | |
tree | a0b030896118a8e241f2d65c5d1f4eb58d823274 /source | |
parent | 565d7f75ccfe955821991793fcd6335e58b6825b (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_pointcloud.c | 9 |
1 files changed, 5 insertions, 4 deletions
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) { |