text stringlengths 1 93.6k |
|---|
draw_face_center(self, context,
|
target_object=self.hover_object,
|
face_index=self.target_face_index,
|
allowed_indices=self.target_allowed_indices[self.hover_object],
|
snap_type=self.snapdata_target.snap_type,
|
ignore_modifiers=self.settings.ignore_modifiers or (
|
is_selection and not self.object_mode),
|
color=point_color[False]
|
)
|
if self.closest_target_id in self.snapdata_target.origins_map:
|
obj_name = self.snapdata_target.origins_map[self.closest_target_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_target_id,
|
snapdata=self.snapdata_target,
|
highlight_data=self.target_highlight_data,
|
npdata=self.target_npdata,
|
ignore_modifiers=self.settings.ignore_modifiers or (
|
self.target_object in self.selection_objects and not self.object_mode),
|
width=self.settings.edge_highlight_width,
|
color=self.settings.edge_highlight_color_target,
|
opacity=self.settings.edge_highlight_opacity)
|
def add_camera_offset(co, camera_position, camera_vector, is_ortho):
|
"""
|
Offset a point towards the camera position to avoid z-fighting.
|
"""
|
cam_point_vector = camera_position - co
|
if is_ortho:
|
return co - camera_vector * np.sqrt(cam_point_vector.dot(cam_point_vector)) * 0.01
|
else:
|
return co + cam_point_vector * 0.01
|
def draw_edge_highlight(context,
|
target_object,
|
target_id,
|
snapdata,
|
highlight_data,
|
npdata,
|
ignore_modifiers,
|
width=2,
|
color=(1, 1, 0),
|
opacity=1
|
):
|
"""
|
Store necessary information and draw edge highlight of tht target point/edge/face.
|
"""
|
if target_id >= 0:
|
if len(snapdata.indices) <= target_id:
|
return
|
vert_index = snapdata.indices[target_id]
|
if vert_index < 0:
|
return
|
vert_object = bpy.data.objects[target_object]
|
if vert_object.type != "MESH":
|
return
|
if target_object not in highlight_data:
|
highlight_data[target_object] = {}
|
if vert_index not in highlight_data[target_object]:
|
matrix = vert_object.matrix_world
|
if ignore_modifiers:
|
data = vert_object.data
|
else:
|
data = vert_object.evaluated_get(context.evaluated_depsgraph_get()).data
|
if snapdata.snap_type == 'POINTS':
|
if target_object not in npdata:
|
npdata[target_object] = {}
|
if "edge_verts" not in npdata[target_object]:
|
arr = np.zeros(len(data.edges) * 2, dtype=int)
|
data.edges.foreach_get('vertices', arr)
|
arr.shape = (len(data.edges), 2)
|
npdata[target_object]["edge_verts"] = arr
|
filter_left = npdata[target_object]["edge_verts"][
|
npdata[target_object]["edge_verts"][:, 0] == vert_index]
|
filter_right = npdata[target_object]["edge_verts"][
|
npdata[target_object]["edge_verts"][:, 1] == vert_index]
|
highlight_data[target_object][vert_index] = {}
|
highlight_data[target_object][vert_index]["edges"] = []
|
for match in filter_left:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.