[Bf-extensions-cvs] [31057804] master: Enhanced 3D cursor: now the change in ray_cast() semantics introduced in Blender 2.77 is handled properly

dairin0d noreply at git.blender.org
Mon Jan 8 05:11:28 CET 2018


Commit: 310578043dec1aae382eb6a447ae1d103792d7e6
Author: dairin0d
Date:   Mon Jan 8 06:11:24 2018 +0200
Branches: master
https://developer.blender.org/rBAC310578043dec1aae382eb6a447ae1d103792d7e6

Enhanced 3D cursor: now the change in ray_cast() semantics introduced in Blender 2.77 is handled properly

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

M	space_view3d_enhanced_3d_cursor.py

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

diff --git a/space_view3d_enhanced_3d_cursor.py b/space_view3d_enhanced_3d_cursor.py
index b3c69451..71d4c9d1 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, 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:



More information about the Bf-extensions-cvs mailing list