text stringlengths 1 93.6k |
|---|
gpu.state.blend_set("ALPHA")
|
if depth_test:
|
gpu.state.depth_test_set("LESS")
|
vertices = points
|
batch = batch_for_shader(shader_3d_uniform_color, 'LINES', {"pos": vertices}, indices=indices_bounds)
|
shader_3d_uniform_color.bind()
|
shader_3d_uniform_color.uniform_float("color", color)
|
batch.draw(shader_3d_uniform_color)
|
if line_width != 1:
|
gpu.state.line_width_set(1)
|
gpu.state.blend_set("NONE")
|
if depth_test:
|
gpu.state.depth_test_set("NONE")
|
sel_color = bpy.context.preferences.themes[0].view_3d.object_active
|
point_color = {
|
True: (sel_color[0], sel_color[1], sel_color[2]),
|
False: (0, 0, 0)
|
}
|
def draw_callback_3d(self, context):
|
"""
|
Draw all 3D ui for QuickSnap: Snap axis, edge/points highlight.
|
"""
|
draw_snap_axis(self, context)
|
if self.current_state == State.IDLE and not (self.object_mode and self.no_selection):
|
coords = [self.snapdata_source.world_space[objectid] for objectid in self.snapdata_source.origins_map]
|
else:
|
coords = [self.snapdata_target.world_space[objectid] for objectid in self.snapdata_target.origins_map]
|
if (self.current_state == State.IDLE and self.snapdata_source.snap_type == 'ORIGINS')\
|
or (self.current_state == State.SOURCE_PICKED and self.snapdata_target.snap_type == 'ORIGINS'):
|
draw_points_3d(coords, point_width=5)
|
elif self.settings.snap_objects_origin == 'ALWAYS':
|
draw_points_3d(coords, color=(1, 1, 0, 0.5), point_width=3, depth_test=True)
|
if self.settings.highlight_target_vertex_edges or self.settings.display_potential_target_points:
|
if self.current_state == State.IDLE:
|
if not self.settings.ignore_modifiers and self.hover_object != '' and \
|
self.settings.display_potential_target_points:
|
if self.hover_object not in self.source_allowed_indices:
|
if not (self.no_selection and self.object_mode):
|
allowed_indices = self.snapdata_source.indices[:self.snapdata_source.added_points_np]
|
object_indices = self.snapdata_source.object_id[:self.snapdata_source.added_points_np]
|
self.source_allowed_indices[self.hover_object] = allowed_indices[
|
object_indices == self.snapdata_source.scene_meshes.index(self.hover_object)]
|
else:
|
self.source_allowed_indices[self.hover_object] = None
|
draw_face_center(self, context,
|
target_object=self.hover_object,
|
face_index=self.target_face_index,
|
allowed_indices=self.source_allowed_indices[self.hover_object],
|
snap_type=self.snapdata_source.snap_type,
|
ignore_modifiers=self.settings.ignore_modifiers or not self.object_mode,
|
color=point_color[not self.no_selection]
|
)
|
if self.closest_source_id in self.snapdata_source.origins_map:
|
obj_name = self.snapdata_source.origins_map[self.closest_source_id]
|
if obj_name not in self.target_bounds:
|
obj = bpy.data.objects[obj_name]
|
bound_points = [v[:] for v in obj.bound_box]
|
region3d = context.space_data.region_3d
|
camera_position = region3d.view_matrix.inverted().translation
|
camera_vector = region3d.view_rotation @ Vector((0.0, 0.0, -1.0))
|
is_ortho = region3d.view_perspective == 'ORTHO'
|
points = [obj.matrix_world @ Vector(point) for point in bound_points]
|
self.target_bounds[obj_name] = [add_camera_offset(point,
|
camera_position,
|
camera_vector,
|
is_ortho) for point in points]
|
draw_bounds(self.target_bounds[obj_name], color=(1, 1, 0, 0.8), line_width=1, depth_test=True)
|
return
|
if self.settings.highlight_target_vertex_edges:
|
draw_edge_highlight(context,
|
target_object=self.target_object,
|
target_id=self.closest_source_id,
|
snapdata=self.snapdata_source,
|
highlight_data=self.source_highlight_data,
|
npdata=self.source_npdata,
|
ignore_modifiers=self.settings.ignore_modifiers or not self.object_mode,
|
width=self.settings.edge_highlight_width,
|
color=self.settings.edge_highlight_color_source,
|
opacity=self.settings.edge_highlight_opacity)
|
elif self.current_state == State.SOURCE_PICKED:
|
if not self.settings.ignore_modifiers:
|
if self.hover_object != '' and self.settings.display_potential_target_points:
|
is_selection = self.hover_object in self.selection_objects
|
if self.hover_object not in self.target_allowed_indices:
|
if is_selection:
|
allowed_indices = self.snapdata_target.indices[:self.snapdata_target.added_points_np]
|
object_indices = self.snapdata_target.object_id[:self.snapdata_target.added_points_np]
|
self.target_allowed_indices[self.hover_object] = \
|
allowed_indices[
|
object_indices == self.snapdata_target.scene_meshes.index(self.hover_object)]
|
else:
|
self.target_allowed_indices[self.hover_object] = None
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.