Skip to content

Commit

Permalink
chore: update set_3d_cursor_to* functions to get_*_transform in view_…
Browse files Browse the repository at this point in the history
…align operator
  • Loading branch information
tristan-hm committed May 7, 2022
1 parent 6cf9461 commit 152c3be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sketching/view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def prepare_evaluated_geometry(self, context):
context.object.data.name = 'ND — View Align'


def set_3d_cursor_to_face(self, mesh, world_matrix):
def get_face_transform(self, mesh, world_matrix):
selected_faces = [f for f in mesh.faces if f.select]
center = v3_average([f.calc_center_median_weighted() for f in selected_faces])
location = world_matrix @ center
Expand All @@ -133,7 +133,7 @@ def set_3d_cursor_to_face(self, mesh, world_matrix):
return (location, rotation)


def set_3d_cursor_to_edge(self, mesh, world_matrix):
def get_edge_transform(self, mesh, world_matrix):
selected_edges = [e for e in mesh.edges if e.select]
center = v3_average([v3_center(*e.verts) for e in selected_edges])
location = world_matrix @ center
Expand All @@ -142,7 +142,7 @@ def set_3d_cursor_to_edge(self, mesh, world_matrix):
return (location, rotation)


def set_3d_cursor_to_vertex(self, mesh, world_matrix):
def get_vertex_transform(self, mesh, world_matrix):
selected_vertices = [v for v in mesh.verts if v.select]
center = v3_average([v.co for v in selected_vertices])
location = world_matrix @ center
Expand Down Expand Up @@ -171,13 +171,13 @@ def prepare_view_align(self, context):
self.set_custom_transform_orientation()

if self.selection_type == 0:
(location, rotation) = self.set_3d_cursor_to_vertex(mesh, world_matrix)
(location, rotation) = self.get_vertex_transform(mesh, world_matrix)
set_3d_cursor(location, rotation.to_quaternion())
elif self.selection_type == 1:
(location, rotation) = self.set_3d_cursor_to_edge(mesh, world_matrix)
(location, rotation) = self.get_edge_transform(mesh, world_matrix)
set_3d_cursor(location, rotation.to_quaternion())
elif self.selection_type == 2:
(location, rotation) = self.set_3d_cursor_to_face(mesh, world_matrix)
(location, rotation) = self.get_face_transform(mesh, world_matrix)
set_3d_cursor(location, rotation.to_quaternion())


Expand Down

0 comments on commit 152c3be

Please sign in to comment.