cookedModelsByID is now an object array instead of a dict

This commit is contained in:
David Vierra 2015-01-03 17:14:14 -10:00
parent 1eab1409a9
commit 62c15ac369
2 changed files with 10 additions and 8 deletions

View File

@ -52,8 +52,8 @@ class BlockModels(object):
self.modelQuads = {} self.modelQuads = {}
self._textureNames = set() self._textureNames = set()
self.firstTextures = {} # first texture found for each block - used for icons (xxx) self.firstTextures = {} # first texture found for each block - used for icons (xxx)
self.cookedModels = {} # nameAndState -> [face -> xyzuv, cullface] self.cookedModels = {} # nameAndState -> list[(xyzuvc, cullface)]
self.cookedModelsByID = {} # (id, meta) -> [face -> xyzuv, cullface] self.cookedModelsByID = numpy.zeros((256*16, 16), dtype=list) # (id, meta) -> list[(xyzuvc, cullface)]
for i, block in enumerate(blocktypes): for i, block in enumerate(blocktypes):
if i % 100 == 0: if i % 100 == 0:
@ -216,10 +216,10 @@ class BlockModels(object):
def cookQuads(self, textureAtlas): def cookQuads(self, textureAtlas):
cookedModels = {} cookedModels = {}
cookedModelsByID = {}
cdef int l, t, w, h cdef int l, t, w, h
cdef int u1, u2, v1, v2 cdef int u1, u2, v1, v2
cdef int uw, vh cdef int uw, vh
cdef list cookedQuads
for nameAndState, allQuads in self.modelQuads.iteritems(): for nameAndState, allQuads in self.modelQuads.iteritems():
cookedQuads = [] cookedQuads = []
for (box, face, texture, uv, cullface, shade, rotation, textureRotation, for (box, face, texture, uv, cullface, shade, rotation, textureRotation,
@ -268,10 +268,9 @@ class BlockModels(object):
cookedModels[nameAndState] = cookedQuads cookedModels[nameAndState] = cookedQuads
ID, meta = self.blocktypes.IDsByState[nameAndState] ID, meta = self.blocktypes.IDsByState[nameAndState]
cookedModelsByID[ID, meta] = cookedQuads self.cookedModelsByID[ID, meta] = cookedQuads
self.cookedModels = cookedModels self.cookedModels = cookedModels
self.cookedModelsByID = cookedModelsByID
def rotateVertices(self, rotation, variantXrot, variantYrot, variantZrot, xyzuvc): def rotateVertices(self, rotation, variantXrot, variantYrot, variantZrot, xyzuvc):
if rotation is not None: if rotation is not None:

View File

@ -34,8 +34,7 @@ class BlockModelMesh(object):
cdef numpy.ndarray[numpy.uint8_t, ndim=1] opaqueCube cdef numpy.ndarray[numpy.uint8_t, ndim=1] opaqueCube
chunk = self.sectionUpdate.chunkUpdate.chunk chunk = self.sectionUpdate.chunkUpdate.chunk
cx, cz = chunk.chunkPosition cdef short cy = self.sectionUpdate.cy
cy = self.sectionUpdate.cy
section = chunk.getSection(cy) section = chunk.getSection(cy)
if section is None: if section is None:
return return
@ -53,8 +52,12 @@ class BlockModelMesh(object):
cdef short dx, dy, dz, cdef short dx, dy, dz,
cdef unsigned short nx, ny, nz, nID cdef unsigned short nx, ny, nz, nID
cdef numpy.ndarray verts 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[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): for y in range(1, 17):
coords[1] = y - 1 + (cy << 4) coords[1] = y - 1 + (cy << 4)
for z in range(1, 17): for z in range(1, 17):
@ -68,7 +71,7 @@ class BlockModelMesh(object):
if renderType[ID] != 3: # only model blocks for now if renderType[ID] != 3: # only model blocks for now
continue continue
quads = blockModels.cookedModelsByID.get((ID, meta)) quads = cookedModelsByID[ID, meta]
if quads is None: if quads is None:
continue continue