Don't uselessly create FloatBoxes, add static types in buildBoxQuads
This commit is contained in:
parent
9f1163f69e
commit
81f35b808b
@ -266,20 +266,29 @@ cdef class BlockModels(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def buildBoxQuads(self, element, nameAndState, textureVars, variantXrot, variantYrot, variantZrot, variantMatrix, blockColor):
|
def buildBoxQuads(self, dict element, unicode nameAndState, dict textureVars,
|
||||||
|
short variantXrot, short variantYrot, short variantZrot,
|
||||||
|
cnp.ndarray variantMatrix, tuple blockColor):
|
||||||
quads = []
|
quads = []
|
||||||
shade = element.get("shade", True)
|
shade = element.get("shade", True)
|
||||||
fromPoint = Vector(*element["from"])
|
|
||||||
toPoint = Vector(*element["to"])
|
cdef float ox, oy, oz
|
||||||
fromPoint /= 16.
|
|
||||||
toPoint /= 16.
|
|
||||||
box = FloatBox(fromPoint, maximum=toPoint)
|
|
||||||
ox, oy, oz, elementMatrix = elementRotation(element.get("rotation"))
|
ox, oy, oz, elementMatrix = elementRotation(element.get("rotation"))
|
||||||
cdef float x1, y1, z1
|
cdef float x1, y1, z1, x2, y2, z2
|
||||||
x1, y1, z1 = box.origin
|
x1, y1, z1 = element["from"]
|
||||||
cdef float x2, y2, z2
|
x2, y2, z2 = element["to"]
|
||||||
x2, y2, z2 = box.maximum
|
|
||||||
|
x1 /= 16.
|
||||||
|
y1 /= 16.
|
||||||
|
z1 /= 16.
|
||||||
|
x2 /= 16.
|
||||||
|
y2 /= 16.
|
||||||
|
z2 /= 16.
|
||||||
|
|
||||||
cdef short u1, v1, u2, v2
|
cdef short u1, v1, u2, v2
|
||||||
|
cdef unicode texture, lasttexvar
|
||||||
|
cdef short i
|
||||||
|
|
||||||
|
|
||||||
for face, info in element["faces"].iteritems():
|
for face, info in element["faces"].iteritems():
|
||||||
face = facesByCardinal[face]
|
face = facesByCardinal[face]
|
||||||
@ -288,7 +297,7 @@ cdef class BlockModels(object):
|
|||||||
|
|
||||||
u1, v1, u2, v2 = info.get("uv", [0, 0, 16, 16])
|
u1, v1, u2, v2 = info.get("uv", [0, 0, 16, 16])
|
||||||
|
|
||||||
lastvar = texture
|
lasttexvar = texture
|
||||||
|
|
||||||
tintindex = info.get("tintindex")
|
tintindex = info.get("tintindex")
|
||||||
if tintindex is not None:
|
if tintindex is not None:
|
||||||
@ -299,9 +308,9 @@ cdef class BlockModels(object):
|
|||||||
# resolve texture variables
|
# resolve texture variables
|
||||||
for i in range(30):
|
for i in range(30):
|
||||||
if texture is None:
|
if texture is None:
|
||||||
raise ValueError("Texture variable %s is not assigned." % lastvar)
|
raise ValueError("Texture variable %s is not assigned." % lasttexvar)
|
||||||
elif texture[0] == "#":
|
elif texture[0] == u"#":
|
||||||
lastvar = texture
|
lasttexvar = texture
|
||||||
texture = textureVars[texture[1:]]
|
texture = textureVars[texture[1:]]
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user