Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-05-17 05:22:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-05-17 05:36:02 +0300
commit5bfeaf6cc183549e4051273841a3e98b7d85924f (patch)
treec9e7ea83a8050a4d7cf644ddc9e54c99476d830b /source
parent3d6361aa9c8d3d21dca91130a7249d3892b68bc0 (diff)
Cleanup: group VBO attributes in a struct
Some names are a bit arbitrary, this makes it clear which names are VBO attributes.
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_cache.c434
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c82
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c10
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c16
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c188
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c34
6 files changed, 379 insertions, 385 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index abaab1b9322..36f95afc7f4 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -156,9 +156,9 @@ static VertexBuffer *fill_arrows_vbo(const float scale)
{
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
/* Line */
@@ -175,21 +175,21 @@ static VertexBuffer *fill_arrows_vbo(const float scale)
v2[axis] = 1.0f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 0, vtmp1);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 1, vtmp2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 0, vtmp1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 1, vtmp2);
v1[axis] = 0.85f;
v1[arrow_axis] = -0.08f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 2, vtmp1);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 3, vtmp2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 2, vtmp1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 3, vtmp2);
v1[arrow_axis] = 0.08f;
mul_v3_v3fl(vtmp1, v1, scale);
mul_v3_v3fl(vtmp2, v2, scale);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 4, vtmp1);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 6 + 5, vtmp2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 4, vtmp1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 6 + 5, vtmp2);
/* reset v1 & v2 to zero */
v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
@@ -203,9 +203,9 @@ static VertexBuffer *sphere_wire_vbo(const float rad)
#define NSEGMENTS 16
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -234,7 +234,7 @@ static VertexBuffer *sphere_wire_vbo(const float rad)
else
v[0] = 0.0f, v[1] = cv[0], v[2] = cv[1];
- VertexBuffer_set_attrib(vbo, pos_id, i * 2 + j + (NSEGMENTS * 2 * axis), v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v);
}
}
}
@@ -254,18 +254,18 @@ Batch *DRW_cache_fullscreen_quad_get(void)
/* Position Only 2D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id, uvs_id;
+ static struct { uint pos, uvs; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
- uvs_id = VertexFormat_add_attrib(&format, "uvs", COMP_F32, 2, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ attr_id.uvs = VertexFormat_add_attrib(&format, "uvs", COMP_F32, 2, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 3);
for (int i = 0; i < 3; ++i) {
- VertexBuffer_set_attrib(vbo, pos_id, i, pos[i]);
- VertexBuffer_set_attrib(vbo, uvs_id, i, uvs[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, pos[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.uvs, i, uvs[i]);
}
SHC.drw_fullscreen_quad = Batch_create(PRIM_TRIANGLES, vbo, NULL);
@@ -298,16 +298,16 @@ Batch *DRW_cache_cube_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 24);
for (int i = 0; i < 24; ++i) {
- VertexBuffer_set_attrib(vbo, pos_id, i, verts[indices[i]]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, verts[indices[i]]);
}
SHC.drw_cube = Batch_create(PRIM_LINES, vbo, NULL);
@@ -323,9 +323,9 @@ Batch *DRW_cache_circle_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -335,12 +335,12 @@ Batch *DRW_cache_circle_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, a * 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, a * 2 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2 + 1, v);
}
SHC.drw_circle = Batch_create(PRIM_LINES, vbo, NULL);
@@ -359,17 +359,17 @@ Batch *DRW_cache_square_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 8);
for (int i = 0; i < 4; i++) {
- VertexBuffer_set_attrib(vbo, pos_id, i * 2, p[i % 4]);
- VertexBuffer_set_attrib(vbo, pos_id, i * 2 + 1, p[(i+1) % 4]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 2, p[i % 4]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 2 + 1, p[(i+1) % 4]);
}
SHC.drw_square = Batch_create(PRIM_LINES, vbo, NULL);
@@ -386,16 +386,16 @@ Batch *DRW_cache_single_line_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 2);
- VertexBuffer_set_attrib(vbo, pos_id, 0, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 1, v2);
SHC.drw_line = Batch_create(PRIM_LINES, vbo, NULL);
}
@@ -411,16 +411,16 @@ Batch *DRW_cache_single_line_endpoints_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 2);
- VertexBuffer_set_attrib(vbo, pos_id, 0, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 1, v2);
SHC.drw_line_endpoints = Batch_create(PRIM_POINTS, vbo, NULL);
}
@@ -435,9 +435,9 @@ Batch *DRW_cache_screenspace_circle_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -446,7 +446,7 @@ Batch *DRW_cache_screenspace_circle_get(void)
for (int a = 0; a <= CIRCLE_RESOL; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- VertexBuffer_set_attrib(vbo, pos_id, a, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a, v);
}
SHC.drw_screenspace_circle = Batch_create(PRIM_LINE_STRIP, vbo, NULL);
@@ -517,9 +517,9 @@ Batch *DRW_cache_plain_axes_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -529,8 +529,8 @@ Batch *DRW_cache_plain_axes_get(void)
v1[axis] = 1.0f;
v2[axis] = -1.0f;
- VertexBuffer_set_attrib(vbo, pos_id, axis * 2, v1);
- VertexBuffer_set_attrib(vbo, pos_id, axis * 2 + 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 2, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, axis * 2 + 1, v2);
/* reset v1 & v2 to zero for next axis */
v1[axis] = v2[axis] = 0.0f;
@@ -548,9 +548,9 @@ Batch *DRW_cache_single_arrow_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
/* Square Pyramid */
@@ -571,9 +571,9 @@ Batch *DRW_cache_single_arrow_get(void)
v3[0] = -v3[0];
}
- VertexBuffer_set_attrib(vbo, pos_id, sides * 3 + 0, v1);
- VertexBuffer_set_attrib(vbo, pos_id, sides * 3 + 1, v2);
- VertexBuffer_set_attrib(vbo, pos_id, sides * 3 + 2, v3);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, sides * 3 + 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, sides * 3 + 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, sides * 3 + 2, v3);
}
SHC.drw_single_arrow = Batch_create(PRIM_TRIANGLES, vbo, NULL);
@@ -604,9 +604,9 @@ Batch *DRW_cache_empty_cone_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -619,17 +619,17 @@ Batch *DRW_cache_empty_cone_get(void)
/* cone sides */
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- VertexBuffer_set_attrib(vbo, pos_id, i * 4, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4, v);
v[0] = 0.0f, v[1] = 2.0f, v[2] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 1, v);
/* end ring */
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 2, v);
cv[0] = p[(i + 1) % NSEGMENTS][0];
cv[1] = p[(i + 1) % NSEGMENTS][1];
v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1];
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 3, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 3, v);
}
SHC.drw_empty_cone = Batch_create(PRIM_LINES, vbo, NULL);
@@ -656,10 +656,10 @@ Batch *DRW_cache_axis_names_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* Using 3rd component as axis indicator */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
/* Line */
@@ -669,40 +669,40 @@ Batch *DRW_cache_axis_names_get(void)
/* X */
copy_v3_fl3(v1, -size, size, 0.0f);
copy_v3_fl3(v2, size, -size, 0.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 0, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 1, v2);
copy_v3_fl3(v1, size, size, 0.0f);
copy_v3_fl3(v2, -size, -size, 0.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 2, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 3, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 2, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 3, v2);
/* Y */
copy_v3_fl3(v1, -size + 0.25f * size, size, 1.0f);
copy_v3_fl3(v2, 0.0f, 0.0f, 1.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 4, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 5, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 4, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 5, v2);
copy_v3_fl3(v1, size - 0.25f * size, size, 1.0f);
copy_v3_fl3(v2, -size + 0.25f * size, -size, 1.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 6, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 7, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 6, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 7, v2);
/* Z */
copy_v3_fl3(v1, -size, size, 2.0f);
copy_v3_fl3(v2, size, size, 2.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 8, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 9, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 8, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 9, v2);
copy_v3_fl3(v1, size, size, 2.0f);
copy_v3_fl3(v2, -size, -size, 2.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 10, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 11, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 10, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 11, v2);
copy_v3_fl3(v1, -size, -size, 2.0f);
copy_v3_fl3(v2, size, -size, 2.0f);
- VertexBuffer_set_attrib(vbo, pos_id, 12, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 13, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 12, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 13, v2);
SHC.drw_axis_names = Batch_create(PRIM_LINES, vbo, NULL);
}
@@ -718,9 +718,9 @@ Batch *DRW_cache_field_wind_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -732,12 +732,12 @@ Batch *DRW_cache_field_wind_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, i * CIRCLE_RESOL * 2 + a * 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
}
}
@@ -755,9 +755,9 @@ Batch *DRW_cache_field_force_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -769,12 +769,12 @@ Batch *DRW_cache_field_force_get(void)
v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * CIRCLE_RESOL * 2 + a * 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v);
v[0] = radius * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = radius * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v);
}
}
@@ -793,9 +793,9 @@ Batch *DRW_cache_field_vortex_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -805,14 +805,14 @@ Batch *DRW_cache_field_vortex_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
v[1] = cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
for (int a = 1; a <= SPIRAL_RESOL; a++) {
v[0] = -sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
v[1] = -cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
SHC.drw_field_vortex = Batch_create(PRIM_LINE_STRIP, vbo, NULL);
@@ -830,9 +830,9 @@ Batch *DRW_cache_field_tube_limit_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -845,12 +845,12 @@ Batch *DRW_cache_field_tube_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
}
/* Side Edges */
@@ -860,7 +860,7 @@ Batch *DRW_cache_field_tube_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / 4.0f);
v[1] = cosf((2.0f * M_PI * a) / 4.0f);
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
}
@@ -879,9 +879,9 @@ Batch *DRW_cache_field_cone_limit_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -894,12 +894,12 @@ Batch *DRW_cache_field_cone_limit_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
}
/* Side Edges */
@@ -909,7 +909,7 @@ Batch *DRW_cache_field_cone_limit_get(void)
v[0] = z * sinf((2.0f * M_PI * a) / 4.0f);
v[1] = z * cosf((2.0f * M_PI * a) / 4.0f);
v[2] = z;
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, v);
}
}
@@ -934,9 +934,9 @@ Batch *DRW_cache_lamp_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -945,11 +945,11 @@ Batch *DRW_cache_lamp_get(void)
for (int a = 0; a < NSEGMENTS; a++) {
v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS));
v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS));
- VertexBuffer_set_attrib(vbo, pos_id, a * 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS));
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS));
- VertexBuffer_set_attrib(vbo, pos_id, a * 2 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2 + 1, v);
}
SHC.drw_lamp = Batch_create(PRIM_LINES, vbo, NULL);
@@ -965,9 +965,9 @@ Batch *DRW_cache_lamp_sunrays_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -980,8 +980,8 @@ Batch *DRW_cache_lamp_sunrays_get(void)
mul_v2_v2fl(v1, v, 1.2f);
mul_v2_v2fl(v2, v, 2.5f);
- VertexBuffer_set_attrib(vbo, pos_id, a * 2, v1);
- VertexBuffer_set_attrib(vbo, pos_id, a * 2 + 1, v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, a * 2 + 1, v2);
}
SHC.drw_lamp_sunrays = Batch_create(PRIM_LINES, vbo, NULL);
@@ -996,27 +996,27 @@ Batch *DRW_cache_lamp_area_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 8);
v1[0] = v1[1] = 0.5f;
- VertexBuffer_set_attrib(vbo, pos_id, 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 0, v1);
v1[0] = -0.5f;
- VertexBuffer_set_attrib(vbo, pos_id, 1, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 2, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 1, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 2, v1);
v1[1] = -0.5f;
- VertexBuffer_set_attrib(vbo, pos_id, 3, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 4, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 3, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 4, v1);
v1[0] = 0.5f;
- VertexBuffer_set_attrib(vbo, pos_id, 5, v1);
- VertexBuffer_set_attrib(vbo, pos_id, 6, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 5, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 6, v1);
v1[1] = 0.5f;
- VertexBuffer_set_attrib(vbo, pos_id, 7, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 7, v1);
SHC.drw_lamp_area = Batch_create(PRIM_LINES, vbo, NULL);
}
@@ -1032,9 +1032,9 @@ Batch *DRW_cache_lamp_hemi_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -1045,12 +1045,12 @@ Batch *DRW_cache_lamp_hemi_get(void)
v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2);
v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f;
v[1] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2);
v[2] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f;
v[1] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
/* XY plane */
@@ -1058,12 +1058,12 @@ Batch *DRW_cache_lamp_hemi_get(void)
v[2] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)) - 1.0f;
v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[0] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
v[2] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)) - 1.0f;
v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[0] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
/* YZ plane full circle */
@@ -1072,11 +1072,11 @@ Batch *DRW_cache_lamp_hemi_get(void)
for (int a = 0; a < CIRCLE_RESOL; a++) {
v[1] = rad * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
v[0] = rad * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
v[1] = rad * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
v[0] = rad * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL));
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
@@ -1110,11 +1110,11 @@ Batch *DRW_cache_lamp_spot_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id, n1_id, n2_id;
+ static struct { uint pos, n1, n2; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -1127,27 +1127,27 @@ Batch *DRW_cache_lamp_spot_get(void)
/* cone sides */
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * 4, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4, v);
v[0] = 0.0f, v[1] = 0.0f, v[2] = 0.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 1, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 1, v);
- VertexBuffer_set_attrib(vbo, n1_id, i * 4, n[(i) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n1_id, i * 4 + 1, n[(i) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n2_id, i * 4, n[(i+1) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n2_id, i * 4 + 1, n[(i+1) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, i * 4, n[(i+1) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, i * 4 + 1, n[(i+1) % NSEGMENTS]);
/* end ring */
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 2, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 2, v);
cv[0] = p[(i + 1) % NSEGMENTS][0];
cv[1] = p[(i + 1) % NSEGMENTS][1];
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
- VertexBuffer_set_attrib(vbo, pos_id, i * 4 + 3, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i * 4 + 3, v);
- VertexBuffer_set_attrib(vbo, n1_id, i * 4 + 2, n[(i) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n1_id, i * 4 + 3, n[(i) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n2_id, i * 4 + 2, neg[(i) % NSEGMENTS]);
- VertexBuffer_set_attrib(vbo, n2_id, i * 4 + 3, neg[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]);
}
SHC.drw_lamp_spot = Batch_create(PRIM_LINES, vbo, NULL);
@@ -1169,9 +1169,9 @@ Batch *DRW_cache_lamp_spot_square_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -1179,11 +1179,11 @@ Batch *DRW_cache_lamp_spot_square_get(void)
/* piramid sides */
for (int i = 1; i <= 4; ++i) {
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, p[0]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, p[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, p[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, p[i]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, p[(i % 4)+1]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, p[((i+1) % 4)+1]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, p[(i % 4)+1]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, p[((i+1) % 4)+1]);
}
SHC.drw_lamp_spot_square = Batch_create(PRIM_LINES, vbo, NULL);
@@ -1207,9 +1207,9 @@ Batch *DRW_cache_speaker_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -1220,16 +1220,16 @@ Batch *DRW_cache_speaker_get(void)
float r = (j == 0 ? 0.5f : 0.25f);
copy_v3_fl3(v, r, 0.0f, z);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
for (int i = 1; i < segments; i++) {
float x = cosf(2.f * (float)M_PI * i / segments) * r;
float y = sinf(2.f * (float)M_PI * i / segments) * r;
copy_v3_fl3(v, x, y, z);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
copy_v3_fl3(v, r, 0.0f, z);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
for (int j = 0; j < 4; j++) {
@@ -1243,9 +1243,9 @@ Batch *DRW_cache_speaker_get(void)
float z = 0.25f * i - 0.125f;
copy_v3_fl3(v, x, y, z);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
if (i == 1) {
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, v);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, v);
}
}
}
@@ -1315,10 +1315,10 @@ Batch *DRW_cache_bone_octahedral_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1326,12 +1326,12 @@ Batch *DRW_cache_bone_octahedral_get(void)
VertexBuffer_allocate_data(vbo, 24);
for (int i = 0; i < 8; i++) {
- VertexBuffer_set_attrib(vbo, nor_id, v_idx, bone_octahedral_solid_normals[i]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][0]]);
- VertexBuffer_set_attrib(vbo, nor_id, v_idx, bone_octahedral_solid_normals[i]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][1]]);
- VertexBuffer_set_attrib(vbo, nor_id, v_idx, bone_octahedral_solid_normals[i]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][2]]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][0]]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][1]]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][2]]);
}
SHC.drw_bone_octahedral = Batch_create(PRIM_TRIANGLES, vbo, NULL);
@@ -1345,11 +1345,11 @@ Batch *DRW_cache_bone_octahedral_wire_outline_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, n1_id, n2_id;
+ static struct { uint pos, n1, n2; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1361,7 +1361,7 @@ Batch *DRW_cache_bone_octahedral_wire_outline_get(void)
const float *co2 = bone_octahedral_verts[bone_octahedral_wire[i * 2 + 1]];
const float *n1 = bone_octahedral_solid_normals[bone_octahedral_wire_adjacent_face[i * 2]];
const float *n2 = bone_octahedral_solid_normals[bone_octahedral_wire_adjacent_face[i * 2 + 1]];
- add_fancy_edge(vbo, pos_id, n1_id, n2_id, &v_idx, co1, co2, n1, n2);
+ add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
}
SHC.drw_bone_octahedral_wire = Batch_create(PRIM_LINES, vbo, NULL);
@@ -1443,10 +1443,10 @@ Batch *DRW_cache_bone_box_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1455,8 +1455,8 @@ Batch *DRW_cache_bone_box_get(void)
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 3; j++) {
- VertexBuffer_set_attrib(vbo, nor_id, v_idx, bone_box_solid_normals[i]);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]);
}
}
@@ -1471,11 +1471,11 @@ Batch *DRW_cache_bone_box_wire_outline_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, n1_id, n2_id;
+ static struct { uint pos, n1, n2; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1487,7 +1487,7 @@ Batch *DRW_cache_bone_box_wire_outline_get(void)
const float *co2 = bone_box_verts[bone_box_wire[i * 2 + 1]];
const float *n1 = bone_box_solid_normals[bone_box_wire_adjacent_face[i * 2]];
const float *n2 = bone_box_solid_normals[bone_box_wire_adjacent_face[i * 2 + 1]];
- add_fancy_edge(vbo, pos_id, n1_id, n2_id, &v_idx, co1, co2, n1, n2);
+ add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
}
SHC.drw_bone_box_wire = Batch_create(PRIM_LINES, vbo, NULL);
@@ -1502,11 +1502,11 @@ Batch *DRW_cache_bone_wire_wire_outline_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, n1_id, n2_id;
+ static struct { uint pos, n1, n2; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1516,7 +1516,7 @@ Batch *DRW_cache_bone_wire_wire_outline_get(void)
const float co1[3] = {0.0f, 0.0f, 0.0f};
const float co2[3] = {0.0f, 1.0f, 0.0f};
const float n[3] = {1.0f, 0.0f, 0.0f};
- add_fancy_edge(vbo, pos_id, n1_id, n2_id, &v_idx, co1, co2, n, n);
+ add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n, n);
SHC.drw_bone_wire_wire = Batch_create(PRIM_LINES, vbo, NULL);
}
@@ -1535,10 +1535,10 @@ Batch *DRW_cache_bone_point_get(void)
unsigned int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
}
/* Vertices */
@@ -1550,15 +1550,15 @@ Batch *DRW_cache_bone_point_get(void)
float lat = 0.0f;
for (int j = 0; j < lat_res; j++, lat += lat_inc) {
if (j != lat_res - 1) { /* Pole */
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat + lat_inc, lon + lon_inc);
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat + lat_inc, lon);
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat, lon);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
}
if (j != 0) { /* Pole */
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat, lon + lon_inc);
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat + lat_inc, lon + lon_inc);
- add_lat_lon_vert(vbo, pos_id, nor_id, &v_idx, rad, lat, lon);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon + lon_inc);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
}
}
}
@@ -1607,52 +1607,52 @@ Batch *DRW_cache_camera_get(void)
int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* use x coordinate to identify the vertex
* the vertex shader take care to place it
* appropriatelly */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 1, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 1, KEEP_FLOAT);
}
/* Vertices */
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 22);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v0);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v0);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v1);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v0);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v0);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v2);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v0);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v3);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v0);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v3);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v0);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v4);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v0);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v4);
/* camera frame */
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v1);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v2);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v2);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v3);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v3);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v3);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v4);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v3);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v4);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v4);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v4);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v1);
/* tria */
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v5);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v6);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v5);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v6);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v6);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v7);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v6);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v7);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v7);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v5);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v7);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v5);
SHC.drw_camera = Batch_create(PRIM_LINES, vbo, NULL);
}
@@ -1668,12 +1668,12 @@ Batch *DRW_cache_camera_tria_get(void)
int v_idx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* use x coordinate to identify the vertex
* the vertex shader take care to place it
* appropriatelly */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 1, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 1, KEEP_FLOAT);
}
/* Vertices */
@@ -1681,9 +1681,9 @@ Batch *DRW_cache_camera_tria_get(void)
VertexBuffer_allocate_data(vbo, 6);
/* tria */
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v5);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v6);
- VertexBuffer_set_attrib(vbo, pos_id, v_idx++, &v7);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v5);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v6);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, v_idx++, &v7);
SHC.drw_camera_tria = Batch_create(PRIM_TRIANGLES, vbo, NULL);
}
@@ -1705,15 +1705,15 @@ Batch *DRW_cache_single_vert_get(void)
/* Position Only 3D format */
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 1);
- VertexBuffer_set_attrib(vbo, pos_id, 0, v1);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 0, v1);
SHC.drw_single_vertice = Batch_create(PRIM_POINTS, vbo, NULL);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 9f3c10db61e..3fbee0d7c2a 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -494,10 +494,10 @@ static VertexBuffer *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cu
if (cache->wire.verts == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
const int vert_len = curve_render_data_wire_verts_len_get(rdata);
@@ -509,7 +509,7 @@ static VertexBuffer *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cu
if (bl->nr > 0) {
const int i_end = vbo_len_used + bl->nr;
for (const BevPoint *bevp = bl->bevpoints; vbo_len_used < i_end; vbo_len_used++, bevp++) {
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bevp->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bevp->vec);
}
}
}
@@ -572,10 +572,10 @@ static VertexBuffer *curve_batch_cache_get_normal_verts(CurveRenderData *rdata,
if (cache->normal.verts == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
const int normal_len = curve_render_data_normal_len_get(rdata);
@@ -614,9 +614,9 @@ static VertexBuffer *curve_batch_cache_get_normal_verts(CurveRenderData *rdata,
add_v3_v3(vec_a, bevp->vec);
add_v3_v3(vec_b, bevp->vec);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, vec_a);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, bevp->vec);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, vec_b);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, vec_a);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, bevp->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, vec_b);
bevp += skip + 1;
nr -= skip;
@@ -666,11 +666,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
if (cache->overlay.verts == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id, data_id;
+ static struct { uint pos, data; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- data_id = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -689,16 +689,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
if (rdata->hide_handles) {
vflag = (bezt->f2 & SELECT) ?
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bezt->vec[1]);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
else {
for (int j = 0; j < 3; j++) {
vflag = ((&bezt->f1)[j] & SELECT) ?
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bezt->vec[j]);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
}
@@ -713,8 +713,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
const bool is_active = (i == rdata->actvert);
char vflag;
vflag = (bp->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bp->vec);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
i += 1;
@@ -734,11 +734,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
/* Note: we could reference indices to vertices (above) */
static VertexFormat format = { 0 };
- static unsigned pos_id, data_id;
+ static struct { uint pos, data; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- data_id = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -756,22 +756,22 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
char vflag;
vflag = (bezt->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bezt->vec[0]);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
/* same vertex twice, only check different selection */
for (int j = 0; j < 2; j++) {
vflag = ((j ? bezt->f3 : bezt->f1) & SELECT) ?
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bezt->vec[1]);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
vflag = (bezt->f3 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bezt->vec[2]);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[2]);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
i += 1;
@@ -783,11 +783,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
if ((bp_prev->hide == false) && (bp_curr->hide == false)) {
char vflag;
vflag = ((bp_prev->f1 & SELECT) && (bp_curr->f1 & SELECT)) ? VFLAG_VERTEX_SELECTED : 0;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bp_prev->vec);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp_prev->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, bp_curr->vec);
- VertexBuffer_set_attrib(vbo, data_id, vbo_len_used, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp_curr->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
vbo_len_used += 1;
}
@@ -828,9 +828,9 @@ static Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, Curve
if (cache->text.select == NULL) {
EditFont *ef = rdata->text.edit_font;
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -883,13 +883,13 @@ static Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, Curve
add_v2_v2(box[3], &sb->x);
}
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[0]);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[1]);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[2]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[1]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[2]);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[0]);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[2]);
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used++, box[3]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[2]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[3]);
}
BLI_assert(vbo_len_used == vbo_len_capacity);
cache->text.select = Batch_create(PRIM_TRIANGLES, vbo, NULL);
@@ -902,16 +902,16 @@ static Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, Curve
BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT);
if (cache->text.cursor == NULL) {
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
const int vbo_len_capacity = 4;
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
for (int i = 0; i < 4; i++) {
- VertexBuffer_set_attrib(vbo, pos_id, i, rdata->text.edit_font->textcurs[i]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
}
cache->text.cursor = Batch_create(PRIM_TRIANGLE_FAN, vbo, NULL);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index f18d02f5ee7..9e93409c24d 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -94,11 +94,11 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
}
static VertexFormat format = { 0 };
- static unsigned int pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
}
const int vert_len = curve_render_surface_vert_len_get(lb);
@@ -117,9 +117,9 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
const float *fp_no = dl->nors;
const int vbo_end = vbo_len_used + dl_vert_len(dl);
while (vbo_len_used < vbo_end) {
- VertexBuffer_set_attrib(vbo, pos_id, vbo_len_used, fp_co);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, fp_co);
if (fp_no) {
- VertexBuffer_set_attrib(vbo, nor_id, vbo_len_used, fp_no);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, vbo_len_used, fp_no);
if (ndata_is_single == false) {
fp_no += 3;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 444b4e641f6..e5d8a6c9301 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -347,10 +347,10 @@ static VertexBuffer *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Latti
if (cache->pos == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
const int vert_len = lattice_render_data_verts_len_get(rdata);
@@ -359,7 +359,7 @@ static VertexBuffer *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Latti
VertexBuffer_allocate_data(cache->pos, vert_len);
for (int i = 0; i < vert_len; ++i) {
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
- VertexBuffer_set_attrib(cache->pos, pos_id, i, bp->vec);
+ VertexBuffer_set_attrib(cache->pos, attr_id.pos, i, bp->vec);
}
}
@@ -432,11 +432,11 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
if (cache->overlay_verts == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id, data_id;
+ static struct { uint pos, data; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- data_id = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
}
const int vert_len = lattice_render_data_verts_len_get(rdata);
@@ -456,8 +456,8 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
}
}
- VertexBuffer_set_attrib(vbo, pos_id, i, bp->vec);
- VertexBuffer_set_attrib(vbo, data_id, i, &vflag);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, bp->vec);
+ VertexBuffer_set_attrib(vbo, attr_id.data, i, &vflag);
}
cache->overlay_verts = Batch_create(PRIM_POINTS, vbo, NULL);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 7d3a296761a..9cf3321e00a 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1859,14 +1859,13 @@ static VertexBuffer *mesh_batch_cache_get_tri_pos_and_normals(
unsigned int vidx = 0, nidx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
#if USE_10_10_10
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
#else
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
#endif
}
@@ -1897,9 +1896,9 @@ static VertexBuffer *mesh_batch_cache_get_tri_pos_and_normals(
#else
short **snor = tri_vert_nors;
#endif
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor[0]);
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor[1]);
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor[2]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor[1]);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor[2]);
}
else {
#if USE_10_10_10
@@ -1908,14 +1907,14 @@ static VertexBuffer *mesh_batch_cache_get_tri_pos_and_normals(
#else
short *snor = tri_nor;
#endif
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor);
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor);
- VertexBuffer_set_attrib(vbo, nor_id, nidx++, snor);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, nidx++, snor);
}
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[0]);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[1]);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[2]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, tri_vert_cos[0]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, tri_vert_cos[1]);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, tri_vert_cos[2]);
}
}
vbo_len_used = vidx;
@@ -1938,10 +1937,9 @@ static VertexBuffer *mesh_batch_cache_get_tri_weights(
unsigned int cidx = 0;
static VertexFormat format = { 0 };
- static unsigned int col_id;
+ static struct { uint col; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- col_id = VertexFormat_add_attrib(&format, "color", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.col = VertexFormat_add_attrib(&format, "color", COMP_F32, 3, KEEP_FLOAT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -1961,7 +1959,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_weights(
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const int v_index = BM_elem_index_get(ltri[tri_corner]->v);
- VertexBuffer_set_attrib(vbo, col_id, cidx++, vert_weight_color[v_index]);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
}
}
}
@@ -1971,7 +1969,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_weights(
const MLoopTri *mlt = &rdata->mlooptri[i];
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v;
- VertexBuffer_set_attrib(vbo, col_id, cidx++, vert_weight_color[v_index]);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, vert_weight_color[v_index]);
}
}
}
@@ -1996,10 +1994,9 @@ static VertexBuffer *mesh_batch_cache_get_tri_vert_colors(
unsigned int cidx = 0;
static VertexFormat format = { 0 };
- static unsigned int col_id;
+ static struct { uint col; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- col_id = VertexFormat_add_attrib(&format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.col = VertexFormat_add_attrib(&format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -2018,7 +2015,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_vert_colors(
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const int v_index = BM_elem_index_get(ltri[tri_corner]->v);
- VertexBuffer_set_attrib(vbo, col_id, cidx++, vert_color[v_index]);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, vert_color[v_index]);
}
}
}
@@ -2028,7 +2025,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_vert_colors(
const MLoopTri *mlt = &rdata->mlooptri[i];
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v;
- VertexBuffer_set_attrib(vbo, col_id, cidx++, vert_color[v_index]);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, vert_color[v_index]);
}
}
}
@@ -2053,10 +2050,9 @@ static VertexBuffer *mesh_batch_cache_get_tri_select_id(
unsigned int cidx = 0;
static VertexFormat format = { 0 };
- static unsigned int col_id;
+ static struct { uint col; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- col_id = VertexFormat_add_attrib(&format, "color", COMP_I32, 1, KEEP_INT);
+ attr_id.col = VertexFormat_add_attrib(&format, "color", COMP_I32, 1, KEEP_INT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -2075,7 +2071,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_select_id(
int select_id;
GPU_select_index_get(poly_index + 1, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- VertexBuffer_set_attrib(vbo, col_id, cidx++, &select_id);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, &select_id);
}
}
}
@@ -2088,7 +2084,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_select_id(
int select_id;
GPU_select_index_get(poly_index + 1, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- VertexBuffer_set_attrib(vbo, col_id, cidx++, &select_id);
+ VertexBuffer_set_attrib(vbo, attr_id.col, cidx++, &select_id);
}
}
}
@@ -2110,11 +2106,10 @@ static VertexBuffer *mesh_batch_cache_get_vert_pos_and_nor_in_order(
if (cache->pos_in_order == NULL) {
static VertexFormat format = { 0 };
- static unsigned pos_id, nor_id;
+ static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- nor_id = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
}
VertexBuffer *vbo = cache->pos_in_order = VertexBuffer_create_with_format(&format);
@@ -2131,15 +2126,15 @@ static VertexBuffer *mesh_batch_cache_get_vert_pos_and_nor_in_order(
static short no_short[3];
normal_float_to_short_v3(no_short, eve->no);
- VertexBuffer_set_attrib(vbo, pos_id, i, eve->co);
- VertexBuffer_set_attrib(vbo, nor_id, i, no_short);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, eve->co);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, i, no_short);
}
BLI_assert(i == vbo_len_capacity);
}
else {
for (int i = 0; i < vbo_len_capacity; ++i) {
- VertexBuffer_set_attrib(vbo, pos_id, i, rdata->mvert[i].co);
- VertexBuffer_set_attrib(vbo, nor_id, i, rdata->mvert[i].no);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, i, rdata->mvert[i].co);
+ VertexBuffer_set_attrib(vbo, attr_id.nor, i, rdata->mvert[i].no);
}
}
}
@@ -2208,25 +2203,26 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
/* Positions */
VertexBuffer *vbo_pos = NULL;
- static unsigned pos_id;
+ static struct { uint pos, vnor, lnor, data; } attr_id;
if (cache->ed_tri_pos == NULL) {
- vbo_pos = cache->ed_tri_pos = VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&pos_id));
+ vbo_pos = cache->ed_tri_pos =
+ VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
VertexBuffer_allocate_data(vbo_pos, vbo_len_capacity);
}
/* Normals */
VertexBuffer *vbo_nor = NULL;
- static unsigned vnor_id, lnor_id;
if (cache->ed_tri_nor == NULL) {
- vbo_nor = cache->ed_tri_nor = VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&vnor_id, &lnor_id));
+ vbo_nor = cache->ed_tri_nor =
+ VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor));
VertexBuffer_allocate_data(vbo_nor, vbo_len_capacity);
}
/* Data */
VertexBuffer *vbo_data = NULL;
- static unsigned data_id;
if (cache->ed_tri_data == NULL) {
- vbo_data = cache->ed_tri_data = VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&data_id));
+ vbo_data = cache->ed_tri_data =
+ VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
VertexBuffer_allocate_data(vbo_data, vbo_len_capacity);
}
@@ -2235,7 +2231,7 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
if (mesh_render_data_looptri_vert_edge_indices_get(rdata, i, tri_vert_idx, tri_edge_idx)) {
add_overlay_tri(
rdata, vbo_pos, vbo_nor, vbo_data,
- pos_id, vnor_id, lnor_id, data_id,
+ attr_id.pos, attr_id.vnor, attr_id.lnor, attr_id.data,
tri_vert_idx, tri_edge_idx, i, vbo_len_used);
vbo_len_used += 3;
@@ -2268,25 +2264,26 @@ static void mesh_batch_cache_create_overlay_ledge_buffers(
/* Positions */
VertexBuffer *vbo_pos = NULL;
- static unsigned pos_id;
+ static struct { uint pos, vnor, data; } attr_id;
if (cache->ed_ledge_pos == NULL) {
- vbo_pos = cache->ed_ledge_pos = VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&pos_id));
+ vbo_pos = cache->ed_ledge_pos =
+ VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
VertexBuffer_allocate_data(vbo_pos, vbo_len_capacity);
}
/* Normals */
VertexBuffer *vbo_nor = NULL;
- static unsigned vnor_id;
if (cache->ed_ledge_nor == NULL) {
- vbo_nor = cache->ed_ledge_nor = VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&vnor_id, NULL));
+ vbo_nor = cache->ed_ledge_nor =
+ VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
VertexBuffer_allocate_data(vbo_nor, vbo_len_capacity);
}
/* Data */
VertexBuffer *vbo_data = NULL;
- static unsigned data_id;
if (cache->ed_ledge_data == NULL) {
- vbo_data = cache->ed_ledge_data = VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&data_id));
+ vbo_data = cache->ed_ledge_data =
+ VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
VertexBuffer_allocate_data(vbo_data, vbo_len_capacity);
}
@@ -2296,7 +2293,7 @@ static void mesh_batch_cache_create_overlay_ledge_buffers(
BLI_assert(ok); /* we don't add */
add_overlay_loose_edge(
rdata, vbo_pos, vbo_nor, vbo_data,
- pos_id, vnor_id, data_id,
+ attr_id.pos, attr_id.vnor, attr_id.data,
vert_idx, i, vbo_len_used);
vbo_len_used += 2;
}
@@ -2325,34 +2322,36 @@ static void mesh_batch_cache_create_overlay_lvert_buffers(
const int vbo_len_capacity = lvert_len;
int vbo_len_used = 0;
+ static struct { uint pos, vnor, data; } attr_id;
+
/* Positions */
VertexBuffer *vbo_pos = NULL;
- static unsigned pos_id;
if (cache->ed_lvert_pos == NULL) {
- vbo_pos = cache->ed_lvert_pos = VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&pos_id));
+ vbo_pos = cache->ed_lvert_pos =
+ VertexBuffer_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos));
VertexBuffer_allocate_data(vbo_pos, vbo_len_capacity);
}
/* Normals */
VertexBuffer *vbo_nor = NULL;
- static unsigned vnor_id;
if (cache->ed_lvert_nor == NULL) {
- vbo_nor = cache->ed_lvert_nor = VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&vnor_id, NULL));
+ vbo_nor = cache->ed_lvert_nor =
+ VertexBuffer_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL));
VertexBuffer_allocate_data(vbo_nor, vbo_len_capacity);
}
/* Data */
VertexBuffer *vbo_data = NULL;
- static unsigned data_id;
if (cache->ed_lvert_data == NULL) {
- vbo_data = cache->ed_lvert_data = VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&data_id));
+ vbo_data = cache->ed_lvert_data =
+ VertexBuffer_create_with_format(edit_mesh_overlay_data_format(&attr_id.data));
VertexBuffer_allocate_data(vbo_data, vbo_len_capacity);
}
for (int i = 0; i < lvert_len; ++i) {
add_overlay_loose_vert(
rdata, vbo_pos, vbo_nor, vbo_data,
- pos_id, vnor_id, data_id,
+ attr_id.pos, attr_id.vnor, attr_id.data,
rdata->loose_verts[i], vbo_len_used);
vbo_len_used += 1;
}
@@ -2598,11 +2597,10 @@ static VertexBuffer *mesh_batch_cache_get_edge_pos_with_sel(
unsigned int vidx = 0, cidx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, sel_id;
+ static struct { uint pos, sel; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- sel_id = VertexFormat_add_attrib(&format, "select", COMP_U8, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.sel = VertexFormat_add_attrib(&format, "select", COMP_U8, 1, KEEP_INT);
}
const int edge_len = mesh_render_data_edges_len_get(rdata);
@@ -2632,11 +2630,11 @@ static VertexBuffer *mesh_batch_cache_get_edge_pos_with_sel(
continue;
}
- VertexBuffer_set_attrib(vbo, sel_id, cidx++, &edge_vert_sel);
- VertexBuffer_set_attrib(vbo, sel_id, cidx++, &edge_vert_sel);
+ VertexBuffer_set_attrib(vbo, attr_id.sel, cidx++, &edge_vert_sel);
+ VertexBuffer_set_attrib(vbo, attr_id.sel, cidx++, &edge_vert_sel);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, rdata->mvert[ed->v1].co);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, rdata->mvert[ed->v2].co);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co);
}
vbo_len_used = vidx;
@@ -2661,10 +2659,9 @@ static VertexBuffer *mesh_batch_cache_get_tri_pos_with_unselect_only(
unsigned int vidx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id;
+ static struct { uint pos; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -2680,7 +2677,7 @@ static VertexBuffer *mesh_batch_cache_get_tri_pos_with_unselect_only(
if (!(rdata->mpoly[mlt->poly].flag & ME_FACE_SEL)) {
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v;
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, rdata->mvert[v_index].co);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, rdata->mvert[v_index].co);
}
}
}
@@ -2703,11 +2700,10 @@ static VertexBuffer *mesh_batch_cache_get_vert_pos_with_sel(MeshRenderData *rdat
unsigned int vidx = 0, cidx = 0;
static VertexFormat format = { 0 };
- static unsigned int pos_id, sel_id;
+ static struct { uint pos, sel; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- sel_id = VertexFormat_add_attrib(&format, "select", COMP_I8, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.sel = VertexFormat_add_attrib(&format, "select", COMP_I8, 1, KEEP_INT);
}
const int vert_len = mesh_render_data_verts_len_get(rdata);
@@ -2721,8 +2717,8 @@ static VertexBuffer *mesh_batch_cache_get_vert_pos_with_sel(MeshRenderData *rdat
for (int i = 0; i < vert_len; i++) {
const MVert *mv = &rdata->mvert[i];
const char vert_sel = (mv->flag & SELECT) != 0;
- VertexBuffer_set_attrib(vbo, sel_id, cidx++, &vert_sel);
- VertexBuffer_set_attrib(vbo, pos_id, vidx++, mv->co);
+ VertexBuffer_set_attrib(vbo, attr_id.sel, cidx++, &vert_sel);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx++, mv->co);
}
vbo_len_used = vidx;
@@ -2902,17 +2898,16 @@ Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
if (cache->fancy_edges == NULL) {
/* create batch from DM */
static VertexFormat format = { 0 };
- static unsigned int pos_id, n1_id, n2_id;
+ static struct { uint pos, n1, n2; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
#if USE_10_10_10 /* takes 1/3 the space */
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_I10, 3, NORMALIZE_INT_TO_FLOAT);
#else
- n1_id = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
- n2_id = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n1 = VertexFormat_add_attrib(&format, "N1", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.n2 = VertexFormat_add_attrib(&format, "N2", COMP_F32, 3, KEEP_FLOAT);
#endif
}
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
@@ -2951,13 +2946,13 @@ Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
const float *n2 = (is_manifold) ? pnor2 : dummy2;
#endif
- VertexBuffer_set_attrib(vbo, pos_id, 2 * i, vcos1);
- VertexBuffer_set_attrib(vbo, n1_id, 2 * i, n1);
- VertexBuffer_set_attrib(vbo, n2_id, 2 * i, n2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 2 * i, vcos1);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, 2 * i, n1);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, 2 * i, n2);
- VertexBuffer_set_attrib(vbo, pos_id, 2 * i + 1, vcos2);
- VertexBuffer_set_attrib(vbo, n1_id, 2 * i + 1, n1);
- VertexBuffer_set_attrib(vbo, n2_id, 2 * i + 1, n2);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, 2 * i + 1, vcos2);
+ VertexBuffer_set_attrib(vbo, attr_id.n1, 2 * i + 1, n1);
+ VertexBuffer_set_attrib(vbo, attr_id.n2, 2 * i + 1, n2);
vbo_len_used += 2;
}
@@ -3076,14 +3071,13 @@ Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
static VertexFormat format = { 0 };
- static unsigned pos_id, data_id;
+ static struct { uint pos, data; } attr_id;
if (format.attrib_ct == 0) {
- /* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
#if USE_10_10_10
- data_id = VertexFormat_add_attrib(&format, "norAndFlag", COMP_I10, 4, NORMALIZE_INT_TO_FLOAT);
+ attr_id.data = VertexFormat_add_attrib(&format, "norAndFlag", COMP_I10, 4, NORMALIZE_INT_TO_FLOAT);
#else
- data_id = VertexFormat_add_attrib(&format, "norAndFlag", COMP_F32, 4, KEEP_FLOAT);
+ attr_id.data = VertexFormat_add_attrib(&format, "norAndFlag", COMP_F32, 4, KEEP_FLOAT);
#endif
}
@@ -3102,13 +3096,13 @@ Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
nor = convert_i10_v3(pnor);
nor.w = selected ? 1 : 0;
- VertexBuffer_set_attrib(vbo, data_id, vidx, &nor);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vidx, &nor);
#else
float nor[4] = {pnor[0], pnor[1], pnor[2], selected ? 1 : 0};
- VertexBuffer_set_attrib(vbo, data_id, vidx, nor);
+ VertexBuffer_set_attrib(vbo, attr_id.data, vidx, nor);
#endif
- VertexBuffer_set_attrib(vbo, pos_id, vidx, pcenter);
+ VertexBuffer_set_attrib(vbo, attr_id.pos, vidx, pcenter);
vidx += 1;
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index ae099e03719..d4247a0e365 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -173,18 +173,18 @@ static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, ParticleBatchCache *cache)
{
if (cache->pos == NULL || cache->segments == NULL) {
- static VertexFormat format = { 0 };
- static unsigned pos_id, tan_id, ind_id;
int curr_point = 0;
VERTEXBUFFER_DISCARD_SAFE(cache->pos);
ELEMENTLIST_DISCARD_SAFE(cache->segments);
+ static VertexFormat format = { 0 };
+ static struct { uint pos, tan, ind; } attr_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
- pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
- tan_id = VertexFormat_add_attrib(&format, "tang", COMP_F32, 3, KEEP_FLOAT);
- ind_id = VertexFormat_add_attrib(&format, "ind", COMP_I32, 1, KEEP_INT);
+ attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.tan = VertexFormat_add_attrib(&format, "tang", COMP_F32, 3, KEEP_FLOAT);
+ attr_id.ind = VertexFormat_add_attrib(&format, "ind", COMP_I32, 1, KEEP_INT);
}
cache->pos = VertexBuffer_create_with_format(&format);
@@ -208,9 +208,9 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co);
}
- VertexBuffer_set_attrib(cache->pos, pos_id, curr_point, path[j].co);
- VertexBuffer_set_attrib(cache->pos, tan_id, curr_point, tangent);
- VertexBuffer_set_attrib(cache->pos, ind_id, curr_point, &i);
+ VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[j].co);
+ VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
+ VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &i);
add_line_vertices(&elb, curr_point, curr_point + 1);
@@ -219,9 +219,9 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co);
- VertexBuffer_set_attrib(cache->pos, pos_id, curr_point, path[path->segments].co);
- VertexBuffer_set_attrib(cache->pos, tan_id, curr_point, tangent);
- VertexBuffer_set_attrib(cache->pos, ind_id, curr_point, &i);
+ VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
+ VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
+ VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &i);
curr_point++;
}
@@ -244,9 +244,9 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co);
}
- VertexBuffer_set_attrib(cache->pos, pos_id, curr_point, path[j].co);
- VertexBuffer_set_attrib(cache->pos, tan_id, curr_point, tangent);
- VertexBuffer_set_attrib(cache->pos, ind_id, curr_point, &x);
+ VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[j].co);
+ VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
+ VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &x);
add_line_vertices(&elb, curr_point, curr_point + 1);
@@ -255,9 +255,9 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co);
- VertexBuffer_set_attrib(cache->pos, pos_id, curr_point, path[path->segments].co);
- VertexBuffer_set_attrib(cache->pos, tan_id, curr_point, tangent);
- VertexBuffer_set_attrib(cache->pos, ind_id, curr_point, &x);
+ VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
+ VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
+ VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &x);
curr_point++;
}