diff --git a/src/mcedit2/rendering/blockmodels.pyx b/src/mcedit2/rendering/blockmodels.pyx index 9bca672..dd46fba 100644 --- a/src/mcedit2/rendering/blockmodels.pyx +++ b/src/mcedit2/rendering/blockmodels.pyx @@ -52,8 +52,8 @@ class BlockModels(object): self.modelQuads = {} 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] + self.cookedModels = {} # nameAndState -> list[(xyzuvc, cullface)] + self.cookedModelsByID = numpy.zeros((256*16, 16), dtype=list) # (id, meta) -> list[(xyzuvc, cullface)] for i, block in enumerate(blocktypes): if i % 100 == 0: @@ -216,10 +216,10 @@ class BlockModels(object): def cookQuads(self, textureAtlas): cookedModels = {} - cookedModelsByID = {} cdef int l, t, w, h cdef int u1, u2, v1, v2 cdef int uw, vh + cdef list cookedQuads for nameAndState, allQuads in self.modelQuads.iteritems(): cookedQuads = [] for (box, face, texture, uv, cullface, shade, rotation, textureRotation, @@ -268,10 +268,9 @@ class BlockModels(object): cookedModels[nameAndState] = cookedQuads ID, meta = self.blocktypes.IDsByState[nameAndState] - cookedModelsByID[ID, meta] = cookedQuads + self.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 c2002a9..004352e 100644 --- a/src/mcedit2/rendering/modelmesh.pyx +++ b/src/mcedit2/rendering/modelmesh.pyx @@ -34,8 +34,7 @@ class BlockModelMesh(object): cdef numpy.ndarray[numpy.uint8_t, ndim=1] opaqueCube chunk = self.sectionUpdate.chunkUpdate.chunk - cx, cz = chunk.chunkPosition - cy = self.sectionUpdate.cy + cdef short cy = self.sectionUpdate.cy section = chunk.getSection(cy) if section is None: return @@ -53,8 +52,12 @@ class BlockModelMesh(object): cdef short dx, dy, dz, cdef unsigned short nx, ny, nz, nID cdef numpy.ndarray verts + cdef list quads + cdef tuple quad cdef numpy.ndarray[numpy.uint16_t, ndim=1] coords = numpy.zeros(3, dtype=numpy.uint16) + cdef numpy.ndarray[list, ndim=2] cookedModelsByID = blockModels.cookedModelsByID + for y in range(1, 17): coords[1] = y - 1 + (cy << 4) for z in range(1, 17): @@ -68,7 +71,7 @@ class BlockModelMesh(object): if renderType[ID] != 3: # only model blocks for now continue - quads = blockModels.cookedModelsByID.get((ID, meta)) + quads = cookedModelsByID[ID, meta] if quads is None: continue