Only cook quads when needed - speeds up world list
This commit is contained in:
parent
cd632c6737
commit
864990429d
@ -54,6 +54,7 @@ class BlockModels(object):
|
|||||||
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 -> list[(xyzuvc, cullface)]
|
self.cookedModels = {} # nameAndState -> list[(xyzuvc, cullface)]
|
||||||
self.cookedModelsByID = numpy.zeros((256*16, 16), dtype=list) # (id, meta) -> list[(xyzuvc, cullface)]
|
self.cookedModelsByID = numpy.zeros((256*16, 16), dtype=list) # (id, meta) -> list[(xyzuvc, cullface)]
|
||||||
|
self.cooked = False
|
||||||
|
|
||||||
for i, block in enumerate(blocktypes):
|
for i, block in enumerate(blocktypes):
|
||||||
if i % 100 == 0:
|
if i % 100 == 0:
|
||||||
@ -215,6 +216,9 @@ class BlockModels(object):
|
|||||||
return iter(self._textureNames)
|
return iter(self._textureNames)
|
||||||
|
|
||||||
def cookQuads(self, textureAtlas):
|
def cookQuads(self, textureAtlas):
|
||||||
|
if self.cooked:
|
||||||
|
return
|
||||||
|
log.info("Cooking quads for %d models...", len(self.modelQuads))
|
||||||
cookedModels = {}
|
cookedModels = {}
|
||||||
cdef int l, t, w, h
|
cdef int l, t, w, h
|
||||||
cdef int u1, u2, v1, v2
|
cdef int u1, u2, v1, v2
|
||||||
@ -269,8 +273,9 @@ class BlockModels(object):
|
|||||||
cookedModels[nameAndState] = cookedQuads
|
cookedModels[nameAndState] = cookedQuads
|
||||||
ID, meta = self.blocktypes.IDsByState[nameAndState]
|
ID, meta = self.blocktypes.IDsByState[nameAndState]
|
||||||
self.cookedModelsByID[ID, meta] = cookedQuads
|
self.cookedModelsByID[ID, meta] = cookedQuads
|
||||||
|
|
||||||
self.cookedModels = cookedModels
|
self.cookedModels = cookedModels
|
||||||
|
self.cooked = True
|
||||||
|
|
||||||
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:
|
||||||
|
@ -39,7 +39,10 @@ class BlockModelMesh(object):
|
|||||||
if section is None:
|
if section is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
blockModels = self.sectionUpdate.chunkUpdate.updateTask.textureAtlas.blockModels
|
atlas = self.sectionUpdate.chunkUpdate.updateTask.textureAtlas
|
||||||
|
blockModels = atlas.blockModels
|
||||||
|
blockModels.cookQuads(atlas)
|
||||||
|
|
||||||
blocktypes = self.sectionUpdate.blocktypes
|
blocktypes = self.sectionUpdate.blocktypes
|
||||||
areaBlocks = self.sectionUpdate.areaBlocks
|
areaBlocks = self.sectionUpdate.areaBlocks
|
||||||
data = section.Data
|
data = section.Data
|
||||||
|
@ -200,8 +200,6 @@ class TextureAtlas(object):
|
|||||||
usedSize = sum(sum(width * height for _, _, _, width, height, _ in slot.textures) for slot in slots) * 4
|
usedSize = sum(sum(width * height for _, _, _, width, height, _ in slot.textures) for slot in slots) * 4
|
||||||
log.info("Terrain atlas created for world %s (%d/%d kB)", util.displayName(self._filename), usedSize / 1024,
|
log.info("Terrain atlas created for world %s (%d/%d kB)", util.displayName(self._filename), usedSize / 1024,
|
||||||
totalSize / 1024)
|
totalSize / 1024)
|
||||||
if self.overrideMaxSize is None:
|
|
||||||
self.blockModels.cookQuads(self)
|
|
||||||
|
|
||||||
#file("terrain-%sw-%sh.raw" % (atlasWidth, atlasHeight), "wb").write(texData.tostring())
|
#file("terrain-%sw-%sh.raw" % (atlasWidth, atlasHeight), "wb").write(texData.tostring())
|
||||||
#raise SystemExit
|
#raise SystemExit
|
||||||
|
Reference in New Issue
Block a user