From 026bd3ea750362ecab0ad4f3c19d978632768d9b Mon Sep 17 00:00:00 2001 From: mano-wii Date: Fri, 28 Jun 2019 10:31:11 -0300 Subject: mesh_snap_utilities_line: Fix local contrain --- mesh_snap_utilities_line/__init__.py | 2 +- mesh_snap_utilities_line/common_classes.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mesh_snap_utilities_line/__init__.py b/mesh_snap_utilities_line/__init__.py index 59a22be1..c78489d3 100644 --- a/mesh_snap_utilities_line/__init__.py +++ b/mesh_snap_utilities_line/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "Snap_Utilities_Line", "author": "Germano Cavalcante", - "version": (5, 9, 17), + "version": (5, 9, 18), "blender": (2, 80, 0), "location": "View3D > TOOLS > Line Tool", "description": "Extends Blender Snap controls", diff --git a/mesh_snap_utilities_line/common_classes.py b/mesh_snap_utilities_line/common_classes.py index 7be2fa97..611b07da 100644 --- a/mesh_snap_utilities_line/common_classes.py +++ b/mesh_snap_utilities_line/common_classes.py @@ -230,6 +230,7 @@ class Constrain: self.orientation[1] = obj.matrix_world.to_3x3().transposed() self.orientation_id = 0 + self.center = Vector((0.0, 0.0, 0.0)) self.center_2d = Vector((0.0, 0.0)) self.projected_vecs = Matrix(([0.0, 0.0], [0.0, 0.0], [0.0, 0.0])) @@ -300,16 +301,19 @@ class Constrain: else: self.preferences.auto_constrain = True - def update(self, region, rv3d, mcursor, location): - if rv3d.view_matrix != self.rotMat: + def update(self, region, rv3d, mcursor, center): + if rv3d.view_matrix != self.rotMat or self.center != center: self.rotMat = rv3d.view_matrix.copy() - self.center_2d = location_3d_to_region_2d(region, rv3d, location) + self.center = center.copy() + self.center_2d = location_3d_to_region_2d(region, rv3d, self.center) - orig = location_3d_to_region_2d(region, rv3d, Vector()) - self.projected_vecs[0] = location_3d_to_region_2d(region, rv3d, self.orientation[self.orientation_id][0]) - orig - self.projected_vecs[1] = location_3d_to_region_2d(region, rv3d, self.orientation[self.orientation_id][1]) - orig - self.projected_vecs[2] = location_3d_to_region_2d(region, rv3d, self.orientation[self.orientation_id][2]) - orig + vec = self.center + self.orientation[self.orientation_id][0] + self.projected_vecs[0] = location_3d_to_region_2d(region, rv3d, vec) - self.center_2d + vec = self.center + self.orientation[self.orientation_id][1] + self.projected_vecs[1] = location_3d_to_region_2d(region, rv3d, vec) - self.center_2d + vec = self.center + self.orientation[self.orientation_id][2] + self.projected_vecs[2] = location_3d_to_region_2d(region, rv3d, vec) - self.center_2d self.projected_vecs[0].normalize() self.projected_vecs[1].normalize() @@ -478,8 +482,7 @@ class SnapUtilities: preferences.constrain_shift_color, tuple(context.preferences.themes[0].user_interface.axis_x) + (1.0,), tuple(context.preferences.themes[0].user_interface.axis_y) + (1.0,), - tuple(context.preferences.themes[0].user_interface.axis_z) + (1.0,) - ) + tuple(context.preferences.themes[0].user_interface.axis_z) + (1.0,)) self.snap_vert = self.snap_edge = snap_edge_and_vert -- cgit v1.2.3