From c00220a410968f1b36eef61b0a3d0ca26d685269 Mon Sep 17 00:00:00 2001 From: TigerKat Date: Sun, 28 Mar 2021 16:53:21 +0930 Subject: [PATCH] bugfix: Importing of .geos would fail if there are duplicate vertices. --- __init__.py | 2 +- geo.py | 7 ++++++- geomesh.py | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 8836d51..73713f8 100644 --- a/__init__.py +++ b/__init__.py @@ -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)", diff --git a/geo.py b/geo.py index 0b1b67e..b87f765 100755 --- a/geo.py +++ b/geo.py @@ -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): diff --git a/geomesh.py b/geomesh.py index 52d846a..835f394 100644 --- a/geomesh.py +++ b/geomesh.py @@ -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):