store cooked models by id, meta. remove face from quad tuples
This commit is contained in:
parent
d997a44264
commit
c23cad678b
@ -47,6 +47,7 @@ class BlockModels(object):
|
|||||||
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 -> [face -> xyzuv, cullface]
|
||||||
|
self.cookedModelsByID = {} # (id, meta) -> [face -> xyzuv, cullface]
|
||||||
|
|
||||||
for i, block in enumerate(blocktypes):
|
for i, block in enumerate(blocktypes):
|
||||||
if i % 100 == 0:
|
if i % 100 == 0:
|
||||||
@ -209,6 +210,7 @@ class BlockModels(object):
|
|||||||
|
|
||||||
def cookQuads(self, textureAtlas):
|
def cookQuads(self, textureAtlas):
|
||||||
cookedModels = {}
|
cookedModels = {}
|
||||||
|
cookedModelsByID = {}
|
||||||
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,
|
||||||
@ -252,11 +254,14 @@ class BlockModels(object):
|
|||||||
else:
|
else:
|
||||||
xyzuvc.view('uint8')[:, 20:] = 0xff
|
xyzuvc.view('uint8')[:, 20:] = 0xff
|
||||||
|
|
||||||
cookedQuads.append((face, xyzuvc, cullface))
|
cookedQuads.append((xyzuvc, cullface))
|
||||||
|
|
||||||
cookedModels[nameAndState] = cookedQuads
|
cookedModels[nameAndState] = cookedQuads
|
||||||
|
ID, meta = self.blocktypes.IDsByState[nameAndState]
|
||||||
|
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:
|
||||||
|
@ -17,7 +17,7 @@ class BlockModelMesh(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
:param sectionUpdate:
|
:param sectionUpdate:
|
||||||
:type sectionUpdate: SectionUpdate
|
:type sectionUpdate: mcedit2.rendering.chunkupdate.SectionUpdate
|
||||||
:return:
|
:return:
|
||||||
:rtype:
|
:rtype:
|
||||||
"""
|
"""
|
||||||
@ -52,10 +52,11 @@ class BlockModelMesh(object):
|
|||||||
block = blocktypes[ID, meta]
|
block = blocktypes[ID, meta]
|
||||||
if block.renderType != 3: # only model blocks for now
|
if block.renderType != 3: # only model blocks for now
|
||||||
continue
|
continue
|
||||||
nameAndState = block.internalName + block.blockState
|
quads = blockModels.cookedModelsByID.get((ID, meta))
|
||||||
quads = blockModels.cookedModels[nameAndState]
|
if quads is None:
|
||||||
|
continue
|
||||||
|
|
||||||
for face, xyzuvc, cullface in quads:
|
for xyzuvc, cullface in quads:
|
||||||
if cullface is not None:
|
if cullface is not None:
|
||||||
dx, dy, dz = cullface.vector
|
dx, dy, dz = cullface.vector
|
||||||
nx = x + dx
|
nx = x + dx
|
||||||
|
Reference in New Issue
Block a user