Hidden block states are stashed in cookedModelsByBlockState
getActualBlockState rule written for grass with snow on top.
This commit is contained in:
parent
4263b184fa
commit
5037655787
@ -14,6 +14,9 @@ cdef struct ModelQuadList:
|
|||||||
int count
|
int count
|
||||||
ModelQuad *quads
|
ModelQuad *quads
|
||||||
|
|
||||||
|
cdef class ModelQuadListObj(object):
|
||||||
|
cdef ModelQuadList quadList
|
||||||
|
|
||||||
cdef class BlockModels:
|
cdef class BlockModels:
|
||||||
cdef object resourceLoader
|
cdef object resourceLoader
|
||||||
cdef object blocktypes
|
cdef object blocktypes
|
||||||
@ -25,6 +28,7 @@ cdef class BlockModels:
|
|||||||
cdef public object firstTextures
|
cdef public object firstTextures
|
||||||
cdef object cookedModels
|
cdef object cookedModels
|
||||||
cdef ModelQuadList cookedModelsByID[4096][16]
|
cdef ModelQuadList cookedModelsByID[4096][16]
|
||||||
|
cdef dict cookedModelsByBlockState
|
||||||
cdef object cooked
|
cdef object cooked
|
||||||
|
|
||||||
cdef object grassImage
|
cdef object grassImage
|
||||||
|
@ -39,6 +39,10 @@ cdef struct ModelQuadList:
|
|||||||
int count
|
int count
|
||||||
ModelQuad *quads
|
ModelQuad *quads
|
||||||
|
|
||||||
|
cdef class ModelQuadListObj(object):
|
||||||
|
pass # defined in blockmodels.pxd
|
||||||
|
|
||||||
|
|
||||||
cdef class FaceInfo(object):
|
cdef class FaceInfo(object):
|
||||||
cdef:
|
cdef:
|
||||||
float x1, y1, z1, x2, y2, z2
|
float x1, y1, z1, x2, y2, z2
|
||||||
@ -167,6 +171,7 @@ cdef class BlockModels(object):
|
|||||||
self.modelStateJsons = {}
|
self.modelStateJsons = {}
|
||||||
self.quadsByResourcePathVariant = {}
|
self.quadsByResourcePathVariant = {}
|
||||||
self.blockStatesByResourcePathVariant = defaultdict(list)
|
self.blockStatesByResourcePathVariant = defaultdict(list)
|
||||||
|
self.cookedModelsByBlockState = {}
|
||||||
|
|
||||||
self._texturePaths = set()
|
self._texturePaths = 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)
|
||||||
@ -246,6 +251,7 @@ cdef class BlockModels(object):
|
|||||||
log.debug("Model for variant %s#%s previously loaded", resourcePath, resourceVariant)
|
log.debug("Model for variant %s#%s previously loaded", resourcePath, resourceVariant)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
self.blockStatesByResourcePathVariant[resourcePath, resourceVariant].append(nameAndState)
|
||||||
internalName, blockState = (nameAndState.split("[") + [""])[:2] # _splitInternalName
|
internalName, blockState = (nameAndState.split("[") + [""])[:2] # _splitInternalName
|
||||||
block = blocktypes.get(internalName, None)
|
block = blocktypes.get(internalName, None)
|
||||||
if block is None:
|
if block is None:
|
||||||
@ -502,6 +508,7 @@ cdef class BlockModels(object):
|
|||||||
cdef unsigned char shade
|
cdef unsigned char shade
|
||||||
cdef ModelQuadList modelQuads
|
cdef ModelQuadList modelQuads
|
||||||
cdef ModelQuadList unknownBlockModel
|
cdef ModelQuadList unknownBlockModel
|
||||||
|
cdef ModelQuadListObj modelQuadsObj = None
|
||||||
cdef list allQuads
|
cdef list allQuads
|
||||||
UNKNOWN_BLOCK = u'MCEDIT_UNKNOWN'
|
UNKNOWN_BLOCK = u'MCEDIT_UNKNOWN'
|
||||||
|
|
||||||
@ -615,6 +622,9 @@ cdef class BlockModels(object):
|
|||||||
try:
|
try:
|
||||||
ID, meta = self.blocktypes.IDsByState[nameAndState]
|
ID, meta = self.blocktypes.IDsByState[nameAndState]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
modelQuadsObj = ModelQuadListObj()
|
||||||
|
modelQuadsObj.quadList = modelQuads
|
||||||
|
self.cookedModelsByBlockState[nameAndState] = modelQuadsObj
|
||||||
continue # xxx put models for hidden states where??
|
continue # xxx put models for hidden states where??
|
||||||
|
|
||||||
# cookedModels[nameAndState] = cookedQuads
|
# cookedModels[nameAndState] = cookedQuads
|
||||||
@ -631,6 +641,7 @@ cdef class BlockModels(object):
|
|||||||
self.cookedModels = cookedModels
|
self.cookedModels = cookedModels
|
||||||
self.cooked = True
|
self.cooked = True
|
||||||
|
|
||||||
|
# import pprint; pprint.pprint(dict(self.blockStatesByResourcePathVariant)); raise SystemExit
|
||||||
self.cookFluidQuads()
|
self.cookFluidQuads()
|
||||||
|
|
||||||
def cookFluidQuads(self):
|
def cookFluidQuads(self):
|
||||||
|
@ -107,6 +107,9 @@ class BlockModelMesh(object):
|
|||||||
cdef unsigned short stoneSlab2ID = getID("minecraft:stone_slab2")
|
cdef unsigned short stoneSlab2ID = getID("minecraft:stone_slab2")
|
||||||
cdef unsigned short woodenSlabID = getID("minecraft:wooden_slab")
|
cdef unsigned short woodenSlabID = getID("minecraft:wooden_slab")
|
||||||
|
|
||||||
|
cdef unsigned short grassID = getID("minecraft:grass")
|
||||||
|
cdef unsigned short snowID = getID("minecraft:snow")
|
||||||
|
cdef unsigned short snowLayerID = getID("minecraft:snow_layer")
|
||||||
|
|
||||||
#cdef char fancyGraphics = self.sectionUpdate.fancyGraphics
|
#cdef char fancyGraphics = self.sectionUpdate.fancyGraphics
|
||||||
cdef char fancyGraphics = True
|
cdef char fancyGraphics = True
|
||||||
@ -157,6 +160,8 @@ class BlockModelMesh(object):
|
|||||||
cdef const unsigned char * tintColor
|
cdef const unsigned char * tintColor
|
||||||
|
|
||||||
cdef char doCull = 0
|
cdef char doCull = 0
|
||||||
|
cdef char foundActualState
|
||||||
|
cdef blockmodels.ModelQuadListObj quadListObj
|
||||||
|
|
||||||
if vertexBuffer == NULL:
|
if vertexBuffer == NULL:
|
||||||
return
|
return
|
||||||
@ -170,9 +175,30 @@ class BlockModelMesh(object):
|
|||||||
if ID == 0:
|
if ID == 0:
|
||||||
continue
|
continue
|
||||||
meta = areaData[y, z, x]
|
meta = areaData[y, z, x]
|
||||||
|
foundActualState = 0
|
||||||
|
|
||||||
if renderType[ID] == 3: # model blocks
|
if renderType[ID] == 3: # model blocks
|
||||||
# xxx cookedModelsByBlockState
|
# if this block has actualStates, get its actualState
|
||||||
|
# using its neighbors and look up that state's models
|
||||||
|
# in blockModels.... ... ...
|
||||||
|
|
||||||
|
# to get its actual state, we need to get its current state from
|
||||||
|
# its id and meta, parse the state into properties,
|
||||||
|
# change some property values into others according to
|
||||||
|
# actualState logic, cram them back into a blockState string,
|
||||||
|
# then use the new state to look up the model
|
||||||
|
# ... ... ...
|
||||||
|
# all without doing a dict lookup for every block...
|
||||||
|
#
|
||||||
|
if grassID and (ID == grassID):
|
||||||
|
if (areaBlocks[y+1, z, x] == snowID
|
||||||
|
or areaBlocks[y+1, z, x] == snowLayerID):
|
||||||
|
actualState = "minecraft:grass[snowy=true]"
|
||||||
|
quadListObj = blockModels.cookedModelsByBlockState[actualState]
|
||||||
|
quads = quadListObj.quadList
|
||||||
|
foundActualState = 1
|
||||||
|
|
||||||
|
if foundActualState == 0:
|
||||||
quads = blockModels.cookedModelsByID[ID][meta]
|
quads = blockModels.cookedModelsByID[ID][meta]
|
||||||
if quads.count == 0:
|
if quads.count == 0:
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user