Cleanup: group VBO attributes in a struct
Some names are a bit arbitrary, this makes it clear which names are VBO attributes.
This commit is contained in:
parent
3d6361aa9c
commit
5bfeaf6cc1
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue