Blender Ktisu: Fix Drawing Sequence Line #157

Merged
Nick Alberelli merged 2 commits from :fix/blender-kitsu-draw into main 2023-10-31 12:21:18 +01:00
Showing only changes of commit ce2ba33ed5 - Show all commits

View File

@ -30,7 +30,7 @@ from gpu_extras.batch import batch_for_shader
# Shaders and batches
rect_coords = ((0, 0), (1, 0), (1, 1), (0, 1))
indices = ((0, 1, 2), (2, 3, 0))
# Setup shaders only if Blender runs in the foreground.
# If running in the background, no handles are registered, as drawing extra UI
# elements does not make sense.
@ -42,7 +42,7 @@ else:
if not bpy.app.background:
ucolor_2d_shader = gpu.shader.from_builtin(color_key)
ucolor_2d_rect_batch = batch_for_shader(
ucolor_2d_shader, "TRI_FAN", {"pos": rect_coords}
ucolor_2d_shader, "TRIS", {"pos": rect_coords}, indices=indices
)
@ -58,8 +58,6 @@ def draw_line(position: Float2, size: Float2, color: Float4):
gpu.matrix.translate(position)
gpu.matrix.scale(size)
# Render a colored rectangle
ucolor_2d_shader.bind()
ucolor_2d_shader.uniform_float("color", color)
ucolor_2d_rect_batch.draw(ucolor_2d_shader)