X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=blender%2Fio_mspgl%2Fmesh.py;fp=blender%2Fio_mspgl%2Fmesh.py;h=d9ae6b760ff545c8043269bb9e120b597f8b05f7;hp=da5e76aaf34ed259d48ff5f3a0b872c32f36cdda;hb=e1d07383b29e8581230b50f45606192d1f21f5dd;hpb=f398c65c9e741ca4919a0770e096c15e8d33c1c2 diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index da5e76aa..d9ae6b76 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -70,8 +70,12 @@ class Vertex: class VertexGroup: def __init__(self, group): - self.group = group.group - self.weight = group.weight + if group: + self.group = group.group + self.weight = group.weight + else: + self.group = 0 + self.weight = 0.0 class Face: @@ -162,8 +166,9 @@ class Mesh: # Clone basic data self.vertices = [Vertex(v) for v in mesh.vertices] - for v in self.vertices: - v.groups = [VertexGroup(g) for g in v.groups] + if self.vertex_groups: + for v in self.vertices: + v.groups = [VertexGroup(g) for g in v.groups] self.faces = [Face(f) for f in mesh.polygons] self.edges = [Edge(e) for e in mesh.edges] @@ -172,6 +177,7 @@ class Mesh: self.use_auto_smooth = mesh.use_auto_smooth self.auto_smooth_angle = mesh.auto_smooth_angle + self.max_groups_per_vertex = mesh.max_groups_per_vertex # Clone only the desired UV layers if mesh.use_uv=='NONE' or not mesh.uv_layers: @@ -371,6 +377,9 @@ class Mesh: progress.pop_task() def prepare_vertex_groups(self, obj): + if not self.vertex_groups: + return + for v in self.vertices: if v.groups: weight_sum = sum(g.weight for g in v.groups) @@ -378,6 +387,8 @@ class Mesh: weight_scale = weight_sum/sum(g.weight for g in v.groups) for g in v.groups: g.weight *= weight_scale + while len(v.groups)