bugfix: Importing of .geos would fail if there are duplicate vertices.

master
TigerKat 4 years ago
parent bdfc38e82e
commit c00220a410

@ -2,7 +2,7 @@
bl_info = {
"name": "City of Heroes (.geo)",
"author": "TigerKat",
"version": (0, 2, 1),
"version": (0, 2, 2),
"blender": (2, 80, 0),
"location": "File > Import/Export,",
"description": "City of Heroes (.geo)",

@ -933,11 +933,16 @@ class Model:
weights = []
#print(" weights: %s" % (weights, ))
v = GeoVertex(coord, normal, uv, weights)
geomesh.getGeoVertexIndex(v)
geomesh.getGeoVertexIndexNew(v)
texture_indexes = []
for t in self.tex_idx:
texture_indexes += [geomesh.getTextureIndex(self.geo.header_texnames[t[0]])] * t[1]
#print("len(self.verts): %s" % (len(self.verts), ))
#print("len(geomesh.geovertex): %s" % (len(geomesh.geovertex), ))
#print("%s" % (self.tex_idx, ))
#print("%s" % (texture_indexes, ))
for i, t in enumerate(self.tris):
#print(" - %s: %s" % (i, t))
geomesh.addFace([geomesh.geovertex[t[0]], geomesh.geovertex[t[1]], geomesh.geovertex[t[2]]], texture_indexes[i])
return geomesh
def loadFromGeoMesh(self, geomesh):

@ -59,6 +59,13 @@ class GeoMesh:
self.face = []
self.have_weights = False
self.have_uvs = True
def getGeoVertexIndexNew(self, gv):
index = self.geovertex_map.get(gv, len(self.geovertex))
if index == len(self.geovertex):
self.geovertex_map[gv] = index
index = len(self.geovertex)
self.geovertex.append(gv)
return index
def getGeoVertexIndex(self, gv):
index = self.geovertex_map.get(gv, len(self.geovertex))
if index == len(self.geovertex):

Loading…
Cancel
Save