Skip to content

Commit 2c39748

Browse files
committed
Fix some review findings
1 parent adcebcc commit 2c39748

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

korge-gradle-plugin/src/main/kotlin/korlibs/korge/gradle/texpacker/NewTexturePacker.kt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object NewTexturePacker {
4444
* Packs tilesets from the given folders into texture atlases.
4545
*
4646
* Each tileset image is split into individual tiles of the specified size.
47-
* These tiles are then checked for duplicates and then packed into atlases.
47+
* These tiles are checked for duplicates and then packed into atlases.
4848
*
4949
* @param folders The folders containing tilesets to be packed.
5050
* @param padding The padding to apply around each tile in the atlas.
@@ -56,7 +56,7 @@ object NewTexturePacker {
5656
padding: Int = 1,
5757
tileSize: Int = 16
5858
): List<AtlasInfo> {
59-
// Load all tilesets and creaet SimpleBitmap instances
59+
// Load all tilesets and create SimpleBitmap instances
6060
val tilesets: List<Pair<File, SimpleBitmap>> = getAllFiles(*folders).mapNotNull {
6161
try {
6262
it.relative to SimpleBitmap(it.file)
@@ -73,7 +73,6 @@ object NewTexturePacker {
7373
throw IllegalArgumentException("Tileset image size must be multiple of tileSize ($tileSize): $file with size ${image.width}x${image.height}")
7474
}
7575
images += image.splitInListOfTiles(file.nameWithoutExtension, tileSize)
76-
// println("Tileset: ${file}, images: $images")
7776
}
7877

7978
return packImages(images, enableRotation = false, enableTrimming = false, padding = padding, trimFileName = true, removeDuplicates = true)
@@ -149,8 +148,6 @@ object NewTexturePacker {
149148
}
150149
images
151150
}
152-
// println("duplicateFileMap: $tileMapping")
153-
// println("Processed images: $mappedImages")
154151

155152
// Add images to the packer (possibly without duplicates)
156153
packer.addArray(mappedImages.map { (file, image) ->
@@ -164,25 +161,22 @@ object NewTexturePacker {
164161
))
165162
})
166163

167-
// Building info which includes mapping duplicates
164+
// Building atlas info which includes mapping duplicates
168165
val outAtlases = arrayListOf<AtlasInfo>()
169-
// TODO for loop needs to go over tileMapping to map possible duplicate files to the same image area in the atlas
170166
for (bin in packer.bins) {
171167
val out = SimpleBitmap(bin.width, bin.height)
172168
val frames = linkedMapOf<String, Any?>()
173169

174170
for (rect in bin.rects) {
175171
val info = rect.raw as Info
176-
// val fileName = info.file.name
177-
// Check if this rect (image) is used by any duplicate files
172+
173+
// Check if this rect (image) is used by any duplicate files - if so, map them all to the same rect area in the atlas
178174
val files = tileMapping.filterValues { it == info.file }.keys
179175
for (file in files) {
180-
181176
val fileName = file.name
182177

183178
val chunk = if (rect.rot) info.trimmedImage.flipY().rotate90() else info.trimmedImage
184179
out.put(rect.x - padding, rect.y - padding, chunk.extrude(padding))
185-
//out.put(rect.x, rect.y, chunk)
186180

187181
val obj = LinkedHashMap<String, Any?>()
188182

@@ -206,7 +200,6 @@ object NewTexturePacker {
206200
}
207201
}
208202

209-
210203
val atlasOut = linkedMapOf<String, Any?>(
211204
"frames" to frames,
212205
"meta" to mapOf(

0 commit comments

Comments
 (0)