From 4c89c1d4c533a76ffec5c3c6befd07f27bfefb91 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 18 Jan 2019 18:45:36 +0900 Subject: [PATCH] spriteassembler: oob bodyparts will clip, as they should be ...to hide unwanted bodyparts in the skeleton --- .../spriteassembler/AssembleFrameGdx.kt | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/net/torvald/spriteassembler/AssembleFrameGdx.kt b/src/net/torvald/spriteassembler/AssembleFrameGdx.kt index 21d065378..e140fb00b 100644 --- a/src/net/torvald/spriteassembler/AssembleFrameGdx.kt +++ b/src/net/torvald/spriteassembler/AssembleFrameGdx.kt @@ -7,7 +7,9 @@ import net.torvald.terrarum.linearSearch import java.io.File /** - * Assembles the single frame of the animation, outputs Java AWT image. + * Assembles the single frame of the animation, outputs GDX Pixmap. + * + * The entire rendering is done by using pixmap. That is, no GPU access. * * Created by minjaesong on 2019-01-06. */ @@ -55,6 +57,8 @@ object AssembleSheetPixmap { AppLoader.printdbg(this, "Frame to draw: $frameName (R$animRow C$animFrame)") drawFrame(animRow, animFrame, canvas, bodyparts, transformList, assembleConfig) + + bodyparts.forEach { it?.dispose() } } private fun drawFrame(row: Int, column: Int, @@ -63,20 +67,25 @@ object AssembleSheetPixmap { transformList: List>, assembleConfig: AssembleConfig ) { + val tmpFrame = Pixmap(assembleConfig.fw, assembleConfig.fh, Pixmap.Format.RGBA8888) + bodyparts.forEachIndexed { index, image -> if (image != null) { val imgCentre = AssembleFrameBase.getCentreOf(image) val drawPos = transformList[index].second.invertY() + assembleConfig.origin - imgCentre - canvas.drawPixmap( - image, - (column - 1) * assembleConfig.fw + drawPos.x, - (row - 1) * assembleConfig.fh + drawPos.y - ) - - image.dispose() + tmpFrame.drawPixmap(image, drawPos.x, drawPos.y) } } + + canvas.drawPixmap( + tmpFrame, + (column - 1) * assembleConfig.fw, + (row - 1) * assembleConfig.fh + ) + + tmpFrame.dispose() + } }