- new objects added from the rna api defaulted to quat rotation, not even using an...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 29 Nov 2009 23:14:41 +0000 (23:14 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 29 Nov 2009 23:14:41 +0000 (23:14 +0000)
- making meshes in python isnt nice at the moment, added a helper function.
    mesh.from_pydata(verts, edges, faces)

release/scripts/modules/bpy_types.py
source/blender/blenkernel/intern/object.c

index 13d48f05d187083dcbd25e0f77832c49a21c0e31..fb1d2978c90589b371d7b67af043e7787f0c98d1 100644 (file)
@@ -128,6 +128,32 @@ def ord_ind(i1,i2):
     return i2,i1
 
 class Mesh(bpy_types.ID):
+    
+    def from_pydata(self, verts, edges, faces):
+        '''
+        Make a mesh from a list of verts/edges/faces
+        Until we have a nicer way to make geometry, use this.
+        '''
+        self.add_geometry(len(verts), len(edges), len(faces))
+        
+        verts_flat = [f for v in verts for f in v]
+        self.verts.foreach_set("co", verts_flat)
+        del verts_flat
+        
+        edges_flat = [i for e in edges for i in e]
+        self.edges.foreach_set("verts", edges_flat)
+        del edges_flat
+        
+        def treat_face(f):
+            if len(f) == 3:
+                return f[0], f[1], f[2], 0
+            elif f[3] == 0:
+                return f[3], f[0], f[1], f[2]
+            return f
+        
+        faces_flat = [v for f in faces for v in treat_face(f)]
+        self.faces.foreach_set("verts_raw", faces_flat)
+        del faces_flat
 
     @property
     def edge_keys(self):
index 73a1d2023a2019839169152e58375459dcd8502c..69c57fb38fe68c5eed8d0f43f97b087b81facbec 100644 (file)
@@ -963,6 +963,7 @@ Object *add_only_object(int type, char *name)
        /* default object vars */
        ob->type= type;
        /* ob->transflag= OB_QUAT; */
+       ob->rotmode= ROT_MODE_EUL;
 
 #if 0 /* not used yet */
        unit_qt(ob->quat);