Revert "Fix T59505: Knife tool cut preview line becomes black"

This reverts commit dafaa6f228.
This commit is contained in:
Germano Cavalcante 2018-12-23 23:18:07 -02:00
parent 94dfa6eaac
commit 34a538ba1b
Notes: blender-bot 2023-02-14 08:06:33 +01:00
Referenced by issue #59505, Knife tool cut preview line becomes black.
1 changed files with 15 additions and 13 deletions

View File

@ -213,6 +213,8 @@ typedef struct KnifeTool_OpData {
/* vector along view z axis (object space, normalized) */
float proj_zaxis[3];
KnifeColors colors;
/* run by the UI or not */
bool is_interactive;
@ -1039,10 +1041,8 @@ static void knife_init_colors(KnifeColors *colors)
static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
{
const KnifeTool_OpData *kcd = arg;
KnifeColors colors;
knife_init_colors(&colors);
GPU_depth_test(false);
glPolygonOffset(1.0f, 1.0f);
GPU_matrix_push();
@ -1058,7 +1058,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
if (kcd->mode == MODE_DRAGGING) {
immUniformColor3ubv(colors.line);
immUniformColor3ubv(kcd->colors.line);
GPU_line_width(2.0);
immBegin(GPU_PRIM_LINES, 2);
@ -1068,7 +1068,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
}
if (kcd->prev.vert) {
immUniformColor3ubv(colors.point);
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(11);
immBegin(GPU_PRIM_POINTS, 1);
@ -1077,7 +1077,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
}
if (kcd->prev.bmface) {
immUniformColor3ubv(colors.curpoint);
immUniformColor3ubv(kcd->colors.curpoint);
GPU_point_size(9);
immBegin(GPU_PRIM_POINTS, 1);
@ -1086,7 +1086,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
}
if (kcd->curr.edge) {
immUniformColor3ubv(colors.edge);
immUniformColor3ubv(kcd->colors.edge);
GPU_line_width(2.0);
immBegin(GPU_PRIM_LINES, 2);
@ -1095,7 +1095,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
immEnd();
}
else if (kcd->curr.vert) {
immUniformColor3ubv(colors.point);
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(11);
immBegin(GPU_PRIM_POINTS, 1);
@ -1104,7 +1104,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
}
if (kcd->curr.bmface) {
immUniformColor3ubv(colors.curpoint);
immUniformColor3ubv(kcd->colors.curpoint);
GPU_point_size(9);
immBegin(GPU_PRIM_POINTS, 1);
@ -1137,14 +1137,14 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
/* draw any snapped verts first */
rgba_uchar_to_float(fcol, colors.point_a);
rgba_uchar_to_float(fcol, kcd->colors.point_a);
GPU_batch_uniform_4fv(batch, "color", fcol);
GPU_matrix_bind(batch->interface);
GPU_point_size(11);
GPU_batch_draw_range_ex(batch, 0, v - 1, false);
/* now draw the rest */
rgba_uchar_to_float(fcol, colors.curpoint_a);
rgba_uchar_to_float(fcol, kcd->colors.curpoint_a);
GPU_batch_uniform_4fv(batch, "color", fcol);
GPU_point_size(7);
GPU_batch_draw_range_ex(batch, vs + 1, kcd->totlinehit - (vs + 1), false);
@ -1159,7 +1159,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iter iter;
KnifeEdge *kfe;
immUniformColor3ubv(colors.line);
immUniformColor3ubv(kcd->colors.line);
GPU_line_width(1.0);
GPUBatch *batch = immBeginBatchAtMost(GPU_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2);
@ -1183,7 +1183,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iter iter;
KnifeVert *kfv;
immUniformColor3ubv(colors.point);
immUniformColor3ubv(kcd->colors.point);
GPU_point_size(5.0);
GPUBatch *batch = immBeginBatchAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts));
@ -2682,6 +2682,8 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
if (is_interactive) {
kcd->draw_handle = ED_region_draw_cb_activate(kcd->ar->type, knifetool_draw, kcd, REGION_DRAW_POST_VIEW);
knife_init_colors(&kcd->colors);
}
}