def __getattr__(self, attr):
return getattr(self._mface, attr)
- def get_vertices_from(self, *vt):
+ def get_vertices_from(self, reverse, *vt):
+ verts=self.verts[:]
+ if reverse:
+ verts.reverse()
indices=[u.index for u in vt]
- flags=[(v.index in indices) for v in self.verts]
- l=len(self.verts)
+ flags=[(v.index in indices) for v in verts]
+ l=len(verts)
for i in range(l):
if flags[i] and not flags[(i+l-1)%l]:
- return self.verts[i:]+self.verts[:i]
+ return verts[i:]+verts[:i]
def get_edge(self, v1, v2):
i1=v1.index
sg.faces.append(other)
queue.append(other)
- def create_strip(self, face):
+ def create_strip(self, face, reverse):
edge=None
for e in face.edges:
other=e.other_face(face)
return None
if self.strip_debug:
- print "Starting strip from %s, edge %s"%([v.index for v in face.verts], (edge.v1.index, edge.v2.index))
+ print "Starting strip from %s, edge %s, reverse=%s"%([v.index for v in face.verts], (edge.v1.index, edge.v2.index), reverse)
- verts=face.get_vertices_from(edge.v1, edge.v2)
+ verts=face.get_vertices_from(reverse, edge.v1, edge.v2)
if len(verts)==3:
result=[verts[-1], verts[0]]
else:
result=[verts[-2], verts[-1]]
while 1:
- verts=face.get_vertices_from(*result[-2:])
+ verts=face.get_vertices_from(reverse, *result[-2:])
k=len(result)%2
if self.strip_debug:
print " Adding %s"%[v.index for v in verts]
best=score
if not face:
break
- strip=self.create_strip(face)
+ strip=self.create_strip(face, self.use_degen_tris and sum([len(s) for s in strips])%2)
if strip:
strips.append(strip)
if self.use_degen_tris:
big_strip=[]
- while strips:
- strip=None
+ for s in strips:
if big_strip:
- for i in range(len(strips)):
- if strips[i][0].index==big_strip[-1].index:
- strip=strips.pop(i)
- break
- if not strip:
- strip=strips.pop(0)
- if big_strip:
- if strip[0].index!=big_strip[-1].index:
- big_strip+=[big_strip[-1]]
- big_strip+=[strip[0]]
- big_strip+=strip
+ big_strip+=[big_strip[-1], s[0]]
+ big_strip+=s
for f in faces:
if not f.flag:
if big_strip:
big_strip+=[big_strip[-1], f.verts[0]]
- big_strip+=[f.verts[i] for i in (0, 1, -1)]
- if len(f.verts)==4:
- big_strip.append(f.verts[-2])
+ if len(big_strip)%2:
+ big_strip+=[f.verts[i] for i in (-1, -2, 0)]
+ if len(f.verts)==4:
+ big_strip.append(f.verts[1])
+ else:
+ big_strip+=[f.verts[i] for i in (0, 1, -1)]
+ if len(f.verts)==4:
+ big_strip.append(f.verts[-2])
f.flag=True
strips=[big_strip]
exp=Exporter(fn)
#exp.use_degen_tris=False
#exp.debug=True
+ #exp.strip_debug=True
exp.export()