object_collection_manager: replace deprecated bgl module #104547
@ -5,7 +5,6 @@
|
|||||||
import time
|
import time
|
||||||
from math import cos, sin, pi, floor
|
from math import cos, sin, pi, floor
|
||||||
import bpy
|
import bpy
|
||||||
import bgl
|
|
||||||
import blf
|
import blf
|
||||||
import gpu
|
import gpu
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
@ -91,15 +90,13 @@ def draw_rounded_rect(area, shader, color, tl=5, tr=5, bl=5, br=5, outline=False
|
|||||||
bl = round(bl * scale_factor())
|
bl = round(bl * scale_factor())
|
||||||
br = round(br * scale_factor())
|
br = round(br * scale_factor())
|
||||||
|
|
||||||
bgl.glEnable(bgl.GL_BLEND)
|
gpu.state.blend_set('ALPHA')
|
||||||
|
|
||||||
if outline:
|
if outline:
|
||||||
thickness = round(2 * scale_factor())
|
thickness = round(2 * scale_factor())
|
||||||
thickness = max(thickness, 2)
|
thickness = max(thickness, 2)
|
||||||
|
|
||||||
bgl.glLineWidth(thickness)
|
gpu.state.line_width_set(thickness)
|
||||||
|
|||||||
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
|
||||||
bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
|
|
||||||
|
|
||||||
draw_type = 'TRI_FAN' if not outline else 'LINE_STRIP'
|
draw_type = 'TRI_FAN' if not outline else 'LINE_STRIP'
|
||||||
|
|
||||||
@ -296,9 +293,8 @@ def draw_rounded_rect(area, shader, color, tl=5, tr=5, bl=5, br=5, outline=False
|
|||||||
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
|
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_LINE_SMOOTH)
|
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_BLEND)
|
gpu.state.blend_set('NONE')
|
||||||
|
|
||||||
def mouse_in_area(mouse_pos, area, buf = 0):
|
def mouse_in_area(mouse_pos, area, buf = 0):
|
||||||
x = mouse_pos[0]
|
x = mouse_pos[0]
|
||||||
@ -844,11 +840,11 @@ def draw_callback_px(self, context):
|
|||||||
shader.uniform_float("color", icon_color[:] + (1,))
|
shader.uniform_float("color", icon_color[:] + (1,))
|
||||||
batch = batch_for_shader(shader, 'TRI_FAN', {"pos": vertices})
|
batch = batch_for_shader(shader, 'TRI_FAN', {"pos": vertices})
|
||||||
|
|
||||||
bgl.glEnable(bgl.GL_BLEND)
|
gpu.state.blend_set('ALPHA')
|
||||||
|
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_BLEND)
|
gpu.state.blend_set('NONE')
|
||||||
|
|
||||||
# SELECTED OBJECTS
|
# SELECTED OBJECTS
|
||||||
elif not set(selected_objects).isdisjoint(collection_objects):
|
elif not set(selected_objects).isdisjoint(collection_objects):
|
||||||
@ -859,15 +855,12 @@ def draw_callback_px(self, context):
|
|||||||
shader.uniform_float("color", icon_color[:] + (alpha,))
|
shader.uniform_float("color", icon_color[:] + (alpha,))
|
||||||
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
|
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
|
||||||
|
|
||||||
bgl.glLineWidth(2 * scale_factor())
|
gpu.state.line_width_set(2 * scale_factor())
|
||||||
bgl.glEnable(bgl.GL_BLEND)
|
gpu.state.blend_set('ALPHA')
|
||||||
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
|
||||||
bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
|
|
||||||
|
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_LINE_SMOOTH)
|
gpu.state.blend_set('NONE')
|
||||||
bgl.glDisable(bgl.GL_BLEND)
|
|
||||||
|
|
||||||
# OBJECTS
|
# OBJECTS
|
||||||
elif collection_objects:
|
elif collection_objects:
|
||||||
@ -878,11 +871,11 @@ def draw_callback_px(self, context):
|
|||||||
shader.uniform_float("color", icon_color[:] + (alpha,))
|
shader.uniform_float("color", icon_color[:] + (alpha,))
|
||||||
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
|
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
|
||||||
|
|
||||||
bgl.glEnable(bgl.GL_BLEND)
|
gpu.state.blend_set('ALPHA')
|
||||||
|
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_BLEND)
|
gpu.state.blend_set('NONE')
|
||||||
|
|
||||||
|
|
||||||
# X ICON
|
# X ICON
|
||||||
@ -894,14 +887,11 @@ def draw_callback_px(self, context):
|
|||||||
shader.uniform_float("color", X_icon_color[:] + (1,))
|
shader.uniform_float("color", X_icon_color[:] + (1,))
|
||||||
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
|
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
|
||||||
|
|
||||||
bgl.glEnable(bgl.GL_BLEND)
|
gpu.state.blend_set('ALPHA')
|
||||||
bgl.glEnable(bgl.GL_POLYGON_SMOOTH)
|
|
||||||
bgl.glHint(bgl.GL_POLYGON_SMOOTH_HINT, bgl.GL_NICEST)
|
|
||||||
|
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
bgl.glDisable(bgl.GL_POLYGON_SMOOTH)
|
gpu.state.blend_set('NONE')
|
||||||
bgl.glDisable(bgl.GL_BLEND)
|
|
||||||
|
|
||||||
if in_tooltip_area:
|
if in_tooltip_area:
|
||||||
if self.draw_tooltip:
|
if self.draw_tooltip:
|
||||||
|
Loading…
Reference in New Issue
Block a user
line_width_set
should no longer be used.