diff --git a/src/mcedit2/rendering/blockmodels.pyx b/src/mcedit2/rendering/blockmodels.pyx index d783ebe..cbbd72b 100644 --- a/src/mcedit2/rendering/blockmodels.pyx +++ b/src/mcedit2/rendering/blockmodels.pyx @@ -47,6 +47,7 @@ class BlockModels(object): self._textureNames = set() self.firstTextures = {} # first texture found for each block - used for icons (xxx) self.cookedModels = {} # nameAndState -> [face -> xyzuv, cullface] + self.cookedModelsByID = {} # (id, meta) -> [face -> xyzuv, cullface] for i, block in enumerate(blocktypes): if i % 100 == 0: @@ -209,6 +210,7 @@ class BlockModels(object): def cookQuads(self, textureAtlas): cookedModels = {} + cookedModelsByID = {} for nameAndState, allQuads in self.modelQuads.iteritems(): cookedQuads = [] for (box, face, texture, uv, cullface, shade, rotation, textureRotation, @@ -252,11 +254,14 @@ class BlockModels(object): else: xyzuvc.view('uint8')[:, 20:] = 0xff - cookedQuads.append((face, xyzuvc, cullface)) + cookedQuads.append((xyzuvc, cullface)) cookedModels[nameAndState] = cookedQuads + ID, meta = self.blocktypes.IDsByState[nameAndState] + cookedModelsByID[ID, meta] = cookedQuads self.cookedModels = cookedModels + self.cookedModelsByID = cookedModelsByID def rotateVertices(self, rotation, variantXrot, variantYrot, variantZrot, xyzuvc): if rotation is not None: diff --git a/src/mcedit2/rendering/modelmesh.pyx b/src/mcedit2/rendering/modelmesh.pyx index feb3994..98ffc77 100644 --- a/src/mcedit2/rendering/modelmesh.pyx +++ b/src/mcedit2/rendering/modelmesh.pyx @@ -17,7 +17,7 @@ class BlockModelMesh(object): """ :param sectionUpdate: - :type sectionUpdate: SectionUpdate + :type sectionUpdate: mcedit2.rendering.chunkupdate.SectionUpdate :return: :rtype: """ @@ -36,7 +36,7 @@ class BlockModelMesh(object): blocktypes = self.sectionUpdate.blocktypes areaBlocks = self.sectionUpdate.areaBlocks faceQuadVerts = [] - + cdef unsigned short y, z, x, ID, meta cdef short dx, dy, dz, cdef unsigned short nx, ny, nz, nID @@ -52,10 +52,11 @@ class BlockModelMesh(object): block = blocktypes[ID, meta] if block.renderType != 3: # only model blocks for now continue - nameAndState = block.internalName + block.blockState - quads = blockModels.cookedModels[nameAndState] + quads = blockModels.cookedModelsByID.get((ID, meta)) + if quads is None: + continue - for face, xyzuvc, cullface in quads: + for xyzuvc, cullface in quads: if cullface is not None: dx, dy, dz = cullface.vector nx = x + dx