diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-30 02:14:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-30 02:14:41 +0300 |
commit | 2bef608fb391fda4c87238abf10e2d3823a883d8 (patch) | |
tree | b047c1e065159d2783738ef979572b90848f3fce /release | |
parent | d98093a91ac7ce96ab6b1e14168493f9f69f379d (diff) |
- new objects added from the rna api defaulted to quat rotation, not even using an identity quat.
- making meshes in python isnt nice at the moment, added a helper function.
mesh.from_pydata(verts, edges, faces)
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 13d48f05d18..fb1d2978c90 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -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): |