[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3234] contrib/py/scripts/addons/ space_view3d_enhanced_3d_cursor.py: Disabled mesh.update(calc_tessface=True ) in raycasting code -- it conflicts with object.ray_cast() from around 45447 revision; fixed bbox snapping

dima glib dima.glib at gmail.com
Sat Apr 7 12:58:19 CEST 2012


Revision: 3234
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3234
Author:   dairin0d
Date:     2012-04-07 10:58:18 +0000 (Sat, 07 Apr 2012)
Log Message:
-----------
Disabled mesh.update(calc_tessface=True) in raycasting code -- it conflicts with object.ray_cast() from around 45447 revision; fixed bbox snapping

Modified Paths:
--------------
    contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py

Modified: contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py	2012-04-06 20:30:39 UTC (rev 3233)
+++ contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py	2012-04-07 10:58:18 UTC (rev 3234)
@@ -21,8 +21,8 @@
     "name": "Enhanced 3D Cursor",
     "description": "Cursor history and bookmarks; drag/snap cursor.",
     "author": "dairin0d",
-    "version": (2, 8, 1),
-    "blender": (2, 6, 0),
+    "version": (2, 8, 5),
+    "blender": (2, 6, 3),
     "location": "View3D > Action mouse; F10; Properties panel",
     "warning": "",
     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
@@ -33,6 +33,14 @@
 #============================================================================#
 
 """
+ATTENTION:
+somewhere around 45447 revision object.ray_cast() starts conflicting with
+mesh.update(calc_tessface=True) -- at least when invoked within one
+operator cycle, object.ray_cast() crashes if object's tessfaces were
+update()d earlier in the code. However, not update()ing the meshes
+seems to work fine -- ray_cast() does its job, and it's possible to
+access tessfaces afterwards.
+
 Breakdown:
     Addon registration
     Keymap utils
@@ -2429,6 +2437,7 @@
         bm = prepare_gridbox_mesh(subdiv=2)
         mesh = bpy.data.meshes.new(tmp_name)
         bm.to_mesh(mesh)
+        mesh.update(calc_tessface=True)
         
         self.bbox_obj = self.cache.create_temporary_mesh_obj(mesh, Matrix())
         self.bbox_obj.hide = True
@@ -2491,7 +2500,7 @@
                 sys_matrix = m.copy()
                 try:
                     sys_matrix_inv = sys_matrix.inverted()
-                except:
+                except Exception:
                     # this is some degenerate system
                     sys_matrix_inv = Matrix()
             m_combined = sys_matrix_inv * m
@@ -2518,12 +2527,9 @@
         
         half = (bbox[1] - bbox[0]) * 0.5
         
-        sys_matrix3 = sys_matrix.to_3x3()
-        
-        m = Matrix()
-        m[0][:3] = sys_matrix3 * Vector((half[0], 0, 0))
-        m[1][:3] = sys_matrix3 * Vector((0, half[1], 0))
-        m[2][:3] = sys_matrix3 * Vector((0, 0, half[2]))
+        m = Matrix(((half[0], 0, 0), (0, half[1], 0), (0, 0, half[2])))
+        m = sys_matrix.to_3x3() * m
+        m.resize_4x4()
         m.translation[:3] = sys_matrix * (bbox[0] + half)
         self.bbox_obj.matrix_world = m
         
@@ -2911,7 +2917,7 @@
                 if self.edit_object is None:
                     self.edit_object = self.__convert(
                                 obj, True, False, False)
-                    self.edit_object.data.update(calc_tessface=True)
+                    #self.edit_object.data.update(calc_tessface=True)
                 return self.edit_object
         
         # A usual object. Cached data will suffice.
@@ -2930,7 +2936,8 @@
             rco = None
         
         self.object_cache[obj] = rco
-        rco.data.update(calc_tessface=True)
+        if rco:
+            pass#rco.data.update(calc_tessface=True)
         
         return rco
     



More information about the Bf-extensions-cvs mailing list