improvement(boxes): don't export as a texture the shadow canvas

As now the canvas drawing isn't affected by the transform, it should be 
safe to not export it as a texture anymore.
This commit is contained in:
Kazhnuz 2019-07-15 10:11:11 +02:00
parent 79aff589b9
commit 932ec26283

View file

@ -40,7 +40,7 @@ function Box3D:new(owner, w, h, d)
self.texture = {} self.texture = {}
self:setTopTexture() self:setTopTexture()
self:setBottomTexture() self:setBottomTexture()
self.texture.shadows = nil self.texture.shadows = love.graphics.newCanvas(self.w, self.h)
self:register() self:register()
end end
@ -123,19 +123,14 @@ end
function Box3D:redrawShadowCanvas() function Box3D:redrawShadowCanvas()
if (self.needRedraw) then if (self.needRedraw) then
local canvas = love.graphics.newCanvas(self.w, self.h) love.graphics.setCanvas( self.texture.shadows )
love.graphics.setCanvas( canvas ) love.graphics.clear()
for i,v in ipairs(self.shadowSources) do for i,v in ipairs(self.shadowSources) do
v.actor:drawShadow(v.x, v.y) v.actor:drawShadow(v.x, v.y)
end end
love.graphics.setCanvas( ) love.graphics.setCanvas( )
local imagedata = canvas:newImageData()
self.texture.shadows = love.graphics.newImage( imagedata )
imagedata:release()
canvas:release()
self.needRedraw = false self.needRedraw = false
end end
end end