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
diff options
context:
space:
mode:
authorGermano <germano.costa@ig.com.br>2018-04-18 17:34:44 +0300
committerGermano <germano.costa@ig.com.br>2018-04-18 17:34:44 +0300
commit34dbe7ff33a3f565772ac6f0d60bbf955e07983c (patch)
treeb6986784b4977c10492ebe8092794fc35d24a7ed
parent24b3b9fa215b52fc38a3238e7216f8cadce0620e (diff)
UV Edit Draw: Fix assert in `immBeginBatch` -> `vertex_count_makes_sense_for_primitive`.
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c176
1 files changed, 89 insertions, 87 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 328ab3f1a8d..b9a4a883b63 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -815,56 +815,105 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immEnd();
/* Then draw each face contour separately. */
- GWN_batch_program_use_begin(uv_batch);
- unsigned int index = 0, vbo_len_used;
- BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ if (uv_vbo->vertex_ct != 0) {
+ GWN_batch_program_use_begin(uv_batch);
+ unsigned int index = 0, vbo_len_used;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
- index += efa->len;
- }
- vbo_len_used = index;
- GWN_batch_program_use_end(uv_batch);
- immUnbindProgram();
+ GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
+ index += efa->len;
+ }
+ vbo_len_used = index;
+ GWN_batch_program_use_end(uv_batch);
+ immUnbindProgram();
- if (sima->dt_uv == SI_UVDT_OUTLINE) {
- glLineWidth(1.0f);
- UI_GetThemeColor4fv(TH_WIRE_EDIT, col2);
+ if (sima->dt_uv == SI_UVDT_OUTLINE) {
+ glLineWidth(1.0f);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, col2);
+
+ if (me->drawflag & ME_DRAWEDGES) {
+ int sel;
+ UI_GetThemeColor4fv(TH_EDGE_SELECT, col1);
+
+ if (interpedges) {
+ /* Create a color buffer. */
+ static Gwn_VertFormat format = { 0 };
+ static uint shdr_col;
+ if (format.attrib_ct == 0) {
+ shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ }
+
+ Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo_col, vbo_len_used);
- if (me->drawflag & ME_DRAWEDGES) {
- int sel;
- UI_GetThemeColor4fv(TH_EDGE_SELECT, col1);
+ index = 0;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- if (interpedges) {
- /* Create a color buffer. */
- static Gwn_VertFormat format = {0};
- static uint shdr_col;
- if (format.attrib_ct == 0) {
- shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- }
+ BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
+ sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
+ GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
+ }
+ }
+ /* Reuse the UV buffer and add the color buffer. */
+ GWN_batch_vertbuf_add_ex(uv_batch, vbo_col, true);
- Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo_col, vbo_len_used);
+ /* Now draw each face contour separately with another builtin program. */
+ GWN_batch_program_set_builtin(uv_batch, GPU_SHADER_2D_SMOOTH_COLOR);
+ gpuBindMatrices(uv_batch->interface);
- index = 0;
- BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ GWN_batch_program_use_begin(uv_batch);
+ index = 0;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
- sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
- GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
+ GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
+ index += efa->len;
}
+ GWN_batch_program_use_end(uv_batch);
}
- /* Reuse the UV buffer and add the color buffer. */
- GWN_batch_vertbuf_add_ex(uv_batch, vbo_col, true);
+ else {
+ Gwn_VertFormat *format = immVertexFormat();
+ pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+
+ /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */
+ Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, vbo_len_used * 2);
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
+
+ BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
+ sel = uvedit_edge_select_test(scene, l, cd_loop_uv_offset);
+ immAttrib4fv(color, sel ? col1 : col2);
+
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ immVertex2fv(pos, luv->uv);
+ luv = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+ immVertex2fv(pos, luv->uv);
+ }
+ }
+ immEnd();
+
+ GWN_batch_draw(flat_edges_batch);
+ GWN_vertbuf_discard(flat_edges_batch->verts[0]);
+ GWN_batch_discard(flat_edges_batch);
- /* Now draw each face contour separately with another builtin program. */
- GWN_batch_program_set_builtin(uv_batch, GPU_SHADER_2D_SMOOTH_COLOR);
- gpuBindMatrices(uv_batch->interface);
+ immUnbindProgram();
+ }
+ }
+ else {
+ GWN_batch_uniform_4fv(uv_batch, "color", col2);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ /* no nice edges */
GWN_batch_program_use_begin(uv_batch);
index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -875,61 +924,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
index += efa->len;
}
GWN_batch_program_use_end(uv_batch);
- }
- else {
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-
- /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */
- Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, vbo_len_used * 2);
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- sel = uvedit_edge_select_test(scene, l, cd_loop_uv_offset);
- immAttrib4fv(color, sel ? col1 : col2);
-
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- immVertex2fv(pos, luv->uv);
- luv = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
- immVertex2fv(pos, luv->uv);
- }
- }
- immEnd();
-
- GWN_batch_draw(flat_edges_batch);
- GWN_vertbuf_discard(flat_edges_batch->verts[0]);
- GWN_batch_discard(flat_edges_batch);
-
immUnbindProgram();
}
}
- else {
- GWN_batch_uniform_4fv(uv_batch, "color", col2);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* no nice edges */
- GWN_batch_program_use_begin(uv_batch);
- index = 0;
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
- index += efa->len;
- }
- GWN_batch_program_use_end(uv_batch);
- immUnbindProgram();
- }
+ GWN_vertbuf_discard(uv_vbo);
+ GWN_batch_discard(uv_batch);
}
- GWN_vertbuf_discard(uv_vbo);
- GWN_batch_discard(uv_batch);
-
if (sima->flag & SI_SMOOTH_UV) {
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);