[lua] Port of mesh whitespaces stripping. See #1232.

This commit is contained in:
badlogic 2018-12-22 15:07:26 +01:00
parent bcab346cde
commit 0312d2725d

View File

@ -67,14 +67,26 @@ function MeshAttachment:updateUVs ()
width = 1 width = 1
height = 1 height = 1
else else
u = self.region.u; local region = self.region
v = self.region.v; local textureWidth = region.page.width
width = self.region.u2 - u; local textureHeight = region.page.height
height = self.region.v2 - v; if region.rotate then
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight
width = region.originalHeight / textureWidth
height = region.originalWidth / textureHeight
else
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
end
end end
local regionUVs = self.regionUVs local regionUVs = self.regionUVs
if not self.uvs or (#self.uvs ~= #regionUVs) then self.uvs = utils.newNumberArray(#regionUVs) end if not self.uvs or (#self.uvs ~= #regionUVs) then self.uvs = utils.newNumberArray(#regionUVs) end
local uvs = self.uvs local uvs = self.uvs
if self.region and self.region.rotate then if self.region and self.region.rotate then
local i = 0 local i = 0
local n = #uvs local n = #uvs