[Bf-extensions-cvs] [0c1a64c5] master: enhanced 3d cursor: update version

meta-androcto noreply at git.blender.org
Fri Jun 16 01:31:38 CEST 2017


Commit: 0c1a64c58a85dc3cdccec69392d0c9bac628a45a
Author: meta-androcto
Date:   Fri Jun 16 09:31:09 2017 +1000
Branches: master
https://developer.blender.org/rBAC0c1a64c58a85dc3cdccec69392d0c9bac628a45a

enhanced 3d cursor: update version

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

M	space_view3d_enhanced_3d_cursor.py

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

diff --git a/space_view3d_enhanced_3d_cursor.py b/space_view3d_enhanced_3d_cursor.py
index 82f06bad..2f20f6c7 100644
--- a/space_view3d_enhanced_3d_cursor.py
+++ b/space_view3d_enhanced_3d_cursor.py
@@ -21,7 +21,7 @@ bl_info = {
     "name": "Enhanced 3D Cursor",
     "description": "Cursor history and bookmarks; drag/snap cursor.",
     "author": "dairin0d",
-    "version": (3, 0, 1),
+    "version": (3, 0, 2),
     "blender": (2, 7, 7),
     "location": "View3D > Action mouse; F10; Properties panel",
     "warning": "",
@@ -157,6 +157,8 @@ class EnhancedSetCursor(bpy.types.Operator):
     key_coordsys_map = {
         'LEFT_BRACKET':-1,
         'RIGHT_BRACKET':1,
+        ':':-1, # Instead of [ for French keyboards
+        '!':1, # Instead of ] for French keyboards
         'J':'VIEW',
         'K':"Surface",
         'L':'LOCAL',
@@ -476,9 +478,20 @@ class EnhancedSetCursor(bpy.types.Operator):
                 self.coord_format = "{:." + \
                     str(settings.free_coord_precision) + "f}"
 
+            new_orient1 = self.key_coordsys_map.get(event.type, None)
+            new_orient2 = self.key_coordsys_map.get(event.unicode, None)
+            new_orientation = (new_orient1 or new_orient2)
+            if new_orientation:
+                self.csu.set_orientation(new_orientation)
+
+                self.update_origin_projection(context)
+
+                if event.ctrl:
+                    self.snap_to_system_origin()
+
             if (event.type == 'ZERO') and event.ctrl:
                 self.snap_to_system_origin()
-            else:
+            elif new_orientation is None: # avoid conflicting shortcuts
                 self.process_axis_input(event)
 
             if event.alt:
@@ -505,15 +518,6 @@ class EnhancedSetCursor(bpy.types.Operator):
                             ttext += c
                         self.set_axes_text(ttext, True)
 
-            if event.type in self.key_coordsys_map:
-                new_orientation = self.key_coordsys_map[event.type]
-                self.csu.set_orientation(new_orientation)
-
-                self.update_origin_projection(context)
-
-                if event.ctrl:
-                    self.snap_to_system_origin()
-
             if event.type in self.key_map["use_object_centers"]:
                 v3d.use_pivot_point_align = not v3d.use_pivot_point_align
 
@@ -2663,9 +2667,18 @@ class Snap3DUtility(SnapUtilityBase):
                 # returns points in flipped order
                 lb, la = sec
 
+            # Note: in 2.77 the ray_cast API has changed.
+            # was: location, normal, index
+            # now: result, location, normal, index
+            def ray_cast(obj, la, lb):
+                res = obj.ray_cast(la, lb)
+                if bpy.app.version < (2, 77, 0):
+                    return ((res[-1] >= 0), res[0], res[1], res[2])
+                return res
+
             # Does ray actually intersect something?
             try:
-                success, lp, ln, face_id = obj.ray_cast(obj, la, lb)
+                success, lp, ln, face_id = ray_cast(obj, la, lb)
             except Exception as e:
                 # Somewhy this seems to happen when snapping cursor
                 # in Local View mode at least since r55223:
@@ -2676,7 +2689,7 @@ class Snap3DUtility(SnapUtilityBase):
                     # Work-around: in Local View at least the object
                     # in focus permits raycasting (modifiers are
                     # applied in 'PREVIEW' mode)
-                    success, lp, ln, face_id = orig_obj.ray_cast(la, lb)
+                    success, lp, ln, face_id = ray_cast(orig_obj, la, lb)
                 except Exception as e:
                     # However, in Edit mode in Local View we have
                     # no luck -- during the edit mode, mesh is
@@ -4006,6 +4019,13 @@ class Cursor3DToolsSettings(bpy.types.PropertyGroup):
         type=TransformExtraOptionsProp,
         options={'HIDDEN'})
 
+    cursor_visible = bpy.props.BoolProperty(
+        name="Cursor visibility",
+        description="Show/hide cursor. When hidden, "\
+"Blender continuously redraws itself (eats CPU like crazy, "\
+"and becomes the less responsive the more complex scene you have)!",
+        default=True)
+
     cursor_lock = bpy.props.BoolProperty(
         name="Lock cursor location",
         description="Prevent accidental cursor movement",
@@ -4175,9 +4195,14 @@ class Cursor3DTools(bpy.types.Panel):
             text="", icon='SNAP_ON', toggle=True)
 
         row = layout.split(0.5)
-        subrow = row.split(1)
+        subrow = row.split(0.5)
         subrow.prop(settings, "cursor_lock", text="", toggle=True,
                  icon=('LOCKED' if settings.cursor_lock else 'UNLOCKED'))
+        subrow = subrow.split(1)
+        subrow.alert = True
+        subrow.prop(settings, "cursor_visible", text="", toggle=True,
+                 icon=('RESTRICT_VIEW_OFF' if settings.cursor_visible
+                       else 'RESTRICT_VIEW_ON'))
         row = row.split(1 / 3, align=True)
         row.prop(settings, "draw_N",
             text="N", toggle=True, index=0)
@@ -5292,6 +5317,36 @@ def draw_callback_view(self, context):
             color_prev[3])
 
     cursor_save_location = Vector(context.space_data.cursor_location)
+    if not settings.cursor_visible:
+        # This is causing problems! See <https://developer.blender.org/T33197>
+        #bpy.context.space_data.cursor_location = Vector([float('nan')] * 3)
+
+        region = context.region
+        v3d = context.space_data
+        rv3d = context.region_data
+
+        pixelsize = 1
+        dpi = context.user_preferences.system.dpi
+        widget_unit = (pixelsize * dpi * 20.0 + 36.0) / 72.0
+
+        cursor_w = widget_unit*2
+        cursor_h = widget_unit*2
+
+        viewinv = rv3d.view_matrix.inverted()
+        persinv = rv3d.perspective_matrix.inverted()
+
+        origin_start = viewinv.translation
+        view_direction = viewinv.col[2].xyz#.normalized()
+        depth_location = origin_start - view_direction
+
+        coord = (-cursor_w, -cursor_h)
+        dx = (2.0 * coord[0] / region.width) - 1.0
+        dy = (2.0 * coord[1] / region.height) - 1.0
+        p = ((persinv.col[0].xyz * dx) +
+             (persinv.col[1].xyz * dy) +
+             depth_location)
+
+        context.space_data.cursor_location = p
 
 def draw_callback_header_px(self, context):
     r = context.region
@@ -5316,6 +5371,9 @@ def draw_callback_px(self, context):
         return
     library = settings.libraries.get_item()
 
+    if not settings.cursor_visible:
+        context.space_data.cursor_location = cursor_save_location
+
     tfm_operator = CursorDynamicSettings.active_transform_operator
 
     if settings.show_bookmarks and library:



More information about the Bf-extensions-cvs mailing list