[Bf-extensions-cvs] [7d78c8a] master: xedit: code cleanup, better function names

NBurn noreply at git.blender.org
Mon May 3 22:14:14 CEST 2021


Commit: 7d78c8a63f2f4b146f9327ddc0d567a5921b94ea
Author: NBurn
Date:   Mon May 3 16:13:57 2021 -0400
Branches: master
https://developer.blender.org/rBAC7d78c8a63f2f4b146f9327ddc0d567a5921b94ea

xedit: code cleanup, better function names

===================================================================

M	exact_edit/xedit_free_rotate.py
M	exact_edit/xedit_set_meas.py

===================================================================

diff --git a/exact_edit/xedit_free_rotate.py b/exact_edit/xedit_free_rotate.py
index 462a19d..0a4d3be 100644
--- a/exact_edit/xedit_free_rotate.py
+++ b/exact_edit/xedit_free_rotate.py
@@ -138,6 +138,14 @@ def flts_alm_eq(flt_a, flt_b):
     return flt_a > (flt_b - tol) and flt_a < (flt_b + tol)
 
 
+# assume both float lists are same size?
+def flt_lists_alm_eq(ls_a, ls_b, tol=0.001):
+    for i in range(len(ls_a)):
+        if not (ls_a[i] > (ls_b[i] - tol) and ls_a[i] < (ls_b[i] + tol)):
+            return False
+    return True
+
+
 # todo : replace with flt_lists_alm_eq?
 def vec3s_alm_eq(vec_a, vec_b):
     X, Y, Z = 0, 1, 2
@@ -148,14 +156,6 @@ def vec3s_alm_eq(vec_a, vec_b):
     return False
 
 
-# assume both float lists are same size?
-def flt_lists_alm_eq(ls_a, ls_b, tol=0.001):
-    for i in range(len(ls_a)):
-        if not (ls_a[i] > (ls_b[i] - tol) and ls_a[i] < (ls_b[i] + tol)):
-            return False
-    return True
-
-
 class MenuStore:
     def __init__(self):
         self.cnt = 0
@@ -523,7 +523,7 @@ def add_pt(self, co3d):
         self.pt_cnt += 1
         self.menu.change_menu(self.pt_cnt)
         if self.pt_cnt > 1:
-            updatelock_pts(self, self.pts)
+            update_lock_pts(self, self.pts)
         set_mouse_highlight(self)
         ''' Begin Debug
         cnt = self.pt_cnt - 1
@@ -548,7 +548,7 @@ def rem_ref_pt(self, idx):
     for j in range(self.pt_cnt, 3):
         self.pts[j].co3d = None
     if self.pt_cnt > 1:
-        updatelock_pts(self, self.pts)
+        update_lock_pts(self, self.pts)
     else:
         TransDat.axis_lock = None
     self.highlight_mouse = True
@@ -687,7 +687,7 @@ def exit_multi_mode(self):
     else:
         self.pts[self.mod_pt].co3d = m_co3d
         if self.pt_cnt > 1:
-            updatelock_pts(self, self.pts)
+            update_lock_pts(self, self.pts)
         set_mouse_highlight(self)
     self.mod_pt = None
     set_help_text(self, "CLICK")
@@ -940,7 +940,7 @@ def create_z_orient(rot_vec):
                    (new_x.z, new_y.z, new_z.z)))
 
 
-def updatelock_pts(self, ref_pts):
+def update_lock_pts(self, ref_pts):
     '''
     Updates lock points and changes curr_meas_stor to use measure based on
     lock points instead of ref_pts (for axis constrained transformations).
@@ -1303,7 +1303,7 @@ class XEDIT_OT_free_rotate(bpy.types.Operator):
                             swap_ref_pts(self, self.grab_pt, self.swap_pt)
                             self.swap_pt = None
                     self.grab_pt = None
-                    updatelock_pts(self, self.pts)
+                    update_lock_pts(self, self.pts)
                     set_piv(self)
                 else:  # no grab or mod point
                     if self.shift_held:
@@ -1334,7 +1334,7 @@ class XEDIT_OT_free_rotate(bpy.types.Operator):
                                     self.pts[self.grab_pt].co3d = found_pt
                             self.grab_pt = None
                             if self.pt_cnt > 1:
-                                updatelock_pts(self, self.pts)
+                                update_lock_pts(self, self.pts)
                             set_mouse_highlight(self)
                             set_piv(self)
                             set_help_text(self, "CLICK")
@@ -1347,7 +1347,7 @@ class XEDIT_OT_free_rotate(bpy.types.Operator):
                                     self.menu.change_menu(self.pt_cnt)
                                     if self.pt_cnt > 1:
                                         TransDat.axis_lock = None
-                                        updatelock_pts(self, self.pts)
+                                        update_lock_pts(self, self.pts)
                                         set_piv(self)
                                         #if self.pt_cnt
                                     set_mouse_highlight(self)
@@ -1367,7 +1367,7 @@ class XEDIT_OT_free_rotate(bpy.types.Operator):
                                 swap_ref_pts(self, self.grab_pt, self.overlap_idx)
                             self.grab_pt = None
                             if self.pt_cnt > 1:
-                                updatelock_pts(self, self.pts)
+                                update_lock_pts(self, self.pts)
                             set_mouse_highlight(self)
                             set_piv(self)
                             set_help_text(self, "CLICK")
diff --git a/exact_edit/xedit_set_meas.py b/exact_edit/xedit_set_meas.py
index 1c69d13..9165ae3 100644
--- a/exact_edit/xedit_set_meas.py
+++ b/exact_edit/xedit_set_meas.py
@@ -610,7 +610,7 @@ def add_pt(self, co3d):
         self.pt_cnt += 1
         self.menu.change_menu(self.pt_cnt)
         if self.pt_cnt > 1:
-            updatelock_pts(self, self.pts)
+            update_lock_pts(self, self.pts)
         set_mouse_highlight(self)
         set_meas_btn(self)
         ''' Begin Debug
@@ -636,7 +636,7 @@ def rem_ref_pt(self, idx):
     for j in range(self.pt_cnt, 3):
         self.pts[j].co3d = None
     if self.pt_cnt > 1:
-        updatelock_pts(self, self.pts)
+        update_lock_pts(self, self.pts)
     else:
         TransDat.axis_lock = None
     self.highlight_mouse = True
@@ -789,7 +789,7 @@ def exit_multi_mode(self):
     else:
         self.pts[self.mod_pt].co3d = m_co3d
         if self.pt_cnt > 1:
-            updatelock_pts(self, self.pts)
+            update_lock_pts(self, self.pts)
         set_mouse_highlight(self)
     self.mod_pt = None
     set_meas_btn(self)
@@ -929,7 +929,7 @@ def slope_check(pt1, pt2):
     return cmp_ls
 
 
-def get_new_3d_co(self, old_dis, new_dis):
+def get_new_3d_co_on_slope(self, old_dis, new_dis):
     '''
     Finds 3D location that shares same slope of line connecting Anchor
     and Free or that is on axis line going through Anchor.
@@ -1373,7 +1373,7 @@ def do_rotate_old(self):
     bpy.context.tool_settings.transform_pivot_point = deepcopy(piv_back)
 
 
-def updatelock_pts(self, ref_pts):
+def update_lock_pts(self, ref_pts):
     '''
     Updates lock points and changes curr_meas_stor to use measure based on
     lock points instead of ref_pts (for axis constrained transformations).
@@ -1405,7 +1405,7 @@ def axis_key_check(self, new_axis):
     if self.pt_cnt > 1:
         if new_axis != TransDat.axis_lock:
             TransDat.axis_lock = new_axis
-            updatelock_pts(self, self.pts)
+            update_lock_pts(self, self.pts)
             set_meas_btn(self)
 
 
@@ -1421,7 +1421,7 @@ def reset_settings(self):
         self.meas_btn.is_drawn = False
         set_lock_pts(self.pts, self.pt_cnt)
     else:
-        updatelock_pts(self, self.pts)
+        update_lock_pts(self, self.pts)
         self.meas_btn.is_drawn = True
         set_meas_btn(self)
     #self.snap_btn_act = True
@@ -1457,7 +1457,7 @@ def do_transform(self):
     # Onto Transformations...
     if self.transf_type == MOVE:
         #print("  MOVE!!")  # debug
-        new_coor = get_new_3d_co(self, curr_meas_stor, new_meas_stor)
+        new_coor = get_new_3d_co_on_slope(self, curr_meas_stor, new_meas_stor)
         if new_coor is not None:
             do_translation(new_coor, self.pts[0].co3d)
             self.pts[0].co3d = new_coor.copy()
@@ -1465,7 +1465,7 @@ def do_transform(self):
 
     elif self.transf_type == SCALE:
         #print("  SCALE!!")  # debug
-        new_coor = get_new_3d_co(self, curr_meas_stor, new_meas_stor)
+        new_coor = get_new_3d_co_on_slope(self, curr_meas_stor, new_meas_stor)
         if new_coor is not None:
             scale_factor = new_meas_stor / curr_meas_stor
             do_scale(self.pts, scale_factor)
@@ -1817,7 +1817,7 @@ class XEDIT_OT_set_meas(bpy.types.Operator):
                             swap_ref_pts(self, self.grab_pt, self.swap_pt)
                             self.swap_pt = None
                     self.grab_pt = None
-                    updatelock_pts(self, self.pts)
+                    update_lock_pts(self, self.pts)
                     set_meas_btn(self)
                 else:  # no grab or mod point
                     if self.shift_held:
@@ -1848,7 +1848,7 @@ class XEDIT_OT_set_meas(bpy.types.Operator):
                                     self.pts[self.grab_pt].co3d = found_pt
                             self.grab_pt = None
                             if self.pt_cnt > 1:
-                                updatelock_pts(self, self.pts)
+                                update_lock_pts(self, self.pts)
                             set_mouse_highlight(self)
                             set_meas_btn(self)
                             set_help_text(self, "CLICK")
@@ -1860,7 +1860,7 @@ class XEDIT_OT_set_meas(bpy.types.Operator):
                                     self.pt_cnt += 1
                                     self.menu.change_menu(self.pt_cnt)
                                     if self.pt_cnt > 1:
-                                        updatelock_pts(self, self.pts)
+                                        update_lock_pts(self, self.pts)
                                         #if self.pt_cnt
                                     set_mouse_highlight(self)
                                     set_meas_btn(self)
@@ -1881,7 +1881,7 @@ class XEDIT_OT_set_meas(bpy.types.Operator):
                                 set_meas_btn(self)
                             self.grab_pt = None
                             if self.pt_cnt > 1:
-                                updatelock_pts(self, self.pts)
+                                update_lock_pts(self, self.pts)
                             set_mouse_highlight(self)
                             set_meas_btn(self)
                             set_help_text(self, "CLICK")



More information about the Bf-extensions-cvs mailing list