[Bf-blender-cvs] [5bfeaf6cc18] blender2.8: Cleanup: group VBO attributes in a struct
Campbell Barton
noreply at git.blender.org
Wed May 17 04:34:20 CEST 2017
Commit: 5bfeaf6cc183549e4051273841a3e98b7d85924f
Author: Campbell Barton
Date: Wed May 17 12:22:22 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB5bfeaf6cc183549e4051273841a3e98b7d85924f
Cleanup: group VBO attributes in a struct
Some names are a bit arbitrary,
this makes it clear which names are VBO attributes.
===================================================================
M source/blender/draw/intern/draw_cache.c
M source/blender/draw/intern/draw_cache_impl_curve.c
M source/blender/draw/intern/draw_cache_impl_displist.c
M source/blender/draw/intern/draw_cache_impl_lattice.c
M source/blender/draw/intern/draw_cache_impl_mesh.c
M source/blender/draw/intern/draw_cache_impl_particles.c
===================================================================
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 */
@@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list