store cooked models by id, meta. remove face from quad tuples

This commit is contained in:
David Vierra 2015-01-03 13:25:57 -10:00
parent d997a44264
commit c23cad678b
2 changed files with 12 additions and 6 deletions

View File

@ -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:

View File

@ -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