From 563ea27eb1a8843fdc05b2fe3944dfbdcd4d5a1f Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 21 Jul 2022 23:35:50 -0300 Subject: UV Layout: bring back smooth lines Feature removed in rBAb56a6acb9f4f. --- io_mesh_uv_layout/export_uv_png.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'io_mesh_uv_layout') diff --git a/io_mesh_uv_layout/export_uv_png.py b/io_mesh_uv_layout/export_uv_png.py index 74cd7b19..78f9f6a2 100644 --- a/io_mesh_uv_layout/export_uv_png.py +++ b/io_mesh_uv_layout/export_uv_png.py @@ -23,11 +23,7 @@ def export(filepath, face_data, colors, width, height, opacity): offscreen.free() def draw_image(face_data, opacity): - gpu.state.line_width_set(1.0) gpu.state.blend_set('ALPHA_PREMULT') - # TODO: Use shader that draws a smooth line (Eg. '3D_POLYLINE_UNIFORM_COLOR') - # bgl.glEnable(bgl.GL_LINE_SMOOTH) - # bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST) with gpu.matrix.push_pop(): gpu.matrix.load_matrix(get_normalize_uvs_matrix()) @@ -74,12 +70,15 @@ def draw_lines(face_data): for i in range(len(uvs)): start = uvs[i] end = uvs[(i+1) % len(uvs)] - coords.append((start[0], start[1])) - coords.append((end[0], end[1])) + coords.append((start[0], start[1], 0.0)) + coords.append((end[0], end[1], 0.0)) - shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') + # Use '2D_UNIFORM_COLOR' if smooth lines are not required. + shader = gpu.shader.from_builtin('3D_POLYLINE_UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos" : coords}) shader.bind() + shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:]) + shader.uniform_float("lineWidth", 0.5) shader.uniform_float("color", (0, 0, 0, 1)) batch.draw(shader) -- cgit v1.2.3