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.
This commit is contained in:
Clément Foucault 2020-07-27 15:39:56 +02:00
parent 565d7f75cc
commit f8a0a5a350
1 changed files with 5 additions and 4 deletions

View File

@ -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) {