svn merge -r40034:40051 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / release / scripts / modules / bpy_types.py
index b3127733c1eb8d8da655f510b31722a139c0a96a..6ab2cfd25bc30457ff87a3bbf83beff8d892d7b3 100644 (file)
@@ -183,7 +183,7 @@ class _GenericBone:
     @property
     def center(self):
         """The midpoint between the head and the tail."""
-        return (self.head + self.tail) * 0.5
+        return self.head.lerp(self.tail, 0.5)
 
     @property
     def length(self):
@@ -330,7 +330,8 @@ class Mesh(bpy_types.ID):
         """
         self.vertices.add(len(vertices))
         self.edges.add(len(edges))
-        self.faces.add(len(faces))
+        self.loops.add(sum((len(f) for f in faces)))
+        self.polygons.add(len(faces))
 
         vertices_flat = [f for v in vertices for f in v]
         self.vertices.foreach_set("co", vertices_flat)
@@ -340,19 +341,15 @@ class Mesh(bpy_types.ID):
         self.edges.foreach_set("vertices", edges_flat)
         del edges_flat
 
-        def treat_face(f):
-            if len(f) == 3:
-                if f[2] == 0:
-                    return f[2], f[0], f[1], 0
-                else:
-                    return f[0], f[1], f[2], 0
-            elif f[2] == 0 or f[3] == 0:
-                return f[2], f[3], f[0], f[1]
-            return f
-
-        faces_flat = [v for f in faces for v in treat_face(f)]
-        self.faces.foreach_set("vertices_raw", faces_flat)
-        del faces_flat
+        # this is different in bmesh
+        loop_index = 0
+        for i, p in enumerate(self.polygons):
+            f = faces[i]
+            loop_len = len(f)
+            p.loop_start = loop_index
+            p.loop_total = loop_len
+            p.vertices = f
+            loop_index += loop_len
 
     @property
     def edge_keys(self):
@@ -585,7 +582,7 @@ class _GenericUI:
         draw_funcs = cls._dyn_ui_initialize()
         try:
             draw_funcs.remove(draw_func)
-        except:
+        except ValueError:
             pass