text stringlengths 1 93.6k |
|---|
if self.current_state == State.IDLE: # no source picked
|
draw_square_2d(source_x, source_y, square_width)
|
else:
|
# logger.info(f"source picked . self.target2d={self.target2d} - self.settings.draw_rubberband={self.settings.draw_rubberband}")
|
if self.closest_target_id >= 0:
|
color = (0, 1, 0, 1)
|
else:
|
color = (1, 1, 0, 1)
|
if self.settings.draw_rubberband:
|
draw_square_2d(source_x, source_y, square_width, color=color)
|
# if self.target2d:
|
if self.target is not None:
|
target_position_2d = bpy_extras.view3d_utils.location_3d_to_region_2d(context.region,
|
context.space_data.region_3d,
|
self.target)
|
target_x, target_y = target_position_2d[0], target_position_2d[1]
|
if self.closest_target_id >= 0:
|
snap_target_2d = bpy_extras.view3d_utils.location_3d_to_region_2d(
|
context.region,
|
context.space_data.region_3d,
|
self.snapdata_target.world_space[self.closest_target_id])
|
if len(self.snapping) > 0:
|
draw_square_2d(target_x, target_y, square_width,
|
color=color, line_width=0) # dot to target
|
draw_square_2d(snap_target_2d[0], snap_target_2d[1], square_width, color=color) # square to snapped point
|
else:
|
draw_square_2d(target_x, target_y, square_width, color=color)
|
else:
|
draw_square_2d(target_x, target_y, square_width, color=color,
|
line_width=0) # dot to target
|
if self.settings.draw_rubberband:
|
draw_line_2d(source_x, source_y, target_x, target_y, line_width=1, color=color)
|
elif self.current_state == State.IDLE:
|
# Draw grey square when tool is enabled, additional indication that the tool is active
|
draw_square_2d(self.mouse_position[0], self.mouse_position[1], square_width, color=(1, 1, 1, 0.3), point_width=0)
|
def draw_snap_axis(self, context):
|
"""
|
Draw axis lines depending on QuickSNap operator snapping settings.
|
"""
|
if self.closest_source_id >= 0 and self.snapping != "":
|
point_position = self.snapdata_source.world_space[self.closest_source_id]
|
if self.snapping_local:
|
for object_name in self.selection_objects:
|
obj_matrix = bpy.data.objects[object_name].matrix_world
|
if 'X' in self.snapping:
|
axis_x = Vector((obj_matrix[0][0], obj_matrix[1][0], obj_matrix[2][0])).normalized()
|
start = point_position + axis_x * 10 ** 5
|
end = point_position - axis_x * 10 ** 5
|
draw_line_3d(start, end, (1, 0.5, 0.5, 0.6), 1)
|
if 'Y' in self.snapping:
|
axis_y = Vector((obj_matrix[0][1], obj_matrix[1][1], obj_matrix[2][1])).normalized()
|
start = point_position + axis_y * 10 ** 5
|
end = point_position - axis_y * 10 ** 5
|
draw_line_3d(start, end, (0.5, 1, 0.5, 0.6), 1)
|
if 'Z' in self.snapping:
|
axis_z = Vector((obj_matrix[0][2], obj_matrix[1][2], obj_matrix[2][2])).normalized()
|
start = point_position + axis_z * 10 ** 5
|
end = point_position - axis_z * 10 ** 5
|
draw_line_3d(start, end, (0.2, 0.6, 1, 0.6), 1)
|
else:
|
if 'X' in self.snapping:
|
start = point_position.copy()
|
start[0] = start[0] + 10 ** 5
|
end = point_position.copy()
|
end[0] = end[0] - 10 ** 5
|
draw_line_3d(start, end, (1, 0.5, 0.5, 0.6), 1)
|
if 'Y' in self.snapping:
|
start = point_position.copy()
|
start[1] = start[1] + 10 ** 5
|
end = point_position.copy()
|
end[1] = end[1] - 10 ** 5
|
draw_line_3d(start, end, (0.5, 1, 0.5, 0.6), 1)
|
if 'Z' in self.snapping:
|
start = point_position.copy()
|
start[2] = start[2] + 10 ** 5
|
end = point_position.copy()
|
end[2] = end[2] - 10 ** 5
|
draw_line_3d(start, end, (0.2, 0.6, 1, 0.6), 1)
|
indices_bounds = (
|
(0, 1), (1, 2), (2, 3), (3, 0),
|
(4, 5), (5, 6), (6, 7), (7, 4),
|
(0, 4), (1, 5), (2, 6), (3, 7),
|
)
|
def draw_bounds(points, color=(1, 1, 0, 1), line_width=3, depth_test=False):
|
"""
|
Draw edges of bounds cube. Inputs bounds vertices.
|
"""
|
if line_width != 1:
|
gpu.state.line_width_set(line_width)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.