author Campbell Barton Sun, 19 Feb 2012 18:41:30 +0000 (18:41 +0000) committer Campbell Barton Sun, 19 Feb 2012 18:41:30 +0000 (18:41 +0000)
1  2
release/scripts/modules/bpy_types.py

@@@ -202,7 -202,7 +202,7 @@@ class _GenericBone
@property
def center(self):
"""The midpoint between the head and the tail."""
+         return (self.head + self.tail) * 0.5

@property
def length(self):
@@@ -373,8 -373,7 +373,8 @@@ class Mesh(bpy_types.ID)
"""
+        self.loops.add(sum((len(f) for f in faces)))

vertices_flat = [f for v in vertices for f in v]
self.vertices.foreach_set("co", vertices_flat)
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):
@@@ -442,20 -445,6 +442,20 @@@ class MeshFace(StructRNA)
ord_ind(verts[3], verts[0]),
)

+class MeshPolygon(StructRNA):
+    __slots__ = ()
+
+    @property
+    def edge_keys(self):
+        verts = self.vertices[:]
+        vlen = len(self.vertices)
+        return [ord_ind(verts[i], verts[(i+1) % vlen]) for i in range(vlen)]
+
+    @property
+    def loops(self):
+        start = self.loop_start
+        end = start + self.loop_total
+        return range(start, end)

class Text(bpy_types.ID):
__slots__ = ()
@@@ -650,7 -639,7 +650,7 @@@ class _GenericUI
draw_funcs = cls._dyn_ui_initialize()
try:
draw_funcs.remove(draw_func)
-         except ValueError:
+         except:
pass

index 26ec7be1002a5e1e4728afa35c4f2b4a84019490,92852120bca31abaf9bfcf021c0e48ea6fd822fa..ebfeb0c6301686507fe0c2240cb77a447f5a6d8e
@@@ -746,6 -746,9 +746,9 @@@ MTex *MeshImporter::assign_textures_to_

const CustomData *data = &me->fdata;
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
+       if(layer_index == -1) return NULL;
CustomDataLayer *cdl = &data->layers[layer_index+setindex];

/* set uvname to bind_vertex_input semantic */
@@@ -958,8 -961,8 +961,8 @@@ bool MeshImporter::write_geometry(cons