Enhanced 3D cursor: now the change in ray_cast() semantics introduced in Blender...
authordairin0d <dima.glib@gmail.com>
Mon, 8 Jan 2018 04:11:24 +0000 (06:11 +0200)
committerdairin0d <dima.glib@gmail.com>
Mon, 8 Jan 2018 04:11:24 +0000 (06:11 +0200)
space_view3d_enhanced_3d_cursor.py

index b3c6945..71d4c9d 100644 (file)
@@ -21,7 +21,7 @@ bl_info = {
     "name": "Enhanced 3D Cursor",
     "description": "Cursor history and bookmarks; drag/snap cursor.",
     "author": "dairin0d",
-    "version": (3, 0, 4),
+    "version": (3, 0, 5),
     "blender": (2, 7, 7),
     "location": "View3D > Action mouse; F10; Properties panel",
     "warning": "",
@@ -2669,14 +2669,17 @@ 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):
+                    # Object.ray_cast(start, end)
+                    # returns (location, normal, index)
+                    res = obj.ray_cast(la, lb)
                     return ((res[-1] >= 0), res[0], res[1], res[2])
-                return res
+                else:
+                    # Object.ray_cast(origin, direction, [distance])
+                    # returns (result, location, normal, index)
+                    ld = lb - la
+                    return obj.ray_cast(la, ld, ld.magnitude)
 
             # Does ray actually intersect something?
             try: