In particular, var xform_inv = xform.affine_inverse() was erroring out for me, which I was able to resolve by throwing in an if to stop trying to bake the lightmap UVs for an empty tree:
func calc_lightmap_uvs():
var packer:FacePacker = FacePacker.new()
var max_dim:float = max(bounds.size.x, bounds.size.y, bounds.size.z)
var tree:FacePacker.FaceTree = packer.build_faces(self, max_dim * .1)
if tree.bounds.size != Vector2.ZERO:
var xform:Transform2D = Transform2D.IDENTITY
xform = xform.scaled(tree.bounds.size)
var xform_inv = xform.affine_inverse()
for ft in tree.face_list:
var face:FaceInfo = faces[ft.face_index]
face.lightmap_uvs = xform_inv * ft.points
I'm not sure if that's a legitimate solution or a band-aid, I just don't have enough context on the inner workings of this project to totally grok what's going on.
In particular,
var xform_inv = xform.affine_inverse()
was erroring out for me, which I was able to resolve by throwing in an if to stop trying to bake the lightmap UVs for an empty tree:I'm not sure if that's a legitimate solution or a band-aid, I just don't have enough context on the inner workings of this project to totally grok what's going on.