text stringlengths 1 93.6k |
|---|
shader_3d_smooth_color.bind()
|
batch.draw(shader_3d_smooth_color)
|
if line_width != 1:
|
bgl.glLineWidth(1)
|
bgl.glDisable(bgl.GL_BLEND)
|
bgl.glDisable(bgl.GL_LINE_SMOOTH)
|
if depth_test:
|
bgl.glDisable(bgl.GL_DEPTH_TEST)
|
def draw_polygon_smooth_blend(points, indices, color, depth_test):
|
"""
|
Draw a smooth blend polygon in the viewport.
|
"""
|
if bpy.app.version >= (3, 4, 0):
|
gpu.state.blend_set("ALPHA")
|
if depth_test:
|
gpu.state.depth_test_set("LESS")
|
colors = [color] * len(points)
|
batch = batch_for_shader(shader_3d_smooth_color, 'TRIS', {"pos": points, "color": colors}, indices=indices)
|
shader_3d_smooth_color.bind()
|
batch.draw(shader_3d_smooth_color)
|
gpu.state.blend_set("NONE")
|
if depth_test:
|
gpu.state.depth_test_set("NONE")
|
else:
|
bgl.glEnable(bgl.GL_BLEND)
|
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
if depth_test:
|
bgl.glEnable(bgl.GL_DEPTH_TEST)
|
colors = [color] * len(points)
|
batch = batch_for_shader(shader_3d_smooth_color, 'TRIS', {"pos": points, "color": colors}, indices=indices)
|
shader_3d_smooth_color.bind()
|
batch.draw(shader_3d_smooth_color)
|
bgl.glDisable(bgl.GL_BLEND)
|
bgl.glDisable(bgl.GL_LINE_SMOOTH)
|
if depth_test:
|
bgl.glDisable(bgl.GL_DEPTH_TEST)
|
def draw_points_3d(coords, color=(1, 1, 0, 1), point_width=3, depth_test=False):
|
"""
|
Draw a list of points in the viewport.
|
"""
|
gpu.state.blend_set("ALPHA")
|
if depth_test:
|
gpu.state.depth_test_set("LESS")
|
gpu.state.point_size_set(point_width)
|
batch = batch_for_shader(shader_3d_uniform_color, 'POINTS', {"pos": coords})
|
shader_3d_uniform_color.bind()
|
shader_3d_uniform_color.uniform_float("color", color)
|
batch.draw(shader_3d_uniform_color)
|
gpu.state.point_size_set(5)
|
gpu.state.blend_set("NONE")
|
if depth_test:
|
gpu.state.depth_test_set("NONE")
|
ui_scale = bpy.context.preferences.system.ui_scale
|
icon_color = {
|
State.IDLE: (0.917, 0.462, 0, .6),
|
State.SOURCE_PICKED: (1, 1, 0, .6)
|
}
|
icon_display_duration = 2
|
fade_duration = 0.2
|
def draw_callback_2d(self, context):
|
"""
|
Draw all QuickSnap 2D UI: Icons, source/target square. rubberband/
|
"""
|
square_width=self.settings.selection_square_size
|
current_time = time.time()
|
if self.settings.snap_target_type_icon != 'NEVER' and current_time < self.icon_display_time + icon_display_duration or self.settings.snap_target_type_icon == 'ALWAYS':
|
fade = 1
|
if self.settings.snap_target_type_icon == 'FADE' and current_time > self.icon_display_time + \
|
icon_display_duration - fade_duration:
|
fade = (self.icon_display_time - current_time + icon_display_duration) / fade_duration
|
if self.current_state == State.IDLE:
|
draw_image(self, self.mouse_position[0] + 30, self.mouse_position[1] - 30, 22 * ui_scale,
|
image=self.snapdata_source.snap_type, color=icon_color[self.current_state], fade=fade)
|
elif self.current_state == State.SOURCE_PICKED:
|
draw_image(self, self.mouse_position[0] + 30, self.mouse_position[1] - 30, 22 * ui_scale,
|
image=self.snapdata_target.snap_type, color=icon_color[self.current_state], fade=fade)
|
if self.closest_source_id >= 0:
|
source_position_3d = self.snapdata_source.world_space[self.closest_source_id]
|
source_position_2d = bpy_extras.view3d_utils.location_3d_to_region_2d(context.region,
|
context.space_data.region_3d,
|
source_position_3d)
|
source_x, source_y = source_position_2d[0], source_position_2d[1]
|
# Source selection
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.